]>
Commit | Line | Data |
---|---|---|
ccc28861 | 1 | /* |
2 | $Id$ | |
3 | */ | |
4 | ||
5 | // This class runs the test TOF preprocessor | |
6 | // It uses AliTestShuttle to simulate a full Shuttle process | |
7 | ||
8 | // The input data is created in the functions | |
9 | // CreateDCSAliasMap() creates input that would in the same way come from DCS | |
10 | // ReadDCSAliasMap() reads from a file | |
11 | // CreateInputFilesMap() creates a list of local files, that can be accessed by the shuttle | |
12 | ||
27a53fea | 13 | extern TBenchmark *gBenchmark; |
7fffa85b | 14 | void TOFPreprocessor(Char_t * RunType="PHYSICS") |
ccc28861 | 15 | { |
db83b789 | 16 | gSystem->Load("$ALICE_ROOT/SHUTTLE/TestShuttle/libTestShuttle.so"); |
ccc28861 | 17 | |
7fffa85b | 18 | //AliLog::SetClassDebugLevel("AliTOFPreprocessor",1); |
ccc28861 | 19 | // initialize location of CDB |
58f7f59a | 20 | AliTestShuttle::SetMainCDB("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB"); |
21 | AliTestShuttle::SetMainRefStorage("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestReference"); | |
22 | ||
ccc28861 | 23 | // create AliTestShuttle instance |
24 | AliTestShuttle* shuttle = new AliTestShuttle(0, 0, 1000); | |
7fffa85b | 25 | //setting run type to physiscs |
26 | shuttle->SetInputRunType(RunType); | |
ccc28861 | 27 | |
28 | // Generation of "fake" input DCS data | |
27a53fea | 29 | TMap* dcsAliasMap = CreateDCSAliasMap(); |
ccc28861 | 30 | |
31 | // now give the alias map to the shuttle | |
27a53fea | 32 | shuttle->SetDCSInput(dcsAliasMap); |
ccc28861 | 33 | |
34 | // processing files. for the time being, the files are local. | |
5abdf772 | 35 | shuttle->AddInputFile(AliTestShuttle::kDAQ, "TOF", "DELAYS", "MON", "$ALICE_ROOT/TOF/ShuttleInput/Total.root"); |
36 | shuttle->AddInputFile(AliTestShuttle::kDAQ, "TOF", "RUNLevel", "MON", "$ALICE_ROOT/TOF/ShuttleInput/Partial.root"); | |
db83b789 | 37 | shuttle->AddInputFile(AliTestShuttle::kDCS, "TOF", "TofFeeMap", "", "$ALICE_ROOT/TOF/ShuttleInput/TOFFEE.20080310.164003.4001"); |
4541173c | 38 | char filename[100]; |
39 | char LDCname[5]; | |
7fffa85b | 40 | |
4541173c | 41 | for (Int_t iLDC=0;iLDC<2;iLDC++){ |
42 | sprintf(filename,"$ALICE_ROOT/TOF/ShuttleInput/TOFoutPulserLDC_%02i.root",iLDC*2); | |
43 | sprintf(LDCname,"LDC%i",iLDC*2); | |
44 | shuttle->AddInputFile(AliTestShuttle::kDAQ, "TOF", "PULSER", LDCname, filename); | |
45 | sprintf(filename,"$ALICE_ROOT/TOF/ShuttleInput/TOFoutNoiseLDC_%02i.root",iLDC*2); | |
46 | sprintf(LDCname,"LDC%i",iLDC*2); | |
47 | shuttle->AddInputFile(AliTestShuttle::kDAQ, "TOF", "NOISE", LDCname, filename); | |
48 | } | |
ccc28861 | 49 | |
50 | // instantiation of the preprocessor | |
124a2863 | 51 | AliPreprocessor* pp = new AliTOFPreprocessor(shuttle); |
ccc28861 | 52 | |
53 | // preprocessing | |
27a53fea | 54 | gBenchmark->Start("process"); |
ccc28861 | 55 | shuttle->Process(); |
27a53fea | 56 | gBenchmark->Stop("process"); |
57 | gBenchmark->Print("process"); | |
ccc28861 | 58 | |
59 | // checking the file which should have been created | |
4541173c | 60 | AliCDBEntry* chkEntry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())->Get("TOF/Calib/ParOnline", 0); |
27a53fea | 61 | if (!chkEntry) |
ccc28861 | 62 | { |
63 | printf("The file is not there. Something went wrong.\n"); | |
64 | return; | |
65 | } | |
66 | ||
27a53fea | 67 | AliTOFDataDCS* output = dynamic_cast<AliTOFDataDCS*> (chkEntry->GetObject()); |
ccc28861 | 68 | // If everything went fine, draw the result |
69 | if (output) | |
38e3bbf1 | 70 | printf("Output found.\n"); |
71 | // output->Draw(); | |
ccc28861 | 72 | |
73 | } | |
74 | ||
75 | TMap* CreateDCSAliasMap() | |
76 | { | |
77 | // Creates a DCS structure | |
78 | // The structure is the following: | |
27a53fea | 79 | // TMap (key --> value) |
80 | // <DCSAlias> --> <valueList> | |
81 | // <DCSAlias> is a string | |
82 | // <valueList> is a TObjArray of AliDCSValue | |
83 | // An AliDCSValue consists of timestamp and a value in form of a AliSimpleValue | |
ccc28861 | 84 | |
27a53fea | 85 | // In this example 6 aliases exists: DCSAlias1 ... DCSAlias6 |
86 | // Each contains 1000 values randomly generated by TRandom::Gaus + 5*nAlias | |
ccc28861 | 87 | |
88 | TMap* aliasMap = new TMap; | |
89 | aliasMap->SetOwner(1); | |
90 | ||
91 | TRandom random; | |
92 | TDatime *datime = new TDatime(); | |
93 | Int_t time = datime->GetTime(); | |
94 | Int_t date = datime->GetDate(); | |
95 | Int_t pid = gSystem->GetPid(); | |
96 | delete datime; | |
97 | Int_t iseed = TMath::Abs(10000 * pid + time - date); | |
98 | ||
27a53fea | 99 | //Float_t thrHVv=7.75, thrHVc=3, thrLVv=2.75, thrLVc=2.5, |
100 | //thrFEEthr=1.5, thrFEEt=10, thrTemp=35, thrPress=1000; | |
101 | //Float_t tentHVv=6.75, tentHVc=2, tentLVv=1.75, tentLVc=1.5, | |
102 | // tentFEEthr=0.5, te result=0; | |
103 | //ntFEEt=20, tentTemp=25, tentPress=900; | |
104 | //Float_t sigmaHVv=1, sigmaHVc=0.25, sigmaLVv=0.25, sigmaLVc=0.25, | |
105 | // sigmaFEEthr=0.05, sigmaFEEt=5, sigmaTemp=1, sigmaPress=10; | |
106 | ||
124a2863 | 107 | Float_t tentHVv=6500, tentHVi=80, tentLVv=2.7, tentLVi=4.5, |
108 | tentLVv33=3.3, tentLVv50=5.0, tentLVv48=48, | |
109 | tentLVi33=100, tentLVi50=3.0, tentLVi48=10, | |
38e3bbf1 | 110 | tentFEEthr=1.0, tentFEEtfeac=25, tentFEEttrm=45; |
124a2863 | 111 | Float_t sigmaHVv=10, sigmaHVi=10, sigmaLVv=0.2, sigmaLVi=1.0, |
112 | sigmaLVv33=0.1, sigmaLVv50=0.1, sigmaLVv48=1, | |
113 | sigmaLVi33=10, sigmaLVi50=0.5, sigmaLVi48=2, | |
38e3bbf1 | 114 | sigmaFEEthr=0.1, sigmaFEEtfeac=10, sigmaFEEttrm=4; |
ccc28861 | 115 | |
116 | Float_t tent=0, sigma=0, thr=0; | |
7fffa85b | 117 | // to have all the aliases, deccoment the following line: |
118 | // Int_t NAliases=10944, NHV=90, NLV=792, NLV33=72, NLV50=72, NLV48=72, NFEEthr=1152, NFEEtfeac=576, NFEEttrm=6840; | |
119 | ||
120 | // if not all the aliases are there, use this: | |
121 | Int_t NAliases=4104, NHV=90, NLV=792, NLV33=72, NLV50=72, NLV48=72, NFEEthr=1152, NFEEtfeac=576; | |
ccc28861 | 122 | |
123 | for(int nAlias=0;nAlias<NAliases;nAlias++) { | |
124 | ||
125 | TObjArray* valueSet = new TObjArray; | |
126 | valueSet->SetOwner(1); | |
127 | ||
124a2863 | 128 | TString sindex; |
ccc28861 | 129 | TString aliasName; |
130 | if (nAlias<NHV){ | |
124a2863 | 131 | aliasName = "tof_hv_vp_"; |
132 | sindex.Form("%02i",nAlias); | |
133 | aliasName += sindex; | |
134 | //aliasName += nAlias; | |
ccc28861 | 135 | tent=tentHVv; |
136 | sigma=sigmaHVv; | |
137 | // thr=thrHVv; | |
138 | } | |
139 | else if (nAlias<NHV*2){ | |
124a2863 | 140 | // aliasName = "HVvneg"; |
141 | //aliasName += nAlias-NHV; | |
142 | aliasName = "tof_hv_vn_"; | |
143 | sindex.Form("%02i",nAlias-NHV); | |
144 | aliasName += sindex; | |
ccc28861 | 145 | tent=-tentHVv; |
146 | sigma=-sigmaHVv; | |
147 | //thr=-thrHVv; | |
148 | } | |
149 | else if (nAlias<NHV*3){ | |
124a2863 | 150 | // aliasName = "HVcpos"; |
151 | //aliasName += nAlias-2*NHV; | |
152 | aliasName = "tof_hv_ip_"; | |
153 | sindex.Form("%02i",nAlias-2*NHV); | |
154 | aliasName += sindex; | |
155 | tent=tentHVi; | |
156 | sigma=sigmaHVi; | |
ccc28861 | 157 | //thr=thrHVc; |
158 | } | |
159 | else if (nAlias<NHV*4){ | |
124a2863 | 160 | // aliasName = "HVcneg"; |
161 | //aliasName += nAlias-3*NHV; | |
162 | aliasName = "tof_hv_in_"; | |
163 | sindex.Form("%02i",nAlias-3*NHV); | |
164 | aliasName += sindex; | |
165 | tent=-tentHVi; | |
166 | sigma=-sigmaHVi; | |
ccc28861 | 167 | //thr=-thrHVc; |
168 | } | |
169 | else if (nAlias<NHV*4+NLV){ | |
124a2863 | 170 | // aliasName = "LVv"; |
171 | //aliasName += nAlias-4*NHV; | |
172 | aliasName = "tof_lv_vfea_"; | |
173 | sindex.Form("%03i",nAlias-4*NHV); | |
174 | aliasName += sindex; | |
ccc28861 | 175 | tent=tentLVv; |
176 | sigma=sigmaLVv; | |
177 | //thr=thrLVv; | |
178 | } | |
179 | else if (nAlias<NHV*4+2*NLV){ | |
124a2863 | 180 | // aliasName = "LVc"; |
181 | //aliasName += nAlias-(4*NHV+NLV); | |
182 | aliasName = "tof_lv_ifea_"; | |
183 | sindex.Form("%03i",nAlias-(4*NHV+NLV)); | |
184 | aliasName += sindex; | |
185 | tent=tentLVi; | |
186 | sigma=sigmaLVi; | |
ccc28861 | 187 | //thr=thrLVc; |
188 | } | |
124a2863 | 189 | else if (nAlias<NHV*4+2*NLV+NLV33){ |
190 | // aliasName = "LVc"; | |
191 | //aliasName += nAlias-(4*NHV+NLV); | |
192 | aliasName = "tof_lv_v33_"; | |
193 | sindex.Form("%02i",nAlias-(4*NHV+2*NLV)); | |
194 | aliasName += sindex; | |
195 | tent=tentLVv33; | |
196 | sigma=sigmaLVv33; | |
197 | //thr=thrLVc; | |
198 | } | |
199 | else if (nAlias<NHV*4+2*NLV+2*NLV33){ | |
200 | // aliasName = "LVc"; | |
201 | //aliasName += nAlias-(4*NHV+NLV); | |
202 | aliasName = "tof_lv_i33_"; | |
203 | sindex.Form("%02i",nAlias-(4*NHV+2*NLV+NLV33)); | |
204 | aliasName += sindex; | |
205 | tent=tentLVi33; | |
206 | sigma=sigmaLVi33; | |
207 | //thr=thrLVc; | |
208 | } | |
209 | else if (nAlias<NHV*4+2*NLV+2*NLV33+NLV50){ | |
210 | // aliasName = "LVc"; | |
211 | //aliasName += nAlias-(4*NHV+NLV); | |
212 | aliasName = "tof_lv_v50_"; | |
213 | sindex.Form("%02i",nAlias-(4*NHV+2*NLV+2*NLV33)); | |
214 | aliasName += sindex; | |
215 | tent=tentLVv50; | |
216 | sigma=sigmaLVv50; | |
217 | //thr=thrLVc; | |
218 | } | |
219 | else if (nAlias<NHV*4+2*NLV+2*NLV33+2*NLV50){ | |
220 | // aliasName = "LVc"; | |
221 | //aliasName += nAlias-(4*NHV+NLV); | |
222 | aliasName = "tof_lv_i50_"; | |
223 | sindex.Form("%02i",nAlias-(4*NHV+2*NLV+2*NLV33+NLV50)); | |
224 | aliasName += sindex; | |
225 | tent=tentLVi50; | |
226 | sigma=sigmaLVi50; | |
227 | //thr=thrLVc; | |
228 | } | |
229 | else if (nAlias<NHV*4+2*NLV+2*NLV33+2*NLV50+NLV48){ | |
230 | // aliasName = "LVc"; | |
231 | //aliasName += nAlias-(4*NHV+NLV); | |
232 | aliasName = "tof_lv_v48_"; | |
233 | sindex.Form("%02i",nAlias-(4*NHV+2*NLV+2*NLV33+2*NLV50)); | |
234 | aliasName += sindex; | |
235 | tent=tentLVv48; | |
236 | sigma=sigmaLVv48; | |
237 | //thr=thrLVc; | |
238 | } | |
239 | else if (nAlias<NHV*4+2*NLV+2*NLV33+2*NLV50+2*NLV48){ | |
240 | // aliasName = "LVc"; | |
241 | //aliasName += nAlias-(4*NHV+NLV); | |
242 | aliasName = "tof_lv_i48_"; | |
243 | sindex.Form("%02i",nAlias-(4*NHV+2*NLV+2*NLV33+2*NLV50+NLV48)); | |
244 | aliasName += sindex; | |
245 | tent=tentLVi48; | |
246 | sigma=sigmaLVi48; | |
247 | //thr=thrLVc; | |
248 | } | |
249 | else if (nAlias<NHV*4+2*NLV+2*NLV33+2*NLV50+2*NLV48+NFEEthr){ | |
250 | // aliasName = "FEEthr"; | |
251 | //aliasName += nAlias-(4*NHV+2*NLV-(4*NHV+2*NLV+2*NLV33+2*NLV50+2*NLV48)); | |
252 | aliasName = "tof_fee_th_"; | |
253 | sindex.Form("%04i",nAlias-(4*NHV+2*NLV+2*NLV33+2*NLV50+2*NLV48)); | |
254 | aliasName += sindex; | |
ccc28861 | 255 | tent=tentFEEthr; |
256 | sigma=sigmaFEEthr; | |
257 | //thr=thrFEEthr; | |
258 | } | |
124a2863 | 259 | else if (nAlias<NHV*4+2*NLV+2*NLV33+2*NLV50+2*NLV48+NFEEthr+NFEEtfeac){ |
260 | //cout << " nalias fee temp = " << nAlias << endl; | |
261 | // aliasName = "FEEt"; | |
262 | //aliasName += nAlias-(4*NHV+2*NLV+NFEEthr); | |
263 | aliasName = "tof_fee_tfeac_"; | |
264 | sindex.Form("%03i",nAlias-(4*NHV+2*NLV+2*NLV33+2*NLV50+2*NLV48+NFEEthr)); | |
265 | aliasName += sindex; | |
266 | //cout << " nalias fee temp name = " << aliasName << endl; | |
267 | tent=tentFEEtfeac; | |
268 | sigma=sigmaFEEtfeac; | |
269 | //thr=thrFEEthr; | |
270 | } | |
7fffa85b | 271 | /* |
124a2863 | 272 | else if (nAlias<NHV*4+2*NLV+2*NLV33+2*NLV50+2*NLV48+NFEEthr+NFEEtfeac+NFEEttrm){ |
ccc28861 | 273 | //cout << " nalias fee temp = " << nAlias << endl; |
124a2863 | 274 | // aliasName = "FEEt"; |
275 | //aliasName += nAlias-(4*NHV+2*NLV+NFEEthr); | |
276 | aliasName = "tof_fee_ttrm_"; | |
277 | sindex.Form("%04i",nAlias-(4*NHV+2*NLV+2*NLV33+2*NLV50+2*NLV48+NFEEthr+NFEEtfeac)); | |
278 | aliasName += sindex; | |
ccc28861 | 279 | //cout << " nalias fee temp name = " << aliasName << endl; |
124a2863 | 280 | tent=tentFEEttrm; |
281 | sigma=sigmaFEEttrm; | |
ccc28861 | 282 | //thr=thrFEEthr; |
283 | } | |
7fffa85b | 284 | */ |
ccc28861 | 285 | // gauss generation of values |
286 | for (int timeStamp=0;timeStamp<1000;timeStamp+=10){ | |
db83b789 | 287 | //for (int timeStamp=0;timeStamp<1;timeStamp++){ |
ccc28861 | 288 | Float_t gaussvalue = (Float_t) (random.Gaus(tent,sigma)); |
289 | if (TMath::Abs(gaussvalue-tent)>sigma){ | |
290 | AliDCSValue* dcsVal = new AliDCSValue(gaussvalue, timeStamp); | |
291 | valueSet->Add(dcsVal); | |
292 | } | |
293 | } | |
294 | ||
295 | aliasMap->Add(new TObjString(aliasName), valueSet); | |
296 | } | |
297 | ||
298 | return aliasMap; | |
299 | } | |
300 | ||
301 | TMap* ReadDCSAliasMap() | |
302 | { | |
303 | // Open a file that contains DCS input data | |
304 | // The CDB framework is used to open the file, this means the file is located | |
305 | // in $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB/<detector>/DCS/Data | |
306 | // The file contains an AliCDBEntry that contains a TMap with the DCS structure. | |
307 | // An explanation of the structure can be found in CreateDCSAliasMap() | |
308 | ||
309 | AliCDBEntry *entry = AliCDBManager::Instance()->Get("TOF/DCS/Data", 0); | |
310 | return dynamic_cast<TMap*> (entry->GetObject()); | |
311 | } | |
312 | ||
313 | void WriteDCSAliasMap() | |
314 | { | |
315 | // This writes the output from CreateDCSAliasMap to a CDB file | |
316 | ||
317 | TMap* dcsAliasMap = CreateDCSAliasMap(); | |
318 | ||
319 | AliCDBMetaData metaData; | |
320 | metaData.SetBeamPeriod(0); | |
321 | metaData.SetResponsible("Chiara"); | |
322 | metaData.SetComment("Test object for TOFPreprocessor.C"); | |
323 | ||
324 | AliCDBId id("TOF/DCS/Data", 0, 0); | |
325 | ||
326 | // initialize location of CDB | |
327 | AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB"); | |
328 | ||
329 | AliCDBManager::Instance()->Put(dcsAliasMap, id, &metaData); | |
330 | } |