| 490 |
}; |
}; |
| 491 |
|
|
| 492 |
/** |
/** |
| 493 |
|
* |
| 494 |
|
* Set the variables which belogns to physendrun tree |
| 495 |
|
* |
| 496 |
|
*/ |
| 497 |
|
void PamelaDBOperations::SetPhysEndRunVariables(){ |
| 498 |
|
// |
| 499 |
|
// |
| 500 |
|
// |
| 501 |
|
TTree *T = 0; |
| 502 |
|
T = (TTree*)file->Get("PhysEndRun"); |
| 503 |
|
if ( !T || T->IsZombie() ) throw -90; |
| 504 |
|
// |
| 505 |
|
PhysEndRunEvent *pher= 0; |
| 506 |
|
EventHeader *eh = 0; |
| 507 |
|
T->SetBranchAddress("PhysEndRun", &pher); |
| 508 |
|
T->SetBranchAddress("Header", &eh); |
| 509 |
|
// |
| 510 |
|
UInt_t phobt = 0; |
| 511 |
|
UInt_t phpkt = 0; |
| 512 |
|
// |
| 513 |
|
glrun->SetPHYSENDRUN_MASK_S3S2S12(0); |
| 514 |
|
glrun->SetPHYSENDRUN_MASK_S11CRC(0); |
| 515 |
|
// |
| 516 |
|
for (Int_t p=0; p<T->GetEntries(); p++){ |
| 517 |
|
// |
| 518 |
|
T->GetEntry(p); |
| 519 |
|
// |
| 520 |
|
phobt = (UInt_t)eh->GetPscuHeader()->GetOrbitalTime(); |
| 521 |
|
phpkt = (UInt_t)eh->GetPscuHeader()->GetCounter(); |
| 522 |
|
// |
| 523 |
|
if ( this->PKT(phpkt) >= this->PKT(glrun->GetRUNHEADER_PKT()) && this->PKT(phpkt) <= this->PKT(glrun->GetRUNTRAILER_PKT()) && this->OBT(phobt) >= this->OBT(glrun->GetRUNHEADER_OBT()) && this->OBT(phobt) <= this->OBT(glrun->GetRUNTRAILER_OBT()) ){ |
| 524 |
|
if ( glrun->GetPHYSENDRUN_MASK_S3S2S12() || glrun->GetPHYSENDRUN_MASK_S11CRC() ){ |
| 525 |
|
if ( IsDebug() ) printf(" WARNING while looping in physendrun: found two PhysEndRun packet for the same RUN! \n"); |
| 526 |
|
if ( IsDebug() ) printf(" Actual values: %X %X New values %X %X \n ",glrun->GetPHYSENDRUN_MASK_S3S2S12(),glrun->GetPHYSENDRUN_MASK_S11CRC(),(UInt_t)pher->TB_ENDRUN.TB_PMT_MASK_S3S2S12,(UInt_t)pher->TB_ENDRUN.TB_PMT_MASK_S11CRC); |
| 527 |
|
if ( PEDANTIC && IsDebug() ) printf(" ERROR while looping in physendrun: found two PhysEndRun packet for the same RUN!\n "); |
| 528 |
|
if ( PEDANTIC ) throw -91; |
| 529 |
|
} else { |
| 530 |
|
glrun->SetPHYSENDRUN_MASK_S3S2S12((UInt_t)pher->TB_ENDRUN.TB_PMT_MASK_S3S2S12); |
| 531 |
|
glrun->SetPHYSENDRUN_MASK_S11CRC((UInt_t)pher->TB_ENDRUN.TB_PMT_MASK_S11CRC); |
| 532 |
|
}; |
| 533 |
|
}; |
| 534 |
|
}; |
| 535 |
|
// |
| 536 |
|
}; |
| 537 |
|
|
| 538 |
|
/** |
| 539 |
* Patch, look for upper limits to avoid processing retransmitted data |
* Patch, look for upper limits to avoid processing retransmitted data |
| 540 |
*/ |
*/ |
| 541 |
Int_t PamelaDBOperations::SetUpperLimits(){ |
Int_t PamelaDBOperations::SetUpperLimits(){ |
| 785 |
}; |
}; |
| 786 |
// |
// |
| 787 |
if ( chewbacca && nevent < 1 ) { |
if ( chewbacca && nevent < 1 ) { |
| 788 |
pktfirst = chpktmin; |
pktfirst = chpktmin; |
| 789 |
upperpkt = PKT(chpktmax); |
upperpkt = PKT(chpktmax); |
| 790 |
pktlast = chpktmax; |
pktlast = chpktmax; |
| 791 |
obtfirst = chobtmin; |
obtfirst = chobtmin; |
| 792 |
obtlast = chobtmax; |
obtlast = chobtmax; |
| 793 |
upperobt = OBT(chobtmax); |
upperobt = OBT(chobtmax); |
| 794 |
}; |
}; |
| 795 |
// |
// |
| 796 |
if ( IsDebug() ) printf(" First entries are: OBT %u pkt_num %u entry %i\n",obtfirst,pktfirst,chminentry); |
if ( IsDebug() ) printf(" First entries are: OBT %u pkt_num %u entry %i\n",obtfirst,pktfirst,chminentry); |
| 798 |
if ( IsDebug() ) printf(" Last entries are: OBT %lld pkt_num %lld entry %i\n",upperobt,upperpkt,upperentry); |
if ( IsDebug() ) printf(" Last entries are: OBT %lld pkt_num %lld entry %i\n",upperobt,upperpkt,upperentry); |
| 799 |
// |
// |
| 800 |
if ( (PKT(pktlast) < PKT(pktfirst) && OBT(obtlast) > OBT(obtfirst)) || (PKT(pktlast) > PKT(pktfirst) && OBT(obtlast) < OBT(obtfirst)) ){ |
if ( (PKT(pktlast) < PKT(pktfirst) && OBT(obtlast) > OBT(obtfirst)) || (PKT(pktlast) > PKT(pktfirst) && OBT(obtlast) < OBT(obtfirst)) ){ |
| 801 |
if ( IsDebug() ) printf(" Inconsistent PKT/OBT sequence: \n (PKT(pktlast) < PKT(pktfirst) && OBT(obtlast) > OBT(obtfirst)) %llu < %llu && %llu > %llu \n OR \n (PKT(pktlast) > PKT(pktfirst) && OBT(obtlast) < OBT(obtfirst)) %llu > %llu && %llu < %llu \n",PKT(pktlast),PKT(pktfirst),OBT(obtlast),OBT(obtfirst),PKT(pktlast),PKT(pktfirst),OBT(obtlast),OBT(obtfirst)); |
if ( IsDebug() ) printf(" Inconsistent PKT/OBT sequence: \n (PKT(pktlast) < PKT(pktfirst) && OBT(obtlast) > OBT(obtfirst)) %llu < %llu && %llu > %llu \n OR \n (PKT(pktlast) > PKT(pktfirst) && OBT(obtlast) < OBT(obtfirst)) %llu > %llu && %llu < %llu \n",PKT(pktlast),PKT(pktfirst),OBT(obtlast),OBT(obtfirst),PKT(pktlast),PKT(pktfirst),OBT(obtlast),OBT(obtfirst)); |
| 802 |
if ( PEDANTIC ) throw -88; |
if ( PEDANTIC ) throw -88; |
| 803 |
return(32); |
return(32); |
| 804 |
}; |
}; |
| 805 |
// |
// |
| 806 |
if ( !nevent ) return(64); |
if ( !nevent ) return(64); |
| 1086 |
upperpkt = pkth; |
upperpkt = pkth; |
| 1087 |
upperobt = obth; |
upperobt = obth; |
| 1088 |
rhev = lasthead+1; |
rhev = lasthead+1; |
| 1089 |
} else { |
} else { |
| 1090 |
rhev = lasthead; |
rhev = lasthead; |
| 1091 |
}; |
}; |
| 1092 |
if ( IsDebug() ) printf(" rhev after %i ph %lld upperp %lld oh %lld uppero %lld \n",rhev,pkth,upperpkt,obth,upperobt); |
if ( IsDebug() ) printf(" rhev after %i ph %lld upperp %lld oh %lld uppero %lld \n",rhev,pkth,upperpkt,obth,upperobt); |
| 1306 |
*/ |
*/ |
| 1307 |
Long64_t PamelaDBOperations::PKT(UInt_t pkt_num){ |
Long64_t PamelaDBOperations::PKT(UInt_t pkt_num){ |
| 1308 |
// |
// |
| 1309 |
// if ( IsDebug() ) printf(" pkt conversion: pkt_num is %u pktfirst is %u (UInt_t)(16777214/2)) is %u \n",pkt_num,ppktfirst,(UInt_t)(16777214/2)); |
// if ( IsDebug() ) printf(" pkt conversion: pkt_num is %u pktfirst is %u (UInt_t)(16777214/2)) is %u \n",pkt_num,ppktfirst,(UInt_t)(16777214/2)); |
| 1310 |
// |
// |
| 1311 |
if ( pkt_num < (ppktfirst/2) && ppktfirst > (16777214/2) ){ |
if ( pkt_num < (ppktfirst/2) && ppktfirst > (16777214/2) ){ |
| 1312 |
// if ( IsDebug() ) printf(" rise up pktnum %lld \n",(Long64_t)pkt_num+16777215LL); |
// if ( IsDebug() ) printf(" rise up pktnum %lld \n",(Long64_t)pkt_num+16777215LL); |
| 1313 |
return((Long64_t)pkt_num+16777215LL); |
return((Long64_t)pkt_num+16777215LL); |
| 1314 |
}; |
}; |
| 1315 |
// |
// |
| 1316 |
if ( pkt_num > ((Long64_t)ppktfirst*2) && pkt_num > (16777214/2) ){ |
if ( pkt_num > ((Long64_t)ppktfirst*2) && pkt_num > (16777214/2) ){ |
| 1317 |
// if ( IsDebug() ) printf(" rise down pktnum %lld \n",(Long64_t)pkt_num-16777215LL); |
// if ( IsDebug() ) printf(" rise down pktnum %lld \n",(Long64_t)pkt_num-16777215LL); |
| 1318 |
return((Long64_t)pkt_num-16777215LL); |
return((Long64_t)pkt_num-16777215LL); |
| 1319 |
}; |
}; |
| 1320 |
// |
// |
| 1321 |
// if ( IsDebug() ) printf(" as it is %lld \n",(Long64_t)pkt_num); |
// if ( IsDebug() ) printf(" as it is %lld \n",(Long64_t)pkt_num); |
| 1322 |
return((Long64_t)pkt_num); |
return((Long64_t)pkt_num); |
| 1323 |
// |
// |
| 1324 |
}; |
}; |
| 1328 |
*/ |
*/ |
| 1329 |
Long64_t PamelaDBOperations::OBT(UInt_t obt){ |
Long64_t PamelaDBOperations::OBT(UInt_t obt){ |
| 1330 |
// |
// |
| 1331 |
// if ( IsDebug() ) printf(" obt conversion: obt is %u obtfirst is %u (numeric_limits<UInt_t>::max()/2) is %u \n",obt,pobtfirst,(UInt_t)(numeric_limits<UInt_t>::max()/2)); |
// if ( IsDebug() ) printf(" obt conversion: obt is %u obtfirst is %u (numeric_limits<UInt_t>::max()/2) is %u \n",obt,pobtfirst,(UInt_t)(numeric_limits<UInt_t>::max()/2)); |
| 1332 |
// |
// |
| 1333 |
if ( obt < (pobtfirst/2) && pobtfirst > (numeric_limits<UInt_t>::max()/2) ){ |
if ( obt < (pobtfirst/2) && pobtfirst > (numeric_limits<UInt_t>::max()/2) ){ |
| 1334 |
// if ( IsDebug() ) printf(" rise up obt %lld \n",(Long64_t)obt+(Long64_t)numeric_limits<UInt_t>::max()); |
// if ( IsDebug() ) printf(" rise up obt %lld \n",(Long64_t)obt+(Long64_t)numeric_limits<UInt_t>::max()); |
| 1335 |
return((Long64_t)obt+(Long64_t)numeric_limits<UInt_t>::max()); |
return((Long64_t)obt+(Long64_t)numeric_limits<UInt_t>::max()); |
| 1336 |
}; |
}; |
| 1337 |
// |
// |
| 1338 |
if ( obt > ((Long64_t)pobtfirst*2) && obt > (numeric_limits<UInt_t>::max()/2) ){ |
if ( obt > ((Long64_t)pobtfirst*2) && obt > (numeric_limits<UInt_t>::max()/2) ){ |
| 1339 |
// if ( IsDebug() ) printf(" pobtfirst*2 %lld \n",((Long64_t)pobtfirst*2)); |
// if ( IsDebug() ) printf(" pobtfirst*2 %lld \n",((Long64_t)pobtfirst*2)); |
| 1340 |
// if ( IsDebug() ) printf(" rise down pktnum %lld \n", (Long64_t)obt-(Long64_t)numeric_limits<UInt_t>::max()); |
// if ( IsDebug() ) printf(" rise down pktnum %lld \n", (Long64_t)obt-(Long64_t)numeric_limits<UInt_t>::max()); |
| 1341 |
return((Long64_t)obt-(Long64_t)numeric_limits<UInt_t>::max()); |
return((Long64_t)obt-(Long64_t)numeric_limits<UInt_t>::max()); |
| 1342 |
}; |
}; |
| 1343 |
// |
// |
| 1344 |
// if ( IsDebug() ) printf(" as it is %lld \n",(Long64_t)obt); |
// if ( IsDebug() ) printf(" as it is %lld \n",(Long64_t)obt); |
| 1345 |
return((Long64_t)obt); |
return((Long64_t)obt); |
| 1346 |
}; |
}; |
| 1347 |
|
|
| 1451 |
if ( IsDebug() ) printf(" firstev %i lastev %i nevents %i \n",firstev,lastev,lastev-firstev+1); |
if ( IsDebug() ) printf(" firstev %i lastev %i nevents %i \n",firstev,lastev,lastev-firstev+1); |
| 1452 |
// |
// |
| 1453 |
this->SetCommonGLRUN(rhtime,rttime); |
this->SetCommonGLRUN(rhtime,rttime); |
| 1454 |
|
this->SetPhysEndRunVariables(); |
| 1455 |
// |
// |
| 1456 |
}; |
}; |
| 1457 |
|
|
| 2108 |
cod = ehh->GetCounter(); |
cod = ehh->GetCounter(); |
| 2109 |
tcod = (UInt_t)cod->Get(pctp->Physics); |
tcod = (UInt_t)cod->Get(pctp->Physics); |
| 2110 |
evbefh = TMath::Max(chminentry,tcod); |
evbefh = TMath::Max(chminentry,tcod); |
| 2111 |
// if ( (UInt_t)evbefh == upperentry ) evbefh = upperentry + 1; // this does not work due to the Counter bug in chewbacca |
// if ( (UInt_t)evbefh == upperentry ) evbefh = upperentry + 1; // this does not work due to the Counter bug in chewbacca |
| 2112 |
if ( (UInt_t)evbefh == upperentry || !upperentry ) evbefh = upperentry + 1; |
if ( (UInt_t)evbefh == upperentry || !upperentry ) evbefh = upperentry + 1; |
| 2113 |
// |
// |
| 2114 |
if ( debug ) printf(" evbefh %i upperentry %u \n",evbefh,upperentry); |
if ( debug ) printf(" evbefh %i upperentry %u \n",evbefh,upperentry); |
| 2115 |
// |
// |
| 2116 |
this->HandleRunFragments(false,true,evbefh,upperentry); |
this->HandleRunFragments(false,true,evbefh,upperentry); |
| 2117 |
// |
// |
| 2414 |
// |
// |
| 2415 |
if ( IsDebug() ) printf(" The new run has more events than the old one \n"); |
if ( IsDebug() ) printf(" The new run has more events than the old one \n"); |
| 2416 |
glrun->DeleteRun(conn,(UInt_t)atoll(row->GetField(0)),"GL_RUN"); |
glrun->DeleteRun(conn,(UInt_t)atoll(row->GetField(0)),"GL_RUN"); |
| 2417 |
// oss.str(""); |
// oss.str(""); |
| 2418 |
// oss << "DELETE FROM GL_RUN WHERE ID=" << row->GetField(0) <<";"; |
// oss << "DELETE FROM GL_RUN WHERE ID=" << row->GetField(0) <<";"; |
| 2419 |
// if ( IsDebug() ) printf(" delete the run entry: query is \n %s \n",oss.str().c_str()); |
// if ( IsDebug() ) printf(" delete the run entry: query is \n %s \n",oss.str().c_str()); |
| 2420 |
// conn->Query(oss.str().c_str()); |
// conn->Query(oss.str().c_str()); |
| 2421 |
if ( signal ) signal = false; |
if ( signal ) signal = false; |
| 2422 |
goto gonext; |
goto gonext; |
| 2423 |
// |
// |
| 2432 |
if ( IsDebug() ) printf(" The new run has the same number of events and the runheader the old one miss the runheader \n"); |
if ( IsDebug() ) printf(" The new run has the same number of events and the runheader the old one miss the runheader \n"); |
| 2433 |
// |
// |
| 2434 |
glrun->DeleteRun(conn,(UInt_t)atoll(row->GetField(0)),"GL_RUN"); |
glrun->DeleteRun(conn,(UInt_t)atoll(row->GetField(0)),"GL_RUN"); |
| 2435 |
// oss.str(""); |
// oss.str(""); |
| 2436 |
// oss << "DELETE FROM GL_RUN WHERE ID=" << row->GetField(0) <<";"; |
// oss << "DELETE FROM GL_RUN WHERE ID=" << row->GetField(0) <<";"; |
| 2437 |
// if ( IsDebug() ) printf(" delete the run entry: query is \n %s \n",oss.str().c_str()); |
// if ( IsDebug() ) printf(" delete the run entry: query is \n %s \n",oss.str().c_str()); |
| 2438 |
// conn->Query(oss.str().c_str()); |
// conn->Query(oss.str().c_str()); |
| 2439 |
// |
// |
| 2440 |
if ( signal ) signal = false; |
if ( signal ) signal = false; |
| 2441 |
goto gonext; |
goto gonext; |
| 2450 |
if ( IsDebug() ) printf(" The new run has the same number of events, the runheader and the runtrailer the old one miss the runtrailer \n"); |
if ( IsDebug() ) printf(" The new run has the same number of events, the runheader and the runtrailer the old one miss the runtrailer \n"); |
| 2451 |
// |
// |
| 2452 |
glrun->DeleteRun(conn,(UInt_t)atoll(row->GetField(0)),"GL_RUN"); |
glrun->DeleteRun(conn,(UInt_t)atoll(row->GetField(0)),"GL_RUN"); |
| 2453 |
// oss.str(""); |
// oss.str(""); |
| 2454 |
// oss << "DELETE FROM GL_RUN WHERE ID=" << row->GetField(0) <<";"; |
// oss << "DELETE FROM GL_RUN WHERE ID=" << row->GetField(0) <<";"; |
| 2455 |
// if ( IsDebug() ) printf(" delete the run entry: query is \n %s \n",oss.str().c_str()); |
// if ( IsDebug() ) printf(" delete the run entry: query is \n %s \n",oss.str().c_str()); |
| 2456 |
// conn->Query(oss.str().c_str()); |
// conn->Query(oss.str().c_str()); |
| 2457 |
if ( signal ) signal = false; |
if ( signal ) signal = false; |
| 2458 |
// |
// |
| 2459 |
}; |
}; |
| 2535 |
if ( IsDebug() ) printf("The run is not consistent, it contains non-physics packets! The run has been handled \n"); |
if ( IsDebug() ) printf("The run is not consistent, it contains non-physics packets! The run has been handled \n"); |
| 2536 |
// |
// |
| 2537 |
} else { |
} else { |
|
// |
|
|
// we have now the good first piece of a run, fill the glrun object |
|
|
// |
|
|
if ( rhfirstev != firstev && !mishead ) mishead = true; |
|
|
if ( rtlastev != lastev && !mistrail ) mistrail = true; |
|
|
// |
|
|
this->FillClass(mishead,mistrail,firstev,lastev); |
|
|
// |
|
|
if ( IsDebug() ) printf("The run is good, is it the other piece in the GL_RUN_FRAGMENTS table?\n"); |
|
|
if ( IsDebug() ) printf(" C THIS RUN: RUNHEADER_OBT %u RUNTRAILER_OBT %u RUNHEADER_PKT %u RUNTRAILER_PKT %u \n", glrun->GetRUNHEADER_OBT(),glrun->GetRUNTRAILER_OBT(),glrun->GetRUNHEADER_PKT(),glrun->GetRUNTRAILER_PKT()); |
|
|
// |
|
|
// First of all insert the run in the fragment table... |
|
|
// |
|
|
oss.str(""); |
|
|
oss << " SELECT ID FROM GL_RUN_FRAGMENTS WHERE " |
|
|
<< " BOOT_NUMBER=" << this->GetBOOTnumber() << " AND (" |
|
|
<< " (RUNHEADER_TIME>=" << (UInt_t)(glrun->GetRUNHEADER_TIME()-10) << " AND " |
|
|
<< " RUNTRAILER_TIME<=" << (UInt_t)(glrun->GetRUNTRAILER_TIME()+10) << " AND (" |
|
|
<< " RUNHEADER_OBT>=" << glrun->GetRUNHEADER_OBT() << " OR " |
|
|
<< " RUNHEADER_PKT>=" << glrun->GetRUNHEADER_PKT() << ") AND (" |
|
|
<< " RUNTRAILER_OBT<=" << glrun->GetRUNTRAILER_OBT() << " OR " |
|
|
<< " RUNTRAILER_PKT<=" << glrun->GetRUNTRAILER_PKT() << ") ) OR " |
|
|
<< " (RUNHEADER_TIME<=" << (UInt_t)glrun->GetRUNHEADER_TIME() << " AND " |
|
|
<< " RUNTRAILER_TIME>=" << (UInt_t)glrun->GetRUNTRAILER_TIME() <<" AND (" |
|
|
<< " RUNHEADER_OBT<=" << glrun->GetRUNHEADER_OBT() << " OR " |
|
|
<< " RUNHEADER_PKT<=" << glrun->GetRUNHEADER_PKT() << ") AND (" |
|
|
<< " RUNTRAILER_OBT>=" << glrun->GetRUNTRAILER_OBT() << " OR " |
|
|
<< " RUNTRAILER_PKT>=" << glrun->GetRUNTRAILER_PKT() << ") ));"; |
|
|
// |
|
|
if ( IsDebug() ) printf(" check if run has been inserted: query is \n %s \n",oss.str().c_str()); |
|
|
result = conn->Query(oss.str().c_str()); |
|
|
// |
|
|
if ( !result ) throw -4; |
|
|
// |
|
|
row = result->Next(); |
|
|
// |
|
|
if ( !row ){ |
|
| 2538 |
// |
// |
| 2539 |
// no, insert this run in the GL_RUN_FRAGMENTS table (check if exist before!) |
// we have now the good first piece of a run, fill the glrun object |
| 2540 |
// |
// |
| 2541 |
if ( IsDebug() ) printf(" The run is new \n"); |
if ( rhfirstev != firstev && !mishead ) mishead = true; |
| 2542 |
if ( IsDebug() ) printf(" -> fill the GL_RUNFRAGMENTS table \n"); |
if ( rtlastev != lastev && !mistrail ) mistrail = true; |
| 2543 |
// |
// |
| 2544 |
glrun->SetID(this->AssignRunID()); |
this->FillClass(mishead,mistrail,firstev,lastev); |
|
glrun->SetID_RUN_FRAG(0); |
|
|
glrun->Fill_GL_RUN_FRAGMENTS(conn); |
|
| 2545 |
// |
// |
| 2546 |
} else { |
if ( IsDebug() ) printf("The run is good, is it the other piece in the GL_RUN_FRAGMENTS table?\n"); |
| 2547 |
if ( IsDebug() ) printf(" The run is already present in the fragment table \n"); |
if ( IsDebug() ) printf(" C THIS RUN: RUNHEADER_OBT %u RUNTRAILER_OBT %u RUNHEADER_PKT %u RUNTRAILER_PKT %u \n", glrun->GetRUNHEADER_OBT(),glrun->GetRUNTRAILER_OBT(),glrun->GetRUNHEADER_PKT(),glrun->GetRUNTRAILER_PKT()); |
| 2548 |
if ( PEDANTIC ) throw -69; |
// |
| 2549 |
return; |
// First of all insert the run in the fragment table... |
|
}; |
|
|
// |
|
|
if ( chewbacca && mishead && mistrail ) goto justcheck; |
|
|
// |
|
|
// can we find the other piece of the run in the GL_RUN_FRAGMENTS table? |
|
|
// |
|
|
if ( mishead && ( rhfirstev == firstev || chewbacca ) ) { // look for runheader (only when at the beginning of the file, if at the end and the runh is |
|
|
// missing it no way we can found a piece in the frag table |
|
| 2550 |
// |
// |
| 2551 |
oss.str(""); |
oss.str(""); |
| 2552 |
oss << " SELECT ID,TRK_CALIB_USED,RUNTRAILER_TIME,RUNTRAILER_OBT,RUNHEADER_PKT,RUNTRAILER_PKT FROM GL_RUN_FRAGMENTS WHERE " |
oss << " SELECT ID FROM GL_RUN_FRAGMENTS WHERE " |
| 2553 |
<< " BOOT_NUMBER=" << this->GetBOOTnumber() << " AND " |
<< " BOOT_NUMBER=" << this->GetBOOTnumber() << " AND (" |
| 2554 |
<< " RUNHEADER_TIME <= " << (UInt_t)glrun->GetRUNHEADER_TIME() << " AND " |
<< " (RUNHEADER_TIME>=" << (UInt_t)(glrun->GetRUNHEADER_TIME()-10) << " AND " |
| 2555 |
<< " ID != " << glrun->ID |
<< " RUNTRAILER_TIME<=" << (UInt_t)(glrun->GetRUNTRAILER_TIME()+10) << " AND (" |
| 2556 |
<< " ORDER BY RUNHEADER_TIME DESC LIMIT 1;"; // DESC NOT ASC!! |
<< " RUNHEADER_OBT>=" << glrun->GetRUNHEADER_OBT() << " OR " |
| 2557 |
|
<< " RUNHEADER_PKT>=" << glrun->GetRUNHEADER_PKT() << ") AND (" |
| 2558 |
|
<< " RUNTRAILER_OBT<=" << glrun->GetRUNTRAILER_OBT() << " OR " |
| 2559 |
|
<< " RUNTRAILER_PKT<=" << glrun->GetRUNTRAILER_PKT() << ") ) OR " |
| 2560 |
|
<< " (RUNHEADER_TIME<=" << (UInt_t)glrun->GetRUNHEADER_TIME() << " AND " |
| 2561 |
|
<< " RUNTRAILER_TIME>=" << (UInt_t)glrun->GetRUNTRAILER_TIME() <<" AND (" |
| 2562 |
|
<< " RUNHEADER_OBT<=" << glrun->GetRUNHEADER_OBT() << " OR " |
| 2563 |
|
<< " RUNHEADER_PKT<=" << glrun->GetRUNHEADER_PKT() << ") AND (" |
| 2564 |
|
<< " RUNTRAILER_OBT>=" << glrun->GetRUNTRAILER_OBT() << " OR " |
| 2565 |
|
<< " RUNTRAILER_PKT>=" << glrun->GetRUNTRAILER_PKT() << ") ));"; |
| 2566 |
// |
// |
| 2567 |
if ( IsDebug() ) printf(" look for runheader in the fragments table: query is \n %s \n",oss.str().c_str()); |
if ( IsDebug() ) printf(" check if run has been inserted: query is \n %s \n",oss.str().c_str()); |
| 2568 |
result = conn->Query(oss.str().c_str()); |
result = conn->Query(oss.str().c_str()); |
| 2569 |
// |
// |
| 2570 |
if ( !result ) throw -4; |
if ( !result ) throw -4; |
| 2571 |
// |
// |
| 2572 |
row = result->Next(); |
row = result->Next(); |
| 2573 |
// |
// |
| 2574 |
if ( !row && NoFrag() ){ |
if ( !row ){ |
| 2575 |
|
// |
| 2576 |
|
// no, insert this run in the GL_RUN_FRAGMENTS table (check if exist before!) |
| 2577 |
|
// |
| 2578 |
|
if ( IsDebug() ) printf(" The run is new \n"); |
| 2579 |
|
if ( IsDebug() ) printf(" -> fill the GL_RUNFRAGMENTS table \n"); |
| 2580 |
|
// |
| 2581 |
|
glrun->SetID(this->AssignRunID()); |
| 2582 |
|
glrun->SetID_RUN_FRAG(0); |
| 2583 |
|
glrun->Fill_GL_RUN_FRAGMENTS(conn); |
| 2584 |
|
// |
| 2585 |
|
} else { |
| 2586 |
|
if ( IsDebug() ) printf(" The run is already present in the fragment table \n"); |
| 2587 |
|
if ( PEDANTIC ) throw -69; |
| 2588 |
|
return; |
| 2589 |
|
}; |
| 2590 |
|
// |
| 2591 |
|
if ( chewbacca && mishead && mistrail ) goto justcheck; |
| 2592 |
|
// |
| 2593 |
|
// can we find the other piece of the run in the GL_RUN_FRAGMENTS table? |
| 2594 |
|
// |
| 2595 |
|
if ( mishead && ( rhfirstev == firstev || chewbacca ) ) { // look for runheader (only when at the beginning of the file, if at the end and the runh is |
| 2596 |
|
// missing it no way we can found a piece in the frag table |
| 2597 |
// |
// |
| 2598 |
oss.str(""); |
oss.str(""); |
| 2599 |
oss << " SELECT ID,TRK_CALIB_USED,RUNTRAILER_TIME,RUNTRAILER_OBT,RUNHEADER_PKT,RUNTRAILER_PKT FROM GL_RUN WHERE " |
oss << " SELECT ID,TRK_CALIB_USED,RUNTRAILER_TIME,RUNTRAILER_OBT,RUNHEADER_PKT,RUNTRAILER_PKT FROM GL_RUN_FRAGMENTS WHERE " |
| 2600 |
<< " BOOT_NUMBER=" << this->GetBOOTnumber() << " AND " |
<< " BOOT_NUMBER=" << this->GetBOOTnumber() << " AND " |
| 2601 |
<< " RUNHEADER_TIME <= " << (UInt_t)glrun->GetRUNHEADER_TIME() << " AND " |
<< " RUNHEADER_TIME <= " << (UInt_t)glrun->GetRUNHEADER_TIME() << " AND " |
| 2602 |
<< " ID != " << glrun->ID |
<< " ID != " << glrun->ID |
| 2603 |
<< " AND ID=ID_RUN_FRAG ORDER BY RUNHEADER_TIME DESC LIMIT 1;"; // DESC NOT ASC!! |
<< " ORDER BY RUNHEADER_TIME DESC LIMIT 1;"; // DESC NOT ASC!! |
| 2604 |
// |
// |
| 2605 |
if ( IsDebug() ) printf(" look for runheader in the GL_RUN table: query is \n %s \n",oss.str().c_str()); |
if ( IsDebug() ) printf(" look for runheader in the fragments table: query is \n %s \n",oss.str().c_str()); |
| 2606 |
result = conn->Query(oss.str().c_str()); |
result = conn->Query(oss.str().c_str()); |
| 2607 |
// |
// |
| 2608 |
if ( !result ) throw -4; |
if ( !result ) throw -4; |
| 2609 |
// |
// |
|
foundinrun = true; |
|
|
// |
|
| 2610 |
row = result->Next(); |
row = result->Next(); |
| 2611 |
// |
// |
| 2612 |
}; |
if ( !row && NoFrag() ){ |
| 2613 |
// |
// |
| 2614 |
if ( !row ){ |
oss.str(""); |
| 2615 |
if ( IsDebug() ) printf(" the corresponding piece has NOT been found \n"); |
oss << " SELECT ID,TRK_CALIB_USED,RUNTRAILER_TIME,RUNTRAILER_OBT,RUNHEADER_PKT,RUNTRAILER_PKT FROM GL_RUN WHERE " |
| 2616 |
found = false; |
<< " BOOT_NUMBER=" << this->GetBOOTnumber() << " AND " |
| 2617 |
} else { |
<< " RUNHEADER_TIME <= " << (UInt_t)glrun->GetRUNHEADER_TIME() << " AND " |
| 2618 |
// |
<< " ID != " << glrun->ID |
| 2619 |
found = false; // default value |
<< " AND ID=ID_RUN_FRAG ORDER BY RUNHEADER_TIME DESC LIMIT 1;"; // DESC NOT ASC!! |
| 2620 |
// |
// |
| 2621 |
if ( IsDebug() ) printf(" Found a possible candidate, checking if it is the good one... \n"); |
if ( IsDebug() ) printf(" look for runheader in the GL_RUN table: query is \n %s \n",oss.str().c_str()); |
| 2622 |
// |
result = conn->Query(oss.str().c_str()); |
| 2623 |
// if we have both runheader and runtrailer we can check with pkt_counter: |
// |
| 2624 |
|
if ( !result ) throw -4; |
| 2625 |
|
// |
| 2626 |
|
foundinrun = true; |
| 2627 |
|
// |
| 2628 |
|
row = result->Next(); |
| 2629 |
|
// |
| 2630 |
|
}; |
| 2631 |
// |
// |
| 2632 |
if ( !mistrail && (UInt_t)atoll(row->GetField(1)) != 0 ){ |
if ( !row ){ |
| 2633 |
ULong64_t chkpkt = 0; |
if ( IsDebug() ) printf(" the corresponding piece has NOT been found \n"); |
| 2634 |
ULong64_t pktt = (ULong64_t)PKT(glrun->GetRUNTRAILER_PKT()); |
found = false; |
| 2635 |
ULong64_t pkth = (ULong64_t)PKT((UInt_t)atoll(row->GetField(4))); |
} else { |
| 2636 |
// |
// |
| 2637 |
chkpkt = pkth + (ULong64_t)glrun->GetPKT_COUNTER() + 1ULL + 1ULL; |
found = false; // default value |
| 2638 |
// |
// |
| 2639 |
if ( labs(chkpkt-pktt)<2 ){ |
if ( IsDebug() ) printf(" Found a possible candidate, checking if it is the good one... \n"); |
| 2640 |
|
// |
| 2641 |
|
// if we have both runheader and runtrailer we can check with pkt_counter: |
| 2642 |
|
// |
| 2643 |
|
if ( !mistrail && (UInt_t)atoll(row->GetField(1)) != 0 ){ |
| 2644 |
|
ULong64_t chkpkt = 0; |
| 2645 |
|
ULong64_t pktt = (ULong64_t)PKT(glrun->GetRUNTRAILER_PKT()); |
| 2646 |
|
ULong64_t pkth = (ULong64_t)PKT((UInt_t)atoll(row->GetField(4))); |
| 2647 |
// |
// |
| 2648 |
if ( IsDebug() ) printf(" FOUND!!! check %llu pktt %llu \n",chkpkt,pktt); |
chkpkt = pkth + (ULong64_t)glrun->GetPKT_COUNTER() + 1ULL + 1ULL; |
| 2649 |
// |
// |
| 2650 |
found = true; |
if ( labs(chkpkt-pktt)<2 ){ |
| 2651 |
|
// |
| 2652 |
|
if ( IsDebug() ) printf(" FOUND!!! check %llu pktt %llu \n",chkpkt,pktt); |
| 2653 |
|
// |
| 2654 |
|
found = true; |
| 2655 |
|
// |
| 2656 |
|
} else { |
| 2657 |
|
// |
| 2658 |
|
if ( IsDebug() ) printf(" The check with pkt counter failed: check %llu pktt %llu \n",chkpkt,pktt); |
| 2659 |
|
// |
| 2660 |
|
found = false; |
| 2661 |
|
// |
| 2662 |
|
}; |
| 2663 |
|
}; |
| 2664 |
|
if ( !found && chewbacca ) goto justcheck; |
| 2665 |
|
if ( !found ){ |
| 2666 |
// |
// |
| 2667 |
} else { |
// if we arrive here we were not able to decide if the two pieces matches using only the pkt counter information, we must check times and obts |
| 2668 |
// |
// |
| 2669 |
if ( IsDebug() ) printf(" The check with pkt counter failed: check %llu pktt %llu \n",chkpkt,pktt); |
ULong64_t chkpkt1 = 0; |
| 2670 |
|
ULong64_t orunh1 = (ULong64_t)PKT(glrun->GetRUNHEADER_PKT()); |
| 2671 |
|
ULong64_t dbrunt1 = (ULong64_t)PKT((UInt_t)atoll(row->GetField(5))); |
| 2672 |
|
chkpkt1 = labs(orunh1-dbrunt1); |
| 2673 |
// |
// |
| 2674 |
found = false; |
ULong64_t chkpkt2 = 0; |
| 2675 |
|
ULong64_t orunh2 = (ULong64_t)OBT(glrun->GetRUNHEADER_OBT()); |
| 2676 |
|
ULong64_t dbrunt2 = (ULong64_t)OBT((UInt_t)atoll(row->GetField(3))); |
| 2677 |
|
chkpkt2 = labs(orunh2-dbrunt2); |
| 2678 |
|
// |
| 2679 |
|
ULong64_t chkpkt3 = 0; |
| 2680 |
|
ULong64_t orunh3 = (ULong64_t)(glrun->GetRUNHEADER_TIME()); |
| 2681 |
|
ULong64_t dbrunt3 = (ULong64_t)((UInt_t)atoll(row->GetField(2))); |
| 2682 |
|
chkpkt3 = labs(orunh3-dbrunt3); |
| 2683 |
// |
// |
| 2684 |
|
if ( (chkpkt1 < 200 || chkpkt2 < 20000) && chkpkt3 < 20 ){ |
| 2685 |
|
// if ( chkpkt1 < 100 && chkpkt2 < 30000 && chkpkt3 < 30 ){ |
| 2686 |
|
// |
| 2687 |
|
if ( IsDebug() ) printf(" FOUND!!! check1 %llu<200 cechk2 %llu<20000 check3 %llu<20 \n",chkpkt1,chkpkt2,chkpkt3); |
| 2688 |
|
// |
| 2689 |
|
found = true; |
| 2690 |
|
// |
| 2691 |
|
} else { |
| 2692 |
|
// |
| 2693 |
|
if ( IsDebug() ) printf(" Check failed: check1 %llu<200? cechk2 %llu<20000? check3 %llu<20? \n",chkpkt1,chkpkt2,chkpkt3); |
| 2694 |
|
// |
| 2695 |
|
found = false; |
| 2696 |
|
// |
| 2697 |
|
}; |
| 2698 |
}; |
}; |
| 2699 |
}; |
}; |
| 2700 |
if ( !found && chewbacca ) goto justcheck; |
// |
| 2701 |
if ( !found ){ |
if ( found ){ |
| 2702 |
|
// |
| 2703 |
|
// we have found the missing piece, glue the two together, merge the informations, fill the gl_run table (check first runs do not exists), delete entry in frag table |
| 2704 |
|
// |
| 2705 |
|
if ( IsDebug() ) printf(" now you can handle the piece of the run \n "); |
| 2706 |
|
// |
| 2707 |
|
if ( foundinrun ){ |
| 2708 |
|
glrun->RestoreRun(conn,(UInt_t)atoll(row->GetField(0)),"GL_RUN_FRAGMENTS"); |
| 2709 |
|
glrun->DeleteRun(conn,(UInt_t)atoll(row->GetField(0)),"GL_RUN"); |
| 2710 |
|
}; |
| 2711 |
// |
// |
| 2712 |
// if we arrive here we were not able to decide if the two pieces matches using only the pkt counter information, we must check times and obts |
GL_RUN *glrun1 = new GL_RUN(); |
| 2713 |
// |
// |
| 2714 |
ULong64_t chkpkt1 = 0; |
// UInt_t idfrag = (UInt_t)atoll(row->GetField(0)); |
|
ULong64_t orunh1 = (ULong64_t)PKT(glrun->GetRUNHEADER_PKT()); |
|
|
ULong64_t dbrunt1 = (ULong64_t)PKT((UInt_t)atoll(row->GetField(5))); |
|
|
chkpkt1 = labs(orunh1-dbrunt1); |
|
|
// |
|
|
ULong64_t chkpkt2 = 0; |
|
|
ULong64_t orunh2 = (ULong64_t)OBT(glrun->GetRUNHEADER_OBT()); |
|
|
ULong64_t dbrunt2 = (ULong64_t)OBT((UInt_t)atoll(row->GetField(3))); |
|
|
chkpkt2 = labs(orunh2-dbrunt2); |
|
|
// |
|
|
ULong64_t chkpkt3 = 0; |
|
|
ULong64_t orunh3 = (ULong64_t)(glrun->GetRUNHEADER_TIME()); |
|
|
ULong64_t dbrunt3 = (ULong64_t)((UInt_t)atoll(row->GetField(2))); |
|
|
chkpkt3 = labs(orunh3-dbrunt3); |
|
| 2715 |
// |
// |
| 2716 |
if ( (chkpkt1 < 200 || chkpkt2 < 20000) && chkpkt3 < 20 ){ |
oss.str(""); |
| 2717 |
// if ( chkpkt1 < 100 && chkpkt2 < 30000 && chkpkt3 < 30 ){ |
oss << " ID="<<row->GetField(0)<<";"; |
| 2718 |
// |
// |
| 2719 |
if ( IsDebug() ) printf(" FOUND!!! check1 %llu<200 cechk2 %llu<20000 check3 %llu<20 \n",chkpkt1,chkpkt2,chkpkt3); |
glrun1->Query_GL_RUN_FRAGMENTS(oss.str().c_str(),conn); // here we have runheader infos |
| 2720 |
// |
// |
| 2721 |
found = true; |
// merge infos |
| 2722 |
// |
// |
| 2723 |
} else { |
UInt_t apkt = PKT(glrun1->GetRUNTRAILER_PKT()); |
| 2724 |
|
ULong64_t aobt = OBT(glrun1->GetRUNTRAILER_OBT()); |
| 2725 |
|
UInt_t bpkt = PKT(glrun->GetRUNHEADER_PKT()); |
| 2726 |
|
ULong64_t bobt = OBT(glrun->GetRUNHEADER_OBT()); |
| 2727 |
|
if ( IsDebug() ) printf(" Check overlapping events: %u %u %llu %llu firstev is %i\n",apkt,bpkt,aobt,bobt,firstev); |
| 2728 |
|
TTree *T= 0; |
| 2729 |
|
T = (TTree*)file->Get("Physics"); |
| 2730 |
|
if ( !T || T->IsZombie() ) throw -16; |
| 2731 |
|
EventHeader *eh = 0; |
| 2732 |
|
PscuHeader *ph = 0; |
| 2733 |
|
T->SetBranchAddress("Header", &eh); |
| 2734 |
|
while ( apkt > bpkt && aobt > bobt && firstev < lastev ){ |
| 2735 |
|
T->GetEntry(firstev); |
| 2736 |
|
ph = eh->GetPscuHeader(); |
| 2737 |
|
bpkt = PKT(ph->GetCounter()); |
| 2738 |
|
bobt = OBT(ph->GetOrbitalTime()); |
| 2739 |
|
firstev++; |
| 2740 |
|
if ( PEDANTIC ) throw -71; |
| 2741 |
|
}; |
| 2742 |
|
if ( IsDebug() ) printf(" Check overlapping events done: %u %u %llu %llu firstev is %i\n",apkt,bpkt,aobt,bobt,firstev); |
| 2743 |
|
// |
| 2744 |
|
glrun1->SetPKT_COUNTER(glrun->GetPKT_COUNTER()); |
| 2745 |
|
glrun1->SetPKT_READY_COUNTER(glrun->GetPKT_READY_COUNTER()); |
| 2746 |
|
glrun1->SetRUNTRAILER_TIME(glrun->GetRUNTRAILER_TIME()); |
| 2747 |
|
glrun1->SetRUNTRAILER_OBT(glrun->GetRUNTRAILER_OBT()); |
| 2748 |
|
glrun1->SetRUNTRAILER_PKT(glrun->GetRUNTRAILER_PKT()); |
| 2749 |
|
// |
| 2750 |
|
glrun->SetEV_FROM(firstev); |
| 2751 |
|
glrun->SetNEVENTS(lastev-firstev+1); |
| 2752 |
|
// |
| 2753 |
|
glrun->SetRUNHEADER_TIME(glrun1->GetRUNHEADER_TIME()); |
| 2754 |
|
glrun->SetRUNHEADER_OBT(glrun1->GetRUNHEADER_OBT()); |
| 2755 |
|
glrun->SetRUNHEADER_PKT(glrun1->GetRUNHEADER_PKT()); |
| 2756 |
|
glrun->SetCOMPILATIONTIMESTAMP(glrun1->GetCOMPILATIONTIMESTAMP()); |
| 2757 |
|
glrun->SetFAV_WRK_SCHEDULE(glrun1->GetFAV_WRK_SCHEDULE()); |
| 2758 |
|
glrun->SetEFF_WRK_SCHEDULE(glrun1->GetEFF_WRK_SCHEDULE()); |
| 2759 |
|
glrun->SetPRH_VAR_TRG_MODE_A(glrun1->GetPRH_VAR_TRG_MODE_A()); |
| 2760 |
|
glrun->SetPRH_VAR_TRG_MODE_B(glrun1->GetPRH_VAR_TRG_MODE_B()); |
| 2761 |
|
glrun->SetACQ_BUILD_INFO(glrun1->GetACQ_BUILD_INFO()); |
| 2762 |
|
glrun->SetACQ_VAR_INFO(glrun1->GetACQ_VAR_INFO()); |
| 2763 |
|
glrun->SetRM_ACQ_AFTER_CALIB(glrun1->GetRM_ACQ_AFTER_CALIB()); |
| 2764 |
|
glrun->SetRM_ACQ_SETTING_MODE(glrun1->GetRM_ACQ_SETTING_MODE()); |
| 2765 |
|
glrun->SetTRK_CALIB_USED(glrun1->GetTRK_CALIB_USED()); |
| 2766 |
|
glrun->SetCAL_DSP_MASK(glrun1->GetCAL_DSP_MASK()); |
| 2767 |
|
glrun->SetLAST_TIMESYNC(glrun1->GetLAST_TIMESYNC()); |
| 2768 |
|
glrun->SetOBT_TIMESYNC(glrun1->GetOBT_TIMESYNC()); |
| 2769 |
|
// |
| 2770 |
|
if ( glrun1->GetPHYSENDRUN_MASK_S3S2S12() ) glrun->SetPHYSENDRUN_MASK_S3S2S12(glrun1->GetPHYSENDRUN_MASK_S3S2S12()); |
| 2771 |
|
if ( glrun1->GetPHYSENDRUN_MASK_S11CRC() ) glrun->SetPHYSENDRUN_MASK_S11CRC(glrun1->GetPHYSENDRUN_MASK_S11CRC()); |
| 2772 |
|
// |
| 2773 |
|
if ( !IsRunAlreadyInserted() ){ |
| 2774 |
|
// |
| 2775 |
|
// glrun->SetID(this->AssignRunID()); |
| 2776 |
|
glrun->SetID_RUN_FRAG(glrun1->GetID()); |
| 2777 |
|
glrun->Fill_GL_RUN(conn); |
| 2778 |
// |
// |
| 2779 |
if ( IsDebug() ) printf(" Check failed: check1 %llu<200? cechk2 %llu<20000? check3 %llu<20? \n",chkpkt1,chkpkt2,chkpkt3); |
// set id number |
| 2780 |
// |
// |
| 2781 |
found = false; |
glrun1->SetID_RUN_FRAG(glrun->GetID()); |
| 2782 |
|
glrun1->Fill_GL_RUN(conn); |
| 2783 |
// |
// |
| 2784 |
}; |
}; |
| 2785 |
}; |
// delete old entry in fragment table |
|
}; |
|
|
// |
|
|
if ( found ){ |
|
|
// |
|
|
// we have found the missing piece, glue the two together, merge the informations, fill the gl_run table (check first runs do not exists), delete entry in frag table |
|
|
// |
|
|
if ( IsDebug() ) printf(" now you can handle the piece of the run \n "); |
|
|
// |
|
|
if ( foundinrun ){ |
|
|
glrun->RestoreRun(conn,(UInt_t)atoll(row->GetField(0)),"GL_RUN_FRAGMENTS"); |
|
|
glrun->DeleteRun(conn,(UInt_t)atoll(row->GetField(0)),"GL_RUN"); |
|
|
}; |
|
|
// |
|
|
GL_RUN *glrun1 = new GL_RUN(); |
|
|
// |
|
|
// UInt_t idfrag = (UInt_t)atoll(row->GetField(0)); |
|
|
// |
|
|
oss.str(""); |
|
|
oss << " ID="<<row->GetField(0)<<";"; |
|
|
// |
|
|
glrun1->Query_GL_RUN_FRAGMENTS(oss.str().c_str(),conn); // here we have runheader infos |
|
|
// |
|
|
// merge infos |
|
|
// |
|
|
UInt_t apkt = PKT(glrun1->GetRUNTRAILER_PKT()); |
|
|
ULong64_t aobt = OBT(glrun1->GetRUNTRAILER_OBT()); |
|
|
UInt_t bpkt = PKT(glrun->GetRUNHEADER_PKT()); |
|
|
ULong64_t bobt = OBT(glrun->GetRUNHEADER_OBT()); |
|
|
if ( IsDebug() ) printf(" Check overlapping events: %u %u %llu %llu firstev is %i\n",apkt,bpkt,aobt,bobt,firstev); |
|
|
TTree *T= 0; |
|
|
T = (TTree*)file->Get("Physics"); |
|
|
if ( !T || T->IsZombie() ) throw -16; |
|
|
EventHeader *eh = 0; |
|
|
PscuHeader *ph = 0; |
|
|
T->SetBranchAddress("Header", &eh); |
|
|
while ( apkt > bpkt && aobt > bobt && firstev < lastev ){ |
|
|
T->GetEntry(firstev); |
|
|
ph = eh->GetPscuHeader(); |
|
|
bpkt = PKT(ph->GetCounter()); |
|
|
bobt = OBT(ph->GetOrbitalTime()); |
|
|
firstev++; |
|
|
if ( PEDANTIC ) throw -71; |
|
|
}; |
|
|
if ( IsDebug() ) printf(" Check overlapping events done: %u %u %llu %llu firstev is %i\n",apkt,bpkt,aobt,bobt,firstev); |
|
|
// |
|
|
glrun1->SetPKT_COUNTER(glrun->GetPKT_COUNTER()); |
|
|
glrun1->SetPKT_READY_COUNTER(glrun->GetPKT_READY_COUNTER()); |
|
|
glrun1->SetRUNTRAILER_TIME(glrun->GetRUNTRAILER_TIME()); |
|
|
glrun1->SetRUNTRAILER_OBT(glrun->GetRUNTRAILER_OBT()); |
|
|
glrun1->SetRUNTRAILER_PKT(glrun->GetRUNTRAILER_PKT()); |
|
|
// |
|
|
glrun->SetEV_FROM(firstev); |
|
|
glrun->SetNEVENTS(lastev-firstev+1); |
|
|
// |
|
|
glrun->SetRUNHEADER_TIME(glrun1->GetRUNHEADER_TIME()); |
|
|
glrun->SetRUNHEADER_OBT(glrun1->GetRUNHEADER_OBT()); |
|
|
glrun->SetRUNHEADER_PKT(glrun1->GetRUNHEADER_PKT()); |
|
|
glrun->SetCOMPILATIONTIMESTAMP(glrun1->GetCOMPILATIONTIMESTAMP()); |
|
|
glrun->SetFAV_WRK_SCHEDULE(glrun1->GetFAV_WRK_SCHEDULE()); |
|
|
glrun->SetEFF_WRK_SCHEDULE(glrun1->GetEFF_WRK_SCHEDULE()); |
|
|
glrun->SetPRH_VAR_TRG_MODE_A(glrun1->GetPRH_VAR_TRG_MODE_A()); |
|
|
glrun->SetPRH_VAR_TRG_MODE_B(glrun1->GetPRH_VAR_TRG_MODE_B()); |
|
|
glrun->SetACQ_BUILD_INFO(glrun1->GetACQ_BUILD_INFO()); |
|
|
glrun->SetACQ_VAR_INFO(glrun1->GetACQ_VAR_INFO()); |
|
|
glrun->SetRM_ACQ_AFTER_CALIB(glrun1->GetRM_ACQ_AFTER_CALIB()); |
|
|
glrun->SetRM_ACQ_SETTING_MODE(glrun1->GetRM_ACQ_SETTING_MODE()); |
|
|
glrun->SetTRK_CALIB_USED(glrun1->GetTRK_CALIB_USED()); |
|
|
glrun->SetCAL_DSP_MASK(glrun1->GetCAL_DSP_MASK()); |
|
|
glrun->SetLAST_TIMESYNC(glrun1->GetLAST_TIMESYNC()); |
|
|
glrun->SetOBT_TIMESYNC(glrun1->GetOBT_TIMESYNC()); |
|
|
// |
|
|
if ( !IsRunAlreadyInserted() ){ |
|
| 2786 |
// |
// |
| 2787 |
// glrun->SetID(this->AssignRunID()); |
glrun->DeleteRun(conn,0,"GL_RUN_FRAGMENTS"); |
| 2788 |
glrun->SetID_RUN_FRAG(glrun1->GetID()); |
glrun1->DeleteRun(conn,0,"GL_RUN_FRAGMENTS"); |
| 2789 |
glrun->Fill_GL_RUN(conn); |
// |
| 2790 |
|
delete glrun1; |
| 2791 |
// |
// |
|
// set id number |
|
| 2792 |
// |
// |
| 2793 |
glrun1->SetID_RUN_FRAG(glrun->GetID()); |
return; |
|
glrun1->Fill_GL_RUN(conn); |
|
| 2794 |
// |
// |
| 2795 |
}; |
}; |
|
// delete old entry in fragment table |
|
|
// |
|
|
glrun->DeleteRun(conn,0,"GL_RUN_FRAGMENTS"); |
|
|
glrun1->DeleteRun(conn,0,"GL_RUN_FRAGMENTS"); |
|
|
// |
|
|
delete glrun1; |
|
|
// |
|
|
// |
|
|
return; |
|
| 2796 |
// |
// |
| 2797 |
}; |
}; |
| 2798 |
// |
// |
| 2799 |
}; |
if ( mistrail && ( rtlastev == lastev || chewbacca )) { // look for runtrailer (only when at the end of the file, if at the beginning and the runh is |
| 2800 |
// |
// missing it no way we can found a piece in the frag table |
|
if ( mistrail && ( rtlastev == lastev || chewbacca )) { // look for runtrailer (only when at the end of the file, if at the beginning and the runh is |
|
|
// missing it no way we can found a piece in the frag table |
|
|
// |
|
|
oss.str(""); |
|
|
oss << " SELECT ID,PKT_COUNTER,RUNHEADER_TIME,RUNHEADER_OBT,RUNTRAILER_PKT,RUNHEADER_PKT FROM GL_RUN_FRAGMENTS WHERE " |
|
|
<< " BOOT_NUMBER=" << this->GetBOOTnumber() << " AND " |
|
|
<< " RUNTRAILER_TIME >= " << (UInt_t)glrun->GetRUNTRAILER_TIME() << " AND " |
|
|
<< " ID != " << glrun->ID |
|
|
<< " ORDER BY RUNTRAILER_TIME ASC LIMIT 1;"; |
|
|
// |
|
|
if ( IsDebug() ) printf(" look for runtrailer in the fragments table: query is \n %s \n",oss.str().c_str()); |
|
|
result = conn->Query(oss.str().c_str()); |
|
|
// |
|
|
if ( !result ) throw -4; |
|
|
// |
|
|
row = result->Next(); |
|
|
// |
|
|
if ( !row && NoFrag() ){ |
|
| 2801 |
// |
// |
| 2802 |
oss.str(""); |
oss.str(""); |
| 2803 |
oss << " SELECT ID,PKT_COUNTER,RUNHEADER_TIME,RUNHEADER_OBT,RUNTRAILER_PKT,RUNHEADER_PKT FROM GL_RUN WHERE " |
oss << " SELECT ID,PKT_COUNTER,RUNHEADER_TIME,RUNHEADER_OBT,RUNTRAILER_PKT,RUNHEADER_PKT FROM GL_RUN_FRAGMENTS WHERE " |
| 2804 |
<< " BOOT_NUMBER=" << this->GetBOOTnumber() << " AND " |
<< " BOOT_NUMBER=" << this->GetBOOTnumber() << " AND " |
| 2805 |
<< " RUNTRAILER_TIME >= " << (UInt_t)glrun->GetRUNTRAILER_TIME() << " AND " |
<< " RUNTRAILER_TIME >= " << (UInt_t)glrun->GetRUNTRAILER_TIME() << " AND " |
| 2806 |
<< " ID != " << glrun->ID |
<< " ID != " << glrun->ID |
| 2807 |
<< " AND ID=ID_RUN_FRAG ORDER BY RUNTRAILER_TIME ASC LIMIT 1;"; |
<< " ORDER BY RUNTRAILER_TIME ASC LIMIT 1;"; |
| 2808 |
// |
// |
| 2809 |
if ( IsDebug() ) printf(" look for runheader in the GL_RUN table: query is \n %s \n",oss.str().c_str()); |
if ( IsDebug() ) printf(" look for runtrailer in the fragments table: query is \n %s \n",oss.str().c_str()); |
| 2810 |
result = conn->Query(oss.str().c_str()); |
result = conn->Query(oss.str().c_str()); |
| 2811 |
// |
// |
| 2812 |
if ( !result ) throw -4; |
if ( !result ) throw -4; |
| 2813 |
// |
// |
|
foundinrun = true; |
|
| 2814 |
row = result->Next(); |
row = result->Next(); |
| 2815 |
// |
// |
| 2816 |
}; |
if ( !row && NoFrag() ){ |
| 2817 |
// |
// |
| 2818 |
if ( !row ){ |
oss.str(""); |
| 2819 |
if ( IsDebug() ) printf(" the corresponding piece has NOT been found \n"); |
oss << " SELECT ID,PKT_COUNTER,RUNHEADER_TIME,RUNHEADER_OBT,RUNTRAILER_PKT,RUNHEADER_PKT FROM GL_RUN WHERE " |
| 2820 |
found = false; |
<< " BOOT_NUMBER=" << this->GetBOOTnumber() << " AND " |
| 2821 |
} else { |
<< " RUNTRAILER_TIME >= " << (UInt_t)glrun->GetRUNTRAILER_TIME() << " AND " |
| 2822 |
// |
<< " ID != " << glrun->ID |
| 2823 |
found = false; // default value |
<< " AND ID=ID_RUN_FRAG ORDER BY RUNTRAILER_TIME ASC LIMIT 1;"; |
| 2824 |
// |
// |
| 2825 |
if ( IsDebug() ) printf(" Found a possible candidate, checking if it is the good one... \n"); |
if ( IsDebug() ) printf(" look for runheader in the GL_RUN table: query is \n %s \n",oss.str().c_str()); |
| 2826 |
// |
result = conn->Query(oss.str().c_str()); |
| 2827 |
// if we have both runheader and runtrailer we can check with pkt_counter: |
// |
| 2828 |
|
if ( !result ) throw -4; |
| 2829 |
|
// |
| 2830 |
|
foundinrun = true; |
| 2831 |
|
row = result->Next(); |
| 2832 |
|
// |
| 2833 |
|
}; |
| 2834 |
// |
// |
| 2835 |
if ( !mishead && (UInt_t)atoll(row->GetField(1)) != 0 ){ |
if ( !row ){ |
| 2836 |
ULong64_t chkpkt = 0; |
if ( IsDebug() ) printf(" the corresponding piece has NOT been found \n"); |
| 2837 |
ULong64_t pktt = (ULong64_t)PKT((UInt_t)atoll(row->GetField(4))); |
found = false; |
| 2838 |
ULong64_t pkth = (ULong64_t)PKT(glrun->GetRUNHEADER_PKT()); |
} else { |
| 2839 |
|
// |
| 2840 |
|
found = false; // default value |
| 2841 |
// |
// |
| 2842 |
chkpkt = pkth + (ULong64_t)((UInt_t)atoll(row->GetField(1))) + 1ULL + 1ULL; |
if ( IsDebug() ) printf(" Found a possible candidate, checking if it is the good one... \n"); |
| 2843 |
// |
// |
| 2844 |
if ( labs(chkpkt-pktt)<2 ){ |
// if we have both runheader and runtrailer we can check with pkt_counter: |
| 2845 |
|
// |
| 2846 |
|
if ( !mishead && (UInt_t)atoll(row->GetField(1)) != 0 ){ |
| 2847 |
|
ULong64_t chkpkt = 0; |
| 2848 |
|
ULong64_t pktt = (ULong64_t)PKT((UInt_t)atoll(row->GetField(4))); |
| 2849 |
|
ULong64_t pkth = (ULong64_t)PKT(glrun->GetRUNHEADER_PKT()); |
| 2850 |
// |
// |
| 2851 |
if ( IsDebug() ) printf(" FOUND!!! check %llu pktt %llu \n",chkpkt,pktt); |
chkpkt = pkth + (ULong64_t)((UInt_t)atoll(row->GetField(1))) + 1ULL + 1ULL; |
| 2852 |
// |
// |
| 2853 |
found = true; |
if ( labs(chkpkt-pktt)<2 ){ |
| 2854 |
|
// |
| 2855 |
|
if ( IsDebug() ) printf(" FOUND!!! check %llu pktt %llu \n",chkpkt,pktt); |
| 2856 |
|
// |
| 2857 |
|
found = true; |
| 2858 |
|
// |
| 2859 |
|
} else { |
| 2860 |
|
// |
| 2861 |
|
if ( IsDebug() ) printf(" The check with pkt counter failed: check %llu pktt %llu \n",chkpkt,pktt); |
| 2862 |
|
// |
| 2863 |
|
found = false; |
| 2864 |
|
// |
| 2865 |
|
}; |
| 2866 |
|
}; |
| 2867 |
|
if ( !found && chewbacca ) goto justcheck; |
| 2868 |
|
if ( !found ){ |
| 2869 |
// |
// |
| 2870 |
} else { |
// if we arrive here we were not able to decide if the two pieces matches using only the pkt counter information, we must check times and obts |
| 2871 |
// |
// |
| 2872 |
if ( IsDebug() ) printf(" The check with pkt counter failed: check %llu pktt %llu \n",chkpkt,pktt); |
ULong64_t chkpkt1 = 0; |
| 2873 |
|
ULong64_t orunh1 = (ULong64_t)PKT(glrun->GetRUNTRAILER_PKT()); |
| 2874 |
|
ULong64_t dbrunt1 = (ULong64_t)PKT((UInt_t)atoll(row->GetField(5))); |
| 2875 |
|
chkpkt1 = labs(orunh1-dbrunt1); |
| 2876 |
// |
// |
| 2877 |
found = false; |
ULong64_t chkpkt2 = 0; |
| 2878 |
|
ULong64_t orunh2 = (ULong64_t)OBT(glrun->GetRUNTRAILER_OBT()); |
| 2879 |
|
ULong64_t dbrunt2 = (ULong64_t)OBT((UInt_t)atoll(row->GetField(3))); |
| 2880 |
|
chkpkt2 = labs(orunh2-dbrunt2); |
| 2881 |
|
// |
| 2882 |
|
ULong64_t chkpkt3 = 0; |
| 2883 |
|
ULong64_t orunh3 = (ULong64_t)(glrun->GetRUNTRAILER_TIME()); |
| 2884 |
|
ULong64_t dbrunt3 = (ULong64_t)((UInt_t)atoll(row->GetField(2))); |
| 2885 |
|
chkpkt3 = labs(orunh3-dbrunt3); |
| 2886 |
// |
// |
| 2887 |
|
if ( (chkpkt1 < 200 || chkpkt2 < 20000) && chkpkt3 < 20 ){ |
| 2888 |
|
// |
| 2889 |
|
if ( IsDebug() ) printf(" FOUND!!! check1 %llu<200 cechk2 %llu<20000 check3 %llu<20 \n",chkpkt1,chkpkt2,chkpkt3); |
| 2890 |
|
// |
| 2891 |
|
found = true; |
| 2892 |
|
// |
| 2893 |
|
} else { |
| 2894 |
|
// |
| 2895 |
|
if ( IsDebug() ) printf(" Check failed: check1 %llu<200? cechk2 %llu<20000? check3 %llu<20? \n",chkpkt1,chkpkt2,chkpkt3); |
| 2896 |
|
// |
| 2897 |
|
found = false; |
| 2898 |
|
// |
| 2899 |
|
}; |
| 2900 |
}; |
}; |
| 2901 |
}; |
}; |
| 2902 |
if ( !found && chewbacca ) goto justcheck; |
// |
| 2903 |
if ( !found ){ |
if ( found ){ |
| 2904 |
|
// |
| 2905 |
|
// we have found the missing piece, glue the two together, merge the informations, fill the gl_run table (check first runs do not exists), delete entry in frag table |
| 2906 |
|
// |
| 2907 |
|
if ( IsDebug() ) printf(" now you can handle the piece of the run \n "); |
| 2908 |
|
// |
| 2909 |
|
if ( foundinrun ){ |
| 2910 |
|
glrun->RestoreRun(conn,(UInt_t)atoll(row->GetField(0)),"GL_RUN_FRAGMENTS"); |
| 2911 |
|
glrun->DeleteRun(conn,(UInt_t)atoll(row->GetField(0)),"GL_RUN"); |
| 2912 |
|
}; |
| 2913 |
// |
// |
| 2914 |
// if we arrive here we were not able to decide if the two pieces matches using only the pkt counter information, we must check times and obts |
GL_RUN *glrun1 = new GL_RUN(); |
| 2915 |
// |
// |
| 2916 |
ULong64_t chkpkt1 = 0; |
// UInt_t idfrag = (UInt_t)atoll(row->GetField(0)); |
|
ULong64_t orunh1 = (ULong64_t)PKT(glrun->GetRUNTRAILER_PKT()); |
|
|
ULong64_t dbrunt1 = (ULong64_t)PKT((UInt_t)atoll(row->GetField(5))); |
|
|
chkpkt1 = labs(orunh1-dbrunt1); |
|
| 2917 |
// |
// |
| 2918 |
ULong64_t chkpkt2 = 0; |
oss.str(""); |
| 2919 |
ULong64_t orunh2 = (ULong64_t)OBT(glrun->GetRUNTRAILER_OBT()); |
oss << " ID="<<row->GetField(0)<<";"; |
|
ULong64_t dbrunt2 = (ULong64_t)OBT((UInt_t)atoll(row->GetField(3))); |
|
|
chkpkt2 = labs(orunh2-dbrunt2); |
|
| 2920 |
// |
// |
| 2921 |
ULong64_t chkpkt3 = 0; |
glrun1->Query_GL_RUN_FRAGMENTS(oss.str().c_str(),conn); // here we have runtrailer infos |
|
ULong64_t orunh3 = (ULong64_t)(glrun->GetRUNTRAILER_TIME()); |
|
|
ULong64_t dbrunt3 = (ULong64_t)((UInt_t)atoll(row->GetField(2))); |
|
|
chkpkt3 = labs(orunh3-dbrunt3); |
|
| 2922 |
// |
// |
| 2923 |
if ( (chkpkt1 < 200 || chkpkt2 < 20000) && chkpkt3 < 20 ){ |
// merge infos |
| 2924 |
// |
// |
| 2925 |
if ( IsDebug() ) printf(" FOUND!!! check1 %llu<200 cechk2 %llu<20000 check3 %llu<20 \n",chkpkt1,chkpkt2,chkpkt3); |
UInt_t apkt = PKT(glrun->GetRUNTRAILER_PKT()); |
| 2926 |
|
ULong64_t aobt = OBT(glrun->GetRUNTRAILER_OBT()); |
| 2927 |
|
UInt_t bpkt = PKT(glrun1->GetRUNHEADER_PKT()); |
| 2928 |
|
ULong64_t bobt = OBT(glrun1->GetRUNHEADER_OBT()); |
| 2929 |
|
if ( IsDebug() ) printf(" Check overlapping events: %u %u %llu %llu lastev is %i\n",apkt,bpkt,aobt,bobt,lastev); |
| 2930 |
|
TTree *T= 0; |
| 2931 |
|
T = (TTree*)file->Get("Physics"); |
| 2932 |
|
if ( !T || T->IsZombie() ) throw -16; |
| 2933 |
|
EventHeader *eh = 0; |
| 2934 |
|
PscuHeader *ph = 0; |
| 2935 |
|
T->SetBranchAddress("Header", &eh); |
| 2936 |
|
while ( apkt > bpkt && aobt > bobt && lastev > 0 ){ |
| 2937 |
|
T->GetEntry(lastev); |
| 2938 |
|
ph = eh->GetPscuHeader(); |
| 2939 |
|
apkt = PKT(ph->GetCounter()); |
| 2940 |
|
aobt = OBT(ph->GetOrbitalTime()); |
| 2941 |
|
lastev--; |
| 2942 |
|
if ( PEDANTIC ) throw -72; |
| 2943 |
|
}; |
| 2944 |
|
if ( IsDebug() ) printf(" Check overlapping events done: %u %u %llu %llu lastev is %i\n",apkt,bpkt,aobt,bobt,lastev); |
| 2945 |
|
// |
| 2946 |
|
glrun->SetEV_TO(lastev); |
| 2947 |
|
glrun->SetNEVENTS(lastev-firstev+1); |
| 2948 |
|
glrun->SetPKT_COUNTER(glrun1->GetPKT_COUNTER()); |
| 2949 |
|
glrun->SetPKT_READY_COUNTER(glrun1->GetPKT_READY_COUNTER()); |
| 2950 |
|
glrun->SetRUNTRAILER_TIME(glrun1->GetRUNTRAILER_TIME()); |
| 2951 |
|
glrun->SetRUNTRAILER_OBT(glrun1->GetRUNTRAILER_OBT()); |
| 2952 |
|
glrun->SetRUNTRAILER_PKT(glrun1->GetRUNTRAILER_PKT()); |
| 2953 |
|
// |
| 2954 |
|
glrun1->SetRUNHEADER_TIME(glrun->GetRUNHEADER_TIME()); |
| 2955 |
|
glrun1->SetRUNHEADER_OBT(glrun->GetRUNHEADER_OBT()); |
| 2956 |
|
glrun1->SetRUNHEADER_PKT(glrun->GetRUNHEADER_PKT()); |
| 2957 |
|
glrun1->SetCOMPILATIONTIMESTAMP(glrun->GetCOMPILATIONTIMESTAMP()); |
| 2958 |
|
glrun1->SetFAV_WRK_SCHEDULE(glrun->GetFAV_WRK_SCHEDULE()); |
| 2959 |
|
glrun1->SetEFF_WRK_SCHEDULE(glrun->GetEFF_WRK_SCHEDULE()); |
| 2960 |
|
glrun1->SetPRH_VAR_TRG_MODE_A(glrun->GetPRH_VAR_TRG_MODE_A()); |
| 2961 |
|
glrun1->SetPRH_VAR_TRG_MODE_B(glrun->GetPRH_VAR_TRG_MODE_B()); |
| 2962 |
|
glrun1->SetACQ_BUILD_INFO(glrun->GetACQ_BUILD_INFO()); |
| 2963 |
|
glrun1->SetACQ_VAR_INFO(glrun->GetACQ_VAR_INFO()); |
| 2964 |
|
glrun1->SetRM_ACQ_AFTER_CALIB(glrun->GetRM_ACQ_AFTER_CALIB()); |
| 2965 |
|
glrun1->SetRM_ACQ_SETTING_MODE(glrun->GetRM_ACQ_SETTING_MODE()); |
| 2966 |
|
glrun1->SetTRK_CALIB_USED(glrun->GetTRK_CALIB_USED()); |
| 2967 |
|
glrun1->SetCAL_DSP_MASK(glrun->GetCAL_DSP_MASK()); |
| 2968 |
|
glrun1->SetLAST_TIMESYNC(glrun->GetLAST_TIMESYNC()); |
| 2969 |
|
glrun1->SetOBT_TIMESYNC(glrun->GetOBT_TIMESYNC()); |
| 2970 |
|
// |
| 2971 |
|
if ( glrun->GetPHYSENDRUN_MASK_S3S2S12() ) glrun1->SetPHYSENDRUN_MASK_S3S2S12(glrun->GetPHYSENDRUN_MASK_S3S2S12()); |
| 2972 |
|
if ( glrun->GetPHYSENDRUN_MASK_S11CRC() ) glrun1->SetPHYSENDRUN_MASK_S11CRC(glrun->GetPHYSENDRUN_MASK_S11CRC()); |
| 2973 |
|
// |
| 2974 |
|
if ( !IsRunAlreadyInserted() ){ |
| 2975 |
|
// |
| 2976 |
|
// glrun->SetID(this->AssignRunID()); |
| 2977 |
// |
// |
| 2978 |
found = true; |
glrun->SetID_RUN_FRAG(glrun1->GetID()); |
| 2979 |
|
glrun->Fill_GL_RUN(conn); |
| 2980 |
// |
// |
| 2981 |
} else { |
// set id number |
| 2982 |
// |
// |
| 2983 |
if ( IsDebug() ) printf(" Check failed: check1 %llu<200? cechk2 %llu<20000? check3 %llu<20? \n",chkpkt1,chkpkt2,chkpkt3); |
glrun1->SetID_RUN_FRAG(glrun->GetID()); |
| 2984 |
// |
glrun1->Fill_GL_RUN(conn); |
|
found = false; |
|
| 2985 |
// |
// |
| 2986 |
}; |
}; |
| 2987 |
|
// |
| 2988 |
|
// delete old entries in fragment table |
| 2989 |
|
// |
| 2990 |
|
glrun->DeleteRun(conn,0,"GL_RUN_FRAGMENTS"); |
| 2991 |
|
glrun1->DeleteRun(conn,0,"GL_RUN_FRAGMENTS"); |
| 2992 |
|
// |
| 2993 |
|
delete glrun1; |
| 2994 |
|
// |
| 2995 |
|
return; |
| 2996 |
|
// |
| 2997 |
}; |
}; |
| 2998 |
|
// |
| 2999 |
}; |
}; |
| 3000 |
// |
// |
| 3001 |
if ( found ){ |
justcheck: |
| 3002 |
// |
// |
| 3003 |
// we have found the missing piece, glue the two together, merge the informations, fill the gl_run table (check first runs do not exists), delete entry in frag table |
if ( !found ){ |
|
// |
|
|
if ( IsDebug() ) printf(" now you can handle the piece of the run \n "); |
|
|
// |
|
|
if ( foundinrun ){ |
|
|
glrun->RestoreRun(conn,(UInt_t)atoll(row->GetField(0)),"GL_RUN_FRAGMENTS"); |
|
|
glrun->DeleteRun(conn,(UInt_t)atoll(row->GetField(0)),"GL_RUN"); |
|
|
}; |
|
| 3004 |
// |
// |
| 3005 |
GL_RUN *glrun1 = new GL_RUN(); |
if ( IsDebug() ) printf(" not found, check if we have already processed the file \n "); |
| 3006 |
// |
// |
| 3007 |
// UInt_t idfrag = (UInt_t)atoll(row->GetField(0)); |
// not found, has this run already inserted in the GL_RUN or in the GL_RUN_FRAGMENTS table? |
| 3008 |
// |
// |
| 3009 |
oss.str(""); |
oss.str(""); |
| 3010 |
oss << " ID="<<row->GetField(0)<<";"; |
oss << " SELECT ID FROM GL_RUN WHERE " |
| 3011 |
|
<< " BOOT_NUMBER=" << this->GetBOOTnumber() << " AND (" |
| 3012 |
|
<< " (RUNHEADER_TIME>=" << (UInt_t)(glrun->GetRUNHEADER_TIME()-10) << " AND " |
| 3013 |
|
<< " RUNTRAILER_TIME<=" << (UInt_t)(glrun->GetRUNTRAILER_TIME()+10) << " AND (" |
| 3014 |
|
<< " RUNHEADER_OBT>=" << glrun->GetRUNHEADER_OBT() << " OR " |
| 3015 |
|
<< " RUNHEADER_PKT>=" << glrun->GetRUNHEADER_PKT() << ") AND (" |
| 3016 |
|
<< " RUNTRAILER_OBT<=" << glrun->GetRUNTRAILER_OBT() << " OR " |
| 3017 |
|
<< " RUNTRAILER_PKT<=" << glrun->GetRUNTRAILER_PKT() << ") ) OR " |
| 3018 |
|
<< " (RUNHEADER_TIME<=" << (UInt_t)glrun->GetRUNHEADER_TIME() << " AND " |
| 3019 |
|
<< " RUNTRAILER_TIME>=" << (UInt_t)glrun->GetRUNTRAILER_TIME() <<" AND (" |
| 3020 |
|
<< " RUNHEADER_OBT<=" << glrun->GetRUNHEADER_OBT() << " OR " |
| 3021 |
|
<< " RUNHEADER_PKT<=" << glrun->GetRUNHEADER_PKT() << ") AND (" |
| 3022 |
|
<< " RUNTRAILER_OBT>=" << glrun->GetRUNTRAILER_OBT() << " OR " |
| 3023 |
|
<< " RUNTRAILER_PKT>=" << glrun->GetRUNTRAILER_PKT() << ") ));"; |
| 3024 |
// |
// |
| 3025 |
glrun1->Query_GL_RUN_FRAGMENTS(oss.str().c_str(),conn); // here we have runtrailer infos |
if ( IsDebug() ) printf(" check if run has been inserted: query is \n %s \n",oss.str().c_str()); |
| 3026 |
|
result = conn->Query(oss.str().c_str()); |
| 3027 |
// |
// |
| 3028 |
// merge infos |
if ( !result ) throw -4; |
| 3029 |
// |
// |
| 3030 |
UInt_t apkt = PKT(glrun->GetRUNTRAILER_PKT()); |
row = result->Next(); |
|
ULong64_t aobt = OBT(glrun->GetRUNTRAILER_OBT()); |
|
|
UInt_t bpkt = PKT(glrun1->GetRUNHEADER_PKT()); |
|
|
ULong64_t bobt = OBT(glrun1->GetRUNHEADER_OBT()); |
|
|
if ( IsDebug() ) printf(" Check overlapping events: %u %u %llu %llu lastev is %i\n",apkt,bpkt,aobt,bobt,lastev); |
|
|
TTree *T= 0; |
|
|
T = (TTree*)file->Get("Physics"); |
|
|
if ( !T || T->IsZombie() ) throw -16; |
|
|
EventHeader *eh = 0; |
|
|
PscuHeader *ph = 0; |
|
|
T->SetBranchAddress("Header", &eh); |
|
|
while ( apkt > bpkt && aobt > bobt && lastev > 0 ){ |
|
|
T->GetEntry(lastev); |
|
|
ph = eh->GetPscuHeader(); |
|
|
apkt = PKT(ph->GetCounter()); |
|
|
aobt = OBT(ph->GetOrbitalTime()); |
|
|
lastev--; |
|
|
if ( PEDANTIC ) throw -72; |
|
|
}; |
|
|
if ( IsDebug() ) printf(" Check overlapping events done: %u %u %llu %llu lastev is %i\n",apkt,bpkt,aobt,bobt,lastev); |
|
|
// |
|
|
glrun->SetEV_TO(lastev); |
|
|
glrun->SetNEVENTS(lastev-firstev+1); |
|
|
glrun->SetPKT_COUNTER(glrun1->GetPKT_COUNTER()); |
|
|
glrun->SetPKT_READY_COUNTER(glrun1->GetPKT_READY_COUNTER()); |
|
|
glrun->SetRUNTRAILER_TIME(glrun1->GetRUNTRAILER_TIME()); |
|
|
glrun->SetRUNTRAILER_OBT(glrun1->GetRUNTRAILER_OBT()); |
|
|
glrun->SetRUNTRAILER_PKT(glrun1->GetRUNTRAILER_PKT()); |
|
|
// |
|
|
glrun1->SetRUNHEADER_TIME(glrun->GetRUNHEADER_TIME()); |
|
|
glrun1->SetRUNHEADER_OBT(glrun->GetRUNHEADER_OBT()); |
|
|
glrun1->SetRUNHEADER_PKT(glrun->GetRUNHEADER_PKT()); |
|
|
glrun1->SetCOMPILATIONTIMESTAMP(glrun->GetCOMPILATIONTIMESTAMP()); |
|
|
glrun1->SetFAV_WRK_SCHEDULE(glrun->GetFAV_WRK_SCHEDULE()); |
|
|
glrun1->SetEFF_WRK_SCHEDULE(glrun->GetEFF_WRK_SCHEDULE()); |
|
|
glrun1->SetPRH_VAR_TRG_MODE_A(glrun->GetPRH_VAR_TRG_MODE_A()); |
|
|
glrun1->SetPRH_VAR_TRG_MODE_B(glrun->GetPRH_VAR_TRG_MODE_B()); |
|
|
glrun1->SetACQ_BUILD_INFO(glrun->GetACQ_BUILD_INFO()); |
|
|
glrun1->SetACQ_VAR_INFO(glrun->GetACQ_VAR_INFO()); |
|
|
glrun1->SetRM_ACQ_AFTER_CALIB(glrun->GetRM_ACQ_AFTER_CALIB()); |
|
|
glrun1->SetRM_ACQ_SETTING_MODE(glrun->GetRM_ACQ_SETTING_MODE()); |
|
|
glrun1->SetTRK_CALIB_USED(glrun->GetTRK_CALIB_USED()); |
|
|
glrun1->SetCAL_DSP_MASK(glrun->GetCAL_DSP_MASK()); |
|
|
glrun1->SetLAST_TIMESYNC(glrun->GetLAST_TIMESYNC()); |
|
|
glrun1->SetOBT_TIMESYNC(glrun->GetOBT_TIMESYNC()); |
|
| 3031 |
// |
// |
| 3032 |
if ( !IsRunAlreadyInserted() ){ |
if ( row ){ |
| 3033 |
// |
if ( IsDebug() ) printf(" The run is already present in the GL_RUN table \n"); |
| 3034 |
// glrun->SetID(this->AssignRunID()); |
if ( PEDANTIC ) throw -70; |
| 3035 |
// |
} else { |
| 3036 |
glrun->SetID_RUN_FRAG(glrun1->GetID()); |
if ( NoFrag() ){ |
| 3037 |
glrun->Fill_GL_RUN(conn); |
glrun->SetID_RUN_FRAG(glrun->GetID()); |
| 3038 |
// |
glrun->Fill_GL_RUN(conn); |
| 3039 |
// set id number |
glrun->DeleteRun(conn,0,"GL_RUN_FRAGMENTS"); |
| 3040 |
// |
}; |
|
glrun1->SetID_RUN_FRAG(glrun->GetID()); |
|
|
glrun1->Fill_GL_RUN(conn); |
|
|
// |
|
| 3041 |
}; |
}; |
|
// |
|
|
// delete old entries in fragment table |
|
|
// |
|
|
glrun->DeleteRun(conn,0,"GL_RUN_FRAGMENTS"); |
|
|
glrun1->DeleteRun(conn,0,"GL_RUN_FRAGMENTS"); |
|
|
// |
|
|
delete glrun1; |
|
|
// |
|
|
return; |
|
|
// |
|
| 3042 |
}; |
}; |
|
// |
|
|
}; |
|
|
// |
|
|
justcheck: |
|
|
// |
|
|
if ( !found ){ |
|
|
// |
|
|
if ( IsDebug() ) printf(" not found, check if we have already processed the file \n "); |
|
|
// |
|
|
// not found, has this run already inserted in the GL_RUN or in the GL_RUN_FRAGMENTS table? |
|
|
// |
|
|
oss.str(""); |
|
|
oss << " SELECT ID FROM GL_RUN WHERE " |
|
|
<< " BOOT_NUMBER=" << this->GetBOOTnumber() << " AND (" |
|
|
<< " (RUNHEADER_TIME>=" << (UInt_t)(glrun->GetRUNHEADER_TIME()-10) << " AND " |
|
|
<< " RUNTRAILER_TIME<=" << (UInt_t)(glrun->GetRUNTRAILER_TIME()+10) << " AND (" |
|
|
<< " RUNHEADER_OBT>=" << glrun->GetRUNHEADER_OBT() << " OR " |
|
|
<< " RUNHEADER_PKT>=" << glrun->GetRUNHEADER_PKT() << ") AND (" |
|
|
<< " RUNTRAILER_OBT<=" << glrun->GetRUNTRAILER_OBT() << " OR " |
|
|
<< " RUNTRAILER_PKT<=" << glrun->GetRUNTRAILER_PKT() << ") ) OR " |
|
|
<< " (RUNHEADER_TIME<=" << (UInt_t)glrun->GetRUNHEADER_TIME() << " AND " |
|
|
<< " RUNTRAILER_TIME>=" << (UInt_t)glrun->GetRUNTRAILER_TIME() <<" AND (" |
|
|
<< " RUNHEADER_OBT<=" << glrun->GetRUNHEADER_OBT() << " OR " |
|
|
<< " RUNHEADER_PKT<=" << glrun->GetRUNHEADER_PKT() << ") AND (" |
|
|
<< " RUNTRAILER_OBT>=" << glrun->GetRUNTRAILER_OBT() << " OR " |
|
|
<< " RUNTRAILER_PKT>=" << glrun->GetRUNTRAILER_PKT() << ") ));"; |
|
|
// |
|
|
if ( IsDebug() ) printf(" check if run has been inserted: query is \n %s \n",oss.str().c_str()); |
|
|
result = conn->Query(oss.str().c_str()); |
|
|
// |
|
|
if ( !result ) throw -4; |
|
|
// |
|
|
row = result->Next(); |
|
|
// |
|
|
if ( row ){ |
|
|
if ( IsDebug() ) printf(" The run is already present in the GL_RUN table \n"); |
|
|
if ( PEDANTIC ) throw -70; |
|
|
} else { |
|
|
if ( NoFrag() ){ |
|
|
glrun->SetID_RUN_FRAG(glrun->GetID()); |
|
|
glrun->Fill_GL_RUN(conn); |
|
|
glrun->DeleteRun(conn,0,"GL_RUN_FRAGMENTS"); |
|
|
}; |
|
|
}; |
|
|
}; |
|
| 3043 |
}; // EEE |
}; // EEE |
| 3044 |
// |
// |
| 3045 |
return; |
return; |
| 3121 |
code = eh->GetCounter(); |
code = eh->GetCounter(); |
| 3122 |
checkfirst = 0; |
checkfirst = 0; |
| 3123 |
for(Iter = packetsNames.begin(); Iter != packetsNames.end(); Iter++){ |
for(Iter = packetsNames.begin(); Iter != packetsNames.end(); Iter++){ |
| 3124 |
if ( strcmp(*Iter,"Physics") ) checkfirst += code->Get(GetPacketType(*Iter)); |
if ( strcmp(*Iter,"Physics") ) checkfirst += code->Get(GetPacketType(*Iter)); |
| 3125 |
}; |
}; |
| 3126 |
if ( IsDebug() ) printf(" Check first is %i firstev is %i\n",checkfirst,firstev); |
if ( IsDebug() ) printf(" Check first is %i firstev is %i\n",checkfirst,firstev); |
| 3127 |
// |
// |
| 3128 |
T->GetEntry(lastev); |
T->GetEntry(lastev); |
| 3129 |
code = eh->GetCounter(); |
code = eh->GetCounter(); |
| 3130 |
checklast = 0; |
checklast = 0; |
| 3131 |
for(Iter = packetsNames.begin(); Iter != packetsNames.end(); Iter++){ |
for(Iter = packetsNames.begin(); Iter != packetsNames.end(); Iter++){ |
| 3132 |
if ( strcmp(*Iter,"Physics") ) checklast += code->Get(GetPacketType(*Iter)); |
if ( strcmp(*Iter,"Physics") ) checklast += code->Get(GetPacketType(*Iter)); |
| 3133 |
}; |
}; |
| 3134 |
if ( IsDebug() ) printf(" Check last is %i lastev is %i\n",checklast,lastev); |
if ( IsDebug() ) printf(" Check last is %i lastev is %i\n",checklast,lastev); |
| 3135 |
// |
// |
| 3136 |
if ( checkfirst == checklast ){ |
if ( checkfirst == checklast ){ |
| 3145 |
// |
// |
| 3146 |
// HERE WE MUST HANDLE THAT RUNS AND GO BACK |
// HERE WE MUST HANDLE THAT RUNS AND GO BACK |
| 3147 |
// |
// |
| 3148 |
// if ( IsDebug() ) printf(" Never seen this case, try to handle it anyway, it was throw -95\n"); |
// if ( IsDebug() ) printf(" Never seen this case, try to handle it anyway, it was throw -95\n"); |
| 3149 |
// |
// |
| 3150 |
Bool_t emptyruns = false; |
Bool_t emptyruns = false; |
| 3151 |
UInt_t check = 0; |
UInt_t check = 0; |
| 3231 |
lastObt = firstObt; |
lastObt = firstObt; |
| 3232 |
lastPkt = firstPkt; |
lastPkt = firstPkt; |
| 3233 |
}; |
}; |
| 3234 |
glrun->SetRUNTRAILER_PKT(lastPkt); |
glrun->SetRUNTRAILER_PKT(lastPkt); |
| 3235 |
glrun->SetRUNTRAILER_OBT(lastObt); |
glrun->SetRUNTRAILER_OBT(lastObt); |
| 3236 |
lastentry++; |
lastentry++; |
| 3237 |
}; |
}; |
| 3238 |
// |
// |
| 3239 |
this->SetCommonGLRUN(firstTime,lastTime); |
this->SetCommonGLRUN(firstTime,lastTime); |
| 3240 |
// |
this->SetPhysEndRunVariables(); |
| 3241 |
if ( chminentry == firstentry ){ // EEE |
// |
| 3242 |
if ( IsDebug() ) printf(" Inside isrunconsistent found a fragment of run at the beginning of the file, put it in the fragment table \n"); |
if ( chminentry == firstentry ){ // EEE |
| 3243 |
// |
if ( IsDebug() ) printf(" Inside isrunconsistent found a fragment of run at the beginning of the file, put it in the fragment table \n"); |
| 3244 |
// this->HandleRunFragments(true,mistrail,firstentry,lastentry); // cannot call it here since it enters a loop which will destroy the already stored variables if we arrive here from HandleRunFragments |
// |
| 3245 |
// |
// this->HandleRunFragments(true,mistrail,firstentry,lastentry); // cannot call it here since it enters a loop which will destroy the already stored variables if we arrive here from HandleRunFragments |
| 3246 |
|
// |
| 3247 |
|
|
| 3248 |
|
|
| 3249 |
|
|
| 3250 |
|
|
| 3251 |
|
|
| 3252 |
|
|
| 3253 |
|
|
| 3254 |
|
|
| 3255 |
|
|
| 3256 |
|
|
| 3257 |
|
|
| 3258 |
|
|
| 3259 |
mishead = true; |
|
| 3260 |
|
mishead = true; |
| 3261 |
|
|
| 3262 |
UInt_t rhfirstev = firstentry; |
|
| 3263 |
// UInt_t rtlastev = lastentry; |
UInt_t rhfirstev = firstentry; |
| 3264 |
Bool_t found = false; |
// UInt_t rtlastev = lastentry; |
| 3265 |
Bool_t foundinrun = false; |
Bool_t found = false; |
| 3266 |
// |
Bool_t foundinrun = false; |
| 3267 |
TSQLResult *result = 0; |
// |
| 3268 |
TSQLRow *row = 0; |
TSQLResult *result = 0; |
| 3269 |
// |
TSQLRow *row = 0; |
| 3270 |
stringstream oss; |
// |
| 3271 |
oss.str(""); |
stringstream oss; |
| 3272 |
// |
oss.str(""); |
| 3273 |
// we have now the good first piece of a run, fill the glrun object |
// |
| 3274 |
// |
// we have now the good first piece of a run, fill the glrun object |
| 3275 |
// if ( rhfirstev != firstev && !mishead ) mishead = true; |
// |
| 3276 |
// if ( rtlastev != lastev && !mistrail ) mistrail = true; |
// if ( rhfirstev != firstev && !mishead ) mishead = true; |
| 3277 |
// |
// if ( rtlastev != lastev && !mistrail ) mistrail = true; |
| 3278 |
// this->FillClass(mishead,mistrail,firstev,lastev); |
// |
| 3279 |
// |
// this->FillClass(mishead,mistrail,firstev,lastev); |
| 3280 |
if ( IsDebug() ) printf("zz The run is good, is it the other piece in the GL_RUN_FRAGMENTS table?\n"); |
// |
| 3281 |
if ( IsDebug() ) printf("zz C THIS RUN: RUNHEADER_OBT %u RUNTRAILER_OBT %u RUNHEADER_PKT %u RUNTRAILER_PKT %u \n", glrun->GetRUNHEADER_OBT(),glrun->GetRUNTRAILER_OBT(),glrun->GetRUNHEADER_PKT(),glrun->GetRUNTRAILER_PKT()); |
if ( IsDebug() ) printf("zz The run is good, is it the other piece in the GL_RUN_FRAGMENTS table?\n"); |
| 3282 |
// |
if ( IsDebug() ) printf("zz C THIS RUN: RUNHEADER_OBT %u RUNTRAILER_OBT %u RUNHEADER_PKT %u RUNTRAILER_PKT %u \n", glrun->GetRUNHEADER_OBT(),glrun->GetRUNTRAILER_OBT(),glrun->GetRUNHEADER_PKT(),glrun->GetRUNTRAILER_PKT()); |
| 3283 |
// First of all insert the run in the fragment table... |
// |
| 3284 |
// |
// First of all insert the run in the fragment table... |
| 3285 |
oss.str(""); |
// |
| 3286 |
oss << " SELECT ID FROM GL_RUN_FRAGMENTS WHERE " |
oss.str(""); |
| 3287 |
<< " BOOT_NUMBER=" << this->GetBOOTnumber() << " AND (" |
oss << " SELECT ID FROM GL_RUN_FRAGMENTS WHERE " |
| 3288 |
<< " (RUNHEADER_TIME>=" << (UInt_t)(glrun->GetRUNHEADER_TIME()-10) << " AND " |
<< " BOOT_NUMBER=" << this->GetBOOTnumber() << " AND (" |
| 3289 |
<< " RUNTRAILER_TIME<=" << (UInt_t)(glrun->GetRUNTRAILER_TIME()+10) << " AND (" |
<< " (RUNHEADER_TIME>=" << (UInt_t)(glrun->GetRUNHEADER_TIME()-10) << " AND " |
| 3290 |
<< " RUNHEADER_OBT>=" << glrun->GetRUNHEADER_OBT() << " OR " |
<< " RUNTRAILER_TIME<=" << (UInt_t)(glrun->GetRUNTRAILER_TIME()+10) << " AND (" |
| 3291 |
<< " RUNHEADER_PKT>=" << glrun->GetRUNHEADER_PKT() << ") AND (" |
<< " RUNHEADER_OBT>=" << glrun->GetRUNHEADER_OBT() << " OR " |
| 3292 |
<< " RUNTRAILER_OBT<=" << glrun->GetRUNTRAILER_OBT() << " OR " |
<< " RUNHEADER_PKT>=" << glrun->GetRUNHEADER_PKT() << ") AND (" |
| 3293 |
<< " RUNTRAILER_PKT<=" << glrun->GetRUNTRAILER_PKT() << ") ) OR " |
<< " RUNTRAILER_OBT<=" << glrun->GetRUNTRAILER_OBT() << " OR " |
| 3294 |
<< " (RUNHEADER_TIME<=" << (UInt_t)glrun->GetRUNHEADER_TIME() << " AND " |
<< " RUNTRAILER_PKT<=" << glrun->GetRUNTRAILER_PKT() << ") ) OR " |
| 3295 |
<< " RUNTRAILER_TIME>=" << (UInt_t)glrun->GetRUNTRAILER_TIME() <<" AND (" |
<< " (RUNHEADER_TIME<=" << (UInt_t)glrun->GetRUNHEADER_TIME() << " AND " |
| 3296 |
<< " RUNHEADER_OBT<=" << glrun->GetRUNHEADER_OBT() << " OR " |
<< " RUNTRAILER_TIME>=" << (UInt_t)glrun->GetRUNTRAILER_TIME() <<" AND (" |
| 3297 |
<< " RUNHEADER_PKT<=" << glrun->GetRUNHEADER_PKT() << ") AND (" |
<< " RUNHEADER_OBT<=" << glrun->GetRUNHEADER_OBT() << " OR " |
| 3298 |
<< " RUNTRAILER_OBT>=" << glrun->GetRUNTRAILER_OBT() << " OR " |
<< " RUNHEADER_PKT<=" << glrun->GetRUNHEADER_PKT() << ") AND (" |
| 3299 |
<< " RUNTRAILER_PKT>=" << glrun->GetRUNTRAILER_PKT() << ") ));"; |
<< " RUNTRAILER_OBT>=" << glrun->GetRUNTRAILER_OBT() << " OR " |
| 3300 |
// |
<< " RUNTRAILER_PKT>=" << glrun->GetRUNTRAILER_PKT() << ") ));"; |
| 3301 |
if ( IsDebug() ) printf(" check if run has been inserted: query is \n %s \n",oss.str().c_str()); |
// |
| 3302 |
result = conn->Query(oss.str().c_str()); |
if ( IsDebug() ) printf(" check if run has been inserted: query is \n %s \n",oss.str().c_str()); |
| 3303 |
// |
result = conn->Query(oss.str().c_str()); |
| 3304 |
if ( !result ) throw -4; |
// |
| 3305 |
// |
if ( !result ) throw -4; |
| 3306 |
row = result->Next(); |
// |
| 3307 |
// |
row = result->Next(); |
| 3308 |
if ( !row ){ |
// |
| 3309 |
// |
if ( !row ){ |
| 3310 |
// no, insert this run in the GL_RUN_FRAGMENTS table (check if exist before!) |
// |
| 3311 |
// |
// no, insert this run in the GL_RUN_FRAGMENTS table (check if exist before!) |
| 3312 |
if ( IsDebug() ) printf(" The run is new \n"); |
// |
| 3313 |
if ( IsDebug() ) printf(" -> fill the GL_RUNFRAGMENTS table \n"); |
if ( IsDebug() ) printf(" The run is new \n"); |
| 3314 |
// |
if ( IsDebug() ) printf(" -> fill the GL_RUNFRAGMENTS table \n"); |
| 3315 |
glrun->SetID(this->AssignRunID()); |
// |
| 3316 |
glrun->SetID_RUN_FRAG(0); |
glrun->SetID(this->AssignRunID()); |
| 3317 |
glrun->Fill_GL_RUN_FRAGMENTS(conn); |
glrun->SetID_RUN_FRAG(0); |
| 3318 |
// |
glrun->Fill_GL_RUN_FRAGMENTS(conn); |
| 3319 |
} else { |
// |
| 3320 |
if ( IsDebug() ) printf(" The run is already present in the fragment table \n"); |
} else { |
| 3321 |
if ( PEDANTIC ) throw -69; |
if ( IsDebug() ) printf(" The run is already present in the fragment table \n"); |
| 3322 |
// return; |
if ( PEDANTIC ) throw -69; |
| 3323 |
}; |
// return; |
| 3324 |
// |
}; |
| 3325 |
if ( chewbacca && mishead && mistrail ) goto zjustcheck; |
// |
| 3326 |
// |
if ( chewbacca && mishead && mistrail ) goto zjustcheck; |
| 3327 |
// can we find the other piece of the run in the GL_RUN_FRAGMENTS table? |
// |
| 3328 |
// |
// can we find the other piece of the run in the GL_RUN_FRAGMENTS table? |
| 3329 |
if ( mishead && ( rhfirstev == firstev || chewbacca ) ) { // look for runheader (only when at the beginning of the file, if at the end and the runh is |
// |
| 3330 |
// missing it no way we can found a piece in the frag table |
if ( mishead && ( rhfirstev == firstev || chewbacca ) ) { // look for runheader (only when at the beginning of the file, if at the end and the runh is |
| 3331 |
// |
// missing it no way we can found a piece in the frag table |
| 3332 |
oss.str(""); |
// |
| 3333 |
oss << " SELECT ID,TRK_CALIB_USED,RUNTRAILER_TIME,RUNTRAILER_OBT,RUNHEADER_PKT,RUNTRAILER_PKT FROM GL_RUN_FRAGMENTS WHERE " |
oss.str(""); |
| 3334 |
<< " BOOT_NUMBER=" << this->GetBOOTnumber() << " AND " |
oss << " SELECT ID,TRK_CALIB_USED,RUNTRAILER_TIME,RUNTRAILER_OBT,RUNHEADER_PKT,RUNTRAILER_PKT FROM GL_RUN_FRAGMENTS WHERE " |
| 3335 |
<< " RUNHEADER_TIME <= " << (UInt_t)glrun->GetRUNHEADER_TIME() << " AND " |
<< " BOOT_NUMBER=" << this->GetBOOTnumber() << " AND " |
| 3336 |
<< " ID != " << glrun->ID |
<< " RUNHEADER_TIME <= " << (UInt_t)glrun->GetRUNHEADER_TIME() << " AND " |
| 3337 |
<< " ORDER BY RUNHEADER_TIME DESC LIMIT 1;"; // DESC NOT ASC!! |
<< " ID != " << glrun->ID |
| 3338 |
// |
<< " ORDER BY RUNHEADER_TIME DESC LIMIT 1;"; // DESC NOT ASC!! |
| 3339 |
if ( IsDebug() ) printf(" look for runheader in the fragments table: query is \n %s \n",oss.str().c_str()); |
// |
| 3340 |
result = conn->Query(oss.str().c_str()); |
if ( IsDebug() ) printf(" look for runheader in the fragments table: query is \n %s \n",oss.str().c_str()); |
| 3341 |
// |
result = conn->Query(oss.str().c_str()); |
| 3342 |
if ( !result ) throw -4; |
// |
| 3343 |
// |
if ( !result ) throw -4; |
| 3344 |
row = result->Next(); |
// |
| 3345 |
// |
row = result->Next(); |
| 3346 |
if ( !row && NoFrag() ){ |
// |
| 3347 |
// |
if ( !row && NoFrag() ){ |
| 3348 |
oss.str(""); |
// |
| 3349 |
oss << " SELECT ID,TRK_CALIB_USED,RUNTRAILER_TIME,RUNTRAILER_OBT,RUNHEADER_PKT,RUNTRAILER_PKT FROM GL_RUN WHERE " |
oss.str(""); |
| 3350 |
<< " BOOT_NUMBER=" << this->GetBOOTnumber() << " AND " |
oss << " SELECT ID,TRK_CALIB_USED,RUNTRAILER_TIME,RUNTRAILER_OBT,RUNHEADER_PKT,RUNTRAILER_PKT FROM GL_RUN WHERE " |
| 3351 |
<< " RUNHEADER_TIME <= " << (UInt_t)glrun->GetRUNHEADER_TIME() << " AND " |
<< " BOOT_NUMBER=" << this->GetBOOTnumber() << " AND " |
| 3352 |
<< " ID != " << glrun->ID |
<< " RUNHEADER_TIME <= " << (UInt_t)glrun->GetRUNHEADER_TIME() << " AND " |
| 3353 |
<< " AND ID=ID_RUN_FRAG ORDER BY RUNHEADER_TIME DESC LIMIT 1;"; // DESC NOT ASC!! |
<< " ID != " << glrun->ID |
| 3354 |
// |
<< " AND ID=ID_RUN_FRAG ORDER BY RUNHEADER_TIME DESC LIMIT 1;"; // DESC NOT ASC!! |
| 3355 |
if ( IsDebug() ) printf(" look for runheader in the GL_RUN table: query is \n %s \n",oss.str().c_str()); |
// |
| 3356 |
result = conn->Query(oss.str().c_str()); |
if ( IsDebug() ) printf(" look for runheader in the GL_RUN table: query is \n %s \n",oss.str().c_str()); |
| 3357 |
// |
result = conn->Query(oss.str().c_str()); |
| 3358 |
if ( !result ) throw -4; |
// |
| 3359 |
// |
if ( !result ) throw -4; |
| 3360 |
foundinrun = true; |
// |
| 3361 |
// |
foundinrun = true; |
| 3362 |
row = result->Next(); |
// |
| 3363 |
// |
row = result->Next(); |
| 3364 |
}; |
// |
| 3365 |
// |
}; |
| 3366 |
if ( !row ){ |
// |
| 3367 |
if ( IsDebug() ) printf(" the corresponding piece has NOT been found \n"); |
if ( !row ){ |
| 3368 |
found = false; |
if ( IsDebug() ) printf(" the corresponding piece has NOT been found \n"); |
| 3369 |
} else { |
found = false; |
| 3370 |
// |
} else { |
| 3371 |
found = false; // default value |
// |
| 3372 |
// |
found = false; // default value |
| 3373 |
if ( IsDebug() ) printf(" Found a possible candidate, checking if it is the good one... \n"); |
// |
| 3374 |
// |
if ( IsDebug() ) printf(" Found a possible candidate, checking if it is the good one... \n"); |
| 3375 |
// if we have both runheader and runtrailer we can check with pkt_counter: |
// |
| 3376 |
// |
// if we have both runheader and runtrailer we can check with pkt_counter: |
| 3377 |
if ( !mistrail && (UInt_t)atoll(row->GetField(1)) != 0 ){ |
// |
| 3378 |
ULong64_t chkpkt = 0; |
if ( !mistrail && (UInt_t)atoll(row->GetField(1)) != 0 ){ |
| 3379 |
ULong64_t pktt = (ULong64_t)PKT(glrun->GetRUNTRAILER_PKT()); |
ULong64_t chkpkt = 0; |
| 3380 |
ULong64_t pkth = (ULong64_t)PKT((UInt_t)atoll(row->GetField(4))); |
ULong64_t pktt = (ULong64_t)PKT(glrun->GetRUNTRAILER_PKT()); |
| 3381 |
// |
ULong64_t pkth = (ULong64_t)PKT((UInt_t)atoll(row->GetField(4))); |
| 3382 |
chkpkt = pkth + (ULong64_t)glrun->GetPKT_COUNTER() + 1ULL + 1ULL; |
// |
| 3383 |
// |
chkpkt = pkth + (ULong64_t)glrun->GetPKT_COUNTER() + 1ULL + 1ULL; |
| 3384 |
if ( labs(chkpkt-pktt)<2 ){ |
// |
| 3385 |
// |
if ( labs(chkpkt-pktt)<2 ){ |
| 3386 |
if ( IsDebug() ) printf(" FOUND!!! check %llu pktt %llu \n",chkpkt,pktt); |
// |
| 3387 |
// |
if ( IsDebug() ) printf(" FOUND!!! check %llu pktt %llu \n",chkpkt,pktt); |
| 3388 |
found = true; |
// |
| 3389 |
// |
found = true; |
| 3390 |
} else { |
// |
| 3391 |
// |
} else { |
| 3392 |
if ( IsDebug() ) printf(" The check with pkt counter failed: check %llu pktt %llu \n",chkpkt,pktt); |
// |
| 3393 |
// |
if ( IsDebug() ) printf(" The check with pkt counter failed: check %llu pktt %llu \n",chkpkt,pktt); |
| 3394 |
found = false; |
// |
| 3395 |
// |
found = false; |
| 3396 |
}; |
// |
| 3397 |
}; |
}; |
| 3398 |
if ( !found && chewbacca ) goto zjustcheck; |
}; |
| 3399 |
if ( !found ){ |
if ( !found && chewbacca ) goto zjustcheck; |
| 3400 |
// |
if ( !found ){ |
| 3401 |
// if we arrive here we were not able to decide if the two pieces matches using only the pkt counter information, we must check times and obts |
// |
| 3402 |
// |
// if we arrive here we were not able to decide if the two pieces matches using only the pkt counter information, we must check times and obts |
| 3403 |
ULong64_t chkpkt1 = 0; |
// |
| 3404 |
ULong64_t orunh1 = (ULong64_t)PKT(glrun->GetRUNHEADER_PKT()); |
ULong64_t chkpkt1 = 0; |
| 3405 |
ULong64_t dbrunt1 = (ULong64_t)PKT((UInt_t)atoll(row->GetField(5))); |
ULong64_t orunh1 = (ULong64_t)PKT(glrun->GetRUNHEADER_PKT()); |
| 3406 |
chkpkt1 = labs(orunh1-dbrunt1); |
ULong64_t dbrunt1 = (ULong64_t)PKT((UInt_t)atoll(row->GetField(5))); |
| 3407 |
// |
chkpkt1 = labs(orunh1-dbrunt1); |
| 3408 |
ULong64_t chkpkt2 = 0; |
// |
| 3409 |
ULong64_t orunh2 = (ULong64_t)OBT(glrun->GetRUNHEADER_OBT()); |
ULong64_t chkpkt2 = 0; |
| 3410 |
ULong64_t dbrunt2 = (ULong64_t)OBT((UInt_t)atoll(row->GetField(3))); |
ULong64_t orunh2 = (ULong64_t)OBT(glrun->GetRUNHEADER_OBT()); |
| 3411 |
chkpkt2 = labs(orunh2-dbrunt2); |
ULong64_t dbrunt2 = (ULong64_t)OBT((UInt_t)atoll(row->GetField(3))); |
| 3412 |
// |
chkpkt2 = labs(orunh2-dbrunt2); |
| 3413 |
ULong64_t chkpkt3 = 0; |
// |
| 3414 |
ULong64_t orunh3 = (ULong64_t)(glrun->GetRUNHEADER_TIME()); |
ULong64_t chkpkt3 = 0; |
| 3415 |
ULong64_t dbrunt3 = (ULong64_t)((UInt_t)atoll(row->GetField(2))); |
ULong64_t orunh3 = (ULong64_t)(glrun->GetRUNHEADER_TIME()); |
| 3416 |
chkpkt3 = labs(orunh3-dbrunt3); |
ULong64_t dbrunt3 = (ULong64_t)((UInt_t)atoll(row->GetField(2))); |
| 3417 |
// |
chkpkt3 = labs(orunh3-dbrunt3); |
| 3418 |
if ( (chkpkt1 < 200 || chkpkt2 < 20000) && chkpkt3 < 20 ){ |
// |
| 3419 |
// if ( chkpkt1 < 100 && chkpkt2 < 30000 && chkpkt3 < 30 ){ |
if ( (chkpkt1 < 200 || chkpkt2 < 20000) && chkpkt3 < 20 ){ |
| 3420 |
// |
// if ( chkpkt1 < 100 && chkpkt2 < 30000 && chkpkt3 < 30 ){ |
| 3421 |
if ( IsDebug() ) printf(" FOUND!!! check1 %llu<200 cechk2 %llu<20000 check3 %llu<20 \n",chkpkt1,chkpkt2,chkpkt3); |
// |
| 3422 |
// |
if ( IsDebug() ) printf(" FOUND!!! check1 %llu<200 cechk2 %llu<20000 check3 %llu<20 \n",chkpkt1,chkpkt2,chkpkt3); |
| 3423 |
found = true; |
// |
| 3424 |
// |
found = true; |
| 3425 |
} else { |
// |
| 3426 |
// |
} else { |
| 3427 |
if ( IsDebug() ) printf(" Check failed: check1 %llu<200? cechk2 %llu<20000? check3 %llu<20? \n",chkpkt1,chkpkt2,chkpkt3); |
// |
| 3428 |
// |
if ( IsDebug() ) printf(" Check failed: check1 %llu<200? cechk2 %llu<20000? check3 %llu<20? \n",chkpkt1,chkpkt2,chkpkt3); |
| 3429 |
found = false; |
// |
| 3430 |
// |
found = false; |
| 3431 |
}; |
// |
| 3432 |
}; |
}; |
| 3433 |
}; |
}; |
| 3434 |
// |
}; |
| 3435 |
if ( found ){ |
// |
| 3436 |
// |
if ( found ){ |
| 3437 |
// we have found the missing piece, glue the two together, merge the informations, fill the gl_run table (check first runs do not exists), delete entry in frag table |
// |
| 3438 |
// |
// we have found the missing piece, glue the two together, merge the informations, fill the gl_run table (check first runs do not exists), delete entry in frag table |
| 3439 |
if ( IsDebug() ) printf(" now you can handle the piece of the run \n "); |
// |
| 3440 |
// |
if ( IsDebug() ) printf(" now you can handle the piece of the run \n "); |
| 3441 |
if ( foundinrun ){ |
// |
| 3442 |
glrun->RestoreRun(conn,(UInt_t)atoll(row->GetField(0)),"GL_RUN_FRAGMENTS"); |
if ( foundinrun ){ |
| 3443 |
glrun->DeleteRun(conn,(UInt_t)atoll(row->GetField(0)),"GL_RUN"); |
glrun->RestoreRun(conn,(UInt_t)atoll(row->GetField(0)),"GL_RUN_FRAGMENTS"); |
| 3444 |
}; |
glrun->DeleteRun(conn,(UInt_t)atoll(row->GetField(0)),"GL_RUN"); |
| 3445 |
// |
}; |
| 3446 |
GL_RUN *glrun1 = new GL_RUN(); |
// |
| 3447 |
// |
GL_RUN *glrun1 = new GL_RUN(); |
| 3448 |
// UInt_t idfrag = (UInt_t)atoll(row->GetField(0)); |
// |
| 3449 |
// |
// UInt_t idfrag = (UInt_t)atoll(row->GetField(0)); |
| 3450 |
oss.str(""); |
// |
| 3451 |
oss << " ID="<<row->GetField(0)<<";"; |
oss.str(""); |
| 3452 |
// |
oss << " ID="<<row->GetField(0)<<";"; |
| 3453 |
glrun1->Query_GL_RUN_FRAGMENTS(oss.str().c_str(),conn); // here we have runheader infos |
// |
| 3454 |
// |
glrun1->Query_GL_RUN_FRAGMENTS(oss.str().c_str(),conn); // here we have runheader infos |
| 3455 |
// merge infos |
// |
| 3456 |
// |
// merge infos |
| 3457 |
UInt_t apkt = PKT(glrun1->GetRUNTRAILER_PKT()); |
// |
| 3458 |
ULong64_t aobt = OBT(glrun1->GetRUNTRAILER_OBT()); |
UInt_t apkt = PKT(glrun1->GetRUNTRAILER_PKT()); |
| 3459 |
UInt_t bpkt = PKT(glrun->GetRUNHEADER_PKT()); |
ULong64_t aobt = OBT(glrun1->GetRUNTRAILER_OBT()); |
| 3460 |
ULong64_t bobt = OBT(glrun->GetRUNHEADER_OBT()); |
UInt_t bpkt = PKT(glrun->GetRUNHEADER_PKT()); |
| 3461 |
if ( IsDebug() ) printf(" Check overlapping events: %u %u %llu %llu firstev is %i\n",apkt,bpkt,aobt,bobt,firstev); |
ULong64_t bobt = OBT(glrun->GetRUNHEADER_OBT()); |
| 3462 |
TTree *T= 0; |
if ( IsDebug() ) printf(" Check overlapping events: %u %u %llu %llu firstev is %i\n",apkt,bpkt,aobt,bobt,firstev); |
| 3463 |
T = (TTree*)file->Get("Physics"); |
TTree *T= 0; |
| 3464 |
if ( !T || T->IsZombie() ) throw -16; |
T = (TTree*)file->Get("Physics"); |
| 3465 |
EventHeader *eh = 0; |
if ( !T || T->IsZombie() ) throw -16; |
| 3466 |
PscuHeader *ph = 0; |
EventHeader *eh = 0; |
| 3467 |
T->SetBranchAddress("Header", &eh); |
PscuHeader *ph = 0; |
| 3468 |
while ( apkt > bpkt && aobt > bobt && firstev < lastev ){ |
T->SetBranchAddress("Header", &eh); |
| 3469 |
T->GetEntry(firstev); |
while ( apkt > bpkt && aobt > bobt && firstev < lastev ){ |
| 3470 |
ph = eh->GetPscuHeader(); |
T->GetEntry(firstev); |
| 3471 |
bpkt = PKT(ph->GetCounter()); |
ph = eh->GetPscuHeader(); |
| 3472 |
bobt = OBT(ph->GetOrbitalTime()); |
bpkt = PKT(ph->GetCounter()); |
| 3473 |
firstev++; |
bobt = OBT(ph->GetOrbitalTime()); |
| 3474 |
if ( PEDANTIC ) throw -71; |
firstev++; |
| 3475 |
}; |
if ( PEDANTIC ) throw -71; |
| 3476 |
if ( IsDebug() ) printf(" Check overlapping events done: %u %u %llu %llu firstev is %i\n",apkt,bpkt,aobt,bobt,firstev); |
}; |
| 3477 |
// |
if ( IsDebug() ) printf(" Check overlapping events done: %u %u %llu %llu firstev is %i\n",apkt,bpkt,aobt,bobt,firstev); |
| 3478 |
glrun1->SetPKT_COUNTER(glrun->GetPKT_COUNTER()); |
// |
| 3479 |
glrun1->SetPKT_READY_COUNTER(glrun->GetPKT_READY_COUNTER()); |
glrun1->SetPKT_COUNTER(glrun->GetPKT_COUNTER()); |
| 3480 |
glrun1->SetRUNTRAILER_TIME(glrun->GetRUNTRAILER_TIME()); |
glrun1->SetPKT_READY_COUNTER(glrun->GetPKT_READY_COUNTER()); |
| 3481 |
glrun1->SetRUNTRAILER_OBT(glrun->GetRUNTRAILER_OBT()); |
glrun1->SetRUNTRAILER_TIME(glrun->GetRUNTRAILER_TIME()); |
| 3482 |
glrun1->SetRUNTRAILER_PKT(glrun->GetRUNTRAILER_PKT()); |
glrun1->SetRUNTRAILER_OBT(glrun->GetRUNTRAILER_OBT()); |
| 3483 |
// |
glrun1->SetRUNTRAILER_PKT(glrun->GetRUNTRAILER_PKT()); |
| 3484 |
glrun->SetEV_FROM(firstev); |
// |
| 3485 |
glrun->SetNEVENTS(lastev-firstev+1); |
glrun->SetEV_FROM(firstev); |
| 3486 |
// |
glrun->SetNEVENTS(lastev-firstev+1); |
| 3487 |
glrun->SetRUNHEADER_TIME(glrun1->GetRUNHEADER_TIME()); |
// |
| 3488 |
glrun->SetRUNHEADER_OBT(glrun1->GetRUNHEADER_OBT()); |
glrun->SetRUNHEADER_TIME(glrun1->GetRUNHEADER_TIME()); |
| 3489 |
glrun->SetRUNHEADER_PKT(glrun1->GetRUNHEADER_PKT()); |
glrun->SetRUNHEADER_OBT(glrun1->GetRUNHEADER_OBT()); |
| 3490 |
glrun->SetCOMPILATIONTIMESTAMP(glrun1->GetCOMPILATIONTIMESTAMP()); |
glrun->SetRUNHEADER_PKT(glrun1->GetRUNHEADER_PKT()); |
| 3491 |
glrun->SetFAV_WRK_SCHEDULE(glrun1->GetFAV_WRK_SCHEDULE()); |
glrun->SetCOMPILATIONTIMESTAMP(glrun1->GetCOMPILATIONTIMESTAMP()); |
| 3492 |
glrun->SetEFF_WRK_SCHEDULE(glrun1->GetEFF_WRK_SCHEDULE()); |
glrun->SetFAV_WRK_SCHEDULE(glrun1->GetFAV_WRK_SCHEDULE()); |
| 3493 |
glrun->SetPRH_VAR_TRG_MODE_A(glrun1->GetPRH_VAR_TRG_MODE_A()); |
glrun->SetEFF_WRK_SCHEDULE(glrun1->GetEFF_WRK_SCHEDULE()); |
| 3494 |
glrun->SetPRH_VAR_TRG_MODE_B(glrun1->GetPRH_VAR_TRG_MODE_B()); |
glrun->SetPRH_VAR_TRG_MODE_A(glrun1->GetPRH_VAR_TRG_MODE_A()); |
| 3495 |
glrun->SetACQ_BUILD_INFO(glrun1->GetACQ_BUILD_INFO()); |
glrun->SetPRH_VAR_TRG_MODE_B(glrun1->GetPRH_VAR_TRG_MODE_B()); |
| 3496 |
glrun->SetACQ_VAR_INFO(glrun1->GetACQ_VAR_INFO()); |
glrun->SetACQ_BUILD_INFO(glrun1->GetACQ_BUILD_INFO()); |
| 3497 |
glrun->SetRM_ACQ_AFTER_CALIB(glrun1->GetRM_ACQ_AFTER_CALIB()); |
glrun->SetACQ_VAR_INFO(glrun1->GetACQ_VAR_INFO()); |
| 3498 |
glrun->SetRM_ACQ_SETTING_MODE(glrun1->GetRM_ACQ_SETTING_MODE()); |
glrun->SetRM_ACQ_AFTER_CALIB(glrun1->GetRM_ACQ_AFTER_CALIB()); |
| 3499 |
glrun->SetTRK_CALIB_USED(glrun1->GetTRK_CALIB_USED()); |
glrun->SetRM_ACQ_SETTING_MODE(glrun1->GetRM_ACQ_SETTING_MODE()); |
| 3500 |
glrun->SetCAL_DSP_MASK(glrun1->GetCAL_DSP_MASK()); |
glrun->SetTRK_CALIB_USED(glrun1->GetTRK_CALIB_USED()); |
| 3501 |
glrun->SetLAST_TIMESYNC(glrun1->GetLAST_TIMESYNC()); |
glrun->SetCAL_DSP_MASK(glrun1->GetCAL_DSP_MASK()); |
| 3502 |
glrun->SetOBT_TIMESYNC(glrun1->GetOBT_TIMESYNC()); |
glrun->SetLAST_TIMESYNC(glrun1->GetLAST_TIMESYNC()); |
| 3503 |
// |
glrun->SetOBT_TIMESYNC(glrun1->GetOBT_TIMESYNC()); |
| 3504 |
if ( !IsRunAlreadyInserted() ){ |
// |
| 3505 |
// |
if ( glrun1->GetPHYSENDRUN_MASK_S3S2S12() ) glrun->SetPHYSENDRUN_MASK_S3S2S12(glrun1->GetPHYSENDRUN_MASK_S3S2S12()); |
| 3506 |
// glrun->SetID(this->AssignRunID()); |
if ( glrun1->GetPHYSENDRUN_MASK_S11CRC() ) glrun->SetPHYSENDRUN_MASK_S11CRC(glrun1->GetPHYSENDRUN_MASK_S11CRC()); |
| 3507 |
glrun->SetID_RUN_FRAG(glrun1->GetID()); |
// |
| 3508 |
glrun->Fill_GL_RUN(conn); |
if ( !IsRunAlreadyInserted() ){ |
| 3509 |
// |
// |
| 3510 |
// set id number |
// glrun->SetID(this->AssignRunID()); |
| 3511 |
// |
glrun->SetID_RUN_FRAG(glrun1->GetID()); |
| 3512 |
glrun1->SetID_RUN_FRAG(glrun->GetID()); |
glrun->Fill_GL_RUN(conn); |
| 3513 |
glrun1->Fill_GL_RUN(conn); |
// |
| 3514 |
// |
// set id number |
| 3515 |
}; |
// |
| 3516 |
// delete old entry in fragment table |
glrun1->SetID_RUN_FRAG(glrun->GetID()); |
| 3517 |
// |
glrun1->Fill_GL_RUN(conn); |
| 3518 |
glrun->DeleteRun(conn,0,"GL_RUN_FRAGMENTS"); |
// |
| 3519 |
glrun1->DeleteRun(conn,0,"GL_RUN_FRAGMENTS"); |
}; |
| 3520 |
// |
// delete old entry in fragment table |
| 3521 |
delete glrun1; |
// |
| 3522 |
// |
glrun->DeleteRun(conn,0,"GL_RUN_FRAGMENTS"); |
| 3523 |
// |
glrun1->DeleteRun(conn,0,"GL_RUN_FRAGMENTS"); |
| 3524 |
// return; |
// |
| 3525 |
// |
delete glrun1; |
| 3526 |
}; |
// |
| 3527 |
// |
// |
| 3528 |
}; |
// return; |
| 3529 |
// |
// |
| 3530 |
// |
}; |
| 3531 |
zjustcheck: |
// |
| 3532 |
// |
}; |
| 3533 |
if ( !found ){ |
// |
| 3534 |
// |
// |
| 3535 |
if ( IsDebug() ) printf(" not found, check if we have already processed the file \n "); |
zjustcheck: |
| 3536 |
// |
// |
| 3537 |
// not found, has this run already inserted in the GL_RUN or in the GL_RUN_FRAGMENTS table? |
if ( !found ){ |
| 3538 |
// |
// |
| 3539 |
oss.str(""); |
if ( IsDebug() ) printf(" not found, check if we have already processed the file \n "); |
| 3540 |
oss << " SELECT ID FROM GL_RUN WHERE " |
// |
| 3541 |
<< " BOOT_NUMBER=" << this->GetBOOTnumber() << " AND (" |
// not found, has this run already inserted in the GL_RUN or in the GL_RUN_FRAGMENTS table? |
| 3542 |
<< " (RUNHEADER_TIME>=" << (UInt_t)(glrun->GetRUNHEADER_TIME()-10) << " AND " |
// |
| 3543 |
<< " RUNTRAILER_TIME<=" << (UInt_t)(glrun->GetRUNTRAILER_TIME()+10) << " AND (" |
oss.str(""); |
| 3544 |
<< " RUNHEADER_OBT>=" << glrun->GetRUNHEADER_OBT() << " OR " |
oss << " SELECT ID FROM GL_RUN WHERE " |
| 3545 |
<< " RUNHEADER_PKT>=" << glrun->GetRUNHEADER_PKT() << ") AND (" |
<< " BOOT_NUMBER=" << this->GetBOOTnumber() << " AND (" |
| 3546 |
<< " RUNTRAILER_OBT<=" << glrun->GetRUNTRAILER_OBT() << " OR " |
<< " (RUNHEADER_TIME>=" << (UInt_t)(glrun->GetRUNHEADER_TIME()-10) << " AND " |
| 3547 |
<< " RUNTRAILER_PKT<=" << glrun->GetRUNTRAILER_PKT() << ") ) OR " |
<< " RUNTRAILER_TIME<=" << (UInt_t)(glrun->GetRUNTRAILER_TIME()+10) << " AND (" |
| 3548 |
<< " (RUNHEADER_TIME<=" << (UInt_t)glrun->GetRUNHEADER_TIME() << " AND " |
<< " RUNHEADER_OBT>=" << glrun->GetRUNHEADER_OBT() << " OR " |
| 3549 |
<< " RUNTRAILER_TIME>=" << (UInt_t)glrun->GetRUNTRAILER_TIME() <<" AND (" |
<< " RUNHEADER_PKT>=" << glrun->GetRUNHEADER_PKT() << ") AND (" |
| 3550 |
<< " RUNHEADER_OBT<=" << glrun->GetRUNHEADER_OBT() << " OR " |
<< " RUNTRAILER_OBT<=" << glrun->GetRUNTRAILER_OBT() << " OR " |
| 3551 |
<< " RUNHEADER_PKT<=" << glrun->GetRUNHEADER_PKT() << ") AND (" |
<< " RUNTRAILER_PKT<=" << glrun->GetRUNTRAILER_PKT() << ") ) OR " |
| 3552 |
<< " RUNTRAILER_OBT>=" << glrun->GetRUNTRAILER_OBT() << " OR " |
<< " (RUNHEADER_TIME<=" << (UInt_t)glrun->GetRUNHEADER_TIME() << " AND " |
| 3553 |
<< " RUNTRAILER_PKT>=" << glrun->GetRUNTRAILER_PKT() << ") ));"; |
<< " RUNTRAILER_TIME>=" << (UInt_t)glrun->GetRUNTRAILER_TIME() <<" AND (" |
| 3554 |
// |
<< " RUNHEADER_OBT<=" << glrun->GetRUNHEADER_OBT() << " OR " |
| 3555 |
if ( IsDebug() ) printf(" check if run has been inserted: query is \n %s \n",oss.str().c_str()); |
<< " RUNHEADER_PKT<=" << glrun->GetRUNHEADER_PKT() << ") AND (" |
| 3556 |
result = conn->Query(oss.str().c_str()); |
<< " RUNTRAILER_OBT>=" << glrun->GetRUNTRAILER_OBT() << " OR " |
| 3557 |
// |
<< " RUNTRAILER_PKT>=" << glrun->GetRUNTRAILER_PKT() << ") ));"; |
| 3558 |
if ( !result ) throw -4; |
// |
| 3559 |
// |
if ( IsDebug() ) printf(" check if run has been inserted: query is \n %s \n",oss.str().c_str()); |
| 3560 |
row = result->Next(); |
result = conn->Query(oss.str().c_str()); |
| 3561 |
// |
// |
| 3562 |
if ( row ){ |
if ( !result ) throw -4; |
| 3563 |
if ( IsDebug() ) printf(" The run is already present in the GL_RUN table \n"); |
// |
| 3564 |
if ( PEDANTIC ) throw -70; |
row = result->Next(); |
| 3565 |
} else { |
// |
| 3566 |
if ( NoFrag() ){ |
if ( row ){ |
| 3567 |
glrun->SetID_RUN_FRAG(glrun->GetID()); |
if ( IsDebug() ) printf(" The run is already present in the GL_RUN table \n"); |
| 3568 |
glrun->Fill_GL_RUN(conn); |
if ( PEDANTIC ) throw -70; |
| 3569 |
glrun->DeleteRun(conn,0,"GL_RUN_FRAGMENTS"); |
} else { |
| 3570 |
}; |
if ( NoFrag() ){ |
| 3571 |
}; |
glrun->SetID_RUN_FRAG(glrun->GetID()); |
| 3572 |
}; // EEE |
glrun->Fill_GL_RUN(conn); |
| 3573 |
|
glrun->DeleteRun(conn,0,"GL_RUN_FRAGMENTS"); |
| 3574 |
|
}; |
| 3575 |
|
}; |
| 3576 |
|
}; // EEE |
| 3577 |
|
|
| 3578 |
|
|
| 3579 |
|
|
| 3608 |
|
|
| 3609 |
|
|
| 3610 |
} else { |
} else { |
| 3611 |
if ( !IsRunAlreadyInserted() ){ |
if ( !IsRunAlreadyInserted() ){ |
| 3612 |
glrun->SetID(this->AssignRunID()); |
glrun->SetID(this->AssignRunID()); |
| 3613 |
glrun->SetID_RUN_FRAG(0); |
glrun->SetID_RUN_FRAG(0); |
| 3614 |
glrun->Fill_GL_RUN(conn); |
glrun->Fill_GL_RUN(conn); |
| 3615 |
}; |
}; |
| 3616 |
}; // EEE |
}; // EEE |
| 3617 |
// |
// |
| 3618 |
firstevno = lastentry + 1; |
firstevno = lastentry + 1; |
| 3704 |
code = eh->GetCounter(); |
code = eh->GetCounter(); |
| 3705 |
checkfirst = 0; |
checkfirst = 0; |
| 3706 |
for(Iter = packetsNames.begin(); Iter != packetsNames.end(); Iter++){ |
for(Iter = packetsNames.begin(); Iter != packetsNames.end(); Iter++){ |
| 3707 |
if ( strcmp(*Iter,"Physics") ) checkfirst += code->Get(GetPacketType(*Iter)); |
if ( strcmp(*Iter,"Physics") ) checkfirst += code->Get(GetPacketType(*Iter)); |
| 3708 |
if ( !strcmp(*Iter,"RunHeader") ) nrunh1++; |
if ( !strcmp(*Iter,"RunHeader") ) nrunh1++; |
| 3709 |
}; |
}; |
| 3710 |
if ( IsDebug() ) printf(" Check first is %i \n",checkfirst); |
if ( IsDebug() ) printf(" Check first is %i \n",checkfirst); |
| 3711 |
// |
// |
| 3712 |
T->GetEntry(lastev); |
T->GetEntry(lastev); |
| 3713 |
code = eh->GetCounter(); |
code = eh->GetCounter(); |
| 3714 |
checklast = 0; |
checklast = 0; |
| 3715 |
for(Iter = packetsNames.begin(); Iter != packetsNames.end(); Iter++){ |
for(Iter = packetsNames.begin(); Iter != packetsNames.end(); Iter++){ |
| 3716 |
if ( strcmp(*Iter,"Physics") ) checklast += code->Get(GetPacketType(*Iter)); |
if ( strcmp(*Iter,"Physics") ) checklast += code->Get(GetPacketType(*Iter)); |
| 3717 |
}; |
}; |
| 3718 |
if ( IsDebug() ) printf(" Check last is %i \n",checklast); |
if ( IsDebug() ) printf(" Check last is %i \n",checklast); |
| 3719 |
// |
// |
| 3720 |
if ( checkfirst == checklast ){ |
if ( checkfirst == checklast ){ |
| 3826 |
}; |
}; |
| 3827 |
// |
// |
| 3828 |
this->SetCommonGLRUN(firstTime,lastTime); |
this->SetCommonGLRUN(firstTime,lastTime); |
| 3829 |
|
this->SetPhysEndRunVariables(); |
| 3830 |
// |
// |
| 3831 |
if ( !IsRunAlreadyInserted() ){ |
if ( !IsRunAlreadyInserted() ){ |
| 3832 |
glrun->SetID(this->AssignRunID()); |
glrun->SetID(this->AssignRunID()); |
| 3866 |
if ( IsDebug() ) printf(" We have the runtrailer \n"); |
if ( IsDebug() ) printf(" We have the runtrailer \n"); |
| 3867 |
// |
// |
| 3868 |
this->SetCommonGLRUN(firstTime,lastTime); |
this->SetCommonGLRUN(firstTime,lastTime); |
| 3869 |
|
this->SetPhysEndRunVariables(); |
| 3870 |
// |
// |
| 3871 |
if ( !IsRunAlreadyInserted() ){ |
if ( !IsRunAlreadyInserted() ){ |
| 3872 |
glrun->SetID(this->AssignRunID()); |
glrun->SetID(this->AssignRunID()); |
| 4639 |
pkt1 = ph1->GetCounter(); |
pkt1 = ph1->GetCounter(); |
| 4640 |
fromtime = this->GetAbsTime(ph1->GetOrbitalTime()); |
fromtime = this->GetAbsTime(ph1->GetOrbitalTime()); |
| 4641 |
// |
// |
| 4642 |
// valid = 1; |
// valid = 1; |
| 4643 |
// // |
// // |
| 4644 |
// if ( caltrk1->unpackError != 0 && caltrk1->good0 == 0 ) valid = 0;// CONDITIONS ON THE GOODNESS OF THE CALIBRATION PKT1 |
// if ( caltrk1->unpackError != 0 && caltrk1->good0 == 0 ) valid = 0;// CONDITIONS ON THE GOODNESS OF THE CALIBRATION PKT1 |
| 4645 |
// |
// |
| 4646 |
// |
// |
| 4647 |
if ( this->PKT(pkt1) >= this->PKT(pktfirst) && this->PKT(pkt1) <= upperpkt && this->OBT(obt1) >= this->OBT(obtfirst) && this->OBT(obt1) <= upperobt ){ |
if ( this->PKT(pkt1) >= this->PKT(pktfirst) && this->PKT(pkt1) <= upperpkt && this->OBT(obt1) >= this->OBT(obtfirst) && this->OBT(obt1) <= upperobt ){ |
| 4670 |
pkt2 = ph2->GetCounter(); |
pkt2 = ph2->GetCounter(); |
| 4671 |
// |
// |
| 4672 |
if ( IsDebug() ) printf(" This is a trk calibration2 at obt %u pkt %u t2 is %u , t2t1cal is %u \n",obt2,pkt2,t2,t2t1cal); |
if ( IsDebug() ) printf(" This is a trk calibration2 at obt %u pkt %u t2 is %u , t2t1cal is %u \n",obt2,pkt2,t2,t2t1cal); |
| 4673 |
// if ( caltrk2->unpackError != 0 || caltrk2->good0 == 0 ) valid = 0; // CONDITIONS ON THE GOODNESS OF THE CALIBRATION PKT2 |
// if ( caltrk2->unpackError != 0 || caltrk2->good0 == 0 ) valid = 0; // CONDITIONS ON THE GOODNESS OF THE CALIBRATION PKT2 |
| 4674 |
// |
// |
| 4675 |
} else { |
} else { |
| 4676 |
// |
// |
| 4686 |
// if ( (this->PKT(pkt2) < this->PKT(pktfirst) || this->PKT(pkt2) > upperpkt) && (this->OBT(obt2) < this->OBT(obtfirst) || this->OBT(obt2) > upperobt) ){ |
// if ( (this->PKT(pkt2) < this->PKT(pktfirst) || this->PKT(pkt2) > upperpkt) && (this->OBT(obt2) < this->OBT(obtfirst) || this->OBT(obt2) > upperobt) ){ |
| 4687 |
|
|
| 4688 |
// EMILIANO |
// EMILIANO |
| 4689 |
// if ( (this->PKT(pkt2) < this->PKT(pktfirst) || this->PKT(pkt2) > upperpkt) || (this->OBT(obt2) < this->OBT(obtfirst) || this->OBT(obt2) > upperobt) ){ |
// if ( (this->PKT(pkt2) < this->PKT(pktfirst) || this->PKT(pkt2) > upperpkt) || (this->OBT(obt2) < this->OBT(obtfirst) || this->OBT(obt2) > upperobt) ){ |
| 4690 |
// // if ( this->PKT(pkt2) < this->PKT(pktfirst) && this->OBT(obt2) < this->OBT(obtfirst) ){ |
// // if ( this->PKT(pkt2) < this->PKT(pktfirst) && this->OBT(obt2) < this->OBT(obtfirst) ){ |
| 4691 |
// if ( IsDebug() ) printf(" running out of vector without finding the corresponding calibration, sig \n"); |
// if ( IsDebug() ) printf(" running out of vector without finding the corresponding calibration, sig \n"); |
| 4692 |
// // |
// // |
| 4693 |
// // running out of vector without finding the corresponding calibration, sig |
// // running out of vector without finding the corresponding calibration, sig |
| 4694 |
// // |
// // |
| 4695 |
// pret2 = t2; |
// pret2 = t2; |
| 4696 |
// obt2 = 0; |
// obt2 = 0; |
| 4697 |
// // pkt2 = pkt1+2; |
// // pkt2 = pkt1+2; |
| 4698 |
// pkt2 = 0; |
// pkt2 = 0; |
| 4699 |
// t2t1cal = t1+1; |
// t2t1cal = t1+1; |
| 4700 |
// }; |
// }; |
| 4701 |
|
|
| 4702 |
|
|
| 4703 |
// |
// |
| 4804 |
// |
// |
| 4805 |
fromtime = this->GetAbsTime(ph2->GetOrbitalTime()); |
fromtime = this->GetAbsTime(ph2->GetOrbitalTime()); |
| 4806 |
valid = 0; |
valid = 0; |
| 4807 |
// if ( this->PKT(pkt1) >= this->PKT(pktfirst) && this->PKT(pkt1) <= upperpkt && this->OBT(obt1) >= this->OBT(obtfirst) && this->OBT(obt1) <= upperobt ){ |
// if ( this->PKT(pkt1) >= this->PKT(pktfirst) && this->PKT(pkt1) <= upperpkt && this->OBT(obt1) >= this->OBT(obtfirst) && this->OBT(obt1) <= upperobt ){ |
| 4808 |
// EMILIANO |
// EMILIANO |
| 4809 |
if ( this->PKT(pkt2) >= this->PKT(pktfirst) && this->PKT(pkt2 <= upperpkt) && this->OBT(obt2) >= this->OBT(obtfirst) && this->OBT(obt2) <= upperobt ){ |
if ( this->PKT(pkt2) >= this->PKT(pktfirst) && this->PKT(pkt2 <= upperpkt) && this->OBT(obt2) >= this->OBT(obtfirst) && this->OBT(obt2) <= upperobt ){ |
| 4810 |
// if ( this->PKT(pkt2) > this->PKT(pktfirst) || this->OBT(obt2) > this->OBT(obtfirst) ){ |
// if ( this->PKT(pkt2) > this->PKT(pktfirst) || this->OBT(obt2) > this->OBT(obtfirst) ){ |
| 4811 |
// |
// |
| 5120 |
<< " RM_ACQ_SETTING_MODE=" << glrun->GetRM_ACQ_SETTING_MODE()<< " , " |
<< " RM_ACQ_SETTING_MODE=" << glrun->GetRM_ACQ_SETTING_MODE()<< " , " |
| 5121 |
<< " TRK_CALIB_USED=" << glrun->GetTRK_CALIB_USED()<< " , " |
<< " TRK_CALIB_USED=" << glrun->GetTRK_CALIB_USED()<< " , " |
| 5122 |
<< " CAL_DSP_MASK=" << glrun->GetCAL_DSP_MASK()<< " , " |
<< " CAL_DSP_MASK=" << glrun->GetCAL_DSP_MASK()<< " , " |
| 5123 |
<< " LAST_TIMESYNC=" << glrun->GetLAST_TIMESYNC()<< " , " |
<< " LAST_TIMESYNC=" << glrun->GetLAST_TIMESYNC()<< " , "; |
| 5124 |
<< " OBT_TIMESYNC=" << glrun->GetOBT_TIMESYNC() |
// |
| 5125 |
<< " WHERE ID=" << myid[u] << ";"; |
if ( glrun->GetPHYSENDRUN_MASK_S3S2S12() ) |
| 5126 |
|
oss << " PHYSENDRUN_MASK_S3S2S12=" << glrun->GetPHYSENDRUN_MASK_S3S2S12() << " , "; |
| 5127 |
|
if ( glrun->GetPHYSENDRUN_MASK_S11CRC() ) |
| 5128 |
|
oss << " PHYSENDRUN_MASK_S11CRC=" << glrun->GetPHYSENDRUN_MASK_S11CRC() << " , "; |
| 5129 |
|
// |
| 5130 |
|
oss << " OBT_TIMESYNC=" << glrun->GetOBT_TIMESYNC(); |
| 5131 |
|
oss << " WHERE ID=" << myid[u] << ";"; |
| 5132 |
conn->Query(oss.str().c_str()); |
conn->Query(oss.str().c_str()); |
| 5133 |
}; |
}; |
| 5134 |
// |
// |
| 5139 |
for (UInt_t u=1; u <= nid ; u++){ |
for (UInt_t u=1; u <= nid ; u++){ |
| 5140 |
oss.str(""); |
oss.str(""); |
| 5141 |
oss << "UPDATE GL_RUN_FRAGMENTS SET " |
oss << "UPDATE GL_RUN_FRAGMENTS SET " |
| 5142 |
<< " RUNHEADER_TIME=" << glrun->GetRUNHEADER_TIME()<< " , " |
<< " RUNHEADER_TIME=" << glrun->GetRUNHEADER_TIME()<< " , "; |
| 5143 |
<< " RUNHEADER_OBT=" << glrun->GetRUNHEADER_OBT()<< " , " |
// |
| 5144 |
|
if ( glrun->GetPHYSENDRUN_MASK_S3S2S12() ) |
| 5145 |
|
oss << " PHYSENDRUN_MASK_S3S2S12=" << glrun->GetPHYSENDRUN_MASK_S3S2S12()<< " , "; |
| 5146 |
|
if ( glrun->GetPHYSENDRUN_MASK_S11CRC() ) |
| 5147 |
|
oss << " PHYSENDRUN_MASK_S11CRC=" << glrun->GetPHYSENDRUN_MASK_S11CRC()<< " , "; |
| 5148 |
|
// |
| 5149 |
|
oss << " RUNHEADER_OBT=" << glrun->GetRUNHEADER_OBT()<< " , " |
| 5150 |
<< " RUNHEADER_PKT=" << glrun->GetRUNHEADER_PKT()<< ";"; |
<< " RUNHEADER_PKT=" << glrun->GetRUNHEADER_PKT()<< ";"; |
| 5151 |
conn->Query(oss.str().c_str()); |
conn->Query(oss.str().c_str()); |
| 5152 |
}; |
}; |
| 5169 |
<< " RUNTRAILER_TIME=" << glrun->GetRUNTRAILER_TIME()<< " , " |
<< " RUNTRAILER_TIME=" << glrun->GetRUNTRAILER_TIME()<< " , " |
| 5170 |
<< " RUNTRAILER_OBT=" << glrun->GetRUNTRAILER_OBT()<< " , " |
<< " RUNTRAILER_OBT=" << glrun->GetRUNTRAILER_OBT()<< " , " |
| 5171 |
<< " RUNTRAILER_PKT=" << glrun->GetRUNTRAILER_PKT()<< " , " |
<< " RUNTRAILER_PKT=" << glrun->GetRUNTRAILER_PKT()<< " , " |
| 5172 |
<< " PKT_COUNTER=" << glrun->GetPKT_COUNTER()<< " , " |
<< " PKT_COUNTER=" << glrun->GetPKT_COUNTER()<< " , "; |
| 5173 |
<< " PKT_READY_COUNTER=" << glrun->GetPKT_READY_COUNTER() |
// |
| 5174 |
|
if ( glrun->GetPHYSENDRUN_MASK_S3S2S12() ){ |
| 5175 |
|
oss << " PHYSENDRUN_MASK_S3S2S12=" << glrun->GetPHYSENDRUN_MASK_S3S2S12()<< " , "; }; |
| 5176 |
|
if ( glrun->GetPHYSENDRUN_MASK_S11CRC() ) { |
| 5177 |
|
oss << " PHYSENDRUN_MASK_S11CRC=" << glrun->GetPHYSENDRUN_MASK_S11CRC()<< " , "; }; |
| 5178 |
|
// |
| 5179 |
|
oss << " PKT_READY_COUNTER=" << glrun->GetPKT_READY_COUNTER() |
| 5180 |
<< " WHERE ID=" << myid[u] << ";"; |
<< " WHERE ID=" << myid[u] << ";"; |
| 5181 |
conn->Query(oss.str().c_str()); |
conn->Query(oss.str().c_str()); |
| 5182 |
}; |
}; |
| 5189 |
oss.str(""); |
oss.str(""); |
| 5190 |
oss << "UPDATE GL_RUN_FRAGMENTS SET " |
oss << "UPDATE GL_RUN_FRAGMENTS SET " |
| 5191 |
<< " RUNTRAILER_TIME=" << glrun->GetRUNTRAILER_TIME()<< " , " |
<< " RUNTRAILER_TIME=" << glrun->GetRUNTRAILER_TIME()<< " , " |
| 5192 |
<< " RUNTRAILER_OBT=" << glrun->GetRUNTRAILER_OBT()<< " , " |
<< " RUNTRAILER_OBT=" << glrun->GetRUNTRAILER_OBT()<< " , "; |
| 5193 |
<< " RUNTRAILER_PKT=" << glrun->GetRUNTRAILER_PKT()<< ";"; |
// |
| 5194 |
|
if ( glrun->GetPHYSENDRUN_MASK_S3S2S12() ){ |
| 5195 |
|
oss << " PHYSENDRUN_MASK_S3S2S12=" << glrun->GetPHYSENDRUN_MASK_S3S2S12()<< " , "; }; |
| 5196 |
|
if ( glrun->GetPHYSENDRUN_MASK_S11CRC() ){ |
| 5197 |
|
oss << " PHYSENDRUN_MASK_S11CRC=" << glrun->GetPHYSENDRUN_MASK_S11CRC()<< " , "; }; |
| 5198 |
|
// |
| 5199 |
|
oss << " RUNTRAILER_PKT=" << glrun->GetRUNTRAILER_PKT()<< ";"; |
| 5200 |
conn->Query(oss.str().c_str()); |
conn->Query(oss.str().c_str()); |
| 5201 |
}; |
}; |
| 5202 |
}; |
}; |
| 5355 |
glrun->SetID_RUN_FRAG(glrun->GetID()); |
glrun->SetID_RUN_FRAG(glrun->GetID()); |
| 5356 |
glrun->Fill_GL_RUN(conn); |
glrun->Fill_GL_RUN(conn); |
| 5357 |
// |
// |
| 5358 |
// oss.str(""); |
// oss.str(""); |
| 5359 |
// oss << " SELECT ID FROM GL_RUN WHERE " |
// oss << " SELECT ID FROM GL_RUN WHERE " |
| 5360 |
// << " BOOT_NUMBER=" << glrun->GetBOOT_NUMBER() << " AND " |
// << " BOOT_NUMBER=" << glrun->GetBOOT_NUMBER() << " AND " |
| 5361 |
// << " RUNHEADER_PKT=" << (UInt_t)glrun->GetRUNHEADER_PKT() << " AND " |
// << " RUNHEADER_PKT=" << (UInt_t)glrun->GetRUNHEADER_PKT() << " AND " |
| 5362 |
// << " RUNTRAILER_PKT=" << (UInt_t)glrun->GetRUNTRAILER_PKT() << " AND " |
// << " RUNTRAILER_PKT=" << (UInt_t)glrun->GetRUNTRAILER_PKT() << " AND " |
| 5363 |
// << " RUNHEADER_OBT=" << (UInt_t)glrun->GetRUNHEADER_OBT() << " AND " |
// << " RUNHEADER_OBT=" << (UInt_t)glrun->GetRUNHEADER_OBT() << " AND " |
| 5364 |
// << " RUNTRAILER_OBT=" << (UInt_t)glrun->GetRUNTRAILER_OBT() << "; "; |
// << " RUNTRAILER_OBT=" << (UInt_t)glrun->GetRUNTRAILER_OBT() << "; "; |
| 5365 |
// // |
// // |
| 5366 |
// if ( IsDebug() ) printf(" Look for the ID of the inserted run: query is \n %s \n",oss.str().c_str()); |
// if ( IsDebug() ) printf(" Look for the ID of the inserted run: query is \n %s \n",oss.str().c_str()); |
| 5367 |
// result2 = conn->Query(oss.str().c_str()); |
// result2 = conn->Query(oss.str().c_str()); |
| 5368 |
// // |
// // |
| 5369 |
// if ( !result2 ) throw -4; |
// if ( !result2 ) throw -4; |
| 5370 |
// // |
// // |
| 5371 |
// row2 = result2->Next(); |
// row2 = result2->Next(); |
| 5372 |
// // |
// // |
| 5373 |
// if ( !row2 ) throw -25; |
// if ( !row2 ) throw -25; |
| 5374 |
// // |
// // |
| 5375 |
// oss.str(""); |
// oss.str(""); |
| 5376 |
// oss << " UPDATE GL_RUN SET ID_RUN_FRAG = " << row2->GetField(0) << " WHERE ID = " << row2->GetField(0); |
// oss << " UPDATE GL_RUN SET ID_RUN_FRAG = " << row2->GetField(0) << " WHERE ID = " << row2->GetField(0); |
| 5377 |
// if ( IsDebug() ) printf(" Update the ID_RUN_FRAG of the inserted run: query is \n %s \n",oss.str().c_str()); |
// if ( IsDebug() ) printf(" Update the ID_RUN_FRAG of the inserted run: query is \n %s \n",oss.str().c_str()); |
| 5378 |
// result2 = conn->Query(oss.str().c_str()); |
// result2 = conn->Query(oss.str().c_str()); |
| 5379 |
// // |
// // |
| 5380 |
// if ( !result2 ) throw -4; |
// if ( !result2 ) throw -4; |
| 5381 |
// |
// |
| 5382 |
moved++; |
moved++; |
| 5383 |
// |
// |
| 5389 |
// |
// |
| 5390 |
// |
// |
| 5391 |
glrun->DeleteRun(conn,(UInt_t)atoll(row->GetField(0)),"GL_RUN_FRAGMENTS"); |
glrun->DeleteRun(conn,(UInt_t)atoll(row->GetField(0)),"GL_RUN_FRAGMENTS"); |
| 5392 |
// oss.str(""); |
// oss.str(""); |
| 5393 |
// oss << " DELETE from GL_RUN_FRAGMENTS where ID = " << row->GetField(0); |
// oss << " DELETE from GL_RUN_FRAGMENTS where ID = " << row->GetField(0); |
| 5394 |
// if ( IsDebug() ) printf(" Clean the GL_RUN_FRAGMENTS table: query is \n %s \n",oss.str().c_str()); |
// if ( IsDebug() ) printf(" Clean the GL_RUN_FRAGMENTS table: query is \n %s \n",oss.str().c_str()); |
| 5395 |
// result2 = conn->Query(oss.str().c_str()); |
// result2 = conn->Query(oss.str().c_str()); |
| 5396 |
// // |
// // |
| 5397 |
// if ( !result2 ) throw -4; |
// if ( !result2 ) throw -4; |
| 5398 |
// // |
// // |
| 5399 |
row = result->Next(); |
row = result->Next(); |
| 5400 |
}; |
}; |
| 5401 |
}; |
}; |
| 5540 |
GL_RUN* this_run = new GL_RUN(); |
GL_RUN* this_run = new GL_RUN(); |
| 5541 |
GL_RUN* next_run = new GL_RUN(); |
GL_RUN* next_run = new GL_RUN(); |
| 5542 |
Int_t nseq_max = 1000; |
Int_t nseq_max = 1000; |
| 5543 |
// UInt_t* sequence = new UInt_t[100]; |
// UInt_t* sequence = new UInt_t[100]; |
| 5544 |
vector<UInt_t> sequence(nseq_max); |
vector<UInt_t> sequence(nseq_max); |
| 5545 |
Int_t nseq = 0; |
Int_t nseq = 0; |
| 5546 |
Bool_t CHECK = false; |
Bool_t CHECK = false; |
| 5555 |
// --------------------------------------------------------------------------------- |
// --------------------------------------------------------------------------------- |
| 5556 |
while(1){ |
while(1){ |
| 5557 |
|
|
| 5558 |
row = result->Next(); |
row = result->Next(); |
| 5559 |
if( row == NULL ) break; |
if( row == NULL ) break; |
| 5560 |
|
|
| 5561 |
//------------ |
//------------ |
| 5562 |
//get run info |
//get run info |
| 5563 |
//------------ |
//------------ |
| 5564 |
this_run->Set_GL_RUN(row); |
this_run->Set_GL_RUN(row); |
| 5565 |
|
|
| 5566 |
Bool_t this_BAD = false; |
Bool_t this_BAD = false; |
| 5567 |
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; |
| 5568 |
else if (this_run->GetTRK_CALIB_USED() == 104) this_ONLINE = false; |
else if (this_run->GetTRK_CALIB_USED() == 104) this_ONLINE = false; |
| 5569 |
else{ |
else{ |
| 5570 |
// printf("Missing or corrupted header!! \n"); |
// printf("Missing or corrupted header!! \n"); |
| 5571 |
this_ONLINE = false; |
this_ONLINE = false; |
| 5572 |
this_BAD = true; |
this_BAD = true; |
| 5573 |
}; |
}; |
| 5574 |
|
|
| 5575 |
//----------------------------------- |
//----------------------------------- |
| 5576 |
//compare with previous(next in time) |
//compare with previous(next in time) |
| 5577 |
//----------------------------------- |
//----------------------------------- |
| 5578 |
CHECK = false; |
CHECK = false; |
| 5579 |
UInt_t interval=0; |
UInt_t interval=0; |
| 5580 |
|
|
| 5581 |
if( nrow != 0){ |
if( nrow != 0){ |
| 5582 |
|
|
| 5583 |
|
|
| 5584 |
t1 = this_run->GetRUNTRAILER_TIME(); |
t1 = this_run->GetRUNTRAILER_TIME(); |
| 5585 |
t2 = next_run->GetRUNHEADER_TIME(); |
t2 = next_run->GetRUNHEADER_TIME(); |
| 5586 |
interval = (t2-t1); |
interval = (t2-t1); |
| 5587 |
|
|
| 5588 |
if(this_ONLINE && next_ONLINE){ // this: ON-LINE + next: ON-LINE |
if(this_ONLINE && next_ONLINE){ // this: ON-LINE + next: ON-LINE |
| 5589 |
|
|
| 5590 |
if( this_run->ID == next_run->ID_RUN_FRAG ) interval = 0; //=> run fragments |
if( this_run->ID == next_run->ID_RUN_FRAG ) interval = 0; //=> run fragments |
| 5591 |
|
|
| 5592 |
if( interval >= calibtime )CHECK = true; //more than calibtime s => there might be a calibration |
if( interval >= calibtime )CHECK = true; //more than calibtime s => there might be a calibration |
| 5593 |
|
|
| 5594 |
if( !CHECK && this_run->VALIDATION ){ |
if( !CHECK && this_run->VALIDATION ){ |
| 5595 |
for (Int_t irun = 0; irun < nseq; irun++)assignVALIDATION(sequence[irun],true); |
for (Int_t irun = 0; irun < nseq; irun++)assignVALIDATION(sequence[irun],true); |
| 5596 |
nseq=0; |
nseq=0; |
| 5597 |
} |
} |
| 5598 |
|
|
| 5599 |
}else if( !this_ONLINE && next_ONLINE) { // this: DEFAULT + next:ON-LINE |
}else if( !this_ONLINE && next_ONLINE) { // this: DEFAULT + next:ON-LINE |
| 5600 |
|
|
| 5601 |
CHECK = true; |
CHECK = true; |
| 5602 |
|
|
| 5603 |
}else if( !next_ONLINE ){ // this:ANY + next:DEFAULT |
}else if( !next_ONLINE ){ // this:ANY + next:DEFAULT |
| 5604 |
|
|
| 5605 |
assignVALIDATION(next_run->ID,true); |
assignVALIDATION(next_run->ID,true); |
| 5606 |
nseq=0; |
nseq=0; |
| 5607 |
} |
} |
| 5608 |
} |
} |
| 5609 |
|
|
| 5610 |
//---------------------------- |
//---------------------------- |
| 5611 |
//check run sequence for calib |
//check run sequence for calib |
| 5612 |
//---------------------------- |
//---------------------------- |
| 5613 |
if( CHECK ){ |
if( CHECK ){ |
| 5614 |
// check if calibration exists |
// check if calibration exists |
| 5615 |
if ( IsDebug() )printf("DT %i ===> CHECK Missing calibration\n",interval); |
if ( IsDebug() )printf("DT %i ===> CHECK Missing calibration\n",interval); |
| 5616 |
Bool_t MISSING = MissingTRK_CALIB(t1,t2); |
Bool_t MISSING = MissingTRK_CALIB(t1,t2); |
| 5617 |
for (Int_t irun = 0; irun < nseq; irun++)assignVALIDATION(sequence[irun],!MISSING); |
for (Int_t irun = 0; irun < nseq; irun++)assignVALIDATION(sequence[irun],!MISSING); |
| 5618 |
nseq=0; |
nseq=0; |
| 5619 |
}; |
}; |
| 5620 |
//-------------- |
//-------------- |
| 5621 |
//store run info |
//store run info |
| 5622 |
//-------------- |
//-------------- |
| 5623 |
*next_run = *this_run; |
*next_run = *this_run; |
| 5624 |
next_ONLINE = this_ONLINE; |
next_ONLINE = this_ONLINE; |
| 5625 |
if( !this_BAD ){ |
if( !this_BAD ){ |
| 5626 |
if(nseq < nseq_max){ |
if(nseq < nseq_max){ |
| 5627 |
sequence[nseq] = this_run->ID; |
sequence[nseq] = this_run->ID; |
| 5628 |
nseq++; |
nseq++; |
| 5629 |
}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); |
| 5630 |
}; |
}; |
| 5631 |
|
|
| 5632 |
if ( IsDebug() ) printf("%i Run %u \n",nrow,this_run->ID); |
if ( IsDebug() ) printf("%i Run %u \n",nrow,this_run->ID); |
| 5633 |
nrow++; |
nrow++; |
| 5634 |
|
|
| 5635 |
}; |
}; |
| 5636 |
delete this_run; |
delete this_run; |
| 5646 |
*/ |
*/ |
| 5647 |
Bool_t PamelaDBOperations::MissingTRK_CALIB(UInt_t t1,UInt_t t2){ |
Bool_t PamelaDBOperations::MissingTRK_CALIB(UInt_t t1,UInt_t t2){ |
| 5648 |
|
|
| 5649 |
GL_TRK_CALIB* trkcalib = new GL_TRK_CALIB(); |
GL_TRK_CALIB* trkcalib = new GL_TRK_CALIB(); |
| 5650 |
|
|
| 5651 |
// get the closest VALIDATED calibration before the run start (t2) |
// get the closest VALIDATED calibration before the run start (t2) |
| 5652 |
if ( trkcalib->Query_GL_TRK_CALIB(t2, conn) )return(true); //>>> missing |
if ( trkcalib->Query_GL_TRK_CALIB(t2, conn) )return(true); //>>> missing |
| 5653 |
|
|
| 5654 |
if ( trkcalib->TO_TIME < t2 ) return(true); //>>> missing |
if ( trkcalib->TO_TIME < t2 ) return(true); //>>> missing |
| 5655 |
|
|
| 5656 |
//============================================================== |
//============================================================== |
| 5657 |
// Check is done first on the basis of time between calibration, |
// Check is done first on the basis of time between calibration, |
| 5658 |
// which should be equal to the time between ascending-nodes. |
// which should be equal to the time between ascending-nodes. |
| 5659 |
//============================================================== |
//============================================================== |
| 5660 |
if ( t2 - trkcalib->FROM_TIME > 5700) { |
if ( t2 - trkcalib->FROM_TIME > 5700) { |
| 5661 |
if ( IsDebug() )printf("Long time between calib and run start %u :-( ==> there might be a missing calib \n",t2 - trkcalib->FROM_TIME); |
if ( IsDebug() )printf("Long time between calib and run start %u :-( ==> there might be a missing calib \n",t2 - trkcalib->FROM_TIME); |
| 5662 |
//============================================================== |
//============================================================== |
| 5663 |
// there might be a missing calibration, due to: |
// there might be a missing calibration, due to: |
| 5664 |
// - MM full |
// - MM full |
| 5665 |
// - corrupted packets |
// - corrupted packets |
| 5666 |
// - loss of data |
// - loss of data |
| 5667 |
// There is an exception in case a download was done during ascending node |
// There is an exception in case a download was done during ascending node |
| 5668 |
//============================================================== |
//============================================================== |
| 5669 |
Bool_t DOWNLOAD = false; |
Bool_t DOWNLOAD = false; |
| 5670 |
// check if the calib was skipped becouse of download .... DA FARE!! |
// check if the calib was skipped becouse of download .... DA FARE!! |
| 5671 |
if(DOWNLOAD)return(false); |
if(DOWNLOAD)return(false); |
| 5672 |
|
|
| 5673 |
return(true); //>>> missing |
return(true); //>>> missing |
| 5674 |
|
|
| 5675 |
}; |
}; |
| 5676 |
|
|
| 5677 |
//============================================================== |
//============================================================== |
| 5678 |
// If the last calibration is close to the run less than this time, |
// If the last calibration is close to the run less than this time, |
| 5679 |
// it is enough to say that there are no missing calibrations |
// it is enough to say that there are no missing calibrations |
| 5680 |
//============================================================== |
//============================================================== |
| 5681 |
// the long time interval bewteen runs might be due to download |
// the long time interval bewteen runs might be due to download |
| 5682 |
if ( IsDebug() )printf("Short time between calib and run start %u :-) ==> OK! \n",t2 - trkcalib->FROM_TIME); |
if ( IsDebug() )printf("Short time between calib and run start %u :-) ==> OK! \n",t2 - trkcalib->FROM_TIME); |
| 5683 |
return(false); |
return(false); |
| 5684 |
|
|
| 5685 |
}; |
}; |
| 5686 |
/** |
/** |
| 5689 |
* @param validation true/false |
* @param validation true/false |
| 5690 |
*/ |
*/ |
| 5691 |
Int_t PamelaDBOperations::assignVALIDATION(UInt_t idrun, Bool_t validation){ |
Int_t PamelaDBOperations::assignVALIDATION(UInt_t idrun, Bool_t validation){ |
| 5692 |
TSQLResult *result = 0; |
TSQLResult *result = 0; |
| 5693 |
stringstream oss; |
stringstream oss; |
| 5694 |
oss.str(""); |
oss.str(""); |
| 5695 |
oss << " UPDATE GL_RUN SET VALIDATION="<< (UInt_t)validation <<" WHERE ID= " << idrun << ";"; |
oss << " UPDATE GL_RUN SET VALIDATION="<< (UInt_t)validation <<" WHERE ID= " << idrun << ";"; |
| 5696 |
// |
// |
| 5697 |
// if ( IsDebug() ) |
// if ( IsDebug() ) |
| 5698 |
// printf(" Set VALIDATION = %i for run %i \n",validation,idrun); |
// printf(" Set VALIDATION = %i for run %i \n",validation,idrun); |
| 5699 |
if ( IsDebug() )printf(" Query: %s \n",oss.str().c_str()); |
if ( IsDebug() )printf(" Query: %s \n",oss.str().c_str()); |
| 5700 |
result = conn->Query(oss.str().c_str()); |
result = conn->Query(oss.str().c_str()); |
| 5701 |
if ( !result ) throw -4; |
if ( !result ) throw -4; |
| 5702 |
return(0); |
return(0); |
| 5703 |
} |
} |
| 5704 |
|
|
| 5705 |
|
|
| 6344 |
**/ |
**/ |
| 6345 |
UInt_t PamelaDBOperations::ValidateTrkCalib( CalibTrk1Event* caltrk, EventHeader *eh ){ |
UInt_t PamelaDBOperations::ValidateTrkCalib( CalibTrk1Event* caltrk, EventHeader *eh ){ |
| 6346 |
|
|
| 6347 |
Int_t vorder[]={5,5,3,3,4,4,2,2,1,1,0,0}; |
Int_t vorder[]={5,5,3,3,4,4,2,2,1,1,0,0}; |
| 6348 |
UInt_t timeaftercalib=120000; //2000; |
UInt_t timeaftercalib=120000; //2000; |
| 6349 |
// ---------- |
// ---------- |
| 6350 |
// Check CRCs |
// Check CRCs |
| 6351 |
// ---------- |
// ---------- |
| 6352 |
for(Int_t ipkt=0; ipkt<6; ipkt++){ |
for(Int_t ipkt=0; ipkt<6; ipkt++){ |
| 6353 |
if( caltrk->crc_hcal[ipkt] )return 0; // :-( |
if( caltrk->crc_hcal[ipkt] )return 0; // :-( |
| 6354 |
for(Int_t ilad=0; ilad<3; ilad++)if( caltrk->crc_cal[ipkt][ilad] )return 0; // :-( |
for(Int_t ilad=0; ilad<3; ilad++)if( caltrk->crc_cal[ipkt][ilad] )return 0; // :-( |
| 6355 |
} |
} |
| 6356 |
// ----------------------- |
// ----------------------- |
| 6357 |
// Check missing packets: |
// Check missing packets: |
| 6358 |
// ----------------------- |
// ----------------------- |
| 6359 |
// Readout order: |
// Readout order: |
| 6360 |
// ------------------ |
// ------------------ |
| 6361 |
// DSP packet board |
// DSP packet board |
| 6362 |
// ------------------ |
// ------------------ |
| 6363 |
// 12 0 1 |
// 12 0 1 |
| 6364 |
// 10 1 1 |
// 10 1 1 |
| 6365 |
// 8 2 1 |
// 8 2 1 |
| 6366 |
// 4 3 1 |
// 4 3 1 |
| 6367 |
// 6 4 1 |
// 6 4 1 |
| 6368 |
// 2 5 1 |
// 2 5 1 |
| 6369 |
// ------------------ |
// ------------------ |
| 6370 |
// 11 0 2 |
// 11 0 2 |
| 6371 |
// 9 1 2 |
// 9 1 2 |
| 6372 |
// 7 2 2 |
// 7 2 2 |
| 6373 |
// 3 3 2 |
// 3 3 2 |
| 6374 |
// 5 4 2 |
// 5 4 2 |
| 6375 |
// 1 5 2 |
// 1 5 2 |
| 6376 |
// ------------------ |
// ------------------ |
| 6377 |
// ------------------------------------------------- |
// ------------------------------------------------- |
| 6378 |
// Check if it is first or second calibration packet |
// Check if it is first or second calibration packet |
| 6379 |
// ------------------------------------------------- |
// ------------------------------------------------- |
| 6380 |
UInt_t build=0; |
UInt_t build=0; |
| 6381 |
TString classname = caltrk->GetName(); |
TString classname = caltrk->GetName(); |
| 6382 |
UInt_t base=0; |
UInt_t base=0; |
| 6383 |
UInt_t mask=0; |
UInt_t mask=0; |
| 6384 |
if(classname.Contains("CalibTrk1Event")){ |
if(classname.Contains("CalibTrk1Event")){ |
| 6385 |
base=12; |
base=12; |
| 6386 |
mask=0x03F000; |
mask=0x03F000; |
| 6387 |
} |
} |
| 6388 |
if(classname.Contains("CalibTrk2Event")){ |
if(classname.Contains("CalibTrk2Event")){ |
| 6389 |
base=18; |
base=18; |
| 6390 |
mask=0xFC0000; |
mask=0xFC0000; |
| 6391 |
} |
} |
| 6392 |
// ------------------------------------------------- |
// ------------------------------------------------- |
| 6393 |
// Count number of packets and set build variable |
// Count number of packets and set build variable |
| 6394 |
// ------------------------------------------------- |
// ------------------------------------------------- |
| 6395 |
Int_t npkts=0; |
Int_t npkts=0; |
| 6396 |
for(Int_t ipkt=0; ipkt<6; ipkt++){ |
for(Int_t ipkt=0; ipkt<6; ipkt++){ |
| 6397 |
if(caltrk->DSPnumber[ipkt]>0 && caltrk->DSPnumber[ipkt]<=12){ |
if(caltrk->DSPnumber[ipkt]>0 && caltrk->DSPnumber[ipkt]<=12){ |
| 6398 |
npkts++; |
npkts++; |
| 6399 |
build = build | ( 1<<(base+vorder[caltrk->DSPnumber[ipkt]-1]) ); |
build = build | ( 1<<(base+vorder[caltrk->DSPnumber[ipkt]-1]) ); |
| 6400 |
} |
} |
| 6401 |
} |
} |
| 6402 |
// if( npkts==6 )return 1; // :-) |
// if( npkts==6 )return 1; // :-) |
| 6403 |
|
|
| 6404 |
|
// cout << classname << " "<<eh->GetPscuHeader()->GetOrbitalTime()<<endl; |
| 6405 |
|
|
| 6406 |
// cout << classname << " "<<eh->GetPscuHeader()->GetOrbitalTime()<<endl; |
// ----------------------------------------------- |
| 6407 |
|
// If missing packets: check the acq configuration |
| 6408 |
|
// (some DSPs might be excluded from acquisition) |
| 6409 |
|
// ----------------------------------------------- |
| 6410 |
|
|
| 6411 |
|
// ----------------------------------------------- |
| 6412 |
|
// retrieve the first run header after calib |
| 6413 |
|
// ----------------------------------------------- |
| 6414 |
|
PacketType *pctp; |
| 6415 |
|
EventCounter *cod; |
| 6416 |
|
cod = eh->GetCounter(); |
| 6417 |
|
Int_t irun = cod->Get(pctp->RunHeader); |
| 6418 |
|
TTree *rh=(TTree*)file->Get("RunHeader"); |
| 6419 |
|
if ( !rh || rh->IsZombie() ) throw -17; |
| 6420 |
|
if( rh->GetEntries() == irun ){ |
| 6421 |
|
if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) no runs after calib (1) -- cannot validate :-( "<<endl; |
| 6422 |
|
return 0; // :-( |
| 6423 |
|
} |
| 6424 |
|
|
| 6425 |
// ----------------------------------------------- |
RunHeaderEvent *run = 0; |
| 6426 |
// If missing packets: check the acq configuration |
EventHeader *hrun = 0; |
| 6427 |
// (some DSPs might be excluded from acquisition) |
rh->SetBranchAddress("RunHeader", &run); |
| 6428 |
// ----------------------------------------------- |
rh->SetBranchAddress("Header", &hrun); |
| 6429 |
|
rh->GetEntry(irun); |
| 6430 |
// ----------------------------------------------- |
// cout << classname << " "<<eh->GetPscuHeader()->GetOrbitalTime() << " Run " << hrun->GetPscuHeader()->GetOrbitalTime() <<endl; |
| 6431 |
// retrieve the first run header after calib |
|
| 6432 |
// ----------------------------------------------- |
if( OBT(hrun->GetPscuHeader()->GetOrbitalTime()) < OBT(eh->GetPscuHeader()->GetOrbitalTime())){ |
| 6433 |
PacketType *pctp; |
if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) no runs after calib (2) -- cannot validate :-( "<<endl; |
| 6434 |
EventCounter *cod; |
return 0; // :-( |
| 6435 |
cod = eh->GetCounter(); |
} |
|
Int_t irun = cod->Get(pctp->RunHeader); |
|
|
TTree *rh=(TTree*)file->Get("RunHeader"); |
|
|
if ( !rh || rh->IsZombie() ) throw -17; |
|
|
if( rh->GetEntries() == irun ){ |
|
|
if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) no runs after calib (1) -- cannot validate :-( "<<endl; |
|
|
return 0; // :-( |
|
|
} |
|
|
|
|
|
RunHeaderEvent *run = 0; |
|
|
EventHeader *hrun = 0; |
|
|
rh->SetBranchAddress("RunHeader", &run); |
|
|
rh->SetBranchAddress("Header", &hrun); |
|
|
rh->GetEntry(irun); |
|
|
// cout << classname << " "<<eh->GetPscuHeader()->GetOrbitalTime() << " Run " << hrun->GetPscuHeader()->GetOrbitalTime() <<endl; |
|
|
|
|
|
if( OBT(hrun->GetPscuHeader()->GetOrbitalTime()) < OBT(eh->GetPscuHeader()->GetOrbitalTime())){ |
|
|
if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) no runs after calib (2) -- cannot validate :-( "<<endl; |
|
|
return 0; // :-( |
|
|
} |
|
| 6436 |
|
|
| 6437 |
if( !run->RM_ACQ_AFTER_CALIB ){ |
if( !run->RM_ACQ_AFTER_CALIB ){ |
| 6438 |
if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) RM_ACQ_AFTER_CALIB=0 -- cannot validate :-( "<<endl; |
if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) RM_ACQ_AFTER_CALIB=0 -- cannot validate :-( "<<endl; |
| 6439 |
return 0; // :-( |
return 0; // :-( |
| 6440 |
} |
} |
| 6441 |
|
|
| 6442 |
UInt_t dtime = OBT(hrun->GetPscuHeader()->GetOrbitalTime()) - OBT(eh->GetPscuHeader()->GetOrbitalTime()); |
UInt_t dtime = OBT(hrun->GetPscuHeader()->GetOrbitalTime()) - OBT(eh->GetPscuHeader()->GetOrbitalTime()); |
| 6443 |
if( dtime > timeaftercalib ){ |
if( dtime > timeaftercalib ){ |
| 6444 |
if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) run after calib too far ( "<<dtime<<"ms ) -- cannot validate :-( "<<endl; |
if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) run after calib too far ( "<<dtime<<"ms ) -- cannot validate :-( "<<endl; |
| 6445 |
return 0; // :-( |
return 0; // :-( |
| 6446 |
} |
} |
| 6447 |
|
|
| 6448 |
|
|
| 6449 |
|
|
| 6450 |
if( (run->ACQ_BUILD_INFO & mask) != build ){ |
if( (run->ACQ_BUILD_INFO & mask) != build ){ |
| 6451 |
if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) ACQ_BUILD_INFO= >>> "<<hex << (run->ACQ_BUILD_INFO&mask) << " != "<< build << dec<<endl; |
if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) ACQ_BUILD_INFO= >>> "<<hex << (run->ACQ_BUILD_INFO&mask) << " != "<< build << dec<<endl; |
| 6452 |
return 0; // :-( |
return 0; // :-( |
| 6453 |
} |
} |
| 6454 |
return 1; // :-) |
return 1; // :-) |
| 6455 |
|
|
| 6456 |
} |
} |
| 6457 |
|
|
| 6461 |
* |
* |
| 6462 |
**/ |
**/ |
| 6463 |
UInt_t PamelaDBOperations::Check(){ |
UInt_t PamelaDBOperations::Check(){ |
| 6464 |
return(this->Check(0,0)); |
return(this->Check(0,0)); |
| 6465 |
} |
} |
| 6466 |
|
|
| 6467 |
UInt_t PamelaDBOperations::Check(UInt_t from, UInt_t to){ |
UInt_t PamelaDBOperations::Check(UInt_t from, UInt_t to){ |
| 6468 |
// |
// |
| 6469 |
if ( IsDebug() ) printf(" from %u to %u \n",from,to); |
if ( IsDebug() ) printf(" from %u to %u \n",from,to); |
| 6470 |
// |
// |
| 6471 |
UInt_t test = 0; |
UInt_t test = 0; |
| 6472 |
// |
// |
| 6507 |
// |
// |
| 6508 |
if ( from > 0 && nid <= from ) goto ss; |
if ( from > 0 && nid <= from ) goto ss; |
| 6509 |
if ( to > 0 && nid >= to ) goto ss; |
if ( to > 0 && nid >= to ) goto ss; |
| 6510 |
// |
// |
| 6511 |
if ( (UInt_t)atoll(row->GetField(4)) > 1 ){ |
if ( (UInt_t)atoll(row->GetField(4)) > 1 ){ |
| 6512 |
// |
// |
| 6513 |
// |
// |
| 6538 |
printf(" CHECK n.4 RUNs %u and %u HAVE SAME RUNHEADER \n",thisid,(UInt_t)atoll(row3->GetField(0))); |
printf(" CHECK n.4 RUNs %u and %u HAVE SAME RUNHEADER \n",thisid,(UInt_t)atoll(row3->GetField(0))); |
| 6539 |
row3 = result3->Next(); |
row3 = result3->Next(); |
| 6540 |
}; |
}; |
| 6541 |
// delete result3; |
// delete result3; |
| 6542 |
|
|
| 6543 |
}; |
}; |
| 6544 |
// |
// |
| 6559 |
printf(" CHECK n.5 RUNs %u and %u HAVE SAME RUNTRAILER \n",thisid,(UInt_t)atoll(row3->GetField(0))); |
printf(" CHECK n.5 RUNs %u and %u HAVE SAME RUNTRAILER \n",thisid,(UInt_t)atoll(row3->GetField(0))); |
| 6560 |
row3 = result3->Next(); |
row3 = result3->Next(); |
| 6561 |
}; |
}; |
| 6562 |
// delete result3; |
// delete result3; |
| 6563 |
}; |
}; |
| 6564 |
// |
// |
| 6565 |
oss.str(""); |
oss.str(""); |
| 6579 |
printf(" CHECK n.7 RUNs %u and %u HAVE SAME RUNTRAILER AND RUNHEADER (ARE THE SAME?) \n",thisid,(UInt_t)atoll(row3->GetField(0))); |
printf(" CHECK n.7 RUNs %u and %u HAVE SAME RUNTRAILER AND RUNHEADER (ARE THE SAME?) \n",thisid,(UInt_t)atoll(row3->GetField(0))); |
| 6580 |
row3 = result3->Next(); |
row3 = result3->Next(); |
| 6581 |
}; |
}; |
| 6582 |
// delete result3; |
// delete result3; |
| 6583 |
|
|
| 6584 |
}; |
}; |
| 6585 |
}; |
}; |
| 6600 |
printf(" CHECK n.6 RUN %u CONTAINS RUN %u \n",thisid,(UInt_t)atoll(row3->GetField(0))); |
printf(" CHECK n.6 RUN %u CONTAINS RUN %u \n",thisid,(UInt_t)atoll(row3->GetField(0))); |
| 6601 |
row3 = result3->Next(); |
row3 = result3->Next(); |
| 6602 |
}; |
}; |
| 6603 |
// delete result3; |
// delete result3; |
| 6604 |
}; |
}; |
| 6605 |
// |
// |
| 6606 |
}; |
}; |
| 6626 |
thisf = (TString)row2->GetField(0); |
thisf = (TString)row2->GetField(0); |
| 6627 |
if ( IsDebug() ) printf(" ==> files %s and %s \n",prevf.Data(),thisf.Data()); |
if ( IsDebug() ) printf(" ==> files %s and %s \n",prevf.Data(),thisf.Data()); |
| 6628 |
test = 1; |
test = 1; |
| 6629 |
// delete result2; |
// delete result2; |
| 6630 |
}; |
}; |
| 6631 |
// |
// |
| 6632 |
if ( (thisrtt < prevrht) && (thisrht != prevrht) ){ |
if ( (thisrtt < prevrht) && (thisrht != prevrht) ){ |
| 6648 |
thisf = (TString)row2->GetField(0); |
thisf = (TString)row2->GetField(0); |
| 6649 |
if ( IsDebug() ) printf(" ==> files %s and %s \n",prevf.Data(),thisf.Data()); |
if ( IsDebug() ) printf(" ==> files %s and %s \n",prevf.Data(),thisf.Data()); |
| 6650 |
test = 1; |
test = 1; |
| 6651 |
// delete result2; |
// delete result2; |
| 6652 |
}; |
}; |
| 6653 |
// |
// |
| 6654 |
if ( (thisrht > thisrtt) && (thisrht != prevrht) ){ |
if ( (thisrht > thisrtt) && (thisrht != prevrht) ){ |
| 6670 |
thisf = (TString)row2->GetField(0); |
thisf = (TString)row2->GetField(0); |
| 6671 |
if ( IsDebug() ) printf(" ==> files %s and %s \n",prevf.Data(),thisf.Data()); |
if ( IsDebug() ) printf(" ==> files %s and %s \n",prevf.Data(),thisf.Data()); |
| 6672 |
test = 1; |
test = 1; |
| 6673 |
// delete result2; |
// delete result2; |
| 6674 |
}; |
}; |
| 6675 |
ss: |
ss: |
| 6676 |
// |
// |
| 6677 |
prevrht = thisrht; |
prevrht = thisrht; |
| 6678 |
prevrtt = thisrtt; |
prevrtt = thisrtt; |
| 6679 |
previd = thisid; |
previd = thisid; |
| 6680 |
prevl0id = thisl0id; |
prevl0id = thisl0id; |
| 6681 |
row = result->Next(); |
row = result->Next(); |
| 6682 |
// if ( result2 ) delete result2; |
// if ( result2 ) delete result2; |
| 6683 |
// if ( result3 ) delete result3; |
// if ( result3 ) delete result3; |
| 6684 |
}; |
}; |
| 6685 |
// |
// |
| 6686 |
return(test); |
return(test); |