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 ){ |
226 |
qu.str(""); |
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;"; |
// 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] |
// 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] |
qu << "SELECT BOOT_NUMBER from ROOT_TABLE where BOOT_NUMBER!=0 AND ABS(LAST_TIME_SYNC_INFO-"<< (float)chlastts <<")<50000 AND ABS(REAL_TIME_INIT-"<< atof(row2->GetField(10)) <<")<50000 group by BOOT_NUMBER order by BOOT_NUMBER asc;"; // even more relaxed conditions... 091214 [9REDtest3: error -29] // 10RED MYSQL operators BUG: |
230 |
|
/* |
231 |
|
|
232 |
|
mysql> select CAST(1322000646 AS UNSIGNED INTEGER)-1322017203.; |
233 |
|
+--------------------------------------------------+ |
234 |
|
| CAST(1322000646 AS UNSIGNED INTEGER)-1322017203. | |
235 |
|
+--------------------------------------------------+ |
236 |
|
| -16557 | |
237 |
|
+--------------------------------------------------+ |
238 |
|
1 row in set (0.06 sec) |
239 |
|
|
240 |
|
mysql> select CAST(1322000646 AS UNSIGNED INTEGER)-1322017203; |
241 |
|
+-------------------------------------------------+ |
242 |
|
| CAST(1322000646 AS UNSIGNED INTEGER)-1322017203 | |
243 |
|
+-------------------------------------------------+ |
244 |
|
| 18446744073709535059 | |
245 |
|
+-------------------------------------------------+ |
246 |
|
1 row in set (0.02 sec) |
247 |
|
|
248 |
|
*/ |
249 |
if ( debug ) printf(" chewbacca: query is %s \n",qu.str().c_str()); |
if ( debug ) printf(" chewbacca: query is %s \n",qu.str().c_str()); |
250 |
result3 = conn->Query(qu.str().c_str()); |
result3 = conn->Query(qu.str().c_str()); |
251 |
if ( result3 ){ |
if ( result3 ){ |
1373 |
oss.str(""); |
oss.str(""); |
1374 |
oss << "SET wait_timeout=173000;"; |
oss << "SET wait_timeout=173000;"; |
1375 |
conn->Query(oss.str().c_str()); |
conn->Query(oss.str().c_str()); |
1376 |
|
delete conn->Query("SET sql_mode = 'NO_UNSIGNED_SUBTRACTION';"); |
1377 |
// |
// |
1378 |
} |
} |
1379 |
|
|
1659 |
Int_t PamelaDBOperations::insertPamelaGL_TIMESYNC(){ |
Int_t PamelaDBOperations::insertPamelaGL_TIMESYNC(){ |
1660 |
// |
// |
1661 |
Int_t signal = 0; |
Int_t signal = 0; |
1662 |
UInt_t idresof = 0; |
// UInt_t idresof = 0; |
1663 |
|
idresof = 0; |
1664 |
stringstream oss; |
stringstream oss; |
1665 |
TSQLResult *result = 0; |
TSQLResult *result = 0; |
1666 |
TSQLRow *row = 0; |
TSQLRow *row = 0; |
1751 |
TYPE = 0; |
TYPE = 0; |
1752 |
TSYNC = 0; |
TSYNC = 0; |
1753 |
// |
// |
1754 |
Double_t minimum = 0.; |
// Double_t minimum = 0.; |
1755 |
Double_t maximum = 0.; |
// Double_t maximum = 0.; |
1756 |
Double_t minimum2 = 0.; |
//Double_t minimum2 = 0.; |
1757 |
Double_t maximum2 = 0.; |
Double_t maximum2 = 0.; |
1758 |
// |
// |
1759 |
// |
// |
1761 |
pamela::McmdRecord *mcrc = 0; |
pamela::McmdRecord *mcrc = 0; |
1762 |
TArrayC *mcmddata = 0; |
TArrayC *mcmddata = 0; |
1763 |
// |
// |
1764 |
minimum = numeric_limits<Double_t>::max(); |
// minimum = numeric_limits<Double_t>::max(); |
1765 |
maximum = numeric_limits<Double_t>::min(); |
// maximum = numeric_limits<Double_t>::min(); |
1766 |
minimum2 = numeric_limits<Double_t>::max(); |
// minimum2 = numeric_limits<Double_t>::max(); |
1767 |
maximum2 = numeric_limits<Double_t>::min(); |
maximum2 = numeric_limits<Double_t>::min(); |
1768 |
// |
// |
1769 |
T = (TTree*)file->Get("Mcmd"); |
T = (TTree*)file->Get("Mcmd"); |
1974 |
// |
// |
1975 |
if ( chewbacca ){ |
if ( chewbacca ){ |
1976 |
oss.str(""); |
oss.str(""); |
1977 |
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<<" and ID_RESURS_OFFSET="<< idresof <<" limit 1;"; // 10RED BUG!!!! without 'and ID_RESURS_OFFSET="<< idresof ' this query is not enough to ensure finding the correct line in GL_TIMSYNC... |
1978 |
if ( debug ) printf(" %s \n",oss.str().c_str()); |
if ( debug ) printf(" %s \n",oss.str().c_str()); |
1979 |
result = conn->Query(oss.str().c_str()); |
result = conn->Query(oss.str().c_str()); |
1980 |
// |
// |
2183 |
UInt_t lowerts = tsync-(obt0/1000)-5; |
UInt_t lowerts = tsync-(obt0/1000)-5; |
2184 |
if ( chewbacca ){ |
if ( chewbacca ){ |
2185 |
oss.str(""); |
oss.str(""); |
2186 |
oss << "select BOOT_NUMBER from ROOT_TABLE where LAST_TIME_SYNC_INFO-(OBT_TIME_SYNC)<" |
oss << "select BOOT_NUMBER from ROOT_TABLE where CAST((LAST_TIME_SYNC_INFO-(OBT_TIME_SYNC)) AS SIGNED INT)<" // 10RED MYSQL OPERATORS BUG |
2187 |
<< upperts |
<< upperts |
2188 |
<< " AND LAST_TIME_SYNC_INFO-(OBT_TIME_SYNC)>" |
<< " AND CAST((LAST_TIME_SYNC_INFO-(OBT_TIME_SYNC)) AS SIGNED INT)>" // 10RED MYSQL OPERATORS BUG |
2189 |
<< lowerts |
<< lowerts |
2190 |
<< " AND BOOT_NUMBER>1;"; |
<< " AND BOOT_NUMBER>1;"; |
2191 |
} else { |
} else { |
2192 |
oss.str(""); |
oss.str(""); |
2193 |
oss << "select GL_RAW.BOOT_NUMBER from GL_TIMESYNC LEFT JOIN GL_RAW ON GL_RAW.ID = GL_TIMESYNC.ID_RAW where TIMESYNC-(OBT0/1000)<" |
oss << "select GL_RAW.BOOT_NUMBER from GL_TIMESYNC LEFT JOIN GL_RAW ON GL_RAW.ID = GL_TIMESYNC.ID_RAW where CAST((TIMESYNC-(OBT0/1000)) AS SIGNED INT)<" // 10RED MYSQL OPERATORS BUG |
2194 |
<< upperts |
<< upperts |
2195 |
<< " AND TIMESYNC-(OBT0/1000)>" |
<< " AND CAST((TIMESYNC-(OBT0/1000)) AS SIGNED INT)>" // 10RED MYSQL OPERATORS BUG |
2196 |
<< lowerts |
<< lowerts |
2197 |
<< " AND GL_RAW.BOOT_NUMBER>0 GROUP BY GL_TIMESYNC.OBT0;"; |
<< " AND GL_RAW.BOOT_NUMBER>0 GROUP BY GL_TIMESYNC.OBT0;"; |
2198 |
}; |
}; |
2291 |
// |
// |
2292 |
// no runtrailers in the file! |
// no runtrailers in the file! |
2293 |
// |
// |
2294 |
if ( !rtev ){ |
if ( IsDebug() ) printf(" Start rtev %i rhev %i nrtev %i nrhev %i \n",rtev,rhev,nrtev,nrhev); |
2295 |
if ( !rhev ){ |
if ( !rtev || (chewbacca && !nrtev) ){ |
2296 |
|
if ( IsDebug() ) printf(" No runtrailers \n"); |
2297 |
|
if ( !rhev || (chewbacca && !nrhev) ){ |
2298 |
if ( IsDebug() ) printf(" No runheaders nor runtrailers!! \n"); |
if ( IsDebug() ) printf(" No runheaders nor runtrailers!! \n"); |
2299 |
if ( !(upperentry-chminentry) ){ |
if ( !(upperentry-chminentry) ){ |
2300 |
if ( IsDebug() ) printf(" No physics events nor runs in the file \n"); // di nuovo potrebbe esserci un runtrailer senza eventi (riempimento MM) |
if ( IsDebug() ) printf(" No physics events nor runs in the file \n"); // di nuovo potrebbe esserci un runtrailer senza eventi (riempimento MM) |
2331 |
// |
// |
2332 |
} else { |
} else { |
2333 |
// |
// |
2334 |
|
if ( IsDebug() ) printf(" We have runtrailers \n"); |
2335 |
Int_t conptt = -1; |
Int_t conptt = -1; |
2336 |
for (Int_t ptt=0; ptt<rtev; ptt++){ |
for (Int_t ptt=0; ptt<rtev; ptt++){ |
2337 |
// |
// |
2978 |
if ( IsDebug() ) printf(" here firstev is %i lastev is %i \n",firstev,lastev); |
if ( IsDebug() ) printf(" here firstev is %i lastev is %i \n",firstev,lastev); |
2979 |
// |
// |
2980 |
glrun->SetEV_FROM(firstev); |
glrun->SetEV_FROM(firstev); |
2981 |
|
glrun->SetEV_TO(lastev); // EM 10 RED ghost run bug |
2982 |
glrun->SetNEVENTS(lastev-firstev+1); |
glrun->SetNEVENTS(lastev-firstev+1); |
2983 |
// |
// |
2984 |
glrun->SetRUNHEADER_TIME(glrun1->GetRUNHEADER_TIME()); |
glrun->SetRUNHEADER_TIME(glrun1->GetRUNHEADER_TIME()); |
3174 |
}; |
}; |
3175 |
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); |
3176 |
// |
// |
3177 |
|
glrun->SetEV_FROM(firstev); // EM 10RED ghost run bug |
3178 |
glrun->SetEV_TO(lastev); |
glrun->SetEV_TO(lastev); |
3179 |
glrun->SetNEVENTS(lastev-firstev+1); |
glrun->SetNEVENTS(lastev-firstev+1); |
3180 |
glrun->SetPKT_COUNTER(glrun1->GetPKT_COUNTER()); |
glrun->SetPKT_COUNTER(glrun1->GetPKT_COUNTER()); |
3267 |
// "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. |
3268 |
// |
// |
3269 |
// 090112 [8RED (-70): RUN ALREADY INSERTED] |
// 090112 [8RED (-70): RUN ALREADY INSERTED] |
3270 |
|
// 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! |
3271 |
// |
// |
3272 |
Bool_t OK = false; |
Bool_t OK = false; |
3273 |
UInt_t IDRL2A = 0; |
UInt_t IDRL2A = 0; |
3274 |
UInt_t IDRL2B = 0; |
UInt_t IDRL2B = 0; |
3275 |
if ( chewbacca ){ |
if ( chewbacca ){ |
3276 |
if ( result->GetRowCount() == 2 ){ |
if ( result->GetRowCount() >= 2 ){ |
3277 |
|
// |
3278 |
|
if ( IsDebug() ) printf(" RH---| gap |---RT case, number of pieces in the GL_RUN table: %i \n",result->GetRowCount()); |
3279 |
|
OK = true; |
3280 |
IDRL2A = (UInt_t)atoll(row->GetField(0)); |
IDRL2A = (UInt_t)atoll(row->GetField(0)); |
3281 |
UInt_t IDRL0A = (UInt_t)atoll(row->GetField(1)); |
// |
3282 |
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()); |
|
3283 |
// |
// |
3284 |
if ( !result2 ) throw -4; |
TSQLResult *trresult = 0; |
3285 |
|
TSQLRow *trrow = 0; |
3286 |
// |
// |
3287 |
row2 = result2->Next(); |
stringstream tross; |
3288 |
|
tross.str(""); |
3289 |
// |
// |
3290 |
if ( row2 ){ |
tross << " SELECT RUNHEADER_PKT, RUNTRAILER_PKT FROM GL_RUN_TRASH where ID=" << row->GetField(0) << ";"; |
3291 |
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()); |
3292 |
delete result2; |
trresult = conn->Query(tross.str().c_str()); |
3293 |
oss.str(""); |
if ( !trresult ) throw -4; |
3294 |
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(); |
3295 |
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 ){ |
3296 |
result2 = conn->Query(oss.str().c_str()); |
OK = false; |
3297 |
// |
if ( IsDebug() ) printf(" OPS! no such run (or multiple runs!) in GL_RUN_TRASH table, something wrong is going on! \n"); |
3298 |
if ( !result2 ) throw -4; |
break; |
3299 |
// |
}; |
3300 |
row2 = result2->Next(); |
// |
3301 |
// |
UInt_t pktH = (UInt_t)atoll(row->GetField(0)); |
3302 |
if ( row2 ){ |
UInt_t pktT = (UInt_t)atoll(row->GetField(1)); |
3303 |
UInt_t PKB = (UInt_t)atoll(row2->GetField(0)); |
delete trresult; |
3304 |
// |
if ( |
3305 |
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())) || |
3306 |
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())) || |
3307 |
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())) ){ |
3308 |
OK = true; |
OK = false; |
3309 |
}; |
if ( IsDebug() ) printf(" The run is overlapping with already inserted ones!! \n"); |
3310 |
}; |
break; |
3311 |
}; |
}; |
3312 |
|
//PKT(glrun->GetRUNHEADER_PKT()) PKT(glrun->GetRUNTRAILER_PKT()) |
3313 |
|
row = result->Next(); |
3314 |
}; |
}; |
3315 |
}; |
|
3316 |
|
// if ( result->GetRowCount() == 2 ) { |
3317 |
|
// IDRL2A = (UInt_t)atoll(row->GetField(0)); |
3318 |
|
// UInt_t IDRL0A = (UInt_t)atoll(row->GetField(1)); |
3319 |
|
// row = result->Next(); |
3320 |
|
// IDRL2B = (UInt_t)atoll(row->GetField(0)); |
3321 |
|
// UInt_t IDRL0B = (UInt_t)atoll(row->GetField(1)); |
3322 |
|
// if ( IsDebug() ) printf(" IDRL0A %u B %u IDRL2A %u B %u \n",IDRL0A,IDRL0B,IDRL2A,IDRL2B); |
3323 |
|
// // if ( IDRL0A == IDRL0B ){ //091230 why this condition???? RH could be in a file and RT in another one... |
3324 |
|
// if ( true ){ |
3325 |
|
// TSQLResult *result2 = 0; |
3326 |
|
// TSQLRow *row2 = 0; |
3327 |
|
// oss.str(""); |
3328 |
|
// oss << "select PKT_NUMBER_FINAL from ROOT_TABLE_MERGING where REAL_TIME_INIT<" << chrtinit << " order by REAL_TIME_INIT desc limit 1;"; |
3329 |
|
// if ( IsDebug() ) printf(" Check if we are in the case RH---| small gap |---RT: query is \n %s \n",oss.str().c_str()); |
3330 |
|
// result2 = conn->Query(oss.str().c_str()); |
3331 |
|
// // |
3332 |
|
// if ( !result2 ) throw -4; |
3333 |
|
// // |
3334 |
|
// row2 = result2->Next(); |
3335 |
|
// // |
3336 |
|
// if ( row2 ){ |
3337 |
|
// UInt_t PKA = (UInt_t)atoll(row2->GetField(0)); |
3338 |
|
// delete result2; |
3339 |
|
// oss.str(""); |
3340 |
|
// oss << "select PKT_NUMBER_INIT from ROOT_TABLE_MERGING where REAL_TIME_INIT>" << chrtinit << " order by REAL_TIME_INIT asc limit 1;"; |
3341 |
|
// if ( IsDebug() ) printf(" Check if we are in the case RH---| small gap |---RT: query is \n %s \n",oss.str().c_str()); |
3342 |
|
// result2 = conn->Query(oss.str().c_str()); |
3343 |
|
// // |
3344 |
|
// if ( !result2 ) throw -4; |
3345 |
|
// // |
3346 |
|
// row2 = result2->Next(); |
3347 |
|
// // |
3348 |
|
// if ( row2 ){ |
3349 |
|
// UInt_t PKB = (UInt_t)atoll(row2->GetField(0)); |
3350 |
|
// // |
3351 |
|
// 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); |
3352 |
|
// if ( PKT(PKA)+1LL == PKT(glrun->GetRUNHEADER_PKT()) && PKT(PKB) == PKT(glrun->GetRUNTRAILER_PKT())+1LL ){ |
3353 |
|
// if ( IsDebug() ) printf(" Ok, we are in the case: RH---| small gap |---RT \n"); |
3354 |
|
// OK = true; |
3355 |
|
// }; |
3356 |
|
// }; |
3357 |
|
// }; |
3358 |
|
// }; |
3359 |
|
// }; |
3360 |
|
}; |
3361 |
}; |
}; |
3362 |
if ( OK ){ |
if ( OK ){ |
3363 |
// |
// |
3364 |
// 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 |
3365 |
// |
// |
3366 |
// 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 ) |
3367 |
// |
// |
3368 |
|
if ( IsDebug() ) printf(" Ok, we are in the case: RH---| small gap |---RT \n"); |
3369 |
|
// |
3370 |
GL_RUN *glA = new GL_RUN(); |
GL_RUN *glA = new GL_RUN(); |
3371 |
glA->Query_GL_RUN(IDRL2A,conn); |
glA->Query_GL_RUN(IDRL2A,conn); |
3372 |
// |
// |
3373 |
|
glrun->SetRUNHEADER_TIME(glA->GetRUNHEADER_TIME()); |
3374 |
|
glrun->SetRUNHEADER_OBT(glA->GetRUNHEADER_OBT()); |
3375 |
|
glrun->SetRUNHEADER_PKT(glA->GetRUNHEADER_PKT()); |
3376 |
|
// |
3377 |
|
glrun->SetRUNTRAILER_TIME(glA->GetRUNTRAILER_TIME()); |
3378 |
|
glrun->SetRUNTRAILER_OBT(glA->GetRUNTRAILER_OBT()); |
3379 |
|
glrun->SetRUNTRAILER_PKT(glA->GetRUNTRAILER_PKT()); |
3380 |
|
// |
3381 |
|
if ( glA->GetPHYSENDRUN_MASK_S3S2S12() ) glrun->SetPHYSENDRUN_MASK_S3S2S12(glA->GetPHYSENDRUN_MASK_S3S2S12()); |
3382 |
|
if ( glA->GetPHYSENDRUN_MASK_S11CRC() ) glrun->SetPHYSENDRUN_MASK_S11CRC(glA->GetPHYSENDRUN_MASK_S11CRC()); |
3383 |
|
// |
3384 |
if ( glA->GetACQ_BUILD_INFO() != 0 ){ |
if ( glA->GetACQ_BUILD_INFO() != 0 ){ |
3385 |
// |
// |
3386 |
// 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! |
3387 |
// |
// |
3388 |
oss.str(""); |
glrun->SetCOMPILATIONTIMESTAMP(glA->GetCOMPILATIONTIMESTAMP()); |
3389 |
oss << "UPDATE GL_RUN_FRAGMENTS SET " |
glrun->SetFAV_WRK_SCHEDULE(glA->GetFAV_WRK_SCHEDULE()); |
3390 |
<< " RUNHEADER_TIME=" << glA->GetRUNHEADER_TIME()<< " , " |
glrun->SetEFF_WRK_SCHEDULE(glA->GetEFF_WRK_SCHEDULE()); |
3391 |
<< " RUNHEADER_OBT=" << glA->GetRUNHEADER_OBT()<< " , " |
glrun->SetPRH_VAR_TRG_MODE_A(glA->GetPRH_VAR_TRG_MODE_A()); |
3392 |
<< " RUNHEADER_PKT=" << glA->GetRUNHEADER_PKT()<< " , " |
glrun->SetPRH_VAR_TRG_MODE_B(glA->GetPRH_VAR_TRG_MODE_B()); |
3393 |
<< " COMPILATIONTIMESTAMP=" << glA->GetCOMPILATIONTIMESTAMP()<< " , " |
glrun->SetACQ_BUILD_INFO(glA->GetACQ_BUILD_INFO()); |
3394 |
<< " FAV_WRK_SCHEDULE=" << glA->GetFAV_WRK_SCHEDULE()<< " , " |
glrun->SetACQ_VAR_INFO(glA->GetACQ_VAR_INFO()); |
3395 |
<< " EFF_WRK_SCHEDULE=" << glA->GetEFF_WRK_SCHEDULE()<< " , " |
glrun->SetRM_ACQ_AFTER_CALIB(glA->GetRM_ACQ_AFTER_CALIB()); |
3396 |
<< " PRH_VAR_TRG_MODE_A=" << glA->GetPRH_VAR_TRG_MODE_A()<< " , " |
glrun->SetRM_ACQ_SETTING_MODE(glA->GetRM_ACQ_SETTING_MODE()); |
3397 |
<< " PRH_VAR_TRG_MODE_B=" << glA->GetPRH_VAR_TRG_MODE_B()<< " , " |
glrun->SetTRK_CALIB_USED(glA->GetTRK_CALIB_USED()); |
3398 |
<< " ACQ_BUILD_INFO=" << glA->GetACQ_BUILD_INFO()<< " , " |
glrun->SetCAL_DSP_MASK(glA->GetCAL_DSP_MASK()); |
3399 |
<< " ACQ_VAR_INFO=" << glA->GetACQ_VAR_INFO()<< " , " |
glrun->SetLAST_TIMESYNC(glA->GetLAST_TIMESYNC()); |
3400 |
<< " RM_ACQ_AFTER_CALIB=" << glA->GetRM_ACQ_AFTER_CALIB()<< " , " |
glrun->SetOBT_TIMESYNC(glA->GetOBT_TIMESYNC()); |
|
<< " RM_ACQ_SETTING_MODE=" << glA->GetRM_ACQ_SETTING_MODE()<< " , " |
|
|
<< " TRK_CALIB_USED=" << glA->GetTRK_CALIB_USED()<< " , " |
|
|
<< " CAL_DSP_MASK=" << glA->GetCAL_DSP_MASK()<< " , " |
|
|
<< " LAST_TIMESYNC=" << glA->GetLAST_TIMESYNC()<< " , "; |
|
|
// |
|
|
if ( glA->GetPHYSENDRUN_MASK_S3S2S12() ) |
|
|
oss << " PHYSENDRUN_MASK_S3S2S12=" << glA->GetPHYSENDRUN_MASK_S3S2S12() << " , "; |
|
|
if ( glA->GetPHYSENDRUN_MASK_S11CRC() ) |
|
|
oss << " PHYSENDRUN_MASK_S11CRC=" << glA->GetPHYSENDRUN_MASK_S11CRC() << " , "; |
|
|
// |
|
|
oss << " OBT_TIMESYNC=" << glA->GetOBT_TIMESYNC(); |
|
|
oss << " WHERE ID=" << glrun->GetID() << ";"; |
|
|
if ( IsDebug() ) printf(" update with correct infos: %s\n",oss.str().c_str()); |
|
|
conn->Query(oss.str().c_str()); |
|
|
// |
|
|
} else { |
|
3401 |
// |
// |
3402 |
// sig no runheader, let set anyway what is possible... |
}; |
3403 |
|
// |
3404 |
|
if ( glA->GetPKT_READY_COUNTER() != 0 ){ |
3405 |
// |
// |
3406 |
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()<< " , "; |
|
3407 |
// |
// |
3408 |
if ( glA->GetPHYSENDRUN_MASK_S3S2S12() ) |
glrun->SetPKT_COUNTER(glA->GetPKT_COUNTER()); |
3409 |
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()); |
|
3410 |
}; |
}; |
3411 |
// |
// |
3412 |
// update runheader ROOT_ID_FRAG |
// update runheader ROOT_ID_FRAG |
3416 |
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()); |
3417 |
conn->Query(oss.str().c_str()); |
conn->Query(oss.str().c_str()); |
3418 |
// |
// |
|
// 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(); |
|
3419 |
oss.str(""); |
oss.str(""); |
3420 |
oss << " ID= "<< myi; |
oss << "SELECT ID FROM GL_RUN WHERE ID_RUN_FRAG = " << IDRL2A << ";"; |
3421 |
// |
if ( IsDebug() ) printf(" update gl_run to have cross indexing: %s\n",oss.str().c_str()); |
3422 |
glrun->Query_GL_RUN_FRAGMENTS(oss.str().c_str(),conn); |
TSQLResult *tsresult = 0; |
3423 |
|
TSQLRow *tsrow = 0; |
3424 |
|
tsresult=conn->Query(oss.str().c_str()); |
3425 |
|
if ( !tsresult ) throw -4; |
3426 |
|
tsrow = tsresult->Next(); |
3427 |
|
if ( !tsrow || tsresult->GetRowCount() != 1 ) throw -4; |
3428 |
|
IDRL2B = (UInt_t)atoll(tsrow->GetField(0)); |
3429 |
|
glrun->SetID_RUN_FRAG(IDRL2B); |
3430 |
// |
// |
3431 |
// fill the new run in GL_RUN |
// fill the new run in GL_RUN |
3432 |
// |
// |
|
glrun->SetID_RUN_FRAG(IDRL2B); |
|
3433 |
glrun->Fill_GL_RUN(conn); |
glrun->Fill_GL_RUN(conn); |
3434 |
|
// |
3435 |
glrun->DeleteRun(conn,0,"GL_RUN_FRAGMENTS"); |
glrun->DeleteRun(conn,0,"GL_RUN_FRAGMENTS"); |
3436 |
delete glA; |
delete glA; |
3437 |
// |
// |
3438 |
} else { |
} else { |
3439 |
|
// // |
3440 |
|
// // this is the case in which we must insert a piece of run between two fragments in the GL_RUN table |
3441 |
|
// // |
3442 |
|
// // 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 ) |
3443 |
|
// // |
3444 |
|
// GL_RUN *glA = new GL_RUN(); |
3445 |
|
// glA->Query_GL_RUN(IDRL2A,conn); |
3446 |
|
// // |
3447 |
|
// if ( glA->GetACQ_BUILD_INFO() != 0 ){ |
3448 |
|
// // |
3449 |
|
// // the first piece contains a good runheader we can update all the other runs with correct infos! |
3450 |
|
// // |
3451 |
|
// oss.str(""); |
3452 |
|
// oss << "UPDATE GL_RUN_FRAGMENTS SET " |
3453 |
|
// << " RUNHEADER_TIME=" << glA->GetRUNHEADER_TIME()<< " , " |
3454 |
|
// << " RUNHEADER_OBT=" << glA->GetRUNHEADER_OBT()<< " , " |
3455 |
|
// << " RUNHEADER_PKT=" << glA->GetRUNHEADER_PKT()<< " , " |
3456 |
|
// << " COMPILATIONTIMESTAMP=" << glA->GetCOMPILATIONTIMESTAMP()<< " , " |
3457 |
|
// << " FAV_WRK_SCHEDULE=" << glA->GetFAV_WRK_SCHEDULE()<< " , " |
3458 |
|
// << " EFF_WRK_SCHEDULE=" << glA->GetEFF_WRK_SCHEDULE()<< " , " |
3459 |
|
// << " PRH_VAR_TRG_MODE_A=" << glA->GetPRH_VAR_TRG_MODE_A()<< " , " |
3460 |
|
// << " PRH_VAR_TRG_MODE_B=" << glA->GetPRH_VAR_TRG_MODE_B()<< " , " |
3461 |
|
// << " ACQ_BUILD_INFO=" << glA->GetACQ_BUILD_INFO()<< " , " |
3462 |
|
// << " ACQ_VAR_INFO=" << glA->GetACQ_VAR_INFO()<< " , " |
3463 |
|
// << " RM_ACQ_AFTER_CALIB=" << glA->GetRM_ACQ_AFTER_CALIB()<< " , " |
3464 |
|
// << " RM_ACQ_SETTING_MODE=" << glA->GetRM_ACQ_SETTING_MODE()<< " , " |
3465 |
|
// << " TRK_CALIB_USED=" << glA->GetTRK_CALIB_USED()<< " , " |
3466 |
|
// << " CAL_DSP_MASK=" << glA->GetCAL_DSP_MASK()<< " , " |
3467 |
|
// << " LAST_TIMESYNC=" << glA->GetLAST_TIMESYNC()<< " , "; |
3468 |
|
// // |
3469 |
|
// if ( glA->GetPHYSENDRUN_MASK_S3S2S12() ) |
3470 |
|
// oss << " PHYSENDRUN_MASK_S3S2S12=" << glA->GetPHYSENDRUN_MASK_S3S2S12() << " , "; |
3471 |
|
// if ( glA->GetPHYSENDRUN_MASK_S11CRC() ) |
3472 |
|
// oss << " PHYSENDRUN_MASK_S11CRC=" << glA->GetPHYSENDRUN_MASK_S11CRC() << " , "; |
3473 |
|
// // |
3474 |
|
// oss << " OBT_TIMESYNC=" << glA->GetOBT_TIMESYNC(); |
3475 |
|
// oss << " WHERE ID=" << glrun->GetID() << ";"; |
3476 |
|
// if ( IsDebug() ) printf(" update with correct infos: %s\n",oss.str().c_str()); |
3477 |
|
// conn->Query(oss.str().c_str()); |
3478 |
|
// // |
3479 |
|
// } else { |
3480 |
|
// // |
3481 |
|
// // sig no runheader, let set anyway what is possible... |
3482 |
|
// // |
3483 |
|
// oss.str(""); |
3484 |
|
// oss << "UPDATE GL_RUN_FRAGMENTS SET " |
3485 |
|
// << " RUNHEADER_TIME=" << glA->GetRUNHEADER_TIME()<< " , "; |
3486 |
|
// // |
3487 |
|
// if ( glA->GetPHYSENDRUN_MASK_S3S2S12() ) |
3488 |
|
// oss << " PHYSENDRUN_MASK_S3S2S12=" << glA->GetPHYSENDRUN_MASK_S3S2S12()<< " , "; |
3489 |
|
// if ( glA->GetPHYSENDRUN_MASK_S11CRC() ) |
3490 |
|
// oss << " PHYSENDRUN_MASK_S11CRC=" << glA->GetPHYSENDRUN_MASK_S11CRC()<< " , "; |
3491 |
|
// // |
3492 |
|
// oss << " RUNHEADER_OBT=" << glA->GetRUNHEADER_OBT()<< " , " |
3493 |
|
// << " RUNHEADER_PKT=" << glA->GetRUNHEADER_PKT(); |
3494 |
|
// oss << " WHERE ID=" << glrun->GetID() << ";"; |
3495 |
|
// if ( IsDebug() ) printf(" update with correct infos2: %s\n",oss.str().c_str()); |
3496 |
|
// conn->Query(oss.str().c_str()); |
3497 |
|
// }; |
3498 |
|
// // |
3499 |
|
// // update runheader ROOT_ID_FRAG |
3500 |
|
// // |
3501 |
|
// oss.str(""); |
3502 |
|
// oss << "UPDATE GL_RUN SET ID_RUN_FRAG = " << glrun->GetID() << " where ID = " << IDRL2A << ";"; |
3503 |
|
// if ( IsDebug() ) printf(" update gl_run to have cross indexing: %s\n",oss.str().c_str()); |
3504 |
|
// conn->Query(oss.str().c_str()); |
3505 |
|
// // |
3506 |
|
// // now let's look for runtrailer if any in the last run |
3507 |
|
// // |
3508 |
|
// glA->Query_GL_RUN(IDRL2B,conn); |
3509 |
|
// // |
3510 |
|
// if ( glA->GetPKT_READY_COUNTER() != 0 ){ |
3511 |
|
// // |
3512 |
|
// // the first piece contains a good runtrailer we can update all the other runs with correct infos! |
3513 |
|
// // |
3514 |
|
// oss.str(""); |
3515 |
|
// oss << "UPDATE GL_RUN_FRAGMENTS SET " |
3516 |
|
// << " RUNTRAILER_TIME=" << glA->GetRUNTRAILER_TIME()<< " , " |
3517 |
|
// << " RUNTRAILER_OBT=" << glA->GetRUNTRAILER_OBT()<< " , " |
3518 |
|
// << " RUNTRAILER_PKT=" << glA->GetRUNTRAILER_PKT()<< " , " |
3519 |
|
// << " PKT_COUNTER=" << glA->GetPKT_COUNTER()<< " , "; |
3520 |
|
// // |
3521 |
|
// if ( glA->GetPHYSENDRUN_MASK_S3S2S12() ){ |
3522 |
|
// oss << " PHYSENDRUN_MASK_S3S2S12=" << glA->GetPHYSENDRUN_MASK_S3S2S12()<< " , "; }; |
3523 |
|
// if ( glA->GetPHYSENDRUN_MASK_S11CRC() ) { |
3524 |
|
// oss << " PHYSENDRUN_MASK_S11CRC=" << glA->GetPHYSENDRUN_MASK_S11CRC()<< " , "; }; |
3525 |
|
// // |
3526 |
|
// oss << " PKT_READY_COUNTER=" << glA->GetPKT_READY_COUNTER() |
3527 |
|
// << " WHERE ID=" << glrun->GetID() << ";"; |
3528 |
|
// if ( IsDebug() ) printf(" update with correct trailer infos: %s\n",oss.str().c_str()); |
3529 |
|
// conn->Query(oss.str().c_str()); |
3530 |
|
// // |
3531 |
|
// } else { |
3532 |
|
// // |
3533 |
|
// // sig no runtrailer, let set anyway what is possible... |
3534 |
|
// // |
3535 |
|
// oss.str(""); |
3536 |
|
// oss << "UPDATE GL_RUN_FRAGMENTS SET " |
3537 |
|
// << " RUNTRAILER_TIME=" << glA->GetRUNTRAILER_TIME()<< " , " |
3538 |
|
// << " RUNTRAILER_OBT=" << glA->GetRUNTRAILER_OBT()<< " , "; |
3539 |
|
// // |
3540 |
|
// if ( glA->GetPHYSENDRUN_MASK_S3S2S12() ){ |
3541 |
|
// oss << " PHYSENDRUN_MASK_S3S2S12=" << glA->GetPHYSENDRUN_MASK_S3S2S12()<< " , "; }; |
3542 |
|
// if ( glA->GetPHYSENDRUN_MASK_S11CRC() ){ |
3543 |
|
// oss << " PHYSENDRUN_MASK_S11CRC=" << glA->GetPHYSENDRUN_MASK_S11CRC()<< " , "; }; |
3544 |
|
// // |
3545 |
|
// oss << " RUNTRAILER_PKT=" << glrun->GetRUNTRAILER_PKT() |
3546 |
|
// << " WHERE ID=" << glrun->GetID() << ";"; |
3547 |
|
// if ( IsDebug() ) printf(" update with correct trailer infos2: %s\n",oss.str().c_str()); |
3548 |
|
// conn->Query(oss.str().c_str()); |
3549 |
|
// }; |
3550 |
|
// // |
3551 |
|
// UInt_t myi = glrun->GetID(); |
3552 |
|
// oss.str(""); |
3553 |
|
// oss << " ID= "<< myi; |
3554 |
|
// // |
3555 |
|
// glrun->Query_GL_RUN_FRAGMENTS(oss.str().c_str(),conn); |
3556 |
|
// // |
3557 |
|
// // fill the new run in GL_RUN |
3558 |
|
// // |
3559 |
|
// glrun->SetID_RUN_FRAG(IDRL2B); |
3560 |
|
// glrun->Fill_GL_RUN(conn); |
3561 |
|
// glrun->DeleteRun(conn,0,"GL_RUN_FRAGMENTS"); |
3562 |
|
// delete glA; |
3563 |
|
// // |
3564 |
|
// } else { |
3565 |
// |
// |
3566 |
// is just a repetition |
// is just a repetition |
3567 |
// |
// |
3621 |
// |
// |
3622 |
EventCounter *code=0; |
EventCounter *code=0; |
3623 |
// |
// |
3624 |
UInt_t nevent = 0; |
// UInt_t nevent = 0; |
3625 |
UInt_t checkfirst = 0; |
UInt_t checkfirst = 0; |
3626 |
UInt_t checklast = 0; |
UInt_t checklast = 0; |
3627 |
UInt_t firstentry = 0; |
UInt_t firstentry = 0; |
3643 |
EventHeader *eh = 0; |
EventHeader *eh = 0; |
3644 |
PscuHeader *ph = 0; |
PscuHeader *ph = 0; |
3645 |
T->SetBranchAddress("Header", &eh); |
T->SetBranchAddress("Header", &eh); |
3646 |
nevent = T->GetEntries(); |
// nevent = T->GetEntries(); |
3647 |
// |
// |
3648 |
// |
// |
3649 |
if ( firstev == lastev+1 || lastev == firstev ) { // no events inside the run! |
if ( firstev == lastev+1 || lastev == firstev ) { // no events inside the run! |
4017 |
glrun1->SetRUNTRAILER_PKT(glrun->GetRUNTRAILER_PKT()); |
glrun1->SetRUNTRAILER_PKT(glrun->GetRUNTRAILER_PKT()); |
4018 |
// |
// |
4019 |
glrun->SetEV_FROM(firstev); |
glrun->SetEV_FROM(firstev); |
4020 |
|
glrun->SetEV_TO(lastev); // 10 RED ghost run bug |
4021 |
glrun->SetNEVENTS(lastev-firstev+1); |
glrun->SetNEVENTS(lastev-firstev+1); |
4022 |
// |
// |
4023 |
glrun->SetRUNHEADER_TIME(glrun1->GetRUNHEADER_TIME()); |
glrun->SetRUNHEADER_TIME(glrun1->GetRUNHEADER_TIME()); |
4165 |
EventCounter *code=0; |
EventCounter *code=0; |
4166 |
UInt_t firstev = 0; |
UInt_t firstev = 0; |
4167 |
UInt_t lastev = 0; |
UInt_t lastev = 0; |
4168 |
UInt_t nevent = 0; |
// UInt_t nevent = 0; |
4169 |
UInt_t checkfirst = 0; |
UInt_t checkfirst = 0; |
4170 |
UInt_t checklast = 0; |
UInt_t checklast = 0; |
4171 |
UInt_t firstentry = 0; |
UInt_t firstentry = 0; |
4190 |
EventHeader *eh = 0; |
EventHeader *eh = 0; |
4191 |
PscuHeader *ph = 0; |
PscuHeader *ph = 0; |
4192 |
T->SetBranchAddress("Header", &eh); |
T->SetBranchAddress("Header", &eh); |
4193 |
nevent = T->GetEntries(); |
// nevent = T->GetEntries(); |
4194 |
// |
// |
4195 |
codt = eht->GetCounter(); |
codt = eht->GetCounter(); |
4196 |
codh = ehh->GetCounter(); |
codh = ehh->GetCounter(); |
5473 |
|
|
5474 |
if ( IsDebug() ) cout << endl << ">>>> TRY TO RECOVER TRACKER CALIBRATIONS <<<<"<<endl; |
if ( IsDebug() ) cout << endl << ">>>> TRY TO RECOVER TRACKER CALIBRATIONS <<<<"<<endl; |
5475 |
|
|
5476 |
TSQLResult *result = 0; |
TSQLResult *rresult = 0; // 10RED bug, result is re-used inside result looop... |
5477 |
|
TSQLResult *result = 0; // 10RED bug, result is re-used inside result looop... |
5478 |
TSQLRow *row = 0; |
TSQLRow *row = 0; |
5479 |
// |
// |
5480 |
stringstream oss; |
stringstream oss; |
5504 |
oss << " ORDER BY ID DESC LIMIT "<<ncalib<<"; "; |
oss << " ORDER BY ID DESC LIMIT "<<ncalib<<"; "; |
5505 |
if ( IsDebug() ) cout << oss.str().c_str() << endl; |
if ( IsDebug() ) cout << oss.str().c_str() << endl; |
5506 |
|
|
5507 |
result = conn->Query(oss.str().c_str()); |
rresult = conn->Query(oss.str().c_str()); |
5508 |
if ( !result ) throw -4;; |
if ( !result ) throw -4;; |
5509 |
if ( IsDebug() ) cout <<"Rows: "<<result->GetRowCount()<<endl; |
if ( IsDebug() ) cout <<"Rows: "<<result->GetRowCount()<<endl; |
5510 |
|
|
5513 |
// ----------------------------------- |
// ----------------------------------- |
5514 |
UInt_t nn=0; |
UInt_t nn=0; |
5515 |
do { |
do { |
5516 |
row = result->Next(); |
row = rresult->Next(); |
5517 |
if(!row)break; |
if(!row)break; |
5518 |
|
|
5519 |
UInt_t id = (UInt_t)atoll(row->GetField(0)); |
UInt_t id = (UInt_t)atoll(row->GetField(0)); |
5552 |
TString path = ""; |
TString path = ""; |
5553 |
TString name = ""; |
TString name = ""; |
5554 |
TString raw = ""; |
TString raw = ""; |
5555 |
UInt_t obt0 = 0; |
// UInt_t obt0 = 0; |
5556 |
UInt_t timesync = 0; |
// UInt_t timesync = 0; |
5557 |
UInt_t boot_number = 0; |
// UInt_t boot_number = 0; |
5558 |
bool FOUND = false; |
bool FOUND = false; |
5559 |
|
|
5560 |
if ( IsDebug() ) cout << "------------------------------------------------------------" <<endl; |
if ( IsDebug() ) cout << "------------------------------------------------------------" <<endl; |
5627 |
path = (TString)row2->GetField(0); |
path = (TString)row2->GetField(0); |
5628 |
name = (TString)row2->GetField(1); |
name = (TString)row2->GetField(1); |
5629 |
raw = (TString)row2->GetField(5); |
raw = (TString)row2->GetField(5); |
5630 |
obt0 = (UInt_t)atoll(row2->GetField(2)); |
// obt0 = (UInt_t)atoll(row2->GetField(2)); |
5631 |
timesync = (UInt_t)atoll(row2->GetField(3)); |
// timesync = (UInt_t)atoll(row2->GetField(3)); |
5632 |
boot_number = (UInt_t)atoll(row2->GetField(4)); |
// boot_number = (UInt_t)atoll(row2->GetField(4)); |
5633 |
|
|
5634 |
if ( IsDebug() ) cout << "- - - - - - - - - - -" <<endl; |
if ( IsDebug() ) cout << "- - - - - - - - - - -" <<endl; |
5635 |
// cout << path <<endl; |
// cout << path <<endl; |
5693 |
if(FOUND)break; |
if(FOUND)break; |
5694 |
|
|
5695 |
}while(1);//endl loop over root table entries |
}while(1);//endl loop over root table entries |
5696 |
|
|
5697 |
|
delete result2; // 10RED potential memory leak |
5698 |
if(FOUND)break; |
if(FOUND)break; |
5699 |
|
|
5700 |
}//end loop over tables |
}//end loop over tables |
5747 |
// --------------------------------------------------------------------- |
// --------------------------------------------------------------------- |
5748 |
UInt_t idtimesync = 0; |
UInt_t idtimesync = 0; |
5749 |
oss.str(""); |
oss.str(""); |
5750 |
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<<" and ID_RESURS_OFFSET="<< idresof <<" limit 1;"; // 10RED BUG!!!! without 'and ID_RESURS_OFFSET="<< idresof ' this query is not enough to ensure finding the correct line in GL_TIMSYNC... |
5751 |
if ( debug ) printf(" %s \n",oss.str().c_str()); |
if ( debug ) printf(" %s \n",oss.str().c_str()); |
5752 |
result = conn->Query(oss.str().c_str()); |
result = conn->Query(oss.str().c_str()); |
5753 |
if ( !result ) throw -3; |
if ( !result ) throw -3; |
5848 |
}while(1);//end loop over calibrations |
}while(1);//end loop over calibrations |
5849 |
|
|
5850 |
|
|
5851 |
if( result )delete result; |
if( rresult )delete rresult; // 10RED bug |
5852 |
if( row )delete row; |
if( row )delete row; |
5853 |
|
|
5854 |
|
|
6149 |
memset(myid,0,500*sizeof(UInt_t)); |
memset(myid,0,500*sizeof(UInt_t)); |
6150 |
// |
// |
6151 |
oss.str(""); |
oss.str(""); |
6152 |
oss << "SELECT ID,RUNTRAILER_TIME,RUNTRAILER_PKT,BOOT_NUMBER FROM GL_RUN_FRAGMENTS WHERE INSERT_TIME <= '" << clean_time->AsSQLString() << "'order BY RUNHEADER_TIME asc;"; |
oss << "SELECT ID,RUNTRAILER_TIME,RUNTRAILER_PKT,BOOT_NUMBER FROM GL_RUN_FRAGMENTS WHERE INSERT_TIME <= '" << clean_time->AsSQLString() << "' order BY RUNHEADER_TIME asc;"; |
6153 |
if ( IsDebug() ) printf(" Select from GL_RUN_FRAGMENTS runs older than %s : query is \n %s \n",clean_time->AsSQLString(),oss.str().c_str()); |
if ( IsDebug() ) printf(" Select from GL_RUN_FRAGMENTS runs older than %s : query is \n %s \n",clean_time->AsSQLString(),oss.str().c_str()); |
6154 |
nresult = conn->Query(oss.str().c_str()); |
nresult = conn->Query(oss.str().c_str()); |
6155 |
// |
// |
6180 |
while ( anr ){ |
while ( anr ){ |
6181 |
// |
// |
6182 |
oss.str(""); |
oss.str(""); |
6183 |
oss << "SELECT ID,RUNTRAILER_TIME,RUNTRAILER_PKT,BOOT_NUMBER FROM GL_RUN_FRAGMENTS WHERE BOOT_NUMBER=" << mbo << " AND RUNHEADER_PKT=" << mrhp << "+1 AND ABS(RUNHEADER_TIME-"<< mrht <<")<=1 AND INSERT_TIME <= '" << clean_time->AsSQLString() << "' order BY RUNHEADER_TIME asc;"; |
oss << "SELECT ID,RUNTRAILER_TIME,RUNTRAILER_PKT,BOOT_NUMBER FROM GL_RUN_FRAGMENTS WHERE BOOT_NUMBER=" << mbo << " AND RUNHEADER_PKT=" << mrhp << "+1 AND ABS(RUNHEADER_TIME-"<< (float)mrht <<")<=1 AND INSERT_TIME <= '" << clean_time->AsSQLString() << "' order BY RUNHEADER_TIME asc;"; // 10RED MYSQL OPERATOR BUG |
6184 |
if ( IsDebug() ) printf(" In the loop searching for fragmented runs : query is \n %s \n",oss.str().c_str()); |
if ( IsDebug() ) printf(" In the loop searching for fragmented runs : query is \n %s \n",oss.str().c_str()); |
6185 |
// |
// |
6186 |
nresult1 = conn->Query(oss.str().c_str()); |
nresult1 = conn->Query(oss.str().c_str()); |