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
37 #include <TObjArray.h>
41 #include <TDirectory.h>
47 #include "AliRawReader.h"
48 #include "AliRawReaderDate.h"
49 #include "AliTRDRawStream.h"
50 #include "AliCDBManager.h"
53 // TRD calibration algorithm includes
55 #include "AliTRDCalibPadStatus.h"
56 #include "AliTRDCalibraFillHisto.h"
63 1- monitoring data source
65 int main(int argc, char **argv) {
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("DA example case2 monitoring program started\n");
100 /* init some counters */
101 int nevents_physics=0;
104 //Instance of AliCDBManager: needed by AliTRDRawStream
105 AliCDBManager *man = AliCDBManager::Instance();
106 man->SetDefaultStorage("local://$ALICE_ROOT");
108 //Instance of AliTRDCalibraFillHisto
109 AliTRDCalibraFillHisto *calibra = AliTRDCalibraFillHisto::Instance();
110 //AliTRDCalibPadStatus
111 AliTRDCalibPadStatus calibpad = AliTRDCalibPadStatus();
112 // pad status on: no zero suppression (special runs)
113 Bool_t passpadstatus = kTRUE;
114 // everythings are okey for vdrift
115 Bool_t passvdrift = kTRUE; // if timebin okey
116 Int_t nbvdrift = 0; // number of events with entries for vdrift
119 /* main loop (infinite) */
121 //for(Int_t k = 0; k < 20; k++) {
122 struct eventHeaderStruct *event;
123 eventTypeType eventT;
125 /* check shutdown condition */
126 if (daqDA_checkShutdown()) {break;}
128 /* get next event (blocking call until timeout) */
129 status=monitorGetEventDynamic((void **)&event);
130 if (status==MON_ERR_EOF) {
131 printf ("End of File detected\n");
132 break; /* end of monitoring file has been reached */
136 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
140 /* retry if got no event */
145 printf(" event number %d (physic event number %d) will be processed\n",(Int_t) nevents_total,(Int_t) nevents_physics);
148 /* use event - here, just write event id to result file */
149 eventT=event->eventType;
151 // pad status calibration: we try a first time to see if zero suppressed or not
154 printf("pad status calibration\n");
155 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
156 AliTRDRawStream *trdRawStream = new AliTRDRawStream((AliRawReader *) rawReader);
157 if(!calibpad.ProcessEvent(trdRawStream,(Bool_t)nevents_total)) passpadstatus = kFALSE;
163 // vdrift calibration: run only for physics events
165 if ((eventT==PHYSICS_EVENT) && (!passpadstatus) && (passvdrift)) {
166 //if (eventT==PHYSICS_EVENT) {
167 printf("vdrift calibration\n");
168 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
169 AliTRDRawStream *trdRawStream = new AliTRDRawStream((AliRawReader *) rawReader);
170 Int_t result = calibra->ProcessEventDAQ(trdRawStream,(Bool_t)nevents_physics);
171 if(!result) passvdrift = kFALSE;
172 else nbvdrift += (Int_t) result/2;
179 if(eventT==PHYSICS_EVENT){
191 /* exit when last event received, no need to wait for TERM signal */
192 if (eventT==END_OF_RUN) {
193 printf("EOR event detected\n");
199 // Write a local file and put it on the FX
201 TFile *fileTRD = new TFile("trdCalibration.root","recreate");
202 Bool_t passwrite = kFALSE;
207 // We do this at the shuttle maybe!
208 //calibpad.AnalyseHisto();
209 //AliTRDCalPadStatus *calPadStatus = calibpad.CreateCalPadStatus();
210 calibpad.Write("calibpadstatus");
216 if((nbvdrift > 0) && passvdrift){
217 Double_t *stat = calibra->StatH((TH2 *)(calibra->GetPH2d()),1);
218 // write only of enough statistics
219 if((stat[6] < 0.20) && (stat[5] > 3000.0)) {
220 calibra->GetPH2d()->Write();
228 if(daqDA_FES_storeFile("trdCalibration.root","trdCalibration.root")) status = -2;