/*
+MTR DA for online
+
+Contact: Franck Manso <manso@clermont.in2p3.fr>
+Link: http://aliceinfo.cern.ch/static/Offline/dimuon/muon_html/README_mtrda.html
+Reference run: 61898, 63698 (dead channels), 63701 (noisy channels)
+Run Type: PHYSICS (noisy channels), STANDALONE (dead channels)
+DA Type: MON
+Number of events needed: 1000 events for noisy and dead channels
+Input Files: Rawdata file (DATE format)
+Input Files from DB:
+MtgGlobalCrate-<version>.dat
+MtgRegionalCrate-<version>.dat
+MtgLocalMask-<version>.dat
+MtgLocalLut-<version>.dat
+MtgCurrent.dat
+
+Output Files: local dir (not persistent)
+ExportedFiles.dat
+*/
-Version 2 for MUONTRGda MUON trigger
-Working version for:
-
- reading back raw data
-
- Versionning of the Mtg file
-
- DA for ELECTRONICS_CALIBRATION_RUN (calib)
- checking dead channels
-
- DA for DETECTOR_CALIBRATION_RUN (ped)
- checking the noisy channels
-
- Interfaced with online database and file exchange server
-
-November 2007
-Ch. Finck
-
-To be done:
- Writing into the online database (need update of daqDAlib)
- Looking at scalers outputs
-
+//////////////////////////////////////////////////////////////////////////////
+// Detector Algorithm for the MUON trigger configuration. //
+// //
+// Calculates masks for the global trigger input, by looking at dead //
+// channels in calibration runs and at noisy channels in physics runs. //
+// Transfers trigger configuration files to the File Exchange Server and //
+// writes them (if modified) into the trigger configuration data base. //
+// //
+// Authors: //
+// Christian Fink (formerly at Subatech, Nantes) //
+// Franck Manso (LPC Clermont-Ferrand, manso@clermont.in2p3.fr) //
+// Bogdan Vulpescu (LPC Clermont-Ferrand, vulpescu@clermont.in2p3.fr) //
+// //
+//////////////////////////////////////////////////////////////////////////////
-*/
extern "C" {
#include <daqDA.h>
}
#include "AliMpConstants.h"
#include "AliMUONRawStreamTrigger.h"
#include "AliMUONDarcHeader.h"
-#include "AliMUONRegHeader.h"
-#include "AliMUONLocalStruct.h"
#include "AliMUONDDLTrigger.h"
-#include "AliMUONVCalibParam.h"
#include "AliMUONVStore.h"
-#include "AliMUONCalibParamND.h"
-#include "AliMUONCalibParamNI.h"
#include "AliMUON1DArray.h"
#include "AliMUONTriggerIO.h"
#include "AliMUONRegionalTriggerConfig.h"
#include "TString.h"
#include "TSystem.h"
#include "TStopwatch.h"
-#include "TMath.h"
-#include "TTimeStamp.h"
#include "TROOT.h"
#include "TPluginManager.h"
-#include "TFile.h"
-#include "TH1F.h"
-#include "TArrayI.h"
-#include "TArrayS.h"
-// global variables
-const Int_t gkNLocalBoard = AliMpConstants::TotalNofLocalBoards();
+/// class for DA run parameters and DA working space
+class AliDAConfig : TObject {
+
+public:
+
+ AliDAConfig() :
+ fDAConfigFileName("DAConfig.txt"),
+ fCurrentFileName("MtgCurrent.dat"),
+ fLastCurrentFileName("MtgLastCurrent.dat"),
+ fSodName(""),
+ fSodFlag(0),
+ fDAName(""),
+ fDAFlag(0),
+ fGlobalFileName(""),
+ fRegionalFileName(""),
+ fLocalMaskFileName(""),
+ fLocalLutFileName(""),
+ fSignatureFileName(""),
+ fGlobalFileVersion(0),
+ fRegionalFileVersion(0),
+ fLocalMaskFileVersion(0),
+ fLocalLutFileVersion(0),
+ fSignatureFileVersion(0),
+ fGlobalFileLastVersion(0),
+ fRegionalFileLastVersion(0),
+ fLocalMaskFileLastVersion(0),
+ fLocalLutFileLastVersion(0),
+ fEventsN(0),
+ fEventsD(0),
+ fPrintLevel(0),
+ fLocalMasks(0x0),
+ fRegionalMasks(0x0),
+ fGlobalMasks(0x0),
+ fTriggerIO(new AliMUONTriggerIO),
+ fAlgoNoisyInput(false),
+ fAlgoDeadcInput(false),
+ fThrN(0.1),
+ fThrD(0.9),
+ fMinEvents(10),
+ fSkipEvents(0),
+ fMaxEvents(65535),
+ fWithWarnings(false),
+ fNLocalBoard(AliMpConstants::TotalNofLocalBoards()+1)
+ {
+ /// default constructor
+ for (Int_t ii = 0; ii < kGlobalInputs; ii++) {
+ for (Int_t il = 0; il < kGlobalInputLength; il++) {
+ fAccGlobalInputN[ii][il] = 0;
+ fAccGlobalInputD[ii][il] = 0;
+ }
+ }
+ fLocalMasks = new AliMUON1DArray(fNLocalBoard);
+ fRegionalMasks = new AliMUONRegionalTriggerConfig();
+ fGlobalMasks = new AliMUONGlobalCrateConfig();
+ }
+
+ AliDAConfig (const AliDAConfig& cfg); // copy constructor
+ AliDAConfig& operator=(const AliDAConfig& cfg); // assignment operator
+ virtual ~AliDAConfig()
+ {
+ /// destructor
+ delete fLocalMasks;
+ delete fRegionalMasks;
+ delete fGlobalMasks;
+ delete fTriggerIO;
+ }
+ void PrintConfig()
+ {
+ /// print DA parameters
+ printf("DA config file name: %s \n",GetDAConfigFileName());
+ printf("Current file name: %s \n",GetCurrentFileName());
+ printf("Last current file name: %s \n",GetLastCurrentFileName());
+ printf("Global file name: %s (%d %d)\n",GetGlobalFileName(),GetGlobalFileVersion(),GetGlobalFileLastVersion());
+ printf("Regional file name: %s (%d %d)\n",GetRegionalFileName(),GetRegionalFileVersion(),GetRegionalFileLastVersion());
+ printf("Local mask file name: %s (%d %d)\n",GetLocalMaskFileName(),GetLocalMaskFileVersion(),GetLocalMaskFileLastVersion());
+ printf("Local LUT file name: %s (%d %d)\n",GetLocalLutFileName(),GetLocalLutFileVersion(),GetLocalLutFileLastVersion());
+ printf("Signature file name: %s (%d)\n",GetSignatureFileName(),GetSignatureFileVersion());
+ }
+
+ const Char_t* GetDAConfigFileName() { return fDAConfigFileName.Data(); }
+ const Char_t* GetCurrentFileName() { return fCurrentFileName.Data(); }
+ const Char_t* GetLastCurrentFileName() { return fLastCurrentFileName.Data(); }
+
+ const Char_t* GetSodName() { return fSodName.Data(); }
+ Int_t GetSodFlag() const { return fSodFlag; }
+
+ const Char_t* GetDAName() { return fDAName.Data(); }
+ Int_t GetDAFlag() const { return fDAFlag; }
+
+ const Char_t* GetGlobalFileName() { return fGlobalFileName.Data(); }
+ const Char_t* GetRegionalFileName() { return fRegionalFileName.Data(); }
+ const Char_t* GetLocalMaskFileName() { return fLocalMaskFileName.Data(); }
+ const Char_t* GetLocalLutFileName() { return fLocalLutFileName.Data(); }
+ const Char_t* GetSignatureFileName() { return fSignatureFileName.Data(); }
+
+ Int_t GetGlobalFileVersion() const { return fGlobalFileVersion; }
+ Int_t GetRegionalFileVersion() const { return fRegionalFileVersion; }
+ Int_t GetLocalMaskFileVersion() const { return fLocalMaskFileVersion; }
+ Int_t GetLocalLutFileVersion() const { return fLocalLutFileVersion; }
+ Int_t GetSignatureFileVersion() const { return fSignatureFileVersion; }
+
+ Int_t GetGlobalFileLastVersion() const { return fGlobalFileLastVersion; }
+ Int_t GetRegionalFileLastVersion() const { return fRegionalFileLastVersion; }
+ Int_t GetLocalMaskFileLastVersion() const { return fLocalMaskFileLastVersion; }
+ Int_t GetLocalLutFileLastVersion() const { return fLocalLutFileLastVersion; }
+
+ AliMUONVStore* GetLocalMasks() const { return fLocalMasks; }
+ AliMUONRegionalTriggerConfig* GetRegionalMasks() const { return fRegionalMasks; }
+ AliMUONGlobalCrateConfig* GetGlobalMasks() const { return fGlobalMasks; }
+
+ AliMUONTriggerIO* GetTriggerIO() const { return fTriggerIO; }
+
+ Int_t GetEventsN() const { return fEventsN; }
+ Int_t GetEventsD() const { return fEventsD; }
+
+ Int_t GetPrintLevel() const { return fPrintLevel; }
+
+ Bool_t GetAlgoNoisyInput() const { return fAlgoNoisyInput; }
+ Bool_t GetAlgoDeadcInput() const { return fAlgoDeadcInput; }
+
+ Float_t GetThrN() const { return fThrN; }
+ Float_t GetThrD() const { return fThrD; }
+
+ Int_t GetMinEvents() const { return fMinEvents; }
+ Int_t GetMaxEvents() const { return fMaxEvents; }
+ Int_t GetSkipEvents() const { return fSkipEvents; }
+
+ Bool_t WithWarnings() const { return fWithWarnings; }
+
+ Int_t GetGlobalInputs() const { return kGlobalInputs; }
+ Int_t GetGlobalInputLength() const { return kGlobalInputLength; }
+
+ Int_t GetAccGlobalInputN(Int_t ii, Int_t ib) const { return fAccGlobalInputN[ii][ib]; }
+ Int_t GetAccGlobalInputD(Int_t ii, Int_t ib) const { return fAccGlobalInputD[ii][ib]; }
+
+ void SetSodName(Char_t *name) { fSodName = TString(name); }
+ void SetSodFlag(Int_t flag) { fSodFlag = flag; }
+
+ void SetDAName(Char_t *name) { fDAName = TString(name); }
+ void SetDAFlag(Int_t flag) { fDAFlag = flag; }
+
+ void SetGlobalFileName(const Char_t *name) { fGlobalFileName = TString(name); }
+ void SetRegionalFileName(const Char_t *name) { fRegionalFileName = TString(name); }
+ void SetLocalMaskFileName(const Char_t *name) { fLocalMaskFileName = TString(name); }
+ void SetLocalLutFileName(const Char_t *name) { fLocalLutFileName = TString(name); }
+ void SetSignatureFileName(const Char_t *name) { fSignatureFileName = TString(name); }
+
+ void SetGlobalFileVersion(Int_t ver) { fGlobalFileVersion = ver; }
+ void SetRegionalFileVersion(Int_t ver) { fRegionalFileVersion = ver; }
+ void SetLocalMaskFileVersion(Int_t ver) { fLocalMaskFileVersion = ver; }
+ void SetLocalLutFileVersion(Int_t ver) { fLocalLutFileVersion = ver; }
+ void SetSignatureFileVersion(Int_t ver) { fSignatureFileVersion = ver; }
+
+ void SetGlobalFileLastVersion(Int_t ver) { fGlobalFileLastVersion = ver; }
+ void SetRegionalFileLastVersion(Int_t ver) { fRegionalFileLastVersion = ver; }
+ void SetLocalMaskFileLastVersion(Int_t ver) { fLocalMaskFileLastVersion = ver; }
+ void SetLocalLutFileLastVersion(Int_t ver) { fLocalLutFileLastVersion = ver; }
+
+ void IncNoiseEvent() { fEventsN++; }
+ void IncDeadcEvent() { fEventsD++; }
+
+ void AddAccGlobalInputN(Int_t ii, Int_t ib, Int_t val) { fAccGlobalInputN[ii][ib] += val; }
+ void AddAccGlobalInputD(Int_t ii, Int_t ib, Int_t val) { fAccGlobalInputD[ii][ib] += val; }
-TString gCommand("");
+ void SetPrintLevel(Int_t level) { fPrintLevel = level; }
-TString gCurrentFileName("MtgCurrent.dat");
-TString gLastCurrentFileName("MtgLastCurrent.dat");
+ void SetAlgoNoisyInput(Bool_t val) { fAlgoNoisyInput = val; }
+ void SetAlgoDeadcInput(Bool_t val) { fAlgoDeadcInput = val; }
-TString gSodName;
-Int_t gSodFlag = 0;
+ void SetThrN(Float_t val) { fThrN = val; }
+ void SetThrD(Float_t val) { fThrD = val; }
-TString gDAName;
-Int_t gDAFlag = 0;
+ void SetMinEvents(Int_t val) { fMinEvents = val; }
+ void SetMaxEvents(Int_t val) { fMaxEvents = val; }
+ void SetSkipEvents(Int_t val) { fSkipEvents = val; }
-TString gGlobalFileName;
-TString gRegionalFileName;
-TString gLocalMaskFileName;
-TString gLocalLutFileName;
-TString gSignatureFileName;
+ void SetWithWarnings() { fWithWarnings = true; }
-Int_t gGlobalFileVersion;
-Int_t gRegionalFileVersion;
-Int_t gLocalMaskFileVersion;
-Int_t gLocalLutFileVersion;
-Int_t gSignatureFileVersion;
+ void IncGlobalFileVersion() { fGlobalFileVersion++; }
+ void DecSkipEvents() { fSkipEvents--; }
-Int_t gGlobalFileLastVersion;
-Int_t gRegionalFileLastVersion;
-Int_t gLocalMaskFileLastVersion;
-Int_t gLocalLutFileLastVersion;
+private:
-UInt_t gRunNumber = 0;
-Int_t gNEvents = 0;
+ const TString fDAConfigFileName;
+ const TString fCurrentFileName;
+ const TString fLastCurrentFileName;
-Int_t gPrintLevel = 0;
+ TString fSodName;
+ Int_t fSodFlag;
-AliMUONVStore* gLocalMasks = 0x0;
-AliMUONRegionalTriggerConfig* gRegionalMasks = 0x0;
-AliMUONGlobalCrateConfig* gGlobalMasks = 0x0;
+ TString fDAName;
+ Int_t fDAFlag;
+ TString fGlobalFileName;
+ TString fRegionalFileName;
+ TString fLocalMaskFileName;
+ TString fLocalLutFileName;
+ TString fSignatureFileName;
- AliMUONTriggerIO gTriggerIO;
+ Int_t fGlobalFileVersion;
+ Int_t fRegionalFileVersion;
+ Int_t fLocalMaskFileVersion;
+ Int_t fLocalLutFileVersion;
+ Int_t fSignatureFileVersion;
+
+ Int_t fGlobalFileLastVersion;
+ Int_t fRegionalFileLastVersion;
+ Int_t fLocalMaskFileLastVersion;
+ Int_t fLocalLutFileLastVersion;
+
+ Int_t fEventsN;
+ Int_t fEventsD;
+
+ Int_t fPrintLevel;
+
+ AliMUONVStore* fLocalMasks;
+ AliMUONRegionalTriggerConfig* fRegionalMasks;
+ AliMUONGlobalCrateConfig* fGlobalMasks;
+
+ AliMUONTriggerIO *fTriggerIO;
+
+ Bool_t fAlgoNoisyInput;
+ Bool_t fAlgoDeadcInput;
-AliMUONVStore* gPatternStore = new AliMUON1DArray(gkNLocalBoard);
+ Float_t fThrN;
+ Float_t fThrD;
+ Int_t fMinEvents;
+ Int_t fSkipEvents;
+ Int_t fMaxEvents;
+ Bool_t fWithWarnings;
-Char_t gHistoFileName[256];
+ const Int_t fNLocalBoard;
-Float_t gkThreshold = 0.2;
+ enum { kGlobalInputs = 4, kGlobalInputLength = 32 };
+
+ Int_t fAccGlobalInputN[kGlobalInputs][kGlobalInputLength];
+ Int_t fAccGlobalInputD[kGlobalInputs][kGlobalInputLength];
+
+};
//__________________________________________________________________
-void UpdateLocalMask(Int_t localBoardId, Int_t connector, Int_t strip)
+Bool_t ReadDAConfig(AliDAConfig& cfg)
{
+ /// read run parameters for the DA
+
+ char line[80];
+
+ TString file;
+ file = cfg.GetDAConfigFileName();
+ std::ifstream in(gSystem->ExpandPathName(file.Data()));
+ if (!in.good()) {
+ printf("Cannot open DA configuration file %s ; use default values.\n",file.Data());
+ return true;
+ }
- // update local mask
- AliMUONVCalibParam* localMask =
- static_cast<AliMUONVCalibParam*>(gLocalMasks->FindObject(localBoardId));
+ TString tmp;
+ Int_t pos;
+
+ in.getline(line,80);
+ tmp = line;
+ pos = tmp.First(" ");
+ tmp = tmp(0,pos);
+ cfg.SetPrintLevel(tmp.Atoi());
+
+ in.getline(line,80);
+ tmp = line;
+ pos = tmp.First(" ");
+ tmp = tmp(0,pos);
+ cfg.SetThrN(tmp.Atof());
+
+ in.getline(line,80);
+ tmp = line;
+ pos = tmp.First(" ");
+ tmp = tmp(0,pos);
+ cfg.SetThrD(tmp.Atof());
+
+ in.getline(line,80);
+ tmp = line;
+ pos = tmp.First(" ");
+ tmp = tmp(0,pos);
+ cfg.SetMinEvents(tmp.Atoi());
+
+ in.getline(line,80);
+ tmp = line;
+ pos = tmp.First(" ");
+ tmp = tmp(0,pos);
+ cfg.SetSkipEvents(tmp.Atoi());
- UShort_t mask = localMask->ValueAsInt(connector,0);
+ in.getline(line,80);
+ tmp = line;
+ pos = tmp.First(" ");
+ tmp = tmp(0,pos);
+ cfg.SetMaxEvents(tmp.Atoi());
- mask ^= (0x1 << strip); // set strip mask to zero
+ in.getline(line,80);
+ tmp = line;
+ pos = tmp.First(" ");
+ tmp = tmp(0,pos);
+ if (tmp.Atoi() != 0) cfg.SetWithWarnings();
+
+ return true;
- localMask->SetValueAsInt(connector,0, mask);
}
//__________________________________________________________________
-void WriteLastCurrentFile(TString currentFile = gLastCurrentFileName)
+void WriteLastCurrentFile(AliDAConfig& cfg, TString currentFile)
{
+ /// write last current file
- // write last current file
ofstream out;
TString file;
file = currentFile;
out.open(file.Data());
- out << gSodName << " " << gSodFlag << endl;
- out << gDAName << " " << gDAFlag << endl;
+ out << cfg.GetSodName() << " " << cfg.GetSodFlag() << endl;
+ out << cfg.GetDAName() << " " << cfg.GetDAFlag() << endl;
- out << gGlobalFileName << " " << gGlobalFileVersion << endl;
- out << gRegionalFileName << " " << gRegionalFileVersion << endl;
- out << gLocalMaskFileName << " " << gLocalMaskFileVersion << endl;
- out << gLocalLutFileName << " " << gLocalLutFileVersion << endl;
- out << gSignatureFileName << " " << gSignatureFileVersion << endl;
+ out << cfg.GetGlobalFileName() << " " << cfg.GetGlobalFileVersion() << endl;
+ out << cfg.GetRegionalFileName() << " " << cfg.GetRegionalFileVersion() << endl;
+ out << cfg.GetLocalMaskFileName() << " " << cfg.GetLocalMaskFileVersion() << endl;
+ out << cfg.GetLocalLutFileName() << " " << cfg.GetLocalLutFileVersion() << endl;
+ out << cfg.GetSignatureFileName() << " " << cfg.GetSignatureFileVersion() << endl;
out.close();
}
//___________________________________________________________________________________________
-Bool_t ReadCurrentFile(TString currentFile = gCurrentFileName, Bool_t lastCurrentFlag = false)
+Bool_t ReadCurrentFile(AliDAConfig& cfg, TString currentFile, Bool_t lastCurrentFlag = false)
{
+ /// read last current file name and version
- // read last current file name and version
char line[80];
char name[80];
+ Int_t flag;
TString file;
file = currentFile;
return false;
}
-
// read SOD
in.getline(line,80);
- sscanf(line, "%s %d", name, &gSodFlag);
- gSodName = name;
- if (gPrintLevel) printf("Sod Flag %d\n", gSodFlag);
+ sscanf(line, "%s %d", name, &flag);
+ cfg.SetSodName(name);
+ cfg.SetSodFlag(flag);
+ if (cfg.GetPrintLevel()) printf("Sod Flag %d\n", cfg.GetSodFlag());
//read DA
in.getline(line,80);
- sscanf(line, "%s %d", name, &gDAFlag);
- gDAName = name;
- if (gPrintLevel) printf("DA Flag: %d\n", gDAFlag);
-
+ sscanf(line, "%s %d", name, &flag);
+ cfg.SetDAName(name);
+ cfg.SetDAFlag(flag);
+ if (cfg.GetPrintLevel()) printf("DA Flag: %d\n", cfg.GetDAFlag());
// read global
in.getline(line,80);
TString tmp(line);
Int_t pos = tmp.First(" ");
- gGlobalFileName = tmp(0, pos);
+ TString tmp1 = tmp(0, pos);
+ cfg.SetGlobalFileName(tmp1.Data());
if (!lastCurrentFlag) {
- gGlobalFileVersion = atoi(tmp(pos+1, tmp.Length()-pos).Data());
- if (gPrintLevel) printf("Global File Name: %s version: %d\n",
- gGlobalFileName.Data(), gGlobalFileVersion);
+ cfg.SetGlobalFileVersion(atoi(tmp(pos+1, tmp.Length()-pos).Data()));
+ if (cfg.GetPrintLevel()) printf("Global File Name: %s version: %d\n",
+ cfg.GetGlobalFileName(), cfg.GetGlobalFileVersion());
} else {
- gGlobalFileLastVersion = atoi(tmp(pos+1, tmp.Length()-pos).Data());
- if (gPrintLevel) printf("Global File Name: %s last version: %d\n",
- gGlobalFileName.Data(), gGlobalFileLastVersion);
+ cfg.SetGlobalFileLastVersion(atoi(tmp(pos+1, tmp.Length()-pos).Data()));
+ if (cfg.GetPrintLevel()) printf("Global File Name: %s last version: %d\n",
+ cfg.GetGlobalFileName(), cfg.GetGlobalFileLastVersion());
}
// read regional
in.getline(line,80);
tmp = line;
pos = tmp.First(" ");
- gRegionalFileName = tmp(0, pos);
+ tmp1 = tmp(0, pos);
+ cfg.SetRegionalFileName(tmp1.Data());
if (!lastCurrentFlag) {
- gRegionalFileVersion = atoi(tmp(pos+1, tmp.Length()-pos).Data());
- if (gPrintLevel) printf("Regional File Name: %s version: %d\n",
- gRegionalFileName.Data(), gRegionalFileVersion);
+ cfg.SetRegionalFileVersion(atoi(tmp(pos+1, tmp.Length()-pos).Data()));
+ if (cfg.GetPrintLevel()) printf("Regional File Name: %s version: %d\n",
+ cfg.GetRegionalFileName(), cfg.GetRegionalFileVersion());
} else {
- gRegionalFileLastVersion = atoi(tmp(pos+1, tmp.Length()-pos).Data());
- if (gPrintLevel) printf("Regional File Name: %s last version: %d\n",
- gRegionalFileName.Data(), gRegionalFileLastVersion);
+ cfg.SetRegionalFileLastVersion(atoi(tmp(pos+1, tmp.Length()-pos).Data()));
+ if (cfg.GetPrintLevel()) printf("Regional File Name: %s last version: %d\n",
+ cfg.GetRegionalFileName(), cfg.GetRegionalFileLastVersion());
}
-
-
// read mask
in.getline(line,80);
tmp = line;
pos = tmp.First(" ");
- gLocalMaskFileName = tmp(0, pos);
+ tmp1 = tmp(0, pos);
+ cfg.SetLocalMaskFileName(tmp1.Data());
if (!lastCurrentFlag) {
- gLocalMaskFileVersion = atoi(tmp(pos+1, tmp.Length()-pos).Data());
- if (gPrintLevel) printf("Mask File Name: %s version: %d\n",
- gLocalMaskFileName.Data(), gLocalMaskFileVersion);
+ cfg.SetLocalMaskFileVersion(atoi(tmp(pos+1, tmp.Length()-pos).Data()));
+ if (cfg.GetPrintLevel()) printf("Mask File Name: %s version: %d\n",
+ cfg.GetLocalMaskFileName(), cfg.GetLocalMaskFileVersion());
} else {
- gLocalMaskFileLastVersion = atoi(tmp(pos+1, tmp.Length()-pos).Data());
- if (gPrintLevel) printf("Mask File Name: %s last version: %d\n",
- gLocalMaskFileName.Data(), gLocalMaskFileLastVersion);
+ cfg.SetLocalMaskFileLastVersion(atoi(tmp(pos+1, tmp.Length()-pos).Data()));
+ if (cfg.GetPrintLevel()) printf("Mask File Name: %s last version: %d\n",
+ cfg.GetLocalMaskFileName(), cfg.GetLocalMaskFileLastVersion());
}
// read Lut
in.getline(line,80);
tmp = line;
pos = tmp.First(" ");
- gLocalLutFileName = tmp(0, pos);
+ tmp1 = tmp(0, pos);
+ cfg.SetLocalLutFileName(tmp1.Data());
if (!lastCurrentFlag) {
- gLocalLutFileVersion = atoi(tmp(pos+1, tmp.Length()-pos).Data());
- if (gPrintLevel) printf("Lut File Name: %s version: %d\n",
- gLocalLutFileName.Data(), gLocalLutFileVersion);
+ cfg.SetLocalLutFileVersion(atoi(tmp(pos+1, tmp.Length()-pos).Data()));
+ if (cfg.GetPrintLevel()) printf("Lut File Name: %s version: %d\n",
+ cfg.GetLocalLutFileName(), cfg.GetLocalLutFileVersion());
} else {
- gLocalLutFileLastVersion = atoi(tmp(pos+1, tmp.Length()-pos).Data());
- if (gPrintLevel) printf("Lut File Name: %s last version: %d\n",
- gLocalLutFileName.Data(), gLocalLutFileLastVersion);
+ cfg.SetLocalLutFileLastVersion(atoi(tmp(pos+1, tmp.Length()-pos).Data()));
+ if (cfg.GetPrintLevel()) printf("Lut File Name: %s last version: %d\n",
+ cfg.GetLocalLutFileName(), cfg.GetLocalLutFileLastVersion());
}
in.getline(line,80);
tmp = line;
pos = tmp.First(" ");
- gSignatureFileName = tmp(0, pos);
- gSignatureFileVersion = atoi(tmp(pos+1, tmp.Length()-pos).Data());
- if (gPrintLevel) printf("Lut File Name: %s version: %d\n",
- gSignatureFileName.Data(), gSignatureFileVersion);
+ tmp1 = tmp(0, pos);
+ cfg.SetSignatureFileName(tmp1.Data());
+ cfg.SetSignatureFileVersion(atoi(tmp(pos+1, tmp.Length()-pos).Data()));
+ if (cfg.GetPrintLevel()) printf("Lut File Name: %s version: %d\n",
+ cfg.GetSignatureFileName(), cfg.GetSignatureFileVersion());
return true;
}
//_____________
-void ReadFileNames()
+void ReadFileNames(AliDAConfig& cfg)
{
- // if last current file does not exist than read current file
- if (!ReadCurrentFile(gLastCurrentFileName, true))
+ /// if last current file does not exist than read current file
+
+ if (!ReadCurrentFile(cfg,cfg.GetLastCurrentFileName(), true))
{
- ReadCurrentFile(gCurrentFileName, true);
- WriteLastCurrentFile();
+ ReadCurrentFile(cfg,cfg.GetCurrentFileName(), true);
}
-
- // any case read current file
- ReadCurrentFile();
-
+
+ // any case read current file
+ ReadCurrentFile(cfg,cfg.GetCurrentFileName());
+
}
//__________________
-Bool_t ExportFiles()
+Bool_t ExportFiles(AliDAConfig& cfg)
{
+ /// Export files to FES
- // Export files to FES
// env variables have to be set (suppose by ECS ?)
// setenv DATE_FES_PATH
// setenv DATE_RUN_NUMBER
// setenv DATE_ROLE_NAME
// setenv DATE_DETECTOR_CODE
- // Export files into the database
- // setenv DATE_DETECTOR_CODE MTR
- // setenv DAQDALIB_PATH $ALICE/daqDAlib
- // setenv DATE_DB_MYSQL_USER det_MTR
- // setenv DATE_DB_MYSQL_PWD MTR123
- // setenv DATE_DB_MYSQL_HOST aldaqdb.cern.ch
- // setenv DATE_DB_MYSQL_DB $DATE_CONFIG
- // set PATH=$PATH:${DAQDALIB_PATH}
-
-
- // to be sure that env variable is set
- // gSystem->Setenv("DAQDALIB_PATH", "$DATE_SITE/infoLogger");
- gSystem->Setenv("DAQDALIB_PATH", "$ALICE/daqDAlib");
- gSystem->Setenv("DATE_DETECTOR_CODE", "MTR");
- gSystem->Setenv("DATE_DB_MYSQL_USER", "det_MTR");
- gSystem->Setenv("DATE_DB_MYSQL_PWD", "MTR123");
- gSystem->Setenv("DATE_DB_MYSQL_HOST", "aldaqdb.cern.ch");
- gSystem->Setenv("DATE_DB_MYSQL_DB", "$DATE_CONFIG");
-
+ // offline:
+ //gSystem->Setenv("DAQDALIB_PATH", "$DATE_SITE/infoLogger");
+
+ // offline: use a dummy FES (local directory)
+ //gSystem->Setenv("DAQDA_TEST_DIR", "/alisoft/FES");
+
// update files
Int_t status = 0;
if (!out.good()) {
printf("Failed to create file: %s\n",file.Data());
return false;
- } file = gGlobalFileName.Data();
+ }
- if (gGlobalFileLastVersion != gGlobalFileVersion) {
+ // check if MtgLastCurrent.dat exists
+ // if not, do initial export of all files
+ Bool_t initFES = false;
+ if (gSystem->AccessPathName("MtgLastCurrent.dat"))
+ initFES = true;
+ if (initFES) printf("Copy all configuration files to the FES.\n");
+ file = cfg.GetGlobalFileName();
+ if ((cfg.GetGlobalFileLastVersion() != cfg.GetGlobalFileVersion()) || initFES) {
status = daqDA_FES_storeFile(file.Data(), file.Data());
if (status) {
- printf("Failed to export file: %s\n",gGlobalFileName.Data());
+ printf("Failed to export file: %s\n",cfg.GetGlobalFileName());
return false;
}
- out << gGlobalFileName.Data() << endl;
- if(gPrintLevel) printf("Export file: %s\n",gGlobalFileName.Data());
+ if(cfg.GetPrintLevel()) printf("Export file: %s\n",cfg.GetGlobalFileName());
+ out << cfg.GetGlobalFileName() << endl;
}
- if (gLocalMaskFileLastVersion != gLocalMaskFileVersion) {
+ file = cfg.GetLocalMaskFileName();
+ if ((cfg.GetLocalMaskFileLastVersion() != cfg.GetLocalMaskFileVersion()) || initFES) {
modified = true;
- file = gLocalMaskFileName;
- // export to FES
status = daqDA_FES_storeFile(file.Data(), file.Data());
if (status) {
- printf("Failed to export file: %s\n",gLocalMaskFileName.Data());
+ printf("Failed to export file: %s\n",cfg.GetLocalMaskFileName());
return false;
}
- // export to DB
- status = daqDA_DB_storeFile(file.Data(), file.Data());
- if (status) {
- printf("Failed to export file to DB: %s\n",gLocalMaskFileName.Data());
- return false;
- }
-
- if(gPrintLevel) printf("Export file: %s\n",gLocalMaskFileName.Data());
- out << gLocalMaskFileName.Data() << endl;
+ if(cfg.GetPrintLevel()) printf("Export file: %s\n",cfg.GetLocalMaskFileName());
+ out << cfg.GetLocalMaskFileName() << endl;
}
- if (gLocalLutFileLastVersion != gLocalLutFileVersion) {
- file = gLocalLutFileName;
+ file = cfg.GetLocalLutFileName();
+ if ((cfg.GetLocalLutFileLastVersion() != cfg.GetLocalLutFileVersion()) || initFES) {
modified = true;
status = daqDA_FES_storeFile(file.Data(), file.Data());
if (status) {
- printf("Failed to export file: %s\n",gLocalLutFileName.Data());
+ printf("Failed to export file: %s\n",cfg.GetLocalLutFileName());
return false;
}
- if(gPrintLevel) printf("Export file: %s\n",gLocalLutFileName.Data());
- out << gLocalLutFileName.Data() << endl;
+ if(cfg.GetPrintLevel()) printf("Export file: %s\n",cfg.GetLocalLutFileName());
+ out << cfg.GetLocalLutFileName() << endl;
}
// exported regional file whenever mask or/and Lut are modified
- if ( (gRegionalFileLastVersion != gRegionalFileVersion) || modified) {
- file = gRegionalFileName;
+ file = cfg.GetRegionalFileName();
+ if ( (cfg.GetRegionalFileLastVersion() != cfg.GetRegionalFileVersion()) || modified || initFES) {
status = daqDA_FES_storeFile(file.Data(), file.Data());
if (status) {
- printf("Failed to export file: %s\n",gRegionalFileName.Data());
+ printf("Failed to export file: %s\n",cfg.GetRegionalFileName());
return false;
}
- if(gPrintLevel) printf("Export file: %s\n",gRegionalFileName.Data());
- out << gRegionalFileName.Data() << endl;
+ if(cfg.GetPrintLevel()) printf("Export file: %s\n",cfg.GetRegionalFileName());
+ out << cfg.GetRegionalFileName() << endl;
}
out.close();
printf("Failed to export file: %s\n", fileExp.Data());
return false;
}
- if(gPrintLevel) printf("Export file: %s\n",fileExp.Data());
+ if(cfg.GetPrintLevel()) printf("Export file: %s\n",fileExp.Data());
+
+ // write last current file
+ WriteLastCurrentFile(cfg,cfg.GetLastCurrentFileName());
return true;
}
+
//__________________
-Bool_t ImportFiles()
+Bool_t ImportFiles(AliDAConfig& cfg)
{
- // copy locally a file from daq detector config db
- // The current detector is identified by detector code in variable
- // DATE_DETECTOR_CODE. It must be defined.
- // If environment variable DAQDA_TEST_DIR is defined, files are copied from DAQDA_TEST_DIR
- // instead of the database. The usual environment variables are not needed.
-
- // to be sure that env variable is set
- // gSystem->Setenv("DAQDALIB_PATH", "$DATE_SITE/db");
- gSystem->Setenv("DAQDALIB_PATH", "$ALICE/daqDAlib");
-
+ /// copy locally a file from daq detector config db
+ /// The current detector is identified by detector code in variable
+ /// DATE_DETECTOR_CODE. It must be defined.
+ /// If environment variable DAQDA_TEST_DIR is defined, files are copied from
+ /// DAQDA_TEST_DIR instead of the database.
+ /// The usual environment variables are not needed.
+
Int_t status = 0;
- status = daqDA_DB_getFile(gCurrentFileName.Data(), gCurrentFileName.Data());
+ // offline:
+ //gSystem->Setenv("DAQDALIB_PATH", "$DATE_SITE/db");
+
+ status = daqDA_DB_getFile(cfg.GetDAConfigFileName(), cfg.GetDAConfigFileName());
if (status) {
- printf("Failed to get current config file from DB: %s\n",gCurrentFileName.Data());
+ printf("Failed to get DA config file from DB: %s\n",cfg.GetDAConfigFileName());
return false;
}
- ReadFileNames();
+ ReadDAConfig(cfg);
- status = daqDA_DB_getFile(gGlobalFileName.Data(), gGlobalFileName.Data());
+ status = daqDA_DB_getFile(cfg.GetCurrentFileName(), cfg.GetCurrentFileName());
if (status) {
- printf("Failed to get current config file from DB: %s\n", gGlobalFileName.Data());
+ printf("Failed to get current config file from DB: %s\n",cfg.GetCurrentFileName());
return false;
}
+
+ ReadFileNames(cfg);
- status = daqDA_DB_getFile(gRegionalFileName.Data(), gRegionalFileName.Data());
+ status = daqDA_DB_getFile(cfg.GetGlobalFileName(), cfg.GetGlobalFileName());
if (status) {
- printf("Failed to get current config file from DB: %s\n",gRegionalFileName.Data());
+ printf("Failed to get current config file from DB: %s\n", cfg.GetGlobalFileName());
return false;
}
- status = daqDA_DB_getFile(gLocalMaskFileName.Data(), gLocalMaskFileName.Data());
+ status = daqDA_DB_getFile(cfg.GetRegionalFileName(), cfg.GetRegionalFileName());
if (status) {
- printf("Failed to get current config file from DB: %s\n",gLocalMaskFileName.Data());
+ printf("Failed to get current config file from DB: %s\n",cfg.GetRegionalFileName());
return false;
}
- status = daqDA_DB_getFile(gLocalLutFileName.Data(), gLocalLutFileName.Data());
+ status = daqDA_DB_getFile(cfg.GetLocalMaskFileName(), cfg.GetLocalMaskFileName());
if (status) {
- printf("Failed to get current config file from DB: %s\n",gLocalLutFileName.Data());
+ printf("Failed to get current config file from DB: %s\n",cfg.GetLocalMaskFileName());
+ return false;
+ }
+
+ status = daqDA_DB_getFile(cfg.GetLocalLutFileName(), cfg.GetLocalLutFileName());
+ if (status) {
+ printf("Failed to get current config file from DB: %s\n",cfg.GetLocalLutFileName());
return false;
}
}
//_____________
-void ReadMaskFiles()
+void ReadMaskFiles(AliDAConfig& cfg)
{
- // read mask files
- gLocalMasks = new AliMUON1DArray(gkNLocalBoard+9);
- gRegionalMasks = new AliMUONRegionalTriggerConfig();
- gGlobalMasks = new AliMUONGlobalCrateConfig();
+ /// read mask files
- TString localFile = gLocalMaskFileName;
- TString regionalFile = gRegionalFileName;
- TString globalFile = gGlobalFileName;
+ const Char_t* localFile = cfg.GetLocalMaskFileName();
+ const Char_t* regionalFile = cfg.GetRegionalFileName();
+ const Char_t* globalFile = cfg.GetGlobalFileName();
- gTriggerIO.ReadConfig(localFile.Data(), regionalFile.Data(), globalFile.Data(),
- gLocalMasks, gRegionalMasks, gGlobalMasks);
+ cfg.GetTriggerIO()->ReadConfig(localFile, regionalFile, globalFile, cfg.GetLocalMasks(), cfg.GetRegionalMasks(), cfg.GetGlobalMasks());
}
-//__________
-void MakePattern(Int_t localBoardId, TArrayS& xPattern, TArrayS& yPattern)
-{
-
- // calculate the hit map for each strip in x and y direction
- AliMUONVCalibParam* pat =
- static_cast<AliMUONVCalibParam*>(gPatternStore->FindObject(localBoardId));
- if (!pat) {
- pat = new AliMUONCalibParamND(2, 64, localBoardId, 0,0.); // put default wise 0.
- gPatternStore->Add(pat);
- }
+//______________________________________________________________
+UInt_t GetFetMode(const AliDAConfig & cfg)
+{
+ /// FET mode = 3 to run algorithm for dead global inputs
+ /// 0x3 prepulse
+ /// 0x0 internal
- for (Int_t i = 0; i < 4; ++i) {
- for (Int_t j = 0; j < 16; ++j) {
-
- Int_t xMask = xPattern[i];
- Int_t yMask = yPattern[i];
+ return cfg.GetGlobalMasks()->GetFetRegister(3);
- Int_t index = 16*i + j;
- Double_t patOcc = 0.;
+}
- if ( (xMask >> j ) & 0x1 ) {
- patOcc = pat->ValueAsDouble(index, 0) + 1.;
- pat->SetValueAsDouble(index, 0, patOcc);
- }
- if ( (yMask >> j ) & 0x1 ) {
- patOcc = pat->ValueAsDouble(index, 0) + 1.;
- pat->SetValueAsDouble(index, 0, patOcc);
- }
- }
+//______________________________________________________________
+void StoreGlobalInput(AliDAConfig& cfg, const UInt_t * const globalInput)
+{
+ /// accumulate and build statistics of global input values
+
+ for (Int_t ii = 0; ii < cfg.GetGlobalInputs(); ii++) {
+ for (Int_t ib = 0; ib < cfg.GetGlobalInputLength(); ib++) {
+ // lsb -> msb
+ if (cfg.GetAlgoNoisyInput())
+ cfg.AddAccGlobalInputN(ii,ib,((globalInput[ii] >> ib) & 0x1));
+ if (cfg.GetAlgoDeadcInput())
+ cfg.AddAccGlobalInputD(ii,ib,((globalInput[ii] >> ib) & 0x1));
}
+ }
}
-//__________
-void MakePatternStore(Bool_t pedestal = true)
+//______________________________________________________________
+void UpdateGlobalMasks(AliDAConfig& cfg)
{
-
- // calculates the occupancy (option: store in a root file)
- // check noisy strip (pedestal true, software trigger)
- // check dead channel (pesdetal false, FET trigger)
-
- Int_t localBoardId = 0;
- Bool_t updated = false;
-
- // histo
-
- Char_t name[255];
- Char_t title[255];
-
- TH1F* xOccHisto[243];
- TH1F* yOccHisto[243];
- TH1F* xPatOccHisto = 0x0;
- TH1F* yPatOccHisto = 0x0;
-
- TFile* histoFile = 0x0;
-
- if (gHistoFileName[0] != 0) {
- histoFile = new TFile(gHistoFileName,"RECREATE","MUON Tracking pedestals");
-
- sprintf(name,"pat_x");
- sprintf(title,"Occupancy for x strip");
- Int_t nx = 200;
- Float_t xmin = -0.2;
- Float_t xmax = 1.2;
- xPatOccHisto = new TH1F(name,title,nx,xmin,xmax);
- xPatOccHisto ->SetDirectory(histoFile);
-
- sprintf(name,"pat_y");
- sprintf(title,"Occupancy for y strip");
- yPatOccHisto = new TH1F(name,title,nx,xmin,xmax);
- yPatOccHisto->SetDirectory(histoFile);
-
- }
-
- // iterator over pedestal
- TIter next(gPatternStore->CreateIterator());
- AliMUONVCalibParam* pat;
+ /// update the global masks
- while ( ( pat = dynamic_cast<AliMUONVCalibParam*>(next() ) ) )
- {
- localBoardId = pat->ID0();
-
- if (gHistoFileName[0] != 0) {
-
- Int_t nx = 64;
- Float_t xmin = 0;
- Float_t xmax = 64;
-
- sprintf(name,"pat_x_%d",localBoardId);
- sprintf(title,"Occupancy for x strip, board %d",localBoardId);
- xOccHisto[localBoardId] = new TH1F(name,title,nx,xmin,xmax);
-
- sprintf(name,"pat_y_%d",localBoardId);
- sprintf(title,"Occupancy for y strip, board %d",localBoardId);
- yOccHisto[localBoardId] = new TH1F(name,title,nx,xmin,xmax);
-
+ // offline:
+ //gSystem->Setenv("DAQDALIB_PATH", "$DATE_SITE/db");
+
+ Float_t rateN = 0.0, rateD = 0.0;
+ UInt_t gmask[4], omask;
+ Bool_t noise, deadc, withEvN, withEvD, updated = false;
+
+ for (Int_t ii = 0; ii < cfg.GetGlobalInputs(); ii++) {
+ gmask[ii] = 0;
+
+ for (Int_t ib = 0; ib < cfg.GetGlobalInputLength(); ib++) {
+ // lsb -> msb
+ noise = false;
+ deadc = false;
+ withEvN = false;
+ withEvD = false;
+ if (cfg.GetEventsN() > cfg.GetMinEvents()) {
+ rateN = (Float_t)cfg.GetAccGlobalInputN(ii,ib)/(Float_t)cfg.GetEventsN();
+ noise = (rateN > cfg.GetThrN());
+ withEvN = true;
}
-
- for (Int_t index = 0; index < pat->Size() ; ++index) {// 64 bits for X and 64 bits for Y strips
-
- Double_t patXOcc = pat->ValueAsDouble(index, 0)/(Double_t)gNEvents;
- Double_t patYOcc = pat->ValueAsDouble(index, 1)/(Double_t)gNEvents;
-
- pat->SetValueAsDouble(index, 0, patXOcc);
- pat->SetValueAsDouble(index, 1, patYOcc);
-
-
- // check for x strip
- if ( (patXOcc > gkThreshold && pedestal) || (patXOcc < 1.- gkThreshold && !pedestal) ) {
- UShort_t strip = index % 16;
- Int_t connector = index/16;
- UpdateLocalMask(localBoardId, connector, strip);
- updated = true;
+ if (cfg.GetEventsD() > cfg.GetMinEvents()) {
+ rateD = (Float_t)cfg.GetAccGlobalInputD(ii,ib)/(Float_t)cfg.GetEventsD();
+ deadc = (rateD < cfg.GetThrD());
+ withEvD = true;
+ }
+ if (!withEvN && !withEvD) {
+ // - copy the bit from the old mask
+ gmask[ii] |= ((cfg.GetGlobalMasks()->GetGlobalMask(ii) >> ib) & 0x1) << ib;
+ printf("Mask not changed (just copy the old values)\n");
+ }
+ if (!withEvN && withEvD) {
+ if (!deadc) {
+ // - create a new mask, set the bit to 1
+ // not allowed!
+ //gmask[ii] |= 0x1 << ib;
+ // - copy the bit from the old mask
+ gmask[ii] |= ((cfg.GetGlobalMasks()->GetGlobalMask(ii) >> ib) & 0x1) << ib;
+ } else {
+ // - create a new mask, set the bit to 0
+ gmask[ii] |= 0x0 << ib;
+ printf("Found dead channel %1d:%02d (%4.2f) \n",ii,ib,rateD);
}
-
- // check for y strip
- if ( (patYOcc > gkThreshold && pedestal) || (patYOcc < 1.- gkThreshold && !pedestal) ) {
- UShort_t strip = index % 16;
- Int_t connector = index/16 + 4;
- UpdateLocalMask(localBoardId, connector, strip);
- updated = true;
-
+ }
+ if (withEvN && !withEvD) {
+ if (!noise) {
+ // - create a new mask, set the bit to 1
+ // not allowed!
+ //gmask[ii] |= 0x1 << ib;
+ // - copy the bit from the old mask
+ gmask[ii] |= ((cfg.GetGlobalMasks()->GetGlobalMask(ii) >> ib) & 0x1) << ib;
+ } else {
+ // - create a new mask, set the bit to 0
+ gmask[ii] |= 0x0 << ib;
+ printf("Found noisy channel %1d:%02d (%4.2f) \n",ii,ib,rateN);
+ }
+ }
+ if (withEvN && withEvD) {
+ if (!noise && !deadc) {
+ // - create a new mask, set the bit to 1
+ // not allowed!
+ //gmask[ii] |= 0x1 << ib;
+ // - copy the bit from the old mask
+ gmask[ii] |= ((cfg.GetGlobalMasks()->GetGlobalMask(ii) >> ib) & 0x1) << ib;
+ } else {
+ // - create a new mask, set the bit to 0
+ gmask[ii] |= 0x0 << ib;
+ if (noise)
+ printf("Found noisy channel %1d:%02d (%4.2f) \n",ii,ib,rateN);
+ if (deadc)
+ printf("Found dead channel %1d:%02d (%4.2f) \n",ii,ib,rateD);
}
-
- if (gHistoFileName[0] != 0) {
- xPatOccHisto->Fill(patXOcc);
- yPatOccHisto->Fill(patYOcc);
- xOccHisto[localBoardId]->Fill(index, patXOcc);
- yOccHisto[localBoardId]->Fill(index, patYOcc);
-
- }
}
}
-
- if (gHistoFileName[0] != 0) {
- histoFile->Write();
- histoFile->Close();
+ }
+
+ // check if at least one mask value has been changed from previous version
+ for (Int_t ii = 0; ii < cfg.GetGlobalInputs(); ii++) {
+ printf("Global mask [%1d] %08x \n",ii,gmask[ii]);
+ omask = cfg.GetGlobalMasks()->GetGlobalMask(ii);
+ if (gmask[ii] != omask) {
+ updated = true;
+ cfg.GetGlobalMasks()->SetGlobalMask(ii,gmask[ii]);
}
+ }
+ Int_t status = 0;
+ if (updated) {
+
+ // update version
+ cfg.IncGlobalFileVersion();
+
+ // don't change the file version ("-x.dat")
+
+ cfg.GetTriggerIO()->WriteGlobalConfig(cfg.GetGlobalFileName(),cfg.GetGlobalMasks());
+
+ // write last current file
+ WriteLastCurrentFile(cfg,cfg.GetCurrentFileName());
- if (updated) {
-
- // update version
- gLocalMaskFileVersion++;
-
- TString tmp(gLocalMaskFileName);
- Int_t pos = tmp.First("-");
- gLocalMaskFileName = tmp(0,pos+1) + Form("%d",gLocalMaskFileVersion) + ".dat";
-
- // write last current file
- WriteLastCurrentFile();
-
- gTriggerIO.WriteConfig(gLocalMaskFileName, gRegionalFileName, gGlobalFileName, gLocalMasks, gRegionalMasks, gGlobalMasks);
+ status = daqDA_DB_storeFile(cfg.GetGlobalFileName(), cfg.GetGlobalFileName());
+ if (status) {
+ printf("Failed to export file to DB: %s\n",cfg.GetGlobalFileName());
+ return;
+ }
+
+ status = daqDA_DB_storeFile(cfg.GetCurrentFileName(), cfg.GetCurrentFileName());
+ if (status) {
+ printf("Failed to export file to DB: %s\n",cfg.GetCurrentFileName());
+ return;
}
+
+ }
+
}
//*************************************************************//
-
- // main routine
int main(Int_t argc, Char_t **argv)
{
+ /// main routine
// needed for streamer application
- gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo", "*", "TStreamerInfo",
- "RIO", "TStreamerInfo()");
+ gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo", "*", "TStreamerInfo", "RIO", "TStreamerInfo()");
- Int_t skipEvents = 0;
- Int_t maxEvents = 1000000;
- Char_t inputFile[256];
- strcpy(inputFile, "");
- TString flatOutputFile;
+ /* check that we got some arguments = list of files */
+ if (argc<2) {
+ printf("Wrong number of arguments\n");
+ return -1;
+ }
-// option handler
+ AliDAConfig cfg;
- // decode the input line
- for (Int_t i = 1; i < argc; i++) // argument 0 is the executable name
- {
- Char_t* arg;
-
- arg = argv[i];
- if (arg[0] != '-') continue;
- switch (arg[1])
- {
- case 'f' :
- i++;
- sprintf(inputFile,argv[i]);
- break;
- case 't' :
- i++;
- gkThreshold = atof(argv[i]);
- break;
- case 'e' :
- i++;
- gCommand = argv[i];
- break;
- case 'd' :
- i++;
- gPrintLevel=atoi(argv[i]);
- break;
- case 's' :
- i++;
- skipEvents=atoi(argv[i]);
- break;
- case 'n' :
- i++;
- sscanf(argv[i],"%d",&maxEvents);
- break;
- case 'r' :
- i++;
- sscanf(argv[i],"%s",gHistoFileName);
- break;
- case 'h' :
- i++;
- printf("\n******************* %s usage **********************",argv[0]);
- printf("\n%s -options, the available options are :",argv[0]);
- printf("\n-h help (this screen)");
- printf("\n");
- printf("\n Input");
- printf("\n-f <raw data file> (default = %s)",inputFile);
- printf("\n");
- printf("\n output");
- printf("\n-r <root file> (default = %s)",gHistoFileName);
- printf("\n");
- printf("\n Options");
- printf("\n-t <threshold values> (default = %3.1f)",gkThreshold);
- printf("\n-d <print level> (default = %d)",gPrintLevel);
- printf("\n-s <skip events> (default = %d)",skipEvents);
- printf("\n-n <max events> (default = %d)",maxEvents);
- printf("\n-e <execute ped/calib> (default = %s)",gCommand.Data());
-
- printf("\n\n");
- exit(-1);
- default :
- printf("%s : bad argument %s (please check %s -h)\n",argv[0],argv[i],argv[0]);
- argc = 2; exit(-1); // exit if error
- } // end of switch
- } // end of for i
-
- // set command to lower case
- gCommand.ToLower();
+ Char_t inputFile[256] = "";
+ inputFile[0] = 0;
+ if (argc > 1)
+ if (argv[1] != NULL)
+ strncpy(inputFile, argv[1], 256);
+ else {
+ printf("MUONTRGda : No input File !\n");
+ return -1;
+ }
// decoding the events
// containers
AliMUONDDLTrigger* ddlTrigger = 0x0;
AliMUONDarcHeader* darcHeader = 0x0;
- AliMUONRegHeader* regHeader = 0x0;
- AliMUONLocalStruct* localStruct = 0x0;
TStopwatch timers;
timers.Start(kTRUE);
// comment out, since we do not retrieve files from database
- if (!ImportFiles()) {
+ if (!ImportFiles(cfg)) {
printf("Import from DB failed\n");
printf("For local test set DAQDA_TEST_DIR to the local directory where the Mtg files are located \n");
return -1;
}
+
+ ReadMaskFiles(cfg);
+
+ // offline: the run number extracted from the file name
+ //TString tmp(inputFile);
+ //Int_t pos = tmp.First("daq");
+ //tmp = tmp(pos+3,5);
+ //gSystem->Setenv("DATE_RUN_NUMBER",tmp.Data());
+ //gSystem->Exec("echo \"DATE_RUN_NUMBER = \" $DATE_RUN_NUMBER");
+
+ if(!ExportFiles(cfg)) {
+ printf("ExportFiles failed\n");
+ return -1;
+ }
+
+ // FET is triggered by CTP
+ if (GetFetMode(cfg) != 3) {
+ printf("FET is not in mode 3\n");
+ return -1;
+ }
- if (!gDAFlag) {
- if(!ExportFiles()) return -1;
- return 0;
+ // All 5 global cards are controlled by the Mts proxy
+ if (cfg.GetGlobalMasks()->GetGlobalCrateEnable() != 0x1F) {
+ printf("The MTS proxy does not control all global cards\n");
+ return -1;
}
- ReadMaskFiles();
+ // The global cards are ON (active on the global inputs)
+ if (!cfg.GetGlobalMasks()->GetMasksOn()) {
+ printf("Global masks are not ON\n");
+ return -1;
+ }
+
+ // make sure to catch the "rare" calib events (1 every 50s in physics)
+ const Char_t* tableSOD[] = {"ALL", "yes", "CAL", "all", NULL, NULL};
+ monitorDeclareTable(const_cast<char**>(tableSOD));
status = monitorSetDataSource(inputFile);
if (status) {
return -1;
}
- cout << "MUONTRKda : Reading data from file " << inputFile <<endl;
+ /* define wait event timeout - 1s max */
+ monitorSetNowait();
+ monitorSetNoWaitNetworkTimeout(1000);
+
+ cout << "MUONTRGda : Reading data from file " << inputFile <<endl;
+
+ UInt_t *globalInput;
+ Bool_t doUpdate = false;
+ Int_t runNumber = 0;
+ Int_t nEvents = 0;
while(1)
{
- if (gNEvents >= maxEvents) break;
- if (gNEvents && gNEvents % 100 == 0)
- cout<<"Cumulated events " << gNEvents << endl;
+ if (nEvents >= cfg.GetMaxEvents()) break;
+ if (nEvents && nEvents % 100 == 0)
+ cout<<"Cumulated events " << nEvents << endl;
// check shutdown condition
if (daqDA_checkShutdown())
break;
// Skip Events if needed
- while (skipEvents) {
+ while (cfg.GetSkipEvents()) {
status = monitorGetEventDynamic(&event);
- skipEvents--;
+ cfg.DecSkipEvents();
}
// starts reading
status = monitorGetEventDynamic(&event);
if (status < 0) {
- cout<<"EOF found"<<endl;
+ cout << "MUONTRGda : EOF found" << endl;
break;
}
AliRawReader *rawReader = new AliRawReaderDate(event);
Int_t eventType = rawReader->GetType();
- gRunNumber = rawReader->GetRunNumber();
+ runNumber = rawReader->GetRunNumber();
-
- if (eventType != PHYSICS_EVENT)
- continue; // for the moment
-
- gNEvents++;
- if (gPrintLevel) printf("\nEvent # %d\n",gNEvents);
+ // L1Swc1
+ // CALIBRATION_EVENT
+ // SYSTEM_SOFTWARE_TRIGGER_EVENT
+ // DETECTOR_SOFTWARE_TRIGGER_EVENT
+ cfg.SetAlgoNoisyInput(false);
+ cfg.SetAlgoDeadcInput(false);
+ if (eventType == PHYSICS_EVENT) {
+ cfg.SetAlgoNoisyInput(true);
+ doUpdate = true;
+ cfg.IncNoiseEvent();
+ } else if (eventType == CALIBRATION_EVENT) {
+ cfg.SetAlgoDeadcInput(true);
+ doUpdate = true;
+ cfg.IncDeadcEvent();
+ } else {
+ continue;
+ }
+
+ nEvents++;
+ if (cfg.GetPrintLevel()) printf("\nEvent # %d\n",nEvents);
// decoding MUON payload
AliMUONRawStreamTrigger* rawStream = new AliMUONRawStreamTrigger(rawReader);
- //rawStream->SetMaxReg(1);
+ // ... without warnings from the decoder !!!
+ if (!cfg.WithWarnings())
+ rawStream->DisableWarnings();
- Int_t index = 0;
// loops over DDL
while((status = rawStream->NextDDL())) {
- if (gPrintLevel) printf("iDDL %d\n", rawStream->GetDDL());
+ if (cfg.GetPrintLevel()) printf("iDDL %d\n", rawStream->GetDDL());
ddlTrigger = rawStream->GetDDLTrigger();
darcHeader = ddlTrigger->GetDarcHeader();
- if (gPrintLevel) printf("Global output %x\n", (Int_t)darcHeader->GetGlobalOutput());
-
- // loop over regional structures
- Int_t nReg = darcHeader->GetRegHeaderEntries();
- for(Int_t iReg = 0; iReg < nReg; ++iReg){ //REG loop
-
- if (gPrintLevel) printf("RegionalId %d\n", iReg);
-
- regHeader = darcHeader->GetRegHeaderEntry(iReg);
-
- // loop over local structures
- Int_t nLocal = regHeader->GetLocalEntries();
- for(Int_t iLocal = 0; iLocal < nLocal; ++iLocal) {
-
- localStruct = regHeader->GetLocalEntry(iLocal);
-
- Int_t localBoardId = gTriggerIO.LocalBoardId(index++);
- if (gPrintLevel) printf("local %d\n", localBoardId );
-
- TArrayS xPattern(4);
- TArrayS yPattern(4);
- localStruct->GetXPattern(xPattern);
- localStruct->GetYPattern(yPattern);
- MakePattern(localBoardId, xPattern, yPattern);
+ if (rawStream->GetDDL() == 0) {
+ if (cfg.GetPrintLevel()) printf("Global output %x\n", (Int_t)darcHeader->GetGlobalOutput());
+ globalInput = darcHeader->GetGlobalInput();
+ StoreGlobalInput(cfg,globalInput);
+ }
- if (gPrintLevel) printf("X pattern %x %x %x %x, Y pattern %x %x %x %x\n",
- localStruct->GetX1(), localStruct->GetX2(),localStruct->GetX3(),localStruct->GetX4(),
- localStruct->GetY1(), localStruct->GetY2(),localStruct->GetY3(),localStruct->GetY4());
-
- } // iLocal
- } // iReg
} // NextDDL
delete rawReader;
} // while (1)
- if (gCommand.Contains("ped"))
- MakePatternStore();
-
- if (gCommand.Contains("cal"))
- MakePatternStore(false);
-
- if (!ExportFiles())
- return -1;
+ // update configuration files ifrequested event types were found
+ if (doUpdate && cfg.GetDAFlag())
+ UpdateGlobalMasks(cfg);
timers.Stop();
- cout << "MUONTRGda : Run number : " << gRunNumber << endl;
- cout << "MUONTRGda : Histo file generated : " << gHistoFileName << endl;
- cout << "MUONTRGda : Nb of DATE events = " << nDateEvents << endl;
- cout << "MUONTRGda : Nb of events used = " << gNEvents << endl;
+ cout << "MUONTRGda: DA enable: \t" << cfg.GetDAFlag() << endl;
+ cout << "MUONTRGda: Run number: \t" << runNumber << endl;
+ cout << "MUONTRGda: Nb of DATE events: \t" << nDateEvents << endl;
+ cout << "MUONTRGda: Nb of events used: \t" << nEvents << endl;
+ cout << "MUONTRGda: Nb of events used (noise): \t" << cfg.GetEventsN() << endl;
+ cout << "MUONTRGda: Nb of events used (deadc): \t" << cfg.GetEventsD() << endl;
+ cout << "MUONTRGda: Minumum nr of events for rate calculation: \t" << cfg.GetMinEvents() << endl;
+ cout << "MUONTRGda: Maximum nr of analyzed events: \t" << cfg.GetMaxEvents() << endl;
+ cout << "MUONTRGda: Skip events from start: \t" << cfg.GetSkipEvents() << endl;
+ cout << "MUONTRGda: Threshold for noisy inputs: \t" << 100*cfg.GetThrN() << "%" << endl;
+ cout << "MUONTRGda: Threshold for dead inputs: \t" << 100*cfg.GetThrD() << "%" << endl;
+ cout << "MUONTRGda: Print level: \t" << cfg.GetPrintLevel() << endl;
+ cout << "MUONTRGda: Show decoder warnings: \t" << cfg.WithWarnings() << endl;
- printf("Execution time : R:%7.2fs C:%7.2fs\n", timers.RealTime(), timers.CpuTime());
+ printf("MUONTRGda: Execution time : R:%7.2fs C:%7.2fs\n", timers.RealTime(), timers.CpuTime());
- delete gLocalMasks;
- delete gRegionalMasks;
- delete gGlobalMasks; // in case
- delete gPatternStore;
return status;
+
}