| 60 |
*/ |
*/ |
| 61 |
PamelaDBOperations::PamelaDBOperations(TString host, TString user, TString password, TString filerawname, TString filerootname, UInt_t boot, UInt_t tsync, UInt_t obt0, Bool_t debug, TString tlefilename, UInt_t dwinput, Bool_t staticp, Bool_t gpamela, Bool_t keepenv){ |
PamelaDBOperations::PamelaDBOperations(TString host, TString user, TString password, TString filerawname, TString filerootname, UInt_t boot, UInt_t tsync, UInt_t obt0, Bool_t debug, TString tlefilename, UInt_t dwinput, Bool_t staticp, Bool_t gpamela, Bool_t keepenv){ |
| 62 |
// |
// |
| 63 |
|
RELAXED = false; |
| 64 |
chewbacca = false; |
chewbacca = false; |
| 65 |
chminentry = 0; |
chminentry = 0; |
| 66 |
chID = 0; |
chID = 0; |
| 144 |
TString chfile; |
TString chfile; |
| 145 |
UInt_t ridn = 0; |
UInt_t ridn = 0; |
| 146 |
qu.str(""); |
qu.str(""); |
| 147 |
qu << "SELECT ROOT_ID_N,PKT_NUMBER_INIT,PKT_NUMBER_FINAL,PKT_OBT_INIT,PKT_OBT_FINAL,INSERTED_BY from ROOT_TABLE_MERGING where ID_N=" << chID << ";"; |
qu << "SELECT ROOT_ID_N,PKT_NUMBER_INIT,PKT_NUMBER_FINAL,PKT_OBT_INIT,PKT_OBT_FINAL,INSERTED_BY,REAL_TIME_INIT from ROOT_TABLE_MERGING where ID_N=" << chID << ";"; |
| 148 |
if ( debug ) printf(" chewbacca: query is %s \n",qu.str().c_str()); |
if ( debug ) printf(" chewbacca: query is %s \n",qu.str().c_str()); |
| 149 |
result = conn->Query(qu.str().c_str()); |
result = conn->Query(qu.str().c_str()); |
| 150 |
if ( result ){ |
if ( result ){ |
| 156 |
chobtmin = (UInt_t)atoll(row->GetField(3)); |
chobtmin = (UInt_t)atoll(row->GetField(3)); |
| 157 |
chobtmax = (UInt_t)atoll(row->GetField(4)); |
chobtmax = (UInt_t)atoll(row->GetField(4)); |
| 158 |
chiby = (TString)(row->GetField(5)); |
chiby = (TString)(row->GetField(5)); |
| 159 |
|
chrtinit = (UInt_t)atoll(row->GetField(6)); |
| 160 |
} else { |
} else { |
| 161 |
throw -84; |
throw -84; |
| 162 |
}; |
}; |
| 184 |
// |
// |
| 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 (REAL_TIME_INIT-"<< row2->GetField(10) <<")<7200 group by BOOT_NUMBER order by BOOT_NUMBER asc limit 1;"; |
// 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 <<")<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 ){ |
| 192 |
row3 = result3->Next(); |
row3 = result3->Next(); |
| 193 |
if ( row3 ){ |
if ( row3 && result3->GetRowCount() == 1 ){ |
| 194 |
chboot = (UInt_t)atoll(row3->GetField(0)); |
chboot = (UInt_t)atoll(row3->GetField(0)); |
| 195 |
if ( debug ) printf(" Found boot_number = %u \n",chboot); |
if ( debug ) printf(" Found boot_number = %u \n",chboot); |
| 196 |
} else { |
} else { |
| 197 |
if ( debug ) printf(" AGH CANNOT DETERMINE THE BOOT NUMBER... \n"); |
if ( debug ) printf(" AGH CANNOT DETERMINE THE BOOT NUMBER... \n"); |
| 198 |
|
throw -29; |
| 199 |
}; |
}; |
| 200 |
}; |
}; |
| 201 |
}; |
}; |
| 427 |
if ( IsDebug() ) printf(" Agh problems determining the orbit number! name = %s \n",name.Data()); |
if ( IsDebug() ) printf(" Agh problems determining the orbit number! name = %s \n",name.Data()); |
| 428 |
return; |
return; |
| 429 |
}; |
}; |
| 430 |
TString dwo = 0; |
TString dwo = ""; |
| 431 |
for (Int_t i = 0; i<5; i++){ |
for (Int_t i = 0; i<5; i++){ |
| 432 |
dwo.Append(name[i],1); |
dwo.Append(name[i],1); |
| 433 |
}; |
}; |
| 821 |
ph = eh->GetPscuHeader(); |
ph = eh->GetPscuHeader(); |
| 822 |
pktlast = ph->GetCounter(); |
pktlast = ph->GetCounter(); |
| 823 |
nevent = upperentry - chminentry; |
nevent = upperentry - chminentry; |
| 824 |
|
if ( ((Int_t)upperentry - (Int_t)chminentry) < 0 ) nevent = 0; // nevent is UInt_t! 090112 [8RED: error -88] |
| 825 |
|
if ( IsDebug() ) printf(" Setting nevent to %u - upperentry %i chminentry %i \n",nevent,upperentry,chminentry); |
| 826 |
// |
// |
| 827 |
} else { |
} else { |
| 828 |
upperpkt = PKT(pktlast); |
upperpkt = PKT(pktlast); |
| 831 |
}; |
}; |
| 832 |
// |
// |
| 833 |
if ( chewbacca && nevent < 1 ) { |
if ( chewbacca && nevent < 1 ) { |
| 834 |
|
if ( IsDebug() ) printf(" chewbacca and no events in the file \n"); |
| 835 |
pktfirst = chpktmin; |
pktfirst = chpktmin; |
| 836 |
upperpkt = PKT(chpktmax); |
upperpkt = PKT(chpktmax); |
| 837 |
pktlast = chpktmax; |
pktlast = chpktmax; |
| 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); |
| 1640 |
if ( !row ){ |
if ( !row ){ |
| 1641 |
oss.str(""); |
oss.str(""); |
| 1642 |
oss << "SELECT YEAR(OFFSET_DATE),MONTH(OFFSET_DATE),DAY(OFFSET_DATE),HOUR(OFFSET_DATE),MINUTE(OFFSET_DATE),SECOND(OFFSET_DATE),ID FROM GL_RESURS_OFFSET WHERE FROM_ORBIT< " |
oss << "SELECT YEAR(OFFSET_DATE),MONTH(OFFSET_DATE),DAY(OFFSET_DATE),HOUR(OFFSET_DATE),MINUTE(OFFSET_DATE),SECOND(OFFSET_DATE),ID FROM GL_RESURS_OFFSET WHERE FROM_ORBIT< " |
| 1643 |
<< dworbit << " order by FROM_ORBIT desc limit 1;"; |
<< dworbit << " AND SPECIAL_FILE='' order by FROM_ORBIT desc limit 1;"; |
| 1644 |
if ( IsDebug() ) printf(" %s \n",oss.str().c_str()); |
if ( IsDebug() ) printf(" %s \n",oss.str().c_str()); |
| 1645 |
result = conn->Query(oss.str().c_str()); |
result = conn->Query(oss.str().c_str()); |
| 1646 |
if ( !result ) throw -10; |
if ( !result ) throw -10; |
| 2737 |
glrun->Fill_GL_RUN_FRAGMENTS(conn); |
glrun->Fill_GL_RUN_FRAGMENTS(conn); |
| 2738 |
// |
// |
| 2739 |
} else { |
} else { |
| 2740 |
if ( IsDebug() ) printf(" The run is already present in the fragment table \n"); |
if ( IsDebug() ) printf(" The run is already present in the fragment table, relaxed %u \n",RELAXED); |
| 2741 |
if ( PEDANTIC ) throw -69; |
if ( !RELAXED ){ |
| 2742 |
return; |
if ( PEDANTIC ) throw -69; |
| 2743 |
|
return; |
| 2744 |
|
} else { |
| 2745 |
|
glrun->SetID((UInt_t)atoll(row->GetField(0))); |
| 2746 |
|
glrun->SetID_RUN_FRAG(0); |
| 2747 |
|
}; |
| 2748 |
}; |
}; |
| 2749 |
// |
// |
| 2750 |
if ( chewbacca && mishead && mistrail ) goto justcheck; |
if ( chewbacca && mishead && mistrail ) goto justcheck; |
| 3102 |
apkt = PKT(ph->GetCounter()); |
apkt = PKT(ph->GetCounter()); |
| 3103 |
aobt = OBT(ph->GetOrbitalTime()); |
aobt = OBT(ph->GetOrbitalTime()); |
| 3104 |
lastev--; |
lastev--; |
| 3105 |
if ( PEDANTIC ) throw -72; |
if ( PEDANTIC && !RELAXED) throw -72; |
| 3106 |
}; |
}; |
| 3107 |
if ( IsDebug() ) printf(" Check overlapping events done: %u %u %llu %llu lastev is %i\n",apkt,bpkt,aobt,bobt,lastev); |
if ( IsDebug() ) printf(" Check overlapping events done: %u %u %llu %llu lastev is %i\n",apkt,bpkt,aobt,bobt,lastev); |
| 3108 |
// |
// |
| 3170 |
// not found, has this run already inserted in the GL_RUN or in the GL_RUN_FRAGMENTS table? |
// not found, has this run already inserted in the GL_RUN or in the GL_RUN_FRAGMENTS table? |
| 3171 |
// |
// |
| 3172 |
oss.str(""); |
oss.str(""); |
| 3173 |
oss << " SELECT ID FROM GL_RUN WHERE " |
oss << " SELECT ID,ID_ROOT_L0 FROM GL_RUN WHERE " |
| 3174 |
<< " BOOT_NUMBER=" << this->GetBOOTnumber() << " AND (" |
<< " BOOT_NUMBER=" << this->GetBOOTnumber() << " AND (" |
| 3175 |
<< " (RUNHEADER_TIME>=" << (UInt_t)(glrun->GetRUNHEADER_TIME()-10) << " AND " |
<< " (RUNHEADER_TIME>=" << (UInt_t)(glrun->GetRUNHEADER_TIME()-10) << " AND " |
| 3176 |
<< " RUNTRAILER_TIME<=" << (UInt_t)(glrun->GetRUNTRAILER_TIME()+10) << " AND (" |
<< " RUNTRAILER_TIME<=" << (UInt_t)(glrun->GetRUNTRAILER_TIME()+10) << " AND (" |
| 3193 |
row = result->Next(); |
row = result->Next(); |
| 3194 |
// |
// |
| 3195 |
if ( row ){ |
if ( row ){ |
| 3196 |
if ( IsDebug() ) printf(" The run is already present in the GL_RUN table \n"); |
// |
| 3197 |
if ( PEDANTIC ) throw -70; |
// 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 |
| 3198 |
|
// "small gap" piece... we recognize this since: we have two entries from this query, the pkt number is consistent with our pkt number. |
| 3199 |
|
// |
| 3200 |
|
// 090112 [8RED (-70): RUN ALREADY INSERTED] |
| 3201 |
|
// |
| 3202 |
|
Bool_t OK = false; |
| 3203 |
|
UInt_t IDRL2A = 0; |
| 3204 |
|
UInt_t IDRL2B = 0; |
| 3205 |
|
if ( chewbacca ){ |
| 3206 |
|
if ( result->GetRowCount() == 2 ){ |
| 3207 |
|
IDRL2A = (UInt_t)atoll(row->GetField(0)); |
| 3208 |
|
UInt_t IDRL0A = (UInt_t)atoll(row->GetField(1)); |
| 3209 |
|
row = result->Next(); |
| 3210 |
|
IDRL2B = (UInt_t)atoll(row->GetField(0)); |
| 3211 |
|
UInt_t IDRL0B = (UInt_t)atoll(row->GetField(1)); |
| 3212 |
|
if ( IsDebug() ) printf(" IDRL0A %u B %u IDRL2A %u B %u \n",IDRL0A,IDRL0B,IDRL2A,IDRL2B); |
| 3213 |
|
if ( IDRL0A == IDRL0B ){ |
| 3214 |
|
TSQLResult *result2 = 0; |
| 3215 |
|
TSQLRow *row2 = 0; |
| 3216 |
|
oss.str(""); |
| 3217 |
|
oss << "select PKT_NUMBER_FINAL from ROOT_TABLE_MERGING where REAL_TIME_INIT<" << chrtinit << " order by REAL_TIME_INIT desc limit 1;"; |
| 3218 |
|
if ( IsDebug() ) printf(" Check if we are in the case RH---| small gap |---RT: query is \n %s \n",oss.str().c_str()); |
| 3219 |
|
result2 = conn->Query(oss.str().c_str()); |
| 3220 |
|
// |
| 3221 |
|
if ( !result2 ) throw -4; |
| 3222 |
|
// |
| 3223 |
|
row2 = result2->Next(); |
| 3224 |
|
// |
| 3225 |
|
if ( row2 ){ |
| 3226 |
|
UInt_t PKA = (UInt_t)atoll(row2->GetField(0)); |
| 3227 |
|
delete result2; |
| 3228 |
|
oss.str(""); |
| 3229 |
|
oss << "select PKT_NUMBER_INIT from ROOT_TABLE_MERGING where REAL_TIME_INIT>" << chrtinit << " order by REAL_TIME_INIT asc limit 1;"; |
| 3230 |
|
if ( IsDebug() ) printf(" Check if we are in the case RH---| small gap |---RT: query is \n %s \n",oss.str().c_str()); |
| 3231 |
|
result2 = conn->Query(oss.str().c_str()); |
| 3232 |
|
// |
| 3233 |
|
if ( !result2 ) throw -4; |
| 3234 |
|
// |
| 3235 |
|
row2 = result2->Next(); |
| 3236 |
|
// |
| 3237 |
|
if ( row2 ){ |
| 3238 |
|
UInt_t PKB = (UInt_t)atoll(row2->GetField(0)); |
| 3239 |
|
// |
| 3240 |
|
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); |
| 3241 |
|
if ( PKT(PKA)+1LL == PKT(glrun->GetRUNHEADER_PKT()) && PKT(PKB) == PKT(glrun->GetRUNTRAILER_PKT())+1LL ){ |
| 3242 |
|
if ( IsDebug() ) printf(" Ok, we are in the case: RH---| small gap |---RT \n"); |
| 3243 |
|
OK = true; |
| 3244 |
|
}; |
| 3245 |
|
}; |
| 3246 |
|
}; |
| 3247 |
|
}; |
| 3248 |
|
}; |
| 3249 |
|
}; |
| 3250 |
|
if ( OK ){ |
| 3251 |
|
// |
| 3252 |
|
// this is the case in which we must insert a piece of run between two fragments in the GL_RUN table |
| 3253 |
|
// |
| 3254 |
|
// 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 ) |
| 3255 |
|
// |
| 3256 |
|
GL_RUN *glA = new GL_RUN(); |
| 3257 |
|
glA->Query_GL_RUN(IDRL2A,conn); |
| 3258 |
|
// |
| 3259 |
|
if ( glA->GetACQ_BUILD_INFO() != 0 ){ |
| 3260 |
|
// |
| 3261 |
|
// the first piece contains a good runheader we can update all the other runs with correct infos! |
| 3262 |
|
// |
| 3263 |
|
oss.str(""); |
| 3264 |
|
oss << "UPDATE GL_RUN_FRAGMENTS SET " |
| 3265 |
|
<< " RUNHEADER_TIME=" << glA->GetRUNHEADER_TIME()<< " , " |
| 3266 |
|
<< " RUNHEADER_OBT=" << glA->GetRUNHEADER_OBT()<< " , " |
| 3267 |
|
<< " RUNHEADER_PKT=" << glA->GetRUNHEADER_PKT()<< " , " |
| 3268 |
|
<< " COMPILATIONTIMESTAMP=" << glA->GetCOMPILATIONTIMESTAMP()<< " , " |
| 3269 |
|
<< " FAV_WRK_SCHEDULE=" << glA->GetFAV_WRK_SCHEDULE()<< " , " |
| 3270 |
|
<< " EFF_WRK_SCHEDULE=" << glA->GetEFF_WRK_SCHEDULE()<< " , " |
| 3271 |
|
<< " PRH_VAR_TRG_MODE_A=" << glA->GetPRH_VAR_TRG_MODE_A()<< " , " |
| 3272 |
|
<< " PRH_VAR_TRG_MODE_B=" << glA->GetPRH_VAR_TRG_MODE_B()<< " , " |
| 3273 |
|
<< " ACQ_BUILD_INFO=" << glA->GetACQ_BUILD_INFO()<< " , " |
| 3274 |
|
<< " ACQ_VAR_INFO=" << glA->GetACQ_VAR_INFO()<< " , " |
| 3275 |
|
<< " RM_ACQ_AFTER_CALIB=" << glA->GetRM_ACQ_AFTER_CALIB()<< " , " |
| 3276 |
|
<< " RM_ACQ_SETTING_MODE=" << glA->GetRM_ACQ_SETTING_MODE()<< " , " |
| 3277 |
|
<< " TRK_CALIB_USED=" << glA->GetTRK_CALIB_USED()<< " , " |
| 3278 |
|
<< " CAL_DSP_MASK=" << glA->GetCAL_DSP_MASK()<< " , " |
| 3279 |
|
<< " LAST_TIMESYNC=" << glA->GetLAST_TIMESYNC()<< " , "; |
| 3280 |
|
// |
| 3281 |
|
if ( glA->GetPHYSENDRUN_MASK_S3S2S12() ) |
| 3282 |
|
oss << " PHYSENDRUN_MASK_S3S2S12=" << glA->GetPHYSENDRUN_MASK_S3S2S12() << " , "; |
| 3283 |
|
if ( glA->GetPHYSENDRUN_MASK_S11CRC() ) |
| 3284 |
|
oss << " PHYSENDRUN_MASK_S11CRC=" << glA->GetPHYSENDRUN_MASK_S11CRC() << " , "; |
| 3285 |
|
// |
| 3286 |
|
oss << " OBT_TIMESYNC=" << glA->GetOBT_TIMESYNC(); |
| 3287 |
|
oss << " WHERE ID=" << glrun->GetID() << ";"; |
| 3288 |
|
if ( IsDebug() ) printf(" update with correct infos: %s\n",oss.str().c_str()); |
| 3289 |
|
conn->Query(oss.str().c_str()); |
| 3290 |
|
// |
| 3291 |
|
} else { |
| 3292 |
|
// |
| 3293 |
|
// sig no runheader, let set anyway what is possible... |
| 3294 |
|
// |
| 3295 |
|
oss.str(""); |
| 3296 |
|
oss << "UPDATE GL_RUN_FRAGMENTS SET " |
| 3297 |
|
<< " RUNHEADER_TIME=" << glA->GetRUNHEADER_TIME()<< " , "; |
| 3298 |
|
// |
| 3299 |
|
if ( glA->GetPHYSENDRUN_MASK_S3S2S12() ) |
| 3300 |
|
oss << " PHYSENDRUN_MASK_S3S2S12=" << glA->GetPHYSENDRUN_MASK_S3S2S12()<< " , "; |
| 3301 |
|
if ( glA->GetPHYSENDRUN_MASK_S11CRC() ) |
| 3302 |
|
oss << " PHYSENDRUN_MASK_S11CRC=" << glA->GetPHYSENDRUN_MASK_S11CRC()<< " , "; |
| 3303 |
|
// |
| 3304 |
|
oss << " RUNHEADER_OBT=" << glA->GetRUNHEADER_OBT()<< " , " |
| 3305 |
|
<< " RUNHEADER_PKT=" << glA->GetRUNHEADER_PKT(); |
| 3306 |
|
oss << " WHERE ID=" << glrun->GetID() << ";"; |
| 3307 |
|
if ( IsDebug() ) printf(" update with correct infos2: %s\n",oss.str().c_str()); |
| 3308 |
|
conn->Query(oss.str().c_str()); |
| 3309 |
|
}; |
| 3310 |
|
// |
| 3311 |
|
// update runheader ROOT_ID_FRAG |
| 3312 |
|
// |
| 3313 |
|
oss.str(""); |
| 3314 |
|
oss << "UPDATE GL_RUN SET ID_RUN_FRAG = " << glrun->GetID() << " where ID = " << IDRL2A << ";"; |
| 3315 |
|
if ( IsDebug() ) printf(" update gl_run to have cross indexing: %s\n",oss.str().c_str()); |
| 3316 |
|
conn->Query(oss.str().c_str()); |
| 3317 |
|
// |
| 3318 |
|
// now let's look for runtrailer if any in the last run |
| 3319 |
|
// |
| 3320 |
|
glA->Query_GL_RUN(IDRL2B,conn); |
| 3321 |
|
// |
| 3322 |
|
if ( glA->GetPKT_READY_COUNTER() != 0 ){ |
| 3323 |
|
// |
| 3324 |
|
// the first piece contains a good runtrailer we can update all the other runs with correct infos! |
| 3325 |
|
// |
| 3326 |
|
oss.str(""); |
| 3327 |
|
oss << "UPDATE GL_RUN_FRAGMENTS SET " |
| 3328 |
|
<< " RUNTRAILER_TIME=" << glA->GetRUNTRAILER_TIME()<< " , " |
| 3329 |
|
<< " RUNTRAILER_OBT=" << glA->GetRUNTRAILER_OBT()<< " , " |
| 3330 |
|
<< " RUNTRAILER_PKT=" << glA->GetRUNTRAILER_PKT()<< " , " |
| 3331 |
|
<< " PKT_COUNTER=" << glA->GetPKT_COUNTER()<< " , "; |
| 3332 |
|
// |
| 3333 |
|
if ( glA->GetPHYSENDRUN_MASK_S3S2S12() ){ |
| 3334 |
|
oss << " PHYSENDRUN_MASK_S3S2S12=" << glA->GetPHYSENDRUN_MASK_S3S2S12()<< " , "; }; |
| 3335 |
|
if ( glA->GetPHYSENDRUN_MASK_S11CRC() ) { |
| 3336 |
|
oss << " PHYSENDRUN_MASK_S11CRC=" << glA->GetPHYSENDRUN_MASK_S11CRC()<< " , "; }; |
| 3337 |
|
// |
| 3338 |
|
oss << " PKT_READY_COUNTER=" << glA->GetPKT_READY_COUNTER() |
| 3339 |
|
<< " WHERE ID=" << glrun->GetID() << ";"; |
| 3340 |
|
if ( IsDebug() ) printf(" update with correct trailer infos: %s\n",oss.str().c_str()); |
| 3341 |
|
conn->Query(oss.str().c_str()); |
| 3342 |
|
// |
| 3343 |
|
} else { |
| 3344 |
|
// |
| 3345 |
|
// sig no runtrailer, let set anyway what is possible... |
| 3346 |
|
// |
| 3347 |
|
oss.str(""); |
| 3348 |
|
oss << "UPDATE GL_RUN_FRAGMENTS SET " |
| 3349 |
|
<< " RUNTRAILER_TIME=" << glA->GetRUNTRAILER_TIME()<< " , " |
| 3350 |
|
<< " RUNTRAILER_OBT=" << glA->GetRUNTRAILER_OBT()<< " , "; |
| 3351 |
|
// |
| 3352 |
|
if ( glA->GetPHYSENDRUN_MASK_S3S2S12() ){ |
| 3353 |
|
oss << " PHYSENDRUN_MASK_S3S2S12=" << glA->GetPHYSENDRUN_MASK_S3S2S12()<< " , "; }; |
| 3354 |
|
if ( glA->GetPHYSENDRUN_MASK_S11CRC() ){ |
| 3355 |
|
oss << " PHYSENDRUN_MASK_S11CRC=" << glA->GetPHYSENDRUN_MASK_S11CRC()<< " , "; }; |
| 3356 |
|
// |
| 3357 |
|
oss << " RUNTRAILER_PKT=" << glrun->GetRUNTRAILER_PKT() |
| 3358 |
|
<< " WHERE ID=" << glrun->GetID() << ";"; |
| 3359 |
|
if ( IsDebug() ) printf(" update with correct trailer infos2: %s\n",oss.str().c_str()); |
| 3360 |
|
conn->Query(oss.str().c_str()); |
| 3361 |
|
}; |
| 3362 |
|
// |
| 3363 |
|
UInt_t myi = glrun->GetID(); |
| 3364 |
|
oss.str(""); |
| 3365 |
|
oss << " ID= "<< myi; |
| 3366 |
|
// |
| 3367 |
|
glrun->Query_GL_RUN_FRAGMENTS(oss.str().c_str(),conn); |
| 3368 |
|
// |
| 3369 |
|
// fill the new run in GL_RUN |
| 3370 |
|
// |
| 3371 |
|
glrun->SetID_RUN_FRAG(IDRL2B); |
| 3372 |
|
glrun->Fill_GL_RUN(conn); |
| 3373 |
|
glrun->DeleteRun(conn,0,"GL_RUN_FRAGMENTS"); |
| 3374 |
|
delete glA; |
| 3375 |
|
// |
| 3376 |
|
} else { |
| 3377 |
|
// |
| 3378 |
|
// is just a repetition |
| 3379 |
|
// |
| 3380 |
|
if ( IsDebug() ) printf(" The run is already present in the GL_RUN table \n"); |
| 3381 |
|
if ( PEDANTIC ) throw -70; |
| 3382 |
|
}; |
| 3383 |
|
// |
| 3384 |
} else { |
} else { |
| 3385 |
if ( NoFrag() ){ |
if ( NoFrag() ){ |
| 3386 |
glrun->SetID_RUN_FRAG(glrun->GetID()); |
glrun->SetID_RUN_FRAG(glrun->GetID()); |
| 4950 |
if ( !result ) throw -4;; |
if ( !result ) throw -4;; |
| 4951 |
row = result->Next(); |
row = result->Next(); |
| 4952 |
if(row)glcal->ID = (UInt_t)atoll(row->GetField(0)); |
if(row)glcal->ID = (UInt_t)atoll(row->GetField(0)); |
| 4953 |
|
// |
| 4954 |
|
delete result; // mmm... "Error in <TMySQLResult::Next>: result set closed" solved? 090112 [8RED error messages] |
| 4955 |
// |
// |
| 4956 |
}; |
}; |
| 4957 |
|
|
| 5459 |
|
|
| 5460 |
if(FOUND){ |
if(FOUND){ |
| 5461 |
|
|
| 5462 |
if ( IsDebug() ) cout << " >>> REPETITION FOUND :-) <<<" <<endl; |
if ( IsDebug() ) cout << " >>> REPETITION FOUND :-) <<<" <<endl; |
| 5463 |
|
|
| 5464 |
//////////////////////////////////////////// |
//////////////////////////////////////////// |
| 5465 |
// insert a new entry in GL_TRK_CALIB and |
// insert a new entry in GL_TRK_CALIB and |
| 5466 |
// modify the time-tag of the previous one |
// modify the time-tag of the previous one |
| 5467 |
//////////////////////////////////////////// |
//////////////////////////////////////////// |
| 5468 |
|
|
| 5469 |
// --------------------------------------------------------------------- |
// --------------------------------------------------------------------- |
| 5470 |
// step 1: insert a new raw file in GL_RAW |
// step 1: insert a new raw file in GL_RAW |
| 5471 |
// --------------------------------------------------------------------- |
// --------------------------------------------------------------------- |
| 5472 |
// |
// |
| 5473 |
// check if the raw file already exist |
// check if the raw file already exist |
| 5474 |
// |
// |
| 5475 |
UInt_t id_raw = 0; // EM GL_RAW is there only for backward compatibility so we do not need to fill it when in "chewbacca" mode |
UInt_t id_raw = 0; // EM GL_RAW is there only for backward compatibility so we do not need to fill it when in "chewbacca" mode |
| 5476 |
// oss.str(""); |
// oss.str(""); |
| 5477 |
// oss << "SELECT ID FROM GL_RAW where NAME=\"" << gSystem->BaseName(raw.Data()) <<"\";"; |
// oss << "SELECT ID FROM GL_RAW where NAME=\"" << gSystem->BaseName(raw.Data()) <<"\";"; |
| 5478 |
// if ( IsDebug() ) cout << oss.str().c_str() << endl; |
// if ( IsDebug() ) cout << oss.str().c_str() << endl; |
| 5479 |
|
|
| 5480 |
// result = conn->Query(oss.str().c_str()); |
// result = conn->Query(oss.str().c_str()); |
| 5481 |
// if ( !result ) throw -4;; |
// if ( !result ) throw -4;; |
| 5482 |
// if ( IsDebug() ) cout <<"Rows: "<<result->GetRowCount()<<endl; |
// if ( IsDebug() ) cout <<"Rows: "<<result->GetRowCount()<<endl; |
| 5483 |
// if( result->GetRowCount() == 0){ |
// if( result->GetRowCount() == 0){ |
| 5484 |
// if ( IsDebug() ) cout << " << Insert new RAW file >> "<<endl; |
// if ( IsDebug() ) cout << " << Insert new RAW file >> "<<endl; |
| 5485 |
// // - - - - - - - - - - - |
// // - - - - - - - - - - - |
| 5486 |
// // insert new raw file |
// // insert new raw file |
| 5487 |
// // - - - - - - - - - - - |
// // - - - - - - - - - - - |
| 5488 |
// GL_RAW glraw = GL_RAW(); |
// GL_RAW glraw = GL_RAW(); |
| 5489 |
// glraw.PATH = gSystem->DirName(raw.Data()); |
// glraw.PATH = gSystem->DirName(raw.Data()); |
| 5490 |
// glraw.NAME = gSystem->BaseName(raw.Data()); |
// glraw.NAME = gSystem->BaseName(raw.Data()); |
| 5491 |
// glraw.BOOT_NUMBER = boot_number; |
// glraw.BOOT_NUMBER = boot_number; |
| 5492 |
// // |
// // |
| 5493 |
// insertPamelaRawFile( &glraw ); |
// insertPamelaRawFile( &glraw ); |
| 5494 |
// // |
// // |
| 5495 |
// id_raw = glraw.ID; |
// id_raw = glraw.ID; |
| 5496 |
// }else{ |
// }else{ |
| 5497 |
// row = result->Next(); |
// row = result->Next(); |
| 5498 |
// id_raw = (UInt_t)atoll(row->GetField(0)); |
// id_raw = (UInt_t)atoll(row->GetField(0)); |
| 5499 |
// } |
// } |
| 5500 |
// if ( IsDebug() ) cout << "ID_RAW = "<<id_raw<<endl; |
// if ( IsDebug() ) cout << "ID_RAW = "<<id_raw<<endl; |
| 5501 |
|
|
| 5502 |
// --------------------------------------------------------------------- |
// --------------------------------------------------------------------- |
| 5503 |
// step 1(bis): retrieve the timesync id associated to the file |
// step 1(bis): retrieve the timesync id associated to the file |
| 5504 |
// (NB, uso lo stesso associato al file iniziale) |
// (NB, uso lo stesso associato al file iniziale) |
| 5505 |
// --------------------------------------------------------------------- |
// --------------------------------------------------------------------- |
| 5506 |
UInt_t idtimesync = 0; |
UInt_t idtimesync = 0; |
| 5507 |
oss.str(""); |
oss.str(""); |
| 5508 |
oss << " SELECT ID FROM GL_TIMESYNC where TIMESYNC="<<chlastts<<" AND OBT0="<<chobtts*1000<<" limit 1;"; |
oss << " SELECT ID FROM GL_TIMESYNC where TIMESYNC="<<chlastts<<" AND OBT0="<<chobtts*1000<<" limit 1;"; |
| 5509 |
if ( debug ) printf(" %s \n",oss.str().c_str()); |
if ( debug ) printf(" %s \n",oss.str().c_str()); |
| 5510 |
result = conn->Query(oss.str().c_str()); |
result = conn->Query(oss.str().c_str()); |
| 5511 |
if ( !result ) throw -3; |
if ( !result ) throw -3; |
| 5512 |
row = result->Next(); |
row = result->Next(); |
| 5513 |
if ( !row ) throw -3; |
if ( !row ) throw -3; |
| 5514 |
idtimesync = (UInt_t)atoll(row->GetField(0)); |
idtimesync = (UInt_t)atoll(row->GetField(0)); |
| 5515 |
if ( IsDebug() ) cout << "ID_TIMESYNC = "<<idtimesync<<endl; |
if ( IsDebug() ) cout << "ID_TIMESYNC = "<<idtimesync<<endl; |
| 5516 |
|
|
| 5517 |
|
delete result;// mmm... "Error in <TMySQLResult::Next>: result set closed" solved? 090112 [8RED error messages] |
| 5518 |
// --------------------------------------------------------------------- |
// --------------------------------------------------------------------- |
| 5519 |
// step 2: insert a new root file in GL_ROOT |
// step 2: insert a new root file in GL_ROOT |
| 5520 |
// --------------------------------------------------------------------- |
// --------------------------------------------------------------------- |
| 5562 |
} |
} |
| 5563 |
if ( IsDebug() ) cout << "ID_ROOT = "<<id_root<<endl; |
if ( IsDebug() ) cout << "ID_ROOT = "<<id_root<<endl; |
| 5564 |
|
|
| 5565 |
|
delete result;// mmm... "Error in <TMySQLResult::Next>: result set closed" solved? 090112 [8RED error messages] |
| 5566 |
// --------------------------------------------------------------------- |
// --------------------------------------------------------------------- |
| 5567 |
// step 3: modify time-tag of corrupted GL_TRK_CALIB entry |
// step 3: modify time-tag of corrupted GL_TRK_CALIB entry |
| 5568 |
// --------------------------------------------------------------------- |
// --------------------------------------------------------------------- |
| 5575 |
result = conn->Query(oss.str().c_str()); |
result = conn->Query(oss.str().c_str()); |
| 5576 |
if ( !result ) throw -4;; |
if ( !result ) throw -4;; |
| 5577 |
|
|
| 5578 |
|
delete result; // mmm... "Error in <TMySQLResult::Next>: result set closed" solved? 090112 [8RED error messages] |
| 5579 |
|
|
| 5580 |
// --------------------------------------------------------------------- |
// --------------------------------------------------------------------- |
| 5581 |
// step 4: insert the new calibration: |
// step 4: insert the new calibration: |
| 5582 |
// --------------------------------------------------------------------- |
// --------------------------------------------------------------------- |
| 6028 |
oss << " PHYSENDRUN_MASK_S11CRC=" << glrun->GetPHYSENDRUN_MASK_S11CRC()<< " , "; |
oss << " PHYSENDRUN_MASK_S11CRC=" << glrun->GetPHYSENDRUN_MASK_S11CRC()<< " , "; |
| 6029 |
// |
// |
| 6030 |
oss << " RUNHEADER_OBT=" << glrun->GetRUNHEADER_OBT()<< " , " |
oss << " RUNHEADER_OBT=" << glrun->GetRUNHEADER_OBT()<< " , " |
| 6031 |
<< " RUNHEADER_PKT=" << glrun->GetRUNHEADER_PKT()<< ";"; |
<< " RUNHEADER_PKT=" << glrun->GetRUNHEADER_PKT(); |
| 6032 |
|
oss << " WHERE ID=" << myid[u] << ";"; // BUG!!! 090112 |
| 6033 |
conn->Query(oss.str().c_str()); |
conn->Query(oss.str().c_str()); |
| 6034 |
}; |
}; |
| 6035 |
}; |
}; |
| 6078 |
if ( glrun->GetPHYSENDRUN_MASK_S11CRC() ){ |
if ( glrun->GetPHYSENDRUN_MASK_S11CRC() ){ |
| 6079 |
oss << " PHYSENDRUN_MASK_S11CRC=" << glrun->GetPHYSENDRUN_MASK_S11CRC()<< " , "; }; |
oss << " PHYSENDRUN_MASK_S11CRC=" << glrun->GetPHYSENDRUN_MASK_S11CRC()<< " , "; }; |
| 6080 |
// |
// |
| 6081 |
oss << " RUNTRAILER_PKT=" << glrun->GetRUNTRAILER_PKT()<< ";"; |
oss << " RUNTRAILER_PKT=" << glrun->GetRUNTRAILER_PKT(); |
| 6082 |
|
oss << " WHERE ID=" << myid[u] << ";"; // BUG!!! 090112 |
| 6083 |
conn->Query(oss.str().c_str()); |
conn->Query(oss.str().c_str()); |
| 6084 |
}; |
}; |
| 6085 |
}; |
}; |
| 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 |
// |
// |