| 223 |
ULong64_t upperobt2 = 0; |
ULong64_t upperobt2 = 0; |
| 224 |
UInt_t zomp = 0; |
UInt_t zomp = 0; |
| 225 |
UInt_t jump = 50000; // was 5000 |
UInt_t jump = 50000; // was 5000 |
| 226 |
|
EventCounter *code=0; |
| 227 |
|
// |
| 228 |
|
// pcksList packetsNames; |
| 229 |
|
// pcksList::iterator Iter; |
| 230 |
|
// getPacketsNames(packetsNames); |
| 231 |
// |
// |
| 232 |
pktfirst = 0; |
pktfirst = 0; |
| 233 |
obtfirst = 0; |
obtfirst = 0; |
| 245 |
pktfirst = ph->GetCounter(); |
pktfirst = ph->GetCounter(); |
| 246 |
obtfirst = ph->GetOrbitalTime(); |
obtfirst = ph->GetOrbitalTime(); |
| 247 |
// |
// |
| 248 |
|
// code = eh->GetCounter(); |
| 249 |
|
// UInt_t en = 0; |
| 250 |
|
// for(Iter = packetsNames.begin(); Iter != packetsNames.end(); Iter++){ |
| 251 |
|
// en = code->Get(GetPacketType(*Iter)); |
| 252 |
|
// if ( en ) printf(" Packet type is %s, entries: %i \n",*Iter,en); |
| 253 |
|
//}; |
| 254 |
|
// |
| 255 |
T->GetEntry(nevent-1); |
T->GetEntry(nevent-1); |
| 256 |
ph = eh->GetPscuHeader(); |
ph = eh->GetPscuHeader(); |
| 257 |
pktlast = ph->GetCounter(); |
pktlast = ph->GetCounter(); |
| 320 |
// check if last runtrailer is within limits, if not extend limits (one should check for all packets but we need only runtrailer) |
// check if last runtrailer is within limits, if not extend limits (one should check for all packets but we need only runtrailer) |
| 321 |
// |
// |
| 322 |
PacketType *pctp=0; |
PacketType *pctp=0; |
|
EventCounter *code=0; |
|
| 323 |
T->GetEntry(upperentry); |
T->GetEntry(upperentry); |
| 324 |
code = eh->GetCounter(); |
code = eh->GetCounter(); |
| 325 |
Int_t lasttrail = code->Get(pctp->RunTrailer); |
Int_t lasttrail = code->Get(pctp->RunTrailer); |
| 337 |
// |
// |
| 338 |
rhev = rh->GetEntries(); |
rhev = rh->GetEntries(); |
| 339 |
rtev = rt->GetEntries(); |
rtev = rt->GetEntries(); |
| 340 |
|
UInt_t sobtt = 0; |
| 341 |
|
UInt_t sobth = 0; |
| 342 |
|
UInt_t spktt = 0; |
| 343 |
|
UInt_t spkth = 0; |
| 344 |
UInt_t pktt = 0; |
UInt_t pktt = 0; |
| 345 |
ULong64_t obtt = 0; |
ULong64_t obtt = 0; |
| 346 |
UInt_t pkth = 0; |
UInt_t pkth = 0; |
| 353 |
obtt = OBT(pht->GetOrbitalTime()); |
obtt = OBT(pht->GetOrbitalTime()); |
| 354 |
}; |
}; |
| 355 |
// |
// |
|
if ( IsDebug() ) printf(" rtev beforev %i pt %i upperp %i ot %llu uppero %llu \n",rtev,pktt,upperpkt,obtt,upperobt); |
|
|
if ( pktt > upperpkt && obtt > upperobt ){ |
|
|
if ( IsDebug() ) printf(" Upper limits extended to include last trailer: pt %i upperp %i ot %llu uppero %llu \n",pktt,upperpkt,obtt,upperobt); |
|
|
upperpkt = pktt; |
|
|
upperobt = obtt; |
|
|
rtev = lasttrail+1; |
|
|
} else { |
|
|
rtev = lasttrail; |
|
|
}; |
|
|
if ( IsDebug() ) printf(" rtev after %i pt %i upperp %i ot %llu uppero %llu \n",rtev,pktt,upperpkt,obtt,upperobt); |
|
|
// |
|
| 356 |
if ( lasthead < rhev ){ |
if ( lasthead < rhev ){ |
| 357 |
rh->GetEntry(lasthead); |
rh->GetEntry(lasthead); |
| 358 |
phh = ehh->GetPscuHeader(); |
phh = ehh->GetPscuHeader(); |
| 371 |
}; |
}; |
| 372 |
if ( IsDebug() ) printf(" rhev after %i ph %i upperp %i oh %llu uppero %llu \n",rhev,pkth,upperpkt,obth,upperobt); |
if ( IsDebug() ) printf(" rhev after %i ph %i upperp %i oh %llu uppero %llu \n",rhev,pkth,upperpkt,obth,upperobt); |
| 373 |
// |
// |
| 374 |
|
if ( IsDebug() ) printf(" rtev beforev %i pt %i upperp %i ot %llu uppero %llu \n",rtev,pktt,upperpkt,obtt,upperobt); |
| 375 |
|
if ( pktt > upperpkt && obtt > upperobt ){ |
| 376 |
|
if ( IsDebug() ) printf(" Upper limits extended to include last trailer: pt %i upperp %i ot %llu uppero %llu \n",pktt,upperpkt,obtt,upperobt); |
| 377 |
|
upperpkt = pktt; |
| 378 |
|
upperobt = obtt; |
| 379 |
|
rtev = lasttrail+1; |
| 380 |
|
} else { |
| 381 |
|
rtev = lasttrail; |
| 382 |
|
}; |
| 383 |
|
if ( IsDebug() ) printf(" rtev after %i pt %i upperp %i ot %llu uppero %llu \n",rtev,pktt,upperpkt,obtt,upperobt); |
| 384 |
|
// goto kikko; |
| 385 |
|
// |
| 386 |
|
// |
| 387 |
|
// Check if runtrailer/runheader are within lower limits |
| 388 |
|
// |
| 389 |
|
// |
| 390 |
|
pkth = 0; |
| 391 |
|
obth = 0; |
| 392 |
|
spkth = 0; |
| 393 |
|
sobth = 0; |
| 394 |
|
for (Int_t k=0; k<rhev; k++){ |
| 395 |
|
if ( k > 0 ){ |
| 396 |
|
spkth = pkth; |
| 397 |
|
sobth = obth; |
| 398 |
|
}; |
| 399 |
|
rh->GetEntry(k); |
| 400 |
|
phh = ehh->GetPscuHeader(); |
| 401 |
|
pkth = PKT(phh->GetCounter()); |
| 402 |
|
obth = OBT(phh->GetOrbitalTime()); |
| 403 |
|
// |
| 404 |
|
if ( pkth < spkth && obth < sobth ){ |
| 405 |
|
if ( IsDebug() ) printf(" rhev before %i ph %i upperp %i oh %llu uppero %llu \n",rhev,pkth,upperpkt,obth,upperobt); |
| 406 |
|
if ( IsDebug() ) printf(" RH PROBLEMS determining the event repetition at the end of the file lasthead %i \n",rhev); |
| 407 |
|
// |
| 408 |
|
rhev--; |
| 409 |
|
rh->GetEntry(rhev); |
| 410 |
|
pkth = spkth; |
| 411 |
|
obth = sobth; |
| 412 |
|
if ( IsDebug() ) printf(" lasthead %i pt %i p1 %i ot %u o1 %u \n",rhev,pkth,spkth,obth,sobth); |
| 413 |
|
// |
| 414 |
|
UInt_t evbefh = 0; |
| 415 |
|
code = ehh->GetCounter(); |
| 416 |
|
evbefh = code->Get(pctp->Physics); |
| 417 |
|
if ( evbefh >= 0 ){ |
| 418 |
|
T->GetEntry(evbefh); |
| 419 |
|
ph = eh->GetPscuHeader(); |
| 420 |
|
t_pktlast = PKT(ph->GetCounter()); |
| 421 |
|
t_obtlast = OBT(ph->GetOrbitalTime()); |
| 422 |
|
if ( t_pktlast < spkth && t_obtlast < sobth ){ // jump |
| 423 |
|
upperpkt = pkth; |
| 424 |
|
upperobt = obth; |
| 425 |
|
upperentry = evbefh-1; |
| 426 |
|
} else { |
| 427 |
|
while ( t_pktlast > spkth && t_obtlast > sobth && evbefh < nevent ){ |
| 428 |
|
evbefh++; |
| 429 |
|
T->GetEntry(evbefh); |
| 430 |
|
ph = eh->GetPscuHeader(); |
| 431 |
|
t_pktlast = PKT(ph->GetCounter()); |
| 432 |
|
t_obtlast = OBT(ph->GetOrbitalTime()); |
| 433 |
|
}; |
| 434 |
|
T->GetEntry(evbefh-1); |
| 435 |
|
ph = eh->GetPscuHeader(); |
| 436 |
|
upperpkt = PKT(ph->GetCounter()); |
| 437 |
|
upperobt = OBT(ph->GetOrbitalTime()); |
| 438 |
|
upperentry = evbefh-1; |
| 439 |
|
}; |
| 440 |
|
}; |
| 441 |
|
if ( IsDebug() ) printf(" rhev after %i ph %i upperp %i oh %llu uppero %llu \n",rhev,pkth,upperpkt,obth,upperobt); |
| 442 |
|
}; |
| 443 |
|
}; |
| 444 |
|
// |
| 445 |
|
// |
| 446 |
|
// |
| 447 |
|
pktt = 0; |
| 448 |
|
obtt = 0; |
| 449 |
|
spktt = 0; |
| 450 |
|
sobtt = 0; |
| 451 |
|
for (Int_t k=0; k<rtev; k++){ |
| 452 |
|
if ( k > 0 ){ |
| 453 |
|
spktt = pktt; |
| 454 |
|
sobtt = obtt; |
| 455 |
|
}; |
| 456 |
|
rt->GetEntry(k); |
| 457 |
|
pht = eht->GetPscuHeader(); |
| 458 |
|
pktt = PKT(pht->GetCounter()); |
| 459 |
|
obtt = OBT(pht->GetOrbitalTime()); |
| 460 |
|
// |
| 461 |
|
if ( pktt < spktt && obtt < sobtt ){ |
| 462 |
|
if ( IsDebug() ) printf(" rtev beforev %i pt %i upperp %i ot %llu uppero %llu \n",rtev,pktt,upperpkt,obtt,upperobt); |
| 463 |
|
if ( IsDebug() ) printf(" RT PROBLEMS determining the event repetition at the end of the file lasttrail %i \n",rtev); |
| 464 |
|
// |
| 465 |
|
rtev--; |
| 466 |
|
rt->GetEntry(rtev); |
| 467 |
|
pktt = spktt; |
| 468 |
|
obtt = sobtt; |
| 469 |
|
if ( IsDebug() ) printf(" lasttrail %i pt %i upperp %i ot %llu uppero %llu \n",rtev,pktt,upperpkt,obtt,upperobt); |
| 470 |
|
// |
| 471 |
|
UInt_t evbeft = 0; |
| 472 |
|
code = eht->GetCounter(); |
| 473 |
|
evbeft = code->Get(pctp->Physics); |
| 474 |
|
if ( evbeft >= 0 ){ |
| 475 |
|
T->GetEntry(evbeft); |
| 476 |
|
ph = eh->GetPscuHeader(); |
| 477 |
|
t_pktlast = PKT(ph->GetCounter()); |
| 478 |
|
t_obtlast = OBT(ph->GetOrbitalTime()); |
| 479 |
|
if ( t_pktlast < spktt && t_obtlast < sobtt ){ // jump |
| 480 |
|
upperpkt = pktt; |
| 481 |
|
upperobt = obtt; |
| 482 |
|
upperentry = evbeft-1; |
| 483 |
|
} else { |
| 484 |
|
while ( t_pktlast > spktt && t_obtlast > sobtt && evbeft < nevent ){ |
| 485 |
|
evbeft++; |
| 486 |
|
T->GetEntry(evbeft); |
| 487 |
|
ph = eh->GetPscuHeader(); |
| 488 |
|
t_pktlast = PKT(ph->GetCounter()); |
| 489 |
|
t_obtlast = OBT(ph->GetOrbitalTime()); |
| 490 |
|
}; |
| 491 |
|
T->GetEntry(evbeft-1); |
| 492 |
|
ph = eh->GetPscuHeader(); |
| 493 |
|
upperpkt = PKT(ph->GetCounter()); |
| 494 |
|
upperobt = OBT(ph->GetOrbitalTime()); |
| 495 |
|
upperentry = evbeft-1; |
| 496 |
|
}; |
| 497 |
|
}; |
| 498 |
|
if ( IsDebug() ) printf(" rtev after %i pt %i upperp %i ot %llu uppero %llu \n",rtev,pktt,upperpkt,obtt,upperobt); |
| 499 |
|
break; |
| 500 |
|
// |
| 501 |
|
}; |
| 502 |
|
// |
| 503 |
|
}; |
| 504 |
|
// |
| 505 |
|
// kikko: |
| 506 |
|
// |
| 507 |
if ( IsDebug() ) printf(" Upper limits are: OBT %llu pkt_num %i upper entry %i \n",upperobt,upperpkt,upperentry); |
if ( IsDebug() ) printf(" Upper limits are: OBT %llu pkt_num %i upper entry %i \n",upperobt,upperpkt,upperentry); |
| 508 |
// |
// |
| 509 |
return(0); |
return(0); |
| 3245 |
Int_t PamelaDBOperations::ValidateRuns(){ |
Int_t PamelaDBOperations::ValidateRuns(){ |
| 3246 |
// |
// |
| 3247 |
TSQLResult *result = 0; |
TSQLResult *result = 0; |
| 3248 |
// TSQLRow *row = 0; |
TSQLRow *row = 0; |
| 3249 |
// |
// |
| 3250 |
UInt_t timelim = 0; |
UInt_t timelim = 0; |
| 3251 |
TDatime *time = new TDatime(); |
TDatime *time = new TDatime(); |
| 3265 |
time->Set(); |
time->Set(); |
| 3266 |
timelim = (UInt_t)time->Convert() - olderthan; |
timelim = (UInt_t)time->Convert() - olderthan; |
| 3267 |
time->Set(timelim,false); |
time->Set(timelim,false); |
| 3268 |
// |
|
| 3269 |
// First of all validate runs with default calibration: |
printf("Validate runs older than %s \n",time->AsSQLString()); |
| 3270 |
// |
|
| 3271 |
oss.str(""); |
// ======================================================= |
| 3272 |
oss << " UPDATE GL_RUN SET VALIDATION=1 WHERE" |
// validate runs by checking missing calibrations |
| 3273 |
<< " VALIDATION = 0 AND TRK_CALIB_USED=104 AND " |
// ======================================================= |
| 3274 |
<< " INSERT_TIME <= '" << time->AsSQLString() << "';"; |
UInt_t t_stop = 0; |
| 3275 |
// |
UInt_t t_start = 0; |
| 3276 |
if ( IsDebug() ) printf(" Validate runs with trk default calibration inserted before %s : query is \n %s \n",time->AsSQLString(),oss.str().c_str()); |
// -------------------------------------------------------------- |
| 3277 |
|
// 1) get the OBT of the last run inserted after clean-time limit |
| 3278 |
|
// -------------------------------------------------------------- |
| 3279 |
|
oss.str(""); |
| 3280 |
|
oss << " SELECT * FROM GL_RUN WHERE INSERT_TIME <= '" << time->AsSQLString() |
| 3281 |
|
<< "' ORDER BY INSERT_TIME DESC LIMIT 1;"; |
| 3282 |
|
printf(" Get start validation-time: query is \n %s \n",oss.str().c_str()); |
| 3283 |
|
result = conn->Query(oss.str().c_str()); |
| 3284 |
|
if ( !result ) throw -4; |
| 3285 |
|
if ( !result->GetRowCount() ) { |
| 3286 |
|
printf(" No runs to validate \n"); |
| 3287 |
|
return(1); |
| 3288 |
|
}else{ |
| 3289 |
|
row = result->Next(); |
| 3290 |
|
t_start = (UInt_t)atoll(row->GetField(4)); |
| 3291 |
|
printf("t_start %i\n",t_start); |
| 3292 |
|
}; |
| 3293 |
|
// -------------------------------------------------------------- |
| 3294 |
|
// 2) get the OBT of the last validated run |
| 3295 |
|
// -------------------------------------------------------------- |
| 3296 |
|
oss.str(""); |
| 3297 |
|
oss << " SELECT * FROM GL_RUN WHERE VALIDATION=1 AND RUNHEADER_TIME<="<< t_start |
| 3298 |
|
<<" ORDER BY RUNHEADER_TIME DESC LIMIT 1;"; |
| 3299 |
|
printf(" Get stop validation-time: query is \n %s \n",oss.str().c_str()); |
| 3300 |
result = conn->Query(oss.str().c_str()); |
result = conn->Query(oss.str().c_str()); |
|
// |
|
| 3301 |
if ( !result ) throw -4; |
if ( !result ) throw -4; |
| 3302 |
|
if ( result->GetRowCount() ){ |
| 3303 |
|
row = result->Next(); |
| 3304 |
|
t_stop = (UInt_t)atoll(row->GetField(4)); |
| 3305 |
|
}; |
| 3306 |
|
printf("t_stop %i\n",t_stop); |
| 3307 |
|
// -------------------------------------------------------------- |
| 3308 |
|
// now retrieves runs to be validated |
| 3309 |
|
// -------------------------------------------------------------- |
| 3310 |
|
oss.str(""); |
| 3311 |
|
oss << " SELECT * FROM GL_RUN WHERE RUNHEADER_TIME <=" << t_start; |
| 3312 |
|
oss << " AND RUNHEADER_TIME >="<< t_stop; |
| 3313 |
|
oss << " ORDER BY RUNHEADER_TIME DESC;"; |
| 3314 |
|
// if ( IsDebug() ) |
| 3315 |
|
printf(" Check runs for validation: query is \n %s \n",oss.str().c_str()); |
| 3316 |
|
result = conn->Query(oss.str().c_str()); |
| 3317 |
|
if ( !result ) throw -4; |
| 3318 |
|
if ( !result->GetRowCount() ) printf(" No runs to validate \n"); |
| 3319 |
|
printf("------------------------------------------------------------------------------- \n"); |
| 3320 |
|
|
| 3321 |
|
Int_t nrow = 0; |
| 3322 |
|
GL_RUN* this_run = new GL_RUN(); |
| 3323 |
|
GL_RUN* next_run = new GL_RUN(); |
| 3324 |
|
Int_t nseq_max = 100; |
| 3325 |
|
// UInt_t* sequence = new UInt_t[100]; |
| 3326 |
|
vector<UInt_t> sequence(nseq_max); |
| 3327 |
|
Int_t nseq = 0; |
| 3328 |
|
Bool_t CHECK = false; |
| 3329 |
|
Bool_t this_ONLINE = false; |
| 3330 |
|
Bool_t next_ONLINE = false; |
| 3331 |
|
UInt_t t1=0,t2=0; |
| 3332 |
|
// --------------------------------------------------------------------------------- |
| 3333 |
|
// - loop over runs, back in time, |
| 3334 |
|
// - select sequences of runs close in time (less than 60 s apart), |
| 3335 |
|
// which could be preceeded by a calibration |
| 3336 |
|
// - check if there might be a missing calibration |
| 3337 |
|
// --------------------------------------------------------------------------------- |
| 3338 |
|
while(1){ |
| 3339 |
|
|
| 3340 |
|
row = result->Next(); |
| 3341 |
|
if( row == NULL ) break; |
| 3342 |
|
|
| 3343 |
|
//------------ |
| 3344 |
|
//get run info |
| 3345 |
|
//------------ |
| 3346 |
|
this_run->Set_GL_RUN(row); |
| 3347 |
|
|
| 3348 |
|
printf(" RUN ID %i --- TRK_CALIB_USED %i --- RM_ACQ_AFTER_CALIB %i --- TIME %i %i \n",this_run->ID,this_run->TRK_CALIB_USED,this_run->RM_ACQ_AFTER_CALIB,this_run->RUNHEADER_TIME, this_run->RUNTRAILER_TIME); |
| 3349 |
|
|
| 3350 |
|
Bool_t this_BAD = false; |
| 3351 |
|
if(this_run->GetTRK_CALIB_USED() == 1 || this_run->GetTRK_CALIB_USED() == 2) this_ONLINE = true; |
| 3352 |
|
else if (this_run->GetTRK_CALIB_USED() == 104) this_ONLINE = false; |
| 3353 |
|
else{ |
| 3354 |
|
printf("Missing or corrupted header!! \n"); |
| 3355 |
|
this_ONLINE = false; |
| 3356 |
|
this_BAD = true; |
| 3357 |
|
}; |
| 3358 |
|
|
| 3359 |
|
//----------------------------------- |
| 3360 |
|
//compare with previous(next in time) |
| 3361 |
|
//----------------------------------- |
| 3362 |
|
CHECK = false; |
| 3363 |
|
UInt_t interval=0; |
| 3364 |
|
|
| 3365 |
|
if( nrow != 0){ |
| 3366 |
|
|
| 3367 |
|
|
| 3368 |
|
t1 = this_run->GetRUNTRAILER_TIME(); |
| 3369 |
|
t2 = next_run->GetRUNHEADER_TIME(); |
| 3370 |
|
interval = (t2-t1); |
| 3371 |
|
|
| 3372 |
|
if(this_ONLINE && next_ONLINE){ // this: ON-LINE + next: ON-LINE |
| 3373 |
|
|
| 3374 |
|
if( this_run->ID == next_run->ID_RUN_FRAG ) interval = 0; //=> run fragments |
| 3375 |
|
|
| 3376 |
|
if( interval >= 60 )CHECK = true; //more than 60 s => there might be a calibration |
| 3377 |
|
|
| 3378 |
|
/* if( CHECK && !next_run->GetRM_ACQ_AFTER_CALIB() ) |
| 3379 |
|
printf(" ValidateRuns ***WARNING*** : DT = %i but RM_ACQ_AFTER_CALIB = %i \n",(t2-t1),next_run->GetRM_ACQ_AFTER_CALIB());*/ |
| 3380 |
|
|
| 3381 |
|
|
| 3382 |
|
if( !CHECK && this_run->VALIDATION ){ |
| 3383 |
|
for (Int_t irun = 0; irun < nseq; irun++)assignVALIDATION(sequence[irun],true); |
| 3384 |
|
nseq=0; |
| 3385 |
|
} |
| 3386 |
|
|
| 3387 |
|
}else if( !this_ONLINE && next_ONLINE) { // this: DEFAULT + next:ON-LINE |
| 3388 |
|
|
| 3389 |
|
CHECK = true; |
| 3390 |
|
// if( interval < 60 ) printf(" ValidateRuns ***WARNING*** : kkkkkk DT = %i \n",interval); |
| 3391 |
|
|
| 3392 |
|
}else if( !next_ONLINE ){ // this:ANY + next:DEFAULT |
| 3393 |
|
|
| 3394 |
|
assignVALIDATION(next_run->ID,true); |
| 3395 |
|
nseq=0; |
| 3396 |
|
} |
| 3397 |
|
} |
| 3398 |
|
|
| 3399 |
|
//---------------------------- |
| 3400 |
|
//check run sequence for calib |
| 3401 |
|
//---------------------------- |
| 3402 |
|
if( CHECK ){ |
| 3403 |
|
// check if calibration exists |
| 3404 |
|
printf("DT %i ===> CHECK Missing calibration\n",interval); |
| 3405 |
|
Bool_t MISSING = MissingTRK_CALIB(t1,t2); |
| 3406 |
|
for (Int_t irun = 0; irun < nseq; irun++)assignVALIDATION(sequence[irun],!MISSING); |
| 3407 |
|
nseq=0; |
| 3408 |
|
} else printf("DT %i\n",interval); |
| 3409 |
|
//-------------- |
| 3410 |
|
//store run info |
| 3411 |
|
//-------------- |
| 3412 |
|
*next_run = *this_run; |
| 3413 |
|
next_ONLINE = this_ONLINE; |
| 3414 |
|
if( !this_BAD ){ |
| 3415 |
|
if(nseq < nseq_max){ |
| 3416 |
|
sequence[nseq] = this_run->ID; |
| 3417 |
|
nseq++; |
| 3418 |
|
}else printf("ValidateRuns ***WARNING*** : run sequence exceed assumed size (%i) \n",nseq_max); |
| 3419 |
|
}; |
| 3420 |
|
|
| 3421 |
|
nrow++; |
| 3422 |
|
|
| 3423 |
|
}; |
| 3424 |
|
delete this_run; |
| 3425 |
|
delete next_run; |
| 3426 |
// |
// |
| 3427 |
return(0); |
return(0); |
| 3428 |
}; |
}; |
| 3429 |
|
/** |
| 3430 |
|
* Check if there might be a missing tracker calibration in a given time interval |
| 3431 |
|
* @param t1 From absolute time |
| 3432 |
|
* @param t2 To absolute time |
| 3433 |
|
* @return true if there might be a missing calibration |
| 3434 |
|
*/ |
| 3435 |
|
Bool_t PamelaDBOperations::MissingTRK_CALIB(UInt_t t1,UInt_t t2){ |
| 3436 |
|
|
| 3437 |
|
GL_TRK_CALIB* trkcalib = new GL_TRK_CALIB(); |
| 3438 |
|
|
| 3439 |
|
// get the closest VALIDATED calibration before the run start (t2) |
| 3440 |
|
if ( trkcalib->Query_GL_TRK_CALIB(t2, conn) )return(true); //>>> missing |
| 3441 |
|
|
| 3442 |
|
if ( trkcalib->TO_TIME < t2 ) return(true); //>>> missing |
| 3443 |
|
|
| 3444 |
|
//============================================================== |
| 3445 |
|
// Check is done first on the basis of time between calibration, |
| 3446 |
|
// which should be equal to the time between ascending-nodes. |
| 3447 |
|
//============================================================== |
| 3448 |
|
if ( t2 - trkcalib->FROM_TIME > 5700) { |
| 3449 |
|
printf("Long time to previous calib %i :-( \n",t2 - trkcalib->FROM_TIME); |
| 3450 |
|
//============================================================== |
| 3451 |
|
// there might be a missing calibration, due to: |
| 3452 |
|
// - MM full |
| 3453 |
|
// - corrupted packets |
| 3454 |
|
// - loss of data |
| 3455 |
|
// There is an exception in case a download was done during ascending node |
| 3456 |
|
//============================================================== |
| 3457 |
|
Bool_t DOWNLOAD = false; |
| 3458 |
|
// check if the calib was skipped becouse of download .... DA FARE!! |
| 3459 |
|
if(DOWNLOAD)return(false); |
| 3460 |
|
|
| 3461 |
|
return(true); //>>> missing |
| 3462 |
|
|
| 3463 |
|
}; |
| 3464 |
|
|
| 3465 |
|
//============================================================== |
| 3466 |
|
// If the last calibration is close to the run less than this time, |
| 3467 |
|
// it is enough to say that there are no missing calibrations |
| 3468 |
|
//============================================================== |
| 3469 |
|
// the long time interval bewteen runs might be due to download |
| 3470 |
|
printf("Short time to previous calib %i :-) \n",t2 - trkcalib->FROM_TIME); |
| 3471 |
|
return(false); |
| 3472 |
|
|
| 3473 |
|
}; |
| 3474 |
|
/** |
| 3475 |
|
* Assign VALIDATION value to a GL_RUN entry |
| 3476 |
|
* @param idrun Run ID |
| 3477 |
|
* @param validation true/false |
| 3478 |
|
*/ |
| 3479 |
|
Int_t PamelaDBOperations::assignVALIDATION(UInt_t idrun, Bool_t validation){ |
| 3480 |
|
TSQLResult *result = 0; |
| 3481 |
|
stringstream oss; |
| 3482 |
|
oss.str(""); |
| 3483 |
|
oss << " UPDATE GL_RUN SET VALIDATION="<< (UInt_t)validation <<" WHERE ID= " << idrun << "';"; |
| 3484 |
|
// |
| 3485 |
|
// if ( IsDebug() ) |
| 3486 |
|
printf(" Set VALIDATION = %i for run %i \n",validation,idrun); |
| 3487 |
|
// printf(" Set VALIDATION = %i for run %i : query is \n %s \n",validation,idrun,oss.str().c_str()); |
| 3488 |
|
// result = conn->Query(oss.str().c_str()); |
| 3489 |
|
// if ( !result ) throw -4; |
| 3490 |
|
return(0); |
| 3491 |
|
} |
| 3492 |
|
|
| 3493 |
|
|
| 3494 |
|
|