]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/TRDVDRIFTda.cxx
do not use class AliTRDrawStreamBase in preparation for modifications in the TRD...
[u/mrichter/AliRoot.git] / TRD / TRDVDRIFTda.cxx
CommitLineData
170c35f1 1/*
2
c5348551 3Contact: r.bailhache@gsi.de
27b46d95 4Link:
5Reference run: 25909
25781e34 6Run Type: PHYSICS STANDALONE
c5348551 7DA Type: MON
27b46d95 8Number of events needed: many
9Input Files: TRD raw files
10Output Files: trdCalibrationv.root
11Trigger types used: PHYSICS_EVENT
170c35f1 12
13*/
14
5f518e55 15#define RESULT_FILE "trdVdrift.root"
16#define FILE_ID "VDRIFT"
6ace5fe2 17
18
170c35f1 19extern "C" {
20#include <daqDA.h>
21}
22
23#include "event.h"
24#include "monitor.h"
25#include <stdio.h>
26#include <stdlib.h>
27
28
29//
30//Root includes
31//
32#include <TObjArray.h>
33#include <TString.h>
34#include <TVectorF.h>
170c35f1 35#include <TDirectory.h>
36#include <TSystem.h>
37#include <TFile.h>
25781e34 38#include "TROOT.h"
39#include "TPluginManager.h"
170c35f1 40//
41//AliRoot includes
42//
43#include "AliRawReader.h"
44#include "AliRawReaderDate.h"
fd50bb14 45//#include "AliTRDrawFastStream.h"
46//#include "AliTRDrawStreamBase.h"
47#include "AliLog.h"
27b46d95 48
1785640c 49//
50//AMORE
51//
52#include <AmoreDA.h>
170c35f1 53
54//
55// TRD calibration algorithm includes
56//
170c35f1 57#include "AliTRDCalibraFillHisto.h"
58
1785640c 59//functions, implementation below
60//void SendToAmoreDB(TObject *o, unsigned long32 runNb);
170c35f1 61
62
63/* Main routine
64 Arguments:
65 1- monitoring data source
66*/
67int main(int argc, char **argv) {
68
25781e34 69 /* magic line from Rene */
70 gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo",
71 "*",
72 "TStreamerInfo",
73 "RIO",
74 "TStreamerInfo()");
170c35f1 75 int status;
76
77 if (argc!=2) {
78 printf("Wrong number of arguments\n");
79 return -1;
80 }
81
82
83 /* define data source : this is argument 1 */
84 status=monitorSetDataSource( argv[1] );
85 if (status!=0) {
86 printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status));
87 return -1;
88 }
89
90
91 /* declare monitoring program */
92 status=monitorDeclareMp( __FILE__ );
93 if (status!=0) {
94 printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status));
95 return -1;
96 }
97
98
99 /* define wait event timeout - 1s max */
100 monitorSetNowait();
101 monitorSetNoWaitNetworkTimeout(1000);
102
103
104 /* log start of process */
6ace5fe2 105 printf("TRD DA VDRIFT started\n");
170c35f1 106
107
108 /* init some counters */
1785640c 109 int nevents_physics=0;
110 int nevents_total=0;
111 //unsigned long32 runNb=0; //run number
170c35f1 112
09ea3770 113 //Instance of AliCDBManager: needed by AliTRDrawFastStream
27b46d95 114 //AliCDBManager *man = AliCDBManager::Instance();
162637e4 115 //man->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
27b46d95 116 //man->SetRun(0);
170c35f1 117 //Instance of AliTRDCalibraFillHisto
118 AliTRDCalibraFillHisto *calibra = AliTRDCalibraFillHisto::Instance();
6aafa7ea 119 calibra->SetNumberClustersProcent(0.9);
1785640c 120
170c35f1 121 // everythings are okey for vdrift
3a0f6479 122 Bool_t passvdrift = kTRUE; // if timebin okey
123 Int_t nbvdrift = 0; // number of events with entries for vdrift
170c35f1 124
162a3e73 125 // setting
fd50bb14 126 //AliTRDrawFastStream::DisableSkipData();
127 AliLog::SetGlobalLogLevel(AliLog::kFatal);
09ea3770 128
170c35f1 129 /* main loop (infinite) */
130 for(;;) {
131 //for(Int_t k = 0; k < 20; k++) {
132 struct eventHeaderStruct *event;
133 eventTypeType eventT;
6ace5fe2 134
170c35f1 135 /* check shutdown condition */
136 if (daqDA_checkShutdown()) {break;}
137
138 /* get next event (blocking call until timeout) */
139 status=monitorGetEventDynamic((void **)&event);
140 if (status==MON_ERR_EOF) {
141 printf ("End of File detected\n");
142 break; /* end of monitoring file has been reached */
143 }
144
145 if (status!=0) {
146 printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status));
147 break;
148 }
149
150 /* retry if got no event */
151 if (event==NULL) {
152 continue;
153 }
154
1785640c 155 if( ((Int_t)nevents_total)%1000 == 0 ) printf(" event number %d (physic event number %d) will be processed\n",(Int_t) nevents_total,(Int_t) nevents_physics);
156
157
170c35f1 158
170c35f1 159 /* use event - here, just write event id to result file */
160 eventT=event->eventType;
6ace5fe2 161
170c35f1 162 //
163 // vdrift calibration: run only for physics events
164 //
6ace5fe2 165 if ((eventT==PHYSICS_EVENT) && (passvdrift)) {
170c35f1 166 //if (eventT==PHYSICS_EVENT) {
170c35f1 167 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
5ac2a9f9 168 rawReader->Select("TRD");
1785640c 169
068b874f 170 Int_t result = calibra->ProcessEventDAQ2((AliRawReader *)rawReader);
3a0f6479 171 if(!result) passvdrift = kFALSE;
172 else nbvdrift += (Int_t) result/2;
5750af0a 173
1785640c 174
170c35f1 175 delete rawReader;
5ac2a9f9 176
170c35f1 177 }
1785640c 178
179 // get the run number
180 //runNb = event->eventRunNb;
170c35f1 181
5750af0a 182 if(eventT==PHYSICS_EVENT){
183
1785640c 184 nevents_physics++;
5750af0a 185
186 }
170c35f1 187
1785640c 188 /*
189 if( ((Int_t)nevents_physics)%100 == 0 ) {
190 SendToAmoreDB(&calibra);
191 }
192 */
193
194
195 nevents_total++;
170c35f1 196
197
198 /* free resources */
199 free(event);
200
201 /* exit when last event received, no need to wait for TERM signal */
202 if (eventT==END_OF_RUN) {
203 printf("EOR event detected\n");
204 break;
205 }
206 }
207
6ace5fe2 208
209 /* report progress */
1785640c 210 printf("%d events processed and %d used\n",nevents_total,nbvdrift);
6ace5fe2 211
170c35f1 212 //
213 // Write a local file and put it on the FX
214 //
6ace5fe2 215 TFile *fileTRD = new TFile(RESULT_FILE,"recreate");
216
3a0f6479 217 if((nbvdrift > 0) && passvdrift){
6ace5fe2 218 //Double_t *stat = calibra->StatH((TH2 *)(calibra->GetPH2d()),1);
219 //if((stat[6] < 0.20) && (stat[5] > 3000.0)) {
220 // write the histogram in any case to see if problems
221 calibra->GetPH2d()->Write();
222 //}
170c35f1 223 }
224 fileTRD->Close();
225 status=0;
6ace5fe2 226 // Export the file in any case to see if problems
5f518e55 227 if(daqDA_FES_storeFile(RESULT_FILE,FILE_ID)) status = -2;
6ace5fe2 228
170c35f1 229 delete fileTRD;
230
231 return status;
1ac4bb35 232}
0ca1720e 233
09ea3770 234/*
235 void SendToAmoreDB(TObject *o)
236 {
237 //AMORE
238 const char *amoreDANameorig=gSystem->Getenv("AMORE_DA_NAME");
239 gSystem->Setenv("AMORE_DA_NAME","TRD-dataQA");
240
241 amore::da::AmoreDA amoreDA(amore::da::AmoreDA::kSender);
242 Int_t statusDA=0;
243 statusDA+=amoreDA.Send("DataQA-VDRIFT",o);
244 if ( statusDA!=0 )
245 printf("Waring: Failed to write one of the calib objects to the AMORE database\n");
246 // reset env var
247 if (amoreDANameorig) gSystem->Setenv("AMORE_DA_NAME",amoreDANameorig);
248 }
249*/
068b874f 250
251