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;"; |
// 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] |
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 ){ |
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; |
2729 |
glrun->Fill_GL_RUN_FRAGMENTS(conn); |
glrun->Fill_GL_RUN_FRAGMENTS(conn); |
2730 |
// |
// |
2731 |
} else { |
} else { |
2732 |
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); |
2733 |
if ( PEDANTIC ) throw -69; |
if ( !RELAXED ){ |
2734 |
return; |
if ( PEDANTIC ) throw -69; |
2735 |
|
return; |
2736 |
|
} else { |
2737 |
|
glrun->SetID((UInt_t)atoll(row->GetField(0))); |
2738 |
|
glrun->SetID_RUN_FRAG(0); |
2739 |
|
}; |
2740 |
}; |
}; |
2741 |
// |
// |
2742 |
if ( chewbacca && mishead && mistrail ) goto justcheck; |
if ( chewbacca && mishead && mistrail ) goto justcheck; |
3094 |
apkt = PKT(ph->GetCounter()); |
apkt = PKT(ph->GetCounter()); |
3095 |
aobt = OBT(ph->GetOrbitalTime()); |
aobt = OBT(ph->GetOrbitalTime()); |
3096 |
lastev--; |
lastev--; |
3097 |
if ( PEDANTIC ) throw -72; |
if ( PEDANTIC && !RELAXED) throw -72; |
3098 |
}; |
}; |
3099 |
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); |
3100 |
// |
// |
3162 |
// 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? |
3163 |
// |
// |
3164 |
oss.str(""); |
oss.str(""); |
3165 |
oss << " SELECT ID FROM GL_RUN WHERE " |
oss << " SELECT ID,ID_ROOT_L0 FROM GL_RUN WHERE " |
3166 |
<< " BOOT_NUMBER=" << this->GetBOOTnumber() << " AND (" |
<< " BOOT_NUMBER=" << this->GetBOOTnumber() << " AND (" |
3167 |
<< " (RUNHEADER_TIME>=" << (UInt_t)(glrun->GetRUNHEADER_TIME()-10) << " AND " |
<< " (RUNHEADER_TIME>=" << (UInt_t)(glrun->GetRUNHEADER_TIME()-10) << " AND " |
3168 |
<< " RUNTRAILER_TIME<=" << (UInt_t)(glrun->GetRUNTRAILER_TIME()+10) << " AND (" |
<< " RUNTRAILER_TIME<=" << (UInt_t)(glrun->GetRUNTRAILER_TIME()+10) << " AND (" |
3185 |
row = result->Next(); |
row = result->Next(); |
3186 |
// |
// |
3187 |
if ( row ){ |
if ( row ){ |
3188 |
if ( IsDebug() ) printf(" The run is already present in the GL_RUN table \n"); |
// |
3189 |
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 |
3190 |
|
// "small gap" piece... we recognize this since: we have two entries from this query, the pkt number is consistent with our pkt number. |
3191 |
|
// |
3192 |
|
// 090112 [8RED (-70): RUN ALREADY INSERTED] |
3193 |
|
// |
3194 |
|
Bool_t OK = false; |
3195 |
|
UInt_t IDRL2A = 0; |
3196 |
|
UInt_t IDRL2B = 0; |
3197 |
|
if ( chewbacca ){ |
3198 |
|
if ( result->GetRowCount() == 2 ){ |
3199 |
|
IDRL2A = (UInt_t)atoll(row->GetField(0)); |
3200 |
|
UInt_t IDRL0A = (UInt_t)atoll(row->GetField(1)); |
3201 |
|
row = result->Next(); |
3202 |
|
IDRL2B = (UInt_t)atoll(row->GetField(0)); |
3203 |
|
UInt_t IDRL0B = (UInt_t)atoll(row->GetField(1)); |
3204 |
|
if ( IsDebug() ) printf(" IDRL0A %u B %u IDRL2A %u B %u \n",IDRL0A,IDRL0B,IDRL2A,IDRL2B); |
3205 |
|
if ( IDRL0A == IDRL0B ){ |
3206 |
|
TSQLResult *result2 = 0; |
3207 |
|
TSQLRow *row2 = 0; |
3208 |
|
oss.str(""); |
3209 |
|
oss << "select PKT_NUMBER_FINAL from ROOT_TABLE_MERGING where REAL_TIME_INIT<" << chrtinit << " order by REAL_TIME_INIT desc limit 1;"; |
3210 |
|
if ( IsDebug() ) printf(" Check if we are in the case RH---| small gap |---RT: query is \n %s \n",oss.str().c_str()); |
3211 |
|
result2 = conn->Query(oss.str().c_str()); |
3212 |
|
// |
3213 |
|
if ( !result2 ) throw -4; |
3214 |
|
// |
3215 |
|
row2 = result2->Next(); |
3216 |
|
// |
3217 |
|
if ( row2 ){ |
3218 |
|
UInt_t PKA = (UInt_t)atoll(row2->GetField(0)); |
3219 |
|
delete result2; |
3220 |
|
oss.str(""); |
3221 |
|
oss << "select PKT_NUMBER_INIT from ROOT_TABLE_MERGING where REAL_TIME_INIT>" << chrtinit << " order by REAL_TIME_INIT asc limit 1;"; |
3222 |
|
if ( IsDebug() ) printf(" Check if we are in the case RH---| small gap |---RT: query is \n %s \n",oss.str().c_str()); |
3223 |
|
result2 = conn->Query(oss.str().c_str()); |
3224 |
|
// |
3225 |
|
if ( !result2 ) throw -4; |
3226 |
|
// |
3227 |
|
row2 = result2->Next(); |
3228 |
|
// |
3229 |
|
if ( row2 ){ |
3230 |
|
UInt_t PKB = (UInt_t)atoll(row2->GetField(0)); |
3231 |
|
// |
3232 |
|
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); |
3233 |
|
if ( PKT(PKA)+1LL == PKT(glrun->GetRUNHEADER_PKT()) && PKT(PKB) == PKT(glrun->GetRUNTRAILER_PKT())+1LL ){ |
3234 |
|
if ( IsDebug() ) printf(" Ok, we are in the case: RH---| small gap |---RT \n"); |
3235 |
|
OK = true; |
3236 |
|
}; |
3237 |
|
}; |
3238 |
|
}; |
3239 |
|
}; |
3240 |
|
}; |
3241 |
|
}; |
3242 |
|
if ( OK ){ |
3243 |
|
// |
3244 |
|
// this is the case in which we must insert a piece of run between two fragments in the GL_RUN table |
3245 |
|
// |
3246 |
|
// 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 ) |
3247 |
|
// |
3248 |
|
GL_RUN *glA = new GL_RUN(); |
3249 |
|
glA->Query_GL_RUN(IDRL2A,conn); |
3250 |
|
// |
3251 |
|
if ( glA->GetACQ_BUILD_INFO() != 0 ){ |
3252 |
|
// |
3253 |
|
// the first piece contains a good runheader we can update all the other runs with correct infos! |
3254 |
|
// |
3255 |
|
oss.str(""); |
3256 |
|
oss << "UPDATE GL_RUN_FRAGMENTS SET " |
3257 |
|
<< " RUNHEADER_TIME=" << glA->GetRUNHEADER_TIME()<< " , " |
3258 |
|
<< " RUNHEADER_OBT=" << glA->GetRUNHEADER_OBT()<< " , " |
3259 |
|
<< " RUNHEADER_PKT=" << glA->GetRUNHEADER_PKT()<< " , " |
3260 |
|
<< " COMPILATIONTIMESTAMP=" << glA->GetCOMPILATIONTIMESTAMP()<< " , " |
3261 |
|
<< " FAV_WRK_SCHEDULE=" << glA->GetFAV_WRK_SCHEDULE()<< " , " |
3262 |
|
<< " EFF_WRK_SCHEDULE=" << glA->GetEFF_WRK_SCHEDULE()<< " , " |
3263 |
|
<< " PRH_VAR_TRG_MODE_A=" << glA->GetPRH_VAR_TRG_MODE_A()<< " , " |
3264 |
|
<< " PRH_VAR_TRG_MODE_B=" << glA->GetPRH_VAR_TRG_MODE_B()<< " , " |
3265 |
|
<< " ACQ_BUILD_INFO=" << glA->GetACQ_BUILD_INFO()<< " , " |
3266 |
|
<< " ACQ_VAR_INFO=" << glA->GetACQ_VAR_INFO()<< " , " |
3267 |
|
<< " RM_ACQ_AFTER_CALIB=" << glA->GetRM_ACQ_AFTER_CALIB()<< " , " |
3268 |
|
<< " RM_ACQ_SETTING_MODE=" << glA->GetRM_ACQ_SETTING_MODE()<< " , " |
3269 |
|
<< " TRK_CALIB_USED=" << glA->GetTRK_CALIB_USED()<< " , " |
3270 |
|
<< " CAL_DSP_MASK=" << glA->GetCAL_DSP_MASK()<< " , " |
3271 |
|
<< " LAST_TIMESYNC=" << glA->GetLAST_TIMESYNC()<< " , "; |
3272 |
|
// |
3273 |
|
if ( glA->GetPHYSENDRUN_MASK_S3S2S12() ) |
3274 |
|
oss << " PHYSENDRUN_MASK_S3S2S12=" << glA->GetPHYSENDRUN_MASK_S3S2S12() << " , "; |
3275 |
|
if ( glA->GetPHYSENDRUN_MASK_S11CRC() ) |
3276 |
|
oss << " PHYSENDRUN_MASK_S11CRC=" << glA->GetPHYSENDRUN_MASK_S11CRC() << " , "; |
3277 |
|
// |
3278 |
|
oss << " OBT_TIMESYNC=" << glA->GetOBT_TIMESYNC(); |
3279 |
|
oss << " WHERE ID=" << glrun->GetID() << ";"; |
3280 |
|
if ( IsDebug() ) printf(" update with correct infos: %s\n",oss.str().c_str()); |
3281 |
|
conn->Query(oss.str().c_str()); |
3282 |
|
// |
3283 |
|
} else { |
3284 |
|
// |
3285 |
|
// sig no runheader, let set anyway what is possible... |
3286 |
|
// |
3287 |
|
oss.str(""); |
3288 |
|
oss << "UPDATE GL_RUN_FRAGMENTS SET " |
3289 |
|
<< " RUNHEADER_TIME=" << glA->GetRUNHEADER_TIME()<< " , "; |
3290 |
|
// |
3291 |
|
if ( glA->GetPHYSENDRUN_MASK_S3S2S12() ) |
3292 |
|
oss << " PHYSENDRUN_MASK_S3S2S12=" << glA->GetPHYSENDRUN_MASK_S3S2S12()<< " , "; |
3293 |
|
if ( glA->GetPHYSENDRUN_MASK_S11CRC() ) |
3294 |
|
oss << " PHYSENDRUN_MASK_S11CRC=" << glA->GetPHYSENDRUN_MASK_S11CRC()<< " , "; |
3295 |
|
// |
3296 |
|
oss << " RUNHEADER_OBT=" << glA->GetRUNHEADER_OBT()<< " , " |
3297 |
|
<< " RUNHEADER_PKT=" << glA->GetRUNHEADER_PKT(); |
3298 |
|
oss << " WHERE ID=" << glrun->GetID() << ";"; |
3299 |
|
if ( IsDebug() ) printf(" update with correct infos2: %s\n",oss.str().c_str()); |
3300 |
|
conn->Query(oss.str().c_str()); |
3301 |
|
}; |
3302 |
|
// |
3303 |
|
// update runheader ROOT_ID_FRAG |
3304 |
|
// |
3305 |
|
oss.str(""); |
3306 |
|
oss << "UPDATE GL_RUN SET ID_RUN_FRAG = " << glrun->GetID() << " where ID = " << IDRL2A << ";"; |
3307 |
|
if ( IsDebug() ) printf(" update gl_run to have cross indexing: %s\n",oss.str().c_str()); |
3308 |
|
conn->Query(oss.str().c_str()); |
3309 |
|
// |
3310 |
|
// now let's look for runtrailer if any in the last run |
3311 |
|
// |
3312 |
|
glA->Query_GL_RUN(IDRL2B,conn); |
3313 |
|
// |
3314 |
|
if ( glA->GetPKT_READY_COUNTER() != 0 ){ |
3315 |
|
// |
3316 |
|
// the first piece contains a good runtrailer we can update all the other runs with correct infos! |
3317 |
|
// |
3318 |
|
oss.str(""); |
3319 |
|
oss << "UPDATE GL_RUN_FRAGMENTS SET " |
3320 |
|
<< " RUNTRAILER_TIME=" << glA->GetRUNTRAILER_TIME()<< " , " |
3321 |
|
<< " RUNTRAILER_OBT=" << glA->GetRUNTRAILER_OBT()<< " , " |
3322 |
|
<< " RUNTRAILER_PKT=" << glA->GetRUNTRAILER_PKT()<< " , " |
3323 |
|
<< " PKT_COUNTER=" << glA->GetPKT_COUNTER()<< " , "; |
3324 |
|
// |
3325 |
|
if ( glA->GetPHYSENDRUN_MASK_S3S2S12() ){ |
3326 |
|
oss << " PHYSENDRUN_MASK_S3S2S12=" << glA->GetPHYSENDRUN_MASK_S3S2S12()<< " , "; }; |
3327 |
|
if ( glA->GetPHYSENDRUN_MASK_S11CRC() ) { |
3328 |
|
oss << " PHYSENDRUN_MASK_S11CRC=" << glA->GetPHYSENDRUN_MASK_S11CRC()<< " , "; }; |
3329 |
|
// |
3330 |
|
oss << " PKT_READY_COUNTER=" << glA->GetPKT_READY_COUNTER() |
3331 |
|
<< " WHERE ID=" << glrun->GetID() << ";"; |
3332 |
|
if ( IsDebug() ) printf(" update with correct trailer infos: %s\n",oss.str().c_str()); |
3333 |
|
conn->Query(oss.str().c_str()); |
3334 |
|
// |
3335 |
|
} else { |
3336 |
|
// |
3337 |
|
// sig no runtrailer, let set anyway what is possible... |
3338 |
|
// |
3339 |
|
oss.str(""); |
3340 |
|
oss << "UPDATE GL_RUN_FRAGMENTS SET " |
3341 |
|
<< " RUNTRAILER_TIME=" << glA->GetRUNTRAILER_TIME()<< " , " |
3342 |
|
<< " RUNTRAILER_OBT=" << glA->GetRUNTRAILER_OBT()<< " , "; |
3343 |
|
// |
3344 |
|
if ( glA->GetPHYSENDRUN_MASK_S3S2S12() ){ |
3345 |
|
oss << " PHYSENDRUN_MASK_S3S2S12=" << glA->GetPHYSENDRUN_MASK_S3S2S12()<< " , "; }; |
3346 |
|
if ( glA->GetPHYSENDRUN_MASK_S11CRC() ){ |
3347 |
|
oss << " PHYSENDRUN_MASK_S11CRC=" << glA->GetPHYSENDRUN_MASK_S11CRC()<< " , "; }; |
3348 |
|
// |
3349 |
|
oss << " RUNTRAILER_PKT=" << glrun->GetRUNTRAILER_PKT() |
3350 |
|
<< " WHERE ID=" << glrun->GetID() << ";"; |
3351 |
|
if ( IsDebug() ) printf(" update with correct trailer infos2: %s\n",oss.str().c_str()); |
3352 |
|
conn->Query(oss.str().c_str()); |
3353 |
|
}; |
3354 |
|
// |
3355 |
|
UInt_t myi = glrun->GetID(); |
3356 |
|
oss.str(""); |
3357 |
|
oss << " ID= "<< myi; |
3358 |
|
// |
3359 |
|
glrun->Query_GL_RUN_FRAGMENTS(oss.str().c_str(),conn); |
3360 |
|
// |
3361 |
|
// fill the new run in GL_RUN |
3362 |
|
// |
3363 |
|
glrun->SetID_RUN_FRAG(IDRL2B); |
3364 |
|
glrun->Fill_GL_RUN(conn); |
3365 |
|
glrun->DeleteRun(conn,0,"GL_RUN_FRAGMENTS"); |
3366 |
|
// |
3367 |
|
} else { |
3368 |
|
// |
3369 |
|
// is just a repetition |
3370 |
|
// |
3371 |
|
if ( IsDebug() ) printf(" The run is already present in the GL_RUN table \n"); |
3372 |
|
if ( PEDANTIC ) throw -70; |
3373 |
|
}; |
3374 |
|
// |
3375 |
} else { |
} else { |
3376 |
if ( NoFrag() ){ |
if ( NoFrag() ){ |
3377 |
glrun->SetID_RUN_FRAG(glrun->GetID()); |
glrun->SetID_RUN_FRAG(glrun->GetID()); |
4941 |
if ( !result ) throw -4;; |
if ( !result ) throw -4;; |
4942 |
row = result->Next(); |
row = result->Next(); |
4943 |
if(row)glcal->ID = (UInt_t)atoll(row->GetField(0)); |
if(row)glcal->ID = (UInt_t)atoll(row->GetField(0)); |
4944 |
|
// |
4945 |
|
delete result; // mmm... "Error in <TMySQLResult::Next>: result set closed" solved? 090112 [8RED error messages] |
4946 |
// |
// |
4947 |
}; |
}; |
4948 |
|
|
5450 |
|
|
5451 |
if(FOUND){ |
if(FOUND){ |
5452 |
|
|
5453 |
if ( IsDebug() ) cout << " >>> REPETITION FOUND :-) <<<" <<endl; |
if ( IsDebug() ) cout << " >>> REPETITION FOUND :-) <<<" <<endl; |
|
|
|
|
//////////////////////////////////////////// |
|
|
// insert a new entry in GL_TRK_CALIB and |
|
|
// modify the time-tag of the previous one |
|
|
//////////////////////////////////////////// |
|
5454 |
|
|
5455 |
// --------------------------------------------------------------------- |
//////////////////////////////////////////// |
5456 |
// step 1: insert a new raw file in GL_RAW |
// insert a new entry in GL_TRK_CALIB and |
5457 |
// --------------------------------------------------------------------- |
// modify the time-tag of the previous one |
5458 |
// |
//////////////////////////////////////////// |
5459 |
// check if the raw file already exist |
|
5460 |
// |
// --------------------------------------------------------------------- |
5461 |
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 |
// step 1: insert a new raw file in GL_RAW |
5462 |
// oss.str(""); |
// --------------------------------------------------------------------- |
5463 |
// oss << "SELECT ID FROM GL_RAW where NAME=\"" << gSystem->BaseName(raw.Data()) <<"\";"; |
// |
5464 |
// if ( IsDebug() ) cout << oss.str().c_str() << endl; |
// check if the raw file already exist |
5465 |
|
// |
5466 |
|
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 |
5467 |
|
// oss.str(""); |
5468 |
|
// oss << "SELECT ID FROM GL_RAW where NAME=\"" << gSystem->BaseName(raw.Data()) <<"\";"; |
5469 |
|
// if ( IsDebug() ) cout << oss.str().c_str() << endl; |
5470 |
|
|
5471 |
// result = conn->Query(oss.str().c_str()); |
// result = conn->Query(oss.str().c_str()); |
5472 |
// if ( !result ) throw -4;; |
// if ( !result ) throw -4;; |
5473 |
// if ( IsDebug() ) cout <<"Rows: "<<result->GetRowCount()<<endl; |
// if ( IsDebug() ) cout <<"Rows: "<<result->GetRowCount()<<endl; |
5474 |
// if( result->GetRowCount() == 0){ |
// if( result->GetRowCount() == 0){ |
5475 |
// if ( IsDebug() ) cout << " << Insert new RAW file >> "<<endl; |
// if ( IsDebug() ) cout << " << Insert new RAW file >> "<<endl; |
5476 |
// // - - - - - - - - - - - |
// // - - - - - - - - - - - |
5477 |
// // insert new raw file |
// // insert new raw file |
5478 |
// // - - - - - - - - - - - |
// // - - - - - - - - - - - |
5479 |
// GL_RAW glraw = GL_RAW(); |
// GL_RAW glraw = GL_RAW(); |
5480 |
// glraw.PATH = gSystem->DirName(raw.Data()); |
// glraw.PATH = gSystem->DirName(raw.Data()); |
5481 |
// glraw.NAME = gSystem->BaseName(raw.Data()); |
// glraw.NAME = gSystem->BaseName(raw.Data()); |
5482 |
// glraw.BOOT_NUMBER = boot_number; |
// glraw.BOOT_NUMBER = boot_number; |
5483 |
// // |
// // |
5484 |
// insertPamelaRawFile( &glraw ); |
// insertPamelaRawFile( &glraw ); |
5485 |
// // |
// // |
5486 |
// id_raw = glraw.ID; |
// id_raw = glraw.ID; |
5487 |
// }else{ |
// }else{ |
5488 |
// row = result->Next(); |
// row = result->Next(); |
5489 |
// id_raw = (UInt_t)atoll(row->GetField(0)); |
// id_raw = (UInt_t)atoll(row->GetField(0)); |
5490 |
// } |
// } |
5491 |
// if ( IsDebug() ) cout << "ID_RAW = "<<id_raw<<endl; |
// if ( IsDebug() ) cout << "ID_RAW = "<<id_raw<<endl; |
5492 |
|
|
5493 |
// --------------------------------------------------------------------- |
// --------------------------------------------------------------------- |
5494 |
// step 1(bis): retrieve the timesync id associated to the file |
// step 1(bis): retrieve the timesync id associated to the file |
5495 |
// (NB, uso lo stesso associato al file iniziale) |
// (NB, uso lo stesso associato al file iniziale) |
5496 |
// --------------------------------------------------------------------- |
// --------------------------------------------------------------------- |
5497 |
UInt_t idtimesync = 0; |
UInt_t idtimesync = 0; |
5498 |
oss.str(""); |
oss.str(""); |
5499 |
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;"; |
5500 |
if ( debug ) printf(" %s \n",oss.str().c_str()); |
if ( debug ) printf(" %s \n",oss.str().c_str()); |
5501 |
result = conn->Query(oss.str().c_str()); |
result = conn->Query(oss.str().c_str()); |
5502 |
if ( !result ) throw -3; |
if ( !result ) throw -3; |
5503 |
row = result->Next(); |
row = result->Next(); |
5504 |
if ( !row ) throw -3; |
if ( !row ) throw -3; |
5505 |
idtimesync = (UInt_t)atoll(row->GetField(0)); |
idtimesync = (UInt_t)atoll(row->GetField(0)); |
5506 |
if ( IsDebug() ) cout << "ID_TIMESYNC = "<<idtimesync<<endl; |
if ( IsDebug() ) cout << "ID_TIMESYNC = "<<idtimesync<<endl; |
5507 |
|
|
5508 |
|
delete result;// mmm... "Error in <TMySQLResult::Next>: result set closed" solved? 090112 [8RED error messages] |
5509 |
// --------------------------------------------------------------------- |
// --------------------------------------------------------------------- |
5510 |
// step 2: insert a new root file in GL_ROOT |
// step 2: insert a new root file in GL_ROOT |
5511 |
// --------------------------------------------------------------------- |
// --------------------------------------------------------------------- |
5553 |
} |
} |
5554 |
if ( IsDebug() ) cout << "ID_ROOT = "<<id_root<<endl; |
if ( IsDebug() ) cout << "ID_ROOT = "<<id_root<<endl; |
5555 |
|
|
5556 |
|
delete result;// mmm... "Error in <TMySQLResult::Next>: result set closed" solved? 090112 [8RED error messages] |
5557 |
// --------------------------------------------------------------------- |
// --------------------------------------------------------------------- |
5558 |
// step 3: modify time-tag of corrupted GL_TRK_CALIB entry |
// step 3: modify time-tag of corrupted GL_TRK_CALIB entry |
5559 |
// --------------------------------------------------------------------- |
// --------------------------------------------------------------------- |
5566 |
result = conn->Query(oss.str().c_str()); |
result = conn->Query(oss.str().c_str()); |
5567 |
if ( !result ) throw -4;; |
if ( !result ) throw -4;; |
5568 |
|
|
5569 |
|
delete result; // mmm... "Error in <TMySQLResult::Next>: result set closed" solved? 090112 [8RED error messages] |
5570 |
|
|
5571 |
// --------------------------------------------------------------------- |
// --------------------------------------------------------------------- |
5572 |
// step 4: insert the new calibration: |
// step 4: insert the new calibration: |
5573 |
// --------------------------------------------------------------------- |
// --------------------------------------------------------------------- |
6019 |
oss << " PHYSENDRUN_MASK_S11CRC=" << glrun->GetPHYSENDRUN_MASK_S11CRC()<< " , "; |
oss << " PHYSENDRUN_MASK_S11CRC=" << glrun->GetPHYSENDRUN_MASK_S11CRC()<< " , "; |
6020 |
// |
// |
6021 |
oss << " RUNHEADER_OBT=" << glrun->GetRUNHEADER_OBT()<< " , " |
oss << " RUNHEADER_OBT=" << glrun->GetRUNHEADER_OBT()<< " , " |
6022 |
<< " RUNHEADER_PKT=" << glrun->GetRUNHEADER_PKT()<< ";"; |
<< " RUNHEADER_PKT=" << glrun->GetRUNHEADER_PKT(); |
6023 |
|
oss << " WHERE ID=" << myid[u] << ";"; // BUG!!! 090112 |
6024 |
conn->Query(oss.str().c_str()); |
conn->Query(oss.str().c_str()); |
6025 |
}; |
}; |
6026 |
}; |
}; |
6069 |
if ( glrun->GetPHYSENDRUN_MASK_S11CRC() ){ |
if ( glrun->GetPHYSENDRUN_MASK_S11CRC() ){ |
6070 |
oss << " PHYSENDRUN_MASK_S11CRC=" << glrun->GetPHYSENDRUN_MASK_S11CRC()<< " , "; }; |
oss << " PHYSENDRUN_MASK_S11CRC=" << glrun->GetPHYSENDRUN_MASK_S11CRC()<< " , "; }; |
6071 |
// |
// |
6072 |
oss << " RUNTRAILER_PKT=" << glrun->GetRUNTRAILER_PKT()<< ";"; |
oss << " RUNTRAILER_PKT=" << glrun->GetRUNTRAILER_PKT(); |
6073 |
|
oss << " WHERE ID=" << myid[u] << ";"; // BUG!!! 090112 |
6074 |
conn->Query(oss.str().c_str()); |
conn->Query(oss.str().c_str()); |
6075 |
}; |
}; |
6076 |
}; |
}; |