]>
Commit | Line | Data |
---|---|---|
3e42bf30 | 1 | /* |
113ad708 | 2 | MTR DA for online |
3 | ||
3e42bf30 | 4 | Contact: Franck Manso <manso@clermont.in2p3.fr> |
5 | Link: http://aliceinfo.cern.ch/static/Offline/dimuon/muon_html/README_mtrda.html | |
327f7faa | 6 | Reference run: 61898, 63698 (dead channels), 63701 (noisy channels) |
41a38dec | 7 | Run Type: PHYSICS (noisy channels), STANDALONE (dead channels) |
8 | DA Type: MON | |
9 | Number of events needed: 1000 events for noisy and dead channels | |
3e42bf30 | 10 | Input Files: Rawdata file (DATE format) |
11 | Input Files from DB: | |
12 | MtgGlobalCrate-<version>.dat | |
13 | MtgRegionalCrate-<version>.dat | |
14 | MtgLocalMask-<version>.dat | |
15 | MtgLocalLut-<version>.dat | |
16 | MtgCurrent.dat | |
17 | ||
18 | Output Files: local dir (not persistent) | |
19 | ExportedFiles.dat | |
20 | */ | |
21 | ||
327f7faa | 22 | ////////////////////////////////////////////////////////////////////////////// |
23 | // Detector Algorithm for the MUON trigger configuration. // | |
24 | // // | |
25 | // Calculates masks for the global trigger input, by looking at dead // | |
26 | // channels in calibration runs and at noisy channels in physics runs. // | |
27 | // Transfers trigger configuration files to the File Exchange Server and // | |
28 | // writes them (if modified) into the trigger configuration data base. // | |
29 | // // | |
30 | // Authors: // | |
31 | // Christian Fink (formerly at Subatech, Nantes) // | |
32 | // Franck Manso (LPC Clermont-Ferrand, manso@clermont.in2p3.fr) // | |
33 | // Bogdan Vulpescu (LPC Clermont-Ferrand, vulpescu@clermont.in2p3.fr) // | |
34 | // // | |
35 | ////////////////////////////////////////////////////////////////////////////// | |
3e42bf30 | 36 | |
9f5fafa6 | 37 | extern "C" { |
38 | #include <daqDA.h> | |
39 | } | |
40 | ||
41 | #include "event.h" | |
42 | #include "monitor.h" | |
43 | ||
44 | #include <Riostream.h> | |
45 | #include <stdio.h> | |
46 | #include <stdlib.h> | |
47 | ||
48 | //AliRoot | |
4fd5ed63 | 49 | #include "AliRawReaderDate.h" |
50 | ||
51 | #include "AliMpConstants.h" | |
9f5fafa6 | 52 | #include "AliMUONRawStreamTrigger.h" |
53 | #include "AliMUONDarcHeader.h" | |
9f5fafa6 | 54 | #include "AliMUONDDLTrigger.h" |
4fd5ed63 | 55 | #include "AliMUONVStore.h" |
4fd5ed63 | 56 | #include "AliMUON1DArray.h" |
57 | #include "AliMUONTriggerIO.h" | |
92c23b09 | 58 | #include "AliMUONRegionalTriggerConfig.h" |
59 | #include "AliMUONGlobalCrateConfig.h" | |
60 | #include "AliMUONTriggerCrateConfig.h" | |
9f5fafa6 | 61 | |
62 | //ROOT | |
9f5fafa6 | 63 | #include "TString.h" |
4fd5ed63 | 64 | #include "TSystem.h" |
9f5fafa6 | 65 | #include "TStopwatch.h" |
9f5fafa6 | 66 | #include "TROOT.h" |
67 | #include "TPluginManager.h" | |
9f5fafa6 | 68 | |
37dacd7d | 69 | /// class for DA run parameters and DA working space |
70 | class AliDAConfig : TObject { | |
71 | ||
72 | public: | |
73 | ||
74 | AliDAConfig() : | |
75 | fDAConfigFileName("DAConfig.txt"), | |
76 | fCurrentFileName("MtgCurrent.dat"), | |
77 | fLastCurrentFileName("MtgLastCurrent.dat"), | |
78 | fSodName(""), | |
79 | fSodFlag(0), | |
80 | fDAName(""), | |
81 | fDAFlag(0), | |
82 | fGlobalFileName(""), | |
83 | fRegionalFileName(""), | |
84 | fLocalMaskFileName(""), | |
85 | fLocalLutFileName(""), | |
86 | fSignatureFileName(""), | |
87 | fGlobalFileVersion(0), | |
88 | fRegionalFileVersion(0), | |
89 | fLocalMaskFileVersion(0), | |
90 | fLocalLutFileVersion(0), | |
91 | fSignatureFileVersion(0), | |
92 | fGlobalFileLastVersion(0), | |
93 | fRegionalFileLastVersion(0), | |
94 | fLocalMaskFileLastVersion(0), | |
95 | fLocalLutFileLastVersion(0), | |
96 | fEventsN(0), | |
97 | fEventsD(0), | |
98 | fPrintLevel(0), | |
99 | fLocalMasks(0x0), | |
100 | fRegionalMasks(0x0), | |
101 | fGlobalMasks(0x0), | |
102 | fTriggerIO(new AliMUONTriggerIO), | |
103 | fAlgoNoisyInput(false), | |
104 | fAlgoDeadcInput(false), | |
105 | fThrN(0.1), | |
106 | fThrD(0.9), | |
107 | fMinEvents(10), | |
108 | fSkipEvents(0), | |
109 | fMaxEvents(65535), | |
110 | fWithWarnings(false), | |
111 | fNLocalBoard(AliMpConstants::TotalNofLocalBoards()+1) | |
112 | { | |
113 | /// default constructor | |
114 | for (Int_t ii = 0; ii < kGlobalInputs; ii++) { | |
115 | for (Int_t il = 0; il < kGlobalInputLength; il++) { | |
116 | fAccGlobalInputN[ii][il] = 0; | |
117 | fAccGlobalInputD[ii][il] = 0; | |
118 | } | |
119 | } | |
120 | fLocalMasks = new AliMUON1DArray(fNLocalBoard); | |
121 | fRegionalMasks = new AliMUONRegionalTriggerConfig(); | |
122 | fGlobalMasks = new AliMUONGlobalCrateConfig(); | |
123 | } | |
124 | ||
125 | AliDAConfig (const AliDAConfig& cfg); // copy constructor | |
126 | AliDAConfig& operator=(const AliDAConfig& cfg); // assignment operator | |
127 | virtual ~AliDAConfig() | |
128 | { | |
129 | /// destructor | |
130 | delete fLocalMasks; | |
131 | delete fRegionalMasks; | |
132 | delete fGlobalMasks; | |
133 | delete fTriggerIO; | |
134 | } | |
135 | void PrintConfig() | |
136 | { | |
137 | /// print DA parameters | |
138 | printf("DA config file name: %s \n",GetDAConfigFileName()); | |
139 | printf("Current file name: %s \n",GetCurrentFileName()); | |
140 | printf("Last current file name: %s \n",GetLastCurrentFileName()); | |
141 | printf("Global file name: %s (%d %d)\n",GetGlobalFileName(),GetGlobalFileVersion(),GetGlobalFileLastVersion()); | |
142 | printf("Regional file name: %s (%d %d)\n",GetRegionalFileName(),GetRegionalFileVersion(),GetRegionalFileLastVersion()); | |
143 | printf("Local mask file name: %s (%d %d)\n",GetLocalMaskFileName(),GetLocalMaskFileVersion(),GetLocalMaskFileLastVersion()); | |
144 | printf("Local LUT file name: %s (%d %d)\n",GetLocalLutFileName(),GetLocalLutFileVersion(),GetLocalLutFileLastVersion()); | |
145 | printf("Signature file name: %s (%d)\n",GetSignatureFileName(),GetSignatureFileVersion()); | |
146 | } | |
147 | ||
148 | const Char_t* GetDAConfigFileName() { return fDAConfigFileName.Data(); } | |
149 | const Char_t* GetCurrentFileName() { return fCurrentFileName.Data(); } | |
150 | const Char_t* GetLastCurrentFileName() { return fLastCurrentFileName.Data(); } | |
151 | ||
152 | const Char_t* GetSodName() { return fSodName.Data(); } | |
153 | Int_t GetSodFlag() const { return fSodFlag; } | |
154 | ||
155 | const Char_t* GetDAName() { return fDAName.Data(); } | |
156 | Int_t GetDAFlag() const { return fDAFlag; } | |
157 | ||
158 | const Char_t* GetGlobalFileName() { return fGlobalFileName.Data(); } | |
159 | const Char_t* GetRegionalFileName() { return fRegionalFileName.Data(); } | |
160 | const Char_t* GetLocalMaskFileName() { return fLocalMaskFileName.Data(); } | |
161 | const Char_t* GetLocalLutFileName() { return fLocalLutFileName.Data(); } | |
162 | const Char_t* GetSignatureFileName() { return fSignatureFileName.Data(); } | |
163 | ||
164 | Int_t GetGlobalFileVersion() const { return fGlobalFileVersion; } | |
165 | Int_t GetRegionalFileVersion() const { return fRegionalFileVersion; } | |
166 | Int_t GetLocalMaskFileVersion() const { return fLocalMaskFileVersion; } | |
167 | Int_t GetLocalLutFileVersion() const { return fLocalLutFileVersion; } | |
168 | Int_t GetSignatureFileVersion() const { return fSignatureFileVersion; } | |
169 | ||
170 | Int_t GetGlobalFileLastVersion() const { return fGlobalFileLastVersion; } | |
171 | Int_t GetRegionalFileLastVersion() const { return fRegionalFileLastVersion; } | |
172 | Int_t GetLocalMaskFileLastVersion() const { return fLocalMaskFileLastVersion; } | |
173 | Int_t GetLocalLutFileLastVersion() const { return fLocalLutFileLastVersion; } | |
174 | ||
175 | AliMUONVStore* GetLocalMasks() const { return fLocalMasks; } | |
176 | AliMUONRegionalTriggerConfig* GetRegionalMasks() const { return fRegionalMasks; } | |
177 | AliMUONGlobalCrateConfig* GetGlobalMasks() const { return fGlobalMasks; } | |
178 | ||
179 | AliMUONTriggerIO* GetTriggerIO() const { return fTriggerIO; } | |
180 | ||
181 | Int_t GetEventsN() const { return fEventsN; } | |
182 | Int_t GetEventsD() const { return fEventsD; } | |
183 | ||
184 | Int_t GetPrintLevel() const { return fPrintLevel; } | |
185 | ||
186 | Bool_t GetAlgoNoisyInput() const { return fAlgoNoisyInput; } | |
187 | Bool_t GetAlgoDeadcInput() const { return fAlgoDeadcInput; } | |
188 | ||
189 | Float_t GetThrN() const { return fThrN; } | |
190 | Float_t GetThrD() const { return fThrD; } | |
191 | ||
192 | Int_t GetMinEvents() const { return fMinEvents; } | |
193 | Int_t GetMaxEvents() const { return fMaxEvents; } | |
194 | Int_t GetSkipEvents() const { return fSkipEvents; } | |
195 | ||
196 | Bool_t WithWarnings() const { return fWithWarnings; } | |
197 | ||
198 | Int_t GetGlobalInputs() const { return kGlobalInputs; } | |
199 | Int_t GetGlobalInputLength() const { return kGlobalInputLength; } | |
200 | ||
201 | Int_t GetAccGlobalInputN(Int_t ii, Int_t ib) const { return fAccGlobalInputN[ii][ib]; } | |
202 | Int_t GetAccGlobalInputD(Int_t ii, Int_t ib) const { return fAccGlobalInputD[ii][ib]; } | |
203 | ||
204 | void SetSodName(Char_t *name) { fSodName = TString(name); } | |
205 | void SetSodFlag(Int_t flag) { fSodFlag = flag; } | |
206 | ||
207 | void SetDAName(Char_t *name) { fDAName = TString(name); } | |
208 | void SetDAFlag(Int_t flag) { fDAFlag = flag; } | |
209 | ||
210 | void SetGlobalFileName(const Char_t *name) { fGlobalFileName = TString(name); } | |
211 | void SetRegionalFileName(const Char_t *name) { fRegionalFileName = TString(name); } | |
212 | void SetLocalMaskFileName(const Char_t *name) { fLocalMaskFileName = TString(name); } | |
213 | void SetLocalLutFileName(const Char_t *name) { fLocalLutFileName = TString(name); } | |
214 | void SetSignatureFileName(const Char_t *name) { fSignatureFileName = TString(name); } | |
215 | ||
216 | void SetGlobalFileVersion(Int_t ver) { fGlobalFileVersion = ver; } | |
217 | void SetRegionalFileVersion(Int_t ver) { fRegionalFileVersion = ver; } | |
218 | void SetLocalMaskFileVersion(Int_t ver) { fLocalMaskFileVersion = ver; } | |
219 | void SetLocalLutFileVersion(Int_t ver) { fLocalLutFileVersion = ver; } | |
220 | void SetSignatureFileVersion(Int_t ver) { fSignatureFileVersion = ver; } | |
221 | ||
222 | void SetGlobalFileLastVersion(Int_t ver) { fGlobalFileLastVersion = ver; } | |
223 | void SetRegionalFileLastVersion(Int_t ver) { fRegionalFileLastVersion = ver; } | |
224 | void SetLocalMaskFileLastVersion(Int_t ver) { fLocalMaskFileLastVersion = ver; } | |
225 | void SetLocalLutFileLastVersion(Int_t ver) { fLocalLutFileLastVersion = ver; } | |
226 | ||
227 | void IncNoiseEvent() { fEventsN++; } | |
228 | void IncDeadcEvent() { fEventsD++; } | |
229 | ||
230 | void AddAccGlobalInputN(Int_t ii, Int_t ib, Int_t val) { fAccGlobalInputN[ii][ib] += val; } | |
231 | void AddAccGlobalInputD(Int_t ii, Int_t ib, Int_t val) { fAccGlobalInputD[ii][ib] += val; } | |
232 | ||
233 | void SetPrintLevel(Int_t level) { fPrintLevel = level; } | |
234 | ||
235 | void SetAlgoNoisyInput(Bool_t val) { fAlgoNoisyInput = val; } | |
236 | void SetAlgoDeadcInput(Bool_t val) { fAlgoDeadcInput = val; } | |
237 | ||
238 | void SetThrN(Float_t val) { fThrN = val; } | |
239 | void SetThrD(Float_t val) { fThrD = val; } | |
240 | ||
241 | void SetMinEvents(Int_t val) { fMinEvents = val; } | |
242 | void SetMaxEvents(Int_t val) { fMaxEvents = val; } | |
243 | void SetSkipEvents(Int_t val) { fSkipEvents = val; } | |
244 | ||
245 | void SetWithWarnings() { fWithWarnings = true; } | |
246 | ||
247 | void IncGlobalFileVersion() { fGlobalFileVersion++; } | |
248 | void DecSkipEvents() { fSkipEvents--; } | |
249 | ||
250 | private: | |
4fd5ed63 | 251 | |
327f7faa | 252 | const TString fDAConfigFileName; |
253 | const TString fCurrentFileName; | |
254 | const TString fLastCurrentFileName; | |
4fd5ed63 | 255 | |
327f7faa | 256 | TString fSodName; |
257 | Int_t fSodFlag; | |
4fd5ed63 | 258 | |
327f7faa | 259 | TString fDAName; |
260 | Int_t fDAFlag; | |
4fd5ed63 | 261 | |
327f7faa | 262 | TString fGlobalFileName; |
263 | TString fRegionalFileName; | |
264 | TString fLocalMaskFileName; | |
265 | TString fLocalLutFileName; | |
266 | TString fSignatureFileName; | |
4fd5ed63 | 267 | |
327f7faa | 268 | Int_t fGlobalFileVersion; |
269 | Int_t fRegionalFileVersion; | |
270 | Int_t fLocalMaskFileVersion; | |
271 | Int_t fLocalLutFileVersion; | |
272 | Int_t fSignatureFileVersion; | |
273 | ||
274 | Int_t fGlobalFileLastVersion; | |
275 | Int_t fRegionalFileLastVersion; | |
276 | Int_t fLocalMaskFileLastVersion; | |
277 | Int_t fLocalLutFileLastVersion; | |
278 | ||
37dacd7d | 279 | Int_t fEventsN; |
280 | Int_t fEventsD; | |
327f7faa | 281 | |
282 | Int_t fPrintLevel; | |
283 | ||
284 | AliMUONVStore* fLocalMasks; | |
285 | AliMUONRegionalTriggerConfig* fRegionalMasks; | |
286 | AliMUONGlobalCrateConfig* fGlobalMasks; | |
287 | ||
288 | AliMUONTriggerIO *fTriggerIO; | |
289 | ||
290 | Bool_t fAlgoNoisyInput; | |
37dacd7d | 291 | Bool_t fAlgoDeadcInput; |
327f7faa | 292 | |
293 | Float_t fThrN; | |
294 | Float_t fThrD; | |
295 | Int_t fMinEvents; | |
296 | Int_t fSkipEvents; | |
297 | Int_t fMaxEvents; | |
298 | Bool_t fWithWarnings; | |
299 | ||
300 | const Int_t fNLocalBoard; | |
301 | ||
302 | enum { kGlobalInputs = 4, kGlobalInputLength = 32 }; | |
303 | ||
304 | Int_t fAccGlobalInputN[kGlobalInputs][kGlobalInputLength]; | |
305 | Int_t fAccGlobalInputD[kGlobalInputs][kGlobalInputLength]; | |
306 | ||
327f7faa | 307 | }; |
4fd5ed63 | 308 | |
327f7faa | 309 | //__________________________________________________________________ |
37dacd7d | 310 | Bool_t ReadDAConfig(AliDAConfig& cfg) |
327f7faa | 311 | { |
37dacd7d | 312 | /// read run parameters for the DA |
4fd5ed63 | 313 | |
327f7faa | 314 | char line[80]; |
4fd5ed63 | 315 | |
327f7faa | 316 | TString file; |
37dacd7d | 317 | file = cfg.GetDAConfigFileName(); |
327f7faa | 318 | std::ifstream in(gSystem->ExpandPathName(file.Data())); |
319 | if (!in.good()) { | |
320 | printf("Cannot open DA configuration file %s ; use default values.\n",file.Data()); | |
321 | return true; | |
322 | } | |
323 | ||
324 | TString tmp; | |
325 | Int_t pos; | |
326 | ||
327 | in.getline(line,80); | |
328 | tmp = line; | |
329 | pos = tmp.First(" "); | |
330 | tmp = tmp(0,pos); | |
37dacd7d | 331 | cfg.SetPrintLevel(tmp.Atoi()); |
327f7faa | 332 | |
333 | in.getline(line,80); | |
334 | tmp = line; | |
335 | pos = tmp.First(" "); | |
336 | tmp = tmp(0,pos); | |
37dacd7d | 337 | cfg.SetThrN(tmp.Atof()); |
327f7faa | 338 | |
339 | in.getline(line,80); | |
340 | tmp = line; | |
341 | pos = tmp.First(" "); | |
342 | tmp = tmp(0,pos); | |
37dacd7d | 343 | cfg.SetThrD(tmp.Atof()); |
327f7faa | 344 | |
345 | in.getline(line,80); | |
346 | tmp = line; | |
347 | pos = tmp.First(" "); | |
348 | tmp = tmp(0,pos); | |
37dacd7d | 349 | cfg.SetMinEvents(tmp.Atoi()); |
327f7faa | 350 | |
351 | in.getline(line,80); | |
352 | tmp = line; | |
353 | pos = tmp.First(" "); | |
354 | tmp = tmp(0,pos); | |
37dacd7d | 355 | cfg.SetSkipEvents(tmp.Atoi()); |
4fd5ed63 | 356 | |
327f7faa | 357 | in.getline(line,80); |
358 | tmp = line; | |
359 | pos = tmp.First(" "); | |
360 | tmp = tmp(0,pos); | |
37dacd7d | 361 | cfg.SetMaxEvents(tmp.Atoi()); |
4fd5ed63 | 362 | |
327f7faa | 363 | in.getline(line,80); |
364 | tmp = line; | |
365 | pos = tmp.First(" "); | |
366 | tmp = tmp(0,pos); | |
37dacd7d | 367 | if (tmp.Atoi() != 0) cfg.SetWithWarnings(); |
327f7faa | 368 | |
369 | return true; | |
4fd5ed63 | 370 | |
327f7faa | 371 | } |
4fd5ed63 | 372 | |
4fd5ed63 | 373 | //__________________________________________________________________ |
37dacd7d | 374 | void WriteLastCurrentFile(AliDAConfig& cfg, TString currentFile) |
4fd5ed63 | 375 | { |
37dacd7d | 376 | /// write last current file |
4fd5ed63 | 377 | |
4fd5ed63 | 378 | ofstream out; |
379 | TString file; | |
380 | file = currentFile; | |
381 | out.open(file.Data()); | |
37dacd7d | 382 | out << cfg.GetSodName() << " " << cfg.GetSodFlag() << endl; |
383 | out << cfg.GetDAName() << " " << cfg.GetDAFlag() << endl; | |
4fd5ed63 | 384 | |
37dacd7d | 385 | out << cfg.GetGlobalFileName() << " " << cfg.GetGlobalFileVersion() << endl; |
386 | out << cfg.GetRegionalFileName() << " " << cfg.GetRegionalFileVersion() << endl; | |
387 | out << cfg.GetLocalMaskFileName() << " " << cfg.GetLocalMaskFileVersion() << endl; | |
388 | out << cfg.GetLocalLutFileName() << " " << cfg.GetLocalLutFileVersion() << endl; | |
389 | out << cfg.GetSignatureFileName() << " " << cfg.GetSignatureFileVersion() << endl; | |
4fd5ed63 | 390 | |
391 | out.close(); | |
392 | } | |
393 | ||
394 | //___________________________________________________________________________________________ | |
37dacd7d | 395 | Bool_t ReadCurrentFile(AliDAConfig& cfg, TString currentFile, Bool_t lastCurrentFlag = false) |
4fd5ed63 | 396 | { |
37dacd7d | 397 | /// read last current file name and version |
4fd5ed63 | 398 | |
4fd5ed63 | 399 | char line[80]; |
400 | char name[80]; | |
37dacd7d | 401 | Int_t flag; |
4fd5ed63 | 402 | |
403 | TString file; | |
404 | file = currentFile; | |
405 | std::ifstream in(gSystem->ExpandPathName(file.Data())); | |
406 | if (!in.good()) { | |
407 | printf("Cannot open last current file %s\n",currentFile.Data()); | |
408 | return false; | |
409 | } | |
410 | ||
4fd5ed63 | 411 | // read SOD |
412 | in.getline(line,80); | |
37dacd7d | 413 | sscanf(line, "%s %d", name, &flag); |
414 | cfg.SetSodName(name); | |
415 | cfg.SetSodFlag(flag); | |
416 | if (cfg.GetPrintLevel()) printf("Sod Flag %d\n", cfg.GetSodFlag()); | |
4fd5ed63 | 417 | |
418 | //read DA | |
419 | in.getline(line,80); | |
37dacd7d | 420 | sscanf(line, "%s %d", name, &flag); |
421 | cfg.SetDAName(name); | |
422 | cfg.SetDAFlag(flag); | |
423 | if (cfg.GetPrintLevel()) printf("DA Flag: %d\n", cfg.GetDAFlag()); | |
4fd5ed63 | 424 | |
4fd5ed63 | 425 | // read global |
426 | in.getline(line,80); | |
427 | TString tmp(line); | |
428 | Int_t pos = tmp.First(" "); | |
37dacd7d | 429 | TString tmp1 = tmp(0, pos); |
430 | cfg.SetGlobalFileName(tmp1.Data()); | |
4fd5ed63 | 431 | |
432 | if (!lastCurrentFlag) { | |
37dacd7d | 433 | cfg.SetGlobalFileVersion(atoi(tmp(pos+1, tmp.Length()-pos).Data())); |
434 | if (cfg.GetPrintLevel()) printf("Global File Name: %s version: %d\n", | |
435 | cfg.GetGlobalFileName(), cfg.GetGlobalFileVersion()); | |
4fd5ed63 | 436 | } else { |
37dacd7d | 437 | cfg.SetGlobalFileLastVersion(atoi(tmp(pos+1, tmp.Length()-pos).Data())); |
438 | if (cfg.GetPrintLevel()) printf("Global File Name: %s last version: %d\n", | |
439 | cfg.GetGlobalFileName(), cfg.GetGlobalFileLastVersion()); | |
4fd5ed63 | 440 | } |
441 | ||
442 | // read regional | |
443 | in.getline(line,80); | |
444 | tmp = line; | |
445 | pos = tmp.First(" "); | |
37dacd7d | 446 | tmp1 = tmp(0, pos); |
447 | cfg.SetRegionalFileName(tmp1.Data()); | |
4fd5ed63 | 448 | |
449 | if (!lastCurrentFlag) { | |
37dacd7d | 450 | cfg.SetRegionalFileVersion(atoi(tmp(pos+1, tmp.Length()-pos).Data())); |
451 | if (cfg.GetPrintLevel()) printf("Regional File Name: %s version: %d\n", | |
452 | cfg.GetRegionalFileName(), cfg.GetRegionalFileVersion()); | |
4fd5ed63 | 453 | |
454 | } else { | |
37dacd7d | 455 | cfg.SetRegionalFileLastVersion(atoi(tmp(pos+1, tmp.Length()-pos).Data())); |
456 | if (cfg.GetPrintLevel()) printf("Regional File Name: %s last version: %d\n", | |
457 | cfg.GetRegionalFileName(), cfg.GetRegionalFileLastVersion()); | |
4fd5ed63 | 458 | } |
459 | ||
4fd5ed63 | 460 | // read mask |
461 | in.getline(line,80); | |
462 | tmp = line; | |
463 | pos = tmp.First(" "); | |
37dacd7d | 464 | tmp1 = tmp(0, pos); |
465 | cfg.SetLocalMaskFileName(tmp1.Data()); | |
4fd5ed63 | 466 | |
467 | if (!lastCurrentFlag) { | |
37dacd7d | 468 | cfg.SetLocalMaskFileVersion(atoi(tmp(pos+1, tmp.Length()-pos).Data())); |
469 | if (cfg.GetPrintLevel()) printf("Mask File Name: %s version: %d\n", | |
470 | cfg.GetLocalMaskFileName(), cfg.GetLocalMaskFileVersion()); | |
4fd5ed63 | 471 | } else { |
37dacd7d | 472 | cfg.SetLocalMaskFileLastVersion(atoi(tmp(pos+1, tmp.Length()-pos).Data())); |
473 | if (cfg.GetPrintLevel()) printf("Mask File Name: %s last version: %d\n", | |
474 | cfg.GetLocalMaskFileName(), cfg.GetLocalMaskFileLastVersion()); | |
4fd5ed63 | 475 | } |
476 | // read Lut | |
477 | in.getline(line,80); | |
478 | tmp = line; | |
479 | pos = tmp.First(" "); | |
37dacd7d | 480 | tmp1 = tmp(0, pos); |
481 | cfg.SetLocalLutFileName(tmp1.Data()); | |
4fd5ed63 | 482 | |
483 | if (!lastCurrentFlag) { | |
37dacd7d | 484 | cfg.SetLocalLutFileVersion(atoi(tmp(pos+1, tmp.Length()-pos).Data())); |
485 | if (cfg.GetPrintLevel()) printf("Lut File Name: %s version: %d\n", | |
486 | cfg.GetLocalLutFileName(), cfg.GetLocalLutFileVersion()); | |
4fd5ed63 | 487 | } else { |
37dacd7d | 488 | cfg.SetLocalLutFileLastVersion(atoi(tmp(pos+1, tmp.Length()-pos).Data())); |
489 | if (cfg.GetPrintLevel()) printf("Lut File Name: %s last version: %d\n", | |
490 | cfg.GetLocalLutFileName(), cfg.GetLocalLutFileLastVersion()); | |
4fd5ed63 | 491 | } |
492 | ||
493 | in.getline(line,80); | |
494 | tmp = line; | |
495 | pos = tmp.First(" "); | |
37dacd7d | 496 | tmp1 = tmp(0, pos); |
497 | cfg.SetSignatureFileName(tmp1.Data()); | |
498 | cfg.SetSignatureFileVersion(atoi(tmp(pos+1, tmp.Length()-pos).Data())); | |
499 | if (cfg.GetPrintLevel()) printf("Lut File Name: %s version: %d\n", | |
500 | cfg.GetSignatureFileName(), cfg.GetSignatureFileVersion()); | |
4fd5ed63 | 501 | |
502 | return true; | |
503 | } | |
504 | ||
505 | //_____________ | |
37dacd7d | 506 | void ReadFileNames(AliDAConfig& cfg) |
4fd5ed63 | 507 | { |
37dacd7d | 508 | /// if last current file does not exist than read current file |
327f7faa | 509 | |
37dacd7d | 510 | if (!ReadCurrentFile(cfg,cfg.GetLastCurrentFileName(), true)) |
4fd5ed63 | 511 | { |
37dacd7d | 512 | ReadCurrentFile(cfg,cfg.GetCurrentFileName(), true); |
4fd5ed63 | 513 | } |
37dacd7d | 514 | |
515 | // any case read current file | |
516 | ReadCurrentFile(cfg,cfg.GetCurrentFileName()); | |
517 | ||
4fd5ed63 | 518 | } |
519 | ||
520 | //__________________ | |
37dacd7d | 521 | Bool_t ExportFiles(AliDAConfig& cfg) |
4fd5ed63 | 522 | { |
37dacd7d | 523 | /// Export files to FES |
4fd5ed63 | 524 | |
4fd5ed63 | 525 | // env variables have to be set (suppose by ECS ?) |
526 | // setenv DATE_FES_PATH | |
527 | // setenv DATE_RUN_NUMBER | |
528 | // setenv DATE_ROLE_NAME | |
529 | // setenv DATE_DETECTOR_CODE | |
530 | ||
41a38dec | 531 | // offline: |
532 | //gSystem->Setenv("DAQDALIB_PATH", "$DATE_SITE/infoLogger"); | |
113ad708 | 533 | |
8f8ae0de | 534 | // offline: use a dummy FES (local directory) |
535 | //gSystem->Setenv("DAQDA_TEST_DIR", "/alisoft/FES"); | |
536 | ||
4fd5ed63 | 537 | // update files |
538 | Int_t status = 0; | |
539 | ||
540 | Bool_t modified = false; | |
541 | ||
542 | ofstream out; | |
543 | TString fileExp("ExportedFiles.dat"); | |
544 | TString file; | |
545 | ||
546 | out.open(fileExp.Data()); | |
547 | if (!out.good()) { | |
548 | printf("Failed to create file: %s\n",file.Data()); | |
549 | return false; | |
113ad708 | 550 | } |
4fd5ed63 | 551 | |
8f8ae0de | 552 | // check if MtgLastCurrent.dat exists |
553 | // if not, do initial export of all files | |
554 | Bool_t initFES = false; | |
555 | if (gSystem->AccessPathName("MtgLastCurrent.dat")) | |
556 | initFES = true; | |
557 | if (initFES) printf("Copy all configuration files to the FES.\n"); | |
558 | ||
37dacd7d | 559 | file = cfg.GetGlobalFileName(); |
560 | if ((cfg.GetGlobalFileLastVersion() != cfg.GetGlobalFileVersion()) || initFES) { | |
4fd5ed63 | 561 | status = daqDA_FES_storeFile(file.Data(), file.Data()); |
562 | if (status) { | |
37dacd7d | 563 | printf("Failed to export file: %s\n",cfg.GetGlobalFileName()); |
4fd5ed63 | 564 | return false; |
565 | } | |
37dacd7d | 566 | if(cfg.GetPrintLevel()) printf("Export file: %s\n",cfg.GetGlobalFileName()); |
567 | out << cfg.GetGlobalFileName() << endl; | |
4fd5ed63 | 568 | } |
569 | ||
37dacd7d | 570 | file = cfg.GetLocalMaskFileName(); |
571 | if ((cfg.GetLocalMaskFileLastVersion() != cfg.GetLocalMaskFileVersion()) || initFES) { | |
4fd5ed63 | 572 | modified = true; |
4fd5ed63 | 573 | status = daqDA_FES_storeFile(file.Data(), file.Data()); |
574 | if (status) { | |
37dacd7d | 575 | printf("Failed to export file: %s\n",cfg.GetLocalMaskFileName()); |
4fd5ed63 | 576 | return false; |
577 | } | |
37dacd7d | 578 | if(cfg.GetPrintLevel()) printf("Export file: %s\n",cfg.GetLocalMaskFileName()); |
579 | out << cfg.GetLocalMaskFileName() << endl; | |
4fd5ed63 | 580 | } |
581 | ||
37dacd7d | 582 | file = cfg.GetLocalLutFileName(); |
583 | if ((cfg.GetLocalLutFileLastVersion() != cfg.GetLocalLutFileVersion()) || initFES) { | |
4fd5ed63 | 584 | modified = true; |
585 | status = daqDA_FES_storeFile(file.Data(), file.Data()); | |
586 | if (status) { | |
37dacd7d | 587 | printf("Failed to export file: %s\n",cfg.GetLocalLutFileName()); |
4fd5ed63 | 588 | return false; |
589 | } | |
37dacd7d | 590 | if(cfg.GetPrintLevel()) printf("Export file: %s\n",cfg.GetLocalLutFileName()); |
591 | out << cfg.GetLocalLutFileName() << endl; | |
4fd5ed63 | 592 | |
593 | } | |
594 | ||
595 | // exported regional file whenever mask or/and Lut are modified | |
37dacd7d | 596 | file = cfg.GetRegionalFileName(); |
597 | if ( (cfg.GetRegionalFileLastVersion() != cfg.GetRegionalFileVersion()) || modified || initFES) { | |
4fd5ed63 | 598 | status = daqDA_FES_storeFile(file.Data(), file.Data()); |
599 | if (status) { | |
37dacd7d | 600 | printf("Failed to export file: %s\n",cfg.GetRegionalFileName()); |
4fd5ed63 | 601 | return false; |
602 | } | |
37dacd7d | 603 | if(cfg.GetPrintLevel()) printf("Export file: %s\n",cfg.GetRegionalFileName()); |
604 | out << cfg.GetRegionalFileName() << endl; | |
4fd5ed63 | 605 | } |
606 | ||
607 | out.close(); | |
608 | ||
609 | // export Exported file to FES anyway | |
610 | status = daqDA_FES_storeFile(fileExp.Data(), fileExp.Data()); | |
611 | if (status) { | |
612 | printf("Failed to export file: %s\n", fileExp.Data()); | |
613 | return false; | |
614 | } | |
37dacd7d | 615 | if(cfg.GetPrintLevel()) printf("Export file: %s\n",fileExp.Data()); |
4fd5ed63 | 616 | |
113ad708 | 617 | // write last current file |
37dacd7d | 618 | WriteLastCurrentFile(cfg,cfg.GetLastCurrentFileName()); |
113ad708 | 619 | |
4fd5ed63 | 620 | return true; |
621 | } | |
41a38dec | 622 | |
4fd5ed63 | 623 | //__________________ |
37dacd7d | 624 | Bool_t ImportFiles(AliDAConfig& cfg) |
4fd5ed63 | 625 | { |
37dacd7d | 626 | /// copy locally a file from daq detector config db |
627 | /// The current detector is identified by detector code in variable | |
628 | /// DATE_DETECTOR_CODE. It must be defined. | |
629 | /// If environment variable DAQDA_TEST_DIR is defined, files are copied from | |
630 | /// DAQDA_TEST_DIR instead of the database. | |
631 | /// The usual environment variables are not needed. | |
4fd5ed63 | 632 | |
41a38dec | 633 | Int_t status = 0; |
4fd5ed63 | 634 | |
41a38dec | 635 | // offline: |
113ad708 | 636 | //gSystem->Setenv("DAQDALIB_PATH", "$DATE_SITE/db"); |
113ad708 | 637 | |
37dacd7d | 638 | status = daqDA_DB_getFile(cfg.GetDAConfigFileName(), cfg.GetDAConfigFileName()); |
4fd5ed63 | 639 | if (status) { |
37dacd7d | 640 | printf("Failed to get DA config file from DB: %s\n",cfg.GetDAConfigFileName()); |
4fd5ed63 | 641 | return false; |
642 | } | |
643 | ||
327f7faa | 644 | ReadDAConfig(cfg); |
4fd5ed63 | 645 | |
37dacd7d | 646 | status = daqDA_DB_getFile(cfg.GetCurrentFileName(), cfg.GetCurrentFileName()); |
4fd5ed63 | 647 | if (status) { |
37dacd7d | 648 | printf("Failed to get current config file from DB: %s\n",cfg.GetCurrentFileName()); |
4fd5ed63 | 649 | return false; |
650 | } | |
327f7faa | 651 | |
652 | ReadFileNames(cfg); | |
4fd5ed63 | 653 | |
37dacd7d | 654 | status = daqDA_DB_getFile(cfg.GetGlobalFileName(), cfg.GetGlobalFileName()); |
327f7faa | 655 | if (status) { |
37dacd7d | 656 | printf("Failed to get current config file from DB: %s\n", cfg.GetGlobalFileName()); |
327f7faa | 657 | return false; |
658 | } | |
41a38dec | 659 | |
37dacd7d | 660 | status = daqDA_DB_getFile(cfg.GetRegionalFileName(), cfg.GetRegionalFileName()); |
4fd5ed63 | 661 | if (status) { |
37dacd7d | 662 | printf("Failed to get current config file from DB: %s\n",cfg.GetRegionalFileName()); |
4fd5ed63 | 663 | return false; |
664 | } | |
665 | ||
37dacd7d | 666 | status = daqDA_DB_getFile(cfg.GetLocalMaskFileName(), cfg.GetLocalMaskFileName()); |
4fd5ed63 | 667 | if (status) { |
37dacd7d | 668 | printf("Failed to get current config file from DB: %s\n",cfg.GetLocalMaskFileName()); |
4fd5ed63 | 669 | return false; |
670 | } | |
671 | ||
37dacd7d | 672 | status = daqDA_DB_getFile(cfg.GetLocalLutFileName(), cfg.GetLocalLutFileName()); |
4fd5ed63 | 673 | if (status) { |
37dacd7d | 674 | printf("Failed to get current config file from DB: %s\n",cfg.GetLocalLutFileName()); |
4fd5ed63 | 675 | return false; |
676 | } | |
677 | ||
678 | return true; | |
679 | } | |
680 | ||
681 | //_____________ | |
37dacd7d | 682 | void ReadMaskFiles(AliDAConfig& cfg) |
4fd5ed63 | 683 | { |
37dacd7d | 684 | /// read mask files |
327f7faa | 685 | |
37dacd7d | 686 | const Char_t* localFile = cfg.GetLocalMaskFileName(); |
687 | const Char_t* regionalFile = cfg.GetRegionalFileName(); | |
688 | const Char_t* globalFile = cfg.GetGlobalFileName(); | |
4fd5ed63 | 689 | |
37dacd7d | 690 | cfg.GetTriggerIO()->ReadConfig(localFile, regionalFile, globalFile, cfg.GetLocalMasks(), cfg.GetRegionalMasks(), cfg.GetGlobalMasks()); |
4fd5ed63 | 691 | } |
4fd5ed63 | 692 | |
41a38dec | 693 | //______________________________________________________________ |
37dacd7d | 694 | UInt_t GetFetMode(const AliDAConfig & cfg) |
41a38dec | 695 | { |
37dacd7d | 696 | /// FET mode = 3 to run algorithm for dead global inputs |
697 | /// 0x3 prepulse | |
698 | /// 0x0 internal | |
4fd5ed63 | 699 | |
37dacd7d | 700 | return cfg.GetGlobalMasks()->GetFetRegister(3); |
4fd5ed63 | 701 | |
41a38dec | 702 | } |
4fd5ed63 | 703 | |
41a38dec | 704 | //______________________________________________________________ |
37dacd7d | 705 | void StoreGlobalInput(AliDAConfig& cfg, const UInt_t * const globalInput) |
41a38dec | 706 | { |
37dacd7d | 707 | /// accumulate and build statistics of global input values |
41a38dec | 708 | |
37dacd7d | 709 | for (Int_t ii = 0; ii < cfg.GetGlobalInputs(); ii++) { |
710 | for (Int_t ib = 0; ib < cfg.GetGlobalInputLength(); ib++) { | |
41a38dec | 711 | // lsb -> msb |
37dacd7d | 712 | if (cfg.GetAlgoNoisyInput()) |
713 | cfg.AddAccGlobalInputN(ii,ib,((globalInput[ii] >> ib) & 0x1)); | |
714 | if (cfg.GetAlgoDeadcInput()) | |
715 | cfg.AddAccGlobalInputD(ii,ib,((globalInput[ii] >> ib) & 0x1)); | |
4fd5ed63 | 716 | } |
41a38dec | 717 | } |
4fd5ed63 | 718 | |
719 | } | |
720 | ||
41a38dec | 721 | //______________________________________________________________ |
37dacd7d | 722 | void UpdateGlobalMasks(AliDAConfig& cfg) |
4fd5ed63 | 723 | { |
37dacd7d | 724 | /// update the global masks |
4fd5ed63 | 725 | |
41a38dec | 726 | // offline: |
727 | //gSystem->Setenv("DAQDALIB_PATH", "$DATE_SITE/db"); | |
327f7faa | 728 | |
41a38dec | 729 | Float_t rateN = 0.0, rateD = 0.0; |
730 | UInt_t gmask[4], omask; | |
731 | Bool_t noise, deadc, withEvN, withEvD, updated = false; | |
732 | ||
37dacd7d | 733 | for (Int_t ii = 0; ii < cfg.GetGlobalInputs(); ii++) { |
41a38dec | 734 | gmask[ii] = 0; |
735 | ||
37dacd7d | 736 | for (Int_t ib = 0; ib < cfg.GetGlobalInputLength(); ib++) { |
41a38dec | 737 | // lsb -> msb |
738 | noise = false; | |
739 | deadc = false; | |
740 | withEvN = false; | |
741 | withEvD = false; | |
37dacd7d | 742 | if (cfg.GetEventsN() > cfg.GetMinEvents()) { |
743 | rateN = (Float_t)cfg.GetAccGlobalInputN(ii,ib)/(Float_t)cfg.GetEventsN(); | |
744 | noise = (rateN > cfg.GetThrN()); | |
41a38dec | 745 | withEvN = true; |
4fd5ed63 | 746 | } |
37dacd7d | 747 | if (cfg.GetEventsD() > cfg.GetMinEvents()) { |
748 | rateD = (Float_t)cfg.GetAccGlobalInputD(ii,ib)/(Float_t)cfg.GetEventsD(); | |
749 | deadc = (rateD < cfg.GetThrD()); | |
41a38dec | 750 | withEvD = true; |
751 | } | |
752 | if (!withEvN && !withEvD) { | |
753 | // - copy the bit from the old mask | |
37dacd7d | 754 | gmask[ii] |= ((cfg.GetGlobalMasks()->GetGlobalMask(ii) >> ib) & 0x1) << ib; |
41a38dec | 755 | printf("Mask not changed (just copy the old values)\n"); |
756 | } | |
757 | if (!withEvN && withEvD) { | |
758 | if (!deadc) { | |
759 | // - create a new mask, set the bit to 1 | |
8f8ae0de | 760 | // not allowed! |
761 | //gmask[ii] |= 0x1 << ib; | |
762 | // - copy the bit from the old mask | |
37dacd7d | 763 | gmask[ii] |= ((cfg.GetGlobalMasks()->GetGlobalMask(ii) >> ib) & 0x1) << ib; |
41a38dec | 764 | } else { |
765 | // - create a new mask, set the bit to 0 | |
766 | gmask[ii] |= 0x0 << ib; | |
327f7faa | 767 | printf("Found dead channel %1d:%02d (%4.2f) \n",ii,ib,rateD); |
4fd5ed63 | 768 | } |
41a38dec | 769 | } |
770 | if (withEvN && !withEvD) { | |
771 | if (!noise) { | |
772 | // - create a new mask, set the bit to 1 | |
8f8ae0de | 773 | // not allowed! |
774 | //gmask[ii] |= 0x1 << ib; | |
775 | // - copy the bit from the old mask | |
37dacd7d | 776 | gmask[ii] |= ((cfg.GetGlobalMasks()->GetGlobalMask(ii) >> ib) & 0x1) << ib; |
41a38dec | 777 | } else { |
778 | // - create a new mask, set the bit to 0 | |
779 | gmask[ii] |= 0x0 << ib; | |
327f7faa | 780 | printf("Found noisy channel %1d:%02d (%4.2f) \n",ii,ib,rateN); |
41a38dec | 781 | } |
782 | } | |
783 | if (withEvN && withEvD) { | |
784 | if (!noise && !deadc) { | |
785 | // - create a new mask, set the bit to 1 | |
8f8ae0de | 786 | // not allowed! |
787 | //gmask[ii] |= 0x1 << ib; | |
788 | // - copy the bit from the old mask | |
37dacd7d | 789 | gmask[ii] |= ((cfg.GetGlobalMasks()->GetGlobalMask(ii) >> ib) & 0x1) << ib; |
41a38dec | 790 | } else { |
791 | // - create a new mask, set the bit to 0 | |
792 | gmask[ii] |= 0x0 << ib; | |
793 | if (noise) | |
327f7faa | 794 | printf("Found noisy channel %1d:%02d (%4.2f) \n",ii,ib,rateN); |
41a38dec | 795 | if (deadc) |
327f7faa | 796 | printf("Found dead channel %1d:%02d (%4.2f) \n",ii,ib,rateD); |
4fd5ed63 | 797 | } |
4fd5ed63 | 798 | } |
799 | } | |
41a38dec | 800 | } |
801 | ||
802 | // check if at least one mask value has been changed from previous version | |
37dacd7d | 803 | for (Int_t ii = 0; ii < cfg.GetGlobalInputs(); ii++) { |
327f7faa | 804 | printf("Global mask [%1d] %08x \n",ii,gmask[ii]); |
37dacd7d | 805 | omask = cfg.GetGlobalMasks()->GetGlobalMask(ii); |
41a38dec | 806 | if (gmask[ii] != omask) { |
807 | updated = true; | |
37dacd7d | 808 | cfg.GetGlobalMasks()->SetGlobalMask(ii,gmask[ii]); |
4fd5ed63 | 809 | } |
41a38dec | 810 | } |
4fd5ed63 | 811 | |
41a38dec | 812 | Int_t status = 0; |
813 | if (updated) { | |
814 | ||
815 | // update version | |
37dacd7d | 816 | cfg.IncGlobalFileVersion(); |
41a38dec | 817 | |
818 | // don't change the file version ("-x.dat") | |
819 | ||
37dacd7d | 820 | cfg.GetTriggerIO()->WriteGlobalConfig(cfg.GetGlobalFileName(),cfg.GetGlobalMasks()); |
41a38dec | 821 | |
822 | // write last current file | |
37dacd7d | 823 | WriteLastCurrentFile(cfg,cfg.GetCurrentFileName()); |
4fd5ed63 | 824 | |
37dacd7d | 825 | status = daqDA_DB_storeFile(cfg.GetGlobalFileName(), cfg.GetGlobalFileName()); |
41a38dec | 826 | if (status) { |
37dacd7d | 827 | printf("Failed to export file to DB: %s\n",cfg.GetGlobalFileName()); |
41a38dec | 828 | return; |
829 | } | |
830 | ||
37dacd7d | 831 | status = daqDA_DB_storeFile(cfg.GetCurrentFileName(), cfg.GetCurrentFileName()); |
41a38dec | 832 | if (status) { |
37dacd7d | 833 | printf("Failed to export file to DB: %s\n",cfg.GetCurrentFileName()); |
41a38dec | 834 | return; |
835 | } | |
113ad708 | 836 | |
41a38dec | 837 | } |
838 | ||
839 | } | |
113ad708 | 840 | |
9f5fafa6 | 841 | //*************************************************************// |
9f5fafa6 | 842 | int main(Int_t argc, Char_t **argv) |
843 | { | |
37dacd7d | 844 | /// main routine |
9f5fafa6 | 845 | |
846 | // needed for streamer application | |
327f7faa | 847 | gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo", "*", "TStreamerInfo", "RIO", "TStreamerInfo()"); |
848 | ||
849 | /* check that we got some arguments = list of files */ | |
850 | if (argc<2) { | |
851 | printf("Wrong number of arguments\n"); | |
852 | return -1; | |
853 | } | |
854 | ||
37dacd7d | 855 | AliDAConfig cfg; |
9f5fafa6 | 856 | |
8f8ae0de | 857 | Char_t inputFile[256] = ""; |
113ad708 | 858 | inputFile[0] = 0; |
859 | if (argc > 1) | |
860 | if (argv[1] != NULL) | |
861 | strncpy(inputFile, argv[1], 256); | |
862 | else { | |
863 | printf("MUONTRGda : No input File !\n"); | |
864 | return -1; | |
865 | } | |
9f5fafa6 | 866 | |
4fd5ed63 | 867 | // decoding the events |
9f5fafa6 | 868 | |
4fd5ed63 | 869 | Int_t status; |
870 | Int_t nDateEvents = 0; | |
9f5fafa6 | 871 | |
4fd5ed63 | 872 | void* event; |
9f5fafa6 | 873 | |
4fd5ed63 | 874 | // containers |
875 | AliMUONDDLTrigger* ddlTrigger = 0x0; | |
876 | AliMUONDarcHeader* darcHeader = 0x0; | |
9f5fafa6 | 877 | |
4fd5ed63 | 878 | TStopwatch timers; |
9f5fafa6 | 879 | |
4fd5ed63 | 880 | timers.Start(kTRUE); |
9f5fafa6 | 881 | |
4fd5ed63 | 882 | // comment out, since we do not retrieve files from database |
327f7faa | 883 | if (!ImportFiles(cfg)) { |
4fd5ed63 | 884 | printf("Import from DB failed\n"); |
885 | printf("For local test set DAQDA_TEST_DIR to the local directory where the Mtg files are located \n"); | |
9f5fafa6 | 886 | return -1; |
887 | } | |
327f7faa | 888 | |
889 | ReadMaskFiles(cfg); | |
4fd5ed63 | 890 | |
8f8ae0de | 891 | // offline: the run number extracted from the file name |
892 | //TString tmp(inputFile); | |
893 | //Int_t pos = tmp.First("daq"); | |
894 | //tmp = tmp(pos+3,5); | |
895 | //gSystem->Setenv("DATE_RUN_NUMBER",tmp.Data()); | |
896 | //gSystem->Exec("echo \"DATE_RUN_NUMBER = \" $DATE_RUN_NUMBER"); | |
37dacd7d | 897 | |
327f7faa | 898 | if(!ExportFiles(cfg)) { |
41a38dec | 899 | printf("ExportFiles failed\n"); |
900 | return -1; | |
901 | } | |
902 | ||
41a38dec | 903 | // FET is triggered by CTP |
327f7faa | 904 | if (GetFetMode(cfg) != 3) { |
41a38dec | 905 | printf("FET is not in mode 3\n"); |
906 | return -1; | |
907 | } | |
908 | ||
909 | // All 5 global cards are controlled by the Mts proxy | |
37dacd7d | 910 | if (cfg.GetGlobalMasks()->GetGlobalCrateEnable() != 0x1F) { |
41a38dec | 911 | printf("The MTS proxy does not control all global cards\n"); |
912 | return -1; | |
913 | } | |
113ad708 | 914 | |
41a38dec | 915 | // The global cards are ON (active on the global inputs) |
37dacd7d | 916 | if (!cfg.GetGlobalMasks()->GetMasksOn()) { |
41a38dec | 917 | printf("Global masks are not ON\n"); |
918 | return -1; | |
919 | } | |
113ad708 | 920 | |
41a38dec | 921 | // make sure to catch the "rare" calib events (1 every 50s in physics) |
922 | const Char_t* tableSOD[] = {"ALL", "yes", "CAL", "all", NULL, NULL}; | |
923 | monitorDeclareTable(const_cast<char**>(tableSOD)); | |
924 | ||
4fd5ed63 | 925 | status = monitorSetDataSource(inputFile); |
926 | if (status) { | |
927 | cerr << "ERROR : monitorSetDataSource status (hex) = " << hex << status | |
928 | << " " << monitorDecodeError(status) << endl; | |
929 | return -1; | |
930 | } | |
931 | status = monitorDeclareMp("MUON Trigger monitoring"); | |
932 | if (status) { | |
933 | cerr << "ERROR : monitorDeclareMp status (hex) = " << hex << status | |
934 | << " " << monitorDecodeError(status) << endl; | |
935 | return -1; | |
9f5fafa6 | 936 | } |
937 | ||
113ad708 | 938 | /* define wait event timeout - 1s max */ |
939 | monitorSetNowait(); | |
940 | monitorSetNoWaitNetworkTimeout(1000); | |
941 | ||
113ad708 | 942 | cout << "MUONTRGda : Reading data from file " << inputFile <<endl; |
4fd5ed63 | 943 | |
41a38dec | 944 | UInt_t *globalInput; |
945 | Bool_t doUpdate = false; | |
327f7faa | 946 | Int_t runNumber = 0; |
947 | Int_t nEvents = 0; | |
948 | ||
4fd5ed63 | 949 | while(1) |
950 | { | |
37dacd7d | 951 | if (nEvents >= cfg.GetMaxEvents()) break; |
327f7faa | 952 | if (nEvents && nEvents % 100 == 0) |
953 | cout<<"Cumulated events " << nEvents << endl; | |
9f5fafa6 | 954 | |
4fd5ed63 | 955 | // check shutdown condition |
956 | if (daqDA_checkShutdown()) | |
957 | break; | |
958 | ||
959 | // Skip Events if needed | |
37dacd7d | 960 | while (cfg.GetSkipEvents()) { |
4fd5ed63 | 961 | status = monitorGetEventDynamic(&event); |
37dacd7d | 962 | cfg.DecSkipEvents(); |
4fd5ed63 | 963 | } |
964 | ||
965 | // starts reading | |
966 | status = monitorGetEventDynamic(&event); | |
967 | if (status < 0) { | |
113ad708 | 968 | cout << "MUONTRGda : EOF found" << endl; |
4fd5ed63 | 969 | break; |
970 | } | |
971 | ||
972 | nDateEvents++; | |
973 | ||
974 | // decoding rawdata headers | |
975 | AliRawReader *rawReader = new AliRawReaderDate(event); | |
9f5fafa6 | 976 | |
4fd5ed63 | 977 | Int_t eventType = rawReader->GetType(); |
327f7faa | 978 | runNumber = rawReader->GetRunNumber(); |
9f5fafa6 | 979 | |
113ad708 | 980 | // L1Swc1 |
981 | // CALIBRATION_EVENT | |
982 | // SYSTEM_SOFTWARE_TRIGGER_EVENT | |
983 | // DETECTOR_SOFTWARE_TRIGGER_EVENT | |
37dacd7d | 984 | cfg.SetAlgoNoisyInput(false); |
985 | cfg.SetAlgoDeadcInput(false); | |
41a38dec | 986 | if (eventType == PHYSICS_EVENT) { |
37dacd7d | 987 | cfg.SetAlgoNoisyInput(true); |
41a38dec | 988 | doUpdate = true; |
37dacd7d | 989 | cfg.IncNoiseEvent(); |
41a38dec | 990 | } else if (eventType == CALIBRATION_EVENT) { |
37dacd7d | 991 | cfg.SetAlgoDeadcInput(true); |
41a38dec | 992 | doUpdate = true; |
37dacd7d | 993 | cfg.IncDeadcEvent(); |
41a38dec | 994 | } else { |
995 | continue; | |
996 | } | |
997 | ||
327f7faa | 998 | nEvents++; |
37dacd7d | 999 | if (cfg.GetPrintLevel()) printf("\nEvent # %d\n",nEvents); |
9f5fafa6 | 1000 | |
4fd5ed63 | 1001 | // decoding MUON payload |
1002 | AliMUONRawStreamTrigger* rawStream = new AliMUONRawStreamTrigger(rawReader); | |
8f8ae0de | 1003 | // ... without warnings from the decoder !!! |
37dacd7d | 1004 | if (!cfg.WithWarnings()) |
8f8ae0de | 1005 | rawStream->DisableWarnings(); |
9f5fafa6 | 1006 | |
4fd5ed63 | 1007 | // loops over DDL |
1008 | while((status = rawStream->NextDDL())) { | |
9f5fafa6 | 1009 | |
37dacd7d | 1010 | if (cfg.GetPrintLevel()) printf("iDDL %d\n", rawStream->GetDDL()); |
9f5fafa6 | 1011 | |
4fd5ed63 | 1012 | ddlTrigger = rawStream->GetDDLTrigger(); |
1013 | darcHeader = ddlTrigger->GetDarcHeader(); | |
9f5fafa6 | 1014 | |
41a38dec | 1015 | if (rawStream->GetDDL() == 0) { |
37dacd7d | 1016 | if (cfg.GetPrintLevel()) printf("Global output %x\n", (Int_t)darcHeader->GetGlobalOutput()); |
41a38dec | 1017 | globalInput = darcHeader->GetGlobalInput(); |
327f7faa | 1018 | StoreGlobalInput(cfg,globalInput); |
41a38dec | 1019 | } |
9f5fafa6 | 1020 | |
4fd5ed63 | 1021 | } // NextDDL |
1022 | ||
1023 | delete rawReader; | |
1024 | delete rawStream; | |
1025 | ||
1026 | } // while (1) | |
1027 | ||
41a38dec | 1028 | // update configuration files ifrequested event types were found |
37dacd7d | 1029 | if (doUpdate && cfg.GetDAFlag()) |
327f7faa | 1030 | UpdateGlobalMasks(cfg); |
9f5fafa6 | 1031 | |
4fd5ed63 | 1032 | timers.Stop(); |
9f5fafa6 | 1033 | |
37dacd7d | 1034 | cout << "MUONTRGda: DA enable: \t" << cfg.GetDAFlag() << endl; |
327f7faa | 1035 | cout << "MUONTRGda: Run number: \t" << runNumber << endl; |
1036 | cout << "MUONTRGda: Nb of DATE events: \t" << nDateEvents << endl; | |
1037 | cout << "MUONTRGda: Nb of events used: \t" << nEvents << endl; | |
37dacd7d | 1038 | cout << "MUONTRGda: Nb of events used (noise): \t" << cfg.GetEventsN() << endl; |
1039 | cout << "MUONTRGda: Nb of events used (deadc): \t" << cfg.GetEventsD() << endl; | |
1040 | cout << "MUONTRGda: Minumum nr of events for rate calculation: \t" << cfg.GetMinEvents() << endl; | |
1041 | cout << "MUONTRGda: Maximum nr of analyzed events: \t" << cfg.GetMaxEvents() << endl; | |
1042 | cout << "MUONTRGda: Skip events from start: \t" << cfg.GetSkipEvents() << endl; | |
1043 | cout << "MUONTRGda: Threshold for noisy inputs: \t" << 100*cfg.GetThrN() << "%" << endl; | |
1044 | cout << "MUONTRGda: Threshold for dead inputs: \t" << 100*cfg.GetThrD() << "%" << endl; | |
1045 | cout << "MUONTRGda: Print level: \t" << cfg.GetPrintLevel() << endl; | |
1046 | cout << "MUONTRGda: Show decoder warnings: \t" << cfg.WithWarnings() << endl; | |
327f7faa | 1047 | |
1048 | printf("MUONTRGda: Execution time : R:%7.2fs C:%7.2fs\n", timers.RealTime(), timers.CpuTime()); | |
1049 | ||
9f5fafa6 | 1050 | |
4fd5ed63 | 1051 | return status; |
41a38dec | 1052 | |
9f5fafa6 | 1053 | } |
92c23b09 | 1054 |