2 TPC DA for online calibration
4 Contact: Jens.Wiechula@cern.ch
6 Run Type: PHYSICS STANDALONE
8 Number of events needed: 200
9 Input Files: /castor/cern.ch/alice/raw/global/2009/08/22/11/09000080958023.30.root
10 Output Files: tpcCalibRaw.root, to be exported to the DAQ FXS
12 Trigger types used: PHYSICS_EVENT
18 TPCRAWda.cxx - calibration algorithm for TPC pulser events
20 30/09/2009 J.Wiechula@gsi.de: First implementation.
23 This process reads RAW data from the files provided as command line arguments
24 and save results in a file (named from RESULT_FILE define - see below).
28 #define RESULT_FILE "tpcCalibRaw.root"
29 #define FILE_ID "tpcCalibRaw"
30 #define MAPPING_FILE "tpcMapping.root"
31 #define CONFIG_FILE "TPCRAWda.conf"
32 #define AliDebugLevel() -1
46 #include "TPluginManager.h"
48 #include "TObjString.h"
53 #include "AliRawReader.h"
54 #include "AliRawReaderDate.h"
55 #include "AliTPCmapper.h"
56 #include "AliTPCROC.h"
57 #include "AliTPCCalROC.h"
58 #include "AliTPCCalPad.h"
59 #include "AliMathBase.h"
60 #include "TTreeStream.h"
63 // #include "AliTPCConfigDA.h"
69 // TPC calibration algorithm includes
71 #include "AliTPCCalibRaw.h"
74 Arguments: list of DATE raw data files
76 int main(int argc, char **argv) {
77 /* log start of process */
78 printf("TPC RAW DA started - %s\n",__FILE__);
81 printf("Wrong number of arguments\n");
84 AliLog::SetClassDebugLevel("AliRawReaderDate",-5);
85 AliLog::SetClassDebugLevel("AliTPCAltroMapping",-5);
86 AliLog::SetModuleDebugLevel("RAW",-5);
88 gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
95 /* declare monitoring program */
97 status=monitorDeclareMp( __FILE__ );
99 printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
102 //Set network timeout
104 monitorSetNoWaitNetworkTimeout(1000);
107 AliTPCmapper *mapping = 0; // The TPC mapping
109 unsigned long32 runNb=0; //run number
110 // configuration options
111 Bool_t fastDecoding = kFALSE;
112 // if test setup get parameters from $DAQDA_TEST_DIR
115 /* copy locally the mapping file from daq detector config db */
116 sprintf(localfile,"./%s",MAPPING_FILE);
117 status = daqDA_DB_getFile(MAPPING_FILE,localfile);
119 printf("Failed to get mapping file (%s) from DAQdetDB, status=%d\n", MAPPING_FILE, status);
123 /* open the mapping file and retrieve mapping object */
124 TFile *fileMapping = new TFile(MAPPING_FILE, "read");
125 mapping = (AliTPCmapper*) fileMapping->Get("tpcMapping");
130 printf("Failed to get mapping object from %s. ...\n", MAPPING_FILE);
133 printf("Got mapping object from %s\n", MAPPING_FILE);
137 // DA configuration from configuration file
139 //retrieve configuration file
140 // sprintf(localfile,"./%s",CONFIG_FILE);
141 // status = daqDA_DB_getFile(CONFIG_FILE,localfile);
143 // printf("Failed to get configuration file (%s) from DAQdetDB, status=%d\n", CONFIG_FILE, status);
146 // AliTPCConfigDA config(CONFIG_FILE);
148 // create calibration object
149 // AliTPCCalibRaw calibRaw(config.GetConfigurationMap()); // pulser calibration algorithm
150 AliTPCCalibRaw calibRaw; // pulser calibration algorithm
151 calibRaw.SetAltroMapping(mapping->GetAltroMapping()); // Use altro mapping we got from daqDetDb
153 //===========================//
154 // loop over RAW data files //
155 //==========================//
157 for(i=1;i<argc;i++) {
159 /* define data source : this is argument i */
160 printf("Processing file %s\n", argv[i]);
161 status=monitorSetDataSource( argv[i] );
163 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
169 struct eventHeaderStruct *event;
171 /* check shutdown condition */
172 if (daqDA_checkShutdown()) {break;}
174 /* get next event (blocking call until timeout) */
175 status=monitorGetEventDynamic((void **)&event);
176 if (status==MON_ERR_EOF) {
177 printf ("End of File %d detected\n",i);
178 break; /* end of monitoring file has been reached */
182 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
186 /* retry if got no event */
191 // get the run number
192 runNb = event->eventRunNb;
194 calibRaw.ProcessEvent(event);
202 // Analyse pulser data and write them to rootfile
205 printf ("%d events processed\n",nevents);
207 TFile * fileTPC = new TFile (RESULT_FILE,"recreate");
208 calibRaw.Write("tpcCalibRaw");
210 printf("Wrote %s\n",RESULT_FILE);
212 /* store the result file on FES */
214 status=daqDA_FES_storeFile(RESULT_FILE,FILE_ID);
219 //Send objects to the AMORE DB
221 printf ("AMORE part\n");
222 const char *amoreDANameorig=gSystem->Getenv("AMORE_DA_NAME");
223 //cheet a little -- temporary solution (hopefully)
225 //currently amoreDA uses the environment variable AMORE_DA_NAME to create the mysql
226 //table in which the calib objects are stored. This table is dropped each time AmoreDA
227 //is initialised. This of course makes a problem if we would like to store different
228 //calibration entries in the AMORE DB. Therefore in each DA which writes to the AMORE DB
229 //the AMORE_DA_NAME env variable is overwritten.
231 gSystem->Setenv("AMORE_DA_NAME","TPC-RAW");
235 TObjString info(Form("Run: %u; Date: %s",runNb,time.AsString()));
237 amore::da::AmoreDA amoreDA(amore::da::AmoreDA::kSender);
239 statusDA+=amoreDA.Send("CalibRaw",&calibRaw);
240 statusDA+=amoreDA.Send("Info",&info);
242 printf("Waring: Failed to write one of the calib objects to the AMORE database\n");
244 if (amoreDANameorig) gSystem->Setenv("AMORE_DA_NAME",amoreDANameorig);