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