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 "trdCalibrationv.root"
31 #include <TObjArray.h>
34 #include <TDirectory.h>
38 #include "TPluginManager.h"
42 #include "AliRawReader.h"
43 #include "AliRawReaderDate.h"
44 #include "AliTRDrawStreamTB.h"
48 // TRD calibration algorithm includes
50 #include "AliTRDCalibraFillHisto.h"
57 1- monitoring data source
59 int main(int argc, char **argv) {
61 /* magic line from Rene */
62 gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
70 printf("Wrong number of arguments\n");
75 /* define data source : this is argument 1 */
76 status=monitorSetDataSource( argv[1] );
78 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
83 /* declare monitoring program */
84 status=monitorDeclareMp( __FILE__ );
86 printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
91 /* define wait event timeout - 1s max */
93 monitorSetNoWaitNetworkTimeout(1000);
96 /* log start of process */
97 printf("TRD DA VDRIFT started\n");
100 /* init some counters */
101 int nevents_physics=0;
104 //Instance of AliCDBManager: needed by AliTRDRawStreamV2
105 //AliCDBManager *man = AliCDBManager::Instance();
106 //man->SetDefaultStorage("local://$ALICE_ROOT");
108 //Instance of AliTRDCalibraFillHisto
109 AliTRDCalibraFillHisto *calibra = AliTRDCalibraFillHisto::Instance();
110 // everythings are okey for vdrift
111 Bool_t passvdrift = kTRUE; // if timebin okey
112 Int_t nbvdrift = 0; // number of events with entries for vdrift
115 // AliTRDrawStreamTB::SetNoDebug();
116 AliTRDrawStreamTB::SetNoErrorWarning();
117 AliTRDrawStreamTB::SetForceCleanDataOnly();
118 AliTRDrawStreamTB::AllowCorruptedData();
119 //AliTRDrawStreamTB::SetSkipCDH();
120 //AliTRDrawStreamTB::SetExtraWordsFix();
121 //AliTRDrawStreamTB::EnableDebugStream();
122 //AliTRDrawStreamTB::SetDumpHead(320);
123 //AliTRDrawStreamTB::SetDumpHead(80);
126 /* main loop (infinite) */
128 //for(Int_t k = 0; k < 20; k++) {
129 struct eventHeaderStruct *event;
130 eventTypeType eventT;
132 /* check shutdown condition */
133 if (daqDA_checkShutdown()) {break;}
135 /* get next event (blocking call until timeout) */
136 status=monitorGetEventDynamic((void **)&event);
137 if (status==MON_ERR_EOF) {
138 printf ("End of File detected\n");
139 break; /* end of monitoring file has been reached */
143 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
147 /* retry if got no event */
152 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);
155 /* use event - here, just write event id to result file */
156 eventT=event->eventType;
159 // vdrift calibration: run only for physics events
161 if ((eventT==PHYSICS_EVENT) && (passvdrift)) {
162 //if (eventT==PHYSICS_EVENT) {
163 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
164 AliTRDrawStreamTB *trdRawStream = new AliTRDrawStreamTB((AliRawReader *) rawReader);
165 Int_t result = calibra->ProcessEventDAQ(trdRawStream,(Bool_t)nevents_physics);
166 if(!result) passvdrift = kFALSE;
167 else nbvdrift += (Int_t) result/2;
174 if(eventT==PHYSICS_EVENT){
186 /* exit when last event received, no need to wait for TERM signal */
187 if (eventT==END_OF_RUN) {
188 printf("EOR event detected\n");
194 /* report progress */
195 printf("%d events processed and %d used\n",nevents_total,nbvdrift);
198 // Write a local file and put it on the FX
200 TFile *fileTRD = new TFile(RESULT_FILE,"recreate");
202 if((nbvdrift > 0) && passvdrift){
203 //Double_t *stat = calibra->StatH((TH2 *)(calibra->GetPH2d()),1);
204 //if((stat[6] < 0.20) && (stat[5] > 3000.0)) {
205 // write the histogram in any case to see if problems
206 calibra->GetPH2d()->Write();
211 // Export the file in any case to see if problems
212 if(daqDA_FES_storeFile(RESULT_FILE,RESULT_FILE)) status = -2;