1 |
mocchiut |
1.1 |
// |
2 |
|
|
// C/C++ headers |
3 |
|
|
// |
4 |
|
|
#include <iostream> |
5 |
|
|
#include <sstream> |
6 |
|
|
// |
7 |
|
|
// ROOT headers |
8 |
|
|
// |
9 |
|
|
#include <TString.h> |
10 |
|
|
#include <TSQLServer.h> |
11 |
|
|
#include <TFile.h> |
12 |
|
|
#include <TSystem.h> |
13 |
|
|
// |
14 |
|
|
// Detector's package headers |
15 |
|
|
// |
16 |
|
|
#include <RunInfoCore.h> |
17 |
|
|
#include <TrkCore.h> |
18 |
|
|
#include <TrigCore.h> |
19 |
|
|
#include <ToFCore.h> |
20 |
|
|
#include <CaloCore.h> |
21 |
|
|
#include <AcCore.h> |
22 |
|
|
#include <S4Core.h> |
23 |
|
|
#include <NDCore.h> |
24 |
|
|
#include <OrbitalInfoCore.h> |
25 |
mocchiut |
1.4 |
#include <RunInfo.h> |
26 |
mocchiut |
1.1 |
// |
27 |
|
|
using namespace std; |
28 |
|
|
// |
29 |
|
|
// |
30 |
|
|
// |
31 |
|
|
#include <DarthVaderVerl2.h> |
32 |
|
|
// |
33 |
|
|
// Usage subroutine |
34 |
|
|
// |
35 |
|
|
void usage(){ |
36 |
|
|
printf("\nUsage:\n"); |
37 |
|
|
printf("\n DarthVader [-v | --verbose] [-h | --help] [--version] -idRun ID_RUN [-processFile filename]\n"); |
38 |
mocchiut |
1.8 |
printf("\n [-host host] [-user username] [-psw password] [+-all] [+-detector [ detector options ] ]\n"); |
39 |
mocchiut |
1.1 |
printf("\n --version print informations about compilation and exit\n"); |
40 |
|
|
printf("\n -h | --help print this help and exit \n"); |
41 |
mocchiut |
1.10 |
printf("\n -v | --verbose be verbose [default]\n"); |
42 |
|
|
printf("\n -s | --silent print nothing on STDOUT]\n"); |
43 |
mocchiut |
1.1 |
printf("\n -idRun ID_RUN: ID number of the run to be processed \n"); |
44 |
|
|
printf("\n -processFile output filename [default ID_RUN.Level2.root]\n"); |
45 |
mocchiut |
1.10 |
printf("\n -host name for the host [default = $PAM_DBHOST or mysql://localhost/pamelaprod]\n"); |
46 |
|
|
printf("\n -user username for the DB [default = $PAM_DBUSER or \"anonymous\"] \n"); |
47 |
|
|
printf("\n -psw password for the DB [default = $PAM_DBPSW or \"\"]\n"); |
48 |
mocchiut |
1.8 |
printf("\n +all | +ALL call all detectors software [default]\n"); |
49 |
|
|
printf("\n -all | -ALL call nothing\n"); |
50 |
mocchiut |
1.1 |
printf("\n +detector process detector; detector can be: TOF,TRK,CAL,TRG,ORB,S4,ND,AC,RUN\n"); |
51 |
|
|
printf("\n -detector do not process detector (as above)\n"); |
52 |
mocchiut |
1.8 |
printf("\n detector options must be included in square parenthesis with spaces, for example:\n"); |
53 |
|
|
printf("\n +CAL [ --verbose -g ] +TRK [ -v --level1 ] \n"); |
54 |
|
|
|
55 |
mocchiut |
1.1 |
printf("\nExamples: \n"); |
56 |
|
|
printf("\nStandard call: DarthVader -idRun 1085 \n"); |
57 |
|
|
printf("\nProcess only RunInfo and Tracker (be verbose for tracker): DarthVader -idRun 1085 -all +RUN +TRK [ --verbose ] \n"); |
58 |
|
|
printf("\nProcess all and be verbose for calorimeter: DarthVader -idRun 1085 +CAL [ --verbose ] \n\n"); |
59 |
|
|
}; |
60 |
|
|
// |
61 |
|
|
// Here the main |
62 |
|
|
// |
63 |
|
|
int main(int numinp, char *inps[]){ |
64 |
|
|
// |
65 |
|
|
// Variables booking |
66 |
|
|
// |
67 |
|
|
TString message; |
68 |
|
|
int nul = 0; |
69 |
|
|
Int_t error = 0; |
70 |
|
|
// |
71 |
|
|
Int_t CALSGN = 0; |
72 |
|
|
Int_t TRKSGN = 0; |
73 |
|
|
Int_t TRGSGN = 0; |
74 |
|
|
Int_t TOFSGN = 0; |
75 |
|
|
Int_t RUNSGN = 0; |
76 |
|
|
Int_t ORBSGN = 0; |
77 |
|
|
Int_t ACSGN = 0; |
78 |
|
|
Int_t S4SGN = 0; |
79 |
|
|
Int_t NDSGN = 0; |
80 |
|
|
// |
81 |
|
|
Bool_t debug = false; |
82 |
mocchiut |
1.10 |
Bool_t beverbose = true; |
83 |
mocchiut |
1.1 |
Bool_t givenid = false; |
84 |
|
|
Bool_t CAL = true; |
85 |
|
|
Bool_t TRK = true; |
86 |
|
|
Bool_t TRG = true; |
87 |
|
|
Bool_t TOF = true; |
88 |
|
|
Bool_t S4 = true; |
89 |
|
|
Bool_t ND = true; |
90 |
|
|
Bool_t AC = true; |
91 |
|
|
Bool_t ORB = true; |
92 |
|
|
Bool_t RUN = true; |
93 |
|
|
// |
94 |
|
|
Int_t calargc = 0; |
95 |
|
|
char *calargv[50]; |
96 |
|
|
Int_t trkargc = 0; |
97 |
|
|
char *trkargv[50]; |
98 |
|
|
Int_t tofargc = 0; |
99 |
|
|
char *tofargv[50]; |
100 |
|
|
Int_t trgargc = 0; |
101 |
|
|
char *trgargv[50]; |
102 |
|
|
Int_t orbargc = 0; |
103 |
|
|
char *orbargv[50]; |
104 |
|
|
Int_t runargc = 0; |
105 |
|
|
char *runargv[50]; |
106 |
|
|
Int_t acargc = 0; |
107 |
|
|
char *acargv[50]; |
108 |
|
|
Int_t s4argc = 0; |
109 |
|
|
char *s4argv[50]; |
110 |
|
|
Int_t ndargc = 0; |
111 |
|
|
char *ndargv[50]; |
112 |
|
|
// |
113 |
|
|
// |
114 |
|
|
// |
115 |
mocchiut |
1.8 |
UInt_t run = 0; |
116 |
mocchiut |
1.1 |
// |
117 |
|
|
TString filename; |
118 |
|
|
TString outDir = gSystem->WorkingDirectory(); |
119 |
|
|
// |
120 |
|
|
TSQLServer *dbc = 0; |
121 |
|
|
TString host = "mysql://localhost/pamelaprod"; |
122 |
|
|
TString user = "anonymous"; |
123 |
|
|
TString psw = ""; |
124 |
|
|
// |
125 |
mocchiut |
1.10 |
// |
126 |
|
|
const char *pamdbhost=gSystem->Getenv("PAM_DBHOST"); |
127 |
|
|
const char *pamdbuser=gSystem->Getenv("PAM_DBUSER"); |
128 |
|
|
const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW"); |
129 |
|
|
if ( strcmp(pamdbhost,"") ) host = pamdbhost; |
130 |
|
|
if ( strcmp(pamdbuser,"") ) user = pamdbuser; |
131 |
|
|
if ( strcmp(pamdbpsw,"") ) psw = pamdbpsw; |
132 |
|
|
// |
133 |
|
|
// |
134 |
mocchiut |
1.1 |
TFile *processFile = 0; |
135 |
|
|
// |
136 |
|
|
// Checking input parameters |
137 |
|
|
// |
138 |
|
|
Int_t i = 0; |
139 |
|
|
try { |
140 |
|
|
if ( numinp > 1 ){ |
141 |
|
|
while ( i < numinp ){ |
142 |
mocchiut |
1.8 |
Bool_t found = false; |
143 |
mocchiut |
1.1 |
if ( !strcmp(inps[i],"--version") ){ |
144 |
|
|
DarthVaderInfo(true); |
145 |
|
|
exit(0); |
146 |
|
|
}; |
147 |
|
|
if ( !strcmp(inps[i],"-h") || !strcmp(inps[i],"--help") ){ |
148 |
|
|
usage(); |
149 |
|
|
exit(0); |
150 |
|
|
}; |
151 |
|
|
if ( !strcmp(inps[i],"-idRun") ) { |
152 |
|
|
if ( numinp-1 < i+1 ) { |
153 |
|
|
usage(); |
154 |
|
|
throw -3; |
155 |
|
|
}; |
156 |
mocchiut |
1.8 |
i++; |
157 |
|
|
found = true; |
158 |
mocchiut |
1.1 |
givenid = true; |
159 |
mocchiut |
1.8 |
run = atoll(inps[i]); |
160 |
mocchiut |
1.1 |
}; |
161 |
|
|
if ( !strcmp(inps[i],"-processFile") ) { |
162 |
|
|
if ( numinp-1 < i+1 ){ |
163 |
|
|
usage(); |
164 |
|
|
throw -3; |
165 |
|
|
}; |
166 |
mocchiut |
1.8 |
i++; |
167 |
|
|
found = true; |
168 |
|
|
filename = (TString)inps[i]; |
169 |
mocchiut |
1.1 |
}; |
170 |
|
|
if ( !strcmp(inps[i],"-outDir") ) { |
171 |
|
|
if ( numinp-1 < i+1 ){ |
172 |
|
|
usage(); |
173 |
|
|
throw -3; |
174 |
|
|
}; |
175 |
mocchiut |
1.8 |
i++; |
176 |
|
|
found = true; |
177 |
|
|
outDir = (TString)inps[i]; |
178 |
mocchiut |
1.1 |
}; |
179 |
|
|
if ( !strcmp(inps[i],"-host") ) { |
180 |
|
|
if ( numinp-1 < i+1 ){ |
181 |
|
|
usage(); |
182 |
|
|
throw -3; |
183 |
|
|
}; |
184 |
mocchiut |
1.8 |
i++; |
185 |
|
|
found = true; |
186 |
|
|
host = (TString)inps[i]; |
187 |
mocchiut |
1.1 |
}; |
188 |
|
|
if ( !strcmp(inps[i],"-user") ) { |
189 |
|
|
if ( numinp-1 < i+1 ){ |
190 |
|
|
usage(); |
191 |
|
|
throw -3; |
192 |
|
|
}; |
193 |
mocchiut |
1.8 |
i++; |
194 |
|
|
found = true; |
195 |
|
|
user = (TString)inps[i]; |
196 |
mocchiut |
1.1 |
}; |
197 |
|
|
if ( !strcmp(inps[i],"-psw") ) { |
198 |
|
|
if ( numinp-1 < i+1 ){ |
199 |
|
|
usage(); |
200 |
|
|
throw -3; |
201 |
|
|
}; |
202 |
mocchiut |
1.8 |
i++; |
203 |
|
|
found = true; |
204 |
|
|
psw = (TString)inps[i]; |
205 |
|
|
}; |
206 |
|
|
if ( !strcmp(inps[i],"-v") || !strcmp(inps[i],"--verbose") ){ |
207 |
|
|
found = true; |
208 |
|
|
beverbose = true; |
209 |
mocchiut |
1.1 |
}; |
210 |
mocchiut |
1.10 |
if ( !strcmp(inps[i],"-s") || !strcmp(inps[i],"--silent") ){ |
211 |
|
|
found = true; |
212 |
|
|
beverbose = false; |
213 |
|
|
}; |
214 |
mocchiut |
1.1 |
// |
215 |
mocchiut |
1.8 |
if ( !strcmp(inps[i],"-g") || !strcmp(inps[i],"--debug") ){ |
216 |
|
|
debug = true; |
217 |
|
|
found = true; |
218 |
|
|
}; |
219 |
mocchiut |
1.1 |
// |
220 |
|
|
if ( !strcmp(inps[i],"-CAL") ) { |
221 |
mocchiut |
1.8 |
found = true; |
222 |
mocchiut |
1.1 |
CAL = false; |
223 |
|
|
}; |
224 |
|
|
if ( !strcmp(inps[i],"-TRK") ) { |
225 |
mocchiut |
1.8 |
found = true; |
226 |
mocchiut |
1.1 |
TRK = false; |
227 |
|
|
}; |
228 |
|
|
if ( !strcmp(inps[i],"-TOF") ) { |
229 |
mocchiut |
1.8 |
found = true; |
230 |
mocchiut |
1.1 |
TOF = false; |
231 |
|
|
}; |
232 |
|
|
if ( !strcmp(inps[i],"-TRG") ) { |
233 |
mocchiut |
1.8 |
found = true; |
234 |
mocchiut |
1.1 |
TRG = false; |
235 |
|
|
}; |
236 |
|
|
if ( !strcmp(inps[i],"-S4") ) { |
237 |
mocchiut |
1.8 |
found = true; |
238 |
mocchiut |
1.1 |
S4 = false; |
239 |
|
|
}; |
240 |
|
|
if ( !strcmp(inps[i],"-ND") ) { |
241 |
mocchiut |
1.8 |
found = true; |
242 |
mocchiut |
1.1 |
ND = false; |
243 |
|
|
}; |
244 |
|
|
if ( !strcmp(inps[i],"-AC") ) { |
245 |
mocchiut |
1.8 |
found = true; |
246 |
mocchiut |
1.1 |
AC = false; |
247 |
|
|
}; |
248 |
|
|
if ( !strcmp(inps[i],"-RUN") ) { |
249 |
mocchiut |
1.8 |
found = true; |
250 |
mocchiut |
1.1 |
RUN = false; |
251 |
|
|
}; |
252 |
|
|
if ( !strcmp(inps[i],"-ORB") ) { |
253 |
mocchiut |
1.8 |
found = true; |
254 |
mocchiut |
1.1 |
ORB = false; |
255 |
|
|
}; |
256 |
|
|
// |
257 |
mocchiut |
1.8 |
if ( !strcmp(inps[i],"-all") || !strcmp(inps[i],"-ALL") ) { |
258 |
mocchiut |
1.1 |
CAL = false; |
259 |
|
|
ORB = false; |
260 |
|
|
TRK = false; |
261 |
|
|
TRG = false; |
262 |
|
|
TOF = false; |
263 |
|
|
S4 = false; |
264 |
|
|
ND = false; |
265 |
|
|
AC = false; |
266 |
|
|
RUN = false; |
267 |
mocchiut |
1.8 |
found = true; |
268 |
mocchiut |
1.1 |
}; |
269 |
|
|
// |
270 |
mocchiut |
1.8 |
if ( !strcmp(inps[i],"+all") || !strcmp(inps[i],"+ALL") ) { |
271 |
mocchiut |
1.1 |
CAL = true; |
272 |
|
|
ORB = true; |
273 |
|
|
TRK = true; |
274 |
|
|
TRG = true; |
275 |
|
|
TOF = true; |
276 |
|
|
S4 = true; |
277 |
|
|
ND = true; |
278 |
|
|
AC = true; |
279 |
|
|
RUN = true; |
280 |
mocchiut |
1.8 |
found = true; |
281 |
mocchiut |
1.1 |
}; |
282 |
|
|
// |
283 |
|
|
if ( !strcmp(inps[i],"+CAL") ) { |
284 |
mocchiut |
1.8 |
found = true; |
285 |
mocchiut |
1.1 |
CAL = true; |
286 |
|
|
if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){ |
287 |
|
|
if ( numinp < i+2 ){ |
288 |
|
|
usage(); |
289 |
|
|
throw -3; |
290 |
|
|
}; |
291 |
|
|
i += 2; |
292 |
|
|
calargc = 0; |
293 |
|
|
while ( strcmp(inps[i],"]") ){ |
294 |
|
|
calargv[calargc] = inps[i]; |
295 |
|
|
calargc++; |
296 |
|
|
i++; |
297 |
|
|
if ( i > numinp-1 ){ |
298 |
|
|
usage(); |
299 |
|
|
throw -3; |
300 |
|
|
}; |
301 |
|
|
}; |
302 |
|
|
}; |
303 |
|
|
}; |
304 |
|
|
if ( !strcmp(inps[i],"+TRK") ) { |
305 |
mocchiut |
1.8 |
found = true; |
306 |
mocchiut |
1.1 |
TRK = true; |
307 |
|
|
if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){ |
308 |
|
|
if ( numinp-1 < i+2 ){ |
309 |
|
|
usage(); |
310 |
|
|
throw -3; |
311 |
|
|
}; |
312 |
|
|
i += 2; |
313 |
|
|
trkargc = 0; |
314 |
|
|
while ( strcmp(inps[i],"]") ){ |
315 |
|
|
trkargv[trkargc] = inps[i]; |
316 |
|
|
trkargc++; |
317 |
|
|
i++; |
318 |
|
|
if ( i > numinp-1 ){ |
319 |
|
|
usage(); |
320 |
|
|
throw -3; |
321 |
|
|
}; |
322 |
|
|
}; |
323 |
|
|
}; |
324 |
|
|
}; |
325 |
|
|
if ( !strcmp(inps[i],"+TOF") ) { |
326 |
mocchiut |
1.8 |
found = true; |
327 |
mocchiut |
1.1 |
TOF = true; |
328 |
|
|
if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){ |
329 |
|
|
i += 2; |
330 |
|
|
tofargc = 0; |
331 |
|
|
while ( strcmp(inps[i],"]") ){ |
332 |
|
|
tofargv[tofargc] = inps[i]; |
333 |
|
|
tofargc++; |
334 |
|
|
i++; |
335 |
|
|
if ( i > numinp-1 ){ |
336 |
|
|
usage(); |
337 |
|
|
throw -3; |
338 |
|
|
}; |
339 |
|
|
}; |
340 |
|
|
}; |
341 |
|
|
}; |
342 |
|
|
if ( !strcmp(inps[i],"+TRG") ) { |
343 |
mocchiut |
1.8 |
found = true; |
344 |
mocchiut |
1.1 |
TRG = true; |
345 |
|
|
if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){ |
346 |
|
|
i += 2; |
347 |
|
|
trgargc = 0; |
348 |
|
|
while ( strcmp(inps[i],"]") ){ |
349 |
|
|
trgargv[trgargc] = inps[i]; |
350 |
|
|
trgargc++; |
351 |
|
|
i++; |
352 |
|
|
if ( i > numinp-1 ){ |
353 |
|
|
usage(); |
354 |
|
|
throw -3; |
355 |
|
|
}; |
356 |
|
|
}; |
357 |
|
|
}; |
358 |
|
|
}; |
359 |
|
|
if ( !strcmp(inps[i],"+ORB") ) { |
360 |
mocchiut |
1.8 |
found = true; |
361 |
mocchiut |
1.1 |
ORB = true; |
362 |
|
|
if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){ |
363 |
|
|
i += 2; |
364 |
|
|
orbargc = 0; |
365 |
|
|
while ( strcmp(inps[i],"]") ){ |
366 |
|
|
orbargv[orbargc] = inps[i]; |
367 |
|
|
orbargc++; |
368 |
|
|
i++; |
369 |
|
|
if ( i > numinp-1 ){ |
370 |
|
|
usage(); |
371 |
|
|
throw -3; |
372 |
|
|
}; |
373 |
|
|
}; |
374 |
|
|
}; |
375 |
|
|
}; |
376 |
|
|
if ( !strcmp(inps[i],"+RUN") ) { |
377 |
mocchiut |
1.8 |
found = true; |
378 |
mocchiut |
1.1 |
RUN = true; |
379 |
|
|
if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){ |
380 |
|
|
i += 2; |
381 |
|
|
runargc = 0; |
382 |
|
|
while ( strcmp(inps[i],"]") ){ |
383 |
|
|
runargv[runargc] = inps[i]; |
384 |
|
|
runargc++; |
385 |
|
|
i++; |
386 |
|
|
if ( i > numinp-1 ){ |
387 |
|
|
usage(); |
388 |
|
|
throw -3; |
389 |
|
|
}; |
390 |
|
|
}; |
391 |
|
|
}; |
392 |
|
|
}; |
393 |
|
|
if ( !strcmp(inps[i],"+AC") ) { |
394 |
mocchiut |
1.8 |
found = true; |
395 |
mocchiut |
1.1 |
AC = true; |
396 |
|
|
if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){ |
397 |
|
|
i += 2; |
398 |
|
|
acargc = 0; |
399 |
|
|
while ( strcmp(inps[i],"]") ){ |
400 |
|
|
acargv[acargc] = inps[i]; |
401 |
|
|
acargc++; |
402 |
|
|
i++; |
403 |
|
|
if ( i > numinp-1 ){ |
404 |
|
|
usage(); |
405 |
|
|
throw -3; |
406 |
|
|
}; |
407 |
|
|
}; |
408 |
|
|
}; |
409 |
|
|
}; |
410 |
|
|
if ( !strcmp(inps[i],"+S4") ) { |
411 |
mocchiut |
1.8 |
found = true; |
412 |
mocchiut |
1.1 |
S4 = true; |
413 |
|
|
if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){ |
414 |
|
|
i += 2; |
415 |
|
|
s4argc = 0; |
416 |
|
|
while ( strcmp(inps[i],"]") ){ |
417 |
|
|
s4argv[s4argc] = inps[i]; |
418 |
|
|
s4argc++; |
419 |
|
|
i++; |
420 |
|
|
if ( i > numinp-1 ){ |
421 |
|
|
usage(); |
422 |
|
|
throw -3; |
423 |
|
|
}; |
424 |
|
|
}; |
425 |
|
|
}; |
426 |
|
|
}; |
427 |
|
|
if ( !strcmp(inps[i],"+ND") ) { |
428 |
mocchiut |
1.8 |
found = true; |
429 |
mocchiut |
1.1 |
ND = true; |
430 |
|
|
if ( numinp >= i+2 && !strcmp(inps[i+1],"[") ){ |
431 |
|
|
i += 2; |
432 |
|
|
ndargc = 0; |
433 |
|
|
while ( strcmp(inps[i],"]") ){ |
434 |
|
|
ndargv[ndargc] = inps[i]; |
435 |
|
|
ndargc++; |
436 |
|
|
i++; |
437 |
|
|
if ( i > numinp-1 ){ |
438 |
|
|
usage(); |
439 |
|
|
throw -3; |
440 |
|
|
}; |
441 |
|
|
}; |
442 |
|
|
}; |
443 |
|
|
}; |
444 |
|
|
// |
445 |
mocchiut |
1.8 |
if ( !found && i > 0 ){ |
446 |
|
|
usage(); |
447 |
|
|
printf(" Unknown input number %i, that is \"%s\" \n",i,inps[i]); |
448 |
|
|
throw -22; |
449 |
|
|
}; |
450 |
|
|
// |
451 |
mocchiut |
1.1 |
i++; |
452 |
|
|
}; |
453 |
|
|
// |
454 |
|
|
} else { |
455 |
|
|
// |
456 |
|
|
// no input parameters exit with error, we need at least the run id. |
457 |
|
|
// |
458 |
|
|
throw -1; |
459 |
|
|
}; |
460 |
|
|
// |
461 |
|
|
// If not in verbose mode redirect to /dev/null the stdout and stderr |
462 |
|
|
// |
463 |
|
|
if ( !beverbose ){ |
464 |
|
|
nul = open("/dev/null", O_CREAT | O_RDWR,S_IREAD | S_IWRITE); |
465 |
|
|
dup2(nul,1); |
466 |
|
|
dup2(nul,2); |
467 |
|
|
}; |
468 |
|
|
// |
469 |
|
|
// Check that an input run number has been given |
470 |
|
|
// |
471 |
|
|
if ( !givenid ) throw -1; |
472 |
|
|
// |
473 |
|
|
char *version = DarthVaderInfo(false); |
474 |
|
|
// |
475 |
|
|
// Start: |
476 |
|
|
// |
477 |
|
|
printf("\n Welcome to the PAMELA LEVEL2 flight software, version %s \n\n",version); |
478 |
|
|
// |
479 |
|
|
// Connect to the DB |
480 |
|
|
// |
481 |
|
|
if ( debug ) printf("\nConnecting to database... \n"); |
482 |
|
|
// |
483 |
|
|
dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
484 |
|
|
if( !dbc ) throw -2; |
485 |
|
|
// |
486 |
|
|
bool connect = dbc->IsConnected(); |
487 |
|
|
// |
488 |
|
|
if( !connect ) throw -2; |
489 |
|
|
// |
490 |
|
|
if ( debug ) printf("...connected! \n\n"); |
491 |
|
|
// |
492 |
|
|
// Create LEVEL2 filename and open it in update mode |
493 |
|
|
// |
494 |
|
|
if ( filename.IsNull() ){ |
495 |
|
|
stringstream strun; |
496 |
|
|
strun.str(""); |
497 |
|
|
strun << run; |
498 |
mocchiut |
1.3 |
filename += outDir; |
499 |
|
|
filename += "/"; |
500 |
mocchiut |
1.1 |
filename += strun.str(); |
501 |
|
|
filename += ".Level2.root"; |
502 |
|
|
}; |
503 |
mocchiut |
1.3 |
// filename = outDir + "/" + filename; |
504 |
mocchiut |
1.1 |
processFile = new TFile(filename.Data(),"UPDATE"); |
505 |
|
|
if ( !processFile->IsOpen() ) throw -15; |
506 |
|
|
// |
507 |
|
|
// Run the core program, put any output error in the "error" variable |
508 |
|
|
// |
509 |
|
|
if ( RUN ) { |
510 |
|
|
printf(" Calling RunInfo... "); |
511 |
|
|
RUNSGN = RunInfoCore(run,processFile,dbc,runargc,runargv); |
512 |
|
|
printf("done\n"); |
513 |
|
|
}; |
514 |
mocchiut |
1.4 |
// |
515 |
|
|
// From the Run Infos extract acq_var_info to determine if detectors are in the acquisition or not |
516 |
|
|
// |
517 |
|
|
printf(" Checking if requested detectors are in the acquisition\n"); |
518 |
|
|
ItoRunInfo *runinfo = new ItoRunInfo(processFile); |
519 |
|
|
runinfo->Read(run); |
520 |
|
|
printf(" => ACQ_VAR_INFO = %i \n",runinfo->ACQ_VAR_INFO); |
521 |
|
|
if ( TRK && !(runinfo->ACQ_VAR_INFO & (1 << 4)) ) throw -16; |
522 |
|
|
if ( TOF && !(runinfo->ACQ_VAR_INFO & (1 << 0)) ) throw -17; |
523 |
|
|
if ( CAL && !(runinfo->ACQ_VAR_INFO & (1 << 3)) ) throw -18; |
524 |
|
|
if ( AC && !(runinfo->ACQ_VAR_INFO & (1 << 1)) && !(runinfo->ACQ_VAR_INFO & (1 << 2)) ) throw -19; |
525 |
|
|
if ( S4 && !(runinfo->ACQ_VAR_INFO & (1 << 5)) ) throw -20; |
526 |
|
|
if ( ND && !(runinfo->ACQ_VAR_INFO & (1 << 9)) ) throw -21; |
527 |
|
|
printf(" OK! start processing detector's data. \n"); |
528 |
|
|
// |
529 |
mocchiut |
1.1 |
if ( TRK ) { |
530 |
|
|
printf(" Calling TrackerLevel2... "); |
531 |
|
|
TRKSGN = TrkCore(run,processFile,dbc,trkargc,trkargv); |
532 |
mocchiut |
1.11 |
gSystem->Unlink("TrackerFolder"); //patch |
533 |
mocchiut |
1.1 |
printf("done\n"); |
534 |
|
|
}; |
535 |
|
|
if ( TOF ) { |
536 |
|
|
printf(" Calling ToFLevel2... "); |
537 |
|
|
TOFSGN = ToFCore(run,processFile,dbc,tofargc,tofargv); |
538 |
|
|
printf("done\n"); |
539 |
|
|
}; |
540 |
|
|
if ( CAL ) { |
541 |
|
|
printf(" Calling CalorimeterLevel2... "); |
542 |
|
|
CALSGN = CaloCore(run,processFile,dbc,calargc,calargv); |
543 |
|
|
printf("done\n"); |
544 |
|
|
}; |
545 |
|
|
if ( TRG ) { |
546 |
|
|
printf(" Calling TriggerLevel2... "); |
547 |
|
|
TRGSGN = TrigCore(run,processFile,dbc,trgargc,trgargv); |
548 |
|
|
printf("done\n"); |
549 |
|
|
}; |
550 |
|
|
if ( AC ) { |
551 |
|
|
printf(" Calling AnticounterLevel2... "); |
552 |
|
|
ACSGN = AcCore(run,processFile,dbc,acargc,acargv); |
553 |
|
|
printf("done\n"); |
554 |
|
|
}; |
555 |
|
|
if ( S4 ) { |
556 |
|
|
printf(" Calling S4Level2 ... "); |
557 |
|
|
S4SGN = S4Core(run,processFile,dbc,s4argc,s4argv); |
558 |
|
|
printf("done\n"); |
559 |
|
|
}; |
560 |
|
|
if ( ND ) { |
561 |
|
|
printf(" Calling NDLevel2... "); |
562 |
|
|
NDSGN = NDCore(run,processFile,dbc,ndargc,ndargv); |
563 |
|
|
printf("done\n"); |
564 |
|
|
}; |
565 |
|
|
if ( ORB ) { |
566 |
|
|
printf(" Calling OrbitalInfo... "); |
567 |
|
|
ORBSGN = OrbitalInfoCore(run,processFile,dbc,orbargc,orbargv); |
568 |
|
|
printf("done\n"); |
569 |
|
|
}; |
570 |
|
|
// |
571 |
|
|
} catch(Int_t signal) { |
572 |
|
|
error = signal; |
573 |
|
|
switch(signal){ |
574 |
|
|
case 51: message += " GLTABLES - TO_TIME < time when querying tables"; break; |
575 |
|
|
case -1: message += " Missing/wrong run ID input parameter"; break; |
576 |
|
|
case -2: message += " DB connection failure"; break; |
577 |
|
|
case -3: message += " Error in input parameters (check format)"; break; |
578 |
|
|
case -4: message += " Request reprocessing of all runs (idRun = 0) but processFile is missing"; break; |
579 |
|
|
case -6: message += " No LEVEL0 file "; break; |
580 |
|
|
case -7: message += " No Physics tree in LEVEL0 file"; break; |
581 |
|
|
case -8: message += " No Header branch in LEVEL0 Physics tree"; break; |
582 |
|
|
case -9: message += " No Registry branch in LEVEL0 Physics tree"; break; |
583 |
|
|
case -11: message += " LEVEL0 Physics tree is empty"; break; |
584 |
mocchiut |
1.9 |
case -12: message += " Too few entries in the tree"; break; |
585 |
mocchiut |
1.1 |
case -13: message += " Cannot create processFolder directory"; break; |
586 |
|
|
case -14: message += " Error querying the DB"; break; |
587 |
|
|
case -15: message += " Cannot open file for writing"; break; |
588 |
mocchiut |
1.4 |
case -16: message += " No tracker in the acquisition (use -TRK to process anyway)"; break; |
589 |
|
|
case -17: message += " No ToF in the acquisition (use -TOF to process anyway)"; break; |
590 |
|
|
case -18: message += " No calorimeter in the acquisition (use -CAL to process anyway)"; break; |
591 |
|
|
case -19: message += " No anticounters in the acquisition (use -AC to process anyway)"; break; |
592 |
|
|
case -20: message += " No S4 in the acquisition (use -S4 to process anyway)"; break; |
593 |
|
|
case -21: message += " No neutron detector in the acquisition (use -ND to process anyway)"; break; |
594 |
mocchiut |
1.8 |
case -22: message += " Unknown input or wrong syntax in input paramters!"; break; |
595 |
mocchiut |
1.1 |
// |
596 |
|
|
case -50: message += " GLTABLES - No entries matching GL_RUN query"; break; |
597 |
|
|
case -51: message += " GLTABLES - No entries matching GL_ROOT query"; break; |
598 |
|
|
case -52: message += " GLTABLES - No entries matching GL_PARAM query"; break; |
599 |
|
|
case -53: message += " GLTABLES - No entries matching GL_TRK_CALIB query"; break; |
600 |
|
|
case -54: message += " GLTABLES - No entries matching GL_CALO_CALIB query"; break; |
601 |
|
|
case -55: message += " GLTABLES - No entries matching GL_CALO_CALIB query"; break; |
602 |
|
|
// |
603 |
|
|
case -100: message += " CALORIMETERLEVEL2 - No Level2 input file"; break; |
604 |
|
|
case -101: message += " CALORIMETERLEVEL2 - Cannot open Level2 file"; break; |
605 |
|
|
case -102: message += " CALORIMETERLEVEL2 - No Tracker TTree in Level2 file"; break; |
606 |
|
|
case -103: message += " CALORIMETERLEVEL2 - No Calorimeter TBranch in Level0 file"; break; |
607 |
|
|
case -104: message += " CALORIMETERLEVEL2 - No Trigger TTree in Level0 file"; break; |
608 |
|
|
case -105: message += " CALORIMETERLEVEL2 - No Calorimeter ADC2MIP conversion file"; break; |
609 |
|
|
case -106: message += " CALORIMETERLEVEL2 - No Calorimeter alignement file"; break; |
610 |
|
|
case -107: message += " CALORIMETERLEVEL2 - Cannot find Level0 file needed for the calibration"; break; |
611 |
|
|
case -108: message += " CALORIMETERLEVEL2 - Cannot open Level0 file needed for the calibration"; break; |
612 |
|
|
case -109: message += " CALORIMETERLEVEL2 - No CalibCalPed TTree in Level0 file needed for the calibration"; break; |
613 |
|
|
case -110: message += " CALORIMETERLEVEL2 - No calibrations in Level0 file needed for the calibration"; break; |
614 |
|
|
case -111: message += " CALORIMETERLEVEL2 - Corrupted calibration"; break; |
615 |
|
|
case -112: message += " CALORIMETERLEVEL2 - No physics event related to registry entry in Level0 file"; break; |
616 |
|
|
case -113: message += " CALORIMETERLEVEL2 - No tracker event related to registry entry in Level2 file"; break; |
617 |
|
|
// |
618 |
|
|
case -200: message += " TRACKERLEVEL2 - LEVEL1 framework unknown (HBOOK/ROOT)"; break; |
619 |
|
|
case -201: message += " TRACKERLEVEL2 - LEVEL2 framework unknown (HBOOK/ROOT)"; break; |
620 |
|
|
case -202: message += " TRACKERLEVEL2 - Neither LEVEL1 nor LEVEL2 output requested"; break; |
621 |
|
|
case -203: message += " TRACKERLEVEL2 - No Tracker branch in LEVEL0 Physics tree"; break; |
622 |
|
|
case -204: message += " TRACKERLEVEL2 - No reprocessing implemented for LEVEL1 output"; break; |
623 |
|
|
case -205: message += " TRACKERLEVEL2 - Error accessing RunInfo "; break; |
624 |
|
|
case -210: message += " TRACKERLEVEL2 - Error opening/reading trk mask GL_PARAM parameters "; break; |
625 |
|
|
case -211: message += " TRACKERLEVEL2 - Error opening/reading trk alignment GL_PARAM parameters"; break; |
626 |
|
|
case -212: message += " TRACKERLEVEL2 - Error opening/reading trk mip GL_PARAM parameters"; break; |
627 |
|
|
case -213: message += " TRACKERLEVEL2 - Error opening/reading trk charge GL_PARAM parameters"; break; |
628 |
|
|
case -214: message += " TRACKERLEVEL2 - Error opening/reading trk pfa GL_PARAM parameters"; break; |
629 |
|
|
case -215: message += " TRACKERLEVEL2 - Error opening/reading field GL_PARAM parameters"; break; |
630 |
|
|
case -216: message += " TRACKERLEVEL2 - Error opening/reading default calibration GL_PARAM parameters"; break; |
631 |
|
|
case -298: message += " TRACKERLEVEL2 - Reprocessing not implemented in standalone mode"; break; |
632 |
|
|
case -299: message += " TRACKERLEVEL2 - Not yet implemented"; break; |
633 |
|
|
// |
634 |
|
|
case -300: message += " TOFLEVEL2 - No Trigger branch in Level0 tree"; break; |
635 |
|
|
case -301: message += " TOFLEVEL2 - Cannot open file for writing"; break; |
636 |
|
|
case -302: message += " TOFLEVEL2 - No tracker tree in Level2 file"; break; |
637 |
|
|
case -303: message += " TOFLEVEL2 - No Tof branch in Level0 file"; break; |
638 |
|
|
case -313: message += " TOFLEVEL2 - No more tracker events in Level2 file"; break; |
639 |
|
|
// |
640 |
|
|
case -401: message += " TRIGGERLEVEL2 - Cannot open file for writing"; break; |
641 |
|
|
case -402: message += " TRIGGERLEVEL2 - No Trigger branch in Level0 tree"; break; |
642 |
|
|
// |
643 |
|
|
case -500: message += " S4LEVEL2 - No level2 file"; break; |
644 |
|
|
case -501: message += " S4LEVEL2 - Cannot open file for writing"; break; |
645 |
|
|
case -502: message += " S4LEVEL2 - No result from GL_S4_CALIB"; break; |
646 |
|
|
case -503: message += " S4LEVEL2 - No S4 branch in Level0 tree"; break; |
647 |
|
|
// |
648 |
|
|
case -600: message += " NDLEVEL2 - No level2 file"; break; |
649 |
|
|
case -601: message += " NDLEVEL2 - Cannot open file for writing"; break; |
650 |
|
|
case -603: message += " NDLEVEL2 - No S4Level2 branch in Level0 tree"; break; |
651 |
|
|
// |
652 |
|
|
case -701: message += " NDLEVEL2 - Cannot open file for writing"; break; |
653 |
|
|
case -704: message += " NDLEVEL2 - No Anticounter branch in Level0 tree"; break; |
654 |
|
|
// |
655 |
|
|
case -800: message += " RUNINFO - No such run in the RunInfo list"; break; |
656 |
|
|
case -801: message += " RUNINFO - No RunInfo tree in Level2 file"; break; |
657 |
|
|
case -802: message += " RUNINFO - Cannot open file for writing"; break; |
658 |
|
|
case -803: message += " RUNINFO - Updating but no RunInfo tree in Level2 file"; break; |
659 |
|
|
case -804: message += " RUNINFO - Unknown detector"; break; |
660 |
mocchiut |
1.2 |
case -805: message += " RUNINFO - Reprocessing data but no RunInfo tree in Level2 file"; break; |
661 |
mocchiut |
1.7 |
case -806: message += " RUNINFO - Can not handle more than 500 runs"; break; |
662 |
mocchiut |
1.1 |
// |
663 |
|
|
default: message += "Unidentified error or warning"; break; |
664 |
|
|
}; |
665 |
|
|
printf("\n"); |
666 |
|
|
if ( signal < 0 ) cout << " ERROR ("<< signal << ") "<< message <<endl; |
667 |
|
|
} |
668 |
|
|
// switch(RUNSGN){ |
669 |
|
|
// }; |
670 |
|
|
switch(CALSGN){ |
671 |
|
|
case 100: printf("\n WARNING CALORIMETER - Data with no associated calibration\n"); break; |
672 |
|
|
case 101: printf("\n WARNING CALORIMETER - No tracks or good events in this run\n"); break; |
673 |
|
|
}; |
674 |
|
|
// |
675 |
|
|
// Close the DB connection |
676 |
|
|
// |
677 |
|
|
if ( dbc ){ |
678 |
|
|
if ( debug ) printf("\nClose the connection to the database... \n"); |
679 |
|
|
dbc->Close(); |
680 |
|
|
if ( debug ) printf("...connection terminated!\n\n"); |
681 |
|
|
}; |
682 |
|
|
if ( processFile ){ |
683 |
|
|
processFile->cd(); |
684 |
|
|
processFile->Close(); |
685 |
|
|
}; |
686 |
|
|
// |
687 |
|
|
if ( error != 0 ) printf("\n\n WARNING: exiting with signal %i \n\n",error); |
688 |
|
|
printf("\n"); |
689 |
mocchiut |
1.6 |
printf("Finished, exiting...\n"); |
690 |
|
|
printf("\n"); |
691 |
mocchiut |
1.1 |
// |
692 |
|
|
// Close redirection if the case. |
693 |
|
|
// |
694 |
|
|
if ( !beverbose ) close(nul); |
695 |
|
|
// |
696 |
|
|
// |
697 |
|
|
exit(error); |
698 |
|
|
} |