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"
53 // EMC calibration-helper algorithm includes
55 #include "AliCaloCalibSignal.h"
58 Main routine, EMC signal detector algorithm
59 Arguments: list of DATE raw data files
62 int main(int argc, char **argv) { // Main routine, EMC signal detector algorithm
64 AliLog::SetClassDebugLevel("AliCaloRawStreamV3",-5);
65 AliLog::SetClassDebugLevel("AliRawReaderDate",-5);
66 AliLog::SetModuleDebugLevel("RAW",-5);
69 printf("Wrong number of arguments\n");
73 /* magic line - for TStreamerInfo */
74 gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
82 /* log start of process */
83 printf("EMCAL DA started - %s\n",__FILE__);
85 Int_t emcID = AliDAQ::DetectorID("EMCAL"); // bit 18..
87 /* declare monitoring program */
88 status=monitorDeclareMp( __FILE__ );
90 printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
93 /* define wait event timeout - 1s max */
95 monitorSetNoWaitNetworkTimeout(1000);
97 /* Retrieve mapping files from DAQ DB */
98 const char* mapFiles[kNRCU] = {"RCU0A.data","RCU1A.data","RCU0C.data","RCU1C.data"};
100 for(Int_t iFile=0; iFile<kNRCU; iFile++) {
101 int failed = daqDA_DB_getFile(mapFiles[iFile], mapFiles[iFile]);
103 printf("Cannot retrieve file %d : %s from DAQ DB. Exit now..\n",
104 iFile, mapFiles[iFile]);
112 /* Open mapping files */
113 AliCaloAltroMapping *mapping[kNRCU];
117 TString side[] = {"A","C"};//+ and - pseudorapidity supermodules
118 for(Int_t j = 0; j < 2; j++){
119 for(Int_t i = 0; i < 2; i++) {
124 mapping[j*2 + i] = new AliCaloAltroMapping(path2.Data());
128 /* Retrieve cut=parameter file from DAQ DB */
129 const char* parameterFile = {"EMCALLEDda.dat"};
131 int failed = daqDA_DB_getFile(parameterFile, parameterFile);
133 printf("Cannot retrieve file : %s from DAQ DB. Exit now..\n",
141 /* set up our analysis classes */
142 AliCaloCalibSignal * calibSignal = new AliCaloCalibSignal(AliCaloCalibSignal::kEmCal);
143 calibSignal->SetAltroMapping( mapping );
144 calibSignal->SetParametersFromFile( parameterFile );
146 AliRawReader *rawReader = NULL;
149 /* loop over RAW data files */
150 for ( i=1; i<argc; i++ ) {
152 /* define data source : this is argument i */
153 printf("Processing file %s\n", argv[i]);
154 status=monitorSetDataSource( argv[i] );
156 printf("monitorSetDataSource() failed. Error=%s. Exiting ...\n", monitorDecodeError(status));
161 struct eventHeaderStruct *event;
162 eventTypeType eventT;
164 for ( ; ; ) { // infinite loop
166 /* check shutdown condition */
167 if (daqDA_checkShutdown()) {break;}
169 /* get next event (blocking call until timeout) */
170 status=monitorGetEventDynamic((void **)&event);
171 if (status==MON_ERR_EOF) {
172 printf ("End of File %d (%s) detected\n", i, argv[i]);
173 break; /* end of monitoring file has been reached */
176 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
180 /* retry if got no event */
184 eventT = event->eventType; /* just convenient shorthand */
185 /* only look at calibration events */
186 if ( eventT != calibrationEvent ) {
191 /* only look at events where EMCAL was included */
192 if (! TEST_DETECTOR_IN_PATTERN(event->eventDetectorPattern, emcID) ) {
197 nevents++; // count how many acceptable events we have
199 // Signal calibration
200 rawReader = new AliRawReaderDate((void*)event);
201 calibSignal->SetRunNumber(event->eventRunNb);
202 calibSignal->ProcessEvent(rawReader);
211 // calculate average values also, for the LED info
212 calibSignal->SetUseAverage(kTRUE);
213 calibSignal->Analyze();
215 // by default, we only save the full info in debug mode
218 // reset the full trees, when we are not in debug mode
219 calibSignal->GetTreeAmpVsTime()->Reset();
220 calibSignal->GetTreeLEDAmpVsTime()->Reset();
224 // write class to rootfile
227 printf ("%d calibration events processed.\n",nevents);
229 TFile f(RESULT_FILE, "recreate");
232 calibSignal->Write(FILE_SIGClassName);
234 printf("Objects saved to file \"%s\" as \"%s\".\n",
235 RESULT_FILE, FILE_SIGClassName);
238 printf("Could not save the object to file \"%s\".\n",
243 // closing down; see if we can delete our analysis helper(s) also
246 for(Int_t iFile=0; iFile<kNRCU; iFile++) {
247 if (mapping[iFile]) delete mapping[iFile];
250 /* store the result file on FES */
253 status = daqDA_FES_storeFile(RESULT_FILE, FILE_ID);