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));
104 AliTPCmapper *mapping = 0; // The TPC mapping
106 unsigned long32 runNb=0; //run number
107 // configuration options
108 Bool_t fastDecoding = kFALSE;
109 // if test setup get parameters from $DAQDA_TEST_DIR
112 /* copy locally the mapping file from daq detector config db */
113 sprintf(localfile,"./%s",MAPPING_FILE);
114 status = daqDA_DB_getFile(MAPPING_FILE,localfile);
116 printf("Failed to get mapping file (%s) from DAQdetDB, status=%d\n", MAPPING_FILE, status);
120 /* open the mapping file and retrieve mapping object */
121 TFile *fileMapping = new TFile(MAPPING_FILE, "read");
122 mapping = (AliTPCmapper*) fileMapping->Get("tpcMapping");
127 printf("Failed to get mapping object from %s. ...\n", MAPPING_FILE);
130 printf("Got mapping object from %s\n", MAPPING_FILE);
134 // DA configuration from configuration file
136 //retrieve configuration file
137 // sprintf(localfile,"./%s",CONFIG_FILE);
138 // status = daqDA_DB_getFile(CONFIG_FILE,localfile);
140 // printf("Failed to get configuration file (%s) from DAQdetDB, status=%d\n", CONFIG_FILE, status);
143 // AliTPCConfigDA config(CONFIG_FILE);
145 // create calibration object
146 // AliTPCCalibRaw calibRaw(config.GetConfigurationMap()); // pulser calibration algorithm
147 AliTPCCalibRaw calibRaw; // pulser calibration algorithm
148 calibRaw.SetAltroMapping(mapping->GetAltroMapping()); // Use altro mapping we got from daqDetDb
150 //===========================//
151 // loop over RAW data files //
152 //==========================//
154 for(i=1;i<argc;i++) {
156 /* define data source : this is argument i */
157 printf("Processing file %s\n", argv[i]);
158 status=monitorSetDataSource( argv[i] );
160 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
166 struct eventHeaderStruct *event;
168 /* check shutdown condition */
169 if (daqDA_checkShutdown()) {break;}
171 /* get next event (blocking call until timeout) */
172 status=monitorGetEventDynamic((void **)&event);
173 if (status==MON_ERR_EOF) {
174 printf ("End of File %d detected\n",i);
175 break; /* end of monitoring file has been reached */
179 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
183 /* retry if got no event */
188 // get the run number
189 runNb = event->eventRunNb;
191 calibRaw.ProcessEvent(event);
199 // Analyse pulser data and write them to rootfile
202 printf ("%d events processed\n",nevents);
204 TFile * fileTPC = new TFile (RESULT_FILE,"recreate");
205 calibRaw.Write("tpcCalibRaw");
207 printf("Wrote %s\n",RESULT_FILE);
209 /* store the result file on FES */
211 status=daqDA_FES_storeFile(RESULT_FILE,FILE_ID);
216 //Send objects to the AMORE DB
218 printf ("AMORE part\n");
219 const char *amoreDANameorig=gSystem->Getenv("AMORE_DA_NAME");
220 //cheet a little -- temporary solution (hopefully)
222 //currently amoreDA uses the environment variable AMORE_DA_NAME to create the mysql
223 //table in which the calib objects are stored. This table is dropped each time AmoreDA
224 //is initialised. This of course makes a problem if we would like to store different
225 //calibration entries in the AMORE DB. Therefore in each DA which writes to the AMORE DB
226 //the AMORE_DA_NAME env variable is overwritten.
228 gSystem->Setenv("AMORE_DA_NAME","TPC-RAW");
232 TObjString info(Form("Run: %u; Date: %s",runNb,time.AsString()));
234 amore::da::AmoreDA amoreDA(amore::da::AmoreDA::kSender);
236 statusDA+=amoreDA.Send("CalibRaw",&calibRaw);
237 statusDA+=amoreDA.Send("Info",&info);
239 printf("Waring: Failed to write one of the calib objects to the AMORE database\n");
241 if (amoreDANameorig) gSystem->Setenv("AMORE_DA_NAME",amoreDANameorig);