3 Contact: r.bailhache@gsi.de
5 Run Type: PHYSICS STANDALONE
7 Number of events needed: as many as possible
8 Input Files: raw files of the TRD
9 Output Files: trdCalibrationv.root,to be exported to the DAQ FXS
10 Trigger types used: PHYSICS_EVENT, for the time being
14 #define RESULT_FILE "trdCalibrationv.root"
30 #include <TObjArray.h>
33 #include <TDirectory.h>
37 #include "TPluginManager.h"
41 #include "AliRawReader.h"
42 #include "AliRawReaderDate.h"
43 #include "AliTRDrawStreamTB.h"
44 #include "AliCDBManager.h"
47 // TRD calibration algorithm includes
49 #include "AliTRDCalibraFillHisto.h"
56 1- monitoring data source
58 int main(int argc, char **argv) {
60 /* magic line from Rene */
61 gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
69 printf("Wrong number of arguments\n");
74 /* define data source : this is argument 1 */
75 status=monitorSetDataSource( argv[1] );
77 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
82 /* declare monitoring program */
83 status=monitorDeclareMp( __FILE__ );
85 printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
90 /* define wait event timeout - 1s max */
92 monitorSetNoWaitNetworkTimeout(1000);
95 /* log start of process */
96 printf("TRD DA VDRIFT started\n");
99 /* init some counters */
100 int nevents_physics=0;
103 //Instance of AliCDBManager: needed by AliTRDRawStreamV2
104 AliCDBManager *man = AliCDBManager::Instance();
105 man->SetDefaultStorage("local://$ALICE_ROOT");
107 //Instance of AliTRDCalibraFillHisto
108 AliTRDCalibraFillHisto *calibra = AliTRDCalibraFillHisto::Instance();
109 // everythings are okey for vdrift
110 Bool_t passvdrift = kTRUE; // if timebin okey
111 Int_t nbvdrift = 0; // number of events with entries for vdrift
114 // AliTRDrawStreamTB::SetNoDebug();
115 AliTRDrawStreamTB::SetNoErrorWarning();
116 AliTRDrawStreamTB::SetForceCleanDataOnly();
117 AliTRDrawStreamTB::AllowCorruptedData();
118 //AliTRDrawStreamTB::SetSkipCDH();
119 //AliTRDrawStreamTB::SetExtraWordsFix();
120 //AliTRDrawStreamTB::EnableDebugStream();
121 //AliTRDrawStreamTB::SetDumpHead(320);
122 //AliTRDrawStreamTB::SetDumpHead(80);
125 /* main loop (infinite) */
127 //for(Int_t k = 0; k < 20; k++) {
128 struct eventHeaderStruct *event;
129 eventTypeType eventT;
131 /* check shutdown condition */
132 if (daqDA_checkShutdown()) {break;}
134 /* get next event (blocking call until timeout) */
135 status=monitorGetEventDynamic((void **)&event);
136 if (status==MON_ERR_EOF) {
137 printf ("End of File detected\n");
138 break; /* end of monitoring file has been reached */
142 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
146 /* retry if got no event */
151 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);
154 /* use event - here, just write event id to result file */
155 eventT=event->eventType;
158 // vdrift calibration: run only for physics events
160 if ((eventT==PHYSICS_EVENT) && (passvdrift)) {
161 //if (eventT==PHYSICS_EVENT) {
162 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
163 AliTRDrawStreamTB *trdRawStream = new AliTRDrawStreamTB((AliRawReader *) rawReader);
164 Int_t result = calibra->ProcessEventDAQ(trdRawStream,(Bool_t)nevents_physics);
165 if(!result) passvdrift = kFALSE;
166 else nbvdrift += (Int_t) result/2;
173 if(eventT==PHYSICS_EVENT){
185 /* exit when last event received, no need to wait for TERM signal */
186 if (eventT==END_OF_RUN) {
187 printf("EOR event detected\n");
193 /* report progress */
194 printf("%d events processed and %d used\n",nevents_total,nbvdrift);
197 // Write a local file and put it on the FX
199 TFile *fileTRD = new TFile(RESULT_FILE,"recreate");
201 if((nbvdrift > 0) && passvdrift){
202 //Double_t *stat = calibra->StatH((TH2 *)(calibra->GetPH2d()),1);
203 //if((stat[6] < 0.20) && (stat[5] > 3000.0)) {
204 // write the histogram in any case to see if problems
205 calibra->GetPH2d()->Write();
210 // Export the file in any case to see if problems
211 if(daqDA_FES_storeFile(RESULT_FILE,RESULT_FILE)) status = -2;