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