88 |
// |
// |
89 |
glrun = new GL_RUN(); |
glrun = new GL_RUN(); |
90 |
// |
// |
91 |
if ( !chewbacca ){ |
// if ( !chewbacca ){ |
92 |
if ( !boot ) SetNOBOOT(false); |
// if ( !boot ) SetNOBOOT(false); |
93 |
SetTsync(tsync,gpamela); |
// SetTsync(tsync,gpamela); |
94 |
SetBOOTnumber(boot,gpamela); |
// SetBOOTnumber(boot,gpamela); |
95 |
SetObt0(obt0); |
// SetObt0(obt0); |
96 |
}; |
// }; |
97 |
// |
// |
98 |
SetTLEPath(tlefilename); |
SetTLEPath(tlefilename); |
99 |
// |
// |
126 |
// |
// |
127 |
// SETTERS |
// SETTERS |
128 |
// |
// |
129 |
|
void PamelaDBOperations::NotChewbacca(UInt_t boot, UInt_t tsync, UInt_t obt0, Bool_t gpamela){ |
130 |
|
if ( !boot ) SetNOBOOT(false); |
131 |
|
SetTsync(tsync,gpamela); |
132 |
|
SetBOOTnumber(boot,gpamela); |
133 |
|
SetObt0(obt0); |
134 |
|
}; |
135 |
|
|
136 |
void PamelaDBOperations::OpenL0File(TString filerootname){ |
void PamelaDBOperations::OpenL0File(TString filerootname){ |
137 |
if( INSERT_ROOT ){ |
if( INSERT_ROOT ){ |
189 |
chboot = (UInt_t)atoll(row2->GetField(5)); |
chboot = (UInt_t)atoll(row2->GetField(5)); |
190 |
// |
// |
191 |
if ( !chboot ){ |
if ( !chboot ){ |
192 |
|
if ( debug ) printf(" mmm... no BOOT number determined by chewbacca, try to find it looking at DB \n"); |
193 |
|
// |
194 |
|
// new feature: check in ROOT_TABLE (timewise) the previous and the next BOOT number != 0 , if it is the same we know this one! |
195 |
|
// if it is different roll back to the old behaviour |
196 |
|
// |
197 |
qu.str(""); |
qu.str(""); |
198 |
// 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 REAL_TIME_INIT>"<< row2->GetField(10) <<" order by REAL_TIME_INIT asc limit 1;"; |
|
// 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] |
|
|
qu << "SELECT BOOT_NUMBER from ROOT_TABLE where BOOT_NUMBER!=0 AND ABS(LAST_TIME_SYNC_INFO-"<< chlastts <<")<50000 AND ABS(REAL_TIME_INIT-"<< row2->GetField(10) <<")<50000 group by BOOT_NUMBER order by BOOT_NUMBER asc;"; // even more relaxed conditions... 091214 [9REDtest3: error -29] |
|
199 |
if ( debug ) printf(" chewbacca: query is %s \n",qu.str().c_str()); |
if ( debug ) printf(" chewbacca: query is %s \n",qu.str().c_str()); |
200 |
|
UInt_t chbootA = 0; |
201 |
|
UInt_t chbootB = 1; |
202 |
result3 = conn->Query(qu.str().c_str()); |
result3 = conn->Query(qu.str().c_str()); |
203 |
if ( result3 ){ |
if ( result3 ){ |
204 |
row3 = result3->Next(); |
row3 = result3->Next(); |
205 |
if ( row3 && result3->GetRowCount() == 1 ){ |
if ( row3 ){ |
206 |
chboot = (UInt_t)atoll(row3->GetField(0)); |
chbootA = (UInt_t)atoll(row3->GetField(0)); |
207 |
if ( debug ) printf(" Found boot_number = %u \n",chboot); |
if ( debug ) printf(" Found boot_number A = %u \n",chbootA); |
208 |
} else { |
}; |
209 |
if ( debug ) printf(" AGH CANNOT DETERMINE THE BOOT NUMBER... \n"); |
}; |
210 |
throw -29; |
delete result3; |
211 |
|
qu.str(""); |
212 |
|
qu << "SELECT BOOT_NUMBER from ROOT_TABLE where BOOT_NUMBER!=0 AND REAL_TIME_INIT<"<< row2->GetField(10) <<" order by REAL_TIME_INIT desc limit 1;"; |
213 |
|
if ( debug ) printf(" chewbacca: query is %s \n",qu.str().c_str()); |
214 |
|
result3 = conn->Query(qu.str().c_str()); |
215 |
|
if ( result3 ){ |
216 |
|
row3 = result3->Next(); |
217 |
|
if ( row3 ){ |
218 |
|
chbootB = (UInt_t)atoll(row3->GetField(0)); |
219 |
|
if ( debug ) printf(" Found boot_number B = %u \n",chbootB); |
220 |
|
}; |
221 |
|
}; |
222 |
|
if ( chbootA == chbootB ){ |
223 |
|
chboot = chbootA; |
224 |
|
if ( debug ) printf(" Found boot_number! it is %u \n",chboot); |
225 |
|
} else { |
226 |
|
qu.str(""); |
227 |
|
// 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;"; |
228 |
|
// 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] |
229 |
|
qu << "SELECT BOOT_NUMBER from ROOT_TABLE where BOOT_NUMBER!=0 AND ABS(LAST_TIME_SYNC_INFO-"<< chlastts <<")<50000 AND ABS(REAL_TIME_INIT-"<< row2->GetField(10) <<")<50000 group by BOOT_NUMBER order by BOOT_NUMBER asc;"; // even more relaxed conditions... 091214 [9REDtest3: error -29] |
230 |
|
if ( debug ) printf(" chewbacca: query is %s \n",qu.str().c_str()); |
231 |
|
result3 = conn->Query(qu.str().c_str()); |
232 |
|
if ( result3 ){ |
233 |
|
row3 = result3->Next(); |
234 |
|
if ( row3 && result3->GetRowCount() == 1 ){ |
235 |
|
chboot = (UInt_t)atoll(row3->GetField(0)); |
236 |
|
if ( debug ) printf(" Found boot_number = %u \n",chboot); |
237 |
|
} else { |
238 |
|
if ( debug ) printf(" AGH CANNOT DETERMINE THE BOOT NUMBER... \n"); |
239 |
|
throw -29; |
240 |
|
}; |
241 |
}; |
}; |
242 |
}; |
}; |
243 |
}; |
}; |
3241 |
// "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. |
3242 |
// |
// |
3243 |
// 090112 [8RED (-70): RUN ALREADY INSERTED] |
// 090112 [8RED (-70): RUN ALREADY INSERTED] |
3244 |
|
// 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! |
3245 |
// |
// |
3246 |
Bool_t OK = false; |
Bool_t OK = false; |
3247 |
UInt_t IDRL2A = 0; |
UInt_t IDRL2A = 0; |
3248 |
UInt_t IDRL2B = 0; |
UInt_t IDRL2B = 0; |
3249 |
if ( chewbacca ){ |
if ( chewbacca ){ |
3250 |
if ( result->GetRowCount() == 2 ){ |
if ( result->GetRowCount() >= 2 ){ |
3251 |
|
// |
3252 |
|
if ( IsDebug() ) printf(" RH---| gap |---RT case, number of pieces in the GL_RUN table: %i \n",result->GetRowCount()); |
3253 |
|
OK = true; |
3254 |
IDRL2A = (UInt_t)atoll(row->GetField(0)); |
IDRL2A = (UInt_t)atoll(row->GetField(0)); |
3255 |
UInt_t IDRL0A = (UInt_t)atoll(row->GetField(1)); |
// |
3256 |
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()); |
|
3257 |
// |
// |
3258 |
if ( !result2 ) throw -4; |
TSQLResult *trresult = 0; |
3259 |
|
TSQLRow *trrow = 0; |
3260 |
// |
// |
3261 |
row2 = result2->Next(); |
stringstream tross; |
3262 |
|
tross.str(""); |
3263 |
// |
// |
3264 |
if ( row2 ){ |
tross << " SELECT RUNHEADER_PKT, RUNTRAILER_PKT FROM GL_RUN_TRASH where ID=" << row->GetField(0) << ";"; |
3265 |
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()); |
3266 |
delete result2; |
trresult = conn->Query(tross.str().c_str()); |
3267 |
oss.str(""); |
if ( !trresult ) throw -4; |
3268 |
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(); |
3269 |
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 ){ |
3270 |
result2 = conn->Query(oss.str().c_str()); |
OK = false; |
3271 |
// |
if ( IsDebug() ) printf(" OPS! no such run (or multiple runs!) in GL_RUN_TRASH table, something wrong is going on! \n"); |
3272 |
if ( !result2 ) throw -4; |
break; |
3273 |
// |
}; |
3274 |
row2 = result2->Next(); |
// |
3275 |
// |
UInt_t pktH = (UInt_t)atoll(row->GetField(0)); |
3276 |
if ( row2 ){ |
UInt_t pktT = (UInt_t)atoll(row->GetField(1)); |
3277 |
UInt_t PKB = (UInt_t)atoll(row2->GetField(0)); |
delete trresult; |
3278 |
// |
if ( |
3279 |
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())) || |
3280 |
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())) || |
3281 |
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())) ){ |
3282 |
OK = true; |
OK = false; |
3283 |
}; |
if ( IsDebug() ) printf(" The run is overlapping with already inserted ones!! \n"); |
3284 |
}; |
break; |
3285 |
}; |
}; |
3286 |
|
//PKT(glrun->GetRUNHEADER_PKT()) PKT(glrun->GetRUNTRAILER_PKT()) |
3287 |
|
row = result->Next(); |
3288 |
}; |
}; |
3289 |
}; |
|
3290 |
|
// if ( result->GetRowCount() == 2 ) { |
3291 |
|
// IDRL2A = (UInt_t)atoll(row->GetField(0)); |
3292 |
|
// UInt_t IDRL0A = (UInt_t)atoll(row->GetField(1)); |
3293 |
|
// row = result->Next(); |
3294 |
|
// IDRL2B = (UInt_t)atoll(row->GetField(0)); |
3295 |
|
// UInt_t IDRL0B = (UInt_t)atoll(row->GetField(1)); |
3296 |
|
// if ( IsDebug() ) printf(" IDRL0A %u B %u IDRL2A %u B %u \n",IDRL0A,IDRL0B,IDRL2A,IDRL2B); |
3297 |
|
// // if ( IDRL0A == IDRL0B ){ //091230 why this condition???? RH could be in a file and RT in another one... |
3298 |
|
// if ( true ){ |
3299 |
|
// TSQLResult *result2 = 0; |
3300 |
|
// TSQLRow *row2 = 0; |
3301 |
|
// oss.str(""); |
3302 |
|
// oss << "select PKT_NUMBER_FINAL from ROOT_TABLE_MERGING where REAL_TIME_INIT<" << chrtinit << " order by REAL_TIME_INIT desc limit 1;"; |
3303 |
|
// if ( IsDebug() ) printf(" Check if we are in the case RH---| small gap |---RT: query is \n %s \n",oss.str().c_str()); |
3304 |
|
// result2 = conn->Query(oss.str().c_str()); |
3305 |
|
// // |
3306 |
|
// if ( !result2 ) throw -4; |
3307 |
|
// // |
3308 |
|
// row2 = result2->Next(); |
3309 |
|
// // |
3310 |
|
// if ( row2 ){ |
3311 |
|
// UInt_t PKA = (UInt_t)atoll(row2->GetField(0)); |
3312 |
|
// delete result2; |
3313 |
|
// oss.str(""); |
3314 |
|
// oss << "select PKT_NUMBER_INIT from ROOT_TABLE_MERGING where REAL_TIME_INIT>" << chrtinit << " order by REAL_TIME_INIT asc limit 1;"; |
3315 |
|
// if ( IsDebug() ) printf(" Check if we are in the case RH---| small gap |---RT: query is \n %s \n",oss.str().c_str()); |
3316 |
|
// result2 = conn->Query(oss.str().c_str()); |
3317 |
|
// // |
3318 |
|
// if ( !result2 ) throw -4; |
3319 |
|
// // |
3320 |
|
// row2 = result2->Next(); |
3321 |
|
// // |
3322 |
|
// if ( row2 ){ |
3323 |
|
// UInt_t PKB = (UInt_t)atoll(row2->GetField(0)); |
3324 |
|
// // |
3325 |
|
// 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); |
3326 |
|
// if ( PKT(PKA)+1LL == PKT(glrun->GetRUNHEADER_PKT()) && PKT(PKB) == PKT(glrun->GetRUNTRAILER_PKT())+1LL ){ |
3327 |
|
// if ( IsDebug() ) printf(" Ok, we are in the case: RH---| small gap |---RT \n"); |
3328 |
|
// OK = true; |
3329 |
|
// }; |
3330 |
|
// }; |
3331 |
|
// }; |
3332 |
|
// }; |
3333 |
|
// }; |
3334 |
|
}; |
3335 |
}; |
}; |
3336 |
if ( OK ){ |
if ( OK ){ |
3337 |
// |
// |
3338 |
// 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 |
3339 |
// |
// |
3340 |
// 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 ) |
3341 |
// |
// |
3342 |
|
if ( IsDebug() ) printf(" Ok, we are in the case: RH---| small gap |---RT \n"); |
3343 |
|
// |
3344 |
GL_RUN *glA = new GL_RUN(); |
GL_RUN *glA = new GL_RUN(); |
3345 |
glA->Query_GL_RUN(IDRL2A,conn); |
glA->Query_GL_RUN(IDRL2A,conn); |
3346 |
// |
// |
3347 |
|
glrun->SetRUNHEADER_TIME(glA->GetRUNHEADER_TIME()); |
3348 |
|
glrun->SetRUNHEADER_OBT(glA->GetRUNHEADER_OBT()); |
3349 |
|
glrun->SetRUNHEADER_PKT(glA->GetRUNHEADER_PKT()); |
3350 |
|
// |
3351 |
|
glrun->SetRUNTRAILER_TIME(glA->GetRUNTRAILER_TIME()); |
3352 |
|
glrun->SetRUNTRAILER_OBT(glA->GetRUNTRAILER_OBT()); |
3353 |
|
glrun->SetRUNTRAILER_PKT(glA->GetRUNTRAILER_PKT()); |
3354 |
|
// |
3355 |
|
if ( glA->GetPHYSENDRUN_MASK_S3S2S12() ) glrun->SetPHYSENDRUN_MASK_S3S2S12(glA->GetPHYSENDRUN_MASK_S3S2S12()); |
3356 |
|
if ( glA->GetPHYSENDRUN_MASK_S11CRC() ) glrun->SetPHYSENDRUN_MASK_S11CRC(glA->GetPHYSENDRUN_MASK_S11CRC()); |
3357 |
|
// |
3358 |
if ( glA->GetACQ_BUILD_INFO() != 0 ){ |
if ( glA->GetACQ_BUILD_INFO() != 0 ){ |
3359 |
// |
// |
3360 |
// 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! |
3361 |
// |
// |
3362 |
oss.str(""); |
glrun->SetCOMPILATIONTIMESTAMP(glA->GetCOMPILATIONTIMESTAMP()); |
3363 |
oss << "UPDATE GL_RUN_FRAGMENTS SET " |
glrun->SetFAV_WRK_SCHEDULE(glA->GetFAV_WRK_SCHEDULE()); |
3364 |
<< " RUNHEADER_TIME=" << glA->GetRUNHEADER_TIME()<< " , " |
glrun->SetEFF_WRK_SCHEDULE(glA->GetEFF_WRK_SCHEDULE()); |
3365 |
<< " RUNHEADER_OBT=" << glA->GetRUNHEADER_OBT()<< " , " |
glrun->SetPRH_VAR_TRG_MODE_A(glA->GetPRH_VAR_TRG_MODE_A()); |
3366 |
<< " RUNHEADER_PKT=" << glA->GetRUNHEADER_PKT()<< " , " |
glrun->SetPRH_VAR_TRG_MODE_B(glA->GetPRH_VAR_TRG_MODE_B()); |
3367 |
<< " COMPILATIONTIMESTAMP=" << glA->GetCOMPILATIONTIMESTAMP()<< " , " |
glrun->SetACQ_BUILD_INFO(glA->GetACQ_BUILD_INFO()); |
3368 |
<< " FAV_WRK_SCHEDULE=" << glA->GetFAV_WRK_SCHEDULE()<< " , " |
glrun->SetACQ_VAR_INFO(glA->GetACQ_VAR_INFO()); |
3369 |
<< " EFF_WRK_SCHEDULE=" << glA->GetEFF_WRK_SCHEDULE()<< " , " |
glrun->SetRM_ACQ_AFTER_CALIB(glA->GetRM_ACQ_AFTER_CALIB()); |
3370 |
<< " PRH_VAR_TRG_MODE_A=" << glA->GetPRH_VAR_TRG_MODE_A()<< " , " |
glrun->SetRM_ACQ_SETTING_MODE(glA->GetRM_ACQ_SETTING_MODE()); |
3371 |
<< " PRH_VAR_TRG_MODE_B=" << glA->GetPRH_VAR_TRG_MODE_B()<< " , " |
glrun->SetTRK_CALIB_USED(glA->GetTRK_CALIB_USED()); |
3372 |
<< " ACQ_BUILD_INFO=" << glA->GetACQ_BUILD_INFO()<< " , " |
glrun->SetCAL_DSP_MASK(glA->GetCAL_DSP_MASK()); |
3373 |
<< " ACQ_VAR_INFO=" << glA->GetACQ_VAR_INFO()<< " , " |
glrun->SetLAST_TIMESYNC(glA->GetLAST_TIMESYNC()); |
3374 |
<< " 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()<< " , "; |
|
3375 |
// |
// |
3376 |
if ( glA->GetPHYSENDRUN_MASK_S3S2S12() ) |
}; |
3377 |
oss << " PHYSENDRUN_MASK_S3S2S12=" << glA->GetPHYSENDRUN_MASK_S3S2S12() << " , "; |
// |
3378 |
if ( glA->GetPHYSENDRUN_MASK_S11CRC() ) |
if ( glA->GetPKT_READY_COUNTER() != 0 ){ |
|
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()); |
|
|
// |
|
|
} else { |
|
|
// |
|
|
// sig no runheader, let set anyway what is possible... |
|
3379 |
// |
// |
3380 |
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()<< " , "; |
|
3381 |
// |
// |
3382 |
if ( glA->GetPHYSENDRUN_MASK_S3S2S12() ) |
glrun->SetPKT_COUNTER(glA->GetPKT_COUNTER()); |
3383 |
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()); |
|
3384 |
}; |
}; |
3385 |
// |
// |
3386 |
// update runheader ROOT_ID_FRAG |
// update runheader ROOT_ID_FRAG |
3390 |
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()); |
3391 |
conn->Query(oss.str().c_str()); |
conn->Query(oss.str().c_str()); |
3392 |
// |
// |
|
// 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(); |
|
3393 |
oss.str(""); |
oss.str(""); |
3394 |
oss << " ID= "<< myi; |
oss << "SELECT ID FROM GL_RUN WHERE ID_RUN_FRAG = " << IDRL2A << ";"; |
3395 |
// |
if ( IsDebug() ) printf(" update gl_run to have cross indexing: %s\n",oss.str().c_str()); |
3396 |
glrun->Query_GL_RUN_FRAGMENTS(oss.str().c_str(),conn); |
TSQLResult *tsresult = 0; |
3397 |
|
TSQLRow *tsrow = 0; |
3398 |
|
tsresult=conn->Query(oss.str().c_str()); |
3399 |
|
if ( !tsresult ) throw -4; |
3400 |
|
tsrow = tsresult->Next(); |
3401 |
|
if ( !tsrow || tsresult->GetRowCount() != 1 ) throw -4; |
3402 |
|
IDRL2B = (UInt_t)atoll(tsrow->GetField(0)); |
3403 |
|
glrun->SetID_RUN_FRAG(IDRL2B); |
3404 |
// |
// |
3405 |
// fill the new run in GL_RUN |
// fill the new run in GL_RUN |
3406 |
// |
// |
|
glrun->SetID_RUN_FRAG(IDRL2B); |
|
3407 |
glrun->Fill_GL_RUN(conn); |
glrun->Fill_GL_RUN(conn); |
3408 |
|
// |
3409 |
glrun->DeleteRun(conn,0,"GL_RUN_FRAGMENTS"); |
glrun->DeleteRun(conn,0,"GL_RUN_FRAGMENTS"); |
3410 |
delete glA; |
delete glA; |
3411 |
// |
// |
3412 |
} else { |
} else { |
3413 |
|
// // |
3414 |
|
// // this is the case in which we must insert a piece of run between two fragments in the GL_RUN table |
3415 |
|
// // |
3416 |
|
// // 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 ) |
3417 |
|
// // |
3418 |
|
// GL_RUN *glA = new GL_RUN(); |
3419 |
|
// glA->Query_GL_RUN(IDRL2A,conn); |
3420 |
|
// // |
3421 |
|
// if ( glA->GetACQ_BUILD_INFO() != 0 ){ |
3422 |
|
// // |
3423 |
|
// // the first piece contains a good runheader we can update all the other runs with correct infos! |
3424 |
|
// // |
3425 |
|
// oss.str(""); |
3426 |
|
// oss << "UPDATE GL_RUN_FRAGMENTS SET " |
3427 |
|
// << " RUNHEADER_TIME=" << glA->GetRUNHEADER_TIME()<< " , " |
3428 |
|
// << " RUNHEADER_OBT=" << glA->GetRUNHEADER_OBT()<< " , " |
3429 |
|
// << " RUNHEADER_PKT=" << glA->GetRUNHEADER_PKT()<< " , " |
3430 |
|
// << " COMPILATIONTIMESTAMP=" << glA->GetCOMPILATIONTIMESTAMP()<< " , " |
3431 |
|
// << " FAV_WRK_SCHEDULE=" << glA->GetFAV_WRK_SCHEDULE()<< " , " |
3432 |
|
// << " EFF_WRK_SCHEDULE=" << glA->GetEFF_WRK_SCHEDULE()<< " , " |
3433 |
|
// << " PRH_VAR_TRG_MODE_A=" << glA->GetPRH_VAR_TRG_MODE_A()<< " , " |
3434 |
|
// << " PRH_VAR_TRG_MODE_B=" << glA->GetPRH_VAR_TRG_MODE_B()<< " , " |
3435 |
|
// << " ACQ_BUILD_INFO=" << glA->GetACQ_BUILD_INFO()<< " , " |
3436 |
|
// << " ACQ_VAR_INFO=" << glA->GetACQ_VAR_INFO()<< " , " |
3437 |
|
// << " RM_ACQ_AFTER_CALIB=" << glA->GetRM_ACQ_AFTER_CALIB()<< " , " |
3438 |
|
// << " RM_ACQ_SETTING_MODE=" << glA->GetRM_ACQ_SETTING_MODE()<< " , " |
3439 |
|
// << " TRK_CALIB_USED=" << glA->GetTRK_CALIB_USED()<< " , " |
3440 |
|
// << " CAL_DSP_MASK=" << glA->GetCAL_DSP_MASK()<< " , " |
3441 |
|
// << " LAST_TIMESYNC=" << glA->GetLAST_TIMESYNC()<< " , "; |
3442 |
|
// // |
3443 |
|
// if ( glA->GetPHYSENDRUN_MASK_S3S2S12() ) |
3444 |
|
// oss << " PHYSENDRUN_MASK_S3S2S12=" << glA->GetPHYSENDRUN_MASK_S3S2S12() << " , "; |
3445 |
|
// if ( glA->GetPHYSENDRUN_MASK_S11CRC() ) |
3446 |
|
// oss << " PHYSENDRUN_MASK_S11CRC=" << glA->GetPHYSENDRUN_MASK_S11CRC() << " , "; |
3447 |
|
// // |
3448 |
|
// oss << " OBT_TIMESYNC=" << glA->GetOBT_TIMESYNC(); |
3449 |
|
// oss << " WHERE ID=" << glrun->GetID() << ";"; |
3450 |
|
// if ( IsDebug() ) printf(" update with correct infos: %s\n",oss.str().c_str()); |
3451 |
|
// conn->Query(oss.str().c_str()); |
3452 |
|
// // |
3453 |
|
// } else { |
3454 |
|
// // |
3455 |
|
// // sig no runheader, let set anyway what is possible... |
3456 |
|
// // |
3457 |
|
// oss.str(""); |
3458 |
|
// oss << "UPDATE GL_RUN_FRAGMENTS SET " |
3459 |
|
// << " RUNHEADER_TIME=" << glA->GetRUNHEADER_TIME()<< " , "; |
3460 |
|
// // |
3461 |
|
// if ( glA->GetPHYSENDRUN_MASK_S3S2S12() ) |
3462 |
|
// oss << " PHYSENDRUN_MASK_S3S2S12=" << glA->GetPHYSENDRUN_MASK_S3S2S12()<< " , "; |
3463 |
|
// if ( glA->GetPHYSENDRUN_MASK_S11CRC() ) |
3464 |
|
// oss << " PHYSENDRUN_MASK_S11CRC=" << glA->GetPHYSENDRUN_MASK_S11CRC()<< " , "; |
3465 |
|
// // |
3466 |
|
// oss << " RUNHEADER_OBT=" << glA->GetRUNHEADER_OBT()<< " , " |
3467 |
|
// << " RUNHEADER_PKT=" << glA->GetRUNHEADER_PKT(); |
3468 |
|
// oss << " WHERE ID=" << glrun->GetID() << ";"; |
3469 |
|
// if ( IsDebug() ) printf(" update with correct infos2: %s\n",oss.str().c_str()); |
3470 |
|
// conn->Query(oss.str().c_str()); |
3471 |
|
// }; |
3472 |
|
// // |
3473 |
|
// // update runheader ROOT_ID_FRAG |
3474 |
|
// // |
3475 |
|
// oss.str(""); |
3476 |
|
// oss << "UPDATE GL_RUN SET ID_RUN_FRAG = " << glrun->GetID() << " where ID = " << IDRL2A << ";"; |
3477 |
|
// if ( IsDebug() ) printf(" update gl_run to have cross indexing: %s\n",oss.str().c_str()); |
3478 |
|
// conn->Query(oss.str().c_str()); |
3479 |
|
// // |
3480 |
|
// // now let's look for runtrailer if any in the last run |
3481 |
|
// // |
3482 |
|
// glA->Query_GL_RUN(IDRL2B,conn); |
3483 |
|
// // |
3484 |
|
// if ( glA->GetPKT_READY_COUNTER() != 0 ){ |
3485 |
|
// // |
3486 |
|
// // the first piece contains a good runtrailer we can update all the other runs with correct infos! |
3487 |
|
// // |
3488 |
|
// oss.str(""); |
3489 |
|
// oss << "UPDATE GL_RUN_FRAGMENTS SET " |
3490 |
|
// << " RUNTRAILER_TIME=" << glA->GetRUNTRAILER_TIME()<< " , " |
3491 |
|
// << " RUNTRAILER_OBT=" << glA->GetRUNTRAILER_OBT()<< " , " |
3492 |
|
// << " RUNTRAILER_PKT=" << glA->GetRUNTRAILER_PKT()<< " , " |
3493 |
|
// << " PKT_COUNTER=" << glA->GetPKT_COUNTER()<< " , "; |
3494 |
|
// // |
3495 |
|
// if ( glA->GetPHYSENDRUN_MASK_S3S2S12() ){ |
3496 |
|
// oss << " PHYSENDRUN_MASK_S3S2S12=" << glA->GetPHYSENDRUN_MASK_S3S2S12()<< " , "; }; |
3497 |
|
// if ( glA->GetPHYSENDRUN_MASK_S11CRC() ) { |
3498 |
|
// oss << " PHYSENDRUN_MASK_S11CRC=" << glA->GetPHYSENDRUN_MASK_S11CRC()<< " , "; }; |
3499 |
|
// // |
3500 |
|
// oss << " PKT_READY_COUNTER=" << glA->GetPKT_READY_COUNTER() |
3501 |
|
// << " WHERE ID=" << glrun->GetID() << ";"; |
3502 |
|
// if ( IsDebug() ) printf(" update with correct trailer infos: %s\n",oss.str().c_str()); |
3503 |
|
// conn->Query(oss.str().c_str()); |
3504 |
|
// // |
3505 |
|
// } else { |
3506 |
|
// // |
3507 |
|
// // sig no runtrailer, let set anyway what is possible... |
3508 |
|
// // |
3509 |
|
// oss.str(""); |
3510 |
|
// oss << "UPDATE GL_RUN_FRAGMENTS SET " |
3511 |
|
// << " RUNTRAILER_TIME=" << glA->GetRUNTRAILER_TIME()<< " , " |
3512 |
|
// << " RUNTRAILER_OBT=" << glA->GetRUNTRAILER_OBT()<< " , "; |
3513 |
|
// // |
3514 |
|
// if ( glA->GetPHYSENDRUN_MASK_S3S2S12() ){ |
3515 |
|
// oss << " PHYSENDRUN_MASK_S3S2S12=" << glA->GetPHYSENDRUN_MASK_S3S2S12()<< " , "; }; |
3516 |
|
// if ( glA->GetPHYSENDRUN_MASK_S11CRC() ){ |
3517 |
|
// oss << " PHYSENDRUN_MASK_S11CRC=" << glA->GetPHYSENDRUN_MASK_S11CRC()<< " , "; }; |
3518 |
|
// // |
3519 |
|
// oss << " RUNTRAILER_PKT=" << glrun->GetRUNTRAILER_PKT() |
3520 |
|
// << " WHERE ID=" << glrun->GetID() << ";"; |
3521 |
|
// if ( IsDebug() ) printf(" update with correct trailer infos2: %s\n",oss.str().c_str()); |
3522 |
|
// conn->Query(oss.str().c_str()); |
3523 |
|
// }; |
3524 |
|
// // |
3525 |
|
// UInt_t myi = glrun->GetID(); |
3526 |
|
// oss.str(""); |
3527 |
|
// oss << " ID= "<< myi; |
3528 |
|
// // |
3529 |
|
// glrun->Query_GL_RUN_FRAGMENTS(oss.str().c_str(),conn); |
3530 |
|
// // |
3531 |
|
// // fill the new run in GL_RUN |
3532 |
|
// // |
3533 |
|
// glrun->SetID_RUN_FRAG(IDRL2B); |
3534 |
|
// glrun->Fill_GL_RUN(conn); |
3535 |
|
// glrun->DeleteRun(conn,0,"GL_RUN_FRAGMENTS"); |
3536 |
|
// delete glA; |
3537 |
|
// // |
3538 |
|
// } else { |
3539 |
// |
// |
3540 |
// is just a repetition |
// is just a repetition |
3541 |
// |
// |