AliRoot Core  3abf5b4 (3abf5b4)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MTRda.cxx
Go to the documentation of this file.
1 /*
2 MTR DA for online
3 
4 Contact: Franck Manso <manso@clermont.in2p3.fr>
5 Link: http://aliceinfo.cern.ch/static/Offline/dimuon/muon_html/README_mtrda.html
6 Reference run: 61898
7 Run Type: PHYSICS
8 DA Type: MON
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
13 */
14 
16 // Detector Algorithm for the MUON trigger configuration. //
17 // //
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. //
22 // //
23 // Authors: //
24 // Christian Fink (formerly at Subatech, Nantes) //
25 // Franck Manso (LPC Clermont-Ferrand, manso@clermont.in2p3.fr) //
26 // Bogdan Vulpescu (LPC Clermont-Ferrand, vulpescu@clermont.in2p3.fr) //
27 // //
29 
30 //#define OFFLINE
31 
32 extern "C" {
33 #include <daqDA.h>
34 }
35 
36 #include "event.h"
37 #include "monitor.h"
38 
39 #include <Riostream.h>
40 #include <stdio.h>
41 
42 #include "AliRawReaderDate.h"
43 
44 #include "AliMpConstants.h"
47 #include "AliMUONDarcHeader.h"
48 #include "AliMUONRegHeader.h"
49 #include "AliMUONDDLTrigger.h"
50 #include "AliMUONVStore.h"
51 #include "AliMUON1DArray.h"
52 #include "AliMUONTriggerIO.h"
55 #include "AliMUONVCalibParam.h"
56 #include "AliMUONCalibParamND.h"
57 #include "AliMUONCalibParamNI.h"
58 #include "AliMUONLocalStruct.h"
59 
60 #include "TString.h"
61 #include "TSystem.h"
62 #include "TStopwatch.h"
63 #include "TROOT.h"
64 #include "TPluginManager.h"
65 #include "TArrayS.h"
66 
67 static const TString fileExp("ExportedFiles.dat");
68 
70 class AliDAConfig : TObject {
71 
72 public:
73 
75  fDAConfigFileName("DAConfig.dat"),
76  fCurrentFileName("MtgCurrent.dat"),
77  fLastCurrentFileName("MtgLastCurrent.dat"),
78  fSodName(""),
79  fSodFlag(0),
80  fDAName(""),
81  fDAFlag(0),
82  fDAMode(1),
83  fGlobalFileName(""),
88  fTrigScalFileName("MtgTrigScalers.dat"),
98  fEventsN(0),
99  fEventsD(0),
100  fPrintLevel(0),
101  fLocalMasks(0x0),
102  fLocalMasksDA(0x0),
103  fRegionalMasks(0x0),
104  fGlobalMasks(0x0),
106  fAlgoNoisyInput(kFALSE),
107  fAlgoDeadcInput(kFALSE),
108  fThrN(0.1),
109  fThrD(0.9),
110  fThrLocN(0.1),
111  fThrLocD(0.9),
112  fMinEvents(10),
113  fSkipEvents(0),
114  fMaxEvents(65535),
115  fWithWarnings(kFALSE),
116  fUseFastDecoder(kFALSE),
117  fNLocalBoard(AliMpConstants::TotalNofLocalBoards()+1),
118  fPatternStoreN(0x0),
119  fPatternStoreD(0x0),
120  fSaveScalers(kFALSE),
121  fScalerRecTime(600)
122  {
124  for (Int_t ii = 0; ii < kGlobalInputs; ii++) {
125  for (Int_t il = 0; il < kGlobalInputLength; il++) {
126  fAccGlobalInputN[ii][il] = 0;
127  fAccGlobalInputD[ii][il] = 0;
128  }
129  }
136 
137  // Generate local trigger masks store. All masks are set to FFFF
138  for (Int_t i = 1; i <= AliMpConstants::TotalNofLocalBoards(); i++) {
139  AliMUONVCalibParam* localBoard = new AliMUONCalibParamNI(1,8,i,0,0);
140  for (Int_t x = 0; x < 2; x++) {
141  for (Int_t y = 0; y < 4; y++) {
142  Int_t index = x*4+y;
143  localBoard->SetValueAsInt(index,0,0xFFFF);
144  }
145  }
146  fLocalMasksDA->Add(localBoard);
147  }
148 
149  // Create a default pattern store
150  for (Int_t i = 1; i <= AliMpConstants::TotalNofLocalBoards(); i++) {
151  AliMUONVCalibParam *patN = new AliMUONCalibParamND(2, 64, i, 0, 0.);
152  AliMUONVCalibParam *patD = new AliMUONCalibParamND(2, 64, i, 0, 0.);
153  fPatternStoreN->Add(patN);
154  fPatternStoreD->Add(patD);
155  }
156 
157  }
158 
159  virtual ~AliDAConfig()
160  {
162  delete fLocalMasks;
163  delete fLocalMasksDA;
164  delete fRegionalMasks;
165  delete fGlobalMasks;
166  delete fPatternStoreN;
167  delete fPatternStoreD;
168  delete fTriggerIO;
169  }
170  void PrintConfig()
171  {
173  printf("DA config file name: %s \n",GetDAConfigFileName());
174  printf("Current file name: %s \n",GetCurrentFileName());
175  printf("Last current file name: %s \n",GetLastCurrentFileName());
176  printf("Global file name: %s (%d %d)\n",GetGlobalFileName(),GetGlobalFileVersion(),GetGlobalFileLastVersion());
177  printf("Regional file name: %s (%d %d)\n",GetRegionalFileName(),GetRegionalFileVersion(),GetRegionalFileLastVersion());
178  printf("Local mask file name: %s (%d %d)\n",GetLocalMaskFileName(),GetLocalMaskFileVersion(),GetLocalMaskFileLastVersion());
179  printf("Local LUT file name: %s (%d %d)\n",GetLocalLutFileName(),GetLocalLutFileVersion(),GetLocalLutFileLastVersion());
180  printf("Signature file name: %s (%d)\n",GetSignatureFileName(),GetSignatureFileVersion());
181  }
182 
184  const Char_t* GetDAConfigFileName() { return fDAConfigFileName.Data(); }
186  const Char_t* GetCurrentFileName() { return fCurrentFileName.Data(); }
188  const Char_t* GetLastCurrentFileName() { return fLastCurrentFileName.Data(); }
189 
191  const Char_t* GetSodName() { return fSodName.Data(); }
193  Int_t GetSodFlag() const { return fSodFlag; }
194 
196  const Char_t* GetDAName() { return fDAName.Data(); }
198  Int_t GetDAFlag() const { return fDAFlag; }
200  Int_t GetDAMode() const { return fDAMode; }
201 
203  const Char_t* GetGlobalFileName() { return fGlobalFileName.Data(); }
205  const Char_t* GetRegionalFileName() { return fRegionalFileName.Data(); }
207  const Char_t* GetLocalMaskFileName() { return fLocalMaskFileName.Data(); }
209  const Char_t* GetLocalLutFileName() { return fLocalLutFileName.Data(); }
211  const Char_t* GetSignatureFileName() { return fSignatureFileName.Data(); }
213  const Char_t* GetTrigScalFileName() { return fTrigScalFileName.Data(); }
214 
216  Int_t GetGlobalFileVersion() const { return fGlobalFileVersion; }
225 
234 
243 
246 
251 
253  Int_t GetEventsN() const { return fEventsN; }
255  Int_t GetEventsD() const { return fEventsD; }
256 
258  Int_t GetPrintLevel() const { return fPrintLevel; }
259 
261  Bool_t GetAlgoNoisyInput() const { return fAlgoNoisyInput; }
263  Bool_t GetAlgoDeadcInput() const { return fAlgoDeadcInput; }
264 
266  Float_t GetThrN() const { return fThrN; }
268  Float_t GetThrD() const { return fThrD; }
270  Float_t GetThrLocN() const { return fThrLocN; }
272  Float_t GetThrLocD() const { return fThrLocD; }
273 
275  Int_t GetMinEvents() const { return fMinEvents; }
277  Int_t GetMaxEvents() const { return fMaxEvents; }
279  Int_t GetSkipEvents() const { return fSkipEvents; }
280 
282  Bool_t WithWarnings() const { return fWithWarnings; }
284  Bool_t UseFastDecoder() const { return fUseFastDecoder; }
285 
287  Bool_t SaveScalers() const { return fSaveScalers; }
289  UInt_t GetScalerRecTime() const { return fScalerRecTime; }
290 
291 
293  Int_t GetGlobalInputs() const { return kGlobalInputs; }
295  Int_t GetGlobalInputLength() const { return kGlobalInputLength; }
296 
298  Int_t GetAccGlobalInputN(Int_t ii, Int_t ib) const { return fAccGlobalInputN[ii][ib]; }
300  Int_t GetAccGlobalInputD(Int_t ii, Int_t ib) const { return fAccGlobalInputD[ii][ib]; }
301 
303  void SetSodName(Char_t *name) { fSodName = TString(name); }
305  void SetSodFlag(Int_t flag) { fSodFlag = flag; }
306 
308  void SetDAName(Char_t *name) { fDAName = TString(name); }
310  void SetDAFlag(Int_t flag) { fDAFlag = flag; }
312  void SetDAMode(Int_t mode) { fDAMode = mode; }
313 
315  void SetGlobalFileName(const Char_t *name) { fGlobalFileName = TString(name); }
317  void SetRegionalFileName(const Char_t *name) { fRegionalFileName = TString(name); }
319  void SetLocalMaskFileName(const Char_t *name) { fLocalMaskFileName = TString(name); }
321  void SetLocalLutFileName(const Char_t *name) { fLocalLutFileName = TString(name); }
323  void SetSignatureFileName(const Char_t *name) { fSignatureFileName = TString(name); }
325  void SetTrigScalFileName(const Char_t *name) { fTrigScalFileName = TString(name); }
326 
328  void SetGlobalFileVersion(Int_t ver) { fGlobalFileVersion = ver; }
330  void SetRegionalFileVersion(Int_t ver) { fRegionalFileVersion = ver; }
334  void SetLocalLutFileVersion(Int_t ver) { fLocalLutFileVersion = ver; }
337 
346 
348  void IncNoiseEvent() { fEventsN++; }
350  void IncDeadcEvent() { fEventsD++; }
351 
353  void AddAccGlobalInputN(Int_t ii, Int_t ib, Int_t val) { fAccGlobalInputN[ii][ib] += val; }
355  void AddAccGlobalInputD(Int_t ii, Int_t ib, Int_t val) { fAccGlobalInputD[ii][ib] += val; }
356 
358  void SetPrintLevel(Int_t level) { fPrintLevel = level; }
359 
361  void SetAlgoNoisyInput(Bool_t val) { fAlgoNoisyInput = val; }
363  void SetAlgoDeadcInput(Bool_t val) { fAlgoDeadcInput = val; }
364 
366  void SetThrN(Float_t val) { fThrN = val; }
368  void SetThrD(Float_t val) { fThrD = val; }
370  void SetThrLocN(Float_t val) { fThrLocN = val; }
372  void SetThrLocD(Float_t val) { fThrLocD = val; }
373 
375  void SetMinEvents(Int_t val) { fMinEvents = val; }
377  void SetMaxEvents(Int_t val) { fMaxEvents = val; }
379  void SetSkipEvents(Int_t val) { fSkipEvents = val; }
380 
382  void SetWithWarnings() { fWithWarnings = kTRUE; }
384  void SetUseFastDecoder() { fUseFastDecoder = kTRUE; }
386  void SetSaveScalers(Bool_t val) { fSaveScalers = val; }
388  void SetScalerRecTime(Int_t trec) { fScalerRecTime = (UInt_t)trec; }
389 
396 
397 private:
398 
400  AliDAConfig (const AliDAConfig& cfg);
402  AliDAConfig& operator=(const AliDAConfig& cfg);
403 
404  const TString fDAConfigFileName;
405  const TString fCurrentFileName;
406  const TString fLastCurrentFileName;
407 
408  TString fSodName;
409  Int_t fSodFlag;
410 
411  TString fDAName;
412  Int_t fDAFlag;
413  Int_t fDAMode;
414 
415  TString fGlobalFileName;
421 
427 
432 
433  Int_t fEventsN;
434  Int_t fEventsD;
435 
436  Int_t fPrintLevel;
437 
442 
444 
447 
448  Float_t fThrN;
449  Float_t fThrD;
450  Float_t fThrLocN;
451  Float_t fThrLocD;
452  Int_t fMinEvents;
453  Int_t fSkipEvents;
454  Int_t fMaxEvents;
455  Bool_t fWithWarnings;
457 
458  const Int_t fNLocalBoard;
459 
460  enum { kGlobalInputs = 4,
462  };
463 
466 
469 
470  Bool_t fSaveScalers;
472 
473 };
474 
475 //__________________________________________________________________
477 {
479 
480  char line[80];
481 
482  TString file;
483  file = cfg.GetDAConfigFileName();
484  std::ifstream in(gSystem->ExpandPathName(file.Data()));
485  if (!in.good()) {
486  printf("Cannot open DA configuration file %s ; use default values.\n",file.Data());
487  return kTRUE;
488  }
489 
490  TString tmp;
491  Int_t pos;
492 
493  in.getline(line,80);
494  tmp = line;
495  pos = tmp.First(" ");
496  tmp = tmp(0,pos);
497  cfg.SetPrintLevel(tmp.Atoi());
498 
499  in.getline(line,80);
500  tmp = line;
501  pos = tmp.First(" ");
502  tmp = tmp(0,pos);
503  cfg.SetThrN(tmp.Atof());
504 
505  in.getline(line,80);
506  tmp = line;
507  pos = tmp.First(" ");
508  tmp = tmp(0,pos);
509  cfg.SetThrD(tmp.Atof());
510 
511  in.getline(line,80);
512  tmp = line;
513  pos = tmp.First(" ");
514  tmp = tmp(0,pos);
515  cfg.SetMinEvents(tmp.Atoi());
516 
517  in.getline(line,80);
518  tmp = line;
519  pos = tmp.First(" ");
520  tmp = tmp(0,pos);
521  cfg.SetSkipEvents(tmp.Atoi());
522 
523  in.getline(line,80);
524  tmp = line;
525  pos = tmp.First(" ");
526  tmp = tmp(0,pos);
527  cfg.SetMaxEvents(tmp.Atoi());
528 
529  in.getline(line,80);
530  tmp = line;
531  pos = tmp.First(" ");
532  tmp = tmp(0,pos);
533  if (tmp.Atoi() != 0) cfg.SetWithWarnings();
534 
535  in.getline(line,80);
536  tmp = line;
537  pos = tmp.First(" ");
538  tmp = tmp(0,pos);
539  if (tmp.Atoi() != 0) cfg.SetUseFastDecoder();
540 
541  in.getline(line,80);
542  tmp = line;
543  pos = tmp.First(" ");
544  tmp = tmp(0,pos);
545  cfg.SetThrLocN(tmp.Atof());
546 
547  in.getline(line,80);
548  tmp = line;
549  pos = tmp.First(" ");
550  tmp = tmp(0,pos);
551  cfg.SetThrLocD(tmp.Atof());
552 
553  in.getline(line,80);
554  tmp = line;
555  pos = tmp.First(" ");
556  tmp = tmp(0,pos);
557  cfg.SetDAMode(tmp.Atoi());
558 
559  in.getline(line,80);
560  tmp = line;
561  pos = tmp.First(" ");
562  tmp = tmp(0,pos);
563  tmp.Atoi() == 0 ? cfg.SetSaveScalers(kFALSE) : cfg.SetSaveScalers(kTRUE);
564 
565  in.getline(line,80);
566  tmp = line;
567  pos = tmp.First(" ");
568  tmp = tmp(0,pos);
569  cfg.SetScalerRecTime(tmp.Atoi());
570 
571  return kTRUE;
572 
573 }
574 
575 //__________________________________________________________________
576 void WriteLastCurrentFile(AliDAConfig& cfg, TString currentFile)
577 {
579 
580  ofstream out;
581  TString file;
582  file = currentFile;
583  out.open(file.Data(), std::ofstream::out);
584  out << cfg.GetSodName() << " " << cfg.GetSodFlag() << endl;
585  out << cfg.GetDAName() << " " << cfg.GetDAFlag() << endl;
586 
587  out << cfg.GetGlobalFileName() << " " << cfg.GetGlobalFileVersion() << endl;
588  out << cfg.GetRegionalFileName() << " " << cfg.GetRegionalFileVersion() << endl;
589  out << cfg.GetLocalMaskFileName() << " " << cfg.GetLocalMaskFileVersion() << endl;
590  out << cfg.GetLocalLutFileName() << " " << cfg.GetLocalLutFileVersion() << endl;
591  out << cfg.GetSignatureFileName() << " " << cfg.GetSignatureFileVersion() << endl;
592 
593  out.close();
594 }
595 
596 //___________________________________________________________________________________________
597 Bool_t ReadCurrentFile(AliDAConfig& cfg, TString currentFile, Bool_t lastCurrentFlag = kFALSE)
598 {
600 
601  char line[80];
602  char name[80];
603  Int_t flag;
604 
605  TString file;
606  file = currentFile;
607  std::ifstream in(gSystem->ExpandPathName(file.Data()));
608  if (!in.good()) {
609  printf("Cannot open last current file %s\n",currentFile.Data());
610  return kFALSE;
611  }
612 
613  // read SOD
614  in.getline(line,80);
615  sscanf(line, "%s %d", name, &flag);
616  cfg.SetSodName(name);
617  cfg.SetSodFlag(flag);
618  if (cfg.GetPrintLevel()) printf("Sod Flag %d\n", cfg.GetSodFlag());
619 
620  //read DA
621  in.getline(line,80);
622  sscanf(line, "%s %d", name, &flag);
623  cfg.SetDAName(name);
624  cfg.SetDAFlag(flag);
625  if (cfg.GetPrintLevel()) printf("DA Flag: %d\n", cfg.GetDAFlag());
626 
627  // read global
628  in.getline(line,80);
629  TString tmp(line);
630  Int_t pos = tmp.First(" ");
631  TString tmp1 = tmp(0, pos);
632  cfg.SetGlobalFileName(tmp1.Data());
633 
634  if (!lastCurrentFlag) {
635  cfg.SetGlobalFileVersion(atoi(tmp(pos+1, tmp.Length()-pos).Data()));
636  if (cfg.GetPrintLevel()) printf("Global File Name: %s version: %d\n",
638  } else {
639  cfg.SetGlobalFileLastVersion(atoi(tmp(pos+1, tmp.Length()-pos).Data()));
640  if (cfg.GetPrintLevel()) printf("Global File Name: %s last version: %d\n",
642  }
643 
644  // read regional
645  in.getline(line,80);
646  tmp = line;
647  pos = tmp.First(" ");
648  tmp1 = tmp(0, pos);
649  cfg.SetRegionalFileName(tmp1.Data());
650 
651  if (!lastCurrentFlag) {
652  cfg.SetRegionalFileVersion(atoi(tmp(pos+1, tmp.Length()-pos).Data()));
653  if (cfg.GetPrintLevel()) printf("Regional File Name: %s version: %d\n",
655 
656  } else {
657  cfg.SetRegionalFileLastVersion(atoi(tmp(pos+1, tmp.Length()-pos).Data()));
658  if (cfg.GetPrintLevel()) printf("Regional File Name: %s last version: %d\n",
660  }
661 
662  // read mask
663  in.getline(line,80);
664  tmp = line;
665  pos = tmp.First(" ");
666  tmp1 = tmp(0, pos);
667  cfg.SetLocalMaskFileName(tmp1.Data());
668 
669  if (!lastCurrentFlag) {
670  cfg.SetLocalMaskFileVersion(atoi(tmp(pos+1, tmp.Length()-pos).Data()));
671  if (cfg.GetPrintLevel()) printf("Mask File Name: %s version: %d\n",
673  } else {
674  cfg.SetLocalMaskFileLastVersion(atoi(tmp(pos+1, tmp.Length()-pos).Data()));
675  if (cfg.GetPrintLevel()) printf("Mask File Name: %s last version: %d\n",
677  }
678  // read Lut
679  in.getline(line,80);
680  tmp = line;
681  pos = tmp.First(" ");
682  tmp1 = tmp(0, pos);
683  cfg.SetLocalLutFileName(tmp1.Data());
684 
685  if (!lastCurrentFlag) {
686  cfg.SetLocalLutFileVersion(atoi(tmp(pos+1, tmp.Length()-pos).Data()));
687  if (cfg.GetPrintLevel()) printf("Lut File Name: %s version: %d\n",
689  } else {
690  cfg.SetLocalLutFileLastVersion(atoi(tmp(pos+1, tmp.Length()-pos).Data()));
691  if (cfg.GetPrintLevel()) printf("Lut File Name: %s last version: %d\n",
693  }
694 
695  in.getline(line,80);
696  tmp = line;
697  pos = tmp.First(" ");
698  tmp1 = tmp(0, pos);
699  cfg.SetSignatureFileName(tmp1.Data());
700  cfg.SetSignatureFileVersion(atoi(tmp(pos+1, tmp.Length()-pos).Data()));
701  if (cfg.GetPrintLevel()) printf("Lut File Name: %s version: %d\n",
703 
704  return kTRUE;
705 }
706 
707 //_____________
709 {
711 
712  if (!ReadCurrentFile(cfg,cfg.GetLastCurrentFileName(), kTRUE))
713  {
714  ReadCurrentFile(cfg,cfg.GetCurrentFileName(), kTRUE);
715  }
716 
717  // any case read current file
719 
720 }
721 
722 //__________________
724 {
726 
727  // env variables have to be set (suppose by ECS ?)
728  // setenv DATE_FES_PATH
729  // setenv DATE_RUN_NUMBER
730  // setenv DATE_ROLE_NAME
731  // setenv DATE_DETECTOR_CODE
732 
733 #ifdef OFFLINE
734  gSystem->Setenv("DAQDALIB_PATH", "$DATE_ROOT/infoLogger");
735  gSystem->Setenv("DAQDA_TEST_DIR", "/users_local1/Software/ALICE/AMORE/FES");
736 #endif
737 
738  // update files
739  Int_t status = 0;
740 
741  Bool_t modified = kFALSE;
742  Bool_t globalExported = kFALSE;
743  Bool_t storeOCDB = kTRUE;
744 
745  ofstream out;
746  TString file;
747 
748  out.open(fileExp.Data(), std::ofstream::out);
749  if (!out.good()) {
750  printf("Failed to create file: %s\n",fileExp.Data());
751  return kFALSE;
752  }
753 
754  // check if MtgLastCurrent.dat exists
755  // if not, do initial export of all files
756  Bool_t initFES = kFALSE;
757  if (gSystem->AccessPathName("MtgLastCurrent.dat"))
758  initFES = kTRUE;
759  if (initFES) printf("Copy all configuration files to the FES.\n");
760 
761  file = cfg.GetLocalMaskFileName();
762  if ((cfg.GetLocalMaskFileLastVersion() != cfg.GetLocalMaskFileVersion()) || initFES) {
763  modified = kTRUE;
764  status = 0;
765  status = daqDA_FES_storeFile(file.Data(), "LOCAL");
766  if (status) {
767  printf("Failed to export file: %s\n",cfg.GetLocalMaskFileName());
768  return kFALSE;
769  }
770  if(cfg.GetPrintLevel()) printf("Export file: %s\n",cfg.GetLocalMaskFileName());
771  out << cfg.GetLocalMaskFileName() << " " << storeOCDB << endl;
772  }
773 
774  file = cfg.GetLocalLutFileName();
775  if ((cfg.GetLocalLutFileLastVersion() != cfg.GetLocalLutFileVersion()) || initFES) {
776  modified = kTRUE;
777  status = 0;
778  status = daqDA_FES_storeFile(file.Data(), "LUT");
779  if (status) {
780  printf("Failed to export file: %s\n",cfg.GetLocalLutFileName());
781  return kFALSE;
782  }
783  if(cfg.GetPrintLevel()) printf("Export file: %s\n",cfg.GetLocalLutFileName());
784  out << cfg.GetLocalLutFileName() << " " << storeOCDB << endl;
785 
786  }
787 
788  file = cfg.GetGlobalFileName();
789  if ((cfg.GetGlobalFileLastVersion() != cfg.GetGlobalFileVersion()) || modified || initFES) {
790  modified = kTRUE;
791  globalExported = kTRUE;
792  status = 0;
793  status = daqDA_FES_storeFile(file.Data(), "GLOBAL");
794  if (status) {
795  printf("Failed to export file: %s\n",cfg.GetGlobalFileName());
796  return kFALSE;
797  }
798  if(cfg.GetPrintLevel()) printf("Export file: %s\n",cfg.GetGlobalFileName());
799  out << cfg.GetGlobalFileName() << " " << storeOCDB << endl;
800  }
801 
802  file = cfg.GetRegionalFileName();
803  if ( (cfg.GetRegionalFileLastVersion() != cfg.GetRegionalFileVersion()) || modified || initFES) {
804  status = 0;
805  status = daqDA_FES_storeFile(file.Data(), "REGIONAL");
806  if (status) {
807  printf("Failed to export file: %s\n",cfg.GetRegionalFileName());
808  return kFALSE;
809  }
810  if(cfg.GetPrintLevel()) printf("Export file: %s\n",cfg.GetRegionalFileName());
811  out << cfg.GetRegionalFileName() << " " << storeOCDB << endl;
812 
813  // needed for the initialisation of the mapping
814  if (!globalExported) {
815  file = cfg.GetGlobalFileName();
816  status = 0;
817  status = daqDA_FES_storeFile(file.Data(), "GLOBAL");
818  if (status) {
819  printf("Failed to export file: %s\n",cfg.GetGlobalFileName());
820  return kFALSE;
821  }
822  if(cfg.GetPrintLevel()) printf("Export file: %s\n",cfg.GetGlobalFileName());
823  out << cfg.GetGlobalFileName() << " " << storeOCDB << endl;
824  }
825 
826  }
827 
828  out.close();
829 
830  // write last current file
832 
833  return kTRUE;
834 }
835 
836 //__________________
838 {
839 
842 
843  TString file;
844  Int_t status = 0;
845  Bool_t storeOCDB = kTRUE;
846 
847  ofstream out;
848  out.open(fileExp.Data(), std::ofstream::app);
849  if (!out.good()) {
850  printf("Failed to open file in append mode: %s\n",fileExp.Data());
851  return kFALSE;
852  }
853 
854  // global config
855  file = cfg.GetGlobalFileName();
856  status = 0;
857  status = daqDA_FES_storeFile(file.Data(), "GLOBAL");
858  if (status) {
859  printf("Failed to export file: %s\n",cfg.GetGlobalFileName());
860  return kFALSE;
861  }
862  if(cfg.GetPrintLevel()) printf("Export file: %s\n",cfg.GetGlobalFileName());
863  storeOCDB = kFALSE;
864  out << cfg.GetGlobalFileName() << " " << storeOCDB << endl;
865 
866  // regional config
867  file = cfg.GetRegionalFileName();
868  status = 0;
869  status = daqDA_FES_storeFile(file.Data(), "REGIONAL");
870  if (status) {
871  printf("Failed to export file: %s\n",cfg.GetRegionalFileName());
872  return kFALSE;
873  }
874  if(cfg.GetPrintLevel()) printf("Export file: %s\n",cfg.GetRegionalFileName());
875  storeOCDB = kFALSE;
876  out << cfg.GetRegionalFileName() << " " << storeOCDB << endl;
877 
878  // trigger scalers
879  file = cfg.GetTrigScalFileName();
880  status = 0;
881  status = daqDA_FES_storeFile(file.Data(), "TRIGSCAL");
882  if (status) {
883  printf("Failed to export file: %s\n",cfg.GetTrigScalFileName());
884  return status;
885  }
886  if(cfg.GetPrintLevel()) printf("Export file: %s\n",cfg.GetTrigScalFileName());
887  storeOCDB = kTRUE;
888  out << cfg.GetTrigScalFileName() << " " << storeOCDB << endl;
889 
890  out.close();
891 
892  return kTRUE;
893 
894 }
895 
896 //__________________
898 {
905 
906  Int_t status = 0;
907 
908 #ifdef OFFLINE
909  gSystem->Setenv("DAQDALIB_PATH", "$DATE_ROOT/db");
910 #endif
911 
912  status = 0;
913  status = daqDA_DB_getFile(cfg.GetDAConfigFileName(), cfg.GetDAConfigFileName());
914  if (status) {
915  printf("Failed to get DA config file from DB: %s\n",cfg.GetDAConfigFileName());
916  return kFALSE;
917  }
918 
919  ReadDAConfig(cfg);
920 
921  status = 0;
922  status = daqDA_DB_getFile(cfg.GetCurrentFileName(), cfg.GetCurrentFileName());
923  if (status) {
924  printf("Failed to get current config file from DB: %s\n",cfg.GetCurrentFileName());
925  return kFALSE;
926  }
927 
928  ReadFileNames(cfg);
929 
930  status = 0;
931  status = daqDA_DB_getFile(cfg.GetGlobalFileName(), cfg.GetGlobalFileName());
932  if (status) {
933  printf("Failed to get current config file from DB: %s\n", cfg.GetGlobalFileName());
934  return kFALSE;
935  }
936 
937  status = 0;
938  status = daqDA_DB_getFile(cfg.GetRegionalFileName(), cfg.GetRegionalFileName());
939  if (status) {
940  printf("Failed to get current config file from DB: %s\n",cfg.GetRegionalFileName());
941  return kFALSE;
942  }
943 
944  status = 0;
945  status = daqDA_DB_getFile(cfg.GetLocalMaskFileName(), cfg.GetLocalMaskFileName());
946  if (status) {
947  printf("Failed to get current config file from DB: %s\n",cfg.GetLocalMaskFileName());
948  return kFALSE;
949  }
950 
951  status = 0;
952  status = daqDA_DB_getFile(cfg.GetLocalLutFileName(), cfg.GetLocalLutFileName());
953  if (status) {
954  printf("Failed to get current config file from DB: %s\n",cfg.GetLocalLutFileName());
955  return kFALSE;
956  }
957 
958  return kTRUE;
959 }
960 
961 //_____________
963 {
965 
966  const Char_t* localFile = cfg.GetLocalMaskFileName();
967  const Char_t* regionalFile = cfg.GetRegionalFileName();
968  const Char_t* globalFile = cfg.GetGlobalFileName();
969 
970  cfg.GetTriggerIO()->ReadConfig(localFile, regionalFile, globalFile, cfg.GetLocalMasks(), cfg.GetRegionalMasks(), cfg.GetGlobalMasks());
971 }
972 
973 //______________________________________________________________
974 UInt_t GetFetMode(const AliDAConfig & cfg)
975 {
979 
980  return cfg.GetGlobalMasks()->GetFetRegister(3);
981 
982 }
983 
984 //______________________________________________________________
985 void StoreGlobalInput(AliDAConfig& cfg, const UInt_t * const globalInput)
986 {
988 
989  for (Int_t ii = 0; ii < cfg.GetGlobalInputs(); ii++) {
990  for (Int_t ib = 0; ib < cfg.GetGlobalInputLength(); ib++) {
991  // lsb -> msb
992  if (cfg.GetAlgoNoisyInput())
993  cfg.AddAccGlobalInputN(ii,ib,((globalInput[ii] >> ib) & 0x1));
994  if (cfg.GetAlgoDeadcInput())
995  cfg.AddAccGlobalInputD(ii,ib,((globalInput[ii] >> ib) & 0x1));
996  }
997  }
998 
999 }
1000 
1001 //______________________________________________________________
1003 {
1005 
1006 #ifdef OFFLINE
1007  gSystem->Setenv("DAQDALIB_PATH", "$DATE_ROOT/db");
1008 #endif
1009 
1010  Float_t rateN = 0.0, rateD = 0.0;
1011  UInt_t gmask[4], omask;
1012  Bool_t noise, deadc, withEvN, withEvD, updated = kFALSE;
1013 
1014  for (Int_t ii = 0; ii < cfg.GetGlobalInputs(); ii++) {
1015  gmask[ii] = 0;
1016 
1017  for (Int_t ib = 0; ib < cfg.GetGlobalInputLength(); ib++) {
1018  // lsb -> msb
1019  noise = kFALSE;
1020  deadc = kFALSE;
1021  withEvN = kFALSE;
1022  withEvD = kFALSE;
1023  if (cfg.GetEventsN() > cfg.GetMinEvents()) {
1024  rateN = (Float_t)cfg.GetAccGlobalInputN(ii,ib)/(Float_t)cfg.GetEventsN();
1025  noise = (rateN > cfg.GetThrN());
1026  withEvN = kTRUE;
1027  }
1028  if (cfg.GetEventsD() > cfg.GetMinEvents()) {
1029  rateD = (Float_t)cfg.GetAccGlobalInputD(ii,ib)/(Float_t)cfg.GetEventsD();
1030  deadc = (rateD < cfg.GetThrD());
1031  withEvD = kTRUE;
1032  }
1033  if (!withEvN && !withEvD) {
1034  // - copy the bit from the old mask
1035  gmask[ii] |= ((cfg.GetGlobalMasks()->GetGlobalMask(ii) >> ib) & 0x1) << ib;
1036  if (cfg.GetPrintLevel())
1037  printf("Mask not changed (just copy the old values)\n");
1038  }
1039  if (!withEvN && withEvD) {
1040  if (!deadc) {
1041  // - create a new mask, set the bit to 1
1042  // not allowed!
1043  //gmask[ii] |= 0x1 << ib;
1044  // - copy the bit from the old mask
1045  gmask[ii] |= ((cfg.GetGlobalMasks()->GetGlobalMask(ii) >> ib) & 0x1) << ib;
1046  } else {
1047  // - create a new mask, set the bit to 0
1048  gmask[ii] |= 0x0 << ib;
1049  if (cfg.GetPrintLevel())
1050  printf("Found dead channel %1d:%02d (%4.2f) \n",ii,ib,rateD);
1051  }
1052  }
1053  if (withEvN && !withEvD) {
1054  if (!noise) {
1055  // - create a new mask, set the bit to 1
1056  // not allowed!
1057  //gmask[ii] |= 0x1 << ib;
1058  // - copy the bit from the old mask
1059  gmask[ii] |= ((cfg.GetGlobalMasks()->GetGlobalMask(ii) >> ib) & 0x1) << ib;
1060  } else {
1061  // - create a new mask, set the bit to 0
1062  gmask[ii] |= 0x0 << ib;
1063  if (cfg.GetPrintLevel())
1064  printf("Found noisy channel %1d:%02d (%4.2f) \n",ii,ib,rateN);
1065  }
1066  }
1067  if (withEvN && withEvD) {
1068  if (!noise && !deadc) {
1069  // - create a new mask, set the bit to 1
1070  // not allowed!
1071  //gmask[ii] |= 0x1 << ib;
1072  // - copy the bit from the old mask
1073  gmask[ii] |= ((cfg.GetGlobalMasks()->GetGlobalMask(ii) >> ib) & 0x1) << ib;
1074  } else {
1075  // - create a new mask, set the bit to 0
1076  gmask[ii] |= 0x0 << ib;
1077  if (cfg.GetPrintLevel()) {
1078  if (noise)
1079  printf("Found noisy channel %1d:%02d (%4.2f) \n",ii,ib,rateN);
1080  if (deadc)
1081  printf("Found dead channel %1d:%02d (%4.2f) \n",ii,ib,rateD);
1082  }
1083  }
1084  }
1085  }
1086  }
1087 
1088  // check if at least one mask value has been changed from previous version
1089  for (Int_t ii = 0; ii < cfg.GetGlobalInputs(); ii++) {
1090  printf("Global mask [%1d] %08x \n",ii,gmask[ii]);
1091  omask = cfg.GetGlobalMasks()->GetGlobalMask(ii);
1092  if (gmask[ii] != omask) {
1093  updated = kTRUE;
1094  cfg.GetGlobalMasks()->SetGlobalMask(ii,gmask[ii]);
1095  }
1096  }
1097 
1098  Int_t status = 0;
1099  if (updated) {
1100 
1101  // update version
1102  cfg.IncGlobalFileVersion();
1103 
1104  // don't change the file version ("-x.dat")
1105 
1107 
1108  // write last current file
1110 
1111  status = 0;
1112  status = daqDA_DB_storeFile(cfg.GetGlobalFileName(), cfg.GetGlobalFileName());
1113  if (status) {
1114  printf("Failed to export file to DB: %s\n",cfg.GetGlobalFileName());
1115  return;
1116  }
1117 
1118  status = 0;
1119  status = daqDA_DB_storeFile(cfg.GetCurrentFileName(), cfg.GetCurrentFileName());
1120  if (status) {
1121  printf("Failed to export file to DB: %s\n",cfg.GetCurrentFileName());
1122  return;
1123  }
1124 
1125  }
1126 
1127 }
1128 
1129 //______________________________________________________________
1130 void UpdateLocalMask(AliDAConfig& cfg, Int_t localBoardId, Int_t connector, Int_t strip)
1131 {
1132 
1134 
1135  AliMUONVCalibParam* localMask =
1136  static_cast<AliMUONVCalibParam*>(cfg.GetLocalMasksDA()->FindObject(localBoardId));
1137 
1138  UShort_t mask = static_cast<UShort_t>(localMask->ValueAsInt(connector,0));
1139 
1140  mask &= ~(0x1 << strip); // set strip mask to zero
1141 
1142  localMask->SetValueAsInt(connector, 0, mask);
1143 
1144 }
1145 
1146 //______________________________________________________________
1147 void MakePattern(AliDAConfig& cfg, Int_t localBoardId, const TArrayS& xPattern, const TArrayS& yPattern)
1148 {
1150 
1151  AliMUONVCalibParam* pat = 0x0;
1152 
1153  if (cfg.GetAlgoNoisyInput())
1154  pat = static_cast<AliMUONVCalibParam*>(cfg.GetPatternStoreN()->FindObject(localBoardId));
1155  if (cfg.GetAlgoDeadcInput())
1156  pat = static_cast<AliMUONVCalibParam*>(cfg.GetPatternStoreD()->FindObject(localBoardId));
1157 
1158  if (!pat) {
1159  pat = new AliMUONCalibParamND(2, 64, localBoardId, 0, 0.);
1160  if (cfg.GetAlgoNoisyInput())
1161  cfg.GetPatternStoreN()->Add(pat);
1162  if (cfg.GetAlgoDeadcInput())
1163  cfg.GetPatternStoreD()->Add(pat);
1164  }
1165 
1166  for (Int_t i = 0; i < 4; ++i) {
1167  for (Int_t j = 0; j < 16; ++j) {
1168 
1169  Int_t xMask = xPattern[i];
1170  Int_t yMask = yPattern[i];
1171 
1172  Int_t index = 16*i + j;
1173  Double_t patOcc = 0.;
1174 
1175  if ( (xMask >> j ) & 0x1 ) {
1176  patOcc = pat->ValueAsDouble(index, 0) + 1.;
1177  pat->SetValueAsDouble(index, 0, patOcc);
1178  }
1179  if ( (yMask >> j ) & 0x1 ) {
1180  patOcc = pat->ValueAsDouble(index, 1) + 1.;
1181  pat->SetValueAsDouble(index, 1, patOcc);
1182  }
1183  }
1184  }
1185 
1186 }
1187 
1188 //______________________________________________________________
1190 {
1192 
1193 #ifdef OFFLINE
1194  gSystem->Setenv("DAQDALIB_PATH", "$DATE_ROOT/db");
1195 #endif
1196 
1197  AliMUONVCalibParam* pat;
1198  Int_t localBoardId = 0;
1199  Int_t nEventsN = 0, nEventsD = 0;
1200  UShort_t strip = 0;
1201  Int_t connector = 0;
1202  Bool_t updated = kFALSE;
1203 
1204  if (cfg.GetEventsN() > cfg.GetMinEvents()) {
1205  nEventsN = cfg.GetEventsN();
1206  }
1207  if (cfg.GetEventsD() > cfg.GetMinEvents()) {
1208  nEventsD = cfg.GetEventsD();
1209  }
1210 
1211  // noisy strips
1212  if (nEventsN > 0) {
1213 
1214  TIter next(cfg.GetPatternStoreN()->CreateIterator());
1215 
1216  while ( ( pat = dynamic_cast<AliMUONVCalibParam*>(next() ) ) ) {
1217 
1218  localBoardId = pat->ID0();
1219 
1220  for (Int_t index = 0; index < pat->Size(); index++) {
1221 
1222  Double_t patXOcc = pat->ValueAsDouble(index, 0)/(Double_t)nEventsN;
1223  Double_t patYOcc = pat->ValueAsDouble(index, 1)/(Double_t)nEventsN;
1224 
1225  pat->SetValueAsDouble(index, 0, patXOcc);
1226  pat->SetValueAsDouble(index, 1, patYOcc);
1227 
1228  // check for x strip
1229  if (patXOcc > cfg.GetThrLocN()) {
1230  strip = index % 16;
1231  connector = index/16;
1232  UpdateLocalMask(cfg, localBoardId, connector, strip);
1233  }
1234  // check for y strip
1235  if (patYOcc > cfg.GetThrLocN()) {
1236  strip = index % 16;
1237  connector = index/16 + 4;
1238  UpdateLocalMask(cfg, localBoardId, connector, strip);
1239  }
1240 
1241  }
1242  }
1243 
1244  }
1245 
1246  // dead strips
1247  if (nEventsD > 0) {
1248 
1249  TIter next(cfg.GetPatternStoreD()->CreateIterator());
1250 
1251  while ( ( pat = dynamic_cast<AliMUONVCalibParam*>(next() ) ) ) {
1252 
1253  localBoardId = pat->ID0();
1254 
1255  for (Int_t index = 0; index < pat->Size(); index++) {
1256 
1257  Double_t patXOcc = pat->ValueAsDouble(index, 0)/(Double_t)nEventsD;
1258  Double_t patYOcc = pat->ValueAsDouble(index, 1)/(Double_t)nEventsD;
1259 
1260  pat->SetValueAsDouble(index, 0, patXOcc);
1261  pat->SetValueAsDouble(index, 1, patYOcc);
1262 
1263  // check for x strip
1264  if (patXOcc < cfg.GetThrLocD()) {
1265  strip = index % 16;
1266  connector = index/16;
1267  UpdateLocalMask(cfg, localBoardId, connector, strip);
1268  }
1269  // check for y strip
1270  if (patYOcc < cfg.GetThrLocD()) {
1271  strip = index % 16;
1272  connector = index/16 + 4;
1273  UpdateLocalMask(cfg, localBoardId, connector, strip);
1274  }
1275 
1276  }
1277  }
1278 
1279  }
1280 
1281  // make and AND with the previous version of the mask and
1282  // check if the mask has changed
1283  UShort_t maskDA, mask;
1284  Int_t nMaskBits = AliMpConstants::TotalNofLocalBoards()*8*16;
1285  Int_t nMaskBitsChanged = 0;
1286  for (localBoardId = 1; localBoardId <= AliMpConstants::TotalNofLocalBoards(); localBoardId++) {
1287  AliMUONVCalibParam* localMaskDA = static_cast<AliMUONVCalibParam*>(cfg.GetLocalMasksDA()->FindObject(localBoardId));
1288  AliMUONVCalibParam* localMask = static_cast<AliMUONVCalibParam*>(cfg.GetLocalMasks()->FindObject(localBoardId));
1289  for (connector = 0; connector < 8; connector++) {
1290  maskDA = static_cast<UShort_t>(localMaskDA->ValueAsInt(connector,0));
1291  mask = static_cast<UShort_t>(localMask->ValueAsInt(connector,0));
1292  maskDA &= mask;
1293  localMaskDA->SetValueAsInt(connector, 0, maskDA);
1294  if (maskDA != mask) {
1295  updated = kTRUE;
1296  // calculated percentage of mask bits changed
1297  for (Int_t iBit = 0; iBit < 16; iBit++) {
1298  if (((maskDA >> iBit) & 0x1) != ((mask >> iBit) &0x1)) {
1299  nMaskBitsChanged++;
1300  }
1301  }
1302  }
1303  }
1304  }
1305 
1306  printf("LOCAL mask bits changed = %5d (%7.3f %%) \n",nMaskBitsChanged,100*(Float_t)nMaskBitsChanged/(Float_t)nMaskBits);
1307 
1308  Int_t status = 0;
1309  if (updated) {
1310 
1311  // update version
1313 
1314  // don't change the file version ("-x.dat")
1315 
1317 
1318  // write last current file
1320 
1321  status = 0;
1322  status = daqDA_DB_storeFile(cfg.GetLocalMaskFileName(), cfg.GetLocalMaskFileName());
1323  if (status) {
1324  printf("Failed to export file to DB: %s\n",cfg.GetLocalMaskFileName());
1325  return;
1326  }
1327 
1328  status = 0;
1329  status = daqDA_DB_storeFile(cfg.GetCurrentFileName(), cfg.GetCurrentFileName());
1330  if (status) {
1331  printf("Failed to export file to DB: %s\n",cfg.GetCurrentFileName());
1332  return;
1333  }
1334 
1335  }
1336 
1337 }
1338 
1339 //*************************************************************//
1340 int main(Int_t argc, Char_t **argv)
1341 {
1343 
1344  // needed for streamer application
1345  gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo", "*", "TStreamerInfo", "RIO", "TStreamerInfo()");
1346 
1347  printf("MTRda version v.23102015.01 \n");
1348 
1349  /* check that we got some arguments = list of files */
1350  if (argc<2) {
1351  printf("Wrong number of arguments\n");
1352  return -1;
1353  }
1354 
1355  AliDAConfig cfg;
1356 
1357  Char_t inputFile[256] = "";
1358  inputFile[0] = 0;
1359  if (argc > 1) {
1360  if (argv[1] != NULL) {
1361  strncpy(inputFile, argv[1], 256);
1362  } else {
1363  printf("MTRda : No input File !\n");
1364  return -1;
1365  }
1366  }
1367 
1368  // decoding the events
1369 
1370  Int_t status = 0;
1371  Int_t nDateEvents = 0;
1372 
1373  // containers
1374  // old decoder
1375  AliMUONDDLTrigger* ddlTrigger = 0x0;
1376  AliMUONDarcHeader* darcHeader = 0x0;
1377  AliMUONRegHeader* regHeader = 0x0;
1378  AliMUONLocalStruct* localStruct = 0x0;
1379  // new (fast) decoder
1380  const AliMUONRawStreamTriggerHP::AliHeader* darcHeaderHP = 0x0;
1381  const AliMUONRawStreamTriggerHP::AliLocalStruct* localStructHP = 0x0;
1382 
1383  TArrayS xPattern(4);
1384  TArrayS yPattern(4);
1385  Int_t localBoardId = 0;
1386 
1387  TStopwatch timers;
1388 
1389  timers.Start(kTRUE);
1390 
1391  // comment out, since we do not retrieve files from database
1392  if (!ImportFiles(cfg)) {
1393  printf("Import from DB failed\n");
1394  printf("For local test set DAQDA_TEST_DIR to the local directory where the Mtg files are located \n");
1395  return -1;
1396  }
1397 
1398  ReadMaskFiles(cfg);
1399 
1400 #ifdef OFFLINE
1401  // the run number extracted from the file name
1402  TString tmp(inputFile);
1403  Int_t pos1 = tmp.First('d');
1404  Int_t pos2 = tmp.Last('.');
1405  Int_t len = pos2 - (pos1+3);
1406  tmp = tmp(pos1+3,len);
1407  gSystem->Setenv("DATE_RUN_NUMBER",tmp.Data());
1408  gSystem->Exec("echo \"DATE_RUN_NUMBER = \" $DATE_RUN_NUMBER");
1409 #endif
1410 
1411  if(!ExportFiles(cfg)) {
1412  printf("ExportFiles failed\n");
1413  return -1;
1414  }
1415 
1416  // FET is triggered by CTP
1417  Bool_t modeFET3 = kTRUE;
1418  if (GetFetMode(cfg) != 3) {
1419  printf("FET is not in mode 3. Only PHYSICS events will be analysed (noisy channels)\n");
1420  modeFET3 = kFALSE;
1421  }
1422 
1423  // All 5 global cards are controlled by the Mts proxy
1424  // sans carte JTAG 0x1F ---> 0x0F (!)
1425  if (cfg.GetGlobalMasks()->GetGlobalCrateEnable() != 0x0F) {
1426  printf("The MTS proxy does not control all global cards\n");
1427  return -1;
1428  }
1429 
1430  // The global cards are ON (active on the global inputs)
1431  if (!cfg.GetGlobalMasks()->GetMasksOn()) {
1432  printf("Global masks are not ON\n");
1433  return -1;
1434  }
1435 
1436  // make sure to catch the "rare" calib events (1 every 50s in physics)
1437  const Char_t* tableSOD[] = {"ALL", "yes", "CAL", "all", NULL, NULL};
1438  monitorDeclareTable(const_cast<char**>(tableSOD));
1439 
1440  status = 0;
1441  status = monitorSetDataSource(inputFile);
1442  if (status) {
1443  cerr << "ERROR : monitorSetDataSource status (hex) = " << hex << status
1444  << " " << monitorDecodeError(status) << endl;
1445  return -1;
1446  }
1447  status = 0;
1448  status = monitorDeclareMp("MUON Trigger monitoring");
1449  if (status) {
1450  cerr << "ERROR : monitorDeclareMp status (hex) = " << hex << status
1451  << " " << monitorDecodeError(status) << endl;
1452  return -1;
1453  }
1454 
1455  /* define wait event timeout - 1s max */
1456  monitorSetNowait();
1457  monitorSetNoWaitNetworkTimeout(1000);
1458 
1459  cout << "MTRda : Reading data from file " << inputFile <<endl;
1460 
1461  UInt_t nCalibEvents;
1462  Double_t elapsT;
1463  Double_t deltaT;
1464  UInt_t glSc[6];
1465  Bool_t overFlow, firstCalibEvent = kTRUE;
1466  const Int_t nTriChambers = AliMpConstants::NofTriggerChambers();
1467  const Int_t nLocBoards = AliMpConstants::NofLocalBoards();
1468  const Int_t nCathodes = 2;
1469  UInt_t locLptScaler[nLocBoards];
1470  ULong64_t locStripScaler[nTriChambers][nLocBoards][nCathodes];
1471  UInt_t locStripOver[nTriChambers][nLocBoards][nCathodes];
1472 
1473  const Int_t bufflen =
1474  8*sizeof(UInt_t)+
1475  nLocBoards*sizeof(UInt_t)+
1476  nLocBoards*nCathodes*nTriChambers*(sizeof(UInt_t)+sizeof(ULong64_t));
1477  UChar_t buffer[bufflen];
1478  //printf("Buffer length = %d bytes \n",bufflen);
1479 
1480  // reset scalers
1481  deltaT = 0.;
1482  nCalibEvents = 0;
1483  for (Int_t bit = 0; bit < 6; bit++) {
1484  glSc[bit] = 0;
1485  }
1486  for (Int_t iLoc = 0; iLoc < nLocBoards; iLoc++) {
1487  locLptScaler[iLoc] = 0;
1488  for (Int_t iCath = 0; iCath < nCathodes; iCath++) {
1489  for (Int_t iCha = 0; iCha < nTriChambers; iCha++) {
1490  locStripScaler[iCha][iLoc][iCath] = 0;
1491  locStripOver[iCha][iLoc][iCath] = 0;
1492  }
1493  }
1494  }
1495 
1496  FILE* fsc = fopen(cfg.GetTrigScalFileName(),"wb");
1497  Bool_t writeScalers = kFALSE;
1498 
1499  UInt_t *globalInput = new UInt_t[4];
1500  Bool_t doUpdate = kFALSE;
1501  Int_t runNumber = 0;
1502  Int_t nEvents = 0;
1503 
1504  // event loop
1505  while(1)
1506  {
1507 
1508  struct eventHeaderStruct *event(0x0);
1509 
1510  if (cfg.GetPrintLevel()) {
1511  if (nEvents && nEvents % 1000 == 0)
1512  cout<<"Cumulated events " << nEvents << endl;
1513  }
1514  // check shutdown condition
1515  if (daqDA_checkShutdown()) {
1516  delete event;
1517  break;
1518  }
1519 
1520  // Skip Events if needed
1521  while (cfg.GetSkipEvents()) {
1522  status = 0;
1523  status = monitorGetEventDynamic((void**)&event);
1524  cfg.DecSkipEvents();
1525  }
1526 
1527  // starts reading
1528  status = 0;
1529  status = monitorGetEventDynamic((void**)&event);
1530  if (status < 0) {
1531  cout << "MTRda : EOF found" << endl;
1532  delete event;
1533  break;
1534  }
1535 
1536  nDateEvents++;
1537 
1538  // decoding rawdata headers
1539  AliRawReader *rawReader = new AliRawReaderDate(event);
1540 
1541  Int_t eventType = rawReader->GetType();
1542  runNumber = rawReader->GetRunNumber();
1543 
1544  if (cfg.GetDAFlag() && (nEvents < cfg.GetMaxEvents())) {
1545  // L1Swc1
1546  // CALIBRATION_EVENT
1547  // SYSTEM_SOFTWARE_TRIGGER_EVENT
1548  // DETECTOR_SOFTWARE_TRIGGER_EVENT
1549  cfg.SetAlgoNoisyInput(kFALSE);
1550  cfg.SetAlgoDeadcInput(kFALSE);
1551  if (eventType == PHYSICS_EVENT) {
1552  cfg.SetAlgoNoisyInput(kTRUE);
1553  doUpdate = kTRUE;
1554  cfg.IncNoiseEvent();
1555  } else if (modeFET3 && eventType == CALIBRATION_EVENT) {
1556  cfg.SetAlgoDeadcInput(kTRUE);
1557  doUpdate = kTRUE;
1558  cfg.IncDeadcEvent();
1559  } else {
1560  delete event;
1561  continue;
1562  }
1563  }
1564  /*
1565  if (eventType == PHYSICS_EVENT) {
1566  printf("DBG: PHYSICS_EVENT\n");
1567  } else if (modeFET3 && eventType == CALIBRATION_EVENT) {
1568  printf("DBG: CALIBRATION_EVENT\n");
1569  } else {
1570  printf("DBG: OTHER (%d)\n",eventType);
1571  }
1572  */
1573  nEvents++;
1574  if (cfg.GetPrintLevel() == 2) printf("\nEvent # %d\n",nEvents);
1575 
1576  // decoding MUON payload
1577  AliMUONVRawStreamTrigger *rawStream = 0x0;
1578  if (cfg.UseFastDecoder()) {
1579  rawStream = new AliMUONRawStreamTriggerHP(rawReader);
1580  } else {
1581  rawStream = new AliMUONRawStreamTrigger(rawReader);
1582  }
1583 
1584  // ... without warnings from the decoder !!!
1585  if (!cfg.WithWarnings())
1586  rawStream->DisableWarnings();
1587 
1588  // if there is global clock overflow
1589  overFlow = kFALSE;
1590  // loops over DDL
1591  while((status = rawStream->NextDDL())) {
1592 
1593  if (cfg.GetPrintLevel() == 2) printf("iDDL %d\n", rawStream->GetDDL());
1594 
1595  if (cfg.UseFastDecoder()) {
1596  darcHeaderHP = static_cast<AliMUONRawStreamTriggerHP*>(rawStream)->GetHeaders();
1597  if (cfg.GetPrintLevel() == 2) printf("Global output (fast decoder) %x\n", (Int_t)darcHeaderHP->GetGlobalOutput());
1598  for (Int_t ig = 0; ig < cfg.GetGlobalInputs(); ig++) {
1599  globalInput[ig] = darcHeaderHP->GetGlobalInput(ig);
1600  }
1601  // global scalers
1602  if (cfg.SaveScalers() && (eventType == CALIBRATION_EVENT)) {
1603  if (darcHeaderHP->GetGlobalFlag()) {
1604  if (firstCalibEvent) {
1605  //printf("Skip first calib event: %x \n",darcHeaderHP->GetGlobalClock());
1606  overFlow = kTRUE;
1607  firstCalibEvent = kFALSE;
1608  } else {
1609  elapsT = darcHeaderHP->GetGlobalClock()/40e6; // [s]
1610  if (elapsT > 50.) {
1611  //printf("Possible overflow: %x \n",darcHeaderHP->GetGlobalClock());
1612  overFlow = kTRUE;
1613  } else {
1614  deltaT += elapsT;
1615  nCalibEvents++;
1616  const UInt_t* globScaler = darcHeaderHP->GetGlobalScaler();
1617  for (Int_t bit = 0; bit < 6; bit++) {
1618  glSc[bit] += (double)(*(globScaler+bit));
1619  }
1620  } // end check overflow
1621  } // end first calib event
1622  } // end global flag
1623  } // end scalers calib event
1624  // loop over regional structure
1625  Int_t nReg = (Int_t)static_cast<AliMUONRawStreamTriggerHP*>(rawStream)->GetRegionalHeaderCount();
1626  for(Int_t iReg = 0; iReg < nReg; iReg++) {
1627  // loop over local structures
1628  Int_t nLoc = (Int_t)static_cast<AliMUONRawStreamTriggerHP*>(rawStream)->GetLocalStructCount(iReg);
1629  for(Int_t iLoc = 0; iLoc < nLoc; iLoc++) {
1630  localStructHP = static_cast<AliMUONRawStreamTriggerHP*>(rawStream)->GetLocalStruct(iReg, iLoc);
1631  localBoardId = cfg.GetTriggerIO()->LocalBoardId(rawStream->GetDDL(),iReg,localStructHP->GetId());
1632  if (localBoardId > 0) {
1633  localStructHP->GetXPattern(xPattern);
1634  localStructHP->GetYPattern(yPattern);
1635  if (cfg.GetDAFlag() && (nEvents < cfg.GetMaxEvents())) {
1636  MakePattern(cfg,localBoardId,xPattern,yPattern);
1637  }
1638  // local scalers
1639  if (cfg.SaveScalers() && (eventType == CALIBRATION_EVENT)) {
1640  if (!overFlow) {
1641  // skip dead and copy cards
1642  if(localBoardId <= nLocBoards) {
1643  locLptScaler[localBoardId-1] +=
1644  localStructHP->GetScalars()->fLPtRTrig +
1645  localStructHP->GetScalars()->fLPtLTrig +
1646  localStructHP->GetScalars()->fLPtSTrig;
1647  Int_t cathode = localStructHP->GetComptXY();
1648  for (Int_t ibitxy = 0; ibitxy < 16; ++ibitxy) {
1649  UInt_t scalerVal[4] = {
1650  localStructHP->GetXY1(ibitxy),
1651  localStructHP->GetXY2(ibitxy),
1652  localStructHP->GetXY3(ibitxy),
1653  localStructHP->GetXY4(ibitxy)
1654  };
1655 
1656  for(Int_t ich = 0; ich < nTriChambers; ich++) {
1657  // sum over all strips
1658  if (scalerVal[ich] < 0xffff/2) {
1659  locStripScaler[ich][localBoardId-1][cathode] += 2*scalerVal[ich];
1660  } else {
1661  locStripOver[ich][localBoardId-1][cathode]++;
1662  }
1663  } // end chamber loop
1664 
1665  } // end strip loop
1666  } // end skip copy cards
1667  } // end check overflow
1668  } // end scalers calib event
1669  } // end valid local
1670  } // end loc loop
1671  } // end reg loop
1672  } else {
1673  ddlTrigger = rawStream->GetDDLTrigger();
1674  darcHeader = ddlTrigger->GetDarcHeader();
1675  if (cfg.GetPrintLevel() == 2) printf("Global output %x\n", (Int_t)darcHeader->GetGlobalOutput());
1676  globalInput = darcHeader->GetGlobalInput();
1677  // loop over regional structure
1678  Int_t nReg = darcHeader->GetRegHeaderEntries();
1679  for(Int_t iReg = 0; iReg < nReg; iReg++) {
1680  regHeader = darcHeader->GetRegHeaderEntry(iReg);
1681  // loop over local structures
1682  Int_t nLoc = regHeader->GetLocalEntries();
1683  for(Int_t iLoc = 0; iLoc < nLoc; iLoc++) {
1684  localStruct = regHeader->GetLocalEntry(iLoc);
1685  localBoardId = cfg.GetTriggerIO()->LocalBoardId(rawStream->GetDDL(),iReg,localStruct->GetId());
1686  if (localBoardId > 0) {
1687  localStruct->GetXPattern(xPattern);
1688  localStruct->GetYPattern(yPattern);
1689  if (cfg.GetDAFlag() && (nEvents < cfg.GetMaxEvents())) {
1690  MakePattern(cfg,localBoardId,xPattern,yPattern);
1691  }
1692  }
1693  }
1694  }
1695  }
1696  if (cfg.GetDAFlag() && (nEvents < cfg.GetMaxEvents())) {
1697  if (rawStream->GetDDL() == 0) {
1698  StoreGlobalInput(cfg,globalInput);
1699  }
1700  }
1701 
1702  } // NextDDL
1703 
1704  if (cfg.SaveScalers()) {
1705  if (!overFlow && (deltaT > (Double_t)cfg.GetScalerRecTime())) {
1706  printf("MTRda: write scalers after %d events\n",nEvents);
1707  writeScalers = kTRUE;
1708  Int_t ibw = 0;
1709  // global
1710  buffer[ibw++] = (nCalibEvents >> 24) & 0xff;
1711  buffer[ibw++] = (nCalibEvents >> 16) & 0xff;
1712  buffer[ibw++] = (nCalibEvents >> 8) & 0xff;
1713  buffer[ibw++] = (nCalibEvents >> 0) & 0xff;
1714  buffer[ibw++] = ((UInt_t)(deltaT+0.5) >> 24) & 0xff;
1715  buffer[ibw++] = ((UInt_t)(deltaT+0.5) >> 16) & 0xff;
1716  buffer[ibw++] = ((UInt_t)(deltaT+0.5) >> 8) & 0xff;
1717  buffer[ibw++] = ((UInt_t)(deltaT+0.5) >> 0) & 0xff;
1718  printf("MTRda: calib events %u time %f \n",nCalibEvents,deltaT);
1719  for (Int_t bit = 0; bit < 6; bit++) {
1720  buffer[ibw++] = (glSc[bit] >> 24) & 0xff;
1721  buffer[ibw++] = (glSc[bit] >> 16) & 0xff;
1722  buffer[ibw++] = (glSc[bit] >> 8) & 0xff;
1723  buffer[ibw++] = (glSc[bit] >> 0) & 0xff;
1724  //printf("glSc %u \n",glSc[bit]);
1725  }
1726  // local
1727  for (Int_t iLoc = 0; iLoc < nLocBoards; iLoc++) {
1728  buffer[ibw++] = (locLptScaler[iLoc] >> 24) & 0xff;
1729  buffer[ibw++] = (locLptScaler[iLoc] >> 16) & 0xff;
1730  buffer[ibw++] = (locLptScaler[iLoc] >> 8) & 0xff;
1731  buffer[ibw++] = (locLptScaler[iLoc] >> 0) & 0xff;
1732  for (Int_t iCath = 0; iCath < nCathodes; iCath++) {
1733  for (Int_t iCha = 0; iCha < nTriChambers; iCha++) {
1734  //printf("Ch%1dCath%1dLoc%03d %u %u \n",iCha,iCath,iLoc+1,locStripScaler[iCha][iLoc][iCath],locStripOver[iCha][iLoc][iCath]);
1735  // strip scalers
1736  buffer[ibw++] = (locStripScaler[iCha][iLoc][iCath] >> 56) & 0xff;
1737  buffer[ibw++] = (locStripScaler[iCha][iLoc][iCath] >> 48) & 0xff;
1738  buffer[ibw++] = (locStripScaler[iCha][iLoc][iCath] >> 40) & 0xff;
1739  buffer[ibw++] = (locStripScaler[iCha][iLoc][iCath] >> 32) & 0xff;
1740  buffer[ibw++] = (locStripScaler[iCha][iLoc][iCath] >> 24) & 0xff;
1741  buffer[ibw++] = (locStripScaler[iCha][iLoc][iCath] >> 16) & 0xff;
1742  buffer[ibw++] = (locStripScaler[iCha][iLoc][iCath] >> 8) & 0xff;
1743  buffer[ibw++] = (locStripScaler[iCha][iLoc][iCath] >> 0) & 0xff;
1744  // number of strips in overflow
1745  buffer[ibw++] = (locStripOver[iCha][iLoc][iCath] >> 24) & 0xff;
1746  buffer[ibw++] = (locStripOver[iCha][iLoc][iCath] >> 16) & 0xff;
1747  buffer[ibw++] = (locStripOver[iCha][iLoc][iCath] >> 8) & 0xff;
1748  buffer[ibw++] = (locStripOver[iCha][iLoc][iCath] >> 0) & 0xff;
1749  }
1750  }
1751  }
1752  printf("MTRda: write to buffer %d bytes.\n",ibw);
1753  fwrite(buffer,ibw,1,fsc);
1754  // reset
1755  deltaT = 0.;
1756  nCalibEvents = 0;
1757  for (Int_t bit = 0; bit < 6; bit++) {
1758  glSc[bit] = 0;
1759  }
1760  for (Int_t iLoc = 0; iLoc < nLocBoards; iLoc++) {
1761  locLptScaler[iLoc] = 0;
1762  for (Int_t iCath = 0; iCath < nCathodes; iCath++) {
1763  for (Int_t iCha = 0; iCha < nTriChambers; iCha++) {
1764  locStripScaler[iCha][iLoc][iCath] = 0;
1765  locStripOver[iCha][iLoc][iCath] = 0;
1766  }
1767  }
1768  }
1769  }
1770  } // end write scalers
1771 
1772  delete event;
1773 
1774  delete rawReader;
1775  delete rawStream;
1776 
1777  } // while (1)
1778 
1779  if (cfg.GetDAFlag() && (nEvents < cfg.GetMaxEvents())) {
1780  // update configuration files ifrequested event types were found
1781  if (doUpdate) {
1782  if (cfg.GetDAMode() > 0) UpdateGlobalMasks(cfg);
1783  if (cfg.GetDAMode() > 1) MakePatternStore(cfg);
1784  }
1785  }
1786 
1787  fclose(fsc);
1788 
1789  if (cfg.SaveScalers()) {
1790  if (writeScalers) {
1791  //printf("Store scalers to FES, DATE_RUN_NUMBER %s \n",gSystem->Getenv("DATE_RUN_NUMBER"));
1792  if(!ExportTRIGSCAL(cfg)) {
1793  printf("ExportTRIGSCAL failed\n");
1794  }
1795  } else {
1796  printf("Run too short ( < %d sec ), no scalers calculated! \n",cfg.GetScalerRecTime());
1797  }
1798  }
1799 
1800  // export Exported file to FES
1801  status = 0;
1802  status = daqDA_FES_storeFile(fileExp.Data(), "EXPORTED");
1803  if (status) {
1804  printf("Failed to export file: %s\n", fileExp.Data());
1805  return kFALSE;
1806  }
1807  if(cfg.GetPrintLevel()) printf("Export file: %s\n",fileExp.Data());
1808 
1809  timers.Stop();
1810 
1811  cout << "MTRda: DA enable: " << cfg.GetDAFlag() << endl;
1812  cout << "MTRda: Run number: " << runNumber << endl;
1813  cout << "MTRda: Nb of DATE events: " << nDateEvents << endl;
1814  cout << "MTRda: Nb of events used: " << nEvents << endl;
1815  cout << "MTRda: Nb of events used (noise): " << cfg.GetEventsN() << endl;
1816  cout << "MTRda: Nb of events used (deadc): " << cfg.GetEventsD() << endl;
1817  cout << "MTRda: Minumum nr of events for rate calculation: " << cfg.GetMinEvents() << endl;
1818  cout << "MTRda: Maximum nr of analyzed events: " << cfg.GetMaxEvents() << endl;
1819  cout << "MTRda: Skip events from start: " << cfg.GetSkipEvents() << endl;
1820  cout << "MTRda: Threshold for global noisy inputs: " << 100*cfg.GetThrN() << "%" << endl;
1821  cout << "MTRda: Threshold for global dead inputs: " << 100*cfg.GetThrD() << "%" << endl;
1822  cout << "MTRda: Threshold for local noisy inputs: " << 100*cfg.GetThrLocN() << "%" << endl;
1823  cout << "MTRda: Threshold for local dead inputs: " << 100*cfg.GetThrLocD() << "%" << endl;
1824  cout << "MTRda: Print level: " << cfg.GetPrintLevel() << endl;
1825  cout << "MTRda: Show decoder warnings: " << cfg.WithWarnings() << endl;
1826  cout << "MTRda: Use the fast decoder: " << cfg.UseFastDecoder() << endl;
1827  cout << "MTRda: DA mode (1=GLOBAL, 2=GLOBAL+LOCAL): " << cfg.GetDAMode() << endl;
1828  cout << "MTRda: Save scalers: " << cfg.SaveScalers() << endl;
1829  if (cfg.SaveScalers()) {
1830  cout << "MTRda: Time to record scalers: " << cfg.GetScalerRecTime() << " seconds" << endl;
1831  }
1832 
1833  printf("MTRda: Execution time : R:%7.2fs C:%7.2fs\n", timers.RealTime(), timers.CpuTime());
1834 
1835  return status;
1836 
1837 }
1838 
Bool_t fAlgoDeadcInput
select CALIBRATION events for dead channels analysis
Definition: MTRda.cxx:446
void GetXPattern(TArrayS &array) const
return X pattern array
AliMUONRegionalTriggerConfig * GetRegionalMasks() const
configuration object for the regional crate (own)
Definition: MTRda.cxx:240
virtual TIterator * CreateIterator() const =0
Return an iterator to loop over the whole store.
length in bits of a global input word
Definition: MTRda.cxx:461
Light weight interface class to the local trigger card data.
void SetGlobalFileLastVersion(Int_t ver)
set the last known version of the global crate configuration
Definition: MTRda.cxx:339
printf("Chi2/npoints = %f\n", TMath::Sqrt(chi2/npoints))
void PrintConfig()
Definition: MTRda.cxx:170
The class defines the configuration of global crate.
AliMUONTriggerIO * fTriggerIO
read/write masks and LUT to/from online files
Definition: MTRda.cxx:443
void ReadMaskFiles(AliDAConfig &cfg)
Definition: MTRda.cxx:962
static const TString fileExp("ExportedFiles.dat")
virtual Int_t GetDDL() const =0
Return number of DDL.
virtual AliMUONDDLTrigger * GetDDLTrigger() const =0
Return pointer to DDL payload object.
UChar_t GetGlobalOutput() const
Return global output.
const Char_t * GetLastCurrentFileName()
last known versions of the configuration files, usually MtgLastCurrent.dat
Definition: MTRda.cxx:188
Int_t GetRegHeaderEntries() const
get entries
Rawdata local card structure for trigger.
void SetLocalMaskFileName(const Char_t *name)
set the masks for the local cards, file name
Definition: MTRda.cxx:319
int main(Int_t argc, Char_t **argv)
Definition: MTRda.cxx:1340
Int_t GetSodFlag() const
flag value of the Start-of-data field in MtgCurrent.dat
Definition: MTRda.cxx:193
UInt_t GetGlobalMask(Int_t index) const
Get mask for the global input.
Int_t fLocalLutFileVersion
version of the transverse momentum Look-Up-Table in the detector DB
Definition: MTRda.cxx:425
void SetRegionalFileVersion(Int_t ver)
set the version of the regional crate configuration in the detector DB
Definition: MTRda.cxx:330
void SetGlobalFileName(const Char_t *name)
set the global crate configuration file name
Definition: MTRda.cxx:315
Bool_t GetGlobalFlag() const
Return global flag.
Int_t GetEventsD() const
number of accumulated CALIBRATION events for dead channels analysis
Definition: MTRda.cxx:255
const Char_t * GetRegionalFileName()
regional crate configuration file name
Definition: MTRda.cxx:205
void SetThrLocN(Float_t val)
set the threshold for noisy local strips (fraction of events)
Definition: MTRda.cxx:370
AliMUONLocalStruct * GetLocalEntry(Int_t i) const
get entry
AliDAConfig & operator=(const AliDAConfig &cfg)
assignment operator, not implemented
AliMUONVStore * GetPatternStoreN() const
store for local strips patterns (noisy strips)
Definition: MTRda.cxx:248
virtual Int_t Size() const =0
The number of channels handled by this object.
Bool_t ImportFiles(AliDAConfig &cfg)
Definition: MTRda.cxx:897
void SetSignatureFileVersion(Int_t ver)
set the version of the signature file in the detector DB
Definition: MTRda.cxx:336
Bool_t ExportFiles(AliDAConfig &cfg)
Definition: MTRda.cxx:723
void SetSaveScalers(Bool_t val)
set/unset the saving of cooked information from scalers
Definition: MTRda.cxx:386
void SetWithWarnings()
set/unset to show warnings from the raw data decoder
Definition: MTRda.cxx:382
Bool_t ExportTRIGSCAL(AliDAConfig &cfg)
Definition: MTRda.cxx:837
void SetLocalMaskFileVersion(Int_t ver)
set the version of the masks for the local cards in the detector DB
Definition: MTRda.cxx:332
void SetSkipEvents(Int_t val)
set the number of events to skip from start
Definition: MTRda.cxx:379
void SetRegionalFileLastVersion(Int_t ver)
set the last known version of the regional crate configuration
Definition: MTRda.cxx:341
UInt_t GetGlobalCrateEnable() const
Get global crate enbale.
Light weight interface class to the DARC and global header data.
UInt_t fLPtRTrig
local low Pt right trigger
void StoreGlobalInput(AliDAConfig &cfg, const UInt_t *const globalInput)
Definition: MTRda.cxx:985
const Char_t * GetSodName()
name of the Start-of-data field in MtgCurrent.dat
Definition: MTRda.cxx:191
Int_t GetRegionalFileVersion() const
version of the regional crate configuration in the detector DB
Definition: MTRda.cxx:218
Int_t GetDAMode() const
DA active mode (GLOBAL or GLOBAL+LOCAL)
Definition: MTRda.cxx:200
Int_t fGlobalFileLastVersion
last known version of the global crate configuration
Definition: MTRda.cxx:428
Float_t fThrD
threshold for dead global inputs (fraction of events)
Definition: MTRda.cxx:449
const UInt_t * GetGlobalScaler() const
Return global scalars or NULL if none exist.
Int_t GetDAFlag() const
flag value of the Detector Algorithm field in MtgCurrent.dat
Definition: MTRda.cxx:198
TROOT * gROOT
AliMUONGlobalCrateConfig * fGlobalMasks
configuration object for the global crate
Definition: MTRda.cxx:441
Int_t GetRegionalFileLastVersion() const
last known version of the regional crate configuration
Definition: MTRda.cxx:229
void SetGlobalFileVersion(Int_t ver)
set the version of the global crate configuration in the detector DB
Definition: MTRda.cxx:328
Higher performance decoder stream class for reading MUON raw trigger data.
AliMUONGlobalCrateConfig * GetGlobalMasks() const
configuration object for the global crate (own)
Definition: MTRda.cxx:242
Bool_t GetAlgoNoisyInput() const
select PHYSICS events for noisy channels analysis
Definition: MTRda.cxx:261
void SetMaxEvents(Int_t val)
set the maximum number of events to analyze
Definition: MTRda.cxx:377
TString fTrigScalFileName
trigger scalers, file name
Definition: MTRda.cxx:420
Int_t fSodFlag
flag value of the Start-of-data field in MtgCurrent.dat
Definition: MTRda.cxx:409
void ReadFileNames(AliDAConfig &cfg)
Definition: MTRda.cxx:708
virtual void SetValueAsInt(Int_t i, Int_t j, Int_t value)=0
Set one value, for channel i, dimension j. Consider value is an integer.
UInt_t GetFetMode(const AliDAConfig &cfg)
Definition: MTRda.cxx:974
virtual Double_t ValueAsDouble(Int_t i, Int_t j=0) const
Int_t fPrintLevel
print verbosity of the DA
Definition: MTRda.cxx:436
MUON regional header for trigger.
static Int_t NofLocalBoards()
Return number of trigger local boards.
const Char_t * GetCurrentFileName()
file with current versions of the configuration files, usually MtgCurrent.dat
Definition: MTRda.cxx:186
Int_t fRegionalFileVersion
version of the regional crate configuration in the detector DB
Definition: MTRda.cxx:423
Bool_t fSaveScalers
save cooked information from the trigger scalers
Definition: MTRda.cxx:470
Bool_t fUseFastDecoder
use the high-performance (HP) decoder
Definition: MTRda.cxx:456
TString fGlobalFileName
global crate configuration, file name
Definition: MTRda.cxx:415
AliMUONVStore * GetPatternStoreD() const
store for local strips patterns (dead strips)
Definition: MTRda.cxx:250
const Int_t fNLocalBoard
number of local boards
Definition: MTRda.cxx:458
UInt_t fLPtSTrig
local low Pt straight trigger
void UpdateGlobalMasks(AliDAConfig &cfg)
Definition: MTRda.cxx:1002
void MakePattern(AliDAConfig &cfg, Int_t localBoardId, const TArrayS &xPattern, const TArrayS &yPattern)
Definition: MTRda.cxx:1147
Int_t GetGlobalInputLength() const
length in bits of a global input word
Definition: MTRda.cxx:295
Int_t GetMaxEvents() const
maximum number of events to analyze
Definition: MTRda.cxx:277
Int_t fScalerRecTime
time between two records, in seconds
Definition: MTRda.cxx:471
UShort_t GetXY1(Int_t n) const
Return XY1.
Int_t fLocalMaskFileVersion
version of the masks for the local cards in the detector DB
Definition: MTRda.cxx:424
Int_t fSignatureFileVersion
version of the signature file in the detector DB
Definition: MTRda.cxx:426
AliMUONVStore * fLocalMasksDA
store for the DA-calculated masks for the local cards
Definition: MTRda.cxx:439
void SetLocalLutFileLastVersion(Int_t ver)
set the last known version of the transverse momentum Look-Up-Table
Definition: MTRda.cxx:345
UShort_t GetXY2(Int_t n) const
Return XY2.
Container of calibration values for a given number of channels.
Class for reading MUON raw digits.
void SetDAName(Char_t *name)
set the name of the Detector Algorithm field in MtgCurrent.dat
Definition: MTRda.cxx:308
void SetSignatureFileName(const Char_t *name)
set the signature file name
Definition: MTRda.cxx:323
Int_t GetSignatureFileVersion() const
version of the signature file in the detector DB
Definition: MTRda.cxx:224
number of global input words
Definition: MTRda.cxx:460
UInt_t GetScalerRecTime() const
time between two records, in seconds
Definition: MTRda.cxx:289
Bool_t ReadCurrentFile(AliDAConfig &cfg, TString currentFile, Bool_t lastCurrentFlag=kFALSE)
Definition: MTRda.cxx:597
Handles read/write of masks and LUT to/from online files.
const Char_t * GetLocalLutFileName()
transverse momentum Look-Up-Table, file name
Definition: MTRda.cxx:209
AliMUONDarcHeader * GetDarcHeader() const
get AliMUONDarcHeader
Base class for reading MUON raw trigger data.
UChar_t GetGlobalOutput() const
Return global output.
Implementation of AliMUONVCalibParam for tuples of ints.
void WriteLastCurrentFile(AliDAConfig &cfg, TString currentFile)
Definition: MTRda.cxx:576
const TString fCurrentFileName
usually MtgCurrent.dat
Definition: MTRda.cxx:405
virtual Bool_t NextDDL()=0
DDL iterator.
void SetAlgoDeadcInput(Bool_t val)
select CALIBRATION events for dead channels analysis
Definition: MTRda.cxx:363
Int_t GetLocalLutFileVersion() const
version of the transverse momentum Look-Up-Table in the detector DB
Definition: MTRda.cxx:222
UShort_t GetXY4(Int_t n) const
Return XY4.
const Char_t * GetDAConfigFileName()
name of the DA configuration file from detector DB
Definition: MTRda.cxx:184
Int_t GetGlobalFileLastVersion() const
last known version of the global crate configuration
Definition: MTRda.cxx:227
Int_t GetGlobalInputs() const
number of global input words
Definition: MTRda.cxx:293
void SetLocalLutFileName(const Char_t *name)
set the transverse momentum Look-Up-Table, file name
Definition: MTRda.cxx:321
Bool_t GetMasksOn() const
Indicates if global masks are active on global inputs.
virtual Int_t ID0() const
First id of this object.
Bool_t fWithWarnings
show warnings from the raw data decoder
Definition: MTRda.cxx:455
Float_t GetThrLocD() const
threshold for dead local strips (fraction of events)
Definition: MTRda.cxx:272
void MakePatternStore(AliDAConfig &cfg)
Definition: MTRda.cxx:1189
Implementation of AliMUONVCalibParam for tuples of double.
Int_t GetGlobalFileVersion() const
version of the global crate configuration in the detector DB
Definition: MTRda.cxx:216
Bool_t WriteLocalMasks(const char *localFile, const AliMUONVStore &localMasks) const
Int_t GetEventsN() const
number of accumulated PHYSICS events for noisy channels analysis
Definition: MTRda.cxx:253
const Char_t * GetSignatureFileName()
signature, file name
Definition: MTRda.cxx:211
void SetRegionalFileName(const Char_t *name)
set the regional crate configuration file name
Definition: MTRda.cxx:317
void SetThrLocD(Float_t val)
set the threshold for dead local strips (fraction of events)
Definition: MTRda.cxx:372
Int_t fEventsD
number of accumulated CALIBRATION events
Definition: MTRda.cxx:434
MUON Darc header for Trigger.
void AddAccGlobalInputD(Int_t ii, Int_t ib, Int_t val)
count the value of the bit "ib" of global input word "ii" (CALIBRATION events)
Definition: MTRda.cxx:355
void SetMinEvents(Int_t val)
set the minumum nr of events for rate calculation
Definition: MTRda.cxx:375
UInt_t GetFetRegister(Int_t index) const
Get register for FET.
Int_t GetLocalMaskFileLastVersion() const
last known version of the masks for the local cards
Definition: MTRda.cxx:231
Int_t GetLocalLutFileLastVersion() const
last known version of the transverse momentum Look-Up-Table
Definition: MTRda.cxx:233
static Int_t TotalNofLocalBoards()
Return total number of trigger local boards.
Int_t LocalBoardId(Int_t index) const
Int_t fDAFlag
flag value of the Detector Algorithm field in MtgCurrent.dat (enabled/disabled)
Definition: MTRda.cxx:412
const TString fLastCurrentFileName
usually MtgLastCurrent.dat
Definition: MTRda.cxx:406
void SetTrigScalFileName(const Char_t *name)
set the trigger scalers file name
Definition: MTRda.cxx:325
void SetUseFastDecoder()
set/unset the use of the high-performance (HP) decoder
Definition: MTRda.cxx:384
const Char_t * GetGlobalFileName()
global crate configuration file name
Definition: MTRda.cxx:203
UInt_t GetGlobalClock() const
Return global clock.
void IncDeadcEvent()
increment the number of selected CALIBRATION events
Definition: MTRda.cxx:350
AliMUONVStore * fLocalMasks
store for the masks for the local cards
Definition: MTRda.cxx:438
TString fLocalLutFileName
transverse momentum Look-Up-Table, file name
Definition: MTRda.cxx:418
Int_t GetAccGlobalInputN(Int_t ii, Int_t ib) const
get accumulated values for bit "ib" from global input word "ii", PHYSICS events
Definition: MTRda.cxx:298
const TString fDAConfigFileName
name of the DA configuration file from detector DB
Definition: MTRda.cxx:404
Implementation of AliMUONVStore.
TString fSignatureFileName
signature, file name
Definition: MTRda.cxx:419
Float_t GetThrLocN() const
threshold for noisy local strips (fraction of events)
Definition: MTRda.cxx:270
UInt_t GetGlobalInput(Int_t n) const
Return global input.
Int_t fEventsN
number of accumulated PHYSICS events
Definition: MTRda.cxx:433
virtual Int_t ValueAsInt(Int_t i, Int_t j=0) const =0
void GetXPattern(TArrayS &array) const
return X pattern array
void GetYPattern(TArrayS &array) const
return Y pattern array
class for DA run parameters and DA working space
Definition: MTRda.cxx:70
Float_t fThrLocD
threshold for dead local strips (fraction of events)
Definition: MTRda.cxx:451
Int_t fSkipEvents
number of events to skip from start
Definition: MTRda.cxx:453
void SetScalerRecTime(Int_t trec)
time between two records, in seconds
Definition: MTRda.cxx:388
void IncGlobalFileVersion()
increment version of the global crate configuration file
Definition: MTRda.cxx:391
AliMUONVStore * GetLocalMasksDA() const
store for the DA-calculated masks for the local cards (own)
Definition: MTRda.cxx:238
Int_t fRegionalFileLastVersion
last known version of the regional crate configuration
Definition: MTRda.cxx:429
Float_t GetThrN() const
threshold for noisy global inputs (fraction of events)
Definition: MTRda.cxx:266
TString fDAName
name of the Detector Algorithm field in MtgCurrent.dat
Definition: MTRda.cxx:411
Int_t fAccGlobalInputD[kGlobalInputs][kGlobalInputLength]
storage for global input (CALIBRATION events)
Definition: MTRda.cxx:468
virtual Bool_t Add(TObject *object)=0
Add an object to the store.
UShort_t GetXY3(Int_t n) const
Return XY3.
void SetAlgoNoisyInput(Bool_t val)
select PHYSICS events for noisy channels analysis
Definition: MTRda.cxx:361
void GetYPattern(TArrayS &array) const
return Y pattern array
Float_t fThrN
threshold for noisy global inputs (fraction of events)
Definition: MTRda.cxx:448
Int_t fAccGlobalInputN[kGlobalInputs][kGlobalInputLength]
storage for global input (PHYSICS events)
Definition: MTRda.cxx:467
Float_t GetThrD() const
threshold for dead global inputs (fraction of events)
Definition: MTRda.cxx:268
void IncLocalMaskFileVersion()
increment version of the local mask configuration file
Definition: MTRda.cxx:393
Bool_t ReadDAConfig(AliDAConfig &cfg)
Definition: MTRda.cxx:476
AliMUONVStore * GetLocalMasks() const
store for the masks for the local cards (own)
Definition: MTRda.cxx:236
AliMUONVStore * fPatternStoreN
store for local strips patterns
Definition: MTRda.cxx:464
Int_t GetSkipEvents() const
number of events to skip from start
Definition: MTRda.cxx:279
Int_t fMinEvents
minumum nr of events for rate calculation
Definition: MTRda.cxx:452
void IncNoiseEvent()
increment the number of selected PHYSICS events
Definition: MTRda.cxx:348
Int_t fDAMode
DA active mode, GLOBAL or GLOBAL+LOCAL.
Definition: MTRda.cxx:413
AliMUONRegHeader * GetRegHeaderEntry(Int_t i) const
get entry
void SetLocalLutFileVersion(Int_t ver)
set the version of the transverse momentum Look-Up-Table in the detector DB
Definition: MTRda.cxx:334
virtual ~AliDAConfig()
Definition: MTRda.cxx:159
TString fLocalMaskFileName
masks for the local cards, file name
Definition: MTRda.cxx:417
Int_t GetAccGlobalInputD(Int_t ii, Int_t ib) const
get accumulated values for bit "ib" from global input word "ii", CALIBRATION events ...
Definition: MTRda.cxx:300
const Char_t * GetDAName()
name of the Detector Algorithm field in MtgCurrent.dat
Definition: MTRda.cxx:196
void AddAccGlobalInputN(Int_t ii, Int_t ib, Int_t val)
count the value of the bit "ib" of global input word "ii" (PHYSICS events)
Definition: MTRda.cxx:353
Bool_t SaveScalers() const
save cooked information from scalers
Definition: MTRda.cxx:287
const AliMUONLocalScalarsStruct * GetScalars() const
void SetDAMode(Int_t mode)
set DA active mode, 1 = GLOBAL (default), 2 = GLOBAL and LOCAL
Definition: MTRda.cxx:312
void DecSkipEvents()
count skipped events
Definition: MTRda.cxx:395
virtual void DisableWarnings()=0
Disable Warnings.
AliMUONVStore * fPatternStoreD
store for local strips patterns
Definition: MTRda.cxx:465
void UpdateLocalMask(AliDAConfig &cfg, Int_t localBoardId, Int_t connector, Int_t strip)
Definition: MTRda.cxx:1130
UChar_t GetId() const
Return Id.
UInt_t GetGlobalInput(Int_t n) const
Return global input.
Bool_t GetAlgoDeadcInput() const
select CALIBRATION events for dead channels analysis
Definition: MTRda.cxx:263
Globally used constants definition.
AliDAConfig()
Definition: MTRda.cxx:74
TString fRegionalFileName
regional crate configuration, file name
Definition: MTRda.cxx:416
Int_t GetLocalEntries() const
get entries
void SetPrintLevel(Int_t level)
set the print verbosity level of the DA
Definition: MTRda.cxx:358
Int_t GetLocalMaskFileVersion() const
version of the masks for the local cards in the detector DB
Definition: MTRda.cxx:220
void SetThrD(Float_t val)
set the threshold for dead global inputs (fraction of events)
Definition: MTRda.cxx:368
Int_t GetMinEvents() const
minumum nr of events for rate calculation
Definition: MTRda.cxx:275
Base class for MUON data stores.
Definition: AliMUONVStore.h:22
Bool_t fAlgoNoisyInput
select PHYSICS events for noisy channels analysis
Definition: MTRda.cxx:445
TString fSodName
name of the Start-of-data field in MtgCurrent.dat
Definition: MTRda.cxx:408
AliMUONTriggerIO * GetTriggerIO() const
read/write configurations, masks and LUT to/from online files (own)
Definition: MTRda.cxx:245
void SetLocalMaskFileLastVersion(Int_t ver)
set the last known version of the masks for the local cards
Definition: MTRda.cxx:343
MUON DDL Trigger.
void SetSodFlag(Int_t flag)
set the flag value of the Start-of-data field in MtgCurrent.dat
Definition: MTRda.cxx:305
Bool_t WithWarnings() const
show warnings from the raw data decoder
Definition: MTRda.cxx:282
Bool_t ReadConfig(const char *localFile, const char *regionalFile, const char *globalFile, AliMUONVStore *localMasks, AliMUONRegionalTriggerConfig *regionalConfig, AliMUONGlobalCrateConfig *globalConfig)
void SetGlobalMask(Int_t index, UInt_t mask)
Set mask for the global input.
UInt_t fLPtLTrig
local low Pt left trigger
The class defines the properties of regional trigger crate.
void SetThrN(Float_t val)
set the threshold for noisy global inputs (fraction of events)
Definition: MTRda.cxx:366
Bool_t UseFastDecoder() const
use the high-performance (HP) decoder
Definition: MTRda.cxx:284
virtual TObject * FindObject(const char *name) const
Find an object by name.
Int_t fMaxEvents
maximum number of events to analyze
Definition: MTRda.cxx:454
Float_t fThrLocN
threshold for noisy local strips (fraction of events)
Definition: MTRda.cxx:450
Int_t fLocalMaskFileLastVersion
last known version of the masks for the local cards
Definition: MTRda.cxx:430
void SetSodName(Char_t *name)
set the name of the Start-of-data field in MtgCurrent.dat
Definition: MTRda.cxx:303
const Char_t * GetLocalMaskFileName()
masks for the local cards, file name
Definition: MTRda.cxx:207
AliMUONRegionalTriggerConfig * fRegionalMasks
configuration object for the regional crate
Definition: MTRda.cxx:440
void SetDAFlag(Int_t flag)
set the flag value of the Detector Algorithm field in MtgCurrent.dat
Definition: MTRda.cxx:310
virtual void SetValueAsDouble(Int_t i, Int_t j, Double_t value)
Bool_t WriteGlobalConfig(const char *globalFile, AliMUONGlobalCrateConfig *globalConfig) const
Int_t fGlobalFileVersion
version of the global crate configuration in the detector DB
Definition: MTRda.cxx:422
Int_t fLocalLutFileLastVersion
last known version of the transverse momentum Look-Up-Table
Definition: MTRda.cxx:431
static Int_t NofTriggerChambers()
const Char_t * GetTrigScalFileName()
signature, file name
Definition: MTRda.cxx:213
Int_t GetPrintLevel() const
print verbosity of the DA
Definition: MTRda.cxx:258