3 Contact: r.bailhache@gsi.de
4 Link: http://www-linux.gsi.de/~bailhach/VDRIFT/raw.root.date
5 Run Type: nothing special in ECS, physics run
7 Number of events needed: as many as possible
8 Input Files: no config files, no previous result files, RAW DATA file with all the TRD ([DDL = 1024 to DDL = 1041])
9 Output Files: trdCalibrationv.root, trdCalibrationv.root, no persitent file over runs
10 Trigger types used: PHYSICS
14 #define RESULT_FILE "trdCalibrationv.root"
30 #include <TObjArray.h>
34 #include <TDirectory.h>
40 #include "AliRawReader.h"
41 #include "AliRawReaderDate.h"
42 #include "AliTRDrawStreamTB.h"
43 #include "AliCDBManager.h"
46 // TRD calibration algorithm includes
48 #include "AliTRDCalibraFillHisto.h"
55 1- monitoring data source
57 int main(int argc, char **argv) {
62 printf("Wrong number of arguments\n");
67 /* define data source : this is argument 1 */
68 status=monitorSetDataSource( argv[1] );
70 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
75 /* declare monitoring program */
76 status=monitorDeclareMp( __FILE__ );
78 printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
83 /* define wait event timeout - 1s max */
85 monitorSetNoWaitNetworkTimeout(1000);
88 /* log start of process */
89 printf("TRD DA VDRIFT started\n");
92 /* init some counters */
93 int nevents_physics=0;
96 //Instance of AliCDBManager: needed by AliTRDRawStreamV2
97 AliCDBManager *man = AliCDBManager::Instance();
98 man->SetDefaultStorage("local://$ALICE_ROOT");
100 //Instance of AliTRDCalibraFillHisto
101 AliTRDCalibraFillHisto *calibra = AliTRDCalibraFillHisto::Instance();
102 // everythings are okey for vdrift
103 Bool_t passvdrift = kTRUE; // if timebin okey
104 Int_t nbvdrift = 0; // number of events with entries for vdrift
107 /* some warning less */
108 AliTRDrawStreamTB::SupressWarnings(kTRUE);
111 /* main loop (infinite) */
113 //for(Int_t k = 0; k < 20; k++) {
114 struct eventHeaderStruct *event;
115 eventTypeType eventT;
117 /* check shutdown condition */
118 if (daqDA_checkShutdown()) {break;}
120 /* get next event (blocking call until timeout) */
121 status=monitorGetEventDynamic((void **)&event);
122 if (status==MON_ERR_EOF) {
123 printf ("End of File detected\n");
124 break; /* end of monitoring file has been reached */
128 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
132 /* retry if got no event */
137 if( ((Int_t)nevents_total)%100 == 0 ) printf(" event number %d (physic event number %d) will be processed\n",(Int_t) nevents_total,(Int_t) nevents_physics);
140 /* use event - here, just write event id to result file */
141 eventT=event->eventType;
144 // vdrift calibration: run only for physics events
146 if ((eventT==PHYSICS_EVENT) && (passvdrift)) {
147 //if (eventT==PHYSICS_EVENT) {
148 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
149 AliTRDrawStreamTB *trdRawStream = new AliTRDrawStreamTB((AliRawReader *) rawReader);
150 Int_t result = calibra->ProcessEventDAQ(trdRawStream,(Bool_t)nevents_physics);
151 if(!result) passvdrift = kFALSE;
152 else nbvdrift += (Int_t) result/2;
159 if(eventT==PHYSICS_EVENT){
171 /* exit when last event received, no need to wait for TERM signal */
172 if (eventT==END_OF_RUN) {
173 printf("EOR event detected\n");
179 /* report progress */
180 printf("%d events processed and %d used\n",nevents_total,nbvdrift);
183 // Write a local file and put it on the FX
185 TFile *fileTRD = new TFile(RESULT_FILE,"recreate");
187 if((nbvdrift > 0) && passvdrift){
188 //Double_t *stat = calibra->StatH((TH2 *)(calibra->GetPH2d()),1);
189 //if((stat[6] < 0.20) && (stat[5] > 3000.0)) {
190 // write the histogram in any case to see if problems
191 calibra->GetPH2d()->Write();
196 // Export the file in any case to see if problems
197 if(daqDA_FES_storeFile(RESULT_FILE,RESULT_FILE)) status = -2;