4 Contact: Franck Manso <manso@clermont.in2p3.fr>
5 Link: http://aliceinfo.cern.ch/static/Offline/dimuon/muon_html/README_mtrda.html
9 Number of events needed: 1000 events
10 Input files: MtgGlobalCrate.dat MtgRegionalCrate.dat MtgLocalMask.dat MtgLocalLut.dat MtgCurrent.dat DAConfig.dat
11 Output Files: ExportedFiles.dat MtgGlobalCrate.dat
12 Trigger types used: PHYSICS_EVENT CALIBRATION_EVENT
15 //////////////////////////////////////////////////////////////////////////////
16 // Detector Algorithm for the MUON trigger configuration. //
18 // Calculates masks for the global trigger input, by looking at dead //
19 // channels in calibration events and at noisy channels in physics events. //
20 // Transfers trigger configuration files to the File Exchange Server and //
21 // writes them (if modified) into the trigger configuration data base. //
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) //
28 //////////////////////////////////////////////////////////////////////////////
39 #include <Riostream.h>
43 #include "AliRawReaderDate.h"
45 #include "AliMpConstants.h"
46 #include "AliMUONRawStreamTrigger.h"
47 #include "AliMUONRawStreamTriggerHP.h"
48 #include "AliMUONDarcHeader.h"
49 #include "AliMUONRegHeader.h"
50 #include "AliMUONDDLTrigger.h"
51 #include "AliMUONVStore.h"
52 #include "AliMUON1DArray.h"
53 #include "AliMUONTriggerIO.h"
54 #include "AliMUONRegionalTriggerConfig.h"
55 #include "AliMUONGlobalCrateConfig.h"
56 #include "AliMUONVCalibParam.h"
57 #include "AliMUONCalibParamND.h"
58 #include "AliMUONCalibParamNI.h"
59 #include "AliMUONLocalStruct.h"
63 #include "TStopwatch.h"
65 #include "TPluginManager.h"
68 /// class for DA run parameters and DA working space
69 class AliDAConfig : TObject {
74 fDAConfigFileName("DAConfig.dat"),
75 fCurrentFileName("MtgCurrent.dat"),
76 fLastCurrentFileName("MtgLastCurrent.dat"),
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),
103 fTriggerIO(new AliMUONTriggerIO),
104 fAlgoNoisyInput(kFALSE),
105 fAlgoDeadcInput(kFALSE),
113 fWithWarnings(kFALSE),
114 fUseFastDecoder(kFALSE),
115 fNLocalBoard(AliMpConstants::TotalNofLocalBoards()+1),
119 /// default constructor
120 for (Int_t ii = 0; ii < kGlobalInputs; ii++) {
121 for (Int_t il = 0; il < kGlobalInputLength; il++) {
122 fAccGlobalInputN[ii][il] = 0;
123 fAccGlobalInputD[ii][il] = 0;
126 fLocalMasks = new AliMUON1DArray(fNLocalBoard);
127 fLocalMasksDA = new AliMUON1DArray(fNLocalBoard);
128 fRegionalMasks = new AliMUONRegionalTriggerConfig();
129 fGlobalMasks = new AliMUONGlobalCrateConfig();
130 fPatternStoreN = new AliMUON1DArray(fNLocalBoard);
131 fPatternStoreD = new AliMUON1DArray(fNLocalBoard);
133 // Generate local trigger masks store. All masks are set to FFFF
134 for (Int_t i = 1; i <= AliMpConstants::TotalNofLocalBoards(); i++) {
135 AliMUONVCalibParam* localBoard = new AliMUONCalibParamNI(1,8,i,0,0);
136 for (Int_t x = 0; x < 2; x++) {
137 for (Int_t y = 0; y < 4; y++) {
139 localBoard->SetValueAsInt(index,0,0xFFFF);
142 fLocalMasksDA->Add(localBoard);
147 virtual ~AliDAConfig()
151 delete fLocalMasksDA;
152 delete fRegionalMasks;
154 delete fPatternStoreN;
155 delete fPatternStoreD;
160 /// print DA parameters
161 printf("DA config file name: %s \n",GetDAConfigFileName());
162 printf("Current file name: %s \n",GetCurrentFileName());
163 printf("Last current file name: %s \n",GetLastCurrentFileName());
164 printf("Global file name: %s (%d %d)\n",GetGlobalFileName(),GetGlobalFileVersion(),GetGlobalFileLastVersion());
165 printf("Regional file name: %s (%d %d)\n",GetRegionalFileName(),GetRegionalFileVersion(),GetRegionalFileLastVersion());
166 printf("Local mask file name: %s (%d %d)\n",GetLocalMaskFileName(),GetLocalMaskFileVersion(),GetLocalMaskFileLastVersion());
167 printf("Local LUT file name: %s (%d %d)\n",GetLocalLutFileName(),GetLocalLutFileVersion(),GetLocalLutFileLastVersion());
168 printf("Signature file name: %s (%d)\n",GetSignatureFileName(),GetSignatureFileVersion());
171 /// name of the DA configuration file from detector DB
172 const Char_t* GetDAConfigFileName() { return fDAConfigFileName.Data(); }
173 /// file with current versions of the configuration files, usually MtgCurrent.dat
174 const Char_t* GetCurrentFileName() { return fCurrentFileName.Data(); }
175 /// last known versions of the configuration files, usually MtgLastCurrent.dat
176 const Char_t* GetLastCurrentFileName() { return fLastCurrentFileName.Data(); }
178 /// name of the Start-of-data field in MtgCurrent.dat
179 const Char_t* GetSodName() { return fSodName.Data(); }
180 /// flag value of the Start-of-data field in MtgCurrent.dat
181 Int_t GetSodFlag() const { return fSodFlag; }
183 /// name of the Detector Algorithm field in MtgCurrent.dat
184 const Char_t* GetDAName() { return fDAName.Data(); }
185 /// flag value of the Detector Algorithm field in MtgCurrent.dat
186 Int_t GetDAFlag() const { return fDAFlag; }
187 /// DA active mode (GLOBAL or GLOBAL+LOCAL)
188 Int_t GetDAMode() const { return fDAMode; }
190 /// global crate configuration file name
191 const Char_t* GetGlobalFileName() { return fGlobalFileName.Data(); }
192 /// regional crate configuration file name
193 const Char_t* GetRegionalFileName() { return fRegionalFileName.Data(); }
194 /// masks for the local cards, file name
195 const Char_t* GetLocalMaskFileName() { return fLocalMaskFileName.Data(); }
196 /// transverse momentum Look-Up-Table, file name
197 const Char_t* GetLocalLutFileName() { return fLocalLutFileName.Data(); }
198 /// signature file name
199 const Char_t* GetSignatureFileName() { return fSignatureFileName.Data(); }
201 /// version of the global crate configuration in the detector DB
202 Int_t GetGlobalFileVersion() const { return fGlobalFileVersion; }
203 /// version of the regional crate configuration in the detector DB
204 Int_t GetRegionalFileVersion() const { return fRegionalFileVersion; }
205 /// version of the masks for the local cards in the detector DB
206 Int_t GetLocalMaskFileVersion() const { return fLocalMaskFileVersion; }
207 /// version of the transverse momentum Look-Up-Table in the detector DB
208 Int_t GetLocalLutFileVersion() const { return fLocalLutFileVersion; }
209 /// version of the signature file in the detector DB
210 Int_t GetSignatureFileVersion() const { return fSignatureFileVersion; }
212 /// last known version of the global crate configuration
213 Int_t GetGlobalFileLastVersion() const { return fGlobalFileLastVersion; }
214 /// last known version of the regional crate configuration
215 Int_t GetRegionalFileLastVersion() const { return fRegionalFileLastVersion; }
216 /// last known version of the masks for the local cards
217 Int_t GetLocalMaskFileLastVersion() const { return fLocalMaskFileLastVersion; }
218 /// last known version of the transverse momentum Look-Up-Table
219 Int_t GetLocalLutFileLastVersion() const { return fLocalLutFileLastVersion; }
221 /// store for the masks for the local cards (own)
222 AliMUONVStore* GetLocalMasks() const { return fLocalMasks; }
223 /// store for the DA-calculated masks for the local cards (own)
224 AliMUONVStore* GetLocalMasksDA() const { return fLocalMasksDA; }
225 /// configuration object for the regional crate (own)
226 AliMUONRegionalTriggerConfig* GetRegionalMasks() const { return fRegionalMasks; }
227 /// configuration object for the global crate (own)
228 AliMUONGlobalCrateConfig* GetGlobalMasks() const { return fGlobalMasks; }
230 /// read/write configurations, masks and LUT to/from online files (own)
231 AliMUONTriggerIO* GetTriggerIO() const { return fTriggerIO; }
233 /// store for local strips patterns (noisy strips)
234 AliMUONVStore* GetPatternStoreN() const { return fPatternStoreN; }
235 /// store for local strips patterns (dead strips)
236 AliMUONVStore* GetPatternStoreD() const { return fPatternStoreD; }
238 /// number of accumulated PHYSICS events for noisy channels analysis
239 Int_t GetEventsN() const { return fEventsN; }
240 /// number of accumulated CALIBRATION events for dead channels analysis
241 Int_t GetEventsD() const { return fEventsD; }
243 /// print verbosity of the DA
244 Int_t GetPrintLevel() const { return fPrintLevel; }
246 /// select PHYSICS events for noisy channels analysis
247 Bool_t GetAlgoNoisyInput() const { return fAlgoNoisyInput; }
248 /// select CALIBRATION events for dead channels analysis
249 Bool_t GetAlgoDeadcInput() const { return fAlgoDeadcInput; }
251 /// threshold for noisy global inputs (fraction of events)
252 Float_t GetThrN() const { return fThrN; }
253 /// threshold for dead global inputs (fraction of events)
254 Float_t GetThrD() const { return fThrD; }
255 /// threshold for noisy local strips (fraction of events)
256 Float_t GetThrLocN() const { return fThrLocN; }
257 /// threshold for dead local strips (fraction of events)
258 Float_t GetThrLocD() const { return fThrLocD; }
260 /// minumum nr of events for rate calculation
261 Int_t GetMinEvents() const { return fMinEvents; }
262 /// maximum number of events to analyze
263 Int_t GetMaxEvents() const { return fMaxEvents; }
264 /// number of events to skip from start
265 Int_t GetSkipEvents() const { return fSkipEvents; }
267 /// show warnings from the raw data decoder
268 Bool_t WithWarnings() const { return fWithWarnings; }
269 /// use the high-performance (HP) decoder
270 Bool_t UseFastDecoder() const { return fUseFastDecoder; }
272 /// number of global input words
273 Int_t GetGlobalInputs() const { return kGlobalInputs; }
274 /// length in bits of a global input word
275 Int_t GetGlobalInputLength() const { return kGlobalInputLength; }
277 /// get accumulated values for bit "ib" from global input word "ii", PHYSICS events
278 Int_t GetAccGlobalInputN(Int_t ii, Int_t ib) const { return fAccGlobalInputN[ii][ib]; }
279 /// get accumulated values for bit "ib" from global input word "ii", CALIBRATION events
280 Int_t GetAccGlobalInputD(Int_t ii, Int_t ib) const { return fAccGlobalInputD[ii][ib]; }
282 /// set the name of the Start-of-data field in MtgCurrent.dat
283 void SetSodName(Char_t *name) { fSodName = TString(name); }
284 /// set the flag value of the Start-of-data field in MtgCurrent.dat
285 void SetSodFlag(Int_t flag) { fSodFlag = flag; }
287 /// set the name of the Detector Algorithm field in MtgCurrent.dat
288 void SetDAName(Char_t *name) { fDAName = TString(name); }
289 /// set the flag value of the Detector Algorithm field in MtgCurrent.dat
290 void SetDAFlag(Int_t flag) { fDAFlag = flag; }
291 /// set DA active mode, 1 = GLOBAL (default), 2 = GLOBAL and LOCAL
292 void SetDAMode(Int_t mode) { fDAMode = mode; }
294 /// set the global crate configuration file name
295 void SetGlobalFileName(const Char_t *name) { fGlobalFileName = TString(name); }
296 /// set the regional crate configuration file name
297 void SetRegionalFileName(const Char_t *name) { fRegionalFileName = TString(name); }
298 /// set the masks for the local cards, file name
299 void SetLocalMaskFileName(const Char_t *name) { fLocalMaskFileName = TString(name); }
300 /// set the transverse momentum Look-Up-Table, file name
301 void SetLocalLutFileName(const Char_t *name) { fLocalLutFileName = TString(name); }
302 /// set the signature file name
303 void SetSignatureFileName(const Char_t *name) { fSignatureFileName = TString(name); }
305 /// set the version of the global crate configuration in the detector DB
306 void SetGlobalFileVersion(Int_t ver) { fGlobalFileVersion = ver; }
307 /// set the version of the regional crate configuration in the detector DB
308 void SetRegionalFileVersion(Int_t ver) { fRegionalFileVersion = ver; }
309 /// set the version of the masks for the local cards in the detector DB
310 void SetLocalMaskFileVersion(Int_t ver) { fLocalMaskFileVersion = ver; }
311 /// set the version of the transverse momentum Look-Up-Table in the detector DB
312 void SetLocalLutFileVersion(Int_t ver) { fLocalLutFileVersion = ver; }
313 /// set the version of the signature file in the detector DB
314 void SetSignatureFileVersion(Int_t ver) { fSignatureFileVersion = ver; }
316 /// set the last known version of the global crate configuration
317 void SetGlobalFileLastVersion(Int_t ver) { fGlobalFileLastVersion = ver; }
318 /// set the last known version of the regional crate configuration
319 void SetRegionalFileLastVersion(Int_t ver) { fRegionalFileLastVersion = ver; }
320 /// set the last known version of the masks for the local cards
321 void SetLocalMaskFileLastVersion(Int_t ver) { fLocalMaskFileLastVersion = ver; }
322 /// set the last known version of the transverse momentum Look-Up-Table
323 void SetLocalLutFileLastVersion(Int_t ver) { fLocalLutFileLastVersion = ver; }
325 /// increment the number of selected PHYSICS events
326 void IncNoiseEvent() { fEventsN++; }
327 /// increment the number of selected CALIBRATION events
328 void IncDeadcEvent() { fEventsD++; }
330 /// count the value of the bit "ib" of global input word "ii" (PHYSICS events)
331 void AddAccGlobalInputN(Int_t ii, Int_t ib, Int_t val) { fAccGlobalInputN[ii][ib] += val; }
332 /// count the value of the bit "ib" of global input word "ii" (CALIBRATION events)
333 void AddAccGlobalInputD(Int_t ii, Int_t ib, Int_t val) { fAccGlobalInputD[ii][ib] += val; }
335 /// set the print verbosity level of the DA
336 void SetPrintLevel(Int_t level) { fPrintLevel = level; }
338 /// select PHYSICS events for noisy channels analysis
339 void SetAlgoNoisyInput(Bool_t val) { fAlgoNoisyInput = val; }
340 /// select CALIBRATION events for dead channels analysis
341 void SetAlgoDeadcInput(Bool_t val) { fAlgoDeadcInput = val; }
343 /// set the threshold for noisy global inputs (fraction of events)
344 void SetThrN(Float_t val) { fThrN = val; }
345 /// set the threshold for dead global inputs (fraction of events)
346 void SetThrD(Float_t val) { fThrD = val; }
347 /// set the threshold for noisy local strips (fraction of events)
348 void SetThrLocN(Float_t val) { fThrLocN = val; }
349 /// set the threshold for dead local strips (fraction of events)
350 void SetThrLocD(Float_t val) { fThrLocD = val; }
352 /// set the minumum nr of events for rate calculation
353 void SetMinEvents(Int_t val) { fMinEvents = val; }
354 /// set the maximum number of events to analyze
355 void SetMaxEvents(Int_t val) { fMaxEvents = val; }
356 /// set the number of events to skip from start
357 void SetSkipEvents(Int_t val) { fSkipEvents = val; }
359 /// set/unset to show warnings from the raw data decoder
360 void SetWithWarnings() { fWithWarnings = kTRUE; }
361 /// set/unset the use of the high-performance (HP) decoder
362 void SetUseFastDecoder() { fUseFastDecoder = kTRUE; }
364 /// increment version of the global crate configuration file
365 void IncGlobalFileVersion() { fGlobalFileVersion++; }
366 /// increment version of the local mask configuration file
367 void IncLocalMaskFileVersion() { fLocalMaskFileVersion++; }
368 /// count skipped events
369 void DecSkipEvents() { fSkipEvents--; }
373 /// copy constructor, not implemented
374 AliDAConfig (const AliDAConfig& cfg);
375 /// assignment operator, not implemented
376 AliDAConfig& operator=(const AliDAConfig& cfg);
378 const TString fDAConfigFileName; //!< name of the DA configuration file from detector DB
379 const TString fCurrentFileName; //!< usually MtgCurrent.dat
380 const TString fLastCurrentFileName; //!< usually MtgLastCurrent.dat
382 TString fSodName; //!< name of the Start-of-data field in MtgCurrent.dat
383 Int_t fSodFlag; //!< flag value of the Start-of-data field in MtgCurrent.dat
385 TString fDAName; //!< name of the Detector Algorithm field in MtgCurrent.dat
386 Int_t fDAFlag; //!< flag value of the Detector Algorithm field in MtgCurrent.dat (enabled/disabled)
387 Int_t fDAMode; //!< DA active mode, GLOBAL or GLOBAL+LOCAL
389 TString fGlobalFileName; //!< global crate configuration, file name
390 TString fRegionalFileName; //!< regional crate configuration, file name
391 TString fLocalMaskFileName; //!< masks for the local cards, file name
392 TString fLocalLutFileName; //!< transverse momentum Look-Up-Table, file name
393 TString fSignatureFileName; //!< signature file name
395 Int_t fGlobalFileVersion; //!< version of the global crate configuration in the detector DB
396 Int_t fRegionalFileVersion; //!< version of the regional crate configuration in the detector DB
397 Int_t fLocalMaskFileVersion; //!< version of the masks for the local cards in the detector DB
398 Int_t fLocalLutFileVersion; //!< version of the transverse momentum Look-Up-Table in the detector DB
399 Int_t fSignatureFileVersion; //!< version of the signature file in the detector DB
401 Int_t fGlobalFileLastVersion; //!< last known version of the global crate configuration
402 Int_t fRegionalFileLastVersion; //!< last known version of the regional crate configuration
403 Int_t fLocalMaskFileLastVersion; //!< last known version of the masks for the local cards
404 Int_t fLocalLutFileLastVersion; //!< last known version of the transverse momentum Look-Up-Table
406 Int_t fEventsN; //!< number of accumulated PHYSICS events
407 Int_t fEventsD; //!< number of accumulated CALIBRATION events
409 Int_t fPrintLevel; //!< print verbosity of the DA
411 AliMUONVStore* fLocalMasks; //!< store for the masks for the local cards
412 AliMUONVStore* fLocalMasksDA; //!< store for the DA-calculated masks for the local cards
413 AliMUONRegionalTriggerConfig* fRegionalMasks; //!< configuration object for the regional crate
414 AliMUONGlobalCrateConfig* fGlobalMasks; //!< configuration object for the global crate
416 AliMUONTriggerIO *fTriggerIO; //!< read/write masks and LUT to/from online files
418 Bool_t fAlgoNoisyInput; //!< select PHYSICS events for noisy channels analysis
419 Bool_t fAlgoDeadcInput; //!< select CALIBRATION events for dead channels analysis
421 Float_t fThrN; //!< threshold for noisy global inputs (fraction of events)
422 Float_t fThrD; //!< threshold for dead global inputs (fraction of events)
423 Float_t fThrLocN; //!< threshold for noisy local strips (fraction of events)
424 Float_t fThrLocD; //!< threshold for dead local strips (fraction of events)
425 Int_t fMinEvents; //!< minumum nr of events for rate calculation
426 Int_t fSkipEvents; //!< number of events to skip from start
427 Int_t fMaxEvents; //!< maximum number of events to analyze
428 Bool_t fWithWarnings; //!< show warnings from the raw data decoder
429 Bool_t fUseFastDecoder; //!< use the high-performance (HP) decoder
431 const Int_t fNLocalBoard; //!< number of local boards
433 enum { kGlobalInputs = 4, //!< number of global input words
434 kGlobalInputLength = 32 //!< length in bits of a global input word
437 AliMUONVStore *fPatternStoreN; //!< store for local strips patterns
438 AliMUONVStore *fPatternStoreD; //!< store for local strips patterns
440 Int_t fAccGlobalInputN[kGlobalInputs][kGlobalInputLength]; //!< storage for global input (PHYSICS events)
441 Int_t fAccGlobalInputD[kGlobalInputs][kGlobalInputLength]; //!< storage for global input (CALIBRATION events)
445 //__________________________________________________________________
446 Bool_t ReadDAConfig(AliDAConfig& cfg)
448 /// read run parameters for the DA
453 file = cfg.GetDAConfigFileName();
454 std::ifstream in(gSystem->ExpandPathName(file.Data()));
456 printf("Cannot open DA configuration file %s ; use default values.\n",file.Data());
465 pos = tmp.First(" ");
467 cfg.SetPrintLevel(tmp.Atoi());
471 pos = tmp.First(" ");
473 cfg.SetThrN(tmp.Atof());
477 pos = tmp.First(" ");
479 cfg.SetThrD(tmp.Atof());
483 pos = tmp.First(" ");
485 cfg.SetMinEvents(tmp.Atoi());
489 pos = tmp.First(" ");
491 cfg.SetSkipEvents(tmp.Atoi());
495 pos = tmp.First(" ");
497 cfg.SetMaxEvents(tmp.Atoi());
501 pos = tmp.First(" ");
503 if (tmp.Atoi() != 0) cfg.SetWithWarnings();
507 pos = tmp.First(" ");
509 if (tmp.Atoi() != 0) cfg.SetUseFastDecoder();
513 pos = tmp.First(" ");
515 cfg.SetThrLocN(tmp.Atof());
519 pos = tmp.First(" ");
521 cfg.SetThrLocD(tmp.Atof());
525 pos = tmp.First(" ");
527 cfg.SetDAMode(tmp.Atoi());
533 //__________________________________________________________________
534 void WriteLastCurrentFile(AliDAConfig& cfg, TString currentFile)
536 /// write last current file
541 out.open(file.Data());
542 out << cfg.GetSodName() << " " << cfg.GetSodFlag() << endl;
543 out << cfg.GetDAName() << " " << cfg.GetDAFlag() << endl;
545 out << cfg.GetGlobalFileName() << " " << cfg.GetGlobalFileVersion() << endl;
546 out << cfg.GetRegionalFileName() << " " << cfg.GetRegionalFileVersion() << endl;
547 out << cfg.GetLocalMaskFileName() << " " << cfg.GetLocalMaskFileVersion() << endl;
548 out << cfg.GetLocalLutFileName() << " " << cfg.GetLocalLutFileVersion() << endl;
549 out << cfg.GetSignatureFileName() << " " << cfg.GetSignatureFileVersion() << endl;
554 //___________________________________________________________________________________________
555 Bool_t ReadCurrentFile(AliDAConfig& cfg, TString currentFile, Bool_t lastCurrentFlag = kFALSE)
557 /// read last current file name and version
565 std::ifstream in(gSystem->ExpandPathName(file.Data()));
567 printf("Cannot open last current file %s\n",currentFile.Data());
573 sscanf(line, "%s %d", name, &flag);
574 cfg.SetSodName(name);
575 cfg.SetSodFlag(flag);
576 if (cfg.GetPrintLevel()) printf("Sod Flag %d\n", cfg.GetSodFlag());
580 sscanf(line, "%s %d", name, &flag);
583 if (cfg.GetPrintLevel()) printf("DA Flag: %d\n", cfg.GetDAFlag());
588 Int_t pos = tmp.First(" ");
589 TString tmp1 = tmp(0, pos);
590 cfg.SetGlobalFileName(tmp1.Data());
592 if (!lastCurrentFlag) {
593 cfg.SetGlobalFileVersion(atoi(tmp(pos+1, tmp.Length()-pos).Data()));
594 if (cfg.GetPrintLevel()) printf("Global File Name: %s version: %d\n",
595 cfg.GetGlobalFileName(), cfg.GetGlobalFileVersion());
597 cfg.SetGlobalFileLastVersion(atoi(tmp(pos+1, tmp.Length()-pos).Data()));
598 if (cfg.GetPrintLevel()) printf("Global File Name: %s last version: %d\n",
599 cfg.GetGlobalFileName(), cfg.GetGlobalFileLastVersion());
605 pos = tmp.First(" ");
607 cfg.SetRegionalFileName(tmp1.Data());
609 if (!lastCurrentFlag) {
610 cfg.SetRegionalFileVersion(atoi(tmp(pos+1, tmp.Length()-pos).Data()));
611 if (cfg.GetPrintLevel()) printf("Regional File Name: %s version: %d\n",
612 cfg.GetRegionalFileName(), cfg.GetRegionalFileVersion());
615 cfg.SetRegionalFileLastVersion(atoi(tmp(pos+1, tmp.Length()-pos).Data()));
616 if (cfg.GetPrintLevel()) printf("Regional File Name: %s last version: %d\n",
617 cfg.GetRegionalFileName(), cfg.GetRegionalFileLastVersion());
623 pos = tmp.First(" ");
625 cfg.SetLocalMaskFileName(tmp1.Data());
627 if (!lastCurrentFlag) {
628 cfg.SetLocalMaskFileVersion(atoi(tmp(pos+1, tmp.Length()-pos).Data()));
629 if (cfg.GetPrintLevel()) printf("Mask File Name: %s version: %d\n",
630 cfg.GetLocalMaskFileName(), cfg.GetLocalMaskFileVersion());
632 cfg.SetLocalMaskFileLastVersion(atoi(tmp(pos+1, tmp.Length()-pos).Data()));
633 if (cfg.GetPrintLevel()) printf("Mask File Name: %s last version: %d\n",
634 cfg.GetLocalMaskFileName(), cfg.GetLocalMaskFileLastVersion());
639 pos = tmp.First(" ");
641 cfg.SetLocalLutFileName(tmp1.Data());
643 if (!lastCurrentFlag) {
644 cfg.SetLocalLutFileVersion(atoi(tmp(pos+1, tmp.Length()-pos).Data()));
645 if (cfg.GetPrintLevel()) printf("Lut File Name: %s version: %d\n",
646 cfg.GetLocalLutFileName(), cfg.GetLocalLutFileVersion());
648 cfg.SetLocalLutFileLastVersion(atoi(tmp(pos+1, tmp.Length()-pos).Data()));
649 if (cfg.GetPrintLevel()) printf("Lut File Name: %s last version: %d\n",
650 cfg.GetLocalLutFileName(), cfg.GetLocalLutFileLastVersion());
655 pos = tmp.First(" ");
657 cfg.SetSignatureFileName(tmp1.Data());
658 cfg.SetSignatureFileVersion(atoi(tmp(pos+1, tmp.Length()-pos).Data()));
659 if (cfg.GetPrintLevel()) printf("Lut File Name: %s version: %d\n",
660 cfg.GetSignatureFileName(), cfg.GetSignatureFileVersion());
666 void ReadFileNames(AliDAConfig& cfg)
668 /// if last current file does not exist than read current file
670 if (!ReadCurrentFile(cfg,cfg.GetLastCurrentFileName(), kTRUE))
672 ReadCurrentFile(cfg,cfg.GetCurrentFileName(), kTRUE);
675 // any case read current file
676 ReadCurrentFile(cfg,cfg.GetCurrentFileName());
681 Bool_t ExportFiles(AliDAConfig& cfg)
683 /// Export files to FES
685 // env variables have to be set (suppose by ECS ?)
686 // setenv DATE_FES_PATH
687 // setenv DATE_RUN_NUMBER
688 // setenv DATE_ROLE_NAME
689 // setenv DATE_DETECTOR_CODE
692 gSystem->Setenv("DAQDALIB_PATH", "$DATE_SITE/infoLogger");
693 gSystem->Setenv("DAQDA_TEST_DIR", "/alisoft/FES");
699 Bool_t modified = kFALSE;
700 Bool_t globalExported = kFALSE;
703 TString fileExp("ExportedFiles.dat");
706 out.open(fileExp.Data());
708 printf("Failed to create file: %s\n",file.Data());
712 // check if MtgLastCurrent.dat exists
713 // if not, do initial export of all files
714 Bool_t initFES = kFALSE;
715 if (gSystem->AccessPathName("MtgLastCurrent.dat"))
717 if (initFES) printf("Copy all configuration files to the FES.\n");
719 file = cfg.GetLocalMaskFileName();
720 if ((cfg.GetLocalMaskFileLastVersion() != cfg.GetLocalMaskFileVersion()) || initFES) {
722 status = daqDA_FES_storeFile(file.Data(), "LOCAL");
724 printf("Failed to export file: %s\n",cfg.GetLocalMaskFileName());
727 if(cfg.GetPrintLevel()) printf("Export file: %s\n",cfg.GetLocalMaskFileName());
728 out << cfg.GetLocalMaskFileName() << endl;
731 file = cfg.GetLocalLutFileName();
732 if ((cfg.GetLocalLutFileLastVersion() != cfg.GetLocalLutFileVersion()) || initFES) {
734 status = daqDA_FES_storeFile(file.Data(), "LUT");
736 printf("Failed to export file: %s\n",cfg.GetLocalLutFileName());
739 if(cfg.GetPrintLevel()) printf("Export file: %s\n",cfg.GetLocalLutFileName());
740 out << cfg.GetLocalLutFileName() << endl;
744 file = cfg.GetGlobalFileName();
745 if ((cfg.GetGlobalFileLastVersion() != cfg.GetGlobalFileVersion()) || modified || initFES) {
747 globalExported = kTRUE;
748 status = daqDA_FES_storeFile(file.Data(), "GLOBAL");
750 printf("Failed to export file: %s\n",cfg.GetGlobalFileName());
753 if(cfg.GetPrintLevel()) printf("Export file: %s\n",cfg.GetGlobalFileName());
754 out << cfg.GetGlobalFileName() << endl;
757 file = cfg.GetRegionalFileName();
758 if ( (cfg.GetRegionalFileLastVersion() != cfg.GetRegionalFileVersion()) || modified || initFES) {
759 status = daqDA_FES_storeFile(file.Data(), "REGIONAL");
761 printf("Failed to export file: %s\n",cfg.GetRegionalFileName());
764 if(cfg.GetPrintLevel()) printf("Export file: %s\n",cfg.GetRegionalFileName());
765 out << cfg.GetRegionalFileName() << endl;
767 // needed for the initialisation of the mapping
768 if (!globalExported) {
769 file = cfg.GetGlobalFileName();
770 status = daqDA_FES_storeFile(file.Data(), "GLOBAL");
772 printf("Failed to export file: %s\n",cfg.GetGlobalFileName());
775 if(cfg.GetPrintLevel()) printf("Export file: %s\n",cfg.GetGlobalFileName());
776 out << cfg.GetGlobalFileName() << endl;
783 // export Exported file to FES anyway
784 status = daqDA_FES_storeFile(fileExp.Data(), "EXPORTED");
786 printf("Failed to export file: %s\n", fileExp.Data());
789 if(cfg.GetPrintLevel()) printf("Export file: %s\n",fileExp.Data());
791 // write last current file
792 WriteLastCurrentFile(cfg,cfg.GetLastCurrentFileName());
798 Bool_t ImportFiles(AliDAConfig& cfg)
800 /// copy locally a file from daq detector config db
801 /// The current detector is identified by detector code in variable
802 /// DATE_DETECTOR_CODE. It must be defined.
803 /// If environment variable DAQDA_TEST_DIR is defined, files are copied from
804 /// DAQDA_TEST_DIR instead of the database.
805 /// The usual environment variables are not needed.
810 gSystem->Setenv("DAQDALIB_PATH", "$DATE_SITE/db");
813 status = daqDA_DB_getFile(cfg.GetDAConfigFileName(), cfg.GetDAConfigFileName());
815 printf("Failed to get DA config file from DB: %s\n",cfg.GetDAConfigFileName());
821 status = daqDA_DB_getFile(cfg.GetCurrentFileName(), cfg.GetCurrentFileName());
823 printf("Failed to get current config file from DB: %s\n",cfg.GetCurrentFileName());
829 status = daqDA_DB_getFile(cfg.GetGlobalFileName(), cfg.GetGlobalFileName());
831 printf("Failed to get current config file from DB: %s\n", cfg.GetGlobalFileName());
835 status = daqDA_DB_getFile(cfg.GetRegionalFileName(), cfg.GetRegionalFileName());
837 printf("Failed to get current config file from DB: %s\n",cfg.GetRegionalFileName());
841 status = daqDA_DB_getFile(cfg.GetLocalMaskFileName(), cfg.GetLocalMaskFileName());
843 printf("Failed to get current config file from DB: %s\n",cfg.GetLocalMaskFileName());
847 status = daqDA_DB_getFile(cfg.GetLocalLutFileName(), cfg.GetLocalLutFileName());
849 printf("Failed to get current config file from DB: %s\n",cfg.GetLocalLutFileName());
857 void ReadMaskFiles(AliDAConfig& cfg)
861 const Char_t* localFile = cfg.GetLocalMaskFileName();
862 const Char_t* regionalFile = cfg.GetRegionalFileName();
863 const Char_t* globalFile = cfg.GetGlobalFileName();
865 cfg.GetTriggerIO()->ReadConfig(localFile, regionalFile, globalFile, cfg.GetLocalMasks(), cfg.GetRegionalMasks(), cfg.GetGlobalMasks());
868 //______________________________________________________________
869 UInt_t GetFetMode(const AliDAConfig & cfg)
871 /// FET mode = 3 to run algorithm for dead global inputs
875 return cfg.GetGlobalMasks()->GetFetRegister(3);
879 //______________________________________________________________
880 void StoreGlobalInput(AliDAConfig& cfg, const UInt_t * const globalInput)
882 /// accumulate and build statistics of global input values
884 for (Int_t ii = 0; ii < cfg.GetGlobalInputs(); ii++) {
885 for (Int_t ib = 0; ib < cfg.GetGlobalInputLength(); ib++) {
887 if (cfg.GetAlgoNoisyInput())
888 cfg.AddAccGlobalInputN(ii,ib,((globalInput[ii] >> ib) & 0x1));
889 if (cfg.GetAlgoDeadcInput())
890 cfg.AddAccGlobalInputD(ii,ib,((globalInput[ii] >> ib) & 0x1));
896 //______________________________________________________________
897 void UpdateGlobalMasks(AliDAConfig& cfg)
899 /// update the global masks
902 gSystem->Setenv("DAQDALIB_PATH", "$DATE_SITE/db");
905 Float_t rateN = 0.0, rateD = 0.0;
906 UInt_t gmask[4], omask;
907 Bool_t noise, deadc, withEvN, withEvD, updated = kFALSE;
909 for (Int_t ii = 0; ii < cfg.GetGlobalInputs(); ii++) {
912 for (Int_t ib = 0; ib < cfg.GetGlobalInputLength(); ib++) {
918 if (cfg.GetEventsN() > cfg.GetMinEvents()) {
919 rateN = (Float_t)cfg.GetAccGlobalInputN(ii,ib)/(Float_t)cfg.GetEventsN();
920 noise = (rateN > cfg.GetThrN());
923 if (cfg.GetEventsD() > cfg.GetMinEvents()) {
924 rateD = (Float_t)cfg.GetAccGlobalInputD(ii,ib)/(Float_t)cfg.GetEventsD();
925 deadc = (rateD < cfg.GetThrD());
928 if (!withEvN && !withEvD) {
929 // - copy the bit from the old mask
930 gmask[ii] |= ((cfg.GetGlobalMasks()->GetGlobalMask(ii) >> ib) & 0x1) << ib;
931 if (cfg.GetPrintLevel())
932 printf("Mask not changed (just copy the old values)\n");
934 if (!withEvN && withEvD) {
936 // - create a new mask, set the bit to 1
938 //gmask[ii] |= 0x1 << ib;
939 // - copy the bit from the old mask
940 gmask[ii] |= ((cfg.GetGlobalMasks()->GetGlobalMask(ii) >> ib) & 0x1) << ib;
942 // - create a new mask, set the bit to 0
943 gmask[ii] |= 0x0 << ib;
944 if (cfg.GetPrintLevel())
945 printf("Found dead channel %1d:%02d (%4.2f) \n",ii,ib,rateD);
948 if (withEvN && !withEvD) {
950 // - create a new mask, set the bit to 1
952 //gmask[ii] |= 0x1 << ib;
953 // - copy the bit from the old mask
954 gmask[ii] |= ((cfg.GetGlobalMasks()->GetGlobalMask(ii) >> ib) & 0x1) << ib;
956 // - create a new mask, set the bit to 0
957 gmask[ii] |= 0x0 << ib;
958 if (cfg.GetPrintLevel())
959 printf("Found noisy channel %1d:%02d (%4.2f) \n",ii,ib,rateN);
962 if (withEvN && withEvD) {
963 if (!noise && !deadc) {
964 // - create a new mask, set the bit to 1
966 //gmask[ii] |= 0x1 << ib;
967 // - copy the bit from the old mask
968 gmask[ii] |= ((cfg.GetGlobalMasks()->GetGlobalMask(ii) >> ib) & 0x1) << ib;
970 // - create a new mask, set the bit to 0
971 gmask[ii] |= 0x0 << ib;
972 if (cfg.GetPrintLevel()) {
974 printf("Found noisy channel %1d:%02d (%4.2f) \n",ii,ib,rateN);
976 printf("Found dead channel %1d:%02d (%4.2f) \n",ii,ib,rateD);
983 // check if at least one mask value has been changed from previous version
984 for (Int_t ii = 0; ii < cfg.GetGlobalInputs(); ii++) {
985 printf("Global mask [%1d] %08x \n",ii,gmask[ii]);
986 omask = cfg.GetGlobalMasks()->GetGlobalMask(ii);
987 if (gmask[ii] != omask) {
989 cfg.GetGlobalMasks()->SetGlobalMask(ii,gmask[ii]);
997 cfg.IncGlobalFileVersion();
999 // don't change the file version ("-x.dat")
1001 cfg.GetTriggerIO()->WriteGlobalConfig(cfg.GetGlobalFileName(),cfg.GetGlobalMasks());
1003 // write last current file
1004 WriteLastCurrentFile(cfg,cfg.GetCurrentFileName());
1006 status = daqDA_DB_storeFile(cfg.GetGlobalFileName(), cfg.GetGlobalFileName());
1008 printf("Failed to export file to DB: %s\n",cfg.GetGlobalFileName());
1012 status = daqDA_DB_storeFile(cfg.GetCurrentFileName(), cfg.GetCurrentFileName());
1014 printf("Failed to export file to DB: %s\n",cfg.GetCurrentFileName());
1022 //______________________________________________________________
1023 void UpdateLocalMask(AliDAConfig& cfg, Int_t localBoardId, Int_t connector, Int_t strip)
1026 /// update local strip mask
1028 AliMUONVCalibParam* localMask =
1029 static_cast<AliMUONVCalibParam*>(cfg.GetLocalMasksDA()->FindObject(localBoardId));
1031 UShort_t mask = static_cast<UShort_t>(localMask->ValueAsInt(connector,0));
1033 mask &= ~(0x1 << strip); // set strip mask to zero
1035 localMask->SetValueAsInt(connector, 0, mask);
1039 //______________________________________________________________
1040 void MakePattern(AliDAConfig& cfg, Int_t localBoardId, const TArrayS& xPattern, const TArrayS& yPattern)
1042 /// calculate the hit map for each strip in x and y direction
1044 AliMUONVCalibParam* pat = 0x0;
1046 if (cfg.GetAlgoNoisyInput())
1047 pat = static_cast<AliMUONVCalibParam*>(cfg.GetPatternStoreN()->FindObject(localBoardId));
1048 if (cfg.GetAlgoDeadcInput())
1049 pat = static_cast<AliMUONVCalibParam*>(cfg.GetPatternStoreD()->FindObject(localBoardId));
1052 pat = new AliMUONCalibParamND(2, 64, localBoardId, 0, 0.);
1053 if (cfg.GetAlgoNoisyInput())
1054 cfg.GetPatternStoreN()->Add(pat);
1055 if (cfg.GetAlgoDeadcInput())
1056 cfg.GetPatternStoreD()->Add(pat);
1059 for (Int_t i = 0; i < 4; ++i) {
1060 for (Int_t j = 0; j < 16; ++j) {
1062 Int_t xMask = xPattern[i];
1063 Int_t yMask = yPattern[i];
1065 Int_t index = 16*i + j;
1066 Double_t patOcc = 0.;
1068 if ( (xMask >> j ) & 0x1 ) {
1069 patOcc = pat->ValueAsDouble(index, 0) + 1.;
1070 pat->SetValueAsDouble(index, 0, patOcc);
1072 if ( (yMask >> j ) & 0x1 ) {
1073 patOcc = pat->ValueAsDouble(index, 1) + 1.;
1074 pat->SetValueAsDouble(index, 1, patOcc);
1081 //______________________________________________________________
1082 void MakePatternStore(AliDAConfig& cfg)
1084 /// analyse patterns for local strips (calculate occupancy)
1087 gSystem->Setenv("DAQDALIB_PATH", "$DATE_SITE/db");
1090 AliMUONVCalibParam* pat;
1091 Int_t localBoardId = 0;
1092 Int_t nEventsN = 0, nEventsD = 0;
1094 Int_t connector = 0;
1095 Bool_t updated = kFALSE;
1097 if (cfg.GetEventsN() > cfg.GetMinEvents()) {
1098 nEventsN = cfg.GetEventsN();
1100 if (cfg.GetEventsD() > cfg.GetMinEvents()) {
1101 nEventsD = cfg.GetEventsD();
1107 TIter next(cfg.GetPatternStoreN()->CreateIterator());
1109 while ( ( pat = dynamic_cast<AliMUONVCalibParam*>(next() ) ) ) {
1111 localBoardId = pat->ID0();
1113 for (Int_t index = 0; index < pat->Size(); index++) {
1115 Double_t patXOcc = pat->ValueAsDouble(index, 0)/(Double_t)nEventsN;
1116 Double_t patYOcc = pat->ValueAsDouble(index, 1)/(Double_t)nEventsN;
1118 pat->SetValueAsDouble(index, 0, patXOcc);
1119 pat->SetValueAsDouble(index, 1, patYOcc);
1121 // check for x strip
1122 if (patXOcc > cfg.GetThrLocN()) {
1124 connector = index/16;
1125 UpdateLocalMask(cfg, localBoardId, connector, strip);
1127 // check for y strip
1128 if (patYOcc > cfg.GetThrLocN()) {
1130 connector = index/16 + 4;
1131 UpdateLocalMask(cfg, localBoardId, connector, strip);
1142 TIter next(cfg.GetPatternStoreD()->CreateIterator());
1144 while ( ( pat = dynamic_cast<AliMUONVCalibParam*>(next() ) ) ) {
1146 localBoardId = pat->ID0();
1148 for (Int_t index = 0; index < pat->Size(); index++) {
1150 Double_t patXOcc = pat->ValueAsDouble(index, 0)/(Double_t)nEventsD;
1151 Double_t patYOcc = pat->ValueAsDouble(index, 1)/(Double_t)nEventsD;
1153 pat->SetValueAsDouble(index, 0, patXOcc);
1154 pat->SetValueAsDouble(index, 1, patYOcc);
1156 // check for x strip
1157 if (patXOcc < cfg.GetThrLocD()) {
1159 connector = index/16;
1160 UpdateLocalMask(cfg, localBoardId, connector, strip);
1162 // check for y strip
1163 if (patYOcc < cfg.GetThrLocD()) {
1165 connector = index/16 + 4;
1166 UpdateLocalMask(cfg, localBoardId, connector, strip);
1174 // make and AND with the previous version of the mask and
1175 // check if the mask has changed
1176 UShort_t maskDA, mask;
1177 Int_t nMaskBits = AliMpConstants::TotalNofLocalBoards()*8*16;
1178 Int_t nMaskBitsChanged = 0;
1179 for (localBoardId = 1; localBoardId <= AliMpConstants::TotalNofLocalBoards(); localBoardId++) {
1180 AliMUONVCalibParam* localMaskDA = static_cast<AliMUONVCalibParam*>(cfg.GetLocalMasksDA()->FindObject(localBoardId));
1181 AliMUONVCalibParam* localMask = static_cast<AliMUONVCalibParam*>(cfg.GetLocalMasks()->FindObject(localBoardId));
1182 for (connector = 0; connector < 8; connector++) {
1183 maskDA = static_cast<UShort_t>(localMaskDA->ValueAsInt(connector,0));
1184 mask = static_cast<UShort_t>(localMask->ValueAsInt(connector,0));
1186 localMaskDA->SetValueAsInt(connector, 0, maskDA);
1187 if (maskDA != mask) {
1189 // calculated percentage of mask bits changed
1190 for (Int_t iBit = 0; iBit < 16; iBit++) {
1191 if (((maskDA >> iBit) & 0x1) != ((mask >> iBit) &0x1)) {
1199 printf("LOCAL mask bits changed = %5d (%7.3f %%) \n",nMaskBitsChanged,100*(Float_t)nMaskBitsChanged/(Float_t)nMaskBits);
1205 cfg.IncLocalMaskFileVersion();
1207 // don't change the file version ("-x.dat")
1209 cfg.GetTriggerIO()->WriteLocalMasks(cfg.GetLocalMaskFileName(),*cfg.GetLocalMasksDA(),cfg.GetRegionalMasks());
1211 // write last current file
1212 WriteLastCurrentFile(cfg,cfg.GetCurrentFileName());
1214 status = daqDA_DB_storeFile(cfg.GetLocalMaskFileName(), cfg.GetLocalMaskFileName());
1216 printf("Failed to export file to DB: %s\n",cfg.GetLocalMaskFileName());
1220 status = daqDA_DB_storeFile(cfg.GetCurrentFileName(), cfg.GetCurrentFileName());
1222 printf("Failed to export file to DB: %s\n",cfg.GetCurrentFileName());
1230 //*************************************************************//
1231 int main(Int_t argc, Char_t **argv)
1235 // needed for streamer application
1236 gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo", "*", "TStreamerInfo", "RIO", "TStreamerInfo()");
1238 /* check that we got some arguments = list of files */
1240 printf("Wrong number of arguments\n");
1246 Char_t inputFile[256] = "";
1249 if (argv[1] != NULL)
1250 strncpy(inputFile, argv[1], 256);
1252 printf("MUONTRGda : No input File !\n");
1256 // decoding the events
1259 Int_t nDateEvents = 0;
1265 AliMUONDDLTrigger* ddlTrigger = 0x0;
1266 AliMUONDarcHeader* darcHeader = 0x0;
1267 AliMUONRegHeader* regHeader = 0x0;
1268 AliMUONLocalStruct* localStruct = 0x0;
1269 // new (fast) decoder
1270 const AliMUONRawStreamTriggerHP::AliHeader* darcHeaderHP = 0x0;
1271 const AliMUONRawStreamTriggerHP::AliLocalStruct* localStructHP = 0x0;
1273 TArrayS xPattern(4);
1274 TArrayS yPattern(4);
1275 Int_t localBoardId = 0;
1279 timers.Start(kTRUE);
1281 // comment out, since we do not retrieve files from database
1282 if (!ImportFiles(cfg)) {
1283 printf("Import from DB failed\n");
1284 printf("For local test set DAQDA_TEST_DIR to the local directory where the Mtg files are located \n");
1291 // the run number extracted from the file name
1292 TString tmp(inputFile);
1293 Int_t pos1 = tmp.First('d');
1294 Int_t pos2 = tmp.Last('.');
1295 Int_t len = pos2 - (pos1+3);
1296 tmp = tmp(pos1+3,len);
1297 gSystem->Setenv("DATE_RUN_NUMBER",tmp.Data());
1298 gSystem->Exec("echo \"DATE_RUN_NUMBER = \" $DATE_RUN_NUMBER");
1301 if(!ExportFiles(cfg)) {
1302 printf("ExportFiles failed\n");
1306 if (!cfg.GetDAFlag()) {
1308 cout << "MUONTRGda: DA enable: " << cfg.GetDAFlag() << endl;
1309 cout << "MUONTRGda: Print level: " << cfg.GetPrintLevel() << endl;
1311 printf("MUONTRGda: Execution time : R:%7.2fs C:%7.2fs\n", timers.RealTime(), timers.CpuTime());
1317 // FET is triggered by CTP
1318 Bool_t modeFET3 = kTRUE;
1319 if (GetFetMode(cfg) != 3) {
1320 printf("FET is not in mode 3. Only PHYSICS events will be analysed (noisy channels)\n");
1324 // All 5 global cards are controlled by the Mts proxy
1325 if (cfg.GetGlobalMasks()->GetGlobalCrateEnable() != 0x1F) {
1326 printf("The MTS proxy does not control all global cards\n");
1330 // The global cards are ON (active on the global inputs)
1331 if (!cfg.GetGlobalMasks()->GetMasksOn()) {
1332 printf("Global masks are not ON\n");
1336 // make sure to catch the "rare" calib events (1 every 50s in physics)
1337 const Char_t* tableSOD[] = {"ALL", "yes", "CAL", "all", NULL, NULL};
1338 monitorDeclareTable(const_cast<char**>(tableSOD));
1340 status = monitorSetDataSource(inputFile);
1342 cerr << "ERROR : monitorSetDataSource status (hex) = " << hex << status
1343 << " " << monitorDecodeError(status) << endl;
1346 status = monitorDeclareMp("MUON Trigger monitoring");
1348 cerr << "ERROR : monitorDeclareMp status (hex) = " << hex << status
1349 << " " << monitorDecodeError(status) << endl;
1353 /* define wait event timeout - 1s max */
1355 monitorSetNoWaitNetworkTimeout(1000);
1357 cout << "MUONTRGda : Reading data from file " << inputFile <<endl;
1359 UInt_t *globalInput = new UInt_t[4];
1360 Bool_t doUpdate = kFALSE;
1361 Int_t runNumber = 0;
1366 if (nEvents >= cfg.GetMaxEvents()) break;
1367 if (cfg.GetPrintLevel()) {
1368 if (nEvents && nEvents % 1000 == 0)
1369 cout<<"Cumulated events " << nEvents << endl;
1371 // check shutdown condition
1372 if (daqDA_checkShutdown())
1375 // Skip Events if needed
1376 while (cfg.GetSkipEvents()) {
1377 status = monitorGetEventDynamic(&event);
1378 cfg.DecSkipEvents();
1382 status = monitorGetEventDynamic(&event);
1384 cout << "MUONTRGda : EOF found" << endl;
1390 // decoding rawdata headers
1391 AliRawReader *rawReader = new AliRawReaderDate(event);
1393 Int_t eventType = rawReader->GetType();
1394 runNumber = rawReader->GetRunNumber();
1397 // CALIBRATION_EVENT
1398 // SYSTEM_SOFTWARE_TRIGGER_EVENT
1399 // DETECTOR_SOFTWARE_TRIGGER_EVENT
1400 cfg.SetAlgoNoisyInput(kFALSE);
1401 cfg.SetAlgoDeadcInput(kFALSE);
1402 if (eventType == PHYSICS_EVENT) {
1403 cfg.SetAlgoNoisyInput(kTRUE);
1405 cfg.IncNoiseEvent();
1406 } else if (modeFET3 && eventType == CALIBRATION_EVENT) {
1407 cfg.SetAlgoDeadcInput(kTRUE);
1409 cfg.IncDeadcEvent();
1415 if (cfg.GetPrintLevel() == 2) printf("\nEvent # %d\n",nEvents);
1417 // decoding MUON payload
1418 AliMUONVRawStreamTrigger *rawStream = 0x0;
1419 if (cfg.UseFastDecoder()) {
1420 rawStream = new AliMUONRawStreamTriggerHP(rawReader);
1422 rawStream = new AliMUONRawStreamTrigger(rawReader);
1425 // ... without warnings from the decoder !!!
1426 if (!cfg.WithWarnings())
1427 rawStream->DisableWarnings();
1430 while((status = rawStream->NextDDL())) {
1432 if (cfg.GetPrintLevel() == 2) printf("iDDL %d\n", rawStream->GetDDL());
1434 if (cfg.UseFastDecoder()) {
1435 darcHeaderHP = static_cast<AliMUONRawStreamTriggerHP*>(rawStream)->GetHeaders();
1436 if (cfg.GetPrintLevel() == 2) printf("Global output (fast decoder) %x\n", (Int_t)darcHeaderHP->GetGlobalOutput());
1437 for (Int_t ig = 0; ig < cfg.GetGlobalInputs(); ig++) {
1438 globalInput[ig] = darcHeaderHP->GetGlobalInput(ig);
1440 // loop over regional structure
1441 Int_t nReg = (Int_t)static_cast<AliMUONRawStreamTriggerHP*>(rawStream)->GetRegionalHeaderCount();
1442 for(Int_t iReg = 0; iReg < nReg; iReg++) {
1443 // loop over local structures
1444 Int_t nLoc = (Int_t)static_cast<AliMUONRawStreamTriggerHP*>(rawStream)->GetLocalStructCount(iReg);
1445 for(Int_t iLoc = 0; iLoc < nLoc; iLoc++) {
1446 localStructHP = static_cast<AliMUONRawStreamTriggerHP*>(rawStream)->GetLocalStruct(iReg, iLoc);
1447 localBoardId = cfg.GetTriggerIO()->LocalBoardId(rawStream->GetDDL(),iReg,localStructHP->GetId());
1448 if (localBoardId > 0) {
1449 localStructHP->GetXPattern(xPattern);
1450 localStructHP->GetYPattern(yPattern);
1451 MakePattern(cfg,localBoardId,xPattern,yPattern);
1456 ddlTrigger = rawStream->GetDDLTrigger();
1457 darcHeader = ddlTrigger->GetDarcHeader();
1458 if (cfg.GetPrintLevel() == 2) printf("Global output %x\n", (Int_t)darcHeader->GetGlobalOutput());
1459 globalInput = darcHeader->GetGlobalInput();
1460 // loop over regional structure
1461 Int_t nReg = darcHeader->GetRegHeaderEntries();
1462 for(Int_t iReg = 0; iReg < nReg; iReg++) {
1463 regHeader = darcHeader->GetRegHeaderEntry(iReg);
1464 // loop over local structures
1465 Int_t nLoc = regHeader->GetLocalEntries();
1466 for(Int_t iLoc = 0; iLoc < nLoc; iLoc++) {
1467 localStruct = regHeader->GetLocalEntry(iLoc);
1468 localBoardId = cfg.GetTriggerIO()->LocalBoardId(rawStream->GetDDL(),iReg,localStruct->GetId());
1469 if (localBoardId > 0) {
1470 localStruct->GetXPattern(xPattern);
1471 localStruct->GetYPattern(yPattern);
1472 MakePattern(cfg,localBoardId,xPattern,yPattern);
1477 if (rawStream->GetDDL() == 0) {
1478 StoreGlobalInput(cfg,globalInput);
1488 // update configuration files ifrequested event types were found
1490 if (cfg.GetDAMode() > 0) UpdateGlobalMasks(cfg);
1491 if (cfg.GetDAMode() > 1) MakePatternStore(cfg);
1496 cout << "MUONTRGda: DA enable: " << cfg.GetDAFlag() << endl;
1497 cout << "MUONTRGda: Run number: " << runNumber << endl;
1498 cout << "MUONTRGda: Nb of DATE events: " << nDateEvents << endl;
1499 cout << "MUONTRGda: Nb of events used: " << nEvents << endl;
1500 cout << "MUONTRGda: Nb of events used (noise): " << cfg.GetEventsN() << endl;
1501 cout << "MUONTRGda: Nb of events used (deadc): " << cfg.GetEventsD() << endl;
1502 cout << "MUONTRGda: Minumum nr of events for rate calculation: " << cfg.GetMinEvents() << endl;
1503 cout << "MUONTRGda: Maximum nr of analyzed events: " << cfg.GetMaxEvents() << endl;
1504 cout << "MUONTRGda: Skip events from start: " << cfg.GetSkipEvents() << endl;
1505 cout << "MUONTRGda: Threshold for global noisy inputs: " << 100*cfg.GetThrN() << "%" << endl;
1506 cout << "MUONTRGda: Threshold for global dead inputs: " << 100*cfg.GetThrD() << "%" << endl;
1507 cout << "MUONTRGda: Threshold for local noisy inputs: " << 100*cfg.GetThrLocN() << "%" << endl;
1508 cout << "MUONTRGda: Threshold for local dead inputs: " << 100*cfg.GetThrLocD() << "%" << endl;
1509 cout << "MUONTRGda: Print level: " << cfg.GetPrintLevel() << endl;
1510 cout << "MUONTRGda: Show decoder warnings: " << cfg.WithWarnings() << endl;
1511 cout << "MUONTRGda: Use the fast decoder: " << cfg.UseFastDecoder() << endl;
1512 cout << "MUONTRGda: DA mode (1=GLOBAL, 2=GLOBAL+LOCAL): " << cfg.GetDAMode() << endl;
1514 printf("MUONTRGda: Execution time : R:%7.2fs C:%7.2fs\n", timers.RealTime(), timers.CpuTime());