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);
145 // Create a default pattern store
146 for (Int_t i = 1; i <= AliMpConstants::TotalNofLocalBoards(); i++) {
147 AliMUONVCalibParam *patN = new AliMUONCalibParamND(2, 64, i, 0, 0.);
148 AliMUONVCalibParam *patD = new AliMUONCalibParamND(2, 64, i, 0, 0.);
149 fPatternStoreN->Add(patN);
150 fPatternStoreD->Add(patD);
155 virtual ~AliDAConfig()
159 delete fLocalMasksDA;
160 delete fRegionalMasks;
162 delete fPatternStoreN;
163 delete fPatternStoreD;
168 /// print DA parameters
169 printf("DA config file name: %s \n",GetDAConfigFileName());
170 printf("Current file name: %s \n",GetCurrentFileName());
171 printf("Last current file name: %s \n",GetLastCurrentFileName());
172 printf("Global file name: %s (%d %d)\n",GetGlobalFileName(),GetGlobalFileVersion(),GetGlobalFileLastVersion());
173 printf("Regional file name: %s (%d %d)\n",GetRegionalFileName(),GetRegionalFileVersion(),GetRegionalFileLastVersion());
174 printf("Local mask file name: %s (%d %d)\n",GetLocalMaskFileName(),GetLocalMaskFileVersion(),GetLocalMaskFileLastVersion());
175 printf("Local LUT file name: %s (%d %d)\n",GetLocalLutFileName(),GetLocalLutFileVersion(),GetLocalLutFileLastVersion());
176 printf("Signature file name: %s (%d)\n",GetSignatureFileName(),GetSignatureFileVersion());
179 /// name of the DA configuration file from detector DB
180 const Char_t* GetDAConfigFileName() { return fDAConfigFileName.Data(); }
181 /// file with current versions of the configuration files, usually MtgCurrent.dat
182 const Char_t* GetCurrentFileName() { return fCurrentFileName.Data(); }
183 /// last known versions of the configuration files, usually MtgLastCurrent.dat
184 const Char_t* GetLastCurrentFileName() { return fLastCurrentFileName.Data(); }
186 /// name of the Start-of-data field in MtgCurrent.dat
187 const Char_t* GetSodName() { return fSodName.Data(); }
188 /// flag value of the Start-of-data field in MtgCurrent.dat
189 Int_t GetSodFlag() const { return fSodFlag; }
191 /// name of the Detector Algorithm field in MtgCurrent.dat
192 const Char_t* GetDAName() { return fDAName.Data(); }
193 /// flag value of the Detector Algorithm field in MtgCurrent.dat
194 Int_t GetDAFlag() const { return fDAFlag; }
195 /// DA active mode (GLOBAL or GLOBAL+LOCAL)
196 Int_t GetDAMode() const { return fDAMode; }
198 /// global crate configuration file name
199 const Char_t* GetGlobalFileName() { return fGlobalFileName.Data(); }
200 /// regional crate configuration file name
201 const Char_t* GetRegionalFileName() { return fRegionalFileName.Data(); }
202 /// masks for the local cards, file name
203 const Char_t* GetLocalMaskFileName() { return fLocalMaskFileName.Data(); }
204 /// transverse momentum Look-Up-Table, file name
205 const Char_t* GetLocalLutFileName() { return fLocalLutFileName.Data(); }
206 /// signature file name
207 const Char_t* GetSignatureFileName() { return fSignatureFileName.Data(); }
209 /// version of the global crate configuration in the detector DB
210 Int_t GetGlobalFileVersion() const { return fGlobalFileVersion; }
211 /// version of the regional crate configuration in the detector DB
212 Int_t GetRegionalFileVersion() const { return fRegionalFileVersion; }
213 /// version of the masks for the local cards in the detector DB
214 Int_t GetLocalMaskFileVersion() const { return fLocalMaskFileVersion; }
215 /// version of the transverse momentum Look-Up-Table in the detector DB
216 Int_t GetLocalLutFileVersion() const { return fLocalLutFileVersion; }
217 /// version of the signature file in the detector DB
218 Int_t GetSignatureFileVersion() const { return fSignatureFileVersion; }
220 /// last known version of the global crate configuration
221 Int_t GetGlobalFileLastVersion() const { return fGlobalFileLastVersion; }
222 /// last known version of the regional crate configuration
223 Int_t GetRegionalFileLastVersion() const { return fRegionalFileLastVersion; }
224 /// last known version of the masks for the local cards
225 Int_t GetLocalMaskFileLastVersion() const { return fLocalMaskFileLastVersion; }
226 /// last known version of the transverse momentum Look-Up-Table
227 Int_t GetLocalLutFileLastVersion() const { return fLocalLutFileLastVersion; }
229 /// store for the masks for the local cards (own)
230 AliMUONVStore* GetLocalMasks() const { return fLocalMasks; }
231 /// store for the DA-calculated masks for the local cards (own)
232 AliMUONVStore* GetLocalMasksDA() const { return fLocalMasksDA; }
233 /// configuration object for the regional crate (own)
234 AliMUONRegionalTriggerConfig* GetRegionalMasks() const { return fRegionalMasks; }
235 /// configuration object for the global crate (own)
236 AliMUONGlobalCrateConfig* GetGlobalMasks() const { return fGlobalMasks; }
238 /// read/write configurations, masks and LUT to/from online files (own)
239 AliMUONTriggerIO* GetTriggerIO() const { return fTriggerIO; }
241 /// store for local strips patterns (noisy strips)
242 AliMUONVStore* GetPatternStoreN() const { return fPatternStoreN; }
243 /// store for local strips patterns (dead strips)
244 AliMUONVStore* GetPatternStoreD() const { return fPatternStoreD; }
246 /// number of accumulated PHYSICS events for noisy channels analysis
247 Int_t GetEventsN() const { return fEventsN; }
248 /// number of accumulated CALIBRATION events for dead channels analysis
249 Int_t GetEventsD() const { return fEventsD; }
251 /// print verbosity of the DA
252 Int_t GetPrintLevel() const { return fPrintLevel; }
254 /// select PHYSICS events for noisy channels analysis
255 Bool_t GetAlgoNoisyInput() const { return fAlgoNoisyInput; }
256 /// select CALIBRATION events for dead channels analysis
257 Bool_t GetAlgoDeadcInput() const { return fAlgoDeadcInput; }
259 /// threshold for noisy global inputs (fraction of events)
260 Float_t GetThrN() const { return fThrN; }
261 /// threshold for dead global inputs (fraction of events)
262 Float_t GetThrD() const { return fThrD; }
263 /// threshold for noisy local strips (fraction of events)
264 Float_t GetThrLocN() const { return fThrLocN; }
265 /// threshold for dead local strips (fraction of events)
266 Float_t GetThrLocD() const { return fThrLocD; }
268 /// minumum nr of events for rate calculation
269 Int_t GetMinEvents() const { return fMinEvents; }
270 /// maximum number of events to analyze
271 Int_t GetMaxEvents() const { return fMaxEvents; }
272 /// number of events to skip from start
273 Int_t GetSkipEvents() const { return fSkipEvents; }
275 /// show warnings from the raw data decoder
276 Bool_t WithWarnings() const { return fWithWarnings; }
277 /// use the high-performance (HP) decoder
278 Bool_t UseFastDecoder() const { return fUseFastDecoder; }
280 /// number of global input words
281 Int_t GetGlobalInputs() const { return kGlobalInputs; }
282 /// length in bits of a global input word
283 Int_t GetGlobalInputLength() const { return kGlobalInputLength; }
285 /// get accumulated values for bit "ib" from global input word "ii", PHYSICS events
286 Int_t GetAccGlobalInputN(Int_t ii, Int_t ib) const { return fAccGlobalInputN[ii][ib]; }
287 /// get accumulated values for bit "ib" from global input word "ii", CALIBRATION events
288 Int_t GetAccGlobalInputD(Int_t ii, Int_t ib) const { return fAccGlobalInputD[ii][ib]; }
290 /// set the name of the Start-of-data field in MtgCurrent.dat
291 void SetSodName(Char_t *name) { fSodName = TString(name); }
292 /// set the flag value of the Start-of-data field in MtgCurrent.dat
293 void SetSodFlag(Int_t flag) { fSodFlag = flag; }
295 /// set the name of the Detector Algorithm field in MtgCurrent.dat
296 void SetDAName(Char_t *name) { fDAName = TString(name); }
297 /// set the flag value of the Detector Algorithm field in MtgCurrent.dat
298 void SetDAFlag(Int_t flag) { fDAFlag = flag; }
299 /// set DA active mode, 1 = GLOBAL (default), 2 = GLOBAL and LOCAL
300 void SetDAMode(Int_t mode) { fDAMode = mode; }
302 /// set the global crate configuration file name
303 void SetGlobalFileName(const Char_t *name) { fGlobalFileName = TString(name); }
304 /// set the regional crate configuration file name
305 void SetRegionalFileName(const Char_t *name) { fRegionalFileName = TString(name); }
306 /// set the masks for the local cards, file name
307 void SetLocalMaskFileName(const Char_t *name) { fLocalMaskFileName = TString(name); }
308 /// set the transverse momentum Look-Up-Table, file name
309 void SetLocalLutFileName(const Char_t *name) { fLocalLutFileName = TString(name); }
310 /// set the signature file name
311 void SetSignatureFileName(const Char_t *name) { fSignatureFileName = TString(name); }
313 /// set the version of the global crate configuration in the detector DB
314 void SetGlobalFileVersion(Int_t ver) { fGlobalFileVersion = ver; }
315 /// set the version of the regional crate configuration in the detector DB
316 void SetRegionalFileVersion(Int_t ver) { fRegionalFileVersion = ver; }
317 /// set the version of the masks for the local cards in the detector DB
318 void SetLocalMaskFileVersion(Int_t ver) { fLocalMaskFileVersion = ver; }
319 /// set the version of the transverse momentum Look-Up-Table in the detector DB
320 void SetLocalLutFileVersion(Int_t ver) { fLocalLutFileVersion = ver; }
321 /// set the version of the signature file in the detector DB
322 void SetSignatureFileVersion(Int_t ver) { fSignatureFileVersion = ver; }
324 /// set the last known version of the global crate configuration
325 void SetGlobalFileLastVersion(Int_t ver) { fGlobalFileLastVersion = ver; }
326 /// set the last known version of the regional crate configuration
327 void SetRegionalFileLastVersion(Int_t ver) { fRegionalFileLastVersion = ver; }
328 /// set the last known version of the masks for the local cards
329 void SetLocalMaskFileLastVersion(Int_t ver) { fLocalMaskFileLastVersion = ver; }
330 /// set the last known version of the transverse momentum Look-Up-Table
331 void SetLocalLutFileLastVersion(Int_t ver) { fLocalLutFileLastVersion = ver; }
333 /// increment the number of selected PHYSICS events
334 void IncNoiseEvent() { fEventsN++; }
335 /// increment the number of selected CALIBRATION events
336 void IncDeadcEvent() { fEventsD++; }
338 /// count the value of the bit "ib" of global input word "ii" (PHYSICS events)
339 void AddAccGlobalInputN(Int_t ii, Int_t ib, Int_t val) { fAccGlobalInputN[ii][ib] += val; }
340 /// count the value of the bit "ib" of global input word "ii" (CALIBRATION events)
341 void AddAccGlobalInputD(Int_t ii, Int_t ib, Int_t val) { fAccGlobalInputD[ii][ib] += val; }
343 /// set the print verbosity level of the DA
344 void SetPrintLevel(Int_t level) { fPrintLevel = level; }
346 /// select PHYSICS events for noisy channels analysis
347 void SetAlgoNoisyInput(Bool_t val) { fAlgoNoisyInput = val; }
348 /// select CALIBRATION events for dead channels analysis
349 void SetAlgoDeadcInput(Bool_t val) { fAlgoDeadcInput = val; }
351 /// set the threshold for noisy global inputs (fraction of events)
352 void SetThrN(Float_t val) { fThrN = val; }
353 /// set the threshold for dead global inputs (fraction of events)
354 void SetThrD(Float_t val) { fThrD = val; }
355 /// set the threshold for noisy local strips (fraction of events)
356 void SetThrLocN(Float_t val) { fThrLocN = val; }
357 /// set the threshold for dead local strips (fraction of events)
358 void SetThrLocD(Float_t val) { fThrLocD = val; }
360 /// set the minumum nr of events for rate calculation
361 void SetMinEvents(Int_t val) { fMinEvents = val; }
362 /// set the maximum number of events to analyze
363 void SetMaxEvents(Int_t val) { fMaxEvents = val; }
364 /// set the number of events to skip from start
365 void SetSkipEvents(Int_t val) { fSkipEvents = val; }
367 /// set/unset to show warnings from the raw data decoder
368 void SetWithWarnings() { fWithWarnings = kTRUE; }
369 /// set/unset the use of the high-performance (HP) decoder
370 void SetUseFastDecoder() { fUseFastDecoder = kTRUE; }
372 /// increment version of the global crate configuration file
373 void IncGlobalFileVersion() { fGlobalFileVersion++; }
374 /// increment version of the local mask configuration file
375 void IncLocalMaskFileVersion() { fLocalMaskFileVersion++; }
376 /// count skipped events
377 void DecSkipEvents() { fSkipEvents--; }
381 /// copy constructor, not implemented
382 AliDAConfig (const AliDAConfig& cfg);
383 /// assignment operator, not implemented
384 AliDAConfig& operator=(const AliDAConfig& cfg);
386 const TString fDAConfigFileName; //!< name of the DA configuration file from detector DB
387 const TString fCurrentFileName; //!< usually MtgCurrent.dat
388 const TString fLastCurrentFileName; //!< usually MtgLastCurrent.dat
390 TString fSodName; //!< name of the Start-of-data field in MtgCurrent.dat
391 Int_t fSodFlag; //!< flag value of the Start-of-data field in MtgCurrent.dat
393 TString fDAName; //!< name of the Detector Algorithm field in MtgCurrent.dat
394 Int_t fDAFlag; //!< flag value of the Detector Algorithm field in MtgCurrent.dat (enabled/disabled)
395 Int_t fDAMode; //!< DA active mode, GLOBAL or GLOBAL+LOCAL
397 TString fGlobalFileName; //!< global crate configuration, file name
398 TString fRegionalFileName; //!< regional crate configuration, file name
399 TString fLocalMaskFileName; //!< masks for the local cards, file name
400 TString fLocalLutFileName; //!< transverse momentum Look-Up-Table, file name
401 TString fSignatureFileName; //!< signature file name
403 Int_t fGlobalFileVersion; //!< version of the global crate configuration in the detector DB
404 Int_t fRegionalFileVersion; //!< version of the regional crate configuration in the detector DB
405 Int_t fLocalMaskFileVersion; //!< version of the masks for the local cards in the detector DB
406 Int_t fLocalLutFileVersion; //!< version of the transverse momentum Look-Up-Table in the detector DB
407 Int_t fSignatureFileVersion; //!< version of the signature file in the detector DB
409 Int_t fGlobalFileLastVersion; //!< last known version of the global crate configuration
410 Int_t fRegionalFileLastVersion; //!< last known version of the regional crate configuration
411 Int_t fLocalMaskFileLastVersion; //!< last known version of the masks for the local cards
412 Int_t fLocalLutFileLastVersion; //!< last known version of the transverse momentum Look-Up-Table
414 Int_t fEventsN; //!< number of accumulated PHYSICS events
415 Int_t fEventsD; //!< number of accumulated CALIBRATION events
417 Int_t fPrintLevel; //!< print verbosity of the DA
419 AliMUONVStore* fLocalMasks; //!< store for the masks for the local cards
420 AliMUONVStore* fLocalMasksDA; //!< store for the DA-calculated masks for the local cards
421 AliMUONRegionalTriggerConfig* fRegionalMasks; //!< configuration object for the regional crate
422 AliMUONGlobalCrateConfig* fGlobalMasks; //!< configuration object for the global crate
424 AliMUONTriggerIO *fTriggerIO; //!< read/write masks and LUT to/from online files
426 Bool_t fAlgoNoisyInput; //!< select PHYSICS events for noisy channels analysis
427 Bool_t fAlgoDeadcInput; //!< select CALIBRATION events for dead channels analysis
429 Float_t fThrN; //!< threshold for noisy global inputs (fraction of events)
430 Float_t fThrD; //!< threshold for dead global inputs (fraction of events)
431 Float_t fThrLocN; //!< threshold for noisy local strips (fraction of events)
432 Float_t fThrLocD; //!< threshold for dead local strips (fraction of events)
433 Int_t fMinEvents; //!< minumum nr of events for rate calculation
434 Int_t fSkipEvents; //!< number of events to skip from start
435 Int_t fMaxEvents; //!< maximum number of events to analyze
436 Bool_t fWithWarnings; //!< show warnings from the raw data decoder
437 Bool_t fUseFastDecoder; //!< use the high-performance (HP) decoder
439 const Int_t fNLocalBoard; //!< number of local boards
441 enum { kGlobalInputs = 4, //!< number of global input words
442 kGlobalInputLength = 32 //!< length in bits of a global input word
445 AliMUONVStore *fPatternStoreN; //! store for local strips patterns
446 AliMUONVStore *fPatternStoreD; //! store for local strips patterns
448 Int_t fAccGlobalInputN[kGlobalInputs][kGlobalInputLength]; //!< storage for global input (PHYSICS events)
449 Int_t fAccGlobalInputD[kGlobalInputs][kGlobalInputLength]; //!< storage for global input (CALIBRATION events)
453 //__________________________________________________________________
454 Bool_t ReadDAConfig(AliDAConfig& cfg)
456 /// read run parameters for the DA
461 file = cfg.GetDAConfigFileName();
462 std::ifstream in(gSystem->ExpandPathName(file.Data()));
464 printf("Cannot open DA configuration file %s ; use default values.\n",file.Data());
473 pos = tmp.First(" ");
475 cfg.SetPrintLevel(tmp.Atoi());
479 pos = tmp.First(" ");
481 cfg.SetThrN(tmp.Atof());
485 pos = tmp.First(" ");
487 cfg.SetThrD(tmp.Atof());
491 pos = tmp.First(" ");
493 cfg.SetMinEvents(tmp.Atoi());
497 pos = tmp.First(" ");
499 cfg.SetSkipEvents(tmp.Atoi());
503 pos = tmp.First(" ");
505 cfg.SetMaxEvents(tmp.Atoi());
509 pos = tmp.First(" ");
511 if (tmp.Atoi() != 0) cfg.SetWithWarnings();
515 pos = tmp.First(" ");
517 if (tmp.Atoi() != 0) cfg.SetUseFastDecoder();
521 pos = tmp.First(" ");
523 cfg.SetThrLocN(tmp.Atof());
527 pos = tmp.First(" ");
529 cfg.SetThrLocD(tmp.Atof());
533 pos = tmp.First(" ");
535 cfg.SetDAMode(tmp.Atoi());
541 //__________________________________________________________________
542 void WriteLastCurrentFile(AliDAConfig& cfg, TString currentFile)
544 /// write last current file
549 out.open(file.Data());
550 out << cfg.GetSodName() << " " << cfg.GetSodFlag() << endl;
551 out << cfg.GetDAName() << " " << cfg.GetDAFlag() << endl;
553 out << cfg.GetGlobalFileName() << " " << cfg.GetGlobalFileVersion() << endl;
554 out << cfg.GetRegionalFileName() << " " << cfg.GetRegionalFileVersion() << endl;
555 out << cfg.GetLocalMaskFileName() << " " << cfg.GetLocalMaskFileVersion() << endl;
556 out << cfg.GetLocalLutFileName() << " " << cfg.GetLocalLutFileVersion() << endl;
557 out << cfg.GetSignatureFileName() << " " << cfg.GetSignatureFileVersion() << endl;
562 //___________________________________________________________________________________________
563 Bool_t ReadCurrentFile(AliDAConfig& cfg, TString currentFile, Bool_t lastCurrentFlag = kFALSE)
565 /// read last current file name and version
573 std::ifstream in(gSystem->ExpandPathName(file.Data()));
575 printf("Cannot open last current file %s\n",currentFile.Data());
581 sscanf(line, "%s %d", name, &flag);
582 cfg.SetSodName(name);
583 cfg.SetSodFlag(flag);
584 if (cfg.GetPrintLevel()) printf("Sod Flag %d\n", cfg.GetSodFlag());
588 sscanf(line, "%s %d", name, &flag);
591 if (cfg.GetPrintLevel()) printf("DA Flag: %d\n", cfg.GetDAFlag());
596 Int_t pos = tmp.First(" ");
597 TString tmp1 = tmp(0, pos);
598 cfg.SetGlobalFileName(tmp1.Data());
600 if (!lastCurrentFlag) {
601 cfg.SetGlobalFileVersion(atoi(tmp(pos+1, tmp.Length()-pos).Data()));
602 if (cfg.GetPrintLevel()) printf("Global File Name: %s version: %d\n",
603 cfg.GetGlobalFileName(), cfg.GetGlobalFileVersion());
605 cfg.SetGlobalFileLastVersion(atoi(tmp(pos+1, tmp.Length()-pos).Data()));
606 if (cfg.GetPrintLevel()) printf("Global File Name: %s last version: %d\n",
607 cfg.GetGlobalFileName(), cfg.GetGlobalFileLastVersion());
613 pos = tmp.First(" ");
615 cfg.SetRegionalFileName(tmp1.Data());
617 if (!lastCurrentFlag) {
618 cfg.SetRegionalFileVersion(atoi(tmp(pos+1, tmp.Length()-pos).Data()));
619 if (cfg.GetPrintLevel()) printf("Regional File Name: %s version: %d\n",
620 cfg.GetRegionalFileName(), cfg.GetRegionalFileVersion());
623 cfg.SetRegionalFileLastVersion(atoi(tmp(pos+1, tmp.Length()-pos).Data()));
624 if (cfg.GetPrintLevel()) printf("Regional File Name: %s last version: %d\n",
625 cfg.GetRegionalFileName(), cfg.GetRegionalFileLastVersion());
631 pos = tmp.First(" ");
633 cfg.SetLocalMaskFileName(tmp1.Data());
635 if (!lastCurrentFlag) {
636 cfg.SetLocalMaskFileVersion(atoi(tmp(pos+1, tmp.Length()-pos).Data()));
637 if (cfg.GetPrintLevel()) printf("Mask File Name: %s version: %d\n",
638 cfg.GetLocalMaskFileName(), cfg.GetLocalMaskFileVersion());
640 cfg.SetLocalMaskFileLastVersion(atoi(tmp(pos+1, tmp.Length()-pos).Data()));
641 if (cfg.GetPrintLevel()) printf("Mask File Name: %s last version: %d\n",
642 cfg.GetLocalMaskFileName(), cfg.GetLocalMaskFileLastVersion());
647 pos = tmp.First(" ");
649 cfg.SetLocalLutFileName(tmp1.Data());
651 if (!lastCurrentFlag) {
652 cfg.SetLocalLutFileVersion(atoi(tmp(pos+1, tmp.Length()-pos).Data()));
653 if (cfg.GetPrintLevel()) printf("Lut File Name: %s version: %d\n",
654 cfg.GetLocalLutFileName(), cfg.GetLocalLutFileVersion());
656 cfg.SetLocalLutFileLastVersion(atoi(tmp(pos+1, tmp.Length()-pos).Data()));
657 if (cfg.GetPrintLevel()) printf("Lut File Name: %s last version: %d\n",
658 cfg.GetLocalLutFileName(), cfg.GetLocalLutFileLastVersion());
663 pos = tmp.First(" ");
665 cfg.SetSignatureFileName(tmp1.Data());
666 cfg.SetSignatureFileVersion(atoi(tmp(pos+1, tmp.Length()-pos).Data()));
667 if (cfg.GetPrintLevel()) printf("Lut File Name: %s version: %d\n",
668 cfg.GetSignatureFileName(), cfg.GetSignatureFileVersion());
674 void ReadFileNames(AliDAConfig& cfg)
676 /// if last current file does not exist than read current file
678 if (!ReadCurrentFile(cfg,cfg.GetLastCurrentFileName(), kTRUE))
680 ReadCurrentFile(cfg,cfg.GetCurrentFileName(), kTRUE);
683 // any case read current file
684 ReadCurrentFile(cfg,cfg.GetCurrentFileName());
689 Bool_t ExportFiles(AliDAConfig& cfg)
691 /// Export files to FES
693 // env variables have to be set (suppose by ECS ?)
694 // setenv DATE_FES_PATH
695 // setenv DATE_RUN_NUMBER
696 // setenv DATE_ROLE_NAME
697 // setenv DATE_DETECTOR_CODE
700 gSystem->Setenv("DAQDALIB_PATH", "$DATE_SITE/infoLogger");
701 gSystem->Setenv("DAQDA_TEST_DIR", "/alisoft/FES");
707 Bool_t modified = kFALSE;
708 Bool_t globalExported = kFALSE;
711 TString fileExp("ExportedFiles.dat");
714 out.open(fileExp.Data());
716 printf("Failed to create file: %s\n",file.Data());
720 // check if MtgLastCurrent.dat exists
721 // if not, do initial export of all files
722 Bool_t initFES = kFALSE;
723 if (gSystem->AccessPathName("MtgLastCurrent.dat"))
725 if (initFES) printf("Copy all configuration files to the FES.\n");
727 file = cfg.GetLocalMaskFileName();
728 if ((cfg.GetLocalMaskFileLastVersion() != cfg.GetLocalMaskFileVersion()) || initFES) {
730 status = daqDA_FES_storeFile(file.Data(), "LOCAL");
732 printf("Failed to export file: %s\n",cfg.GetLocalMaskFileName());
735 if(cfg.GetPrintLevel()) printf("Export file: %s\n",cfg.GetLocalMaskFileName());
736 out << cfg.GetLocalMaskFileName() << endl;
739 file = cfg.GetLocalLutFileName();
740 if ((cfg.GetLocalLutFileLastVersion() != cfg.GetLocalLutFileVersion()) || initFES) {
742 status = daqDA_FES_storeFile(file.Data(), "LUT");
744 printf("Failed to export file: %s\n",cfg.GetLocalLutFileName());
747 if(cfg.GetPrintLevel()) printf("Export file: %s\n",cfg.GetLocalLutFileName());
748 out << cfg.GetLocalLutFileName() << endl;
752 file = cfg.GetGlobalFileName();
753 if ((cfg.GetGlobalFileLastVersion() != cfg.GetGlobalFileVersion()) || modified || initFES) {
755 globalExported = kTRUE;
756 status = daqDA_FES_storeFile(file.Data(), "GLOBAL");
758 printf("Failed to export file: %s\n",cfg.GetGlobalFileName());
761 if(cfg.GetPrintLevel()) printf("Export file: %s\n",cfg.GetGlobalFileName());
762 out << cfg.GetGlobalFileName() << endl;
765 file = cfg.GetRegionalFileName();
766 if ( (cfg.GetRegionalFileLastVersion() != cfg.GetRegionalFileVersion()) || modified || initFES) {
767 status = daqDA_FES_storeFile(file.Data(), "REGIONAL");
769 printf("Failed to export file: %s\n",cfg.GetRegionalFileName());
772 if(cfg.GetPrintLevel()) printf("Export file: %s\n",cfg.GetRegionalFileName());
773 out << cfg.GetRegionalFileName() << endl;
775 // needed for the initialisation of the mapping
776 if (!globalExported) {
777 file = cfg.GetGlobalFileName();
778 status = daqDA_FES_storeFile(file.Data(), "GLOBAL");
780 printf("Failed to export file: %s\n",cfg.GetGlobalFileName());
783 if(cfg.GetPrintLevel()) printf("Export file: %s\n",cfg.GetGlobalFileName());
784 out << cfg.GetGlobalFileName() << endl;
791 // export Exported file to FES anyway
792 status = daqDA_FES_storeFile(fileExp.Data(), "EXPORTED");
794 printf("Failed to export file: %s\n", fileExp.Data());
797 if(cfg.GetPrintLevel()) printf("Export file: %s\n",fileExp.Data());
799 // write last current file
800 WriteLastCurrentFile(cfg,cfg.GetLastCurrentFileName());
806 Bool_t ImportFiles(AliDAConfig& cfg)
808 /// copy locally a file from daq detector config db
809 /// The current detector is identified by detector code in variable
810 /// DATE_DETECTOR_CODE. It must be defined.
811 /// If environment variable DAQDA_TEST_DIR is defined, files are copied from
812 /// DAQDA_TEST_DIR instead of the database.
813 /// The usual environment variables are not needed.
818 gSystem->Setenv("DAQDALIB_PATH", "$DATE_SITE/db");
821 status = daqDA_DB_getFile(cfg.GetDAConfigFileName(), cfg.GetDAConfigFileName());
823 printf("Failed to get DA config file from DB: %s\n",cfg.GetDAConfigFileName());
829 status = daqDA_DB_getFile(cfg.GetCurrentFileName(), cfg.GetCurrentFileName());
831 printf("Failed to get current config file from DB: %s\n",cfg.GetCurrentFileName());
837 status = daqDA_DB_getFile(cfg.GetGlobalFileName(), cfg.GetGlobalFileName());
839 printf("Failed to get current config file from DB: %s\n", cfg.GetGlobalFileName());
843 status = daqDA_DB_getFile(cfg.GetRegionalFileName(), cfg.GetRegionalFileName());
845 printf("Failed to get current config file from DB: %s\n",cfg.GetRegionalFileName());
849 status = daqDA_DB_getFile(cfg.GetLocalMaskFileName(), cfg.GetLocalMaskFileName());
851 printf("Failed to get current config file from DB: %s\n",cfg.GetLocalMaskFileName());
855 status = daqDA_DB_getFile(cfg.GetLocalLutFileName(), cfg.GetLocalLutFileName());
857 printf("Failed to get current config file from DB: %s\n",cfg.GetLocalLutFileName());
865 void ReadMaskFiles(AliDAConfig& cfg)
869 const Char_t* localFile = cfg.GetLocalMaskFileName();
870 const Char_t* regionalFile = cfg.GetRegionalFileName();
871 const Char_t* globalFile = cfg.GetGlobalFileName();
873 cfg.GetTriggerIO()->ReadConfig(localFile, regionalFile, globalFile, cfg.GetLocalMasks(), cfg.GetRegionalMasks(), cfg.GetGlobalMasks());
876 //______________________________________________________________
877 UInt_t GetFetMode(const AliDAConfig & cfg)
879 /// FET mode = 3 to run algorithm for dead global inputs
883 return cfg.GetGlobalMasks()->GetFetRegister(3);
887 //______________________________________________________________
888 void StoreGlobalInput(AliDAConfig& cfg, const UInt_t * const globalInput)
890 /// accumulate and build statistics of global input values
892 for (Int_t ii = 0; ii < cfg.GetGlobalInputs(); ii++) {
893 for (Int_t ib = 0; ib < cfg.GetGlobalInputLength(); ib++) {
895 if (cfg.GetAlgoNoisyInput())
896 cfg.AddAccGlobalInputN(ii,ib,((globalInput[ii] >> ib) & 0x1));
897 if (cfg.GetAlgoDeadcInput())
898 cfg.AddAccGlobalInputD(ii,ib,((globalInput[ii] >> ib) & 0x1));
904 //______________________________________________________________
905 void UpdateGlobalMasks(AliDAConfig& cfg)
907 /// update the global masks
910 gSystem->Setenv("DAQDALIB_PATH", "$DATE_SITE/db");
913 Float_t rateN = 0.0, rateD = 0.0;
914 UInt_t gmask[4], omask;
915 Bool_t noise, deadc, withEvN, withEvD, updated = kFALSE;
917 for (Int_t ii = 0; ii < cfg.GetGlobalInputs(); ii++) {
920 for (Int_t ib = 0; ib < cfg.GetGlobalInputLength(); ib++) {
926 if (cfg.GetEventsN() > cfg.GetMinEvents()) {
927 rateN = (Float_t)cfg.GetAccGlobalInputN(ii,ib)/(Float_t)cfg.GetEventsN();
928 noise = (rateN > cfg.GetThrN());
931 if (cfg.GetEventsD() > cfg.GetMinEvents()) {
932 rateD = (Float_t)cfg.GetAccGlobalInputD(ii,ib)/(Float_t)cfg.GetEventsD();
933 deadc = (rateD < cfg.GetThrD());
936 if (!withEvN && !withEvD) {
937 // - copy the bit from the old mask
938 gmask[ii] |= ((cfg.GetGlobalMasks()->GetGlobalMask(ii) >> ib) & 0x1) << ib;
939 if (cfg.GetPrintLevel())
940 printf("Mask not changed (just copy the old values)\n");
942 if (!withEvN && withEvD) {
944 // - create a new mask, set the bit to 1
946 //gmask[ii] |= 0x1 << ib;
947 // - copy the bit from the old mask
948 gmask[ii] |= ((cfg.GetGlobalMasks()->GetGlobalMask(ii) >> ib) & 0x1) << ib;
950 // - create a new mask, set the bit to 0
951 gmask[ii] |= 0x0 << ib;
952 if (cfg.GetPrintLevel())
953 printf("Found dead channel %1d:%02d (%4.2f) \n",ii,ib,rateD);
956 if (withEvN && !withEvD) {
958 // - create a new mask, set the bit to 1
960 //gmask[ii] |= 0x1 << ib;
961 // - copy the bit from the old mask
962 gmask[ii] |= ((cfg.GetGlobalMasks()->GetGlobalMask(ii) >> ib) & 0x1) << ib;
964 // - create a new mask, set the bit to 0
965 gmask[ii] |= 0x0 << ib;
966 if (cfg.GetPrintLevel())
967 printf("Found noisy channel %1d:%02d (%4.2f) \n",ii,ib,rateN);
970 if (withEvN && withEvD) {
971 if (!noise && !deadc) {
972 // - create a new mask, set the bit to 1
974 //gmask[ii] |= 0x1 << ib;
975 // - copy the bit from the old mask
976 gmask[ii] |= ((cfg.GetGlobalMasks()->GetGlobalMask(ii) >> ib) & 0x1) << ib;
978 // - create a new mask, set the bit to 0
979 gmask[ii] |= 0x0 << ib;
980 if (cfg.GetPrintLevel()) {
982 printf("Found noisy channel %1d:%02d (%4.2f) \n",ii,ib,rateN);
984 printf("Found dead channel %1d:%02d (%4.2f) \n",ii,ib,rateD);
991 // check if at least one mask value has been changed from previous version
992 for (Int_t ii = 0; ii < cfg.GetGlobalInputs(); ii++) {
993 printf("Global mask [%1d] %08x \n",ii,gmask[ii]);
994 omask = cfg.GetGlobalMasks()->GetGlobalMask(ii);
995 if (gmask[ii] != omask) {
997 cfg.GetGlobalMasks()->SetGlobalMask(ii,gmask[ii]);
1005 cfg.IncGlobalFileVersion();
1007 // don't change the file version ("-x.dat")
1009 cfg.GetTriggerIO()->WriteGlobalConfig(cfg.GetGlobalFileName(),cfg.GetGlobalMasks());
1011 // write last current file
1012 WriteLastCurrentFile(cfg,cfg.GetCurrentFileName());
1014 status = daqDA_DB_storeFile(cfg.GetGlobalFileName(), cfg.GetGlobalFileName());
1016 printf("Failed to export file to DB: %s\n",cfg.GetGlobalFileName());
1020 status = daqDA_DB_storeFile(cfg.GetCurrentFileName(), cfg.GetCurrentFileName());
1022 printf("Failed to export file to DB: %s\n",cfg.GetCurrentFileName());
1030 //______________________________________________________________
1031 void UpdateLocalMask(AliDAConfig& cfg, Int_t localBoardId, Int_t connector, Int_t strip)
1034 /// update local strip mask
1036 AliMUONVCalibParam* localMask =
1037 static_cast<AliMUONVCalibParam*>(cfg.GetLocalMasksDA()->FindObject(localBoardId));
1039 UShort_t mask = static_cast<UShort_t>(localMask->ValueAsInt(connector,0));
1041 mask &= ~(0x1 << strip); // set strip mask to zero
1043 localMask->SetValueAsInt(connector, 0, mask);
1047 //______________________________________________________________
1048 void MakePattern(AliDAConfig& cfg, Int_t localBoardId, const TArrayS& xPattern, const TArrayS& yPattern)
1050 /// calculate the hit map for each strip in x and y direction
1052 AliMUONVCalibParam* pat = 0x0;
1054 if (cfg.GetAlgoNoisyInput())
1055 pat = static_cast<AliMUONVCalibParam*>(cfg.GetPatternStoreN()->FindObject(localBoardId));
1056 if (cfg.GetAlgoDeadcInput())
1057 pat = static_cast<AliMUONVCalibParam*>(cfg.GetPatternStoreD()->FindObject(localBoardId));
1060 pat = new AliMUONCalibParamND(2, 64, localBoardId, 0, 0.);
1061 if (cfg.GetAlgoNoisyInput())
1062 cfg.GetPatternStoreN()->Add(pat);
1063 if (cfg.GetAlgoDeadcInput())
1064 cfg.GetPatternStoreD()->Add(pat);
1067 for (Int_t i = 0; i < 4; ++i) {
1068 for (Int_t j = 0; j < 16; ++j) {
1070 Int_t xMask = xPattern[i];
1071 Int_t yMask = yPattern[i];
1073 Int_t index = 16*i + j;
1074 Double_t patOcc = 0.;
1076 if ( (xMask >> j ) & 0x1 ) {
1077 patOcc = pat->ValueAsDouble(index, 0) + 1.;
1078 pat->SetValueAsDouble(index, 0, patOcc);
1080 if ( (yMask >> j ) & 0x1 ) {
1081 patOcc = pat->ValueAsDouble(index, 1) + 1.;
1082 pat->SetValueAsDouble(index, 1, patOcc);
1089 //______________________________________________________________
1090 void MakePatternStore(AliDAConfig& cfg)
1092 /// analyse patterns for local strips (calculate occupancy)
1095 gSystem->Setenv("DAQDALIB_PATH", "$DATE_SITE/db");
1098 AliMUONVCalibParam* pat;
1099 Int_t localBoardId = 0;
1100 Int_t nEventsN = 0, nEventsD = 0;
1102 Int_t connector = 0;
1103 Bool_t updated = kFALSE;
1105 if (cfg.GetEventsN() > cfg.GetMinEvents()) {
1106 nEventsN = cfg.GetEventsN();
1108 if (cfg.GetEventsD() > cfg.GetMinEvents()) {
1109 nEventsD = cfg.GetEventsD();
1115 TIter next(cfg.GetPatternStoreN()->CreateIterator());
1117 while ( ( pat = dynamic_cast<AliMUONVCalibParam*>(next() ) ) ) {
1119 localBoardId = pat->ID0();
1121 for (Int_t index = 0; index < pat->Size(); index++) {
1123 Double_t patXOcc = pat->ValueAsDouble(index, 0)/(Double_t)nEventsN;
1124 Double_t patYOcc = pat->ValueAsDouble(index, 1)/(Double_t)nEventsN;
1126 pat->SetValueAsDouble(index, 0, patXOcc);
1127 pat->SetValueAsDouble(index, 1, patYOcc);
1129 // check for x strip
1130 if (patXOcc > cfg.GetThrLocN()) {
1132 connector = index/16;
1133 UpdateLocalMask(cfg, localBoardId, connector, strip);
1135 // check for y strip
1136 if (patYOcc > cfg.GetThrLocN()) {
1138 connector = index/16 + 4;
1139 UpdateLocalMask(cfg, localBoardId, connector, strip);
1150 TIter next(cfg.GetPatternStoreD()->CreateIterator());
1152 while ( ( pat = dynamic_cast<AliMUONVCalibParam*>(next() ) ) ) {
1154 localBoardId = pat->ID0();
1156 for (Int_t index = 0; index < pat->Size(); index++) {
1158 Double_t patXOcc = pat->ValueAsDouble(index, 0)/(Double_t)nEventsD;
1159 Double_t patYOcc = pat->ValueAsDouble(index, 1)/(Double_t)nEventsD;
1161 pat->SetValueAsDouble(index, 0, patXOcc);
1162 pat->SetValueAsDouble(index, 1, patYOcc);
1164 // check for x strip
1165 if (patXOcc < cfg.GetThrLocD()) {
1167 connector = index/16;
1168 UpdateLocalMask(cfg, localBoardId, connector, strip);
1170 // check for y strip
1171 if (patYOcc < cfg.GetThrLocD()) {
1173 connector = index/16 + 4;
1174 UpdateLocalMask(cfg, localBoardId, connector, strip);
1182 // make and AND with the previous version of the mask and
1183 // check if the mask has changed
1184 UShort_t maskDA, mask;
1185 Int_t nMaskBits = AliMpConstants::TotalNofLocalBoards()*8*16;
1186 Int_t nMaskBitsChanged = 0;
1187 for (localBoardId = 1; localBoardId <= AliMpConstants::TotalNofLocalBoards(); localBoardId++) {
1188 AliMUONVCalibParam* localMaskDA = static_cast<AliMUONVCalibParam*>(cfg.GetLocalMasksDA()->FindObject(localBoardId));
1189 AliMUONVCalibParam* localMask = static_cast<AliMUONVCalibParam*>(cfg.GetLocalMasks()->FindObject(localBoardId));
1190 for (connector = 0; connector < 8; connector++) {
1191 maskDA = static_cast<UShort_t>(localMaskDA->ValueAsInt(connector,0));
1192 mask = static_cast<UShort_t>(localMask->ValueAsInt(connector,0));
1194 localMaskDA->SetValueAsInt(connector, 0, maskDA);
1195 if (maskDA != mask) {
1197 // calculated percentage of mask bits changed
1198 for (Int_t iBit = 0; iBit < 16; iBit++) {
1199 if (((maskDA >> iBit) & 0x1) != ((mask >> iBit) &0x1)) {
1207 printf("LOCAL mask bits changed = %5d (%7.3f %%) \n",nMaskBitsChanged,100*(Float_t)nMaskBitsChanged/(Float_t)nMaskBits);
1213 cfg.IncLocalMaskFileVersion();
1215 // don't change the file version ("-x.dat")
1217 cfg.GetTriggerIO()->WriteLocalMasks(cfg.GetLocalMaskFileName(),*cfg.GetLocalMasksDA());
1219 // write last current file
1220 WriteLastCurrentFile(cfg,cfg.GetCurrentFileName());
1222 status = daqDA_DB_storeFile(cfg.GetLocalMaskFileName(), cfg.GetLocalMaskFileName());
1224 printf("Failed to export file to DB: %s\n",cfg.GetLocalMaskFileName());
1228 status = daqDA_DB_storeFile(cfg.GetCurrentFileName(), cfg.GetCurrentFileName());
1230 printf("Failed to export file to DB: %s\n",cfg.GetCurrentFileName());
1238 //*************************************************************//
1239 int main(Int_t argc, Char_t **argv)
1243 // needed for streamer application
1244 gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo", "*", "TStreamerInfo", "RIO", "TStreamerInfo()");
1246 /* check that we got some arguments = list of files */
1248 printf("Wrong number of arguments\n");
1254 Char_t inputFile[256] = "";
1257 if (argv[1] != NULL)
1258 strncpy(inputFile, argv[1], 256);
1260 printf("MUONTRGda : No input File !\n");
1264 // decoding the events
1267 Int_t nDateEvents = 0;
1273 AliMUONDDLTrigger* ddlTrigger = 0x0;
1274 AliMUONDarcHeader* darcHeader = 0x0;
1275 AliMUONRegHeader* regHeader = 0x0;
1276 AliMUONLocalStruct* localStruct = 0x0;
1277 // new (fast) decoder
1278 const AliMUONRawStreamTriggerHP::AliHeader* darcHeaderHP = 0x0;
1279 const AliMUONRawStreamTriggerHP::AliLocalStruct* localStructHP = 0x0;
1281 TArrayS xPattern(4);
1282 TArrayS yPattern(4);
1283 Int_t localBoardId = 0;
1287 timers.Start(kTRUE);
1289 // comment out, since we do not retrieve files from database
1290 if (!ImportFiles(cfg)) {
1291 printf("Import from DB failed\n");
1292 printf("For local test set DAQDA_TEST_DIR to the local directory where the Mtg files are located \n");
1299 // the run number extracted from the file name
1300 TString tmp(inputFile);
1301 Int_t pos1 = tmp.First('d');
1302 Int_t pos2 = tmp.Last('.');
1303 Int_t len = pos2 - (pos1+3);
1304 tmp = tmp(pos1+3,len);
1305 gSystem->Setenv("DATE_RUN_NUMBER",tmp.Data());
1306 gSystem->Exec("echo \"DATE_RUN_NUMBER = \" $DATE_RUN_NUMBER");
1309 if(!ExportFiles(cfg)) {
1310 printf("ExportFiles failed\n");
1314 if (!cfg.GetDAFlag()) {
1316 cout << "MUONTRGda: DA enable: " << cfg.GetDAFlag() << endl;
1317 cout << "MUONTRGda: Print level: " << cfg.GetPrintLevel() << endl;
1319 printf("MUONTRGda: Execution time : R:%7.2fs C:%7.2fs\n", timers.RealTime(), timers.CpuTime());
1325 // FET is triggered by CTP
1326 Bool_t modeFET3 = kTRUE;
1327 if (GetFetMode(cfg) != 3) {
1328 printf("FET is not in mode 3. Only PHYSICS events will be analysed (noisy channels)\n");
1332 // All 5 global cards are controlled by the Mts proxy
1333 if (cfg.GetGlobalMasks()->GetGlobalCrateEnable() != 0x1F) {
1334 printf("The MTS proxy does not control all global cards\n");
1338 // The global cards are ON (active on the global inputs)
1339 if (!cfg.GetGlobalMasks()->GetMasksOn()) {
1340 printf("Global masks are not ON\n");
1344 // make sure to catch the "rare" calib events (1 every 50s in physics)
1345 const Char_t* tableSOD[] = {"ALL", "yes", "CAL", "all", NULL, NULL};
1346 monitorDeclareTable(const_cast<char**>(tableSOD));
1348 status = monitorSetDataSource(inputFile);
1350 cerr << "ERROR : monitorSetDataSource status (hex) = " << hex << status
1351 << " " << monitorDecodeError(status) << endl;
1354 status = monitorDeclareMp("MUON Trigger monitoring");
1356 cerr << "ERROR : monitorDeclareMp status (hex) = " << hex << status
1357 << " " << monitorDecodeError(status) << endl;
1361 /* define wait event timeout - 1s max */
1363 monitorSetNoWaitNetworkTimeout(1000);
1365 cout << "MUONTRGda : Reading data from file " << inputFile <<endl;
1367 UInt_t *globalInput = new UInt_t[4];
1368 Bool_t doUpdate = kFALSE;
1369 Int_t runNumber = 0;
1374 if (nEvents >= cfg.GetMaxEvents()) break;
1375 if (cfg.GetPrintLevel()) {
1376 if (nEvents && nEvents % 1000 == 0)
1377 cout<<"Cumulated events " << nEvents << endl;
1379 // check shutdown condition
1380 if (daqDA_checkShutdown())
1383 // Skip Events if needed
1384 while (cfg.GetSkipEvents()) {
1385 status = monitorGetEventDynamic(&event);
1386 cfg.DecSkipEvents();
1390 status = monitorGetEventDynamic(&event);
1392 cout << "MUONTRGda : EOF found" << endl;
1398 // decoding rawdata headers
1399 AliRawReader *rawReader = new AliRawReaderDate(event);
1401 Int_t eventType = rawReader->GetType();
1402 runNumber = rawReader->GetRunNumber();
1405 // CALIBRATION_EVENT
1406 // SYSTEM_SOFTWARE_TRIGGER_EVENT
1407 // DETECTOR_SOFTWARE_TRIGGER_EVENT
1408 cfg.SetAlgoNoisyInput(kFALSE);
1409 cfg.SetAlgoDeadcInput(kFALSE);
1410 if (eventType == PHYSICS_EVENT) {
1411 cfg.SetAlgoNoisyInput(kTRUE);
1413 cfg.IncNoiseEvent();
1414 } else if (modeFET3 && eventType == CALIBRATION_EVENT) {
1415 cfg.SetAlgoDeadcInput(kTRUE);
1417 cfg.IncDeadcEvent();
1423 if (cfg.GetPrintLevel() == 2) printf("\nEvent # %d\n",nEvents);
1425 // decoding MUON payload
1426 AliMUONVRawStreamTrigger *rawStream = 0x0;
1427 if (cfg.UseFastDecoder()) {
1428 rawStream = new AliMUONRawStreamTriggerHP(rawReader);
1430 rawStream = new AliMUONRawStreamTrigger(rawReader);
1433 // ... without warnings from the decoder !!!
1434 if (!cfg.WithWarnings())
1435 rawStream->DisableWarnings();
1438 while((status = rawStream->NextDDL())) {
1440 if (cfg.GetPrintLevel() == 2) printf("iDDL %d\n", rawStream->GetDDL());
1442 if (cfg.UseFastDecoder()) {
1443 darcHeaderHP = static_cast<AliMUONRawStreamTriggerHP*>(rawStream)->GetHeaders();
1444 if (cfg.GetPrintLevel() == 2) printf("Global output (fast decoder) %x\n", (Int_t)darcHeaderHP->GetGlobalOutput());
1445 for (Int_t ig = 0; ig < cfg.GetGlobalInputs(); ig++) {
1446 globalInput[ig] = darcHeaderHP->GetGlobalInput(ig);
1448 // loop over regional structure
1449 Int_t nReg = (Int_t)static_cast<AliMUONRawStreamTriggerHP*>(rawStream)->GetRegionalHeaderCount();
1450 for(Int_t iReg = 0; iReg < nReg; iReg++) {
1451 // loop over local structures
1452 Int_t nLoc = (Int_t)static_cast<AliMUONRawStreamTriggerHP*>(rawStream)->GetLocalStructCount(iReg);
1453 for(Int_t iLoc = 0; iLoc < nLoc; iLoc++) {
1454 localStructHP = static_cast<AliMUONRawStreamTriggerHP*>(rawStream)->GetLocalStruct(iReg, iLoc);
1455 localBoardId = cfg.GetTriggerIO()->LocalBoardId(rawStream->GetDDL(),iReg,localStructHP->GetId());
1456 if (localBoardId > 0) {
1457 localStructHP->GetXPattern(xPattern);
1458 localStructHP->GetYPattern(yPattern);
1459 MakePattern(cfg,localBoardId,xPattern,yPattern);
1464 ddlTrigger = rawStream->GetDDLTrigger();
1465 darcHeader = ddlTrigger->GetDarcHeader();
1466 if (cfg.GetPrintLevel() == 2) printf("Global output %x\n", (Int_t)darcHeader->GetGlobalOutput());
1467 globalInput = darcHeader->GetGlobalInput();
1468 // loop over regional structure
1469 Int_t nReg = darcHeader->GetRegHeaderEntries();
1470 for(Int_t iReg = 0; iReg < nReg; iReg++) {
1471 regHeader = darcHeader->GetRegHeaderEntry(iReg);
1472 // loop over local structures
1473 Int_t nLoc = regHeader->GetLocalEntries();
1474 for(Int_t iLoc = 0; iLoc < nLoc; iLoc++) {
1475 localStruct = regHeader->GetLocalEntry(iLoc);
1476 localBoardId = cfg.GetTriggerIO()->LocalBoardId(rawStream->GetDDL(),iReg,localStruct->GetId());
1477 if (localBoardId > 0) {
1478 localStruct->GetXPattern(xPattern);
1479 localStruct->GetYPattern(yPattern);
1480 MakePattern(cfg,localBoardId,xPattern,yPattern);
1485 if (rawStream->GetDDL() == 0) {
1486 StoreGlobalInput(cfg,globalInput);
1496 // update configuration files ifrequested event types were found
1498 if (cfg.GetDAMode() > 0) UpdateGlobalMasks(cfg);
1499 if (cfg.GetDAMode() > 1) MakePatternStore(cfg);
1504 cout << "MUONTRGda: DA enable: " << cfg.GetDAFlag() << endl;
1505 cout << "MUONTRGda: Run number: " << runNumber << endl;
1506 cout << "MUONTRGda: Nb of DATE events: " << nDateEvents << endl;
1507 cout << "MUONTRGda: Nb of events used: " << nEvents << endl;
1508 cout << "MUONTRGda: Nb of events used (noise): " << cfg.GetEventsN() << endl;
1509 cout << "MUONTRGda: Nb of events used (deadc): " << cfg.GetEventsD() << endl;
1510 cout << "MUONTRGda: Minumum nr of events for rate calculation: " << cfg.GetMinEvents() << endl;
1511 cout << "MUONTRGda: Maximum nr of analyzed events: " << cfg.GetMaxEvents() << endl;
1512 cout << "MUONTRGda: Skip events from start: " << cfg.GetSkipEvents() << endl;
1513 cout << "MUONTRGda: Threshold for global noisy inputs: " << 100*cfg.GetThrN() << "%" << endl;
1514 cout << "MUONTRGda: Threshold for global dead inputs: " << 100*cfg.GetThrD() << "%" << endl;
1515 cout << "MUONTRGda: Threshold for local noisy inputs: " << 100*cfg.GetThrLocN() << "%" << endl;
1516 cout << "MUONTRGda: Threshold for local dead inputs: " << 100*cfg.GetThrLocD() << "%" << endl;
1517 cout << "MUONTRGda: Print level: " << cfg.GetPrintLevel() << endl;
1518 cout << "MUONTRGda: Show decoder warnings: " << cfg.WithWarnings() << endl;
1519 cout << "MUONTRGda: Use the fast decoder: " << cfg.UseFastDecoder() << endl;
1520 cout << "MUONTRGda: DA mode (1=GLOBAL, 2=GLOBAL+LOCAL): " << cfg.GetDAMode() << endl;
1522 printf("MUONTRGda: Execution time : R:%7.2fs C:%7.2fs\n", timers.RealTime(), timers.CpuTime());