21 |
printf("\n --version print informations about compilation and exit\n"); |
printf("\n --version print informations about compilation and exit\n"); |
22 |
printf("\n -h | --help print this help and exit \n"); |
printf("\n -h | --help print this help and exit \n"); |
23 |
printf("\n -v | --verbose be verbose [default]\n"); |
printf("\n -v | --verbose be verbose [default]\n"); |
24 |
printf("\n -s | --silent default: print nothing on STDOUT\n"); |
printf("\n -s | --silent print nothing on STDOUT\n"); |
25 |
printf("\n -g | --debug be very verbose [default: no]\n"); |
printf("\n -g | --debug be very verbose [default: no]\n"); |
26 |
printf("\n -boot number CPU boot number [default = taken from VarDump]\n"); |
printf("\n -boot number CPU boot number [default = taken from VarDump]\n"); |
27 |
printf("\n -tsync number timesync (s) [default = taken from data]\n"); |
printf("\n -tsync number timesync (s) [default = taken from data]\n"); |
32 |
printf("\n -host name for the host [default = $PAM_DBHOST or mysql://localhost/pamelaprod]\n"); |
printf("\n -host name for the host [default = $PAM_DBHOST or mysql://localhost/pamelaprod]\n"); |
33 |
printf("\n -user username for the DB [default = $PAM_DBUSER or \"anonymous\"] \n"); |
printf("\n -user username for the DB [default = $PAM_DBUSER or \"anonymous\"] \n"); |
34 |
printf("\n -psw password for the DB [default = $PAM_DBPSW or \"\"]\n"); |
printf("\n -psw password for the DB [default = $PAM_DBPSW or \"\"]\n"); |
35 |
|
printf("\n -tle <file> ascii file containing TLE obtained from celestrak.org or space-track.org [default = no]\n"); |
36 |
printf("\n The order of input files and options does not matter. \n"); |
printf("\n The order of input files and options does not matter. \n"); |
37 |
printf("\nExample: \n"); |
printf("\nExample: \n"); |
38 |
printf("\n YodaProfiler -yodaFile /path/to/raw/files/000_000_00000_cln2.pam -rawFile /path/to/filesfromyoda/000_000_00000_cln2.root -v \n\n"); |
printf("\n YodaProfiler -yodaFile /path/to/raw/files/000_000_00000_cln2.pam -rawFile /path/to/filesfromyoda/000_000_00000_cln2.root -v \n\n"); |
59 |
TString user = "anonymous"; |
TString user = "anonymous"; |
60 |
TString password = ""; |
TString password = ""; |
61 |
// |
// |
62 |
/* const char *pamdbhost=gSystem->Getenv("PAM_DBHOST"); |
TString tlefilename = ""; |
63 |
const char *pamdbuser=gSystem->Getenv("PAM_DBUSER"); |
|
64 |
const char *pamdbpsw=gSystem->Getenv("PAM_DBPSW"); |
const char *pamdbhost = gSystem->Getenv("PAM_DBHOST"); |
65 |
|
const char *pamdbuser = gSystem->Getenv("PAM_DBUSER"); |
66 |
|
const char *pamdbpsw = gSystem->Getenv("PAM_DBPSW"); |
67 |
|
if ( !pamdbhost ) pamdbhost = ""; |
68 |
|
if ( !pamdbuser ) pamdbuser = ""; |
69 |
|
if ( !pamdbpsw ) pamdbpsw = ""; |
70 |
if ( strcmp(pamdbhost,"") ) host = pamdbhost; |
if ( strcmp(pamdbhost,"") ) host = pamdbhost; |
71 |
if ( strcmp(pamdbuser,"") ) user = pamdbuser; |
if ( strcmp(pamdbuser,"") ) user = pamdbuser; |
72 |
if ( strcmp(pamdbpsw,"") ) password = pamdbpsw;*/ |
if ( strcmp(pamdbpsw,"") ) password = pamdbpsw; |
73 |
// |
// |
74 |
// |
// |
75 |
Bool_t beverbose = true; |
Bool_t beverbose = true; |
76 |
Bool_t debug = false; |
Bool_t debug = false; |
77 |
|
// |
78 |
Int_t i = 0; |
Int_t i = 0; |
79 |
// |
// |
80 |
if ( numinp > 1 ){ |
if ( numinp > 1 ){ |
151 |
}; |
}; |
152 |
password = (TString)inps[i+1]; |
password = (TString)inps[i+1]; |
153 |
}; |
}; |
154 |
|
|
155 |
|
if ( !strcmp(inps[i],"-tle") ) { |
156 |
|
if ( numinp-1 < i+1 ){ |
157 |
|
usage(); |
158 |
|
exit(1); |
159 |
|
}; |
160 |
|
tlefilename = (TString)inps[i+1]; |
161 |
|
}; |
162 |
|
|
163 |
// |
// |
164 |
if ( !strcmp(inps[i],"-v") || !strcmp(inps[i],"--verbose") ) beverbose = true; |
if ( !strcmp(inps[i],"-v") || !strcmp(inps[i],"--verbose") ) beverbose = true; |
165 |
// |
// |
192 |
TString message; |
TString message; |
193 |
char *version = YodaProfilerInfo(false); |
char *version = YodaProfilerInfo(false); |
194 |
PamelaDBOperations *pamDB = 0; |
PamelaDBOperations *pamDB = 0; |
195 |
UInt_t sizeofwar = 10; |
UInt_t sizeofwar = 11; |
196 |
UInt_t WAR[10]; |
UInt_t WAR[11]; |
197 |
memset(WAR, 0, 10*sizeof(UInt_t)); |
memset(WAR, 0, 11*sizeof(UInt_t)); |
198 |
// |
// |
199 |
printf("\n Welcome to the PAMELA YodaProfiler, version %s \n\n",version); |
printf("\n Welcome to the PAMELA YodaProfiler, version %s \n\n",version); |
200 |
try{ |
try{ |
203 |
// Create pamDB object and open SQL connection |
// Create pamDB object and open SQL connection |
204 |
//------------------------------------------------------------------------------------------- |
//------------------------------------------------------------------------------------------- |
205 |
if ( beverbose ) printf(" 1 => Initialize and open SQL connection \n"); |
if ( beverbose ) printf(" 1 => Initialize and open SQL connection \n"); |
206 |
pamDB = new PamelaDBOperations(host,user,password,filerawname,filerootname,boot,tsync,obt0,debug,olderthan); |
pamDB = new PamelaDBOperations(host,user,password,filerawname,filerootname,boot,tsync,obt0,debug,tlefilename); |
207 |
pamDB->CheckConnection(); |
pamDB->CheckConnection(); |
208 |
|
//------------------------------------------------------------------------------------------- |
|
// pamDB->SetOlderThan(olderthan);//deve stare qui? |
|
|
//------------------------------------------------------------------------------------------- |
|
209 |
// |
// |
210 |
|
|
211 |
if(pamDB->InsertRaw()){ |
if(pamDB->InsertRaw()){ |
212 |
//------------------------------------------------------------------------------------------- |
//------------------------------------------------------------------------------------------- |
213 |
//Insert a Raw file in GL_RAW |
//Insert a Raw file in GL_RAW |
214 |
//------------------------------------------------------------------------------------------- |
//------------------------------------------------------------------------------------------- |
215 |
if ( beverbose ) printf(" 2 => Insert a RAW file in GL_RAW \n"); |
if ( beverbose ) printf(" 2 => Insert a RAW file in GL_RAW \n"); |
216 |
WAR[0] = pamDB->insertPamelaRawFile(); |
WAR[0] = pamDB->insertPamelaRawFile(); |
217 |
//------------------------------------------------------------------------------------------- |
//------------------------------------------------------------------------------------------- |
218 |
}; |
}; |
219 |
|
|
220 |
if(pamDB->InsertRoot()){ |
if(pamDB->InsertRoot()){ |
221 |
|
|
222 |
if(!pamDB->InsertRaw())printf("=> RAW file not inserted --- the DB might not ( yet ) be filled correctlly \n"); |
if(!pamDB->InsertRaw())printf("=> RAW file not inserted --- the DB might not ( yet ) be filled correctly \n"); |
223 |
//------------------------------------------------------------------------------------------- |
pamDB->CheckFile(); |
224 |
//Update a single GL_RAW record with its BOOT_NUMBER |
//------------------------------------------------------------------------------------------- |
225 |
//------------------------------------------------------------------------------------------- |
//Update a single GL_RAW record with its BOOT_NUMBER |
226 |
if ( beverbose ) printf(" 3 => Update a single GL_RAW record with its BOOT_NUMBER \n"); |
//------------------------------------------------------------------------------------------- |
227 |
WAR[3] = pamDB->assignBOOT_NUMBER(); |
if ( beverbose ) printf(" 3 => Update a single GL_RAW record with its BOOT_NUMBER \n"); |
228 |
// if ( WAR[3] ) pamDB->SetNOBOOT(true); |
WAR[3] = pamDB->assignBOOT_NUMBER(); |
229 |
if ( WAR[3] && WAR[3] != 1 ) throw -9; |
// if ( WAR[3] ) pamDB->SetNOBOOT(true); |
230 |
//------------------------------------------------------------------------------------------- |
if ( WAR[3] && WAR[3] != 1 ) throw -9; |
231 |
// |
//------------------------------------------------------------------------------------------- |
232 |
//------------------------------------------------------------------------------------------- |
// |
233 |
//Insert an entry in GL_TIMESYNC |
//------------------------------------------------------------------------------------------- |
234 |
//------------------------------------------------------------------------------------------- |
//Insert an entry in GL_TIMESYNC |
235 |
if ( beverbose ) printf(" 4 => Insert an entry in GL_TIMESYNC \n"); |
//------------------------------------------------------------------------------------------- |
236 |
WAR[1] = pamDB->insertPamelaGL_TIMESYNC(); |
if ( beverbose ) printf(" 4 => Insert an entry in GL_TIMESYNC \n"); |
237 |
//------------------------------------------------------------------------------------------- |
WAR[1] = pamDB->insertPamelaGL_TIMESYNC(); |
238 |
// |
//------------------------------------------------------------------------------------------- |
239 |
//------------------------------------------------------------------------------------------- |
// |
240 |
//Insert unpack ROOT file in GL_ROOT |
//------------------------------------------------------------------------------------------- |
241 |
//------------------------------------------------------------------------------------------- |
//Insert unpack ROOT file in GL_ROOT |
242 |
if ( beverbose ) printf(" 5 => Insert unpack ROOT file in GL_ROOT \n"); |
//------------------------------------------------------------------------------------------- |
243 |
WAR[2] = pamDB->insertPamelaRootFile(); |
if ( beverbose ) printf(" 5 => Insert unpack ROOT file in GL_ROOT \n"); |
244 |
//------------------------------------------------------------------------------------------- |
WAR[2] = pamDB->insertPamelaRootFile(); |
245 |
// |
//------------------------------------------------------------------------------------------- |
246 |
//------------------------------------------------------------------------------------------- |
// |
247 |
//Insert in GL_RUN runs information records relative to a single unpack |
//------------------------------------------------------------------------------------------- |
248 |
//------------------------------------------------------------------------------------------- |
//Insert in GL_RUN runs information records relative to a single unpack |
249 |
if ( beverbose ) printf(" 6 => Scan physics and store runs in the GL_RUN table\n"); |
//------------------------------------------------------------------------------------------- |
250 |
WAR[4] = pamDB->insertPamelaRUN(); |
if ( beverbose ) printf(" 6 => Scan physics and store runs in the GL_RUN table\n"); |
251 |
//------------------------------------------------------------------------------------------- |
WAR[4] = pamDB->insertPamelaRUN(); |
252 |
|
//------------------------------------------------------------------------------------------- |
253 |
|
|
254 |
//------------------------------------------------------------------------------------------- |
//------------------------------------------------------------------------------------------- |
255 |
//Insert in GL_CALO_CALIB calibration information records relative to a single unpack |
//Insert in GL_CALO_CALIB calibration information records relative to a single unpack |
256 |
//------------------------------------------------------------------------------------------- |
//------------------------------------------------------------------------------------------- |
257 |
if ( beverbose ) printf(" 7 => Insert calorimeter calibrations in the GL_CALO_CALIB table\n"); |
if ( beverbose ) printf(" 7 => Insert calorimeter calibrations in the GL_CALO_CALIB table\n"); |
258 |
WAR[5] = pamDB->insertCALO_CALIB(); |
WAR[5] = pamDB->insertCALO_CALIB(); |
259 |
//------------------------------------------------------------------------------------------- |
//------------------------------------------------------------------------------------------- |
260 |
|
|
261 |
//------------------------------------------------------------------------------------------- |
//------------------------------------------------------------------------------------------- |
262 |
//Insert in GL_TRK_CALIB calibration information records relative to a single unpack |
//Insert in GL_TRK_CALIB calibration information records relative to a single unpack |
263 |
//------------------------------------------------------------------------------------------- |
//------------------------------------------------------------------------------------------- |
264 |
if ( beverbose ) printf(" 8 => Insert tracker calibrations in the GL_TRK_CALIB table\n"); |
if ( beverbose ) printf(" 8 => Insert tracker calibrations in the GL_TRK_CALIB table\n"); |
265 |
WAR[6] = pamDB->insertTRK_CALIB(); |
WAR[6] = pamDB->insertTRK_CALIB(); |
266 |
//------------------------------------------------------------------------------------------- |
//------------------------------------------------------------------------------------------- |
267 |
|
|
268 |
//------------------------------------------------------------------------------------------- |
//------------------------------------------------------------------------------------------- |
269 |
//Insert in GL_S4_CALIB calibration information records relative to a single unpack |
//Insert in GL_S4_CALIB calibration information records relative to a single unpack |
270 |
//------------------------------------------------------------------------------------------- |
//------------------------------------------------------------------------------------------- |
271 |
if ( beverbose ) printf(" 9 => Insert S4 calibrations in the GL_S4_CALIB table\n"); |
if ( beverbose ) printf(" 9 => Insert S4 calibrations in the GL_S4_CALIB table\n"); |
272 |
WAR[7] = pamDB->insertS4_CALIB(); |
WAR[7] = pamDB->insertS4_CALIB(); |
273 |
//------------------------------------------------------------------------------------------- |
//------------------------------------------------------------------------------------------- |
274 |
}; |
}; |
275 |
|
// |
276 |
if(pamDB->Validate()){ |
pamDB->CheckValidate(olderthan); |
277 |
|
// |
278 |
//------------------------------------------------------------------------------------------- |
if(pamDB->Validate()){ |
279 |
//Clean the GL_RUN_FRAGMENTS |
//------------------------------------------------------------------------------------------- |
280 |
//------------------------------------------------------------------------------------------- |
//Clean the GL_RUN_FRAGMENTS |
281 |
if ( beverbose ) printf(" 10 => Clean the GL_RUN_FRAGMENTS table (before %s) \n",pamDB->GetCleanTime() ); |
//------------------------------------------------------------------------------------------- |
282 |
WAR[8] = pamDB->CleanGL_RUN_FRAGMENTS(); |
if ( beverbose ) printf(" 10 => Clean the GL_RUN_FRAGMENTS table (earlier than %s) \n",pamDB->GetCleanTime() ); |
283 |
//------------------------------------------------------------------------------------------- |
WAR[8] = pamDB->CleanGL_RUN_FRAGMENTS(); |
284 |
|
//------------------------------------------------------------------------------------------- |
285 |
|
|
286 |
//------------------------------------------------------------------------------------------- |
//------------------------------------------------------------------------------------------- |
287 |
//Validate runs |
//Validate runs |
288 |
//------------------------------------------------------------------------------------------- |
//------------------------------------------------------------------------------------------- |
289 |
if ( beverbose ) printf(" 11 => Validate runs (before %s)\n",pamDB->GetCleanTime()); |
if ( beverbose ) printf(" 11 => Validate runs (earlier than %s)\n",pamDB->GetCleanTime()); |
290 |
WAR[9] = pamDB->ValidateRuns(); |
WAR[9] = pamDB->ValidateRuns(); |
291 |
//------------------------------------------------------------------------------------------- |
//------------------------------------------------------------------------------------------- |
292 |
}; |
}; |
293 |
|
|
294 |
|
if(! tlefilename.IsNull() ) { |
295 |
|
//---------------------------------------------- |
296 |
|
//Populate GL_TLE table using the file provided |
297 |
|
//---------------------------------------------- |
298 |
|
if ( beverbose ) printf(" 12 => Insert TLE elements in the GL_TLE table from file %s \n",tlefilename.Data()); |
299 |
|
WAR[10] = pamDB->populateTLE(); |
300 |
|
} |
301 |
|
|
302 |
} catch (Int_t exc) { |
} catch (Int_t exc) { |
303 |
signal = exc; |
signal = exc; |
308 |
case -4: message += " Error querying DB"; break; |
case -4: message += " Error querying DB"; break; |
309 |
case -5: message += " Inconsistent OBT/pkt_num"; break; |
case -5: message += " Inconsistent OBT/pkt_num"; break; |
310 |
case -6: message += " The file is not in the database"; break; |
case -6: message += " The file is not in the database"; break; |
311 |
|
case -7: message += " Cannot open TLE file"; break; |
312 |
case -8: message += " Event file is empty"; break; |
case -8: message += " Event file is empty"; break; |
313 |
case -9: message += " No VarDump no BOOT number, use the -boot option to override"; break; |
case -9: message += " No VarDump no BOOT number, use the -boot option to override"; break; |
314 |
case -10: message += " No results from DB"; break; |
case -10: message += " No results from DB"; break; |
328 |
case -24: message += " No CalibS4 tree in Level0 file"; break; |
case -24: message += " No CalibS4 tree in Level0 file"; break; |
329 |
case -25: message += " Cannot find the run just inserted"; break; |
case -25: message += " Cannot find the run just inserted"; break; |
330 |
case -26: message += " Raw file not found looking for VarDump"; break; |
case -26: message += " Raw file not found looking for VarDump"; break; |
331 |
|
case -27: message += " Cannot determine downlink orbit, wrong filename format?"; break; |
332 |
|
case -28: message += " Cannot assign a RUN ID unique number!"; break; |
333 |
default: message += " Unidentified error"; break; |
default: message += " Unidentified error"; break; |
334 |
}; |
}; |
335 |
printf("\n"); |
printf("\n"); |
446 |
}; |
}; |
447 |
}; |
}; |
448 |
}; |
}; |
449 |
|
// |
450 |
|
if ( j == 10 ){ // populateTLE |
451 |
|
for (UInt_t bit=0; bit<32; bit++){ |
452 |
|
if ( WAR[j] & (1 << bit) ){ |
453 |
|
if ( bit == 0 ) message += "=> TLE insertion failed\n"; |
454 |
|
if ( bit == 1 ) message += "=> No new TLE available\n"; |
455 |
|
else message += "=> Unidentified populateTle warning\n"; |
456 |
|
}; |
457 |
|
}; |
458 |
|
}; |
459 |
}; |
}; |
460 |
}; |
}; |
461 |
// |
// |
469 |
//--------------------------------------------------------------------------------------- |
//--------------------------------------------------------------------------------------- |
470 |
// Close and exit |
// Close and exit |
471 |
//--------------------------------------------------------------------------------------- |
//--------------------------------------------------------------------------------------- |
472 |
if ( beverbose ) printf(" 12 => Free objects and close SQL connection \n"); |
if ( beverbose ) printf(" 13 => Free objects and close SQL connection \n"); |
473 |
pamDB->Close(); |
pamDB->Close(); |
474 |
// |
// |
475 |
printf("\n"); |
printf("\n"); |