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