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 = kFALSE;
118 /* main loop (infinite) */
120 //for(Int_t k = 0; k < 20; k++) {
121 struct eventHeaderStruct *event;
122 eventTypeType eventT;
124 /* check shutdown condition */
125 if (daqDA_checkShutdown()) {break;}
127 /* get next event (blocking call until timeout) */
128 status=monitorGetEventDynamic((void **)&event);
129 if (status==MON_ERR_EOF) {
130 printf ("End of File detected\n");
131 break; /* end of monitoring file has been reached */
135 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
139 /* retry if got no event */
144 printf(" physic event number %d will be processed\n",(Int_t) nevents_physics);
147 /* use event - here, just write event id to result file */
148 eventT=event->eventType;
150 // pad status calibration: we try a first time to see if zero suppressed or not
153 printf("pad status calibration\n");
154 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
155 AliTRDRawStream *trdRawStream = new AliTRDRawStream((AliRawReader *) rawReader);
156 if(!calibpad.ProcessEvent(trdRawStream)) passpadstatus = kFALSE;
162 // vdrift calibration: run only for physics events
164 if ((eventT==PHYSICS_EVENT) && (!passpadstatus)) {
165 //if (eventT==PHYSICS_EVENT) {
166 printf("vdrift calibration\n");
167 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
168 AliTRDRawStream *trdRawStream = new AliTRDRawStream((AliRawReader *) rawReader);
169 if(calibra->ProcessEventDAQ(trdRawStream)) passvdrift = kTRUE;
184 /* exit when last event received, no need to wait for TERM signal */
185 if (eventT==END_OF_RUN) {
186 printf("EOR event detected\n");
192 // Write a local file and put it on the FX
194 TFile *fileTRD = new TFile("trdCalibration.root","recreate");
195 Bool_t passwrite = kFALSE;
200 // We do this at the shuttle maybe!
201 //calibpad.AnalyseHisto();
202 //AliTRDCalPadStatus *calPadStatus = calibpad.CreateCalPadStatus();
203 calibpad.Write("calibpadstatus");
209 if((nevents_physics > 0) && passvdrift){
210 Double_t *stat = calibra->StatH((TH2 *)(calibra->GetPH2d()),1);
211 // write only of enough statistics
213 calibra->GetPH2d()->Write();
221 if(daqDA_FES_storeFile("trdCalibration.root","trdCalibration.root")) status = -2;