| 185 |
if ( !chboot ){ |
if ( !chboot ){ |
| 186 |
qu.str(""); |
qu.str(""); |
| 187 |
// qu << "SELECT BOOT_NUMBER from ROOT_TABLE where BOOT_NUMBER!=0 AND ABS(LAST_TIME_SYNC_INFO-"<< chlastts <<")<10000 AND ABS(REAL_TIME_INIT-"<< row2->GetField(10) <<")<7200 group by BOOT_NUMBER order by BOOT_NUMBER asc;"; |
// qu << "SELECT BOOT_NUMBER from ROOT_TABLE where BOOT_NUMBER!=0 AND ABS(LAST_TIME_SYNC_INFO-"<< chlastts <<")<10000 AND ABS(REAL_TIME_INIT-"<< row2->GetField(10) <<")<7200 group by BOOT_NUMBER order by BOOT_NUMBER asc;"; |
| 188 |
qu << "SELECT BOOT_NUMBER from ROOT_TABLE where BOOT_NUMBER!=0 AND ABS(LAST_TIME_SYNC_INFO-"<< chlastts <<")<20000 AND ABS(REAL_TIME_INIT-"<< row2->GetField(10) <<")<40000 group by BOOT_NUMBER order by BOOT_NUMBER asc;"; // relax conditions... 090112 [8RED: error -29] |
qu << "SELECT BOOT_NUMBER from ROOT_TABLE where BOOT_NUMBER!=0 AND ABS(LAST_TIME_SYNC_INFO-"<< chlastts <<")<40000 AND ABS(REAL_TIME_INIT-"<< row2->GetField(10) <<")<40000 group by BOOT_NUMBER order by BOOT_NUMBER asc;"; // relax conditions... 090112 [8RED: error -29] |
| 189 |
if ( debug ) printf(" chewbacca: query is %s \n",qu.str().c_str()); |
if ( debug ) printf(" chewbacca: query is %s \n",qu.str().c_str()); |
| 190 |
result3 = conn->Query(qu.str().c_str()); |
result3 = conn->Query(qu.str().c_str()); |
| 191 |
if ( result3 ){ |
if ( result3 ){ |
| 1504 |
glrun->SetRUNTRAILER_PKT(lastPkt); |
glrun->SetRUNTRAILER_PKT(lastPkt); |
| 1505 |
// |
// |
| 1506 |
}; |
}; |
| 1507 |
|
// |
| 1508 |
|
// ad hoc solution for INF EV_TO [8RED] 090113 |
| 1509 |
|
// |
| 1510 |
|
if ( !firstev && lastev == -1 ){ |
| 1511 |
|
if ( IsDebug() ) printf(" EE firstev %i lastev %i nevents %i \n",firstev,lastev,lastev-firstev+1); |
| 1512 |
|
firstev = 1; |
| 1513 |
|
lastev = 0; |
| 1514 |
|
}; |
| 1515 |
glrun->SetEV_FROM((UInt_t)firstev); |
glrun->SetEV_FROM((UInt_t)firstev); |
| 1516 |
glrun->SetEV_TO((UInt_t)lastev); |
glrun->SetEV_TO((UInt_t)lastev); |
| 1517 |
glrun->SetNEVENTS((UInt_t)lastev-(UInt_t)firstev+1); |
glrun->SetNEVENTS((UInt_t)lastev-(UInt_t)firstev+1); |
| 3371 |
glrun->SetID_RUN_FRAG(IDRL2B); |
glrun->SetID_RUN_FRAG(IDRL2B); |
| 3372 |
glrun->Fill_GL_RUN(conn); |
glrun->Fill_GL_RUN(conn); |
| 3373 |
glrun->DeleteRun(conn,0,"GL_RUN_FRAGMENTS"); |
glrun->DeleteRun(conn,0,"GL_RUN_FRAGMENTS"); |
| 3374 |
|
delete glA; |
| 3375 |
// |
// |
| 3376 |
} else { |
} else { |
| 3377 |
// |
// |
| 6130 |
row2 = result2->Next(); |
row2 = result2->Next(); |
| 6131 |
// |
// |
| 6132 |
if ( row2 ){ |
if ( row2 ){ |
| 6133 |
if ( IsDebug() ) printf(" The already exist in the GL_RUN table! \n"); |
if ( IsDebug() ) printf(" The run already exists in the GL_RUN table! \n"); |
| 6134 |
if ( PEDANTIC ) throw -83; |
if ( PEDANTIC ) throw -83; |
| 6135 |
row2->Close(); |
row2->Close(); |
| 6136 |
}; |
}; |
| 6207 |
glrun->Query_GL_RUN_FRAGMENTS(oss.str().c_str(),conn); |
glrun->Query_GL_RUN_FRAGMENTS(oss.str().c_str(),conn); |
| 6208 |
// |
// |
| 6209 |
oss.str(""); |
oss.str(""); |
| 6210 |
oss << " SELECT ID,NEVENTS,TRK_CALIB_USED,PKT_COUNTER FROM GL_RUN WHERE " |
oss << " SELECT ID,NEVENTS,TRK_CALIB_USED,PKT_COUNTER,ID_ROOT_L0 FROM GL_RUN WHERE " |
| 6211 |
<< " BOOT_NUMBER=" << glrun->GetBOOT_NUMBER() << " AND (" |
<< " BOOT_NUMBER=" << glrun->GetBOOT_NUMBER() << " AND (" |
| 6212 |
<< " (RUNHEADER_TIME>=" << (UInt_t)(glrun->GetRUNHEADER_TIME()-10) << " AND " |
<< " (RUNHEADER_TIME>=" << (UInt_t)(glrun->GetRUNHEADER_TIME()-10) << " AND " |
| 6213 |
<< " RUNTRAILER_TIME<=" << (UInt_t)(glrun->GetRUNTRAILER_TIME()+10) << " AND (" |
<< " RUNTRAILER_TIME<=" << (UInt_t)(glrun->GetRUNTRAILER_TIME()+10) << " AND (" |
| 6265 |
moved++; |
moved++; |
| 6266 |
// |
// |
| 6267 |
} else { |
} else { |
| 6268 |
if ( IsDebug() ) printf(" The already exist in the GL_RUN table! \n"); |
|
| 6269 |
if ( PEDANTIC ) throw -83; |
// questa parte mah mah mah... da controllare |
| 6270 |
|
|
| 6271 |
|
// |
| 6272 |
|
// we end up here if chewbacca and we have RH---| small gap |---RT, in this case the two pieces are attached and moved to GL_RUN. We are now processing the |
| 6273 |
|
// "small gap" piece... we recognize this since: we have two entries from this query, the pkt number is consistent with our pkt number. |
| 6274 |
|
// |
| 6275 |
|
// 090112 [8RED (-70): RUN ALREADY INSERTED] |
| 6276 |
|
// |
| 6277 |
|
Bool_t OK = false; |
| 6278 |
|
UInt_t IDRL2A = 0; |
| 6279 |
|
UInt_t IDRL2B = 0; |
| 6280 |
|
if ( result2->GetRowCount() == 2 ){ |
| 6281 |
|
IDRL2A = (UInt_t)atoll(row2->GetField(0)); |
| 6282 |
|
UInt_t IDRL0A = (UInt_t)atoll(row2->GetField(4)); |
| 6283 |
|
row2 = result2->Next(); |
| 6284 |
|
IDRL2B = (UInt_t)atoll(row2->GetField(0)); |
| 6285 |
|
UInt_t IDRL0B = (UInt_t)atoll(row2->GetField(4)); |
| 6286 |
|
if ( IsDebug() ) printf(" IDRL0A %u B %u IDRL2A %u B %u \n",IDRL0A,IDRL0B,IDRL2A,IDRL2B); |
| 6287 |
|
// if ( IDRL0A == IDRL0B ){ |
| 6288 |
|
// TSQLResult *result2a = 0; |
| 6289 |
|
// TSQLRow *row2a = 0; |
| 6290 |
|
// oss.str(""); |
| 6291 |
|
// oss << "select PKT_NUMBER_FINAL from ROOT_TABLE_MERGING where REAL_TIME_INIT<" << chrtinit << " order by REAL_TIME_INIT desc limit 1;"; |
| 6292 |
|
// if ( IsDebug() ) printf(" Check if we are in the case RH---| small gap |---RT: query is \n %s \n",oss.str().c_str()); |
| 6293 |
|
// result2a = conn->Query(oss.str().c_str()); |
| 6294 |
|
// // |
| 6295 |
|
// if ( !result2a ) throw -4; |
| 6296 |
|
// // |
| 6297 |
|
// row2a = result2a->Next(); |
| 6298 |
|
// // |
| 6299 |
|
// if ( row2a ){ |
| 6300 |
|
// UInt_t PKA = (UInt_t)atoll(row2a->GetField(0)); |
| 6301 |
|
// delete result2a; |
| 6302 |
|
// oss.str(""); |
| 6303 |
|
// oss << "select PKT_NUMBER_INIT from ROOT_TABLE_MERGING where REAL_TIME_INIT>" << chrtinit << " order by REAL_TIME_INIT asc limit 1;"; |
| 6304 |
|
// if ( IsDebug() ) printf(" Check if we are in the case RH---| small gap |---RT: query is \n %s \n",oss.str().c_str()); |
| 6305 |
|
// result2a = conn->Query(oss.str().c_str()); |
| 6306 |
|
// // |
| 6307 |
|
// if ( !result2a ) throw -4; |
| 6308 |
|
// // |
| 6309 |
|
// row2a = result2a->Next(); |
| 6310 |
|
// // |
| 6311 |
|
// if ( row2a ){ |
| 6312 |
|
// UInt_t PKB = (UInt_t)atoll(row2a->GetField(0)); |
| 6313 |
|
// // |
| 6314 |
|
// 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); |
| 6315 |
|
// if ( PKT(PKA)+1LL == PKT(glrun->GetRUNHEADER_PKT()) && PKT(PKB) == PKT(glrun->GetRUNTRAILER_PKT())+1LL ){ |
| 6316 |
|
// if ( IsDebug() ) printf(" Ok, we are in the case: RH---| small gap |---RT \n"); |
| 6317 |
|
OK = true; |
| 6318 |
|
// }; |
| 6319 |
|
// }; |
| 6320 |
|
// }; |
| 6321 |
|
// }; |
| 6322 |
|
}; |
| 6323 |
|
if ( OK ){ |
| 6324 |
|
// |
| 6325 |
|
// this is the case in which we must insert a piece of run between two fragments in the GL_RUN table |
| 6326 |
|
// |
| 6327 |
|
// 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 ) |
| 6328 |
|
// |
| 6329 |
|
GL_RUN *glA = new GL_RUN(); |
| 6330 |
|
glA->Query_GL_RUN(IDRL2A,conn); |
| 6331 |
|
// |
| 6332 |
|
if ( glA->GetACQ_BUILD_INFO() != 0 ){ |
| 6333 |
|
// |
| 6334 |
|
// the first piece contains a good runheader we can update all the other runs with correct infos! |
| 6335 |
|
// |
| 6336 |
|
oss.str(""); |
| 6337 |
|
oss << "UPDATE GL_RUN_FRAGMENTS SET " |
| 6338 |
|
<< " RUNHEADER_TIME=" << glA->GetRUNHEADER_TIME()<< " , " |
| 6339 |
|
<< " RUNHEADER_OBT=" << glA->GetRUNHEADER_OBT()<< " , " |
| 6340 |
|
<< " RUNHEADER_PKT=" << glA->GetRUNHEADER_PKT()<< " , " |
| 6341 |
|
<< " COMPILATIONTIMESTAMP=" << glA->GetCOMPILATIONTIMESTAMP()<< " , " |
| 6342 |
|
<< " FAV_WRK_SCHEDULE=" << glA->GetFAV_WRK_SCHEDULE()<< " , " |
| 6343 |
|
<< " EFF_WRK_SCHEDULE=" << glA->GetEFF_WRK_SCHEDULE()<< " , " |
| 6344 |
|
<< " PRH_VAR_TRG_MODE_A=" << glA->GetPRH_VAR_TRG_MODE_A()<< " , " |
| 6345 |
|
<< " PRH_VAR_TRG_MODE_B=" << glA->GetPRH_VAR_TRG_MODE_B()<< " , " |
| 6346 |
|
<< " ACQ_BUILD_INFO=" << glA->GetACQ_BUILD_INFO()<< " , " |
| 6347 |
|
<< " ACQ_VAR_INFO=" << glA->GetACQ_VAR_INFO()<< " , " |
| 6348 |
|
<< " RM_ACQ_AFTER_CALIB=" << glA->GetRM_ACQ_AFTER_CALIB()<< " , " |
| 6349 |
|
<< " RM_ACQ_SETTING_MODE=" << glA->GetRM_ACQ_SETTING_MODE()<< " , " |
| 6350 |
|
<< " TRK_CALIB_USED=" << glA->GetTRK_CALIB_USED()<< " , " |
| 6351 |
|
<< " CAL_DSP_MASK=" << glA->GetCAL_DSP_MASK()<< " , " |
| 6352 |
|
<< " LAST_TIMESYNC=" << glA->GetLAST_TIMESYNC()<< " , "; |
| 6353 |
|
// |
| 6354 |
|
if ( glA->GetPHYSENDRUN_MASK_S3S2S12() ) |
| 6355 |
|
oss << " PHYSENDRUN_MASK_S3S2S12=" << glA->GetPHYSENDRUN_MASK_S3S2S12() << " , "; |
| 6356 |
|
if ( glA->GetPHYSENDRUN_MASK_S11CRC() ) |
| 6357 |
|
oss << " PHYSENDRUN_MASK_S11CRC=" << glA->GetPHYSENDRUN_MASK_S11CRC() << " , "; |
| 6358 |
|
// |
| 6359 |
|
oss << " OBT_TIMESYNC=" << glA->GetOBT_TIMESYNC(); |
| 6360 |
|
oss << " WHERE ID=" << glrun->GetID() << ";"; |
| 6361 |
|
if ( IsDebug() ) printf(" update with correct infos: %s\n",oss.str().c_str()); |
| 6362 |
|
conn->Query(oss.str().c_str()); |
| 6363 |
|
// |
| 6364 |
|
} else { |
| 6365 |
|
// |
| 6366 |
|
// sig no runheader, let set anyway what is possible... |
| 6367 |
|
// |
| 6368 |
|
oss.str(""); |
| 6369 |
|
oss << "UPDATE GL_RUN_FRAGMENTS SET " |
| 6370 |
|
<< " RUNHEADER_TIME=" << glA->GetRUNHEADER_TIME()<< " , "; |
| 6371 |
|
// |
| 6372 |
|
if ( glA->GetPHYSENDRUN_MASK_S3S2S12() ) |
| 6373 |
|
oss << " PHYSENDRUN_MASK_S3S2S12=" << glA->GetPHYSENDRUN_MASK_S3S2S12()<< " , "; |
| 6374 |
|
if ( glA->GetPHYSENDRUN_MASK_S11CRC() ) |
| 6375 |
|
oss << " PHYSENDRUN_MASK_S11CRC=" << glA->GetPHYSENDRUN_MASK_S11CRC()<< " , "; |
| 6376 |
|
// |
| 6377 |
|
oss << " RUNHEADER_OBT=" << glA->GetRUNHEADER_OBT()<< " , " |
| 6378 |
|
<< " RUNHEADER_PKT=" << glA->GetRUNHEADER_PKT(); |
| 6379 |
|
oss << " WHERE ID=" << glrun->GetID() << ";"; |
| 6380 |
|
if ( IsDebug() ) printf(" update with correct infos2: %s\n",oss.str().c_str()); |
| 6381 |
|
conn->Query(oss.str().c_str()); |
| 6382 |
|
}; |
| 6383 |
|
// |
| 6384 |
|
// update runheader ROOT_ID_FRAG |
| 6385 |
|
// |
| 6386 |
|
oss.str(""); |
| 6387 |
|
oss << "UPDATE GL_RUN SET ID_RUN_FRAG = " << glrun->GetID() << " where ID = " << IDRL2A << ";"; |
| 6388 |
|
if ( IsDebug() ) printf(" update gl_run to have cross indexing: %s\n",oss.str().c_str()); |
| 6389 |
|
conn->Query(oss.str().c_str()); |
| 6390 |
|
// |
| 6391 |
|
// now let's look for runtrailer if any in the last run |
| 6392 |
|
// |
| 6393 |
|
glA->Query_GL_RUN(IDRL2B,conn); |
| 6394 |
|
// |
| 6395 |
|
if ( glA->GetPKT_READY_COUNTER() != 0 ){ |
| 6396 |
|
// |
| 6397 |
|
// the first piece contains a good runtrailer we can update all the other runs with correct infos! |
| 6398 |
|
// |
| 6399 |
|
oss.str(""); |
| 6400 |
|
oss << "UPDATE GL_RUN_FRAGMENTS SET " |
| 6401 |
|
<< " RUNTRAILER_TIME=" << glA->GetRUNTRAILER_TIME()<< " , " |
| 6402 |
|
<< " RUNTRAILER_OBT=" << glA->GetRUNTRAILER_OBT()<< " , " |
| 6403 |
|
<< " RUNTRAILER_PKT=" << glA->GetRUNTRAILER_PKT()<< " , " |
| 6404 |
|
<< " PKT_COUNTER=" << glA->GetPKT_COUNTER()<< " , "; |
| 6405 |
|
// |
| 6406 |
|
if ( glA->GetPHYSENDRUN_MASK_S3S2S12() ){ |
| 6407 |
|
oss << " PHYSENDRUN_MASK_S3S2S12=" << glA->GetPHYSENDRUN_MASK_S3S2S12()<< " , "; }; |
| 6408 |
|
if ( glA->GetPHYSENDRUN_MASK_S11CRC() ) { |
| 6409 |
|
oss << " PHYSENDRUN_MASK_S11CRC=" << glA->GetPHYSENDRUN_MASK_S11CRC()<< " , "; }; |
| 6410 |
|
// |
| 6411 |
|
oss << " PKT_READY_COUNTER=" << glA->GetPKT_READY_COUNTER() |
| 6412 |
|
<< " WHERE ID=" << glrun->GetID() << ";"; |
| 6413 |
|
if ( IsDebug() ) printf(" update with correct trailer infos: %s\n",oss.str().c_str()); |
| 6414 |
|
conn->Query(oss.str().c_str()); |
| 6415 |
|
// |
| 6416 |
|
} else { |
| 6417 |
|
// |
| 6418 |
|
// sig no runtrailer, let set anyway what is possible... |
| 6419 |
|
// |
| 6420 |
|
oss.str(""); |
| 6421 |
|
oss << "UPDATE GL_RUN_FRAGMENTS SET " |
| 6422 |
|
<< " RUNTRAILER_TIME=" << glA->GetRUNTRAILER_TIME()<< " , " |
| 6423 |
|
<< " RUNTRAILER_OBT=" << glA->GetRUNTRAILER_OBT()<< " , "; |
| 6424 |
|
// |
| 6425 |
|
if ( glA->GetPHYSENDRUN_MASK_S3S2S12() ){ |
| 6426 |
|
oss << " PHYSENDRUN_MASK_S3S2S12=" << glA->GetPHYSENDRUN_MASK_S3S2S12()<< " , "; }; |
| 6427 |
|
if ( glA->GetPHYSENDRUN_MASK_S11CRC() ){ |
| 6428 |
|
oss << " PHYSENDRUN_MASK_S11CRC=" << glA->GetPHYSENDRUN_MASK_S11CRC()<< " , "; }; |
| 6429 |
|
// |
| 6430 |
|
oss << " RUNTRAILER_PKT=" << glrun->GetRUNTRAILER_PKT() |
| 6431 |
|
<< " WHERE ID=" << glrun->GetID() << ";"; |
| 6432 |
|
if ( IsDebug() ) printf(" update with correct trailer infos2: %s\n",oss.str().c_str()); |
| 6433 |
|
conn->Query(oss.str().c_str()); |
| 6434 |
|
}; |
| 6435 |
|
// |
| 6436 |
|
UInt_t myi = glrun->GetID(); |
| 6437 |
|
oss.str(""); |
| 6438 |
|
oss << " ID= "<< myi; |
| 6439 |
|
// |
| 6440 |
|
glrun->Query_GL_RUN_FRAGMENTS(oss.str().c_str(),conn); |
| 6441 |
|
// |
| 6442 |
|
// fill the new run in GL_RUN |
| 6443 |
|
// |
| 6444 |
|
glrun->SetID_RUN_FRAG(IDRL2B); |
| 6445 |
|
glrun->Fill_GL_RUN(conn); |
| 6446 |
|
glrun->DeleteRun(conn,0,"GL_RUN_FRAGMENTS"); |
| 6447 |
|
delete glA; |
| 6448 |
|
moved++; |
| 6449 |
|
// |
| 6450 |
|
} else { |
| 6451 |
|
// |
| 6452 |
|
// is just a repetition |
| 6453 |
|
// |
| 6454 |
|
if ( IsDebug() ) printf(" The run %u is already present in the GL_RUN table...\n",glrun->GetID()); |
| 6455 |
|
// printf(" CCCCCCCCICCCCCCCCCCCCIOOOOOOOOOO si muove Ciccio! %u \n",glrun->GetID()); |
| 6456 |
|
// if ( PEDANTIC && glrun->GetID() != 61563 ) throw -83; |
| 6457 |
|
if ( PEDANTIC ) throw -83; |
| 6458 |
|
}; |
| 6459 |
|
// if ( IsDebug() ) printf(" The run already exists in the GL_RUN table! ...\n"); |
| 6460 |
|
// if ( PEDANTIC ) throw -83; |
| 6461 |
}; |
}; |
| 6462 |
if ( IsDebug() ) printf(" Delete run %s from the GL_RUN_FRAGMENTS table \n",row->GetField(0)); |
if ( IsDebug() ) printf(" Delete run %s from the GL_RUN_FRAGMENTS table \n",row->GetField(0)); |
| 6463 |
// |
// |