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"
35 #define CONFIG_FILE "TPCQAda.conf"
49 #include "TPluginManager.h"
54 #include "AliRawReader.h"
55 #include "AliRawReaderDate.h"
56 #include "AliTPCmapper.h"
57 #include "AliTPCRawStream.h"
58 #include "AliTPCROC.h"
59 #include "AliTPCCalROC.h"
60 #include "AliTPCCalPad.h"
61 #include "TTreeStream.h"
63 #include "AliTPCConfigDA.h"
66 // TPC calibration algorithm includes
68 #include "AliTPCdataQA.h"
71 Arguments: list of DATE raw data files
73 int main(int argc, char **argv) {
75 gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
81 AliLog::SetClassDebugLevel("AliTPCRawStream",-5);
82 AliLog::SetClassDebugLevel("AliRawReaderDate",-5);
83 AliLog::SetClassDebugLevel("AliTPCAltroMapping",-5);
84 AliLog::SetModuleDebugLevel("RAW",-5);
88 AliTPCmapper *mapping = 0; // The TPC mapping
89 // configuration options
90 Bool_t fastDecoding = kFALSE;
91 // if test setup get parameters from $DAQDA_TEST_DIR
94 /* copy locally the mapping file from daq detector config db */
95 status = daqDA_DB_getFile(MAPPING_FILE,"./tpcMapping.root");
97 printf("Failed to get mapping file (%s) from DAQdetDB, status=%d\n", MAPPING_FILE, status);
98 printf("Continue anyway ... maybe it works?\n"); // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
99 return -1; // temporarily uncommented for testing on pcald47 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
102 /* open the mapping file and retrieve mapping object */
103 TFile *fileMapping = new TFile(MAPPING_FILE, "read");
104 mapping = (AliTPCmapper*) fileMapping->Get("tpcMapping");
109 printf("Failed to get mapping object from %s. ...\n", MAPPING_FILE);
112 printf("Got mapping object from %s\n", MAPPING_FILE);
114 //retrieve configuration file
116 sprintf(localfile,"./%s",CONFIG_FILE);
117 status = daqDA_DB_getFile(CONFIG_FILE,localfile);
119 printf("Failed to get configuration file (%s) from DAQdetDB, status=%d\n", CONFIG_FILE, status);
122 AliTPCConfigDA config(CONFIG_FILE);
123 // check configuration options
124 if ( (Int_t)config.GetValue("UseFastDecoder") == 1 ) {
125 printf("Info: The fast decoder will be used for the processing.\n");
130 AliTPCdataQA calibQA(config.GetConfigurationMap()); // pedestal and noise calibration
133 printf("Wrong number of arguments\n");
138 /* log start of process */
139 printf("TPC QA DA started - %s\n",__FILE__);
142 /* set time bin range */
143 // calibQA.SetRangeTime(0,1000); // should be done in the configuration file now
144 calibQA.SetAltroMapping(mapping->GetAltroMapping()); // Use altro mapping we got from daqDetDb
146 /* declare monitoring program */
147 status=monitorDeclareMp( __FILE__ );
149 printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
154 monitorSetNoWaitNetworkTimeout(1000);
156 /* loop over RAW data files */
158 for(i=1;i<argc;i++) {
160 /* define data source : this is argument i */
161 printf("Processing file %s\n", argv[i]);
162 status=monitorSetDataSource( argv[i] );
164 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
170 struct eventHeaderStruct *event;
172 /* check shutdown condition */
173 if (daqDA_checkShutdown()) {break;}
175 /* get next event (blocking call until timeout) */
176 status=monitorGetEventDynamic((void **)&event);
177 if (status==MON_ERR_EOF) {
178 printf ("End of File %d detected\n",i);
179 break; /* end of monitoring file has been reached */
183 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
187 /* retry if got no event */
193 // Pulser calibration
195 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
196 if ( fastDecoding ) calibQA.ProcessEventFast(rawReader);
197 else calibQA.ProcessEvent(rawReader);
206 printf ("%d events processed\n",nevents);
208 TFile * fileTPC = new TFile (RESULT_FILE,"recreate");
209 calibQA.Write("tpcCalibQA");
211 printf("Wrote %s\n",RESULT_FILE);
213 /* store the result file on FXS */
215 status=daqDA_FES_storeFile(RESULT_FILE,FILE_ID);