5 This program reads the DAQ data files passed as argument using the monitoring library.
6 It stores the required event information into an output file.
7 Messages on stdout are exported to DAQ log system.
9 contact: Hisayuki.Torii@cern.ch
20 #include "AliRawReader.h"
21 #include "AliRawReaderDate.h"
22 #include "AliPHOSRawDecoder.h"
23 #include "AliCaloAltroMapping.h"
24 #include "AliPHOSDApi0mip.h"
27 Arguments: list of DATE raw data files
29 int main(int argc, char **argv) {
33 /* log start of process */
34 printf("PHOSPHYSda program started\n");
36 /* Time out counters*/
37 int timeout = 180; // 3mins
38 time_t start_time = time(0);
40 /* check that we got some arguments = list of files */
42 printf("Wrong number of arguments\n");
47 /* Retrieve mapping files from DAQ DB */
48 const char* mapFiles[4] = {"RCU0.data","RCU1.data","RCU2.data","RCU3.data"};
49 for(Int_t iFile=0; iFile<4; iFile++) {
50 int failed = daqDA_DB_getFile(mapFiles[iFile], mapFiles[iFile]);
52 printf("Cannot retrieve file %s from DAQ DB. Exit.\n",mapFiles[iFile]);
57 /* Open mapping files */
58 AliAltroMapping *mapping[4];
62 for(Int_t i = 0; i < 4; i++) {
66 mapping[i] = new AliCaloAltroMapping(path2.Data());
70 daqDA_progressReport(10);
72 /* init some counters */
73 int nevents_physics=0;
77 AliRawReader *rawReader = NULL;
79 /* Prepare DA algorithm */
81 AliPHOSDApi0mip* dapi0mip = new AliPHOSDApi0mip(iMod);
83 /* read the data files */
84 for(int n=1;n<argc;n++) {
85 status=monitorSetDataSource( argv[n] );
87 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
92 /* in this example, indexed on the number of files */
93 daqDA_progressReport(10+80*(n-1)/argc);
97 struct eventHeaderStruct *event;
101 status=monitorGetEventDynamic((void **)&event);
102 if (status==MON_ERR_EOF) break; /* end of monitoring file has been reached */
104 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
108 /* retry if got no event */
114 // This is just for debugging
115 //if( nevents_total%1000 == 0 ){
116 //daqDA_progressReport(10+80*(n-1)/argc+nevents_total/10000);
117 //printf(" DEBUGDEBUG:: next event %d\n",nevents_total);
122 t = event->eventTimestamp;
123 dapi0mip->SetTime(t);
125 /* Applying into DA algorithm */
127 eventT=event->eventType;
128 if (eventT==PHYSICS_EVENT || eventT==CALIBRATION_EVENT) {
129 // ---------------------------------------------------------------
130 // User Defined Function
131 // ---------------------------------------------------------------
132 dapi0mip->NewEvent();
133 rawReader = new AliRawReaderDate((void*)event);
134 //AliPHOSRawDecoderv1 dc(rawReader,mapping);
135 AliPHOSRawDecoder dc(rawReader,mapping);
136 dc.SubtractPedestals(false);
137 while(dc.NextDigit()) {
139 ix = dc.GetRow() - 1;
140 iz = dc.GetColumn() - 1;
141 if(dc.IsLowGain()) igain = 0; else igain = 1;
143 dapi0mip->FillDigit(dc.GetEnergy(),ix,iz);
148 //dapi0mip->FillHist(); // This is not necesarry in this DA algorithm
149 dapi0mip->FillTree();
150 //if( nevents_total%1000 == 0 ){ // Dump for debugging
153 // ---------------------------------------------------------------
158 /* Check the time out */
159 if( nevents_total%1000 == 0 ){
160 time_t current_time = time(0);
161 if( current_time - start_time > timeout ){
163 printf(" Warning: Exit due to the processing time exceed the limitation of %d sec\n",timeout);
175 /* report progress */
176 daqDA_progressReport(90);
178 /* Delete DA algorithm for saving output into a file */
181 /* Store output files to the File Exchange Server */
182 char localfile[1024];
183 char remotefile[1024];
184 sprintf(localfile,"AliPHOSDApi0mip_mod%d.root",iMod);
185 sprintf(remotefile,"PHOSDApi0mip",iMod);
186 daqDA_FES_storeFile(localfile,remotefile);
188 /* report progress */
189 daqDA_progressReport(100);