]>
Commit | Line | Data |
---|---|---|
170c35f1 | 1 | /* |
2 | ||
c5348551 | 3 | Contact: r.bailhache@gsi.de |
27b46d95 | 4 | Link: |
5 | Reference run: 25909 | |
25781e34 | 6 | Run Type: PHYSICS STANDALONE |
c5348551 | 7 | DA Type: MON |
27b46d95 | 8 | Number of events needed: many |
9 | Input Files: TRD raw files | |
10 | Output Files: trdCalibrationv.root | |
11 | Trigger types used: PHYSICS_EVENT | |
170c35f1 | 12 | |
13 | */ | |
14 | ||
5f518e55 | 15 | #define RESULT_FILE "trdVdrift.root" |
16 | #define FILE_ID "VDRIFT" | |
6ace5fe2 | 17 | |
18 | ||
170c35f1 | 19 | extern "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" | |
80cb9622 | 45 | #include "AliTRDrawStreamTB.h" |
27b46d95 | 46 | |
170c35f1 | 47 | |
48 | // | |
49 | // TRD calibration algorithm includes | |
50 | // | |
170c35f1 | 51 | #include "AliTRDCalibraFillHisto.h" |
52 | ||
53 | ||
54 | ||
55 | ||
56 | /* Main routine | |
57 | Arguments: | |
58 | 1- monitoring data source | |
59 | */ | |
60 | int main(int argc, char **argv) { | |
61 | ||
25781e34 | 62 | /* magic line from Rene */ |
63 | gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo", | |
64 | "*", | |
65 | "TStreamerInfo", | |
66 | "RIO", | |
67 | "TStreamerInfo()"); | |
170c35f1 | 68 | int status; |
69 | ||
70 | if (argc!=2) { | |
71 | printf("Wrong number of arguments\n"); | |
72 | return -1; | |
73 | } | |
74 | ||
75 | ||
76 | /* define data source : this is argument 1 */ | |
77 | status=monitorSetDataSource( argv[1] ); | |
78 | if (status!=0) { | |
79 | printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status)); | |
80 | return -1; | |
81 | } | |
82 | ||
83 | ||
84 | /* declare monitoring program */ | |
85 | status=monitorDeclareMp( __FILE__ ); | |
86 | if (status!=0) { | |
87 | printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status)); | |
88 | return -1; | |
89 | } | |
90 | ||
91 | ||
92 | /* define wait event timeout - 1s max */ | |
93 | monitorSetNowait(); | |
94 | monitorSetNoWaitNetworkTimeout(1000); | |
95 | ||
96 | ||
97 | /* log start of process */ | |
6ace5fe2 | 98 | printf("TRD DA VDRIFT started\n"); |
170c35f1 | 99 | |
100 | ||
101 | /* init some counters */ | |
102 | int nevents_physics=0; | |
103 | int nevents_total=0; | |
104 | ||
289cc637 | 105 | //Instance of AliCDBManager: needed by AliTRDRawStreamV2 |
27b46d95 | 106 | //AliCDBManager *man = AliCDBManager::Instance(); |
107 | //man->SetDefaultStorage("local://$ALICE_ROOT"); | |
108 | //man->SetRun(0); | |
170c35f1 | 109 | //Instance of AliTRDCalibraFillHisto |
110 | AliTRDCalibraFillHisto *calibra = AliTRDCalibraFillHisto::Instance(); | |
170c35f1 | 111 | // everythings are okey for vdrift |
3a0f6479 | 112 | Bool_t passvdrift = kTRUE; // if timebin okey |
113 | Int_t nbvdrift = 0; // number of events with entries for vdrift | |
170c35f1 | 114 | |
162a3e73 | 115 | // setting |
116 | // AliTRDrawStreamTB::SetNoDebug(); | |
117 | AliTRDrawStreamTB::SetNoErrorWarning(); | |
5f518e55 | 118 | //AliTRDrawStreamTB::SetForceCleanDataOnly(); |
162a3e73 | 119 | AliTRDrawStreamTB::AllowCorruptedData(); |
5f518e55 | 120 | AliTRDrawStreamTB::DisableStackNumberChecker(); |
121 | AliTRDrawStreamTB::DisableStackLinkNumberChecker(); | |
162a3e73 | 122 | //AliTRDrawStreamTB::SetSkipCDH(); |
123 | //AliTRDrawStreamTB::SetExtraWordsFix(); | |
124 | //AliTRDrawStreamTB::EnableDebugStream(); | |
125 | //AliTRDrawStreamTB::SetDumpHead(320); | |
126 | //AliTRDrawStreamTB::SetDumpHead(80); | |
f222df8d | 127 | |
170c35f1 | 128 | |
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 | ||
25781e34 | 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); |
170c35f1 | 156 | |
157 | ||
158 | /* use event - here, just write event id to result file */ | |
159 | eventT=event->eventType; | |
6ace5fe2 | 160 | |
170c35f1 | 161 | // |
162 | // vdrift calibration: run only for physics events | |
163 | // | |
6ace5fe2 | 164 | if ((eventT==PHYSICS_EVENT) && (passvdrift)) { |
170c35f1 | 165 | //if (eventT==PHYSICS_EVENT) { |
170c35f1 | 166 | AliRawReader *rawReader = new AliRawReaderDate((void*)event); |
80cb9622 | 167 | AliTRDrawStreamTB *trdRawStream = new AliTRDrawStreamTB((AliRawReader *) rawReader); |
3a0f6479 | 168 | Int_t result = calibra->ProcessEventDAQ(trdRawStream,(Bool_t)nevents_physics); |
169 | if(!result) passvdrift = kFALSE; | |
170 | else nbvdrift += (Int_t) result/2; | |
5750af0a | 171 | |
172 | ||
170c35f1 | 173 | delete trdRawStream; |
174 | delete rawReader; | |
175 | } | |
176 | ||
5750af0a | 177 | if(eventT==PHYSICS_EVENT){ |
178 | ||
179 | nevents_physics++; | |
180 | ||
181 | } | |
170c35f1 | 182 | |
183 | nevents_total++; | |
184 | ||
185 | ||
186 | /* free resources */ | |
187 | free(event); | |
188 | ||
189 | /* exit when last event received, no need to wait for TERM signal */ | |
190 | if (eventT==END_OF_RUN) { | |
191 | printf("EOR event detected\n"); | |
192 | break; | |
193 | } | |
194 | } | |
195 | ||
6ace5fe2 | 196 | |
197 | /* report progress */ | |
198 | printf("%d events processed and %d used\n",nevents_total,nbvdrift); | |
199 | ||
170c35f1 | 200 | // |
201 | // Write a local file and put it on the FX | |
202 | // | |
6ace5fe2 | 203 | TFile *fileTRD = new TFile(RESULT_FILE,"recreate"); |
204 | ||
3a0f6479 | 205 | if((nbvdrift > 0) && passvdrift){ |
6ace5fe2 | 206 | //Double_t *stat = calibra->StatH((TH2 *)(calibra->GetPH2d()),1); |
207 | //if((stat[6] < 0.20) && (stat[5] > 3000.0)) { | |
208 | // write the histogram in any case to see if problems | |
209 | calibra->GetPH2d()->Write(); | |
210 | //} | |
170c35f1 | 211 | } |
212 | fileTRD->Close(); | |
213 | status=0; | |
6ace5fe2 | 214 | // Export the file in any case to see if problems |
5f518e55 | 215 | if(daqDA_FES_storeFile(RESULT_FILE,FILE_ID)) status = -2; |
6ace5fe2 | 216 | |
170c35f1 | 217 | delete fileTRD; |
218 | ||
219 | return status; | |
220 | } |