2 TPC DA for online calibration
4 Contact: Haavard.Helstrup@cern.ch, peter.christiansen@hep.lu.se
6 Run Type: PHYSICS STANDALONE DAQ
8 Number of events needed: 500
10 Output Files: tpcQA.root, to be exported to the DAQ FXS
12 Trigger types used: PHYSICS_EVENT
18 TPCQAda.cxx - algorithm for TPC RAW QA
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
22 09/06/2008 peter.christiansen@hep.lu.se and haavard.helstrup@cern.ch : created QA DA based on AliTPCdataQA code
24 contact: marian.ivanov@cern.ch, peter.christiansen@hep.lu.se
27 This process reads RAW data from the files provided as command line arguments
28 and save results in a file (named from RESULT_FILE define - see below).
32 #define RESULT_FILE "tpcQA.root"
34 #define MAPPING_FILE "tpcMapping.root"
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 "TTreeStream.h"
64 // TPC calibration algorithm includes
66 #include "AliTPCdataQA.h"
69 Arguments: list of DATE raw data files
71 int main(int argc, char **argv) {
73 gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
79 AliLog::SetClassDebugLevel("AliTPCRawStream",-5);
80 AliLog::SetClassDebugLevel("AliRawReaderDate",-5);
81 AliLog::SetClassDebugLevel("AliTPCAltroMapping",-5);
82 AliLog::SetModuleDebugLevel("RAW",-5);
85 AliTPCmapper *mapping = 0; // The TPC mapping
86 // if test setup get parameters from $DAQDA_TEST_DIR
89 /* copy locally the mapping file from daq detector config db */
90 status = daqDA_DB_getFile(MAPPING_FILE,"./tpcMapping.root");
92 printf("Failed to get mapping file (%s) from DAQdetDB, status=%d\n", MAPPING_FILE, status);
93 printf("Continue anyway ... maybe it works?\n"); // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
94 return -1; // temporarily uncommented for testing on pcald47 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
97 /* open the mapping file and retrieve mapping object */
98 TFile *fileMapping = new TFile(MAPPING_FILE, "read");
99 mapping = (AliTPCmapper*) fileMapping->Get("tpcMapping");
104 printf("Failed to get mapping object from %s. ...\n", MAPPING_FILE);
107 printf("Got mapping object from %s\n", MAPPING_FILE);
111 AliTPCdataQA calibQA; // pedestal and noise calibration
114 printf("Wrong number of arguments\n");
119 /* log start of process */
120 printf("TPC QA DA started - %s\n",__FILE__);
123 /* set time bin range */
124 calibQA.SetRangeTime(0,1000);
125 calibQA.SetAltroMapping(mapping->GetAltroMapping()); // Use altro mapping we got from daqDetDb
127 /* declare monitoring program */
128 status=monitorDeclareMp( __FILE__ );
130 printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
135 /* loop over RAW data files */
137 for(i=1;i<argc;i++) {
139 /* define data source : this is argument i */
140 printf("Processing file %s\n", argv[i]);
141 status=monitorSetDataSource( argv[i] );
143 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
149 struct eventHeaderStruct *event;
151 /* check shutdown condition */
152 if (daqDA_checkShutdown()) {break;}
154 /* get next event (blocking call until timeout) */
155 status=monitorGetEventDynamic((void **)&event);
156 if (status==MON_ERR_EOF) {
157 printf ("End of File %d detected\n",i);
158 break; /* end of monitoring file has been reached */
162 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
166 /* retry if got no event */
172 // Pulser calibration
174 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
175 calibQA.ProcessEvent(rawReader);
184 printf ("%d events processed\n",nevents);
186 TFile * fileTPC = new TFile (RESULT_FILE,"recreate");
187 calibQA.Write("tpcCalibQA");
189 printf("Wrote %s\n",RESULT_FILE);
191 /* store the result file on FXS */
193 status=daqDA_FES_storeFile(RESULT_FILE,FILE_ID);