| 1730 |
TYPE = 0; |
TYPE = 0; |
| 1731 |
TSYNC = 0; |
TSYNC = 0; |
| 1732 |
// |
// |
| 1733 |
Double_t minimum = 0.; |
// Double_t minimum = 0.; |
| 1734 |
Double_t maximum = 0.; |
// Double_t maximum = 0.; |
| 1735 |
Double_t minimum2 = 0.; |
//Double_t minimum2 = 0.; |
| 1736 |
Double_t maximum2 = 0.; |
Double_t maximum2 = 0.; |
| 1737 |
// |
// |
| 1738 |
// |
// |
| 1740 |
pamela::McmdRecord *mcrc = 0; |
pamela::McmdRecord *mcrc = 0; |
| 1741 |
TArrayC *mcmddata = 0; |
TArrayC *mcmddata = 0; |
| 1742 |
// |
// |
| 1743 |
minimum = numeric_limits<Double_t>::max(); |
// minimum = numeric_limits<Double_t>::max(); |
| 1744 |
maximum = numeric_limits<Double_t>::min(); |
// maximum = numeric_limits<Double_t>::min(); |
| 1745 |
minimum2 = numeric_limits<Double_t>::max(); |
// minimum2 = numeric_limits<Double_t>::max(); |
| 1746 |
maximum2 = numeric_limits<Double_t>::min(); |
maximum2 = numeric_limits<Double_t>::min(); |
| 1747 |
// |
// |
| 1748 |
T = (TTree*)file->Get("Mcmd"); |
T = (TTree*)file->Get("Mcmd"); |
| 2270 |
// |
// |
| 2271 |
// no runtrailers in the file! |
// no runtrailers in the file! |
| 2272 |
// |
// |
| 2273 |
if ( !rtev ){ |
if ( IsDebug() ) printf(" Start rtev %i rhev %i nrtev %i nrhev %i \n",rtev,rhev,nrtev,nrhev); |
| 2274 |
if ( !rhev ){ |
if ( !rtev || (chewbacca && !nrtev) ){ |
| 2275 |
|
if ( IsDebug() ) printf(" No runtrailers \n"); |
| 2276 |
|
if ( !rhev || (chewbacca && !nrhev) ){ |
| 2277 |
if ( IsDebug() ) printf(" No runheaders nor runtrailers!! \n"); |
if ( IsDebug() ) printf(" No runheaders nor runtrailers!! \n"); |
| 2278 |
if ( !(upperentry-chminentry) ){ |
if ( !(upperentry-chminentry) ){ |
| 2279 |
if ( IsDebug() ) printf(" No physics events nor runs in the file \n"); // di nuovo potrebbe esserci un runtrailer senza eventi (riempimento MM) |
if ( IsDebug() ) printf(" No physics events nor runs in the file \n"); // di nuovo potrebbe esserci un runtrailer senza eventi (riempimento MM) |
| 2310 |
// |
// |
| 2311 |
} else { |
} else { |
| 2312 |
// |
// |
| 2313 |
|
if ( IsDebug() ) printf(" We have runtrailers \n"); |
| 2314 |
Int_t conptt = -1; |
Int_t conptt = -1; |
| 2315 |
for (Int_t ptt=0; ptt<rtev; ptt++){ |
for (Int_t ptt=0; ptt<rtev; ptt++){ |
| 2316 |
// |
// |
| 3244 |
// "small gap" piece... we recognize this since: we have two entries from this query, the pkt number is consistent with our pkt number. |
// "small gap" piece... we recognize this since: we have two entries from this query, the pkt number is consistent with our pkt number. |
| 3245 |
// |
// |
| 3246 |
// 090112 [8RED (-70): RUN ALREADY INSERTED] |
// 090112 [8RED (-70): RUN ALREADY INSERTED] |
| 3247 |
|
// 093012 [8RED (-70): RUN ALREADY INSERTED] try to be more general... the run has not been instered yet if the runheader-trailer PKT interval is not covered by already inserted runs, NOTICE: we must look in the GL_RUN_TRASH table! |
| 3248 |
// |
// |
| 3249 |
Bool_t OK = false; |
Bool_t OK = false; |
| 3250 |
UInt_t IDRL2A = 0; |
UInt_t IDRL2A = 0; |
| 3251 |
UInt_t IDRL2B = 0; |
UInt_t IDRL2B = 0; |
| 3252 |
if ( chewbacca ){ |
if ( chewbacca ){ |
| 3253 |
if ( result->GetRowCount() == 2 ){ |
if ( result->GetRowCount() >= 2 ){ |
| 3254 |
|
// |
| 3255 |
|
if ( IsDebug() ) printf(" RH---| gap |---RT case, number of pieces in the GL_RUN table: %i \n",result->GetRowCount()); |
| 3256 |
|
OK = true; |
| 3257 |
IDRL2A = (UInt_t)atoll(row->GetField(0)); |
IDRL2A = (UInt_t)atoll(row->GetField(0)); |
| 3258 |
UInt_t IDRL0A = (UInt_t)atoll(row->GetField(1)); |
// |
| 3259 |
row = result->Next(); |
while ( row ){ |
|
IDRL2B = (UInt_t)atoll(row->GetField(0)); |
|
|
UInt_t IDRL0B = (UInt_t)atoll(row->GetField(1)); |
|
|
if ( IsDebug() ) printf(" IDRL0A %u B %u IDRL2A %u B %u \n",IDRL0A,IDRL0B,IDRL2A,IDRL2B); |
|
|
if ( IDRL0A == IDRL0B ){ |
|
|
TSQLResult *result2 = 0; |
|
|
TSQLRow *row2 = 0; |
|
|
oss.str(""); |
|
|
oss << "select PKT_NUMBER_FINAL from ROOT_TABLE_MERGING where REAL_TIME_INIT<" << chrtinit << " order by REAL_TIME_INIT desc limit 1;"; |
|
|
if ( IsDebug() ) printf(" Check if we are in the case RH---| small gap |---RT: query is \n %s \n",oss.str().c_str()); |
|
|
result2 = conn->Query(oss.str().c_str()); |
|
| 3260 |
// |
// |
| 3261 |
if ( !result2 ) throw -4; |
TSQLResult *trresult = 0; |
| 3262 |
|
TSQLRow *trrow = 0; |
| 3263 |
// |
// |
| 3264 |
row2 = result2->Next(); |
stringstream tross; |
| 3265 |
|
tross.str(""); |
| 3266 |
// |
// |
| 3267 |
if ( row2 ){ |
tross << " SELECT RUNHEADER_PKT, RUNTRAILER_PKT FROM GL_RUN_TRASH where ID=" << row->GetField(0) << ";"; |
| 3268 |
UInt_t PKA = (UInt_t)atoll(row2->GetField(0)); |
if ( IsDebug() ) printf(" check in the gl_run_trash table for pkt intervals: query is \n %s \n",tross.str().c_str()); |
| 3269 |
delete result2; |
trresult = conn->Query(tross.str().c_str()); |
| 3270 |
oss.str(""); |
if ( !trresult ) throw -4; |
| 3271 |
oss << "select PKT_NUMBER_INIT from ROOT_TABLE_MERGING where REAL_TIME_INIT>" << chrtinit << " order by REAL_TIME_INIT asc limit 1;"; |
trrow = trresult->Next(); |
| 3272 |
if ( IsDebug() ) printf(" Check if we are in the case RH---| small gap |---RT: query is \n %s \n",oss.str().c_str()); |
if ( !trrow || trresult->GetRowCount() != 1 ){ |
| 3273 |
result2 = conn->Query(oss.str().c_str()); |
OK = false; |
| 3274 |
// |
if ( IsDebug() ) printf(" OPS! no such run (or multiple runs!) in GL_RUN_TRASH table, something wrong is going on! \n"); |
| 3275 |
if ( !result2 ) throw -4; |
break; |
| 3276 |
// |
}; |
| 3277 |
row2 = result2->Next(); |
// |
| 3278 |
// |
UInt_t pktH = (UInt_t)atoll(row->GetField(0)); |
| 3279 |
if ( row2 ){ |
UInt_t pktT = (UInt_t)atoll(row->GetField(1)); |
| 3280 |
UInt_t PKB = (UInt_t)atoll(row2->GetField(0)); |
delete trresult; |
| 3281 |
// |
if ( |
| 3282 |
if ( IsDebug() ) printf(" PKT(PKA) + 1 %llu == runheaderpkt %llu && PKB = runtrailer %llu + 1 %llu \n",PKT(PKA)+1LL, PKT(glrun->GetRUNHEADER_PKT()),PKT(PKB), PKT(glrun->GetRUNTRAILER_PKT())+1LL); |
(PKT(pktH) >= PKT(glrun->GetRUNHEADER_PKT()) && PKT(pktH) <= PKT(glrun->GetRUNTRAILER_PKT())) || |
| 3283 |
if ( PKT(PKA)+1LL == PKT(glrun->GetRUNHEADER_PKT()) && PKT(PKB) == PKT(glrun->GetRUNTRAILER_PKT())+1LL ){ |
(PKT(pktT) >= PKT(glrun->GetRUNHEADER_PKT()) && PKT(pktT) <= PKT(glrun->GetRUNTRAILER_PKT())) || |
| 3284 |
if ( IsDebug() ) printf(" Ok, we are in the case: RH---| small gap |---RT \n"); |
(PKT(pktH) <= PKT(glrun->GetRUNTRAILER_PKT()) && PKT(pktT) >= PKT(glrun->GetRUNTRAILER_PKT())) ){ |
| 3285 |
OK = true; |
OK = false; |
| 3286 |
}; |
if ( IsDebug() ) printf(" The run is overlapping with already inserted ones!! \n"); |
| 3287 |
}; |
break; |
| 3288 |
}; |
}; |
| 3289 |
|
//PKT(glrun->GetRUNHEADER_PKT()) PKT(glrun->GetRUNTRAILER_PKT()) |
| 3290 |
|
row = result->Next(); |
| 3291 |
}; |
}; |
| 3292 |
}; |
|
| 3293 |
|
// if ( result->GetRowCount() == 2 ) { |
| 3294 |
|
// IDRL2A = (UInt_t)atoll(row->GetField(0)); |
| 3295 |
|
// UInt_t IDRL0A = (UInt_t)atoll(row->GetField(1)); |
| 3296 |
|
// row = result->Next(); |
| 3297 |
|
// IDRL2B = (UInt_t)atoll(row->GetField(0)); |
| 3298 |
|
// UInt_t IDRL0B = (UInt_t)atoll(row->GetField(1)); |
| 3299 |
|
// if ( IsDebug() ) printf(" IDRL0A %u B %u IDRL2A %u B %u \n",IDRL0A,IDRL0B,IDRL2A,IDRL2B); |
| 3300 |
|
// // if ( IDRL0A == IDRL0B ){ //091230 why this condition???? RH could be in a file and RT in another one... |
| 3301 |
|
// if ( true ){ |
| 3302 |
|
// TSQLResult *result2 = 0; |
| 3303 |
|
// TSQLRow *row2 = 0; |
| 3304 |
|
// oss.str(""); |
| 3305 |
|
// oss << "select PKT_NUMBER_FINAL from ROOT_TABLE_MERGING where REAL_TIME_INIT<" << chrtinit << " order by REAL_TIME_INIT desc limit 1;"; |
| 3306 |
|
// if ( IsDebug() ) printf(" Check if we are in the case RH---| small gap |---RT: query is \n %s \n",oss.str().c_str()); |
| 3307 |
|
// result2 = conn->Query(oss.str().c_str()); |
| 3308 |
|
// // |
| 3309 |
|
// if ( !result2 ) throw -4; |
| 3310 |
|
// // |
| 3311 |
|
// row2 = result2->Next(); |
| 3312 |
|
// // |
| 3313 |
|
// if ( row2 ){ |
| 3314 |
|
// UInt_t PKA = (UInt_t)atoll(row2->GetField(0)); |
| 3315 |
|
// delete result2; |
| 3316 |
|
// oss.str(""); |
| 3317 |
|
// oss << "select PKT_NUMBER_INIT from ROOT_TABLE_MERGING where REAL_TIME_INIT>" << chrtinit << " order by REAL_TIME_INIT asc limit 1;"; |
| 3318 |
|
// if ( IsDebug() ) printf(" Check if we are in the case RH---| small gap |---RT: query is \n %s \n",oss.str().c_str()); |
| 3319 |
|
// result2 = conn->Query(oss.str().c_str()); |
| 3320 |
|
// // |
| 3321 |
|
// if ( !result2 ) throw -4; |
| 3322 |
|
// // |
| 3323 |
|
// row2 = result2->Next(); |
| 3324 |
|
// // |
| 3325 |
|
// if ( row2 ){ |
| 3326 |
|
// UInt_t PKB = (UInt_t)atoll(row2->GetField(0)); |
| 3327 |
|
// // |
| 3328 |
|
// if ( IsDebug() ) printf(" PKT(PKA) + 1 %llu == runheaderpkt %llu && PKB = runtrailer %llu + 1 %llu \n",PKT(PKA)+1LL, PKT(glrun->GetRUNHEADER_PKT()),PKT(PKB), PKT(glrun->GetRUNTRAILER_PKT())+1LL); |
| 3329 |
|
// if ( PKT(PKA)+1LL == PKT(glrun->GetRUNHEADER_PKT()) && PKT(PKB) == PKT(glrun->GetRUNTRAILER_PKT())+1LL ){ |
| 3330 |
|
// if ( IsDebug() ) printf(" Ok, we are in the case: RH---| small gap |---RT \n"); |
| 3331 |
|
// OK = true; |
| 3332 |
|
// }; |
| 3333 |
|
// }; |
| 3334 |
|
// }; |
| 3335 |
|
// }; |
| 3336 |
|
// }; |
| 3337 |
|
}; |
| 3338 |
}; |
}; |
| 3339 |
if ( OK ){ |
if ( OK ){ |
| 3340 |
// |
// |
| 3341 |
// this is the case in which we must insert a piece of run between two fragments in the GL_RUN table |
// this is the case in which we must insert a piece of run between two fragments in the GL_RUN table // we arrive here ONLY with internal pieces of runs, never runheader or runtrailer by definition |
| 3342 |
// |
// |
| 3343 |
// we have to update with runheader/trailer infos our run and we have to change the ROOT_ID_FRAG of the header piece ( 1/2 2/1 must become 1/3 3/2 2/1 ) |
// we have to update with runheader/trailer infos our run and we have to change the ROOT_ID_FRAG of the header piece ( 1/2 2/1 must become 1/3 3/2 2/1 ) |
| 3344 |
// |
// |
| 3345 |
|
if ( IsDebug() ) printf(" Ok, we are in the case: RH---| small gap |---RT \n"); |
| 3346 |
|
// |
| 3347 |
GL_RUN *glA = new GL_RUN(); |
GL_RUN *glA = new GL_RUN(); |
| 3348 |
glA->Query_GL_RUN(IDRL2A,conn); |
glA->Query_GL_RUN(IDRL2A,conn); |
| 3349 |
// |
// |
| 3350 |
|
glrun->SetRUNHEADER_TIME(glA->GetRUNHEADER_TIME()); |
| 3351 |
|
glrun->SetRUNHEADER_OBT(glA->GetRUNHEADER_OBT()); |
| 3352 |
|
glrun->SetRUNHEADER_PKT(glA->GetRUNHEADER_PKT()); |
| 3353 |
|
// |
| 3354 |
|
glrun->SetRUNTRAILER_TIME(glA->GetRUNTRAILER_TIME()); |
| 3355 |
|
glrun->SetRUNTRAILER_OBT(glA->GetRUNTRAILER_OBT()); |
| 3356 |
|
glrun->SetRUNTRAILER_PKT(glA->GetRUNTRAILER_PKT()); |
| 3357 |
|
// |
| 3358 |
|
if ( glA->GetPHYSENDRUN_MASK_S3S2S12() ) glrun->SetPHYSENDRUN_MASK_S3S2S12(glA->GetPHYSENDRUN_MASK_S3S2S12()); |
| 3359 |
|
if ( glA->GetPHYSENDRUN_MASK_S11CRC() ) glrun->SetPHYSENDRUN_MASK_S11CRC(glA->GetPHYSENDRUN_MASK_S11CRC()); |
| 3360 |
|
// |
| 3361 |
if ( glA->GetACQ_BUILD_INFO() != 0 ){ |
if ( glA->GetACQ_BUILD_INFO() != 0 ){ |
| 3362 |
// |
// |
| 3363 |
// the first piece contains a good runheader we can update all the other runs with correct infos! |
// the first piece contains a good runheader we can update all the other runs with correct infos! |
| 3364 |
// |
// |
| 3365 |
oss.str(""); |
glrun->SetCOMPILATIONTIMESTAMP(glA->GetCOMPILATIONTIMESTAMP()); |
| 3366 |
oss << "UPDATE GL_RUN_FRAGMENTS SET " |
glrun->SetFAV_WRK_SCHEDULE(glA->GetFAV_WRK_SCHEDULE()); |
| 3367 |
<< " RUNHEADER_TIME=" << glA->GetRUNHEADER_TIME()<< " , " |
glrun->SetEFF_WRK_SCHEDULE(glA->GetEFF_WRK_SCHEDULE()); |
| 3368 |
<< " RUNHEADER_OBT=" << glA->GetRUNHEADER_OBT()<< " , " |
glrun->SetPRH_VAR_TRG_MODE_A(glA->GetPRH_VAR_TRG_MODE_A()); |
| 3369 |
<< " RUNHEADER_PKT=" << glA->GetRUNHEADER_PKT()<< " , " |
glrun->SetPRH_VAR_TRG_MODE_B(glA->GetPRH_VAR_TRG_MODE_B()); |
| 3370 |
<< " COMPILATIONTIMESTAMP=" << glA->GetCOMPILATIONTIMESTAMP()<< " , " |
glrun->SetACQ_BUILD_INFO(glA->GetACQ_BUILD_INFO()); |
| 3371 |
<< " FAV_WRK_SCHEDULE=" << glA->GetFAV_WRK_SCHEDULE()<< " , " |
glrun->SetACQ_VAR_INFO(glA->GetACQ_VAR_INFO()); |
| 3372 |
<< " EFF_WRK_SCHEDULE=" << glA->GetEFF_WRK_SCHEDULE()<< " , " |
glrun->SetRM_ACQ_AFTER_CALIB(glA->GetRM_ACQ_AFTER_CALIB()); |
| 3373 |
<< " PRH_VAR_TRG_MODE_A=" << glA->GetPRH_VAR_TRG_MODE_A()<< " , " |
glrun->SetRM_ACQ_SETTING_MODE(glA->GetRM_ACQ_SETTING_MODE()); |
| 3374 |
<< " PRH_VAR_TRG_MODE_B=" << glA->GetPRH_VAR_TRG_MODE_B()<< " , " |
glrun->SetTRK_CALIB_USED(glA->GetTRK_CALIB_USED()); |
| 3375 |
<< " ACQ_BUILD_INFO=" << glA->GetACQ_BUILD_INFO()<< " , " |
glrun->SetCAL_DSP_MASK(glA->GetCAL_DSP_MASK()); |
| 3376 |
<< " ACQ_VAR_INFO=" << glA->GetACQ_VAR_INFO()<< " , " |
glrun->SetLAST_TIMESYNC(glA->GetLAST_TIMESYNC()); |
| 3377 |
<< " RM_ACQ_AFTER_CALIB=" << glA->GetRM_ACQ_AFTER_CALIB()<< " , " |
glrun->SetOBT_TIMESYNC(glA->GetOBT_TIMESYNC()); |
|
<< " RM_ACQ_SETTING_MODE=" << glA->GetRM_ACQ_SETTING_MODE()<< " , " |
|
|
<< " TRK_CALIB_USED=" << glA->GetTRK_CALIB_USED()<< " , " |
|
|
<< " CAL_DSP_MASK=" << glA->GetCAL_DSP_MASK()<< " , " |
|
|
<< " LAST_TIMESYNC=" << glA->GetLAST_TIMESYNC()<< " , "; |
|
|
// |
|
|
if ( glA->GetPHYSENDRUN_MASK_S3S2S12() ) |
|
|
oss << " PHYSENDRUN_MASK_S3S2S12=" << glA->GetPHYSENDRUN_MASK_S3S2S12() << " , "; |
|
|
if ( glA->GetPHYSENDRUN_MASK_S11CRC() ) |
|
|
oss << " PHYSENDRUN_MASK_S11CRC=" << glA->GetPHYSENDRUN_MASK_S11CRC() << " , "; |
|
|
// |
|
|
oss << " OBT_TIMESYNC=" << glA->GetOBT_TIMESYNC(); |
|
|
oss << " WHERE ID=" << glrun->GetID() << ";"; |
|
|
if ( IsDebug() ) printf(" update with correct infos: %s\n",oss.str().c_str()); |
|
|
conn->Query(oss.str().c_str()); |
|
| 3378 |
// |
// |
| 3379 |
} else { |
}; |
| 3380 |
// |
// |
| 3381 |
// sig no runheader, let set anyway what is possible... |
if ( glA->GetPKT_READY_COUNTER() != 0 ){ |
| 3382 |
// |
// |
| 3383 |
oss.str(""); |
// the first piece contains a good runtrailer we can update all the other runs with correct infos! |
|
oss << "UPDATE GL_RUN_FRAGMENTS SET " |
|
|
<< " RUNHEADER_TIME=" << glA->GetRUNHEADER_TIME()<< " , "; |
|
| 3384 |
// |
// |
| 3385 |
if ( glA->GetPHYSENDRUN_MASK_S3S2S12() ) |
glrun->SetPKT_COUNTER(glA->GetPKT_COUNTER()); |
| 3386 |
oss << " PHYSENDRUN_MASK_S3S2S12=" << glA->GetPHYSENDRUN_MASK_S3S2S12()<< " , "; |
glrun->SetPKT_READY_COUNTER(glA->GetPKT_READY_COUNTER()); |
|
if ( glA->GetPHYSENDRUN_MASK_S11CRC() ) |
|
|
oss << " PHYSENDRUN_MASK_S11CRC=" << glA->GetPHYSENDRUN_MASK_S11CRC()<< " , "; |
|
|
// |
|
|
oss << " RUNHEADER_OBT=" << glA->GetRUNHEADER_OBT()<< " , " |
|
|
<< " RUNHEADER_PKT=" << glA->GetRUNHEADER_PKT(); |
|
|
oss << " WHERE ID=" << glrun->GetID() << ";"; |
|
|
if ( IsDebug() ) printf(" update with correct infos2: %s\n",oss.str().c_str()); |
|
|
conn->Query(oss.str().c_str()); |
|
| 3387 |
}; |
}; |
| 3388 |
// |
// |
| 3389 |
// update runheader ROOT_ID_FRAG |
// update runheader ROOT_ID_FRAG |
| 3393 |
if ( IsDebug() ) printf(" update gl_run to have cross indexing: %s\n",oss.str().c_str()); |
if ( IsDebug() ) printf(" update gl_run to have cross indexing: %s\n",oss.str().c_str()); |
| 3394 |
conn->Query(oss.str().c_str()); |
conn->Query(oss.str().c_str()); |
| 3395 |
// |
// |
|
// now let's look for runtrailer if any in the last run |
|
|
// |
|
|
glA->Query_GL_RUN(IDRL2B,conn); |
|
|
// |
|
|
if ( glA->GetPKT_READY_COUNTER() != 0 ){ |
|
|
// |
|
|
// the first piece contains a good runtrailer we can update all the other runs with correct infos! |
|
|
// |
|
|
oss.str(""); |
|
|
oss << "UPDATE GL_RUN_FRAGMENTS SET " |
|
|
<< " RUNTRAILER_TIME=" << glA->GetRUNTRAILER_TIME()<< " , " |
|
|
<< " RUNTRAILER_OBT=" << glA->GetRUNTRAILER_OBT()<< " , " |
|
|
<< " RUNTRAILER_PKT=" << glA->GetRUNTRAILER_PKT()<< " , " |
|
|
<< " PKT_COUNTER=" << glA->GetPKT_COUNTER()<< " , "; |
|
|
// |
|
|
if ( glA->GetPHYSENDRUN_MASK_S3S2S12() ){ |
|
|
oss << " PHYSENDRUN_MASK_S3S2S12=" << glA->GetPHYSENDRUN_MASK_S3S2S12()<< " , "; }; |
|
|
if ( glA->GetPHYSENDRUN_MASK_S11CRC() ) { |
|
|
oss << " PHYSENDRUN_MASK_S11CRC=" << glA->GetPHYSENDRUN_MASK_S11CRC()<< " , "; }; |
|
|
// |
|
|
oss << " PKT_READY_COUNTER=" << glA->GetPKT_READY_COUNTER() |
|
|
<< " WHERE ID=" << glrun->GetID() << ";"; |
|
|
if ( IsDebug() ) printf(" update with correct trailer infos: %s\n",oss.str().c_str()); |
|
|
conn->Query(oss.str().c_str()); |
|
|
// |
|
|
} else { |
|
|
// |
|
|
// sig no runtrailer, let set anyway what is possible... |
|
|
// |
|
|
oss.str(""); |
|
|
oss << "UPDATE GL_RUN_FRAGMENTS SET " |
|
|
<< " RUNTRAILER_TIME=" << glA->GetRUNTRAILER_TIME()<< " , " |
|
|
<< " RUNTRAILER_OBT=" << glA->GetRUNTRAILER_OBT()<< " , "; |
|
|
// |
|
|
if ( glA->GetPHYSENDRUN_MASK_S3S2S12() ){ |
|
|
oss << " PHYSENDRUN_MASK_S3S2S12=" << glA->GetPHYSENDRUN_MASK_S3S2S12()<< " , "; }; |
|
|
if ( glA->GetPHYSENDRUN_MASK_S11CRC() ){ |
|
|
oss << " PHYSENDRUN_MASK_S11CRC=" << glA->GetPHYSENDRUN_MASK_S11CRC()<< " , "; }; |
|
|
// |
|
|
oss << " RUNTRAILER_PKT=" << glrun->GetRUNTRAILER_PKT() |
|
|
<< " WHERE ID=" << glrun->GetID() << ";"; |
|
|
if ( IsDebug() ) printf(" update with correct trailer infos2: %s\n",oss.str().c_str()); |
|
|
conn->Query(oss.str().c_str()); |
|
|
}; |
|
|
// |
|
|
UInt_t myi = glrun->GetID(); |
|
| 3396 |
oss.str(""); |
oss.str(""); |
| 3397 |
oss << " ID= "<< myi; |
oss << "SELECT ID FROM GL_RUN WHERE ID_RUN_FRAG = " << IDRL2A << ";"; |
| 3398 |
// |
if ( IsDebug() ) printf(" update gl_run to have cross indexing: %s\n",oss.str().c_str()); |
| 3399 |
glrun->Query_GL_RUN_FRAGMENTS(oss.str().c_str(),conn); |
TSQLResult *tsresult = 0; |
| 3400 |
|
TSQLRow *tsrow = 0; |
| 3401 |
|
tsresult=conn->Query(oss.str().c_str()); |
| 3402 |
|
if ( !tsresult ) throw -4; |
| 3403 |
|
tsrow = tsresult->Next(); |
| 3404 |
|
if ( !tsrow || tsresult->GetRowCount() != 1 ) throw -4; |
| 3405 |
|
IDRL2B = (UInt_t)atoll(tsrow->GetField(0)); |
| 3406 |
|
glrun->SetID_RUN_FRAG(IDRL2B); |
| 3407 |
// |
// |
| 3408 |
// fill the new run in GL_RUN |
// fill the new run in GL_RUN |
| 3409 |
// |
// |
|
glrun->SetID_RUN_FRAG(IDRL2B); |
|
| 3410 |
glrun->Fill_GL_RUN(conn); |
glrun->Fill_GL_RUN(conn); |
| 3411 |
|
// |
| 3412 |
glrun->DeleteRun(conn,0,"GL_RUN_FRAGMENTS"); |
glrun->DeleteRun(conn,0,"GL_RUN_FRAGMENTS"); |
| 3413 |
delete glA; |
delete glA; |
| 3414 |
// |
// |
| 3415 |
} else { |
} else { |
| 3416 |
|
// // |
| 3417 |
|
// // this is the case in which we must insert a piece of run between two fragments in the GL_RUN table |
| 3418 |
|
// // |
| 3419 |
|
// // we have to update with runheader/trailer infos our run and we have to change the ROOT_ID_FRAG of the header piece ( 1/2 2/1 must become 1/3 3/2 2/1 ) |
| 3420 |
|
// // |
| 3421 |
|
// GL_RUN *glA = new GL_RUN(); |
| 3422 |
|
// glA->Query_GL_RUN(IDRL2A,conn); |
| 3423 |
|
// // |
| 3424 |
|
// if ( glA->GetACQ_BUILD_INFO() != 0 ){ |
| 3425 |
|
// // |
| 3426 |
|
// // the first piece contains a good runheader we can update all the other runs with correct infos! |
| 3427 |
|
// // |
| 3428 |
|
// oss.str(""); |
| 3429 |
|
// oss << "UPDATE GL_RUN_FRAGMENTS SET " |
| 3430 |
|
// << " RUNHEADER_TIME=" << glA->GetRUNHEADER_TIME()<< " , " |
| 3431 |
|
// << " RUNHEADER_OBT=" << glA->GetRUNHEADER_OBT()<< " , " |
| 3432 |
|
// << " RUNHEADER_PKT=" << glA->GetRUNHEADER_PKT()<< " , " |
| 3433 |
|
// << " COMPILATIONTIMESTAMP=" << glA->GetCOMPILATIONTIMESTAMP()<< " , " |
| 3434 |
|
// << " FAV_WRK_SCHEDULE=" << glA->GetFAV_WRK_SCHEDULE()<< " , " |
| 3435 |
|
// << " EFF_WRK_SCHEDULE=" << glA->GetEFF_WRK_SCHEDULE()<< " , " |
| 3436 |
|
// << " PRH_VAR_TRG_MODE_A=" << glA->GetPRH_VAR_TRG_MODE_A()<< " , " |
| 3437 |
|
// << " PRH_VAR_TRG_MODE_B=" << glA->GetPRH_VAR_TRG_MODE_B()<< " , " |
| 3438 |
|
// << " ACQ_BUILD_INFO=" << glA->GetACQ_BUILD_INFO()<< " , " |
| 3439 |
|
// << " ACQ_VAR_INFO=" << glA->GetACQ_VAR_INFO()<< " , " |
| 3440 |
|
// << " RM_ACQ_AFTER_CALIB=" << glA->GetRM_ACQ_AFTER_CALIB()<< " , " |
| 3441 |
|
// << " RM_ACQ_SETTING_MODE=" << glA->GetRM_ACQ_SETTING_MODE()<< " , " |
| 3442 |
|
// << " TRK_CALIB_USED=" << glA->GetTRK_CALIB_USED()<< " , " |
| 3443 |
|
// << " CAL_DSP_MASK=" << glA->GetCAL_DSP_MASK()<< " , " |
| 3444 |
|
// << " LAST_TIMESYNC=" << glA->GetLAST_TIMESYNC()<< " , "; |
| 3445 |
|
// // |
| 3446 |
|
// if ( glA->GetPHYSENDRUN_MASK_S3S2S12() ) |
| 3447 |
|
// oss << " PHYSENDRUN_MASK_S3S2S12=" << glA->GetPHYSENDRUN_MASK_S3S2S12() << " , "; |
| 3448 |
|
// if ( glA->GetPHYSENDRUN_MASK_S11CRC() ) |
| 3449 |
|
// oss << " PHYSENDRUN_MASK_S11CRC=" << glA->GetPHYSENDRUN_MASK_S11CRC() << " , "; |
| 3450 |
|
// // |
| 3451 |
|
// oss << " OBT_TIMESYNC=" << glA->GetOBT_TIMESYNC(); |
| 3452 |
|
// oss << " WHERE ID=" << glrun->GetID() << ";"; |
| 3453 |
|
// if ( IsDebug() ) printf(" update with correct infos: %s\n",oss.str().c_str()); |
| 3454 |
|
// conn->Query(oss.str().c_str()); |
| 3455 |
|
// // |
| 3456 |
|
// } else { |
| 3457 |
|
// // |
| 3458 |
|
// // sig no runheader, let set anyway what is possible... |
| 3459 |
|
// // |
| 3460 |
|
// oss.str(""); |
| 3461 |
|
// oss << "UPDATE GL_RUN_FRAGMENTS SET " |
| 3462 |
|
// << " RUNHEADER_TIME=" << glA->GetRUNHEADER_TIME()<< " , "; |
| 3463 |
|
// // |
| 3464 |
|
// if ( glA->GetPHYSENDRUN_MASK_S3S2S12() ) |
| 3465 |
|
// oss << " PHYSENDRUN_MASK_S3S2S12=" << glA->GetPHYSENDRUN_MASK_S3S2S12()<< " , "; |
| 3466 |
|
// if ( glA->GetPHYSENDRUN_MASK_S11CRC() ) |
| 3467 |
|
// oss << " PHYSENDRUN_MASK_S11CRC=" << glA->GetPHYSENDRUN_MASK_S11CRC()<< " , "; |
| 3468 |
|
// // |
| 3469 |
|
// oss << " RUNHEADER_OBT=" << glA->GetRUNHEADER_OBT()<< " , " |
| 3470 |
|
// << " RUNHEADER_PKT=" << glA->GetRUNHEADER_PKT(); |
| 3471 |
|
// oss << " WHERE ID=" << glrun->GetID() << ";"; |
| 3472 |
|
// if ( IsDebug() ) printf(" update with correct infos2: %s\n",oss.str().c_str()); |
| 3473 |
|
// conn->Query(oss.str().c_str()); |
| 3474 |
|
// }; |
| 3475 |
|
// // |
| 3476 |
|
// // update runheader ROOT_ID_FRAG |
| 3477 |
|
// // |
| 3478 |
|
// oss.str(""); |
| 3479 |
|
// oss << "UPDATE GL_RUN SET ID_RUN_FRAG = " << glrun->GetID() << " where ID = " << IDRL2A << ";"; |
| 3480 |
|
// if ( IsDebug() ) printf(" update gl_run to have cross indexing: %s\n",oss.str().c_str()); |
| 3481 |
|
// conn->Query(oss.str().c_str()); |
| 3482 |
|
// // |
| 3483 |
|
// // now let's look for runtrailer if any in the last run |
| 3484 |
|
// // |
| 3485 |
|
// glA->Query_GL_RUN(IDRL2B,conn); |
| 3486 |
|
// // |
| 3487 |
|
// if ( glA->GetPKT_READY_COUNTER() != 0 ){ |
| 3488 |
|
// // |
| 3489 |
|
// // the first piece contains a good runtrailer we can update all the other runs with correct infos! |
| 3490 |
|
// // |
| 3491 |
|
// oss.str(""); |
| 3492 |
|
// oss << "UPDATE GL_RUN_FRAGMENTS SET " |
| 3493 |
|
// << " RUNTRAILER_TIME=" << glA->GetRUNTRAILER_TIME()<< " , " |
| 3494 |
|
// << " RUNTRAILER_OBT=" << glA->GetRUNTRAILER_OBT()<< " , " |
| 3495 |
|
// << " RUNTRAILER_PKT=" << glA->GetRUNTRAILER_PKT()<< " , " |
| 3496 |
|
// << " PKT_COUNTER=" << glA->GetPKT_COUNTER()<< " , "; |
| 3497 |
|
// // |
| 3498 |
|
// if ( glA->GetPHYSENDRUN_MASK_S3S2S12() ){ |
| 3499 |
|
// oss << " PHYSENDRUN_MASK_S3S2S12=" << glA->GetPHYSENDRUN_MASK_S3S2S12()<< " , "; }; |
| 3500 |
|
// if ( glA->GetPHYSENDRUN_MASK_S11CRC() ) { |
| 3501 |
|
// oss << " PHYSENDRUN_MASK_S11CRC=" << glA->GetPHYSENDRUN_MASK_S11CRC()<< " , "; }; |
| 3502 |
|
// // |
| 3503 |
|
// oss << " PKT_READY_COUNTER=" << glA->GetPKT_READY_COUNTER() |
| 3504 |
|
// << " WHERE ID=" << glrun->GetID() << ";"; |
| 3505 |
|
// if ( IsDebug() ) printf(" update with correct trailer infos: %s\n",oss.str().c_str()); |
| 3506 |
|
// conn->Query(oss.str().c_str()); |
| 3507 |
|
// // |
| 3508 |
|
// } else { |
| 3509 |
|
// // |
| 3510 |
|
// // sig no runtrailer, let set anyway what is possible... |
| 3511 |
|
// // |
| 3512 |
|
// oss.str(""); |
| 3513 |
|
// oss << "UPDATE GL_RUN_FRAGMENTS SET " |
| 3514 |
|
// << " RUNTRAILER_TIME=" << glA->GetRUNTRAILER_TIME()<< " , " |
| 3515 |
|
// << " RUNTRAILER_OBT=" << glA->GetRUNTRAILER_OBT()<< " , "; |
| 3516 |
|
// // |
| 3517 |
|
// if ( glA->GetPHYSENDRUN_MASK_S3S2S12() ){ |
| 3518 |
|
// oss << " PHYSENDRUN_MASK_S3S2S12=" << glA->GetPHYSENDRUN_MASK_S3S2S12()<< " , "; }; |
| 3519 |
|
// if ( glA->GetPHYSENDRUN_MASK_S11CRC() ){ |
| 3520 |
|
// oss << " PHYSENDRUN_MASK_S11CRC=" << glA->GetPHYSENDRUN_MASK_S11CRC()<< " , "; }; |
| 3521 |
|
// // |
| 3522 |
|
// oss << " RUNTRAILER_PKT=" << glrun->GetRUNTRAILER_PKT() |
| 3523 |
|
// << " WHERE ID=" << glrun->GetID() << ";"; |
| 3524 |
|
// if ( IsDebug() ) printf(" update with correct trailer infos2: %s\n",oss.str().c_str()); |
| 3525 |
|
// conn->Query(oss.str().c_str()); |
| 3526 |
|
// }; |
| 3527 |
|
// // |
| 3528 |
|
// UInt_t myi = glrun->GetID(); |
| 3529 |
|
// oss.str(""); |
| 3530 |
|
// oss << " ID= "<< myi; |
| 3531 |
|
// // |
| 3532 |
|
// glrun->Query_GL_RUN_FRAGMENTS(oss.str().c_str(),conn); |
| 3533 |
|
// // |
| 3534 |
|
// // fill the new run in GL_RUN |
| 3535 |
|
// // |
| 3536 |
|
// glrun->SetID_RUN_FRAG(IDRL2B); |
| 3537 |
|
// glrun->Fill_GL_RUN(conn); |
| 3538 |
|
// glrun->DeleteRun(conn,0,"GL_RUN_FRAGMENTS"); |
| 3539 |
|
// delete glA; |
| 3540 |
|
// // |
| 3541 |
|
// } else { |
| 3542 |
// |
// |
| 3543 |
// is just a repetition |
// is just a repetition |
| 3544 |
// |
// |
| 3598 |
// |
// |
| 3599 |
EventCounter *code=0; |
EventCounter *code=0; |
| 3600 |
// |
// |
| 3601 |
UInt_t nevent = 0; |
// UInt_t nevent = 0; |
| 3602 |
UInt_t checkfirst = 0; |
UInt_t checkfirst = 0; |
| 3603 |
UInt_t checklast = 0; |
UInt_t checklast = 0; |
| 3604 |
UInt_t firstentry = 0; |
UInt_t firstentry = 0; |
| 3620 |
EventHeader *eh = 0; |
EventHeader *eh = 0; |
| 3621 |
PscuHeader *ph = 0; |
PscuHeader *ph = 0; |
| 3622 |
T->SetBranchAddress("Header", &eh); |
T->SetBranchAddress("Header", &eh); |
| 3623 |
nevent = T->GetEntries(); |
// nevent = T->GetEntries(); |
| 3624 |
// |
// |
| 3625 |
// |
// |
| 3626 |
if ( firstev == lastev+1 || lastev == firstev ) { // no events inside the run! |
if ( firstev == lastev+1 || lastev == firstev ) { // no events inside the run! |
| 4141 |
EventCounter *code=0; |
EventCounter *code=0; |
| 4142 |
UInt_t firstev = 0; |
UInt_t firstev = 0; |
| 4143 |
UInt_t lastev = 0; |
UInt_t lastev = 0; |
| 4144 |
UInt_t nevent = 0; |
// UInt_t nevent = 0; |
| 4145 |
UInt_t checkfirst = 0; |
UInt_t checkfirst = 0; |
| 4146 |
UInt_t checklast = 0; |
UInt_t checklast = 0; |
| 4147 |
UInt_t firstentry = 0; |
UInt_t firstentry = 0; |
| 4166 |
EventHeader *eh = 0; |
EventHeader *eh = 0; |
| 4167 |
PscuHeader *ph = 0; |
PscuHeader *ph = 0; |
| 4168 |
T->SetBranchAddress("Header", &eh); |
T->SetBranchAddress("Header", &eh); |
| 4169 |
nevent = T->GetEntries(); |
// nevent = T->GetEntries(); |
| 4170 |
// |
// |
| 4171 |
codt = eht->GetCounter(); |
codt = eht->GetCounter(); |
| 4172 |
codh = ehh->GetCounter(); |
codh = ehh->GetCounter(); |
| 5527 |
TString path = ""; |
TString path = ""; |
| 5528 |
TString name = ""; |
TString name = ""; |
| 5529 |
TString raw = ""; |
TString raw = ""; |
| 5530 |
UInt_t obt0 = 0; |
// UInt_t obt0 = 0; |
| 5531 |
UInt_t timesync = 0; |
// UInt_t timesync = 0; |
| 5532 |
UInt_t boot_number = 0; |
// UInt_t boot_number = 0; |
| 5533 |
bool FOUND = false; |
bool FOUND = false; |
| 5534 |
|
|
| 5535 |
if ( IsDebug() ) cout << "------------------------------------------------------------" <<endl; |
if ( IsDebug() ) cout << "------------------------------------------------------------" <<endl; |
| 5602 |
path = (TString)row2->GetField(0); |
path = (TString)row2->GetField(0); |
| 5603 |
name = (TString)row2->GetField(1); |
name = (TString)row2->GetField(1); |
| 5604 |
raw = (TString)row2->GetField(5); |
raw = (TString)row2->GetField(5); |
| 5605 |
obt0 = (UInt_t)atoll(row2->GetField(2)); |
// obt0 = (UInt_t)atoll(row2->GetField(2)); |
| 5606 |
timesync = (UInt_t)atoll(row2->GetField(3)); |
// timesync = (UInt_t)atoll(row2->GetField(3)); |
| 5607 |
boot_number = (UInt_t)atoll(row2->GetField(4)); |
// boot_number = (UInt_t)atoll(row2->GetField(4)); |
| 5608 |
|
|
| 5609 |
if ( IsDebug() ) cout << "- - - - - - - - - - -" <<endl; |
if ( IsDebug() ) cout << "- - - - - - - - - - -" <<endl; |
| 5610 |
// cout << path <<endl; |
// cout << path <<endl; |
| 6123 |
memset(myid,0,500*sizeof(UInt_t)); |
memset(myid,0,500*sizeof(UInt_t)); |
| 6124 |
// |
// |
| 6125 |
oss.str(""); |
oss.str(""); |
| 6126 |
oss << "SELECT ID,RUNTRAILER_TIME,RUNTRAILER_PKT,BOOT_NUMBER FROM GL_RUN_FRAGMENTS WHERE INSERT_TIME <= '" << clean_time->AsSQLString() << "'order BY RUNHEADER_TIME asc;"; |
oss << "SELECT ID,RUNTRAILER_TIME,RUNTRAILER_PKT,BOOT_NUMBER FROM GL_RUN_FRAGMENTS WHERE INSERT_TIME <= '" << clean_time->AsSQLString() << "' order BY RUNHEADER_TIME asc;"; |
| 6127 |
if ( IsDebug() ) printf(" Select from GL_RUN_FRAGMENTS runs older than %s : query is \n %s \n",clean_time->AsSQLString(),oss.str().c_str()); |
if ( IsDebug() ) printf(" Select from GL_RUN_FRAGMENTS runs older than %s : query is \n %s \n",clean_time->AsSQLString(),oss.str().c_str()); |
| 6128 |
nresult = conn->Query(oss.str().c_str()); |
nresult = conn->Query(oss.str().c_str()); |
| 6129 |
// |
// |