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
12 Trigger types used: CALIBRATION_EVENT
18 TPCda_pulser.cxx - calibration algorithm for TPC pulser events
20 10/06/2007 sylvain.chapeland@cern.ch : first version - clean skeleton based on DAQ DA case1
21 30/09/2007 haavard.helstrup@cern.ch : created pulser DA based on pedestal 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 "tpcPulser.root"
32 #define FILE_ID "pulser"
33 #define MAPPING_FILE "tpcMapping.root"
34 #define AliDebugLevel() -1
48 #include "TPluginManager.h"
52 #include "AliRawReader.h"
53 #include "AliRawReaderDate.h"
54 #include "AliTPCmapper.h"
55 #include "AliTPCRawStream.h"
56 #include "AliTPCROC.h"
57 #include "AliTPCCalROC.h"
58 #include "AliTPCCalPad.h"
59 #include "AliMathBase.h"
60 #include "TTreeStream.h"
65 // TPC calibration algorithm includes
67 #include "AliTPCCalibPulser.h"
73 Arguments: list of DATE raw data files
75 int main(int argc, char **argv) {
76 AliLog::SetClassDebugLevel("AliTPCRawStream",-5);
77 AliLog::SetClassDebugLevel("AliRawReaderDate",-5);
78 AliLog::SetClassDebugLevel("AliTPCAltroMapping",-5);
79 AliLog::SetModuleDebugLevel("RAW",-5);
81 gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
89 AliTPCmapper *mapping = 0; // The TPC mapping
90 // if test setup get parameters from $DAQDA_TEST_DIR
93 /* copy locally the mapping file from daq detector config db */
94 status = daqDA_DB_getFile(MAPPING_FILE,"./tpcMapping.root");
96 printf("Failed to get mapping file (%s) from DAQdetDB, status=%d\n", MAPPING_FILE, status);
97 printf("Continue anyway ... maybe it works?\n"); // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
98 return -1; // temporarily uncommented for testing on pcald47 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
101 /* open the mapping file and retrieve mapping object */
102 TFile *fileMapping = new TFile(MAPPING_FILE, "read");
103 mapping = (AliTPCmapper*) fileMapping->Get("tpcMapping");
108 printf("Failed to get mapping object from %s. ...\n", MAPPING_FILE);
111 printf("Got mapping object from %s\n", MAPPING_FILE);
115 AliTPCCalibPulser calibPulser; // pedestal and noise calibration
118 printf("Wrong number of arguments\n");
123 /* log start of process */
124 printf("TPC Pulser DA started - %s\n",__FILE__);
126 /* set time bin range */
127 calibPulser.SetRangeTime(400,500);
128 calibPulser.SetAltroMapping(mapping->GetAltroMapping()); // Use altro mapping we got from daqDetDb
129 /* declare monitoring program */
130 status=monitorDeclareMp( __FILE__ );
132 printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
137 /* loop over RAW data files */
139 for(i=1;i<argc;i++) {
141 /* define data source : this is argument i */
142 printf("Processing file %s\n", argv[i]);
143 status=monitorSetDataSource( argv[i] );
145 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
151 struct eventHeaderStruct *event;
153 /* check shutdown condition */
154 if (daqDA_checkShutdown()) {break;}
156 /* get next event (blocking call until timeout) */
157 status=monitorGetEventDynamic((void **)&event);
158 if (status==MON_ERR_EOF) {
159 printf ("End of File %d detected\n",i);
160 break; /* end of monitoring file has been reached */
164 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
168 /* retry if got no event */
174 // Pulser calibration
176 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
177 // calibPulser.ProcessEvent(rawReader);
178 calibPulser.ProcessEventFast(rawReader);
186 calibPulser.Analyse();
187 printf ("%d events processed\n",nevents);
189 TFile * fileTPC = new TFile (RESULT_FILE,"recreate");
190 calibPulser.Write("calibPulser");
192 printf("Wrote %s\n",RESULT_FILE);
194 /* store the result file on FES */
196 status=daqDA_FES_storeFile(RESULT_FILE,FILE_ID);