4 TRDda.cxx - calibration algorithm to be run on monitoring server
7 AliTRDCalibraFillHisto - average pulse height/ vdrift calibration
8 AliTRDCalibPadStatus - pad status calibration
11 This program connects to the DAQ data source passed as argument
12 and populates local "./result.txt" file with the ids of events received
15 The program exits when being asked to shut down (daqDA_checkshutdown)
18 Messages on stdout are exported to DAQ log system.
20 contact: alice-datesupport@cern.ch
24 #define RESULT_FILE "trdCalibrationv.root"
40 #include <TObjArray.h>
44 #include <TDirectory.h>
50 #include "AliRawReader.h"
51 #include "AliRawReaderDate.h"
52 #include "AliTRDRawStreamV2.h"
53 #include "AliCDBManager.h"
56 // TRD calibration algorithm includes
58 #include "AliTRDCalibraFillHisto.h"
65 1- monitoring data source
67 int main(int argc, char **argv) {
72 printf("Wrong number of arguments\n");
77 /* define data source : this is argument 1 */
78 status=monitorSetDataSource( argv[1] );
80 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
85 /* declare monitoring program */
86 status=monitorDeclareMp( __FILE__ );
88 printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
93 /* define wait event timeout - 1s max */
95 monitorSetNoWaitNetworkTimeout(1000);
98 /* log start of process */
99 printf("TRD DA VDRIFT started\n");
102 /* init some counters */
103 int nevents_physics=0;
106 //Instance of AliCDBManager: needed by AliTRDRawStreamV2
107 AliCDBManager *man = AliCDBManager::Instance();
108 man->SetDefaultStorage("local://$ALICE_ROOT");
110 //Instance of AliTRDCalibraFillHisto
111 AliTRDCalibraFillHisto *calibra = AliTRDCalibraFillHisto::Instance();
112 // everythings are okey for vdrift
113 Bool_t passvdrift = kTRUE; // if timebin okey
114 Int_t nbvdrift = 0; // number of events with entries for vdrift
117 /* main loop (infinite) */
119 //for(Int_t k = 0; k < 20; k++) {
120 struct eventHeaderStruct *event;
121 eventTypeType eventT;
123 /* check shutdown condition */
124 if (daqDA_checkShutdown()) {break;}
126 /* get next event (blocking call until timeout) */
127 status=monitorGetEventDynamic((void **)&event);
128 if (status==MON_ERR_EOF) {
129 printf ("End of File detected\n");
130 break; /* end of monitoring file has been reached */
134 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
138 /* retry if got no event */
143 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);
146 /* use event - here, just write event id to result file */
147 eventT=event->eventType;
150 // vdrift calibration: run only for physics events
152 if ((eventT==PHYSICS_EVENT) && (passvdrift)) {
153 //if (eventT==PHYSICS_EVENT) {
154 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
155 AliTRDRawStreamV2 *trdRawStream = new AliTRDRawStreamV2((AliRawReader *) rawReader);
156 Int_t result = calibra->ProcessEventDAQ(trdRawStream,(Bool_t)nevents_physics);
157 if(!result) passvdrift = kFALSE;
158 else nbvdrift += (Int_t) result/2;
165 if(eventT==PHYSICS_EVENT){
177 /* exit when last event received, no need to wait for TERM signal */
178 if (eventT==END_OF_RUN) {
179 printf("EOR event detected\n");
185 /* report progress */
186 printf("%d events processed and %d used\n",nevents_total,nbvdrift);
189 // Write a local file and put it on the FX
191 TFile *fileTRD = new TFile(RESULT_FILE,"recreate");
193 if((nbvdrift > 0) && passvdrift){
194 //Double_t *stat = calibra->StatH((TH2 *)(calibra->GetPH2d()),1);
195 //if((stat[6] < 0.20) && (stat[5] > 3000.0)) {
196 // write the histogram in any case to see if problems
197 calibra->GetPH2d()->Write();
202 // Export the file in any case to see if problems
203 if(daqDA_FES_storeFile(RESULT_FILE,RESULT_FILE)) status = -2;