forked from alisw/AliRoot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTOFPreprocessorFDR.C
159 lines (127 loc) · 4.65 KB
/
TOFPreprocessorFDR.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
/*
$Id$
*/
// This class runs the test TOF preprocessor
// It uses AliTestShuttle to simulate a full Shuttle process
// The input data is created in the functions
// CreateDCSAliasMap() creates input that would in the same way come from DCS
// ReadDCSAliasMap() reads from a file
// CreateInputFilesMap() creates a list of local files, that can be accessed by the shuttle
extern TBenchmark *gBenchmark;
void TOFPreprocessorFDR()
{
gSystem->Load("$ALICE/SHUTTLE/TestShuttle/libTestShuttle");
AliLog::SetClassDebugLevel("AliTOFPreprocessorFDR",1);
// initialize location of CDB
AliTestShuttle::SetMainCDB("local://$ALICE_ROOT/OCDB/SHUTTLE/TestShuttle/TestCDB");
AliTestShuttle::SetMainRefStorage("local://$ALICE_ROOT/OCDB/SHUTTLE/TestShuttle/TestReference");
// create AliTestShuttle instance
AliTestShuttle* shuttle = new AliTestShuttle(0, 0, 1000);
// Generation of "fake" input DCS data
TMap* dcsAliasMap = CreateDCSAliasMap();
// now give the alias map to the shuttle
shuttle->SetDCSInput(dcsAliasMap);
// instantiation of the preprocessor
AliPreprocessor* pp = new AliTOFPreprocessorFDR(shuttle);
// preprocessing
gBenchmark->Start("process");
shuttle->Process();
gBenchmark->Stop("process");
gBenchmark->Print("process");
// checking the file which should have been created
AliCDBEntry* chkEntry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())->Get("TOF/Calib/DCSData", 0);
if (!chkEntry)
{
printf("The file is not there. Something went wrong.\n");
return;
}
AliTOFDataDCS* output = dynamic_cast<AliTOFDataDCS*> (chkEntry->GetObject());
// If everything went fine, draw the result
if (output)
printf("Output found.\n");
// output->Draw();
}
TMap* CreateDCSAliasMap()
{
// Creates a DCS structure
// The structure is the following:
// TMap (key --> value)
// <DCSAlias> --> <valueList>
// <DCSAlias> is a string
// <valueList> is a TObjArray of AliDCSValue
// An AliDCSValue consists of timestamp and a value in form of a AliSimpleValue
// In this example 6 aliases exists: DCSAlias1 ... DCSAlias6
// Each contains 1000 values randomly generated by TRandom::Gaus + 5*nAlias
TMap* aliasMap = new TMap;
aliasMap->SetOwner(1);
TRandom random;
TDatime *datime = new TDatime();
Int_t time = datime->GetTime();
Int_t date = datime->GetDate();
Int_t pid = gSystem->GetPid();
delete datime;
Int_t iseed = TMath::Abs(10000 * pid + time - date);
Float_t tentLVv33=3.3, tentLVv48=48, tentLVi33=100, tentLVi48=10;
Float_t sigmaLVv33=0.1, sigmaLVv48=1, sigmaLVi33=10, sigmaLVi48=2;
Float_t tent=0, sigma=0, thr=0;
Int_t NAliases=4;
for(int nAlias=0;nAlias<NAliases;nAlias++) {
TObjArray* valueSet = new TObjArray;
valueSet->SetOwner(1);
TString sindex;
TString aliasName;
if (nAlias==0){
aliasName = "tof_lv_i48_02";
tent=tentLVi48;
sigma=sigmaLVi48;
}
else if (nAlias==1){
aliasName = "tof_lv_v48_02";
tent=tentLVv48;
sigma=sigmaLVv48;
}
else if (nAlias==2){
aliasName = "tof_lv_i33_02";
tent=tentLVi33;
sigma=sigmaLVi33;
}
else if (nAlias==3){
aliasName = "tof_lv_v33_02";
tent=tentLVv33;
sigma=sigmaLVv33;
}
// gauss generation of values
for (int timeStamp=0;timeStamp<1000;timeStamp+=10){
Float_t gaussvalue = (Float_t) (random.Gaus(tent,sigma));
if (TMath::Abs(gaussvalue-tent)>sigma){
AliDCSValue* dcsVal = new AliDCSValue(gaussvalue, timeStamp);
valueSet->Add(dcsVal);
}
}
aliasMap->Add(new TObjString(aliasName), valueSet);
}
return aliasMap;
}
TMap* ReadDCSAliasMap()
{
// Open a file that contains DCS input data
// The CDB framework is used to open the file, this means the file is located
// in $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB/<detector>/DCS/Data
// The file contains an AliCDBEntry that contains a TMap with the DCS structure.
// An explanation of the structure can be found in CreateDCSAliasMap()
AliCDBEntry *entry = AliCDBManager::Instance()->Get("TOF/DCS/Data", 0);
return dynamic_cast<TMap*> (entry->GetObject());
}
void WriteDCSAliasMap()
{
// This writes the output from CreateDCSAliasMap to a CDB file
TMap* dcsAliasMap = CreateDCSAliasMap();
AliCDBMetaData metaData;
metaData.SetBeamPeriod(0);
metaData.SetResponsible("Chiara");
metaData.SetComment("Test object for TOFPreprocessorDCS.C");
AliCDBId id("TOF/DCS/Data", 0, 0);
// initialize location of CDB
AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/OCDB/SHUTTLE/TestShuttle/TestCDB");
AliCDBManager::Instance()->Put(dcsAliasMap, id, &metaData);
}