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 "trdVdrift.root"
16 #define FILE_ID "VDRIFT"
32 #include <TObjArray.h>
35 #include <TDirectory.h>
39 #include "TPluginManager.h"
43 #include "AliRawReader.h"
44 #include "AliRawReaderDate.h"
45 #include "AliTRDrawStream.h"
46 #include "AliTRDrawStreamBase.h"
50 // TRD calibration algorithm includes
52 #include "AliTRDCalibraFillHisto.h"
59 1- monitoring data source
61 int main(int argc, char **argv) {
63 /* magic line from Rene */
64 gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
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 neventsphysics=0;
106 //Instance of AliCDBManager: needed by AliTRDrawStream
107 //AliCDBManager *man = AliCDBManager::Instance();
108 //man->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
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 // AliTRDrawStream::SetNoDebug();
118 AliTRDrawStream::DisableSkipData();
119 AliTRDrawStream::SetNoErrorWarning();
120 //AliTRDrawStream::SetSubtractBaseline(0);
121 //AliTRDrawStream::SetForceCleanDataOnly();
122 //AliTRDrawStream::AllowCorruptedData();
123 //AliTRDrawStream::DisableStackNumberChecker();
124 //AliTRDrawStream::DisableStackLinkNumberChecker();
125 //AliTRDrawStream::SetSkipCDH();
126 //AliTRDrawStream::SetExtraWordsFix();
127 //AliTRDrawStream::EnableDebugStream();
128 //AliTRDrawStream::SetDumpHead(320);
129 //AliTRDrawStream::SetDumpHead(80);
132 /* main loop (infinite) */
134 //for(Int_t k = 0; k < 20; k++) {
135 struct eventHeaderStruct *event;
136 eventTypeType eventT;
138 /* check shutdown condition */
139 if (daqDA_checkShutdown()) {break;}
141 /* get next event (blocking call until timeout) */
142 status=monitorGetEventDynamic((void **)&event);
143 if (status==MON_ERR_EOF) {
144 printf ("End of File detected\n");
145 break; /* end of monitoring file has been reached */
149 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
153 /* retry if got no event */
158 if( ((Int_t)neventstotal)%1000 == 0 ) printf(" event number %d (physic event number %d) will be processed\n",(Int_t) neventstotal,(Int_t) neventsphysics);
161 /* use event - here, just write event id to result file */
162 eventT=event->eventType;
165 // vdrift calibration: run only for physics events
167 if ((eventT==PHYSICS_EVENT) && (passvdrift)) {
168 //if (eventT==PHYSICS_EVENT) {
169 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
170 rawReader->Select("TRD");
171 AliTRDrawStream *trdRawStream = new AliTRDrawStream((AliRawReader *) rawReader);
172 Int_t result = calibra->ProcessEventDAQ((AliTRDrawStreamBase *) trdRawStream,(Bool_t)nbvdrift);
173 if(!result) passvdrift = kFALSE;
174 else nbvdrift += (Int_t) result/2;
181 if(eventT==PHYSICS_EVENT){
193 /* exit when last event received, no need to wait for TERM signal */
194 if (eventT==END_OF_RUN) {
195 printf("EOR event detected\n");
201 /* report progress */
202 printf("%d events processed and %d used\n",neventstotal,nbvdrift);
205 // Write a local file and put it on the FX
207 TFile *fileTRD = new TFile(RESULT_FILE,"recreate");
209 if((nbvdrift > 0) && passvdrift){
210 //Double_t *stat = calibra->StatH((TH2 *)(calibra->GetPH2d()),1);
211 //if((stat[6] < 0.20) && (stat[5] > 3000.0)) {
212 // write the histogram in any case to see if problems
213 calibra->GetPH2d()->Write();
218 // Export the file in any case to see if problems
219 if(daqDA_FES_storeFile(RESULT_FILE,FILE_ID)) status = -2;