AliRoot Core  v5-06-30 (35d6c57)
 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",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() << 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() << 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() << 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() << 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() << 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 
846  ofstream out;
847  out.open(fileExp.Data(), std::ofstream::app);
848  if (!out.good()) {
849  printf("Failed to open file in append mode: %s\n",fileExp.Data());
850  return kFALSE;
851  }
852 
853  // global config
854  file = cfg.GetGlobalFileName();
855  status = 0;
856  status = daqDA_FES_storeFile(file.Data(), "GLOBAL");
857  if (status) {
858  printf("Failed to export file: %s\n",cfg.GetGlobalFileName());
859  return kFALSE;
860  }
861  if(cfg.GetPrintLevel()) printf("Export file: %s\n",cfg.GetGlobalFileName());
862  out << cfg.GetGlobalFileName() << endl;
863 
864  // regional config
865  file = cfg.GetRegionalFileName();
866  status = 0;
867  status = daqDA_FES_storeFile(file.Data(), "REGIONAL");
868  if (status) {
869  printf("Failed to export file: %s\n",cfg.GetRegionalFileName());
870  return kFALSE;
871  }
872  if(cfg.GetPrintLevel()) printf("Export file: %s\n",cfg.GetRegionalFileName());
873  out << cfg.GetRegionalFileName() << endl;
874 
875  // trigger scalers
876  file = cfg.GetTrigScalFileName();
877  status = 0;
878  status = daqDA_FES_storeFile(file.Data(), "TRIGSCAL");
879  if (status) {
880  printf("Failed to export file: %s\n",cfg.GetTrigScalFileName());
881  return status;
882  }
883  if(cfg.GetPrintLevel()) printf("Export file: %s\n",cfg.GetTrigScalFileName());
884  out << cfg.GetTrigScalFileName() << endl;
885 
886  out.close();
887 
888  return kTRUE;
889 
890 }
891 
892 //__________________
894 {
901 
902  Int_t status = 0;
903 
904 #ifdef OFFLINE
905  gSystem->Setenv("DAQDALIB_PATH", "$DATE_ROOT/db");
906 #endif
907 
908  status = 0;
909  status = daqDA_DB_getFile(cfg.GetDAConfigFileName(), cfg.GetDAConfigFileName());
910  if (status) {
911  printf("Failed to get DA config file from DB: %s\n",cfg.GetDAConfigFileName());
912  return kFALSE;
913  }
914 
915  ReadDAConfig(cfg);
916 
917  status = 0;
918  status = daqDA_DB_getFile(cfg.GetCurrentFileName(), cfg.GetCurrentFileName());
919  if (status) {
920  printf("Failed to get current config file from DB: %s\n",cfg.GetCurrentFileName());
921  return kFALSE;
922  }
923 
924  ReadFileNames(cfg);
925 
926  status = 0;
927  status = daqDA_DB_getFile(cfg.GetGlobalFileName(), cfg.GetGlobalFileName());
928  if (status) {
929  printf("Failed to get current config file from DB: %s\n", cfg.GetGlobalFileName());
930  return kFALSE;
931  }
932 
933  status = 0;
934  status = daqDA_DB_getFile(cfg.GetRegionalFileName(), cfg.GetRegionalFileName());
935  if (status) {
936  printf("Failed to get current config file from DB: %s\n",cfg.GetRegionalFileName());
937  return kFALSE;
938  }
939 
940  status = 0;
941  status = daqDA_DB_getFile(cfg.GetLocalMaskFileName(), cfg.GetLocalMaskFileName());
942  if (status) {
943  printf("Failed to get current config file from DB: %s\n",cfg.GetLocalMaskFileName());
944  return kFALSE;
945  }
946 
947  status = 0;
948  status = daqDA_DB_getFile(cfg.GetLocalLutFileName(), cfg.GetLocalLutFileName());
949  if (status) {
950  printf("Failed to get current config file from DB: %s\n",cfg.GetLocalLutFileName());
951  return kFALSE;
952  }
953 
954  return kTRUE;
955 }
956 
957 //_____________
959 {
961 
962  const Char_t* localFile = cfg.GetLocalMaskFileName();
963  const Char_t* regionalFile = cfg.GetRegionalFileName();
964  const Char_t* globalFile = cfg.GetGlobalFileName();
965 
966  cfg.GetTriggerIO()->ReadConfig(localFile, regionalFile, globalFile, cfg.GetLocalMasks(), cfg.GetRegionalMasks(), cfg.GetGlobalMasks());
967 }
968 
969 //______________________________________________________________
970 UInt_t GetFetMode(const AliDAConfig & cfg)
971 {
975 
976  return cfg.GetGlobalMasks()->GetFetRegister(3);
977 
978 }
979 
980 //______________________________________________________________
981 void StoreGlobalInput(AliDAConfig& cfg, const UInt_t * const globalInput)
982 {
984 
985  for (Int_t ii = 0; ii < cfg.GetGlobalInputs(); ii++) {
986  for (Int_t ib = 0; ib < cfg.GetGlobalInputLength(); ib++) {
987  // lsb -> msb
988  if (cfg.GetAlgoNoisyInput())
989  cfg.AddAccGlobalInputN(ii,ib,((globalInput[ii] >> ib) & 0x1));
990  if (cfg.GetAlgoDeadcInput())
991  cfg.AddAccGlobalInputD(ii,ib,((globalInput[ii] >> ib) & 0x1));
992  }
993  }
994 
995 }
996 
997 //______________________________________________________________
999 {
1001 
1002 #ifdef OFFLINE
1003  gSystem->Setenv("DAQDALIB_PATH", "$DATE_ROOT/db");
1004 #endif
1005 
1006  Float_t rateN = 0.0, rateD = 0.0;
1007  UInt_t gmask[4], omask;
1008  Bool_t noise, deadc, withEvN, withEvD, updated = kFALSE;
1009 
1010  for (Int_t ii = 0; ii < cfg.GetGlobalInputs(); ii++) {
1011  gmask[ii] = 0;
1012 
1013  for (Int_t ib = 0; ib < cfg.GetGlobalInputLength(); ib++) {
1014  // lsb -> msb
1015  noise = kFALSE;
1016  deadc = kFALSE;
1017  withEvN = kFALSE;
1018  withEvD = kFALSE;
1019  if (cfg.GetEventsN() > cfg.GetMinEvents()) {
1020  rateN = (Float_t)cfg.GetAccGlobalInputN(ii,ib)/(Float_t)cfg.GetEventsN();
1021  noise = (rateN > cfg.GetThrN());
1022  withEvN = kTRUE;
1023  }
1024  if (cfg.GetEventsD() > cfg.GetMinEvents()) {
1025  rateD = (Float_t)cfg.GetAccGlobalInputD(ii,ib)/(Float_t)cfg.GetEventsD();
1026  deadc = (rateD < cfg.GetThrD());
1027  withEvD = kTRUE;
1028  }
1029  if (!withEvN && !withEvD) {
1030  // - copy the bit from the old mask
1031  gmask[ii] |= ((cfg.GetGlobalMasks()->GetGlobalMask(ii) >> ib) & 0x1) << ib;
1032  if (cfg.GetPrintLevel())
1033  printf("Mask not changed (just copy the old values)\n");
1034  }
1035  if (!withEvN && withEvD) {
1036  if (!deadc) {
1037  // - create a new mask, set the bit to 1
1038  // not allowed!
1039  //gmask[ii] |= 0x1 << ib;
1040  // - copy the bit from the old mask
1041  gmask[ii] |= ((cfg.GetGlobalMasks()->GetGlobalMask(ii) >> ib) & 0x1) << ib;
1042  } else {
1043  // - create a new mask, set the bit to 0
1044  gmask[ii] |= 0x0 << ib;
1045  if (cfg.GetPrintLevel())
1046  printf("Found dead channel %1d:%02d (%4.2f) \n",ii,ib,rateD);
1047  }
1048  }
1049  if (withEvN && !withEvD) {
1050  if (!noise) {
1051  // - create a new mask, set the bit to 1
1052  // not allowed!
1053  //gmask[ii] |= 0x1 << ib;
1054  // - copy the bit from the old mask
1055  gmask[ii] |= ((cfg.GetGlobalMasks()->GetGlobalMask(ii) >> ib) & 0x1) << ib;
1056  } else {
1057  // - create a new mask, set the bit to 0
1058  gmask[ii] |= 0x0 << ib;
1059  if (cfg.GetPrintLevel())
1060  printf("Found noisy channel %1d:%02d (%4.2f) \n",ii,ib,rateN);
1061  }
1062  }
1063  if (withEvN && withEvD) {
1064  if (!noise && !deadc) {
1065  // - create a new mask, set the bit to 1
1066  // not allowed!
1067  //gmask[ii] |= 0x1 << ib;
1068  // - copy the bit from the old mask
1069  gmask[ii] |= ((cfg.GetGlobalMasks()->GetGlobalMask(ii) >> ib) & 0x1) << ib;
1070  } else {
1071  // - create a new mask, set the bit to 0
1072  gmask[ii] |= 0x0 << ib;
1073  if (cfg.GetPrintLevel()) {
1074  if (noise)
1075  printf("Found noisy channel %1d:%02d (%4.2f) \n",ii,ib,rateN);
1076  if (deadc)
1077  printf("Found dead channel %1d:%02d (%4.2f) \n",ii,ib,rateD);
1078  }
1079  }
1080  }
1081  }
1082  }
1083 
1084  // check if at least one mask value has been changed from previous version
1085  for (Int_t ii = 0; ii < cfg.GetGlobalInputs(); ii++) {
1086  printf("Global mask [%1d] %08x \n",ii,gmask[ii]);
1087  omask = cfg.GetGlobalMasks()->GetGlobalMask(ii);
1088  if (gmask[ii] != omask) {
1089  updated = kTRUE;
1090  cfg.GetGlobalMasks()->SetGlobalMask(ii,gmask[ii]);
1091  }
1092  }
1093 
1094  Int_t status = 0;
1095  if (updated) {
1096 
1097  // update version
1098  cfg.IncGlobalFileVersion();
1099 
1100  // don't change the file version ("-x.dat")
1101 
1103 
1104  // write last current file
1106 
1107  status = 0;
1108  status = daqDA_DB_storeFile(cfg.GetGlobalFileName(), cfg.GetGlobalFileName());
1109  if (status) {
1110  printf("Failed to export file to DB: %s\n",cfg.GetGlobalFileName());
1111  return;
1112  }
1113 
1114  status = 0;
1115  status = daqDA_DB_storeFile(cfg.GetCurrentFileName(), cfg.GetCurrentFileName());
1116  if (status) {
1117  printf("Failed to export file to DB: %s\n",cfg.GetCurrentFileName());
1118  return;
1119  }
1120 
1121  }
1122 
1123 }
1124 
1125 //______________________________________________________________
1126 void UpdateLocalMask(AliDAConfig& cfg, Int_t localBoardId, Int_t connector, Int_t strip)
1127 {
1128 
1130 
1131  AliMUONVCalibParam* localMask =
1132  static_cast<AliMUONVCalibParam*>(cfg.GetLocalMasksDA()->FindObject(localBoardId));
1133 
1134  UShort_t mask = static_cast<UShort_t>(localMask->ValueAsInt(connector,0));
1135 
1136  mask &= ~(0x1 << strip); // set strip mask to zero
1137 
1138  localMask->SetValueAsInt(connector, 0, mask);
1139 
1140 }
1141 
1142 //______________________________________________________________
1143 void MakePattern(AliDAConfig& cfg, Int_t localBoardId, const TArrayS& xPattern, const TArrayS& yPattern)
1144 {
1146 
1147  AliMUONVCalibParam* pat = 0x0;
1148 
1149  if (cfg.GetAlgoNoisyInput())
1150  pat = static_cast<AliMUONVCalibParam*>(cfg.GetPatternStoreN()->FindObject(localBoardId));
1151  if (cfg.GetAlgoDeadcInput())
1152  pat = static_cast<AliMUONVCalibParam*>(cfg.GetPatternStoreD()->FindObject(localBoardId));
1153 
1154  if (!pat) {
1155  pat = new AliMUONCalibParamND(2, 64, localBoardId, 0, 0.);
1156  if (cfg.GetAlgoNoisyInput())
1157  cfg.GetPatternStoreN()->Add(pat);
1158  if (cfg.GetAlgoDeadcInput())
1159  cfg.GetPatternStoreD()->Add(pat);
1160  }
1161 
1162  for (Int_t i = 0; i < 4; ++i) {
1163  for (Int_t j = 0; j < 16; ++j) {
1164 
1165  Int_t xMask = xPattern[i];
1166  Int_t yMask = yPattern[i];
1167 
1168  Int_t index = 16*i + j;
1169  Double_t patOcc = 0.;
1170 
1171  if ( (xMask >> j ) & 0x1 ) {
1172  patOcc = pat->ValueAsDouble(index, 0) + 1.;
1173  pat->SetValueAsDouble(index, 0, patOcc);
1174  }
1175  if ( (yMask >> j ) & 0x1 ) {
1176  patOcc = pat->ValueAsDouble(index, 1) + 1.;
1177  pat->SetValueAsDouble(index, 1, patOcc);
1178  }
1179  }
1180  }
1181 
1182 }
1183 
1184 //______________________________________________________________
1186 {
1188 
1189 #ifdef OFFLINE
1190  gSystem->Setenv("DAQDALIB_PATH", "$DATE_ROOT/db");
1191 #endif
1192 
1193  AliMUONVCalibParam* pat;
1194  Int_t localBoardId = 0;
1195  Int_t nEventsN = 0, nEventsD = 0;
1196  UShort_t strip = 0;
1197  Int_t connector = 0;
1198  Bool_t updated = kFALSE;
1199 
1200  if (cfg.GetEventsN() > cfg.GetMinEvents()) {
1201  nEventsN = cfg.GetEventsN();
1202  }
1203  if (cfg.GetEventsD() > cfg.GetMinEvents()) {
1204  nEventsD = cfg.GetEventsD();
1205  }
1206 
1207  // noisy strips
1208  if (nEventsN > 0) {
1209 
1210  TIter next(cfg.GetPatternStoreN()->CreateIterator());
1211 
1212  while ( ( pat = dynamic_cast<AliMUONVCalibParam*>(next() ) ) ) {
1213 
1214  localBoardId = pat->ID0();
1215 
1216  for (Int_t index = 0; index < pat->Size(); index++) {
1217 
1218  Double_t patXOcc = pat->ValueAsDouble(index, 0)/(Double_t)nEventsN;
1219  Double_t patYOcc = pat->ValueAsDouble(index, 1)/(Double_t)nEventsN;
1220 
1221  pat->SetValueAsDouble(index, 0, patXOcc);
1222  pat->SetValueAsDouble(index, 1, patYOcc);
1223 
1224  // check for x strip
1225  if (patXOcc > cfg.GetThrLocN()) {
1226  strip = index % 16;
1227  connector = index/16;
1228  UpdateLocalMask(cfg, localBoardId, connector, strip);
1229  }
1230  // check for y strip
1231  if (patYOcc > cfg.GetThrLocN()) {
1232  strip = index % 16;
1233  connector = index/16 + 4;
1234  UpdateLocalMask(cfg, localBoardId, connector, strip);
1235  }
1236 
1237  }
1238  }
1239 
1240  }
1241 
1242  // dead strips
1243  if (nEventsD > 0) {
1244 
1245  TIter next(cfg.GetPatternStoreD()->CreateIterator());
1246 
1247  while ( ( pat = dynamic_cast<AliMUONVCalibParam*>(next() ) ) ) {
1248 
1249  localBoardId = pat->ID0();
1250 
1251  for (Int_t index = 0; index < pat->Size(); index++) {
1252 
1253  Double_t patXOcc = pat->ValueAsDouble(index, 0)/(Double_t)nEventsD;
1254  Double_t patYOcc = pat->ValueAsDouble(index, 1)/(Double_t)nEventsD;
1255 
1256  pat->SetValueAsDouble(index, 0, patXOcc);
1257  pat->SetValueAsDouble(index, 1, patYOcc);
1258 
1259  // check for x strip
1260  if (patXOcc < cfg.GetThrLocD()) {
1261  strip = index % 16;
1262  connector = index/16;
1263  UpdateLocalMask(cfg, localBoardId, connector, strip);
1264  }
1265  // check for y strip
1266  if (patYOcc < cfg.GetThrLocD()) {
1267  strip = index % 16;
1268  connector = index/16 + 4;
1269  UpdateLocalMask(cfg, localBoardId, connector, strip);
1270  }
1271 
1272  }
1273  }
1274 
1275  }
1276 
1277  // make and AND with the previous version of the mask and
1278  // check if the mask has changed
1279  UShort_t maskDA, mask;
1280  Int_t nMaskBits = AliMpConstants::TotalNofLocalBoards()*8*16;
1281  Int_t nMaskBitsChanged = 0;
1282  for (localBoardId = 1; localBoardId <= AliMpConstants::TotalNofLocalBoards(); localBoardId++) {
1283  AliMUONVCalibParam* localMaskDA = static_cast<AliMUONVCalibParam*>(cfg.GetLocalMasksDA()->FindObject(localBoardId));
1284  AliMUONVCalibParam* localMask = static_cast<AliMUONVCalibParam*>(cfg.GetLocalMasks()->FindObject(localBoardId));
1285  for (connector = 0; connector < 8; connector++) {
1286  maskDA = static_cast<UShort_t>(localMaskDA->ValueAsInt(connector,0));
1287  mask = static_cast<UShort_t>(localMask->ValueAsInt(connector,0));
1288  maskDA &= mask;
1289  localMaskDA->SetValueAsInt(connector, 0, maskDA);
1290  if (maskDA != mask) {
1291  updated = kTRUE;
1292  // calculated percentage of mask bits changed
1293  for (Int_t iBit = 0; iBit < 16; iBit++) {
1294  if (((maskDA >> iBit) & 0x1) != ((mask >> iBit) &0x1)) {
1295  nMaskBitsChanged++;
1296  }
1297  }
1298  }
1299  }
1300  }
1301 
1302  printf("LOCAL mask bits changed = %5d (%7.3f %%) \n",nMaskBitsChanged,100*(Float_t)nMaskBitsChanged/(Float_t)nMaskBits);
1303 
1304  Int_t status = 0;
1305  if (updated) {
1306 
1307  // update version
1309 
1310  // don't change the file version ("-x.dat")
1311 
1313 
1314  // write last current file
1316 
1317  status = 0;
1318  status = daqDA_DB_storeFile(cfg.GetLocalMaskFileName(), cfg.GetLocalMaskFileName());
1319  if (status) {
1320  printf("Failed to export file to DB: %s\n",cfg.GetLocalMaskFileName());
1321  return;
1322  }
1323 
1324  status = 0;
1325  status = daqDA_DB_storeFile(cfg.GetCurrentFileName(), cfg.GetCurrentFileName());
1326  if (status) {
1327  printf("Failed to export file to DB: %s\n",cfg.GetCurrentFileName());
1328  return;
1329  }
1330 
1331  }
1332 
1333 }
1334 
1335 //*************************************************************//
1336 int main(Int_t argc, Char_t **argv)
1337 {
1339 
1340  // needed for streamer application
1341  gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo", "*", "TStreamerInfo", "RIO", "TStreamerInfo()");
1342 
1343  /* check that we got some arguments = list of files */
1344  if (argc<2) {
1345  printf("Wrong number of arguments\n");
1346  return -1;
1347  }
1348 
1349  AliDAConfig cfg;
1350 
1351  Char_t inputFile[256] = "";
1352  inputFile[0] = 0;
1353  if (argc > 1)
1354  if (argv[1] != NULL)
1355  strncpy(inputFile, argv[1], 256);
1356  else {
1357  printf("MUONTRGda : No input File !\n");
1358  return -1;
1359  }
1360 
1361  // decoding the events
1362 
1363  Int_t status = 0;
1364  Int_t nDateEvents = 0;
1365 
1366  // containers
1367  // old decoder
1368  AliMUONDDLTrigger* ddlTrigger = 0x0;
1369  AliMUONDarcHeader* darcHeader = 0x0;
1370  AliMUONRegHeader* regHeader = 0x0;
1371  AliMUONLocalStruct* localStruct = 0x0;
1372  // new (fast) decoder
1373  const AliMUONRawStreamTriggerHP::AliHeader* darcHeaderHP = 0x0;
1374  const AliMUONRawStreamTriggerHP::AliLocalStruct* localStructHP = 0x0;
1375 
1376  TArrayS xPattern(4);
1377  TArrayS yPattern(4);
1378  Int_t localBoardId = 0;
1379 
1380  TStopwatch timers;
1381 
1382  timers.Start(kTRUE);
1383 
1384  // comment out, since we do not retrieve files from database
1385  if (!ImportFiles(cfg)) {
1386  printf("Import from DB failed\n");
1387  printf("For local test set DAQDA_TEST_DIR to the local directory where the Mtg files are located \n");
1388  return -1;
1389  }
1390 
1391  ReadMaskFiles(cfg);
1392 
1393 #ifdef OFFLINE
1394  // the run number extracted from the file name
1395  TString tmp(inputFile);
1396  Int_t pos1 = tmp.First('d');
1397  Int_t pos2 = tmp.Last('.');
1398  Int_t len = pos2 - (pos1+3);
1399  tmp = tmp(pos1+3,len);
1400  gSystem->Setenv("DATE_RUN_NUMBER",tmp.Data());
1401  gSystem->Exec("echo \"DATE_RUN_NUMBER = \" $DATE_RUN_NUMBER");
1402 #endif
1403 
1404  if(!ExportFiles(cfg)) {
1405  printf("ExportFiles failed\n");
1406  return -1;
1407  }
1408 
1409  // FET is triggered by CTP
1410  Bool_t modeFET3 = kTRUE;
1411  if (GetFetMode(cfg) != 3) {
1412  printf("FET is not in mode 3. Only PHYSICS events will be analysed (noisy channels)\n");
1413  modeFET3 = kFALSE;
1414  }
1415 
1416  // All 5 global cards are controlled by the Mts proxy
1417  // sans carte JTAG 0x1F ---> 0x0F (!)
1418  if (cfg.GetGlobalMasks()->GetGlobalCrateEnable() != 0x1F) {
1419  printf("The MTS proxy does not control all global cards\n");
1420  return -1;
1421  }
1422 
1423  // The global cards are ON (active on the global inputs)
1424  if (!cfg.GetGlobalMasks()->GetMasksOn()) {
1425  printf("Global masks are not ON\n");
1426  return -1;
1427  }
1428 
1429  // make sure to catch the "rare" calib events (1 every 50s in physics)
1430  const Char_t* tableSOD[] = {"ALL", "yes", "CAL", "all", NULL, NULL};
1431  monitorDeclareTable(const_cast<char**>(tableSOD));
1432 
1433  status = 0;
1434  status = monitorSetDataSource(inputFile);
1435  if (status) {
1436  cerr << "ERROR : monitorSetDataSource status (hex) = " << hex << status
1437  << " " << monitorDecodeError(status) << endl;
1438  return -1;
1439  }
1440  status = 0;
1441  status = monitorDeclareMp("MUON Trigger monitoring");
1442  if (status) {
1443  cerr << "ERROR : monitorDeclareMp status (hex) = " << hex << status
1444  << " " << monitorDecodeError(status) << endl;
1445  return -1;
1446  }
1447 
1448  /* define wait event timeout - 1s max */
1449  monitorSetNowait();
1450  monitorSetNoWaitNetworkTimeout(1000);
1451 
1452  cout << "MUONTRGda : Reading data from file " << inputFile <<endl;
1453 
1454  UInt_t nCalibEvents;
1455  UInt_t elapsT;
1456  UInt_t deltaT;
1457  UInt_t glSc[6];
1458  Bool_t overFlow, firstCalibEvent = kTRUE;
1459  const Int_t nTriChambers = AliMpConstants::NofTriggerChambers();
1460  const Int_t nLocBoards = AliMpConstants::NofLocalBoards();
1461  const Int_t nCathodes = 2;
1462  UInt_t locLptScaler[nLocBoards];
1463  ULong64_t locStripScaler[nTriChambers][nLocBoards][nCathodes];
1464  UInt_t locStripOver[nTriChambers][nLocBoards][nCathodes];
1465 
1466  const Int_t bufflen =
1467  8*sizeof(UInt_t)+
1468  nLocBoards*sizeof(UInt_t)+
1469  nLocBoards*nCathodes*nTriChambers*(sizeof(UInt_t)+sizeof(ULong64_t));
1470  UChar_t buffer[bufflen];
1471  //printf("Buffer length = %d bytes \n",bufflen);
1472 
1473  // reset scalers
1474  deltaT = 0.;
1475  nCalibEvents = 0;
1476  for (Int_t bit = 0; bit < 6; bit++) {
1477  glSc[bit] = 0;
1478  }
1479  for (Int_t iLoc = 0; iLoc < nLocBoards; iLoc++) {
1480  locLptScaler[iLoc] = 0;
1481  for (Int_t iCath = 0; iCath < nCathodes; iCath++) {
1482  for (Int_t iCha = 0; iCha < nTriChambers; iCha++) {
1483  locStripScaler[iCha][iLoc][iCath] = 0;
1484  locStripOver[iCha][iLoc][iCath] = 0;
1485  }
1486  }
1487  }
1488 
1489  FILE* fsc = fopen(cfg.GetTrigScalFileName(),"wb");
1490  Bool_t writeScalers = kFALSE;
1491 
1492  UInt_t *globalInput = new UInt_t[4];
1493  Bool_t doUpdate = kFALSE;
1494  Int_t runNumber = 0;
1495  Int_t nEvents = 0;
1496 
1497  // event loop
1498  while(1)
1499  {
1500 
1501  void *event;
1502 
1503  if (cfg.GetPrintLevel()) {
1504  if (nEvents && nEvents % 1000 == 0)
1505  cout<<"Cumulated events " << nEvents << endl;
1506  }
1507  // check shutdown condition
1508  if (daqDA_checkShutdown())
1509  break;
1510 
1511  // Skip Events if needed
1512  while (cfg.GetSkipEvents()) {
1513  status = 0;
1514  status = monitorGetEventDynamic(&event);
1515  cfg.DecSkipEvents();
1516  }
1517 
1518  // starts reading
1519  status = 0;
1520  status = monitorGetEventDynamic(&event);
1521  if (status < 0) {
1522  cout << "MUONTRGda : EOF found" << endl;
1523  break;
1524  }
1525 
1526  nDateEvents++;
1527 
1528  // decoding rawdata headers
1529  AliRawReader *rawReader = new AliRawReaderDate(event);
1530 
1531  Int_t eventType = rawReader->GetType();
1532  runNumber = rawReader->GetRunNumber();
1533 
1534  if (cfg.GetDAFlag() && (nEvents < cfg.GetMaxEvents())) {
1535  // L1Swc1
1536  // CALIBRATION_EVENT
1537  // SYSTEM_SOFTWARE_TRIGGER_EVENT
1538  // DETECTOR_SOFTWARE_TRIGGER_EVENT
1539  cfg.SetAlgoNoisyInput(kFALSE);
1540  cfg.SetAlgoDeadcInput(kFALSE);
1541  if (eventType == PHYSICS_EVENT) {
1542  cfg.SetAlgoNoisyInput(kTRUE);
1543  doUpdate = kTRUE;
1544  cfg.IncNoiseEvent();
1545  } else if (modeFET3 && eventType == CALIBRATION_EVENT) {
1546  cfg.SetAlgoDeadcInput(kTRUE);
1547  doUpdate = kTRUE;
1548  cfg.IncDeadcEvent();
1549  } else {
1550  continue;
1551  }
1552  }
1553  /*
1554  if (eventType == PHYSICS_EVENT) {
1555  printf("DBG: PHYSICS_EVENT\n");
1556  } else if (modeFET3 && eventType == CALIBRATION_EVENT) {
1557  printf("DBG: CALIBRATION_EVENT\n");
1558  } else {
1559  printf("DBG: OTHER (%d)\n",eventType);
1560  }
1561  */
1562  nEvents++;
1563  if (cfg.GetPrintLevel() == 2) printf("\nEvent # %d\n",nEvents);
1564 
1565  // decoding MUON payload
1566  AliMUONVRawStreamTrigger *rawStream = 0x0;
1567  if (cfg.UseFastDecoder()) {
1568  rawStream = new AliMUONRawStreamTriggerHP(rawReader);
1569  } else {
1570  rawStream = new AliMUONRawStreamTrigger(rawReader);
1571  }
1572 
1573  // ... without warnings from the decoder !!!
1574  if (!cfg.WithWarnings())
1575  rawStream->DisableWarnings();
1576 
1577  // if there is global clock overflow
1578  overFlow = kFALSE;
1579  // loops over DDL
1580  while((status = rawStream->NextDDL())) {
1581 
1582  if (cfg.GetPrintLevel() == 2) printf("iDDL %d\n", rawStream->GetDDL());
1583 
1584  if (cfg.UseFastDecoder()) {
1585  darcHeaderHP = static_cast<AliMUONRawStreamTriggerHP*>(rawStream)->GetHeaders();
1586  if (cfg.GetPrintLevel() == 2) printf("Global output (fast decoder) %x\n", (Int_t)darcHeaderHP->GetGlobalOutput());
1587  for (Int_t ig = 0; ig < cfg.GetGlobalInputs(); ig++) {
1588  globalInput[ig] = darcHeaderHP->GetGlobalInput(ig);
1589  }
1590  // global scalers
1591  if (cfg.SaveScalers() && (eventType == CALIBRATION_EVENT)) {
1592  if (darcHeaderHP->GetGlobalFlag()) {
1593  if (firstCalibEvent) {
1594  //printf("Skip first calib event: %x \n",darcHeaderHP->GetGlobalClock());
1595  overFlow = kTRUE;
1596  firstCalibEvent = kFALSE;
1597  } else {
1598  elapsT = darcHeaderHP->GetGlobalClock()/40e6; // [s]
1599  if (elapsT > 50) {
1600  //printf("Possible overflow: %x \n",darcHeaderHP->GetGlobalClock());
1601  overFlow = kTRUE;
1602  } else {
1603  deltaT += elapsT;
1604  nCalibEvents++;
1605  const UInt_t* globScaler = darcHeaderHP->GetGlobalScaler();
1606  for (Int_t bit = 0; bit < 6; bit++) {
1607  glSc[bit] += (double)(*(globScaler+bit));
1608  }
1609  } // end check overflow
1610  } // end first calib event
1611  } // end global flag
1612  } // end scalers calib event
1613  // loop over regional structure
1614  Int_t nReg = (Int_t)static_cast<AliMUONRawStreamTriggerHP*>(rawStream)->GetRegionalHeaderCount();
1615  for(Int_t iReg = 0; iReg < nReg; iReg++) {
1616  // loop over local structures
1617  Int_t nLoc = (Int_t)static_cast<AliMUONRawStreamTriggerHP*>(rawStream)->GetLocalStructCount(iReg);
1618  for(Int_t iLoc = 0; iLoc < nLoc; iLoc++) {
1619  localStructHP = static_cast<AliMUONRawStreamTriggerHP*>(rawStream)->GetLocalStruct(iReg, iLoc);
1620  localBoardId = cfg.GetTriggerIO()->LocalBoardId(rawStream->GetDDL(),iReg,localStructHP->GetId());
1621  if (localBoardId > 0) {
1622  localStructHP->GetXPattern(xPattern);
1623  localStructHP->GetYPattern(yPattern);
1624  if (cfg.GetDAFlag() && (nEvents < cfg.GetMaxEvents())) {
1625  MakePattern(cfg,localBoardId,xPattern,yPattern);
1626  }
1627  // local scalers
1628  if (cfg.SaveScalers() && (eventType == CALIBRATION_EVENT)) {
1629  if (!overFlow) {
1630  // skip dead and copy cards
1631  if(localBoardId <= nLocBoards) {
1632  locLptScaler[localBoardId-1] +=
1633  localStructHP->GetScalars()->fLPtRTrig +
1634  localStructHP->GetScalars()->fLPtLTrig +
1635  localStructHP->GetScalars()->fLPtSTrig;
1636  Int_t cathode = localStructHP->GetComptXY();
1637  for (Int_t ibitxy = 0; ibitxy < 16; ++ibitxy) {
1638  UInt_t scalerVal[4] = {
1639  localStructHP->GetXY1(ibitxy),
1640  localStructHP->GetXY2(ibitxy),
1641  localStructHP->GetXY3(ibitxy),
1642  localStructHP->GetXY4(ibitxy)
1643  };
1644 
1645  for(Int_t ich = 0; ich < nTriChambers; ich++) {
1646  // sum over all strips
1647  if (scalerVal[ich] < 0xffff/2) {
1648  locStripScaler[ich][localBoardId-1][cathode] += 2*scalerVal[ich];
1649  } else {
1650  locStripOver[ich][localBoardId-1][cathode]++;
1651  }
1652  } // end chamber loop
1653 
1654  } // end strip loop
1655  } // end skip copy cards
1656  } // env check overflow
1657  } // end scalers calib event
1658  } // end valid local
1659  } // end loc loop
1660  } // end reg loop
1661  } else {
1662  ddlTrigger = rawStream->GetDDLTrigger();
1663  darcHeader = ddlTrigger->GetDarcHeader();
1664  if (cfg.GetPrintLevel() == 2) printf("Global output %x\n", (Int_t)darcHeader->GetGlobalOutput());
1665  globalInput = darcHeader->GetGlobalInput();
1666  // loop over regional structure
1667  Int_t nReg = darcHeader->GetRegHeaderEntries();
1668  for(Int_t iReg = 0; iReg < nReg; iReg++) {
1669  regHeader = darcHeader->GetRegHeaderEntry(iReg);
1670  // loop over local structures
1671  Int_t nLoc = regHeader->GetLocalEntries();
1672  for(Int_t iLoc = 0; iLoc < nLoc; iLoc++) {
1673  localStruct = regHeader->GetLocalEntry(iLoc);
1674  localBoardId = cfg.GetTriggerIO()->LocalBoardId(rawStream->GetDDL(),iReg,localStruct->GetId());
1675  if (localBoardId > 0) {
1676  localStruct->GetXPattern(xPattern);
1677  localStruct->GetYPattern(yPattern);
1678  if (cfg.GetDAFlag() && (nEvents < cfg.GetMaxEvents())) {
1679  MakePattern(cfg,localBoardId,xPattern,yPattern);
1680  }
1681  }
1682  }
1683  }
1684  }
1685  if (cfg.GetDAFlag() && (nEvents < cfg.GetMaxEvents())) {
1686  if (rawStream->GetDDL() == 0) {
1687  StoreGlobalInput(cfg,globalInput);
1688  }
1689  }
1690 
1691  } // NextDDL
1692 
1693  if (cfg.SaveScalers()) {
1694  if (!overFlow && (deltaT > cfg.GetScalerRecTime())) {
1695  //printf("Write scalers after %d events\n",nEvents);
1696  writeScalers = kTRUE;
1697  Int_t ibw = 0;
1698  // global
1699  buffer[ibw++] = (nCalibEvents >> 24) & 0xff;
1700  buffer[ibw++] = (nCalibEvents >> 16) & 0xff;
1701  buffer[ibw++] = (nCalibEvents >> 8) & 0xff;
1702  buffer[ibw++] = (nCalibEvents >> 0) & 0xff;
1703  buffer[ibw++] = (deltaT >> 24) & 0xff;
1704  buffer[ibw++] = (deltaT >> 16) & 0xff;
1705  buffer[ibw++] = (deltaT >> 8) & 0xff;
1706  buffer[ibw++] = (deltaT >> 0) & 0xff;
1707  //printf("nev %u time %u \n",nCalibEvents,deltaT);
1708  for (Int_t bit = 0; bit < 6; bit++) {
1709  buffer[ibw++] = (glSc[bit] >> 24) & 0xff;
1710  buffer[ibw++] = (glSc[bit] >> 16) & 0xff;
1711  buffer[ibw++] = (glSc[bit] >> 8) & 0xff;
1712  buffer[ibw++] = (glSc[bit] >> 0) & 0xff;
1713  //printf("glSc %u \n",glSc[bit]);
1714  }
1715  // local
1716  for (Int_t iLoc = 0; iLoc < nLocBoards; iLoc++) {
1717  buffer[ibw++] = (locLptScaler[iLoc] >> 24) & 0xff;
1718  buffer[ibw++] = (locLptScaler[iLoc] >> 16) & 0xff;
1719  buffer[ibw++] = (locLptScaler[iLoc] >> 8) & 0xff;
1720  buffer[ibw++] = (locLptScaler[iLoc] >> 0) & 0xff;
1721  for (Int_t iCath = 0; iCath < nCathodes; iCath++) {
1722  for (Int_t iCha = 0; iCha < nTriChambers; iCha++) {
1723  //printf("Ch%1dCath%1dLoc%03d %u %u \n",iCha,iCath,iLoc+1,locStripScaler[iCha][iLoc][iCath],locStripOver[iCha][iLoc][iCath]);
1724  // strip scalers
1725  buffer[ibw++] = (locStripScaler[iCha][iLoc][iCath] >> 56) & 0xff;
1726  buffer[ibw++] = (locStripScaler[iCha][iLoc][iCath] >> 48) & 0xff;
1727  buffer[ibw++] = (locStripScaler[iCha][iLoc][iCath] >> 40) & 0xff;
1728  buffer[ibw++] = (locStripScaler[iCha][iLoc][iCath] >> 32) & 0xff;
1729  buffer[ibw++] = (locStripScaler[iCha][iLoc][iCath] >> 24) & 0xff;
1730  buffer[ibw++] = (locStripScaler[iCha][iLoc][iCath] >> 16) & 0xff;
1731  buffer[ibw++] = (locStripScaler[iCha][iLoc][iCath] >> 8) & 0xff;
1732  buffer[ibw++] = (locStripScaler[iCha][iLoc][iCath] >> 0) & 0xff;
1733  // number of strips in overflow
1734  buffer[ibw++] = (locStripOver[iCha][iLoc][iCath] >> 24) & 0xff;
1735  buffer[ibw++] = (locStripOver[iCha][iLoc][iCath] >> 16) & 0xff;
1736  buffer[ibw++] = (locStripOver[iCha][iLoc][iCath] >> 8) & 0xff;
1737  buffer[ibw++] = (locStripOver[iCha][iLoc][iCath] >> 0) & 0xff;
1738  }
1739  }
1740  }
1741  //printf("Write to buffer %d bytes.\n",ibw);
1742  fwrite(&buffer,ibw,1,fsc);
1743  // reset
1744  deltaT = 0.;
1745  nCalibEvents = 0;
1746  for (Int_t bit = 0; bit < 6; bit++) {
1747  glSc[bit] = 0;
1748  }
1749  for (Int_t iLoc = 0; iLoc < nLocBoards; iLoc++) {
1750  locLptScaler[iLoc] = 0;
1751  for (Int_t iCath = 0; iCath < nCathodes; iCath++) {
1752  for (Int_t iCha = 0; iCha < nTriChambers; iCha++) {
1753  locStripScaler[iCha][iLoc][iCath] = 0;
1754  locStripOver[iCha][iLoc][iCath] = 0;
1755  }
1756  }
1757  }
1758  }
1759  } // end write scalers
1760 
1761  delete event;
1762 
1763  delete rawReader;
1764  delete rawStream;
1765 
1766  } // while (1)
1767 
1768  if (cfg.GetDAFlag() && (nEvents < cfg.GetMaxEvents())) {
1769  // update configuration files ifrequested event types were found
1770  if (doUpdate) {
1771  if (cfg.GetDAMode() > 0) UpdateGlobalMasks(cfg);
1772  if (cfg.GetDAMode() > 1) MakePatternStore(cfg);
1773  }
1774  }
1775 
1776  fclose(fsc);
1777 
1778  if (cfg.SaveScalers()) {
1779  if (writeScalers) {
1780  //printf("Store scalers to FES, DATE_RUN_NUMBER %s \n",gSystem->Getenv("DATE_RUN_NUMBER"));
1781  if(!ExportTRIGSCAL(cfg)) {
1782  printf("ExportTRIGSCAL failed\n");
1783  }
1784  } else {
1785  printf("Run too short ( < %d sec ), no scalers calculated! \n",cfg.GetScalerRecTime());
1786  }
1787  }
1788 
1789  // export Exported file to FES
1790  status = 0;
1791  status = daqDA_FES_storeFile(fileExp.Data(), "EXPORTED");
1792  if (status) {
1793  printf("Failed to export file: %s\n", fileExp.Data());
1794  return kFALSE;
1795  }
1796  if(cfg.GetPrintLevel()) printf("Export file: %s\n",fileExp.Data());
1797 
1798  timers.Stop();
1799 
1800  cout << "MUONTRGda: DA enable: " << cfg.GetDAFlag() << endl;
1801  cout << "MUONTRGda: Run number: " << runNumber << endl;
1802  cout << "MUONTRGda: Nb of DATE events: " << nDateEvents << endl;
1803  cout << "MUONTRGda: Nb of events used: " << nEvents << endl;
1804  cout << "MUONTRGda: Nb of events used (noise): " << cfg.GetEventsN() << endl;
1805  cout << "MUONTRGda: Nb of events used (deadc): " << cfg.GetEventsD() << endl;
1806  cout << "MUONTRGda: Minumum nr of events for rate calculation: " << cfg.GetMinEvents() << endl;
1807  cout << "MUONTRGda: Maximum nr of analyzed events: " << cfg.GetMaxEvents() << endl;
1808  cout << "MUONTRGda: Skip events from start: " << cfg.GetSkipEvents() << endl;
1809  cout << "MUONTRGda: Threshold for global noisy inputs: " << 100*cfg.GetThrN() << "%" << endl;
1810  cout << "MUONTRGda: Threshold for global dead inputs: " << 100*cfg.GetThrD() << "%" << endl;
1811  cout << "MUONTRGda: Threshold for local noisy inputs: " << 100*cfg.GetThrLocN() << "%" << endl;
1812  cout << "MUONTRGda: Threshold for local dead inputs: " << 100*cfg.GetThrLocD() << "%" << endl;
1813  cout << "MUONTRGda: Print level: " << cfg.GetPrintLevel() << endl;
1814  cout << "MUONTRGda: Show decoder warnings: " << cfg.WithWarnings() << endl;
1815  cout << "MUONTRGda: Use the fast decoder: " << cfg.UseFastDecoder() << endl;
1816  cout << "MUONTRGda: DA mode (1=GLOBAL, 2=GLOBAL+LOCAL): " << cfg.GetDAMode() << endl;
1817  cout << "MUONTRGda: Save scalers: " << cfg.SaveScalers() << endl;
1818  if (cfg.SaveScalers()) {
1819  cout << "MUONTRGda: Time to record scalers: " << cfg.GetScalerRecTime() << " seconds" << endl;
1820  }
1821 
1822  printf("MUONTRGda: Execution time : R:%7.2fs C:%7.2fs\n", timers.RealTime(), timers.CpuTime());
1823 
1824  return status;
1825 
1826 }
1827 
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:958
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:1336
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:893
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
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: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:981
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
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:970
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
void UpdateGlobalMasks(AliDAConfig &cfg)
Definition: MTRda.cxx:998
void MakePattern(AliDAConfig &cfg, Int_t localBoardId, const TArrayS &xPattern, const TArrayS &yPattern)
Definition: MTRda.cxx:1143
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.
length in bits of a global input word
Definition: MTRda.cxx:462
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:1185
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
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
number of global input words
Definition: MTRda.cxx:461
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:1126
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