3 Contact: r.bailhache@gsi.de
6 Run Type: PHYSICS STANDALONE
8 Number of events needed: many
9 Input Files: TRD raw files
10 Output Files: trdCalibrationv.root
11 Trigger types used: PHYSICS_EVENT
15 #define RESULT_FILE "trdVdrift.root"
16 #define FILE_ID "VDRIFT"
32 #include <TObjArray.h>
35 #include <TDirectory.h>
39 #include "TPluginManager.h"
43 #include "AliRawReader.h"
44 #include "AliRawReaderDate.h"
45 //#include "AliTRDrawFastStream.h"
46 //#include "AliTRDrawStreamBase.h"
55 // TRD calibration algorithm includes
57 #include "AliTRDCalibraFillHisto.h"
59 //functions, implementation below
60 //void SendToAmoreDB(TObject *o, unsigned long32 runNb);
65 1- monitoring data source
67 int main(int argc, char **argv) {
69 /* magic line from Rene */
70 gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
78 printf("Wrong number of arguments\n");
83 /* define data source : this is argument 1 */
84 status=monitorSetDataSource( argv[1] );
86 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
91 /* declare monitoring program */
92 status=monitorDeclareMp( __FILE__ );
94 printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
99 /* define wait event timeout - 1s max */
101 monitorSetNoWaitNetworkTimeout(1000);
104 /* log start of process */
105 printf("TRD DA VDRIFT started\n");
108 /* init some counters */
109 int nevents_physics=0;
111 //unsigned long32 runNb=0; //run number
113 //Instance of AliCDBManager: needed by AliTRDrawFastStream
114 //AliCDBManager *man = AliCDBManager::Instance();
115 //man->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
117 //Instance of AliTRDCalibraFillHisto
118 AliTRDCalibraFillHisto *calibra = AliTRDCalibraFillHisto::Instance();
119 calibra->SetNumberClustersProcent(0.9);
121 // everythings are okey for vdrift
122 Bool_t passvdrift = kTRUE; // if timebin okey
123 Int_t nbvdrift = 0; // number of events with entries for vdrift
126 //AliTRDrawFastStream::DisableSkipData();
127 AliLog::SetGlobalLogLevel(AliLog::kFatal);
129 /* main loop (infinite) */
131 //for(Int_t k = 0; k < 20; k++) {
132 struct eventHeaderStruct *event;
133 eventTypeType eventT;
135 /* check shutdown condition */
136 if (daqDA_checkShutdown()) {break;}
138 /* get next event (blocking call until timeout) */
139 status=monitorGetEventDynamic((void **)&event);
140 if (status==MON_ERR_EOF) {
141 printf ("End of File detected\n");
142 break; /* end of monitoring file has been reached */
146 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
150 /* retry if got no event */
155 if( ((Int_t)nevents_total)%1000 == 0 ) printf(" event number %d (physic event number %d) will be processed\n",(Int_t) nevents_total,(Int_t) nevents_physics);
159 /* use event - here, just write event id to result file */
160 eventT=event->eventType;
163 // vdrift calibration: run only for physics events
165 if ((eventT==PHYSICS_EVENT) && (passvdrift)) {
166 //if (eventT==PHYSICS_EVENT) {
167 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
168 rawReader->Select("TRD");
170 Int_t result = calibra->ProcessEventDAQ3((AliRawReader *)rawReader);
171 if(!result) passvdrift = kFALSE;
172 else nbvdrift += (Int_t) result/2;
179 // get the run number
180 //runNb = event->eventRunNb;
182 if(eventT==PHYSICS_EVENT){
189 if( ((Int_t)nevents_physics)%100 == 0 ) {
190 SendToAmoreDB(&calibra);
201 /* exit when last event received, no need to wait for TERM signal */
202 if (eventT==END_OF_RUN) {
203 printf("EOR event detected\n");
209 /* report progress */
210 printf("%d events processed and %d used\n",nevents_total,nbvdrift);
213 // Write a local file and put it on the FX
215 TFile *fileTRD = new TFile(RESULT_FILE,"recreate");
217 if((nbvdrift > 0) && passvdrift){
218 //Double_t *stat = calibra->StatH((TH2 *)(calibra->GetPH2d()),1);
219 //if((stat[6] < 0.20) && (stat[5] > 3000.0)) {
220 // write the histogram in any case to see if problems
221 calibra->GetPH2d()->Write();
226 // Export the file in any case to see if problems
227 if(daqDA_FES_storeFile(RESULT_FILE,FILE_ID)) status = -2;
235 void SendToAmoreDB(TObject *o)
238 const char *amoreDANameorig=gSystem->Getenv("AMORE_DA_NAME");
239 gSystem->Setenv("AMORE_DA_NAME","TRD-dataQA");
241 amore::da::AmoreDA amoreDA(amore::da::AmoreDA::kSender);
243 statusDA+=amoreDA.Send("DataQA-VDRIFT",o);
245 printf("Waring: Failed to write one of the calib objects to the AMORE database\n");
247 if (amoreDANameorig) gSystem->Setenv("AMORE_DA_NAME",amoreDANameorig);