2 TPC DA for online calibration
4 Contact: Haavard.Helstrup@cern.ch
8 Number of events needed: 100
10 Output Files: tpcPulser.root, to be exported to the DAQ FXS
11 Trigger types used: CALIBRATION_EVENT
17 TPCda_pulser.cxx - calibration algorithm for TPC pulser events
19 10/06/2007 sylvain.chapeland@cern.ch : first version - clean skeleton based on DAQ DA case1
20 30/09/2007 haavard.helstrup@cern.ch : created pulser DA based on pedestal 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 "tpcPulser.root"
31 #define MAPPING_FILE "tpcMapping.root"
32 #define AliDebugLevel() -1
46 #include "TPluginManager.h"
50 #include "AliRawReader.h"
51 #include "AliRawReaderDate.h"
52 #include "AliTPCmapper.h"
53 #include "AliTPCRawStream.h"
54 #include "AliTPCROC.h"
55 #include "AliTPCCalROC.h"
56 #include "AliTPCCalPad.h"
57 #include "AliMathBase.h"
58 #include "TTreeStream.h"
63 // TPC calibration algorithm includes
65 #include "AliTPCCalibPulser.h"
71 Arguments: list of DATE raw data files
73 int main(int argc, char **argv) {
74 AliLog::SetClassDebugLevel("AliTPCRawStream",AliLog::kFatal);
75 AliLog::SetClassDebugLevel("AliRawReaderDate",AliLog::kFatal);
76 AliLog::SetClassDebugLevel("AliTPCAltroMapping",AliLog::kFatal);
77 AliLog::SetModuleDebugLevel("TPC",AliLog::kFatal);
78 AliLog::SetModuleDebugLevel("RAW",AliLog::kFatal);
80 gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
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 AliTPCCalibPulser calibPulser; // pedestal and noise calibration
117 printf("Wrong number of arguments\n");
122 /* log start of process */
123 printf("TPC Pulser DA started - %s\n",__FILE__);
125 /* set time bin range */
126 calibPulser.SetRangeTime(400,500);
127 calibPulser.SetAltroMapping(mapping->GetAltroMapping()); // Use altro mapping we got from daqDetDb
128 /* declare monitoring program */
129 status=monitorDeclareMp( __FILE__ );
131 printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
136 /* loop over RAW data files */
138 for(i=1;i<argc;i++) {
140 /* define data source : this is argument i */
141 printf("Processing file %s\n", argv[i]);
142 status=monitorSetDataSource( argv[i] );
144 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
150 struct eventHeaderStruct *event;
152 /* check shutdown condition */
153 if (daqDA_checkShutdown()) {break;}
155 /* get next event (blocking call until timeout) */
156 status=monitorGetEventDynamic((void **)&event);
157 if (status==MON_ERR_EOF) {
158 printf ("End of File %d detected\n",i);
159 break; /* end of monitoring file has been reached */
163 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
167 /* retry if got no event */
173 // Pulser calibration
175 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
176 // calibPulser.ProcessEvent(rawReader);
177 calibPulser.ProcessEventFast(rawReader);
185 calibPulser.Analyse();
186 printf ("%d events processed\n",nevents);
188 TFile * fileTPC = new TFile (RESULT_FILE,"recreate");
189 calibPulser.Write("calibPulser");
191 printf("Wrote %s\n",RESULT_FILE);
193 /* store the result file on FES */
195 status=daqDA_FES_storeFile(RESULT_FILE,RESULT_FILE);