2 EMCAL DA for online calibration: for pedestal studies
4 Contact: silvermy@ornl.gov
7 Number of events needed: ~1000
8 Frequency: expect to run this once per day initially
9 (maybe less frequent later)
10 Input Files: argument list
11 Output Files: RESULT_FILE=EMCALPED.root, to be exported to the DAQ FXS
12 fileId: FILE_ID=EMCALPED
14 Trigger types used: at least for now, all events in special PEDESTAL run
15 (physics, calibration, systemSoftwareTrigger, detectorSoftwareTrigger)
16 [When we have real data files later, we may restrict this further]
19 This process reads RAW data from the files provided as command line arguments
20 and save results (class itself) in a file (named from RESULT_FILE define
24 #define RESULT_FILE "EMCALPED.root"
25 #define FILE_ID "EMCALPED"
26 #define AliDebugLevel() -1
27 #define FILE_PEDClassName "emcCalibPedestal"
29 /* LOCAL_DEBUG is used to bypass daq* calls, for local testing */
30 //#define LOCAL_DEBUG 1 // comment out to run normally
35 #include "event.h" /* in $DATE_COMMON_DEFS/; includes definition of event types */
36 #include "monitor.h" /* in $DATE_MONITOR_DIR/; monitor* interfaces */
44 #include <TPluginManager.h>
50 #include "AliRawReader.h"
51 #include "AliRawReaderDate.h"
52 #include "AliRawEventHeaderBase.h"
53 #include "AliCaloRawStream.h"
54 #include "AliCaloAltroMapping.h"
58 // EMC calibration-helper algorithm includes
60 #include "AliCaloCalibPedestal.h"
63 Main routine, EMC pedestal detector algorithm
64 Arguments: list of DATE raw data files
67 int main(int argc, char **argv) {
69 AliLog::SetClassDebugLevel("AliCaloRawStream",-5);
70 AliLog::SetClassDebugLevel("AliRawReaderDate",-5);
71 AliLog::SetModuleDebugLevel("RAW",-5);
74 printf("Wrong number of arguments\n");
78 /* magic line - for TStreamerInfo */
79 gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
87 /* log start of process */
88 printf("EMCAL DA started - %s\n",__FILE__);
90 /* declare monitoring program */
91 status=monitorDeclareMp( __FILE__ );
93 printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
96 /* define wait event timeout - 1s max */
98 monitorSetNoWaitNetworkTimeout(1000);
100 /* Retrieve mapping files from DAQ DB */
101 const char* mapFiles[kNRCU] = {"RCU0.data","RCU1.data"};
103 for(Int_t iFile=0; iFile<kNRCU; iFile++) {
104 int failed = daqDA_DB_getFile(mapFiles[iFile], mapFiles[iFile]);
106 printf("Cannot retrieve file %d : %s from DAQ DB. Exit now..\n",
107 iFile, mapFiles[iFile]);
115 /* Open mapping files */
116 AliCaloAltroMapping *mapping[kNRCU];
120 for(Int_t i = 0; i < kNRCU; i++) {
124 mapping[i] = new AliCaloAltroMapping(path2.Data());
127 /* set up our analysis class */
128 AliCaloCalibPedestal * calibPedestal = new AliCaloCalibPedestal(AliCaloCalibPedestal::kEmCal); // pedestal and noise calibration
129 calibPedestal->SetAltroMapping( mapping );
131 AliRawReader *rawReader = NULL;
134 /* loop over RAW data files */
135 for ( i=1; i<argc; i++ ) {
137 /* define data source : this is argument i */
138 printf("Processing file %s\n", argv[i]);
139 status=monitorSetDataSource( argv[i] );
141 printf("monitorSetDataSource() failed. Error=%s. Exiting ...\n", monitorDecodeError(status));
146 struct eventHeaderStruct *event;
147 eventTypeType eventT;
149 for ( ; ; ) { // infinite loop
151 /* check shutdown condition */
152 if (daqDA_checkShutdown()) {break;}
154 /* get next event (blocking call until timeout) */
155 status=monitorGetEventDynamic((void **)&event);
156 if (status==MON_ERR_EOF) {
157 printf ("End of File %d (%s) detected\n", i, argv[i]);
158 break; /* end of monitoring file has been reached */
161 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
165 /* retry if got no event */
169 eventT = event->eventType; /* just convenient shorthand */
171 /* skip start/end of run events */
172 if ( (eventT != physicsEvent) && (eventT != calibrationEvent) &&
173 (eventT != systemSoftwareTriggerEvent) && (eventT != detectorSoftwareTriggerEvent) ) {
177 nevents++; // count how many acceptable events we have
179 // Pedestal calibration
180 rawReader = new AliRawReaderDate((void*)event);
181 calibPedestal->ProcessEvent(rawReader);
191 // write class to rootfile
194 printf ("%d physics/calibration events processed.\n",nevents);
196 TFile f(RESULT_FILE, "recreate");
199 calibPedestal->Write(FILE_PEDClassName);
201 printf("Object saved to file \"%s\" as \"%s\".\n",
202 RESULT_FILE, FILE_PEDClassName);
205 printf("Could not save the object to file \"%s\".\n",
210 // closing down; see if we can delete our analysis helper also
212 delete calibPedestal;
213 for(Int_t iFile=0; iFile<kNRCU; iFile++) {
214 if (mapping[iFile]) delete mapping[iFile];
217 /* store the result file on FES */
220 status = daqDA_FES_storeFile(RESULT_FILE, FILE_ID);