63 |
SetObt0(obt0); |
SetObt0(obt0); |
64 |
// |
// |
65 |
// |
// |
66 |
SetRootName(filerootname); |
INSERT_RAW =!filerawname.IsNull(); |
67 |
SetRawName(filerawname); |
if(INSERT_RAW)SetRawName(filerawname); |
68 |
// |
// |
69 |
this->OpenFile(); |
INSERT_ROOT = !filerootname.IsNull(); |
70 |
|
if( INSERT_ROOT ){ |
71 |
|
file = TFile::Open(this->GetRootName().Data()); |
72 |
|
// if ( !file ) INSERT_ROOT = false; |
73 |
|
}; |
74 |
|
// this->OpenFile(); |
75 |
// |
// |
76 |
this->SetID_RAW(0); |
this->SetID_RAW(0); |
77 |
this->SetID_ROOT(0); |
this->SetID_ROOT(0); |
78 |
|
|
79 |
|
VALIDATE = false; |
80 |
|
|
81 |
// |
// |
82 |
}; |
}; |
83 |
|
|
86 |
*/ |
*/ |
87 |
void PamelaDBOperations::Close(){ |
void PamelaDBOperations::Close(){ |
88 |
if( conn && conn->IsConnected() ) conn->Close(); |
if( conn && conn->IsConnected() ) conn->Close(); |
89 |
|
delete clean_time; |
90 |
delete glrun; |
delete glrun; |
91 |
delete this; |
delete this; |
92 |
}; |
}; |
95 |
// SETTERS |
// SETTERS |
96 |
// |
// |
97 |
|
|
98 |
|
// |
99 |
|
// must be out of the constructor in order to FORCE the validation of the latest runs in case you run the validation together with the latest file |
100 |
|
// |
101 |
|
void PamelaDBOperations::CheckValidate(Long64_t olderthan){ |
102 |
|
clean_time = new TDatime(); |
103 |
|
if(olderthan >= 0){ |
104 |
|
VALIDATE = true; |
105 |
|
UInt_t timelim = 0; |
106 |
|
timelim = (UInt_t)clean_time->Convert() - olderthan; |
107 |
|
clean_time->Set(timelim,false); |
108 |
|
}; |
109 |
|
}; |
110 |
|
|
111 |
/** |
/** |
112 |
* Open the DB connection |
* Open the DB connection |
113 |
* @param host hostname for the SQL connection. |
* @param host hostname for the SQL connection. |
194 |
* Store the olderthan variable |
* Store the olderthan variable |
195 |
* @param olderthan |
* @param olderthan |
196 |
*/ |
*/ |
197 |
void PamelaDBOperations::SetOlderThan(Long64_t oldthan){ |
// void PamelaDBOperations::SetOlderThan(Long64_t oldthan){ |
198 |
olderthan = oldthan; |
// olderthan = oldthan; |
199 |
}; |
// }; |
200 |
|
|
201 |
/** |
/** |
202 |
* Retrieve the ID_RAW, if exists, returns NULL if does not exist. |
* Retrieve the ID_RAW, if exists, returns NULL if does not exist. |
342 |
// 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) |
343 |
// |
// |
344 |
PacketType *pctp=0; |
PacketType *pctp=0; |
|
T->GetEntry(upperentry); |
|
|
code = eh->GetCounter(); |
|
|
Int_t lasttrail = code->Get(pctp->RunTrailer); |
|
|
Int_t lasthead = code->Get(pctp->RunHeader); |
|
345 |
TTree *rh=(TTree*)file->Get("RunHeader"); |
TTree *rh=(TTree*)file->Get("RunHeader"); |
346 |
if ( !rh || rh->IsZombie() ) throw -17; |
if ( !rh || rh->IsZombie() ) throw -17; |
347 |
TTree *rt=(TTree*)file->Get("RunTrailer"); |
TTree *rt=(TTree*)file->Get("RunTrailer"); |
364 |
UInt_t pkth = 0; |
UInt_t pkth = 0; |
365 |
ULong64_t obth = 0; |
ULong64_t obth = 0; |
366 |
// |
// |
367 |
|
T->GetEntry(upperentry); |
368 |
|
code = eh->GetCounter(); |
369 |
|
Int_t lasttrail = code->Get(pctp->RunTrailer); |
370 |
|
Int_t lasthead = code->Get(pctp->RunHeader); |
371 |
if ( lasttrail < rtev ){ |
if ( lasttrail < rtev ){ |
372 |
rt->GetEntry(lasttrail); |
rt->GetEntry(lasttrail); |
373 |
pht = eht->GetPscuHeader(); |
pht = eht->GetPscuHeader(); |
378 |
if ( lasthead < rhev ){ |
if ( lasthead < rhev ){ |
379 |
rh->GetEntry(lasthead); |
rh->GetEntry(lasthead); |
380 |
phh = ehh->GetPscuHeader(); |
phh = ehh->GetPscuHeader(); |
381 |
pkth = PKT(pht->GetCounter()); |
pkth = PKT(phh->GetCounter()); |
382 |
obth = OBT(pht->GetOrbitalTime()); |
obth = OBT(phh->GetOrbitalTime()); |
383 |
}; |
}; |
384 |
// |
// |
385 |
if ( IsDebug() ) printf(" rhev before %i ph %i upperp %i oh %llu uppero %llu \n",rhev,pkth,upperpkt,obth,upperobt); |
if ( IsDebug() ) printf(" rhev before %i ph %i upperp %i oh %llu uppero %llu \n",rhev,pkth,upperpkt,obth,upperobt); |
423 |
pkth = PKT(phh->GetCounter()); |
pkth = PKT(phh->GetCounter()); |
424 |
obth = OBT(phh->GetOrbitalTime()); |
obth = OBT(phh->GetOrbitalTime()); |
425 |
// |
// |
426 |
|
// if ( IsDebug() ) printf(" k %i rhev before %i ph %u upperp %u oh %u uppero %u \n",k,rhev,pkth,spkth,obth,sobth); |
427 |
|
// |
428 |
if ( pkth < spkth && obth < sobth ){ |
if ( pkth < spkth && obth < sobth ){ |
|
if ( IsDebug() ) printf(" rhev before %i ph %i upperp %i oh %llu uppero %llu \n",rhev,pkth,upperpkt,obth,upperobt); |
|
429 |
if ( IsDebug() ) printf(" RH PROBLEMS determining the event repetition at the end of the file lasthead %i \n",rhev); |
if ( IsDebug() ) printf(" RH PROBLEMS determining the event repetition at the end of the file lasthead %i \n",rhev); |
430 |
// |
// |
431 |
rhev--; |
rhev = k-1; |
432 |
rh->GetEntry(rhev); |
rh->GetEntry(rhev); |
433 |
pkth = spkth; |
pkth = spkth; |
434 |
obth = sobth; |
obth = sobth; |
|
if ( IsDebug() ) printf(" lasthead %i pt %i p1 %i ot %u o1 %u \n",rhev,pkth,spkth,obth,sobth); |
|
435 |
// |
// |
436 |
UInt_t evbefh = 0; |
UInt_t evbefh = 0; |
437 |
code = ehh->GetCounter(); |
code = ehh->GetCounter(); |
441 |
ph = eh->GetPscuHeader(); |
ph = eh->GetPscuHeader(); |
442 |
t_pktlast = PKT(ph->GetCounter()); |
t_pktlast = PKT(ph->GetCounter()); |
443 |
t_obtlast = OBT(ph->GetOrbitalTime()); |
t_obtlast = OBT(ph->GetOrbitalTime()); |
444 |
if ( t_pktlast < spkth && t_obtlast < sobth ){ // jump |
if ( t_pktlast <= spkth && t_obtlast <= sobth ){ // jump |
445 |
upperpkt = pkth; |
upperpkt = pkth; |
446 |
upperobt = obth; |
upperobt = obth; |
447 |
upperentry = evbefh-1; |
upperentry = evbefh-1; |
461 |
}; |
}; |
462 |
}; |
}; |
463 |
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); |
464 |
|
goto kikko0; |
465 |
}; |
}; |
466 |
}; |
}; |
467 |
|
kikko0: |
468 |
// |
// |
469 |
// |
// |
470 |
// |
// |
482 |
pktt = PKT(pht->GetCounter()); |
pktt = PKT(pht->GetCounter()); |
483 |
obtt = OBT(pht->GetOrbitalTime()); |
obtt = OBT(pht->GetOrbitalTime()); |
484 |
// |
// |
485 |
|
// if ( IsDebug() ) printf(" k %i rtev beforev %i pt %i upperp %i ot %llu uppero %llu \n",k,rtev,pktt,spktt,obtt,sobtt); |
486 |
|
// |
487 |
if ( pktt < spktt && obtt < sobtt ){ |
if ( pktt < spktt && obtt < sobtt ){ |
|
if ( IsDebug() ) printf(" rtev beforev %i pt %i upperp %i ot %llu uppero %llu \n",rtev,pktt,upperpkt,obtt,upperobt); |
|
488 |
if ( IsDebug() ) printf(" RT PROBLEMS determining the event repetition at the end of the file lasttrail %i \n",rtev); |
if ( IsDebug() ) printf(" RT PROBLEMS determining the event repetition at the end of the file lasttrail %i \n",rtev); |
489 |
// |
// |
490 |
rtev--; |
rtev = k-1; |
491 |
rt->GetEntry(rtev); |
rt->GetEntry(rtev); |
492 |
pktt = spktt; |
pktt = spktt; |
493 |
obtt = sobtt; |
obtt = sobtt; |
501 |
ph = eh->GetPscuHeader(); |
ph = eh->GetPscuHeader(); |
502 |
t_pktlast = PKT(ph->GetCounter()); |
t_pktlast = PKT(ph->GetCounter()); |
503 |
t_obtlast = OBT(ph->GetOrbitalTime()); |
t_obtlast = OBT(ph->GetOrbitalTime()); |
504 |
if ( t_pktlast < spktt && t_obtlast < sobtt ){ // jump |
if ( t_pktlast <= spktt && t_obtlast <= sobtt ){ // jump |
505 |
upperpkt = pktt; |
upperpkt = pktt; |
506 |
upperobt = obtt; |
upperobt = obtt; |
507 |
upperentry = evbeft-1; |
upperentry = evbeft-1; |
521 |
}; |
}; |
522 |
}; |
}; |
523 |
if ( IsDebug() ) printf(" rtev after %i pt %i upperp %i ot %llu uppero %llu \n",rtev,pktt,upperpkt,obtt,upperobt); |
if ( IsDebug() ) printf(" rtev after %i pt %i upperp %i ot %llu uppero %llu \n",rtev,pktt,upperpkt,obtt,upperobt); |
524 |
break; |
goto kikko; |
525 |
|
// break; |
526 |
// |
// |
527 |
}; |
}; |
528 |
// |
// |
529 |
}; |
}; |
530 |
// |
// |
531 |
// kikko: |
kikko: |
532 |
|
// |
533 |
|
T->GetEntry(upperentry); |
534 |
|
code = eh->GetCounter(); |
535 |
|
lasttrail = code->Get(pctp->RunTrailer); |
536 |
|
lasthead = code->Get(pctp->RunHeader); |
537 |
|
if ( lasttrail < rtev ){ |
538 |
|
rt->GetEntry(lasttrail); |
539 |
|
pht = eht->GetPscuHeader(); |
540 |
|
pktt = PKT(pht->GetCounter()); |
541 |
|
obtt = OBT(pht->GetOrbitalTime()); |
542 |
|
}; |
543 |
|
// |
544 |
|
if ( lasthead < rhev ){ |
545 |
|
rh->GetEntry(lasthead); |
546 |
|
phh = ehh->GetPscuHeader(); |
547 |
|
pkth = PKT(phh->GetCounter()); |
548 |
|
obth = OBT(phh->GetOrbitalTime()); |
549 |
|
}; |
550 |
|
// |
551 |
|
if ( IsDebug() ) printf(" rhev before %i ph %i upperp %i oh %llu uppero %llu \n",rhev,pkth,upperpkt,obth,upperobt); |
552 |
|
if ( pkth > upperpkt && obth > upperobt ){ |
553 |
|
if ( IsDebug() ) printf(" Upper limits extended to include last header: ph %i upperp %i oh %llu uppero %llu \n",pkth,upperpkt,obth,upperobt); |
554 |
|
upperpkt = pkth; |
555 |
|
upperobt = obth; |
556 |
|
rhev = lasthead+1; |
557 |
|
} else { |
558 |
|
rhev = lasthead; |
559 |
|
}; |
560 |
|
if ( IsDebug() ) printf(" rhev after %i ph %i upperp %i oh %llu uppero %llu \n",rhev,pkth,upperpkt,obth,upperobt); |
561 |
|
// |
562 |
|
if ( IsDebug() ) printf(" rtev beforev %i pt %i upperp %i ot %llu uppero %llu \n",rtev,pktt,upperpkt,obtt,upperobt); |
563 |
|
if ( pktt > upperpkt && obtt > upperobt ){ |
564 |
|
if ( IsDebug() ) printf(" Upper limits extended to include last trailer: pt %i upperp %i ot %llu uppero %llu \n",pktt,upperpkt,obtt,upperobt); |
565 |
|
upperpkt = pktt; |
566 |
|
upperobt = obtt; |
567 |
|
rtev = lasttrail+1; |
568 |
|
} else { |
569 |
|
rtev = lasttrail; |
570 |
|
}; |
571 |
|
if ( IsDebug() ) printf(" rtev after %i pt %i upperp %i ot %llu uppero %llu \n",rtev,pktt,upperpkt,obtt,upperobt); |
572 |
// |
// |
573 |
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); |
574 |
// |
// |
650 |
// PRIVATE FUNCTIONS |
// PRIVATE FUNCTIONS |
651 |
// |
// |
652 |
|
|
653 |
/** |
// /** |
654 |
* Open the ROOT filename for reading |
// * Open the ROOT filename for reading |
655 |
*/ |
// */ |
656 |
void PamelaDBOperations::OpenFile(){ |
// void PamelaDBOperations::OpenFile(){ |
657 |
file = TFile::Open(this->GetRootName().Data()); |
// file = TFile::Open(this->GetRootName().Data()); |
658 |
|
// // |
659 |
|
|
660 |
|
void PamelaDBOperations::CheckFile(){ |
661 |
|
if ( !file ) throw -12; |
662 |
}; |
}; |
663 |
|
|
664 |
|
|
665 |
/** |
/** |
666 |
* Check if LEVEL0 file and DB connection have really be opened |
* Check if LEVEL0 file and DB connection have really be opened |
667 |
*/ |
*/ |
668 |
void PamelaDBOperations::CheckFile(){ |
void PamelaDBOperations::CheckConnection(){ |
|
// |
|
|
if ( !file ) throw -12; |
|
669 |
// |
// |
670 |
// check connection |
// check connection |
671 |
// |
// |
672 |
if( !conn ) throw -1; |
if( !conn ) throw -1; |
673 |
bool connect = conn->IsConnected(); |
bool connect = conn->IsConnected(); |
674 |
if( !connect ) throw -1; |
if( !connect ) throw -1; |
675 |
}; |
}; |
676 |
|
|
677 |
/** |
/** |
3192 |
TSQLRow *row2 = 0; |
TSQLRow *row2 = 0; |
3193 |
// |
// |
3194 |
UInt_t moved = 0; |
UInt_t moved = 0; |
3195 |
UInt_t timelim = 0; |
// UInt_t timelim = 0; |
3196 |
TDatime *time = new TDatime(); |
// TDatime *time = new TDatime(); |
3197 |
// |
// |
3198 |
stringstream oss; |
stringstream oss; |
3199 |
oss.str(""); |
oss.str(""); |
3200 |
// |
// |
3201 |
// |
// |
|
// |
|
|
if ( olderthan < 0 ){ |
|
|
if ( IsDebug() ) printf(" Do not clean GL_RUN_FRAGMENTS table \n"); |
|
|
return(1); |
|
|
}; |
|
|
// |
|
|
// timelim = now - olderthan |
|
|
// |
|
|
time->Set(); |
|
|
timelim = (UInt_t)time->Convert() - olderthan; |
|
|
time->Set(timelim,false); |
|
|
// |
|
3202 |
// check if there are entries older than "olderthan" seconds from now |
// check if there are entries older than "olderthan" seconds from now |
3203 |
// |
// |
3204 |
oss.str(""); |
oss.str(""); |
3205 |
oss << " SELECT ID FROM GL_RUN_FRAGMENTS WHERE" |
oss << " SELECT ID FROM GL_RUN_FRAGMENTS WHERE" |
3206 |
<< " INSERT_TIME <= '" << time->AsSQLString() << "';"; |
<< " INSERT_TIME <= '" << clean_time->AsSQLString() << "';"; |
3207 |
// |
// |
3208 |
if ( IsDebug() ) printf(" Select from GL_RUN_FRAGMENTS runs older than %s : query is \n %s \n",time->AsSQLString(),oss.str().c_str()); |
if ( IsDebug() ) printf(" Select from GL_RUN_FRAGMENTS runs older than %s : query is \n %s \n",clean_time->AsSQLString(),oss.str().c_str()); |
3209 |
result = conn->Query(oss.str().c_str()); |
result = conn->Query(oss.str().c_str()); |
3210 |
// |
// |
3211 |
if ( result ){ |
if ( result ){ |
3303 |
TSQLResult *result = 0; |
TSQLResult *result = 0; |
3304 |
TSQLRow *row = 0; |
TSQLRow *row = 0; |
3305 |
// |
// |
|
UInt_t timelim = 0; |
|
|
TDatime *time = new TDatime(); |
|
|
// |
|
3306 |
stringstream oss; |
stringstream oss; |
3307 |
oss.str(""); |
oss.str(""); |
3308 |
// |
// |
|
// |
|
|
// |
|
|
if ( olderthan < 0 ){ |
|
|
if ( IsDebug() ) printf(" Do not validate runs \n"); |
|
|
return(1); |
|
|
}; |
|
|
// |
|
|
// timelim = now - olderthan |
|
|
// |
|
|
time->Set(); |
|
|
timelim = (UInt_t)time->Convert() - olderthan; |
|
|
time->Set(timelim,false); |
|
|
|
|
|
printf("Validate runs older than %s \n",time->AsSQLString()); |
|
|
|
|
3309 |
// ======================================================= |
// ======================================================= |
3310 |
// validate runs by checking missing calibrations |
// validate runs by checking missing calibrations |
3311 |
// ======================================================= |
// ======================================================= |
3315 |
// 1) get the OBT of the last run inserted after clean-time limit |
// 1) get the OBT of the last run inserted after clean-time limit |
3316 |
// -------------------------------------------------------------- |
// -------------------------------------------------------------- |
3317 |
oss.str(""); |
oss.str(""); |
3318 |
oss << " SELECT * FROM GL_RUN WHERE INSERT_TIME <= '" << time->AsSQLString() |
oss << " SELECT * FROM GL_RUN WHERE INSERT_TIME <= '" << clean_time->AsSQLString() |
3319 |
<< "' ORDER BY INSERT_TIME DESC LIMIT 1;"; |
<< "' ORDER BY RUNHEADER_TIME DESC LIMIT 1;"; |
3320 |
printf(" Get start validation-time: query is \n %s \n",oss.str().c_str()); |
if ( IsDebug() ) printf(" Get start validation-time: query is \n %s \n",oss.str().c_str()); |
3321 |
result = conn->Query(oss.str().c_str()); |
result = conn->Query(oss.str().c_str()); |
3322 |
if ( !result ) throw -4; |
if ( !result ) throw -4; |
3323 |
if ( !result->GetRowCount() ) { |
if ( !result->GetRowCount() ) { |
3326 |
}else{ |
}else{ |
3327 |
row = result->Next(); |
row = result->Next(); |
3328 |
t_start = (UInt_t)atoll(row->GetField(4)); |
t_start = (UInt_t)atoll(row->GetField(4)); |
|
printf("t_start %i\n",t_start); |
|
3329 |
}; |
}; |
3330 |
// -------------------------------------------------------------- |
// -------------------------------------------------------------- |
3331 |
// 2) get the OBT of the last validated run |
// 2) get the OBT of the last validated run |
3333 |
oss.str(""); |
oss.str(""); |
3334 |
oss << " SELECT * FROM GL_RUN WHERE VALIDATION=1 AND RUNHEADER_TIME<="<< t_start |
oss << " SELECT * FROM GL_RUN WHERE VALIDATION=1 AND RUNHEADER_TIME<="<< t_start |
3335 |
<<" ORDER BY RUNHEADER_TIME DESC LIMIT 1;"; |
<<" ORDER BY RUNHEADER_TIME DESC LIMIT 1;"; |
3336 |
printf(" Get stop validation-time: query is \n %s \n",oss.str().c_str()); |
if ( IsDebug() ) printf(" Get stop validation-time: query is \n %s \n",oss.str().c_str()); |
3337 |
result = conn->Query(oss.str().c_str()); |
result = conn->Query(oss.str().c_str()); |
3338 |
if ( !result ) throw -4; |
if ( !result ) throw -4; |
3339 |
if ( result->GetRowCount() ){ |
if ( result->GetRowCount() ){ |
3340 |
row = result->Next(); |
row = result->Next(); |
3341 |
t_stop = (UInt_t)atoll(row->GetField(4)); |
t_stop = (UInt_t)atoll(row->GetField(4)); |
3342 |
}; |
}; |
3343 |
printf("t_stop %i\n",t_stop); |
if ( IsDebug() ) printf("Validation interval: from time %i - to time %i \n\n",t_stop,t_start); |
3344 |
// -------------------------------------------------------------- |
// -------------------------------------------------------------- |
3345 |
// now retrieves runs to be validated |
// now retrieves runs to be validated |
3346 |
// -------------------------------------------------------------- |
// -------------------------------------------------------------- |
3349 |
oss << " AND RUNHEADER_TIME >="<< t_stop; |
oss << " AND RUNHEADER_TIME >="<< t_stop; |
3350 |
oss << " ORDER BY RUNHEADER_TIME DESC;"; |
oss << " ORDER BY RUNHEADER_TIME DESC;"; |
3351 |
// if ( IsDebug() ) |
// if ( IsDebug() ) |
3352 |
printf(" Check runs for validation: query is \n %s \n",oss.str().c_str()); |
if ( IsDebug() )printf(" Check runs for validation: query is \n %s \n",oss.str().c_str()); |
3353 |
result = conn->Query(oss.str().c_str()); |
result = conn->Query(oss.str().c_str()); |
3354 |
if ( !result ) throw -4; |
if ( !result ) throw -4; |
3355 |
if ( !result->GetRowCount() ) printf(" No runs to validate \n"); |
if ( !result->GetRowCount() ) printf(" No runs to validate \n"); |
3356 |
printf("------------------------------------------------------------------------------- \n"); |
// printf("------------------------------------------------------------------------------- \n"); |
3357 |
|
|
3358 |
Int_t nrow = 0; |
Int_t nrow = 0; |
3359 |
GL_RUN* this_run = new GL_RUN(); |
GL_RUN* this_run = new GL_RUN(); |
3360 |
GL_RUN* next_run = new GL_RUN(); |
GL_RUN* next_run = new GL_RUN(); |
3361 |
Int_t nseq_max = 100; |
Int_t nseq_max = 1000; |
3362 |
// UInt_t* sequence = new UInt_t[100]; |
// UInt_t* sequence = new UInt_t[100]; |
3363 |
vector<UInt_t> sequence(nseq_max); |
vector<UInt_t> sequence(nseq_max); |
3364 |
Int_t nseq = 0; |
Int_t nseq = 0; |
3381 |
//get run info |
//get run info |
3382 |
//------------ |
//------------ |
3383 |
this_run->Set_GL_RUN(row); |
this_run->Set_GL_RUN(row); |
3384 |
|
|
|
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); |
|
|
|
|
3385 |
Bool_t this_BAD = false; |
Bool_t this_BAD = false; |
3386 |
if(this_run->GetTRK_CALIB_USED() == 1 || this_run->GetTRK_CALIB_USED() == 2) this_ONLINE = true; |
if(this_run->GetTRK_CALIB_USED() == 1 || this_run->GetTRK_CALIB_USED() == 2) this_ONLINE = true; |
3387 |
else if (this_run->GetTRK_CALIB_USED() == 104) this_ONLINE = false; |
else if (this_run->GetTRK_CALIB_USED() == 104) this_ONLINE = false; |
3388 |
else{ |
else{ |
3389 |
printf("Missing or corrupted header!! \n"); |
// printf("Missing or corrupted header!! \n"); |
3390 |
this_ONLINE = false; |
this_ONLINE = false; |
3391 |
this_BAD = true; |
this_BAD = true; |
3392 |
}; |
}; |
3410 |
|
|
3411 |
if( interval >= 60 )CHECK = true; //more than 60 s => there might be a calibration |
if( interval >= 60 )CHECK = true; //more than 60 s => there might be a calibration |
3412 |
|
|
|
/* if( CHECK && !next_run->GetRM_ACQ_AFTER_CALIB() ) |
|
|
printf(" ValidateRuns ***WARNING*** : DT = %i but RM_ACQ_AFTER_CALIB = %i \n",(t2-t1),next_run->GetRM_ACQ_AFTER_CALIB());*/ |
|
|
|
|
|
|
|
3413 |
if( !CHECK && this_run->VALIDATION ){ |
if( !CHECK && this_run->VALIDATION ){ |
3414 |
for (Int_t irun = 0; irun < nseq; irun++)assignVALIDATION(sequence[irun],true); |
for (Int_t irun = 0; irun < nseq; irun++)assignVALIDATION(sequence[irun],true); |
3415 |
nseq=0; |
nseq=0; |
3418 |
}else if( !this_ONLINE && next_ONLINE) { // this: DEFAULT + next:ON-LINE |
}else if( !this_ONLINE && next_ONLINE) { // this: DEFAULT + next:ON-LINE |
3419 |
|
|
3420 |
CHECK = true; |
CHECK = true; |
|
// if( interval < 60 ) printf(" ValidateRuns ***WARNING*** : kkkkkk DT = %i \n",interval); |
|
3421 |
|
|
3422 |
}else if( !next_ONLINE ){ // this:ANY + next:DEFAULT |
}else if( !next_ONLINE ){ // this:ANY + next:DEFAULT |
3423 |
|
|
3431 |
//---------------------------- |
//---------------------------- |
3432 |
if( CHECK ){ |
if( CHECK ){ |
3433 |
// check if calibration exists |
// check if calibration exists |
3434 |
printf("DT %i ===> CHECK Missing calibration\n",interval); |
if ( IsDebug() )printf("DT %i ===> CHECK Missing calibration\n",interval); |
3435 |
Bool_t MISSING = MissingTRK_CALIB(t1,t2); |
Bool_t MISSING = MissingTRK_CALIB(t1,t2); |
3436 |
for (Int_t irun = 0; irun < nseq; irun++)assignVALIDATION(sequence[irun],!MISSING); |
for (Int_t irun = 0; irun < nseq; irun++)assignVALIDATION(sequence[irun],!MISSING); |
3437 |
nseq=0; |
nseq=0; |
3438 |
} else printf("DT %i\n",interval); |
}; |
3439 |
//-------------- |
//-------------- |
3440 |
//store run info |
//store run info |
3441 |
//-------------- |
//-------------- |
3448 |
}else printf("ValidateRuns ***WARNING*** : run sequence exceed assumed size (%i) \n",nseq_max); |
}else printf("ValidateRuns ***WARNING*** : run sequence exceed assumed size (%i) \n",nseq_max); |
3449 |
}; |
}; |
3450 |
|
|
3451 |
|
if ( IsDebug() ) printf("%i Run %i \n",nrow,this_run->ID); |
3452 |
nrow++; |
nrow++; |
3453 |
|
|
3454 |
}; |
}; |
3477 |
// which should be equal to the time between ascending-nodes. |
// which should be equal to the time between ascending-nodes. |
3478 |
//============================================================== |
//============================================================== |
3479 |
if ( t2 - trkcalib->FROM_TIME > 5700) { |
if ( t2 - trkcalib->FROM_TIME > 5700) { |
3480 |
printf("Long time to previous calib %i :-( \n",t2 - trkcalib->FROM_TIME); |
if ( IsDebug() )printf("Long time between calib and run start %i :-( ==> there might be a missing calib \n",t2 - trkcalib->FROM_TIME); |
3481 |
//============================================================== |
//============================================================== |
3482 |
// there might be a missing calibration, due to: |
// there might be a missing calibration, due to: |
3483 |
// - MM full |
// - MM full |
3498 |
// it is enough to say that there are no missing calibrations |
// it is enough to say that there are no missing calibrations |
3499 |
//============================================================== |
//============================================================== |
3500 |
// the long time interval bewteen runs might be due to download |
// the long time interval bewteen runs might be due to download |
3501 |
printf("Short time to previous calib %i :-) \n",t2 - trkcalib->FROM_TIME); |
if ( IsDebug() )printf("Short time between calib and run start %i :-) ==> OK! \n",t2 - trkcalib->FROM_TIME); |
3502 |
return(false); |
return(false); |
3503 |
|
|
3504 |
}; |
}; |
3511 |
TSQLResult *result = 0; |
TSQLResult *result = 0; |
3512 |
stringstream oss; |
stringstream oss; |
3513 |
oss.str(""); |
oss.str(""); |
3514 |
oss << " UPDATE GL_RUN SET VALIDATION="<< (UInt_t)validation <<" WHERE ID= " << idrun << "';"; |
oss << " UPDATE GL_RUN SET VALIDATION="<< (UInt_t)validation <<" WHERE ID= " << idrun << ";"; |
3515 |
// |
// |
3516 |
// if ( IsDebug() ) |
// if ( IsDebug() ) |
3517 |
printf(" Set VALIDATION = %i for run %i \n",validation,idrun); |
// printf(" Set VALIDATION = %i for run %i \n",validation,idrun); |
3518 |
// printf(" Set VALIDATION = %i for run %i : query is \n %s \n",validation,idrun,oss.str().c_str()); |
if ( IsDebug() )printf(" Query: %s \n",oss.str().c_str()); |
3519 |
// result = conn->Query(oss.str().c_str()); |
result = conn->Query(oss.str().c_str()); |
3520 |
// if ( !result ) throw -4; |
if ( !result ) throw -4; |
3521 |
return(0); |
return(0); |
3522 |
} |
} |
3523 |
|
|