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
12 Trigger types used: PHYSICS_EVENT
18 TPCCEda.cxx - calibration algorithm for TPC Central Electrode events
20 10/06/2007 sylvain.chapeland@cern.ch : first version - clean skeleton based on DAQ DA case1
21 06/12/2007 haavard.helstrup@cern.ch : created CE DA based on pulser code
23 contact: marian.ivanov@cern.ch
26 This process reads RAW data from the files provided as command line arguments
27 and save results in a file (named from RESULT_FILE define - see below).
31 #define RESULT_FILE "tpcCE.root"
33 #define MAPPING_FILE "tpcMapping.root"
47 #include "TPluginManager.h"
51 #include "AliRawReader.h"
52 #include "AliRawReaderDate.h"
53 #include "AliTPCmapper.h"
54 #include "AliTPCRawStream.h"
55 #include "AliTPCROC.h"
56 #include "AliTPCCalROC.h"
57 #include "AliTPCCalPad.h"
58 #include "AliMathBase.h"
59 #include "TTreeStream.h"
64 // TPC calibration algorithm includes
66 #include "AliTPCCalibCE.h"
72 Arguments: list of DATE raw data files
74 int main(int argc, char **argv) {
76 gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
82 AliLog::SetClassDebugLevel("AliTPCRawStream",-5);
83 AliLog::SetClassDebugLevel("AliRawReaderDate",-5);
84 AliLog::SetClassDebugLevel("AliTPCAltroMapping",-5);
85 AliLog::SetModuleDebugLevel("RAW",-5);
88 AliTPCmapper *mapping = 0; // The TPC mapping
89 // if test setup get parameters from $DAQDA_TEST_DIR
92 /* copy locally the mapping file from daq detector config db */
93 status = daqDA_DB_getFile(MAPPING_FILE,"./tpcMapping.root");
95 printf("Failed to get mapping file (%s) from DAQdetDB, status=%d\n", MAPPING_FILE, status);
96 printf("Continue anyway ... maybe it works?\n"); // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
97 return -1; // temporarily uncommented for testing on pcald47 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
100 /* open the mapping file and retrieve mapping object */
101 TFile *fileMapping = new TFile(MAPPING_FILE, "read");
102 mapping = (AliTPCmapper*) fileMapping->Get("tpcMapping");
107 printf("Failed to get mapping object from %s. ...\n", MAPPING_FILE);
110 printf("Got mapping object from %s\n", MAPPING_FILE);
114 AliTPCCalibCE calibCE; // pedestal and noise calibration
117 printf("Wrong number of arguments\n");
122 /* log start of process */
123 printf("TPC CE DA started - %s\n",__FILE__);
126 /* set time bin range */
127 calibCE.SetRangeTime(800,940);
128 calibCE.SetAltroMapping(mapping->GetAltroMapping()); // Use altro mapping we got from daqDetDb
130 /* declare monitoring program */
131 status=monitorDeclareMp( __FILE__ );
133 printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
138 /* loop over RAW data files */
140 for(i=1;i<argc;i++) {
142 /* define data source : this is argument i */
143 printf("Processing file %s\n", argv[i]);
144 status=monitorSetDataSource( argv[i] );
146 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
152 struct eventHeaderStruct *event;
154 /* check shutdown condition */
155 if (daqDA_checkShutdown()) {break;}
157 /* get next event (blocking call until timeout) */
158 status=monitorGetEventDynamic((void **)&event);
159 if (status==MON_ERR_EOF) {
160 printf ("End of File %d detected\n",i);
161 break; /* end of monitoring file has been reached */
165 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
169 /* retry if got no event */
175 // Pulser calibration
177 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
178 calibCE.ProcessEvent(rawReader);
187 printf ("%d events processed\n",nevents);
189 TFile * fileTPC = new TFile (RESULT_FILE,"recreate");
190 calibCE.Write("calibCE");
192 printf("Wrote %s\n",RESULT_FILE);
194 /* store the result file on FES */
196 status=daqDA_FES_storeFile(RESULT_FILE,FILE_ID);