fColumns(0),
fRows(0),
fModules(0),
+ fCaloString(),
+ fMapping(NULL),
fRunNumber(-1)
{
//Default constructor. First we set the detector-type related constants.
fColumns = fgkPhosCols;
fRows = fgkPhosRows;
fModules = fgkPhosModules;
+ fCaloString = "PHOS";
}
else {
//We'll just trust the enum to keep everything in line, so that if detectorType
fColumns = fgkEmCalCols;
fRows = fgkEmCalRows;
fModules = fgkEmCalModules;
+ fCaloString = "EMCAL";
}
fDetType = detectorType;
fColumns(ped.GetColumns()),
fRows(ped.GetRows()),
fModules(ped.GetModules()),
+ fCaloString(ped.GetCaloString()),
+ fMapping(NULL), //! note that we are not copying the map info
fRunNumber(ped.GetRunNumber())
{
// Then the ObjArray ones; we add the histograms rather than trying TObjArray = assignment
return kTRUE;//We succesfully added info from the supplied object
}
+//_____________________________________________________________________
+Bool_t AliCaloCalibPedestal::ProcessEvent(AliRawReader *rawReader)
+{
+ // if fMapping is NULL the rawstream will crate its own mapping
+ AliCaloRawStream rawStream(rawReader, fCaloString, (AliAltroMapping**)fMapping);
+ return ProcessEvent(&rawStream);
+}
+
//_____________________________________________________________________
Bool_t AliCaloCalibPedestal::ProcessEvent(AliCaloRawStream *in)
{
#include "TH2.h"
#include "TObjArray.h"
class AliCaloRawStream;
+class AliCaloAltroMapping;
+class AliRawReader;
class AliCaloCalibPedestal : public TObject {
//Functions to ask for the constants (in case a GUI needs them, for an example
static const int GetSampleMax() {return fgkSampleMax;};
static const int GetSampleMin() {return fgkSampleMin;};
-
+
+ // Event processing methods:
+ Bool_t ProcessEvent(AliRawReader *rawReader);
Bool_t ProcessEvent(AliCaloRawStream *in);
+ // Mapping handling
+ AliCaloAltroMapping **GetAltroMapping() { return fMapping; };
+ void SetAltroMapping(AliCaloAltroMapping **mapp) { fMapping = mapp; };
+
////////////////////////////
//Simple getters
// Main profiles:
// Basic info: getters
kDetType GetDetectorType() const {return fDetType;};//Returns if this is a PHOS or EMCAL object
+ TString GetCaloString() const {return fCaloString;}; //Returns if this is a PHOS or EMCAL object
int GetColumns() const {return fColumns;}; //The number of columns per module
int GetRows() const {return fRows;}; //The number of rows per module
int fColumns; //The number of columns per module
int fRows; //The number of rows per module
int fModules; //The number of modules
+ TString fCaloString; // id for which detector type we have
+ AliCaloAltroMapping **fMapping; //! Altro Mapping object
int fRunNumber; //The run number. Needs to be set by the user.
-
+
//Constants needed by the class
static const int fgkSampleMax = 1023; // highest possible sample value (10-bit = 0x3ff)
static const int fgkSampleMin = 0; // lowest possible sample value
#include "TFile.h"
+#include "AliRawReader.h"
#include "AliRawEventHeaderBase.h"
#include "AliCaloRawStream.h"
fColumns(0),
fRows(0),
fModules(0),
+ fCaloString(),
+ fMapping(NULL),
fRunNumber(-1),
fStartTime(0),
fAmpCut(50),
fColumns = fgkPhosCols;
fRows = fgkPhosRows;
fModules = fgkPhosModules;
+ fCaloString = "PHOS";
}
else {
//We'll just trust the enum to keep everything in line, so that if detectorType
fColumns = fgkEmCalCols;
fRows = fgkEmCalRows;
fModules = fgkEmCalModules;
+ fCaloString = "EMCAL";
}
fDetType = detectorType;
fColumns(sig.GetColumns()),
fRows(sig.GetRows()),
fModules(sig.GetModules()),
+ fCaloString(sig.GetCaloString()),
+ fMapping(NULL), //! note that we are not copying the map info
fRunNumber(sig.GetRunNumber()),
fStartTime(sig.GetStartTime()),
fAmpCut(sig.GetAmpCut()),
return kTRUE;//We succesfully added info from the supplied object
}
+//_____________________________________________________________________
+Bool_t AliCaloCalibSignal::ProcessEvent(AliRawReader *rawReader)
+{
+ // if fMapping is NULL the rawstream will crate its own mapping
+ AliCaloRawStream rawStream(rawReader, fCaloString, (AliAltroMapping**)fMapping);
+
+ return ProcessEvent( &rawStream, (AliRawEventHeaderBase*)rawReader->GetEventHeader() );
+}
//_____________________________________________________________________
Bool_t AliCaloCalibSignal::ProcessEvent(AliCaloRawStream *in, AliRawEventHeaderBase *aliHeader)
#include "TGraph.h"
#include "TProfile.h"
class AliCaloRawStream;
+class AliCaloAltroMapping;
+class AliRawReader;
class AliRawEventHeaderBase;
class AliCaloCalibSignal : public TObject {
AliCaloCalibSignal(const AliCaloCalibSignal &sig); // copy ctor
AliCaloCalibSignal& operator = (const AliCaloCalibSignal &source); //!
+ // Event processing methods:
+ Bool_t ProcessEvent(AliRawReader *rawReader);
Bool_t ProcessEvent(AliCaloRawStream *in, AliRawEventHeaderBase *aliHeader); // added header for time info
Bool_t CheckFractionAboveAmp(int *AmpVal, int nTotChan); // check fraction of signals to check for LED events
+ // Mapping handling
+ AliCaloAltroMapping **GetAltroMapping() { return fMapping; };
+ void SetAltroMapping(AliCaloAltroMapping **mapp) { fMapping = mapp; };
+
////////////////////////////
//Simple getters
// need public access to the TGraphs..
// Basic info: getters
kDetType GetDetectorType() const {return fDetType;};//Returns if this is a PHOS or EMCAL object
-
+ TString GetCaloString() const {return fCaloString;}; //Returns if this is a PHOS or EMCAL object
+
int GetColumns() const {return fColumns;}; //The number of columns per module
int GetRows() const {return fRows;}; //The number of rows per module
int GetModules() const {return fModules;}; //The number of modules
int fColumns; //The number of columns per module
int fRows; //The number of rows per module
int fModules; //The number of modules
+ TString fCaloString; // id for which detector type we have
+ AliCaloAltroMapping **fMapping; //! Altro Mapping object
int fRunNumber; //The run number. Needs to be set by the user.
int fStartTime; // Time of first event
Contact: silvermy@ornl.gov
Run Type: PHYSICS or STANDALONE
- DA Type: LDC
+ DA Type: MON
Number of events needed: ~1000
Input Files: argument list
Output Files: RESULT_FILE=EMCALCalibSignal.root, to be exported to the DAQ FXS
#define FILE_ID "EMCALCalibSignal"
#define AliDebugLevel() -1
#define FILE_ClassName "emcCalibSignal"
-
+const int kNRCU = 2;
+/* LOCAL_DEBUG is used to bypass daq* calls that do not work locally */
+// #define LOCAL_DEBUG 1 // comment out to run normally
extern "C" {
#include <daqDA.h>
}
#include "stdio.h"
#include "stdlib.h"
+// ROOT includes
+#include <TFile.h>
+#include <TROOT.h>
+#include <TPluginManager.h>
+#include <TSystem.h>
+
//
//AliRoot includes
//
#include "AliRawReaderDate.h"
#include "AliRawEventHeaderBase.h"
#include "AliCaloRawStream.h"
+#include "AliCaloAltroMapping.h"
#include "AliLog.h"
//
// EMC calibration-helper algorithm includes
//
#include "AliCaloCalibSignal.h"
-#include <TFile.h> // ROOT
/*
- Main routine, EMC signal detector algorithm to be run on EMC LDC
+ Main routine, EMC signal detector algorithm
Arguments: list of DATE raw data files
*/
if (argc<2) {
printf("Wrong number of arguments\n");
- return -1;
+ return -1;
}
+ /* magic line - for TStreamerInfo */
+ gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
+ "*",
+ "TStreamerInfo",
+ "RIO",
+ "TStreamerInfo()");
+
int i, status;
/* log start of process */
printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
return -1;
}
+ /* define wait event timeout - 1s max */
+ monitorSetNowait();
+ monitorSetNoWaitNetworkTimeout(1000);
+
+ /* Retrieve mapping files from DAQ DB */
+ const char* mapFiles[kNRCU] = {"RCU0.data","RCU1.data"};
+
+ for(Int_t iFile=0; iFile<kNRCU; iFile++) {
+ int failed = daqDA_DB_getFile(mapFiles[iFile], mapFiles[iFile]);
+ if(failed) {
+ printf("Cannot retrieve file %d : %s from DAQ DB. Exit now..\n",
+ iFile, mapFiles[iFile]);
+#ifdef LOCAL_DEBUG
+#else
+ return -1;
+#endif
+ }
+ }
+
+ /* Open mapping files */
+ AliCaloAltroMapping *mapping[kNRCU];
+ TString path = "./";
+ path += "RCU";
+ TString path2;
+ for(Int_t i = 0; i < kNRCU; i++) {
+ path2 = path;
+ path2 += i;
+ path2 += ".data";
+ mapping[i] = new AliCaloAltroMapping(path2.Data());
+ }
+
+ /* set up our analysis class */
+ AliCaloCalibSignal * calibSignal = new AliCaloCalibSignal(AliCaloCalibSignal::kEmCal);
+ calibSignal->SetAltroMapping( mapping );
- AliCaloCalibSignal * calibSignal = new
- AliCaloCalibSignal(AliCaloCalibSignal::kEmCal); // signal and noise calibration
+ AliRawReader *rawReader = NULL;
+ int nevents=0;
/* loop over RAW data files */
- int nevents=0;
for ( i=1; i<argc; i++ ) {
/* define data source : this is argument i */
printf("Processing file %s\n", argv[i]);
-
- AliRawReader *rawReader = new AliRawReaderDate(argv[i]);
- AliCaloRawStream *in = new AliCaloRawStream(rawReader,"EMCAL");
- AliRawEventHeaderBase *aliHeader=NULL;
+ status=monitorSetDataSource( argv[i] );
+ if (status!=0) {
+ printf("monitorSetDataSource() failed. Error=%s. Exiting ...\n", monitorDecodeError(status));
+ return -1;
+ }
/* read until EOF */
- while ( rawReader->NextEvent() ) {
+ struct eventHeaderStruct *event;
+ eventTypeType eventT;
+
+ for ( ; ; ) { // infinite loop
/* check shutdown condition */
if (daqDA_checkShutdown()) {break;}
- aliHeader = (AliRawEventHeaderBase*) rawReader->GetEventHeader();
-
- // select physics and calibration events now (only calibration in future)
- // For running on testbeam files: we don't have any event classifications then: commented out selection with //DS below
- //DS if ( aliHeader->Get("Type") == AliRawEventHeaderBase::kPhysicsEvent || aliHeader->Get("Type") == AliRawEventHeaderBase::kCalibrationEvent ) {
-
- nevents++;
-
- // Signal calibration
- calibSignal->ProcessEvent(in, aliHeader);
- //DS } // event selection
- } // loop over all events in file
- /* cleanup the reading handles */
- delete in;
- delete rawReader;
+ /* get next event (blocking call until timeout) */
+ status=monitorGetEventDynamic((void **)&event);
+ if (status==MON_ERR_EOF) {
+ printf ("End of File %d (%s) detected\n", i, argv[i]);
+ break; /* end of monitoring file has been reached */
+ }
+ if (status!=0) {
+ printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
+ break;
+ }
+
+ /* retry if got no event */
+ if (event==NULL) {
+ continue;
+ }
+ eventT = event->eventType; // just shorthand
+
+ /* skip start/end of run events */
+ if ( (eventT != physicsEvent) && (eventT != calibrationEvent) ) {
+ continue;
+ }
+
+ nevents++; // count how many acceptable events we have
+
+ // Signal calibration
+ rawReader = new AliRawReaderDate((void*)event);
+ calibSignal->ProcessEvent(rawReader);
+ delete rawReader;
+
+ /* free resources */
+ free(event);
+
+ } //until EOF
} // loop over files
//
printf("Could not save the object to file \"%s\".\n", RESULT_FILE);
}
- /* store the result file on FES */
- status = daqDA_FES_storeFile(RESULT_FILE, FILE_ID);
-
// see if we can delete our analysis helper also
delete calibSignal;
+ for(Int_t iFile=0; iFile<kNRCU; iFile++) {
+ if (mapping[iFile]) delete mapping[iFile];
+ }
+
+ /* store the result file on FES */
+#ifdef LOCAL_DEBUG
+#else
+ status = daqDA_FES_storeFile(RESULT_FILE, FILE_ID);
+#endif
return status;
}
Contact: silvermy@ornl.gov
Run Type: PEDESTAL or PHYSICS or STANDALONE
- DA Type: LDC
+ DA Type: LDC (PEDESTAL), MON (PHYSICS or STANDALONE)
Number of events needed: ~1000
Input Files: argument list
Output Files: RESULT_FILE=EMCALCalibPedestal.root, to be exported to the DAQ FXS
#define FILE_ID "EMCALCalibPedestal"
#define AliDebugLevel() -1
#define FILE_ClassName "emcCalibPedestal"
+const int kNRCU = 2;
+/* LOCAL_DEBUG is used to bypass daq* calls, for local testing */
+// #define LOCAL_DEBUG 1 // comment out to run normally
extern "C" {
#include <daqDA.h>
#include "stdio.h"
#include "stdlib.h"
+// ROOT includes
+#include <TFile.h>
+#include <TROOT.h>
+#include <TPluginManager.h>
+#include <TSystem.h>
+
//
//AliRoot includes
//
#include "AliRawReaderDate.h"
#include "AliRawEventHeaderBase.h"
#include "AliCaloRawStream.h"
+#include "AliCaloAltroMapping.h"
#include "AliLog.h"
//
// EMC calibration-helper algorithm includes
//
#include "AliCaloCalibPedestal.h"
-#include <TFile.h> // ROOT
/*
- Main routine, EMC pedestal detector algorithm to be run on EMC LDC
+ Main routine, EMC pedestal detector algorithm
Arguments: list of DATE raw data files
*/
if (argc<2) {
printf("Wrong number of arguments\n");
- return -1;
+ return -1;
}
+ /* magic line - for TStreamerInfo */
+ gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
+ "*",
+ "TStreamerInfo",
+ "RIO",
+ "TStreamerInfo()");
+
int i, status;
/* log start of process */
printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
return -1;
}
+ /* define wait event timeout - 1s max */
+ monitorSetNowait();
+ monitorSetNoWaitNetworkTimeout(1000);
+
+ /* Retrieve mapping files from DAQ DB */
+ const char* mapFiles[kNRCU] = {"RCU0.data","RCU1.data"};
+
+ for(Int_t iFile=0; iFile<kNRCU; iFile++) {
+ int failed = daqDA_DB_getFile(mapFiles[iFile], mapFiles[iFile]);
+ if(failed) {
+ printf("Cannot retrieve file %d : %s from DAQ DB. Exit now..\n",
+ iFile, mapFiles[iFile]);
+#ifdef LOCAL_DEBUG
+#else
+ return -1;
+#endif
+ }
+ }
+
+ /* Open mapping files */
+ AliCaloAltroMapping *mapping[kNRCU];
+ TString path = "./";
+ path += "RCU";
+ TString path2;
+ for(Int_t i = 0; i < kNRCU; i++) {
+ path2 = path;
+ path2 += i;
+ path2 += ".data";
+ mapping[i] = new AliCaloAltroMapping(path2.Data());
+ }
+
+ /* set up our analysis class */
+ AliCaloCalibPedestal * calibPedestal = new AliCaloCalibPedestal(AliCaloCalibPedestal::kEmCal); // pedestal and noise calibration
+ calibPedestal->SetAltroMapping( mapping );
- AliCaloCalibPedestal * calibPedestal = new
- AliCaloCalibPedestal(AliCaloCalibPedestal::kEmCal); // pedestal and noise calibration
+ AliRawReader *rawReader = NULL;
+ int nevents=0;
/* loop over RAW data files */
- int nevents=0;
for ( i=1; i<argc; i++ ) {
/* define data source : this is argument i */
printf("Processing file %s\n", argv[i]);
-
- AliRawReader *rawReader = new AliRawReaderDate(argv[i]);
- AliCaloRawStream *in = new AliCaloRawStream(rawReader,"EMCAL");
- AliRawEventHeaderBase *aliHeader=NULL;
+ status=monitorSetDataSource( argv[i] );
+ if (status!=0) {
+ printf("monitorSetDataSource() failed. Error=%s. Exiting ...\n", monitorDecodeError(status));
+ return -1;
+ }
/* read until EOF */
- while ( rawReader->NextEvent() ) {
+ struct eventHeaderStruct *event;
+ eventTypeType eventT;
+
+ for ( ; ; ) { // infinite loop
/* check shutdown condition */
if (daqDA_checkShutdown()) {break;}
- aliHeader = (AliRawEventHeaderBase*) rawReader->GetEventHeader();
-
- // select physics and calibration events now (only calibration in future)
- // For running on testbeam files: we don't have any event classifications then: commented out selection with //DS below
- //DS if ( aliHeader->Get("Type") == AliRawEventHeaderBase::kPhysicsEvent || aliHeader->Get("Type") == AliRawEventHeaderBase::kCalibrationEvent ) {
-
- nevents++;
-
- // Pedestal calibration
- calibPedestal->ProcessEvent(in);
- //DS } // event selection
- } // loop over all events in file
- /* cleanup the reading handles */
- delete in;
- delete rawReader;
+ /* get next event (blocking call until timeout) */
+ status=monitorGetEventDynamic((void **)&event);
+ if (status==MON_ERR_EOF) {
+ printf ("End of File %d (%s) detected\n", i, argv[i]);
+ break; /* end of monitoring file has been reached */
+ }
+ if (status!=0) {
+ printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
+ break;
+ }
+
+ /* retry if got no event */
+ if (event==NULL) {
+ continue;
+ }
+ eventT = event->eventType; // just shorthand
+
+ /* skip start/end of run events */
+ if ( (eventT != physicsEvent) && (eventT != calibrationEvent) ) {
+ continue;
+ }
+
+ nevents++; // count how many acceptable events we have
+
+ // Pedestal calibration
+ rawReader = new AliRawReaderDate((void*)event);
+ calibPedestal->ProcessEvent(rawReader);
+ delete rawReader;
+
+ /* free resources */
+ free(event);
+
+ } //until EOF
} // loop over files
//
printf("Could not save the object to file \"%s\".\n", RESULT_FILE);
}
- /* store the result file on FES */
- status = daqDA_FES_storeFile(RESULT_FILE, FILE_ID);
-
// see if we can delete our analysis helper also
delete calibPedestal;
+ for(Int_t iFile=0; iFile<kNRCU; iFile++) {
+ if (mapping[iFile]) delete mapping[iFile];
+ }
+
+ /* store the result file on FES */
+#ifdef LOCAL_DEBUG
+#else
+ status = daqDA_FES_storeFile(RESULT_FILE, FILE_ID);
+#endif
return status;
}