]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | ||
3 | Contact: r.bailhache@gsi.de | |
4 | Link: | |
5 | Reference run: 25909 | |
6 | Run Type: PHYSICS STANDALONE | |
7 | DA Type: MON | |
8 | Number of events needed: many | |
9 | Input Files: TRD raw files | |
10 | Output Files: trdCalibrationv.root | |
11 | Trigger types used: PHYSICS_EVENT | |
12 | ||
13 | */ | |
14 | ||
15 | #define RESULT_FILE "trdVdrift.root" | |
16 | #define FILE_ID "VDRIFT" | |
17 | ||
18 | ||
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> | |
35 | #include <TDirectory.h> | |
36 | #include <TSystem.h> | |
37 | #include <TFile.h> | |
38 | #include "TROOT.h" | |
39 | #include "TPluginManager.h" | |
40 | // | |
41 | //AliRoot includes | |
42 | // | |
43 | #include "AliRawReader.h" | |
44 | #include "AliRawReaderDate.h" | |
45 | #include "AliTRDrawStream.h" | |
46 | #include "AliTRDrawStreamBase.h" | |
47 | ||
48 | ||
49 | // | |
50 | // TRD calibration algorithm includes | |
51 | // | |
52 | #include "AliTRDCalibraFillHisto.h" | |
53 | ||
54 | ||
55 | ||
56 | ||
57 | /* Main routine | |
58 | Arguments: | |
59 | 1- monitoring data source | |
60 | */ | |
61 | int main(int argc, char **argv) { | |
62 | ||
63 | /* magic line from Rene */ | |
64 | gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo", | |
65 | "*", | |
66 | "TStreamerInfo", | |
67 | "RIO", | |
68 | "TStreamerInfo()"); | |
69 | int status; | |
70 | ||
71 | if (argc!=2) { | |
72 | printf("Wrong number of arguments\n"); | |
73 | return -1; | |
74 | } | |
75 | ||
76 | ||
77 | /* define data source : this is argument 1 */ | |
78 | status=monitorSetDataSource( argv[1] ); | |
79 | if (status!=0) { | |
80 | printf("monitorSetDataSource() failed : %s\n",monitorDecodeError(status)); | |
81 | return -1; | |
82 | } | |
83 | ||
84 | ||
85 | /* declare monitoring program */ | |
86 | status=monitorDeclareMp( __FILE__ ); | |
87 | if (status!=0) { | |
88 | printf("monitorDeclareMp() failed : %s\n",monitorDecodeError(status)); | |
89 | return -1; | |
90 | } | |
91 | ||
92 | ||
93 | /* define wait event timeout - 1s max */ | |
94 | monitorSetNowait(); | |
95 | monitorSetNoWaitNetworkTimeout(1000); | |
96 | ||
97 | ||
98 | /* log start of process */ | |
99 | printf("TRD DA VDRIFT started\n"); | |
100 | ||
101 | ||
102 | /* init some counters */ | |
103 | int nevents_physics=0; | |
104 | int nevents_total=0; | |
105 | ||
106 | //Instance of AliCDBManager: needed by AliTRDRawStreamV2 | |
107 | //AliCDBManager *man = AliCDBManager::Instance(); | |
108 | //man->SetDefaultStorage("local://$ALICE_ROOT"); | |
109 | //man->SetRun(0); | |
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 | |
115 | ||
116 | // setting | |
117 | // AliTRDrawStream::SetNoDebug(); | |
118 | AliTRDrawStream::SetNoErrorWarning(); | |
119 | //AliTRDrawStream::SetForceCleanDataOnly(); | |
120 | AliTRDrawStream::AllowCorruptedData(); | |
121 | AliTRDrawStream::DisableStackNumberChecker(); | |
122 | AliTRDrawStream::DisableStackLinkNumberChecker(); | |
123 | //AliTRDrawStream::SetSkipCDH(); | |
124 | //AliTRDrawStream::SetExtraWordsFix(); | |
125 | //AliTRDrawStream::EnableDebugStream(); | |
126 | //AliTRDrawStream::SetDumpHead(320); | |
127 | //AliTRDrawStream::SetDumpHead(80); | |
128 | ||
129 | ||
130 | /* main loop (infinite) */ | |
131 | for(;;) { | |
132 | //for(Int_t k = 0; k < 20; k++) { | |
133 | struct eventHeaderStruct *event; | |
134 | eventTypeType eventT; | |
135 | ||
136 | /* check shutdown condition */ | |
137 | if (daqDA_checkShutdown()) {break;} | |
138 | ||
139 | /* get next event (blocking call until timeout) */ | |
140 | status=monitorGetEventDynamic((void **)&event); | |
141 | if (status==MON_ERR_EOF) { | |
142 | printf ("End of File detected\n"); | |
143 | break; /* end of monitoring file has been reached */ | |
144 | } | |
145 | ||
146 | if (status!=0) { | |
147 | printf("monitorGetEventDynamic() failed : %s\n",monitorDecodeError(status)); | |
148 | break; | |
149 | } | |
150 | ||
151 | /* retry if got no event */ | |
152 | if (event==NULL) { | |
153 | continue; | |
154 | } | |
155 | ||
156 | 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); | |
157 | ||
158 | ||
159 | /* use event - here, just write event id to result file */ | |
160 | eventT=event->eventType; | |
161 | ||
162 | // | |
163 | // vdrift calibration: run only for physics events | |
164 | // | |
165 | if ((eventT==PHYSICS_EVENT) && (passvdrift)) { | |
166 | //if (eventT==PHYSICS_EVENT) { | |
167 | AliRawReader *rawReader = new AliRawReaderDate((void*)event); | |
168 | rawReader->Select("TRD"); | |
169 | AliTRDrawStream *trdRawStream = new AliTRDrawStream((AliRawReader *) rawReader); | |
170 | Int_t result = calibra->ProcessEventDAQ((AliTRDrawStreamBase *) trdRawStream,(Bool_t)nbvdrift); | |
171 | if(!result) passvdrift = kFALSE; | |
172 | else nbvdrift += (Int_t) result/2; | |
173 | ||
174 | delete trdRawStream; | |
175 | delete rawReader; | |
176 | ||
177 | } | |
178 | ||
179 | if(eventT==PHYSICS_EVENT){ | |
180 | ||
181 | nevents_physics++; | |
182 | ||
183 | } | |
184 | ||
185 | nevents_total++; | |
186 | ||
187 | ||
188 | /* free resources */ | |
189 | free(event); | |
190 | ||
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"); | |
194 | break; | |
195 | } | |
196 | } | |
197 | ||
198 | ||
199 | /* report progress */ | |
200 | printf("%d events processed and %d used\n",nevents_total,nbvdrift); | |
201 | ||
202 | // | |
203 | // Write a local file and put it on the FX | |
204 | // | |
205 | TFile *fileTRD = new TFile(RESULT_FILE,"recreate"); | |
206 | ||
207 | if((nbvdrift > 0) && passvdrift){ | |
208 | //Double_t *stat = calibra->StatH((TH2 *)(calibra->GetPH2d()),1); | |
209 | //if((stat[6] < 0.20) && (stat[5] > 3000.0)) { | |
210 | // write the histogram in any case to see if problems | |
211 | calibra->GetPH2d()->Write(); | |
212 | //} | |
213 | } | |
214 | fileTRD->Close(); | |
215 | status=0; | |
216 | // Export the file in any case to see if problems | |
217 | if(daqDA_FES_storeFile(RESULT_FILE,FILE_ID)) status = -2; | |
218 | ||
219 | delete fileTRD; | |
220 | ||
221 | return status; | |
222 | } |