Contact: Franck Manso <manso@clermont.in2p3.fr>
Link: http://aliceinfo.cern.ch/static/Offline/dimuon/muon_html/README_mtrda.html
-Reference run: 61898, 61945 (dead channels), 61963 (noisy channels)
+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
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 checked:
- Writing into the online database (need update of daqDAlib)
-To be done:
- 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()+1;
+// structure for DA run parameters and DA working space
+struct DAConfig {
-TString gCurrentFileName("MtgCurrent.dat");
-TString gLastCurrentFileName("MtgLastCurrent.dat");
+ const TString fDAConfigFileName;
+ const TString fCurrentFileName;
+ const TString fLastCurrentFileName;
-TString gSodName;
-Int_t gSodFlag = 0;
+ TString fSodName;
+ Int_t fSodFlag;
-TString gDAName;
-Int_t gDAFlag = 0;
+ TString fDAName;
+ Int_t fDAFlag;
-TString gGlobalFileName;
-TString gRegionalFileName;
-TString gLocalMaskFileName;
-TString gLocalLutFileName;
-TString gSignatureFileName;
+ TString fGlobalFileName;
+ TString fRegionalFileName;
+ TString fLocalMaskFileName;
+ TString fLocalLutFileName;
+ TString fSignatureFileName;
-Int_t gGlobalFileVersion;
-Int_t gRegionalFileVersion;
-Int_t gLocalMaskFileVersion;
-Int_t gLocalLutFileVersion;
-Int_t gSignatureFileVersion;
+ 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 fNEventsN;
+ Int_t fNEventsD;
+
+ Int_t fPrintLevel;
+
+ AliMUONVStore* fLocalMasks;
+ AliMUONRegionalTriggerConfig* fRegionalMasks;
+ AliMUONGlobalCrateConfig* fGlobalMasks;
+
+ AliMUONTriggerIO *fTriggerIO;
+
+ Bool_t fAlgoNoisyInput;
+ Bool_t fAlgoDeadInput;
+
+ Float_t fThrN;
+ Float_t fThrD;
+ Int_t fMinEvents;
+ Int_t fSkipEvents;
+ Int_t fMaxEvents;
+ Bool_t fWithWarnings;
+
+ const Int_t fNLocalBoard;
+
+ enum { kGlobalInputs = 4, kGlobalInputLength = 32 };
+
+ Int_t fAccGlobalInputN[kGlobalInputs][kGlobalInputLength];
+ Int_t fAccGlobalInputD[kGlobalInputs][kGlobalInputLength];
+
+ DAConfig() :
+ 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),
+ fNEventsN(0),
+ fNEventsD(0),
+ fPrintLevel(0),
+ fLocalMasks(0x0),
+ fRegionalMasks(0x0),
+ fGlobalMasks(0x0),
+ fTriggerIO(new AliMUONTriggerIO),
+ fAlgoNoisyInput(false),
+ fAlgoDeadInput(false),
+ fThrN(0.1),
+ fThrD(0.9),
+ fMinEvents(10),
+ fSkipEvents(0),
+ fMaxEvents(65535),
+ fWithWarnings(false),
+ fNLocalBoard(AliMpConstants::TotalNofLocalBoards()+1)
+ {
+ for (Int_t ii = 0; ii < kGlobalInputs; ii++) {
+ for (Int_t il = 0; il < kGlobalInputLength; il++) {
+ fAccGlobalInputN[ii][il] = 0;
+ fAccGlobalInputD[ii][il] = 0;
+ }
+ }
+ }
-Int_t gGlobalFileLastVersion;
-Int_t gRegionalFileLastVersion;
-Int_t gLocalMaskFileLastVersion;
-Int_t gLocalLutFileLastVersion;
+ DAConfig (const DAConfig& cfg);
+ DAConfig& operator=(const DAConfig& cfg);
-UInt_t gRunNumber = 0;
-Int_t gNEvents = 0;
-Int_t gNEventsN = 0;
-Int_t gNEventsD = 0;
+};
-Int_t gPrintLevel = 0;
+//__________________________________________________________________
+Bool_t ReadDAConfig(DAConfig& cfg)
+{
+ // read run parameters for the DA
-AliMUONVStore* gLocalMasks = 0x0;
-AliMUONRegionalTriggerConfig* gRegionalMasks = 0x0;
-AliMUONGlobalCrateConfig* gGlobalMasks = 0x0;
+ char line[80];
-AliMUONTriggerIO gTriggerIO;
+ TString file;
+ file = cfg.fDAConfigFileName;
+ 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;
+ }
+
+ TString tmp;
+ Int_t pos;
+
+ in.getline(line,80);
+ tmp = line;
+ pos = tmp.First(" ");
+ tmp = tmp(0,pos);
+ cfg.fPrintLevel = tmp.Atoi();
+
+ in.getline(line,80);
+ tmp = line;
+ pos = tmp.First(" ");
+ tmp = tmp(0,pos);
+ cfg.fThrN = tmp.Atof();
+
+ in.getline(line,80);
+ tmp = line;
+ pos = tmp.First(" ");
+ tmp = tmp(0,pos);
+ cfg.fThrD = tmp.Atof();
+
+ in.getline(line,80);
+ tmp = line;
+ pos = tmp.First(" ");
+ tmp = tmp(0,pos);
+ cfg.fMinEvents = tmp.Atoi();
+
+ in.getline(line,80);
+ tmp = line;
+ pos = tmp.First(" ");
+ tmp = tmp(0,pos);
+ cfg.fSkipEvents = tmp.Atoi();
-Bool_t gAlgoNoisyInput = false;
-Bool_t gAlgoDeadInput = false;
+ in.getline(line,80);
+ tmp = line;
+ pos = tmp.First(" ");
+ tmp = tmp(0,pos);
+ cfg.fMaxEvents = tmp.Atoi();
-Int_t gkGlobalInputs = 4;
-Int_t gkGlobalInputLength = 32;
-Float_t gkThrN = 0.1;
-Float_t gkThrD = 0.1;
-Int_t gkMinEvents = 10;
+ in.getline(line,80);
+ tmp = line;
+ pos = tmp.First(" ");
+ tmp = tmp(0,pos);
+ cfg.fWithWarnings = tmp.Atoi();
+
+ return true;
-Int_t gAccGlobalInputN[4][32] = {0};
-Int_t gAccGlobalInputD[4][32] = {0};
+}
//__________________________________________________________________
-void WriteLastCurrentFile(TString currentFile = gLastCurrentFileName)
+void WriteLastCurrentFile(DAConfig& cfg, TString currentFile)
{
// write last current file
TString file;
file = currentFile;
out.open(file.Data());
- out << gSodName << " " << gSodFlag << endl;
- out << gDAName << " " << gDAFlag << endl;
+ out << cfg.fSodName << " " << cfg.fSodFlag << endl;
+ out << cfg.fDAName << " " << cfg.fDAFlag << endl;
- out << gGlobalFileName << " " << gGlobalFileVersion << endl;
- out << gRegionalFileName << " " << gRegionalFileVersion << endl;
- out << gLocalMaskFileName << " " << gLocalMaskFileVersion << endl;
- out << gLocalLutFileName << " " << gLocalLutFileVersion << endl;
- out << gSignatureFileName << " " << gSignatureFileVersion << endl;
+ out << cfg.fGlobalFileName << " " << cfg.fGlobalFileVersion << endl;
+ out << cfg.fRegionalFileName << " " << cfg.fRegionalFileVersion << endl;
+ out << cfg.fLocalMaskFileName << " " << cfg.fLocalMaskFileVersion << endl;
+ out << cfg.fLocalLutFileName << " " << cfg.fLocalLutFileVersion << endl;
+ out << cfg.fSignatureFileName << " " << cfg.fSignatureFileVersion << endl;
out.close();
}
//___________________________________________________________________________________________
-Bool_t ReadCurrentFile(TString currentFile = gCurrentFileName, Bool_t lastCurrentFlag = false)
+Bool_t ReadCurrentFile(DAConfig& cfg, TString currentFile, Bool_t lastCurrentFlag = false)
{
// read last current file name and version
// 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, &cfg.fSodFlag);
+ cfg.fSodName = name;
+ if (cfg.fPrintLevel) printf("Sod Flag %d\n", cfg.fSodFlag);
//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, &cfg.fDAFlag);
+ cfg.fDAName = name;
+ if (cfg.fPrintLevel) printf("DA Flag: %d\n", cfg.fDAFlag);
// read global
in.getline(line,80);
TString tmp(line);
Int_t pos = tmp.First(" ");
- gGlobalFileName = tmp(0, pos);
+ cfg.fGlobalFileName = tmp(0, pos);
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.fGlobalFileVersion = atoi(tmp(pos+1, tmp.Length()-pos).Data());
+ if (cfg.fPrintLevel) printf("Global File Name: %s version: %d\n",
+ cfg.fGlobalFileName.Data(), cfg.fGlobalFileVersion);
} 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.fGlobalFileLastVersion = atoi(tmp(pos+1, tmp.Length()-pos).Data());
+ if (cfg.fPrintLevel) printf("Global File Name: %s last version: %d\n",
+ cfg.fGlobalFileName.Data(), cfg.fGlobalFileLastVersion);
}
// read regional
in.getline(line,80);
tmp = line;
pos = tmp.First(" ");
- gRegionalFileName = tmp(0, pos);
+ cfg.fRegionalFileName = tmp(0, pos);
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.fRegionalFileVersion = atoi(tmp(pos+1, tmp.Length()-pos).Data());
+ if (cfg.fPrintLevel) printf("Regional File Name: %s version: %d\n",
+ cfg.fRegionalFileName.Data(), cfg.fRegionalFileVersion);
} 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.fRegionalFileLastVersion = atoi(tmp(pos+1, tmp.Length()-pos).Data());
+ if (cfg.fPrintLevel) printf("Regional File Name: %s last version: %d\n",
+ cfg.fRegionalFileName.Data(), cfg.fRegionalFileLastVersion);
}
// read mask
in.getline(line,80);
tmp = line;
pos = tmp.First(" ");
- gLocalMaskFileName = tmp(0, pos);
+ cfg.fLocalMaskFileName = tmp(0, pos);
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.fLocalMaskFileVersion = atoi(tmp(pos+1, tmp.Length()-pos).Data());
+ if (cfg.fPrintLevel) printf("Mask File Name: %s version: %d\n",
+ cfg.fLocalMaskFileName.Data(), cfg.fLocalMaskFileVersion);
} 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.fLocalMaskFileLastVersion = atoi(tmp(pos+1, tmp.Length()-pos).Data());
+ if (cfg.fPrintLevel) printf("Mask File Name: %s last version: %d\n",
+ cfg.fLocalMaskFileName.Data(), cfg.fLocalMaskFileLastVersion);
}
// read Lut
in.getline(line,80);
tmp = line;
pos = tmp.First(" ");
- gLocalLutFileName = tmp(0, pos);
+ cfg.fLocalLutFileName = tmp(0, pos);
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.fLocalLutFileVersion = atoi(tmp(pos+1, tmp.Length()-pos).Data());
+ if (cfg.fPrintLevel) printf("Lut File Name: %s version: %d\n",
+ cfg.fLocalLutFileName.Data(), cfg.fLocalLutFileVersion);
} 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.fLocalLutFileLastVersion = atoi(tmp(pos+1, tmp.Length()-pos).Data());
+ if (cfg.fPrintLevel) printf("Lut File Name: %s last version: %d\n",
+ cfg.fLocalLutFileName.Data(), cfg.fLocalLutFileLastVersion);
}
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);
+ cfg.fSignatureFileName = tmp(0, pos);
+ cfg.fSignatureFileVersion = atoi(tmp(pos+1, tmp.Length()-pos).Data());
+ if (cfg.fPrintLevel) printf("Lut File Name: %s version: %d\n",
+ cfg.fSignatureFileName.Data(), cfg.fSignatureFileVersion);
return true;
}
//_____________
-void ReadFileNames()
+void ReadFileNames(DAConfig& cfg)
{
+
// if last current file does not exist than read current file
- if (!ReadCurrentFile(gLastCurrentFileName, true))
+ if (!ReadCurrentFile(cfg,cfg.fLastCurrentFileName, true))
{
- ReadCurrentFile(gCurrentFileName, true);
+ ReadCurrentFile(cfg,cfg.fCurrentFileName, true);
}
// any case read current file
- ReadCurrentFile();
+ ReadCurrentFile(cfg,cfg.fCurrentFileName);
}
//__________________
-Bool_t ExportFiles()
+Bool_t ExportFiles(DAConfig& cfg)
{
// Export files to FES
initFES = true;
if (initFES) printf("Copy all configuration files to the FES.\n");
- file = gGlobalFileName;
- if ((gGlobalFileLastVersion != gGlobalFileVersion) || initFES) {
+ file = cfg.fGlobalFileName;
+ if ((cfg.fGlobalFileLastVersion != cfg.fGlobalFileVersion) || 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.fGlobalFileName.Data());
return false;
}
- if(gPrintLevel) printf("Export file: %s\n",gGlobalFileName.Data());
- out << gGlobalFileName.Data() << endl;
+ if(cfg.fPrintLevel) printf("Export file: %s\n",cfg.fGlobalFileName.Data());
+ out << cfg.fGlobalFileName.Data() << endl;
}
- file = gLocalMaskFileName;
- if ((gLocalMaskFileLastVersion != gLocalMaskFileVersion) || initFES) {
+ file = cfg.fLocalMaskFileName;
+ if ((cfg.fLocalMaskFileLastVersion != cfg.fLocalMaskFileVersion) || initFES) {
modified = true;
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.fLocalMaskFileName.Data());
return false;
}
- if(gPrintLevel) printf("Export file: %s\n",gLocalMaskFileName.Data());
- out << gLocalMaskFileName.Data() << endl;
+ if(cfg.fPrintLevel) printf("Export file: %s\n",cfg.fLocalMaskFileName.Data());
+ out << cfg.fLocalMaskFileName.Data() << endl;
}
- file = gLocalLutFileName;
- if ((gLocalLutFileLastVersion != gLocalLutFileVersion) || initFES) {
+ file = cfg.fLocalLutFileName;
+ if ((cfg.fLocalLutFileLastVersion != cfg.fLocalLutFileVersion) || 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.fLocalLutFileName.Data());
return false;
}
- if(gPrintLevel) printf("Export file: %s\n",gLocalLutFileName.Data());
- out << gLocalLutFileName.Data() << endl;
+ if(cfg.fPrintLevel) printf("Export file: %s\n",cfg.fLocalLutFileName.Data());
+ out << cfg.fLocalLutFileName.Data() << endl;
}
// exported regional file whenever mask or/and Lut are modified
- file = gRegionalFileName;
- if ( (gRegionalFileLastVersion != gRegionalFileVersion) || modified || initFES) {
+ file = cfg.fRegionalFileName;
+ if ( (cfg.fRegionalFileLastVersion != cfg.fRegionalFileVersion) || 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.fRegionalFileName.Data());
return false;
}
- if(gPrintLevel) printf("Export file: %s\n",gRegionalFileName.Data());
- out << gRegionalFileName.Data() << endl;
+ if(cfg.fPrintLevel) printf("Export file: %s\n",cfg.fRegionalFileName.Data());
+ out << cfg.fRegionalFileName.Data() << 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.fPrintLevel) printf("Export file: %s\n",fileExp.Data());
// write last current file
- WriteLastCurrentFile();
+ WriteLastCurrentFile(cfg,cfg.fLastCurrentFileName);
return true;
}
//__________________
-Bool_t ImportFiles()
+Bool_t ImportFiles(DAConfig& cfg)
{
// copy locally a file from daq detector config db
// The current detector is identified by detector code in variable
// offline:
//gSystem->Setenv("DAQDALIB_PATH", "$DATE_SITE/db");
- // offline: take the first two files from the local db
- //gSystem->Unsetenv("DAQDA_TEST_DIR");
-
- status = daqDA_DB_getFile(gCurrentFileName.Data(), gCurrentFileName.Data());
+ status = daqDA_DB_getFile(cfg.fDAConfigFileName.Data(), cfg.fDAConfigFileName.Data());
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.fDAConfigFileName.Data());
return false;
}
- ReadFileNames();
+ ReadDAConfig(cfg);
- status = daqDA_DB_getFile(gGlobalFileName.Data(), gGlobalFileName.Data());
+ status = daqDA_DB_getFile(cfg.fCurrentFileName.Data(), cfg.fCurrentFileName.Data());
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.fCurrentFileName.Data());
return false;
}
+
+ ReadFileNames(cfg);
- // offline: take the other files from the special local storage (not db)
- //gSystem->Setenv("DAQDA_TEST_DIR", "/alisoft/Mts-files");
+ status = daqDA_DB_getFile(cfg.fGlobalFileName.Data(), cfg.fGlobalFileName.Data());
+ if (status) {
+ printf("Failed to get current config file from DB: %s\n", cfg.fGlobalFileName.Data());
+ return false;
+ }
- status = daqDA_DB_getFile(gRegionalFileName.Data(), gRegionalFileName.Data());
+ status = daqDA_DB_getFile(cfg.fRegionalFileName.Data(), cfg.fRegionalFileName.Data());
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.fRegionalFileName.Data());
return false;
}
- status = daqDA_DB_getFile(gLocalMaskFileName.Data(), gLocalMaskFileName.Data());
+ status = daqDA_DB_getFile(cfg.fLocalMaskFileName.Data(), cfg.fLocalMaskFileName.Data());
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.fLocalMaskFileName.Data());
return false;
}
- status = daqDA_DB_getFile(gLocalLutFileName.Data(), gLocalLutFileName.Data());
+ status = daqDA_DB_getFile(cfg.fLocalLutFileName.Data(), cfg.fLocalLutFileName.Data());
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.fLocalLutFileName.Data());
return false;
}
}
//_____________
-void ReadMaskFiles()
+void ReadMaskFiles(DAConfig& cfg)
{
+
// read mask files
- gLocalMasks = new AliMUON1DArray(gkNLocalBoard);
- gRegionalMasks = new AliMUONRegionalTriggerConfig();
- gGlobalMasks = new AliMUONGlobalCrateConfig();
+ cfg.fLocalMasks = new AliMUON1DArray(cfg.fNLocalBoard);
+ cfg.fRegionalMasks = new AliMUONRegionalTriggerConfig();
+ cfg.fGlobalMasks = new AliMUONGlobalCrateConfig();
- TString localFile = gLocalMaskFileName;
- TString regionalFile = gRegionalFileName;
- TString globalFile = gGlobalFileName;
+ TString localFile = cfg.fLocalMaskFileName;
+ TString regionalFile = cfg.fRegionalFileName;
+ TString globalFile = cfg.fGlobalFileName;
- gTriggerIO.ReadConfig(localFile.Data(), regionalFile.Data(), globalFile.Data(),
- gLocalMasks, gRegionalMasks, gGlobalMasks);
+ cfg.fTriggerIO->ReadConfig(localFile.Data(), regionalFile.Data(), globalFile.Data(),
+ cfg.fLocalMasks, cfg.fRegionalMasks, cfg.fGlobalMasks);
}
//______________________________________________________________
-UInt_t GetFetMode()
+UInt_t GetFetMode(DAConfig& cfg)
{
// FET mode = 3 to run algorithm for dead global inputs
// 0x3 prepulse
// 0x0 internal
- return gGlobalMasks->GetFetRegister(3);
+ return cfg.fGlobalMasks->GetFetRegister(3);
}
//______________________________________________________________
-void StoreGlobalInput(UInt_t *globalInput)
+void StoreGlobalInput(DAConfig& cfg, const UInt_t * const globalInput)
{
// accumulate and build statistics of global input values
- for (Int_t ii = 0; ii < gkGlobalInputs; ii++) {
- for (Int_t ib = 0; ib < gkGlobalInputLength; ib++) {
+ for (Int_t ii = 0; ii < cfg.kGlobalInputs; ii++) {
+ for (Int_t ib = 0; ib < cfg.kGlobalInputLength; ib++) {
// lsb -> msb
- if (gAlgoNoisyInput)
- gAccGlobalInputN[ii][ib] += (globalInput[ii] >> ib) & 0x1;
- if (gAlgoDeadInput)
- gAccGlobalInputD[ii][ib] += (globalInput[ii] >> ib) & 0x1;
+ if (cfg.fAlgoNoisyInput)
+ cfg.fAccGlobalInputN[ii][ib] += (globalInput[ii] >> ib) & 0x1;
+ if (cfg.fAlgoDeadInput)
+ cfg.fAccGlobalInputD[ii][ib] += (globalInput[ii] >> ib) & 0x1;
}
}
}
//______________________________________________________________
-void UpdateGlobalMasks()
+void UpdateGlobalMasks(DAConfig& cfg)
{
// update the global masks
// 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 < gkGlobalInputs; ii++) {
+ for (Int_t ii = 0; ii < cfg.kGlobalInputs; ii++) {
gmask[ii] = 0;
- for (Int_t ib = 0; ib < gkGlobalInputLength; ib++) {
+ for (Int_t ib = 0; ib < cfg.kGlobalInputLength; ib++) {
// lsb -> msb
noise = false;
deadc = false;
withEvN = false;
withEvD = false;
- if (gNEventsN > gkMinEvents) {
- rateN = (Float_t)gAccGlobalInputN[ii][ib]/(Float_t)gNEventsN;
- noise = (rateN > gkThrN);
+ if (cfg.fNEventsN > cfg.fMinEvents) {
+ rateN = (Float_t)cfg.fAccGlobalInputN[ii][ib]/(Float_t)cfg.fNEventsN;
+ noise = (rateN > cfg.fThrN);
withEvN = true;
}
- if (gNEventsD > gkMinEvents) {
- rateD = (Float_t)gAccGlobalInputD[ii][ib]/(Float_t)gNEventsD;
- deadc = (rateD < (1.0-gkThrD));
+ if (cfg.fNEventsD > cfg.fMinEvents) {
+ rateD = (Float_t)cfg.fAccGlobalInputD[ii][ib]/(Float_t)cfg.fNEventsD;
+ deadc = (rateD < cfg.fThrD);
withEvD = true;
}
if (!withEvN && !withEvD) {
// - copy the bit from the old mask
- gmask[ii] |= ((gGlobalMasks->GetGlobalMask(ii) >> ib) & 0x1) << ib;
+ gmask[ii] |= ((cfg.fGlobalMasks->GetGlobalMask(ii) >> ib) & 0x1) << ib;
printf("Mask not changed (just copy the old values)\n");
}
if (!withEvN && withEvD) {
// not allowed!
//gmask[ii] |= 0x1 << ib;
// - copy the bit from the old mask
- gmask[ii] |= ((gGlobalMasks->GetGlobalMask(ii) >> ib) & 0x1) << ib;
+ gmask[ii] |= ((cfg.fGlobalMasks->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 \n",ii,ib);
+ printf("Found dead channel %1d:%02d (%4.2f) \n",ii,ib,rateD);
}
}
if (withEvN && !withEvD) {
// not allowed!
//gmask[ii] |= 0x1 << ib;
// - copy the bit from the old mask
- gmask[ii] |= ((gGlobalMasks->GetGlobalMask(ii) >> ib) & 0x1) << ib;
+ gmask[ii] |= ((cfg.fGlobalMasks->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 \n",ii,ib);
+ printf("Found noisy channel %1d:%02d (%4.2f) \n",ii,ib,rateN);
}
}
if (withEvN && withEvD) {
// not allowed!
//gmask[ii] |= 0x1 << ib;
// - copy the bit from the old mask
- gmask[ii] |= ((gGlobalMasks->GetGlobalMask(ii) >> ib) & 0x1) << ib;
+ gmask[ii] |= ((cfg.fGlobalMasks->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 \n",ii,ib);
+ printf("Found noisy channel %1d:%02d (%4.2f) \n",ii,ib,rateN);
if (deadc)
- printf("Found dead channel %1d:%02d \n",ii,ib);
+ printf("Found dead channel %1d:%02d (%4.2f) \n",ii,ib,rateD);
}
}
}
- printf("Global mask [%1d] %08x \n",ii,gmask[ii]);
}
// check if at least one mask value has been changed from previous version
- for (Int_t ii = 0; ii < gkGlobalInputs; ii++) {
- omask = gGlobalMasks->GetGlobalMask(ii);
+ for (Int_t ii = 0; ii < cfg.kGlobalInputs; ii++) {
+ printf("Global mask [%1d] %08x \n",ii,gmask[ii]);
+ omask = cfg.fGlobalMasks->GetGlobalMask(ii);
if (gmask[ii] != omask) {
updated = true;
- gGlobalMasks->SetGlobalMask(ii,gmask[ii]);
+ cfg.fGlobalMasks->SetGlobalMask(ii,gmask[ii]);
}
}
if (updated) {
// update version
- gGlobalFileVersion++;
+ cfg.fGlobalFileVersion++;
// don't change the file version ("-x.dat")
- gTriggerIO.WriteGlobalConfig(gGlobalFileName,gGlobalMasks);
+ cfg.fTriggerIO->WriteGlobalConfig(cfg.fGlobalFileName,cfg.fGlobalMasks);
// write last current file
- WriteLastCurrentFile(gCurrentFileName);
+ WriteLastCurrentFile(cfg,cfg.fCurrentFileName);
- status = daqDA_DB_storeFile(gGlobalFileName.Data(), gGlobalFileName.Data());
+ status = daqDA_DB_storeFile(cfg.fGlobalFileName.Data(), cfg.fGlobalFileName.Data());
if (status) {
- printf("Failed to export file to DB: %s\n",gGlobalFileName.Data());
+ printf("Failed to export file to DB: %s\n",cfg.fGlobalFileName.Data());
return;
}
- status = daqDA_DB_storeFile(gCurrentFileName.Data(), gCurrentFileName.Data());
+ status = daqDA_DB_storeFile(cfg.fCurrentFileName.Data(), cfg.fCurrentFileName.Data());
if (status) {
- printf("Failed to export file to DB: %s\n",gCurrentFileName.Data());
+ printf("Failed to export file to DB: %s\n",cfg.fCurrentFileName.Data());
return;
}
{
// needed for streamer application
- gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo", "*", "TStreamerInfo",
- "RIO", "TStreamerInfo()");
+ gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo", "*", "TStreamerInfo", "RIO", "TStreamerInfo()");
+
+ /* check that we got some arguments = list of files */
+ if (argc<2) {
+ printf("Wrong number of arguments\n");
+ return -1;
+ }
+
+ DAConfig cfg;
- Int_t skipEvents = 0;
- Int_t maxEvents = 1000000;
- Int_t withWarnings = 0;
Char_t inputFile[256] = "";
inputFile[0] = 0;
if (argc > 1)
printf("MUONTRGda : No input File !\n");
return -1;
}
- TString flatOutputFile;
-
-// option handler
-
- // 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 'p' :
- i++;
- gkThrD = atof(argv[i]);
- break;
- case 'c' :
- i++;
- gkThrN = atof(argv[i]);
- break;
- case 'l' :
- i++;
- gPrintLevel=atoi(argv[i]);
- break;
- case 's' :
- i++;
- skipEvents=atoi(argv[i]);
- break;
- case 'n' :
- i++;
- sscanf(argv[i],"%d",&maxEvents);
- break;
- case 'w' :
- i++;
- sscanf(argv[i],"%d",&withWarnings);
- 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>");
- printf("\n");
- printf("\n Output");
- printf("\n");
- printf("\n Options");
- printf("\n-p <thr value ped (deadc)> (default = %3.1f)",gkThrD);
- printf("\n-c <thr value cal (noise)> (default = %3.1f)",gkThrN);
- printf("\n-l <print level> (default = %d)",gPrintLevel);
- printf("\n-s <skip events> (default = %d)",skipEvents);
- printf("\n-n <max events> (default = %d)",maxEvents);
- printf("\n-w <decoder warnings> (default = %d)",withWarnings);
-
- 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
// decoding the events
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();
+
+ ReadMaskFiles(cfg);
// offline: the run number extracted from the file name
//TString tmp(inputFile);
//tmp = tmp(pos+3,5);
//gSystem->Setenv("DATE_RUN_NUMBER",tmp.Data());
//gSystem->Exec("echo \"DATE_RUN_NUMBER = \" $DATE_RUN_NUMBER");
-
- if(!ExportFiles()) {
+
+ if(!ExportFiles(cfg)) {
printf("ExportFiles failed\n");
return -1;
}
// FET is triggered by CTP
- if (GetFetMode() != 3) {
+ if (GetFetMode(cfg) != 3) {
printf("FET is not in mode 3\n");
return -1;
}
// All 5 global cards are controlled by the Mts proxy
- if (gGlobalMasks->GetGlobalCrateEnable() != 0x1F) {
+ if (cfg.fGlobalMasks->GetGlobalCrateEnable() != 0x1F) {
printf("The MTS proxy does not control all global cards\n");
return -1;
}
// The global cards are ON (active on the global inputs)
- if (!gGlobalMasks->GetMasksOn()) {
+ if (!cfg.fGlobalMasks->GetMasksOn()) {
printf("Global masks are not ON\n");
return -1;
}
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.fMaxEvents) 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.fSkipEvents) {
status = monitorGetEventDynamic(&event);
- skipEvents--;
+ cfg.fSkipEvents--;
}
// starts reading
AliRawReader *rawReader = new AliRawReaderDate(event);
Int_t eventType = rawReader->GetType();
- gRunNumber = rawReader->GetRunNumber();
+ runNumber = rawReader->GetRunNumber();
// L1Swc1
// CALIBRATION_EVENT
// SYSTEM_SOFTWARE_TRIGGER_EVENT
// DETECTOR_SOFTWARE_TRIGGER_EVENT
- gAlgoNoisyInput = false;
- gAlgoDeadInput = false;
+ cfg.fAlgoNoisyInput = false;
+ cfg.fAlgoDeadInput = false;
if (eventType == PHYSICS_EVENT) {
- gAlgoNoisyInput = true;
+ cfg.fAlgoNoisyInput = true;
doUpdate = true;
- gNEventsN++;
+ cfg.fNEventsN++;
} else if (eventType == CALIBRATION_EVENT) {
- gAlgoDeadInput = true;
+ cfg.fAlgoDeadInput = true;
doUpdate = true;
- gNEventsD++;
- if (gRunNumber == 61963) { // FET overwrite, not used for dead channels
- gAlgoNoisyInput = true;
- gNEventsN++;
- gAlgoDeadInput = false;
- gNEventsD--;
- }
+ cfg.fNEventsD++;
} else {
continue;
}
- gNEvents++;
- if (gPrintLevel) printf("\nEvent # %d\n",gNEvents);
+ nEvents++;
+ if (cfg.fPrintLevel) printf("\nEvent # %d\n",nEvents);
// decoding MUON payload
AliMUONRawStreamTrigger* rawStream = new AliMUONRawStreamTrigger(rawReader);
// ... without warnings from the decoder !!!
- if (!withWarnings)
+ if (!cfg.fWithWarnings)
rawStream->DisableWarnings();
// loops over DDL
while((status = rawStream->NextDDL())) {
- if (gPrintLevel) printf("iDDL %d\n", rawStream->GetDDL());
+ if (cfg.fPrintLevel) printf("iDDL %d\n", rawStream->GetDDL());
ddlTrigger = rawStream->GetDDLTrigger();
darcHeader = ddlTrigger->GetDarcHeader();
if (rawStream->GetDDL() == 0) {
- if (gPrintLevel) printf("Global output %x\n", (Int_t)darcHeader->GetGlobalOutput());
+ if (cfg.fPrintLevel) printf("Global output %x\n", (Int_t)darcHeader->GetGlobalOutput());
globalInput = darcHeader->GetGlobalInput();
- StoreGlobalInput(globalInput);
+ StoreGlobalInput(cfg,globalInput);
}
} // NextDDL
} // while (1)
// update configuration files ifrequested event types were found
- if (doUpdate && gDAFlag)
- UpdateGlobalMasks();
+ if (doUpdate && cfg.fDAFlag)
+ UpdateGlobalMasks(cfg);
timers.Stop();
- cout << "MUONTRGda : Run number : " << gRunNumber << endl;
- cout << "MUONTRGda : Nb of DATE events = " << nDateEvents << endl;
- cout << "MUONTRGda : Nb of events used = " << gNEvents << endl;
- cout << "MUONTRGda : Nb of events used (noise) = " << gNEventsN << endl;
- cout << "MUONTRGda : Nb of events used (deadc) = " << gNEventsD << endl;
- cout << "Threshold for noisy inputs : " << gkThrN << " of the total number of used events (noise)" << endl;
- cout << "Threshold for dead inputs : " << gkThrD << " of the total number of used events (deadc)" << endl;
-
- printf("Execution time : R:%7.2fs C:%7.2fs\n", timers.RealTime(), timers.CpuTime());
-
- delete gLocalMasks;
- delete gRegionalMasks;
- delete gGlobalMasks;
+ cout << "MUONTRGda: DA enable: \t" << cfg.fDAFlag << 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.fNEventsN << endl;
+ cout << "MUONTRGda: Nb of events used (deadc): \t" << cfg.fNEventsD << endl;
+ cout << "MUONTRGda: Minumum nr of events for rate calculation: \t" << cfg.fMinEvents << endl;
+ cout << "MUONTRGda: Maximum nr of analyzed events: \t" << cfg.fMaxEvents << endl;
+ cout << "MUONTRGda: Skip events from start: \t" << cfg.fSkipEvents << endl;
+ cout << "MUONTRGda: Threshold for noisy inputs: \t" << 100*cfg.fThrN << "%" << endl;
+ cout << "MUONTRGda: Threshold for dead inputs: \t" << 100*cfg.fThrD << "%" << endl;
+ cout << "MUONTRGda: Print level: \t" << cfg.fPrintLevel << endl;
+ cout << "MUONTRGda: Show decoder warnings: \t" << cfg.fWithWarnings << endl;
+
+ printf("MUONTRGda: Execution time : R:%7.2fs C:%7.2fs\n", timers.RealTime(), timers.CpuTime());
+
+ delete cfg.fLocalMasks;
+ delete cfg.fRegionalMasks;
+ delete cfg.fGlobalMasks;
+ delete cfg.fTriggerIO;
return status;