/* PHOSPHYSda.cxx This program reads the DAQ data files passed as argument using the monitoring library. It stores the required event information into an output file. Messages on stdout are exported to DAQ log system. contact: Hisayuki.Torii@cern.ch */ #include "event.h" #include "monitor.h" #include "daqDA.h" #include #include #include "AliRawReader.h" #include "AliRawReaderDate.h" #include "AliPHOSRawDecoder.h" #include "AliCaloAltroMapping.h" #include "AliPHOSDApi0mip.h" /* Main routine Arguments: list of DATE raw data files */ int main(int argc, char **argv) { int status; /* log start of process */ printf("PHOSPHYSda program started\n"); /* Time out counters*/ int timeout = 180; // 3mins time_t start_time = time(0); /* check that we got some arguments = list of files */ if (argc<2) { printf("Wrong number of arguments\n"); return -1; } /* Retrieve mapping files from DAQ DB */ const char* mapFiles[4] = {"RCU0.data","RCU1.data","RCU2.data","RCU3.data"}; for(Int_t iFile=0; iFile<4; iFile++) { int failed = daqDA_DB_getFile(mapFiles[iFile], mapFiles[iFile]); if(failed) { printf("Cannot retrieve file %s from DAQ DB. Exit.\n",mapFiles[iFile]); return -1; } } /* Open mapping files */ AliAltroMapping *mapping[4]; TString path = "./"; path += "RCU"; TString path2; for(Int_t i = 0; i < 4; i++) { path2 = path; path2 += i; path2 += ".data"; mapping[i] = new AliCaloAltroMapping(path2.Data()); } /* report progress */ daqDA_progressReport(10); /* init some counters */ int nevents_physics=0; int nevents_total=0; /* init PHOS reader*/ AliRawReader *rawReader = NULL; /* Prepare DA algorithm */ int iMod = 0; AliPHOSDApi0mip* dapi0mip = new AliPHOSDApi0mip(iMod); /* read the data files */ for(int n=1;neventTimestamp; dapi0mip->SetTime(t); /* Applying into DA algorithm */ int ix, iz, igain; eventT=event->eventType; if (eventT==PHYSICS_EVENT || eventT==CALIBRATION_EVENT) { // --------------------------------------------------------------- // User Defined Function // --------------------------------------------------------------- dapi0mip->NewEvent(); rawReader = new AliRawReaderDate((void*)event); //AliPHOSRawDecoderv1 dc(rawReader,mapping); AliPHOSRawDecoder dc(rawReader,mapping); dc.SubtractPedestals(false); while(dc.NextDigit()) { //printf("."); ix = dc.GetRow() - 1; iz = dc.GetColumn() - 1; if(dc.IsLowGain()) igain = 0; else igain = 1; if( igain == 1 ){ dapi0mip->FillDigit(dc.GetEnergy(),ix,iz); } //dc.GetTime(); } delete rawReader; //dapi0mip->FillHist(); // This is not necesarry in this DA algorithm dapi0mip->FillTree(); //if( nevents_total%1000 == 0 ){ // Dump for debugging //dapi0mip->Print(); //} // --------------------------------------------------------------- nevents_physics++; } nevents_total++; /* Check the time out */ if( nevents_total%1000 == 0 ){ time_t current_time = time(0); if( current_time - start_time > timeout ){ free(event); printf(" Warning: Exit due to the processing time exceed the limitation of %d sec\n",timeout); n = argc; break; } } /* free resources */ free(event); } } /* report progress */ daqDA_progressReport(90); /* Delete DA algorithm for saving output into a file */ delete dapi0mip; /* Store output files to the File Exchange Server */ char localfile[1024]; char remotefile[1024]; sprintf(localfile,"AliPHOSDApi0mip_mod%d.root",iMod); sprintf(remotefile,"PHOSDApi0mip",iMod); daqDA_FES_storeFile(localfile,remotefile); /* report progress */ daqDA_progressReport(100); return status; }