2 EMCAL DA for online calibration: for LED studies
4 Contact: silvermy@ornl.gov
5 Run Type: PHYSICS or STANDALONE
7 Number of events needed: continously accumulating for all runs, rate ~0.1-1 Hz
8 Input Files: argument list
9 Output Files: RESULT_FILE=EMCALLED.root, to be exported to the DAQ FXS
10 fileId: FILE_ID=EMCALLED
11 Trigger types used: CALIBRATION_EVENT
14 This process reads RAW data from the files provided as command line arguments
15 and save results (class itself) in a file (named from RESULT_FILE define -
19 #define RESULT_FILE "EMCALLED.root"
20 #define FILE_ID "signal"
21 #define AliDebugLevel() -1
22 #define FILE_SIGClassName "emcCalibSignal"
24 /* LOCAL_DEBUG is used to bypass daq* calls that do not work locally */
25 //#define LOCAL_DEBUG 1 // comment out to run normally
29 #include "event.h" /* in $DATE_COMMON_DEFS/; includes definition of event types */
30 #include "monitor.h" /* in $DATE_MONITOR_DIR/; monitor* interfaces */
38 #include <TPluginManager.h>
44 #include "AliRawReader.h"
45 #include "AliRawReaderDate.h"
46 #include "AliRawEventHeaderBase.h"
47 #include "AliCaloRawStreamV3.h"
48 #include "AliCaloAltroMapping.h"
52 // EMC calibration-helper algorithm includes
54 #include "AliCaloCalibSignal.h"
57 Main routine, EMC signal detector algorithm
58 Arguments: list of DATE raw data files
61 int main(int argc, char **argv) {
63 AliLog::SetClassDebugLevel("AliCaloRawStreamV3",-5);
64 AliLog::SetClassDebugLevel("AliRawReaderDate",-5);
65 AliLog::SetModuleDebugLevel("RAW",-5);
68 printf("Wrong number of arguments\n");
72 /* magic line - for TStreamerInfo */
73 gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
81 /* log start of process */
82 printf("EMCAL DA started - %s\n",__FILE__);
84 /* declare monitoring program */
85 status=monitorDeclareMp( __FILE__ );
87 printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
90 /* define wait event timeout - 1s max */
92 monitorSetNoWaitNetworkTimeout(1000);
94 /* Retrieve mapping files from DAQ DB */
95 const char* mapFiles[kNRCU] = {"RCU0A.data","RCU1A.data","RCU0C.data","RCU1C.data"};
97 for(Int_t iFile=0; iFile<kNRCU; iFile++) {
98 int failed = daqDA_DB_getFile(mapFiles[iFile], mapFiles[iFile]);
100 printf("Cannot retrieve file %d : %s from DAQ DB. Exit now..\n",
101 iFile, mapFiles[iFile]);
109 /* Open mapping files */
110 AliCaloAltroMapping *mapping[kNRCU];
114 TString side[] = {"A","C"};//+ and - pseudorapidity supermodules
115 for(Int_t j = 0; j < 2; j++){
116 for(Int_t i = 0; i < 2; i++) {
121 mapping[j*2 + i] = new AliCaloAltroMapping(path2.Data());
125 /* Retrieve cut=parameter file from DAQ DB */
126 const char* parameterFile = {"EMCALLEDda.dat"};
128 int failed = daqDA_DB_getFile(parameterFile, parameterFile);
130 printf("Cannot retrieve file : %s from DAQ DB. Exit now..\n",
138 /* set up our analysis classes */
139 AliCaloCalibSignal * calibSignal = new AliCaloCalibSignal(AliCaloCalibSignal::kEmCal);
140 calibSignal->SetAltroMapping( mapping );
141 calibSignal->SetParametersFromFile( parameterFile );
143 AliRawReader *rawReader = NULL;
146 /* loop over RAW data files */
147 for ( i=1; i<argc; i++ ) {
149 /* define data source : this is argument i */
150 printf("Processing file %s\n", argv[i]);
151 status=monitorSetDataSource( argv[i] );
153 printf("monitorSetDataSource() failed. Error=%s. Exiting ...\n", monitorDecodeError(status));
158 struct eventHeaderStruct *event;
159 eventTypeType eventT;
161 for ( ; ; ) { // infinite loop
163 /* check shutdown condition */
164 if (daqDA_checkShutdown()) {break;}
166 /* get next event (blocking call until timeout) */
167 status=monitorGetEventDynamic((void **)&event);
168 if (status==MON_ERR_EOF) {
169 printf ("End of File %d (%s) detected\n", i, argv[i]);
170 break; /* end of monitoring file has been reached */
173 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
177 /* retry if got no event */
181 eventT = event->eventType; /* just convenient shorthand */
183 /* only look at calibration events */
184 if ( eventT != calibrationEvent ) {
188 nevents++; // count how many acceptable events we have
190 // Signal calibration
191 rawReader = new AliRawReaderDate((void*)event);
192 calibSignal->SetRunNumber(event->eventRunNb);
193 calibSignal->ProcessEvent(rawReader);
202 // calculate average values also, for the LED info
203 calibSignal->SetUseAverage(kTRUE);
204 calibSignal->Analyze();
206 // by default, we only save the full info in debug mode
209 // reset the full trees, when we are not in debug mode
210 calibSignal->GetTreeAmpVsTime()->Reset();
211 calibSignal->GetTreeLEDAmpVsTime()->Reset();
215 // write class to rootfile
218 printf ("%d calibration events processed.\n",nevents);
220 TFile f(RESULT_FILE, "recreate");
223 calibSignal->Write(FILE_SIGClassName);
225 printf("Objects saved to file \"%s\" as \"%s\".\n",
226 RESULT_FILE, FILE_SIGClassName);
229 printf("Could not save the object to file \"%s\".\n",
234 // closing down; see if we can delete our analysis helper(s) also
237 for(Int_t iFile=0; iFile<kNRCU; iFile++) {
238 if (mapping[iFile]) delete mapping[iFile];
241 /* store the result file on FES */
244 status = daqDA_FES_storeFile(RESULT_FILE, FILE_ID);