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 (temporarily also PHYSICS_EVENT to start with)
12 [When we have real data files later, we should only use CALIBRATION_EVENT]
15 This process reads RAW data from the files provided as command line arguments
16 and save results (class itself) in a file (named from RESULT_FILE define -
20 #define RESULT_FILE "EMCALLED.root"
21 #define FILE_ID "signal"
22 #define AliDebugLevel() -1
23 #define FILE_SIGClassName "emcCalibSignal"
25 /* LOCAL_DEBUG is used to bypass daq* calls that do not work locally */
26 //#define LOCAL_DEBUG 1 // comment out to run normally
30 #include "event.h" /* in $DATE_COMMON_DEFS/; includes definition of event types */
31 #include "monitor.h" /* in $DATE_MONITOR_DIR/; monitor* interfaces */
39 #include <TPluginManager.h>
45 #include "AliRawReader.h"
46 #include "AliRawReaderDate.h"
47 #include "AliRawEventHeaderBase.h"
48 #include "AliCaloRawStreamV3.h"
49 #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) {
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 /* declare monitoring program */
86 status=monitorDeclareMp( __FILE__ );
88 printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
91 /* define wait event timeout - 1s max */
93 monitorSetNoWaitNetworkTimeout(1000);
95 /* Retrieve mapping files from DAQ DB */
96 const char* mapFiles[kNRCU] = {"RCU0A.data","RCU1A.data","RCU0C.data","RCU1C.data"};
98 for(Int_t iFile=0; iFile<kNRCU; iFile++) {
99 int failed = daqDA_DB_getFile(mapFiles[iFile], mapFiles[iFile]);
101 printf("Cannot retrieve file %d : %s from DAQ DB. Exit now..\n",
102 iFile, mapFiles[iFile]);
110 /* Open mapping files */
111 AliCaloAltroMapping *mapping[kNRCU];
115 TString side[] = {"A","C"};//+ and - pseudorapidity supermodules
116 for(Int_t j = 0; j < 2; j++){
117 for(Int_t i = 0; i < 2; i++) {
122 mapping[j*2 + i] = new AliCaloAltroMapping(path2.Data());
126 /* Retrieve cut=parameter file from DAQ DB */
127 const char* parameterFile = {"EMCALLEDda.dat"};
129 int failed = daqDA_DB_getFile(parameterFile, parameterFile);
131 printf("Cannot retrieve file : %s from DAQ DB. Exit now..\n",
139 /* set up our analysis classes */
140 AliCaloCalibSignal * calibSignal = new AliCaloCalibSignal(AliCaloCalibSignal::kEmCal);
141 calibSignal->SetAltroMapping( mapping );
142 calibSignal->SetParametersFromFile( parameterFile );
144 AliRawReader *rawReader = NULL;
147 /* loop over RAW data files */
148 for ( i=1; i<argc; i++ ) {
150 /* define data source : this is argument i */
151 printf("Processing file %s\n", argv[i]);
152 status=monitorSetDataSource( argv[i] );
154 printf("monitorSetDataSource() failed. Error=%s. Exiting ...\n", monitorDecodeError(status));
159 struct eventHeaderStruct *event;
160 eventTypeType eventT;
162 for ( ; ; ) { // infinite loop
164 /* check shutdown condition */
165 if (daqDA_checkShutdown()) {break;}
167 /* get next event (blocking call until timeout) */
168 status=monitorGetEventDynamic((void **)&event);
169 if (status==MON_ERR_EOF) {
170 printf ("End of File %d (%s) detected\n", i, argv[i]);
171 break; /* end of monitoring file has been reached */
174 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
178 /* retry if got no event */
182 eventT = event->eventType; /* just convenient shorthand */
184 /* skip start/end of run events */
185 if ( (eventT != physicsEvent) && (eventT != calibrationEvent) ) {
189 nevents++; // count how many acceptable events we have
191 // Signal calibration
192 rawReader = new AliRawReaderDate((void*)event);
193 calibSignal->SetRunNumber(event->eventRunNb);
194 calibSignal->ProcessEvent(rawReader);
203 // calculate average values also, for the LED info
204 calibSignal->SetUseAverage(kTRUE);
205 calibSignal->Analyze();
207 // by default, we only save the full info in debug mode
210 // reset the full trees, when we are not in debug mode
211 calibSignal->GetTreeAmpVsTime()->Reset();
212 calibSignal->GetTreeLEDAmpVsTime()->Reset();
216 // write class to rootfile
219 printf ("%d physics/calibration events processed.\n",nevents);
221 TFile f(RESULT_FILE, "recreate");
224 calibSignal->Write(FILE_SIGClassName);
226 printf("Objects saved to file \"%s\" as \"%s\".\n",
227 RESULT_FILE, FILE_SIGClassName);
230 printf("Could not save the object to file \"%s\".\n",
235 // closing down; see if we can delete our analysis helper(s) also
238 for(Int_t iFile=0; iFile<kNRCU; iFile++) {
239 if (mapping[iFile]) delete mapping[iFile];
242 /* store the result file on FES */
245 status = daqDA_FES_storeFile(RESULT_FILE, FILE_ID);