2 TPC DA for online calibration
4 Contact: Haavard.Helstrup@cern.ch
6 Run Type: PHYSICS_RUN STANDALONE DAQ
8 Number of events needed: 500
10 Output Files: tpcCE.root, to be exported to the DAQ FXS
11 Trigger types used: PHYSICS_EVENT
17 TPCCEda.cxx - calibration algorithm for TPC Central Electrode events
19 10/06/2007 sylvain.chapeland@cern.ch : first version - clean skeleton based on DAQ DA case1
20 06/12/2007 haavard.helstrup@cern.ch : created CE DA based on pulser code
22 contact: marian.ivanov@cern.ch
25 This process reads RAW data from the files provided as command line arguments
26 and save results in a file (named from RESULT_FILE define - see below).
30 #define RESULT_FILE "tpcCE.root"
31 #define MAPPING_FILE "tpcMapping.root"
45 #include "TPluginManager.h"
49 #include "AliRawReader.h"
50 #include "AliRawReaderDate.h"
51 #include "AliTPCmapper.h"
52 #include "AliTPCRawStream.h"
53 #include "AliTPCROC.h"
54 #include "AliTPCCalROC.h"
55 #include "AliTPCCalPad.h"
56 #include "AliMathBase.h"
57 #include "TTreeStream.h"
60 // TPC calibration algorithm includes
62 #include "AliTPCCalibCE.h"
68 Arguments: list of DATE raw data files
70 int main(int argc, char **argv) {
72 gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
81 /* copy locally the mapping file from daq detector config db */
82 status = daqDA_DB_getFile(MAPPING_FILE,"./tpcMapping.root");
84 printf("Failed to get mapping file (%s) from DAQdetDB, status=%d\n", MAPPING_FILE, status);
85 printf("Continue anyway ... maybe it works?\n"); // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
86 //return -1; // temporarily uncommented for testing on pcald47 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
89 /* open the mapping file and retrieve mapping object */
90 AliTPCmapper *mapping = 0; // The TPC mapping
91 TFile *fileMapping = new TFile(MAPPING_FILE, "read");
92 mapping = (AliTPCmapper*) fileMapping->Get("tpcMapping");
94 printf("Failed to get mapping object from %s. Exiting ...\n", MAPPING_FILE);
98 printf("Got mapping object from %s\n", MAPPING_FILE);
102 AliTPCCalibCE calibCE; // pedestal and noise calibration
105 printf("Wrong number of arguments\n");
110 /* log start of process */
111 printf("TPC CE DA started - %s\n",__FILE__);
114 /* set time bin range */
115 calibCE.SetRangeTime(800,940);
116 calibCE.SetAltroMapping(mapping->GetAltroMapping()); // Use altro mapping we got from daqDetDb
118 /* declare monitoring program */
119 status=monitorDeclareMp( __FILE__ );
121 printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
126 /* loop over RAW data files */
128 for(i=1;i<argc;i++) {
130 /* define data source : this is argument i */
131 printf("Processing file %s\n", argv[i]);
132 status=monitorSetDataSource( argv[i] );
134 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
140 struct eventHeaderStruct *event;
142 /* check shutdown condition */
143 if (daqDA_checkShutdown()) {break;}
145 /* get next event (blocking call until timeout) */
146 status=monitorGetEventDynamic((void **)&event);
147 if (status==MON_ERR_EOF) {
148 printf ("End of File %d detected\n",i);
149 break; /* end of monitoring file has been reached */
153 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
157 /* retry if got no event */
163 // Pulser calibration
165 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
166 calibCE.ProcessEvent(rawReader);
175 printf ("%d events processed\n",nevents);
177 TFile * fileTPC = new TFile (RESULT_FILE,"recreate");
178 calibCE.Write("calibCE");
180 printf("Wrote %s\n",RESULT_FILE);
182 /* store the result file on FES */
184 status=daqDA_FES_storeFile(RESULT_FILE,RESULT_FILE);