135 |
stringstream qu; |
stringstream qu; |
136 |
TSQLResult *result = 0; |
TSQLResult *result = 0; |
137 |
TSQLResult *result2 = 0; |
TSQLResult *result2 = 0; |
138 |
|
TSQLResult *result3 = 0; |
139 |
TSQLRow *row = 0; |
TSQLRow *row = 0; |
140 |
TSQLRow *row2 = 0; |
TSQLRow *row2 = 0; |
141 |
|
TSQLRow *row3 = 0; |
142 |
TString chpath; |
TString chpath; |
143 |
TString chfile; |
TString chfile; |
144 |
UInt_t ridn = 0; |
UInt_t ridn = 0; |
163 |
}; |
}; |
164 |
delete result; |
delete result; |
165 |
qu.str(""); |
qu.str(""); |
166 |
qu << "SELECT FOLDER_NAME,FILE_NAME,OBT_TIME_SYNC,LAST_TIME_SYNC_INFO,TIME_OFFSET,BOOT_NUMBER,PKT_NUMBER_INIT,PKT_NUMBER_FINAL,PKT_OBT_INIT,PKT_OBT_FINAL from ROOT_TABLE where ID_N=" << ridn << ";"; |
qu << "SELECT FOLDER_NAME,FILE_NAME,OBT_TIME_SYNC,LAST_TIME_SYNC_INFO,TIME_OFFSET,BOOT_NUMBER,PKT_NUMBER_INIT,PKT_NUMBER_FINAL,PKT_OBT_INIT,PKT_OBT_FINAL,REAL_TIME_INIT from ROOT_TABLE where ID_N=" << ridn << ";"; |
167 |
if ( debug ) printf(" chewbacca: query is %s \n",qu.str().c_str()); |
if ( debug ) printf(" chewbacca: query is %s \n",qu.str().c_str()); |
168 |
result2 = conn->Query(qu.str().c_str()); |
result2 = conn->Query(qu.str().c_str()); |
169 |
if ( result2 ){ |
if ( result2 ){ |
180 |
chresursts = (UInt_t)atoll(row2->GetField(4)); |
chresursts = (UInt_t)atoll(row2->GetField(4)); |
181 |
chboot = (UInt_t)atoll(row2->GetField(5)); |
chboot = (UInt_t)atoll(row2->GetField(5)); |
182 |
// |
// |
183 |
|
if ( !chboot ){ |
184 |
|
qu.str(""); |
185 |
|
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;"; |
186 |
|
if ( debug ) printf(" chewbacca: query is %s \n",qu.str().c_str()); |
187 |
|
result3 = conn->Query(qu.str().c_str()); |
188 |
|
if ( result3 ){ |
189 |
|
row3 = result3->Next(); |
190 |
|
if ( row3 && result3->GetRowCount() == 1 ){ |
191 |
|
chboot = (UInt_t)atoll(row3->GetField(0)); |
192 |
|
if ( debug ) printf(" Found boot_number = %u \n",chboot); |
193 |
|
} else { |
194 |
|
if ( debug ) printf(" AGH CANNOT DETERMINE THE BOOT NUMBER... \n"); |
195 |
|
throw -29; |
196 |
|
}; |
197 |
|
}; |
198 |
|
}; |
199 |
|
// |
200 |
chpktinit = (UInt_t)atoll(row2->GetField(6)); |
chpktinit = (UInt_t)atoll(row2->GetField(6)); |
201 |
chpktfinal = (UInt_t)atoll(row2->GetField(7)); |
chpktfinal = (UInt_t)atoll(row2->GetField(7)); |
202 |
chobtinit = (UInt_t)atoll(row2->GetField(8)); |
chobtinit = (UInt_t)atoll(row2->GetField(8)); |
2267 |
ptht = cod->Get(pctp->RunHeader) - 1; |
ptht = cod->Get(pctp->RunHeader) - 1; |
2268 |
// evbeft = cod->Get(pctp->Physics); |
// evbeft = cod->Get(pctp->Physics); |
2269 |
tcod = (UInt_t)cod->Get(pctp->Physics); |
tcod = (UInt_t)cod->Get(pctp->Physics); |
2270 |
if ( !tcod ) tcod = 1; |
if ( !tcod ) tcod = 1; // IS A BUG SINCE RUNS WITH ZERO EVENTS WILL LOOK LIKE RUNS WITH ONE EVENT |
2271 |
evbeft = TMath::Min(upperentry,(tcod-1)); |
evbeft = TMath::Min(upperentry,(tcod-1)); |
2272 |
if ( debug ) printf(" Loop in runtrailers, evbeft is %u upperentry %u cod->getetc %u \n",evbeft,upperentry,cod->Get(pctp->Physics)); |
if ( debug ) printf(" Loop in runtrailers, evbeft is %u upperentry %u cod->getetc %u \n",evbeft,upperentry,cod->Get(pctp->Physics)); |
2273 |
// |
// |
2306 |
obth = phh->GetOrbitalTime(); |
obth = phh->GetOrbitalTime(); |
2307 |
cod = ehh->GetCounter(); |
cod = ehh->GetCounter(); |
2308 |
tcod = (UInt_t)cod->Get(pctp->Physics); |
tcod = (UInt_t)cod->Get(pctp->Physics); |
2309 |
if ( !tcod ) tcod = 1; |
if ( !tcod ) tcod = 1; // IS A BUG SINCE RUNS WITH ZERO EVENTS WILL LOOK LIKE RUNS WITH ONE EVENT |
2310 |
evbefh = TMath::Max(chminentry,(tcod-1)); |
evbefh = TMath::Max(chminentry,(tcod-1)); |
2311 |
// |
// |
2312 |
if ( PKT(pkth) >= PKT(pktfirst) && PKT(pkth) <= upperpkt ){ |
if ( PKT(pkth) >= PKT(pktfirst) && PKT(pkth) <= upperpkt ){ |
2368 |
cod = ehh->GetCounter(); |
cod = ehh->GetCounter(); |
2369 |
// evbeft = cod->Get(pctp->Physics); |
// evbeft = cod->Get(pctp->Physics); |
2370 |
tcod = (UInt_t)cod->Get(pctp->Physics); |
tcod = (UInt_t)cod->Get(pctp->Physics); |
2371 |
if ( !tcod ) tcod = 1; |
if ( !tcod ) tcod = 1; // IS A BUG SINCE RUNS WITH ZERO EVENTS WILL LOOK LIKE RUNS WITH ONE EVENT |
2372 |
evbeft = TMath::Min(upperentry,(tcod-1)); |
evbeft = TMath::Min(upperentry,(tcod-1)); |
2373 |
rh->GetEntry(pth); |
rh->GetEntry(pth); |
2374 |
phh = ehh->GetPscuHeader(); |
phh = ehh->GetPscuHeader(); |
2674 |
// |
// |
2675 |
// we have now the good first piece of a run, fill the glrun object |
// we have now the good first piece of a run, fill the glrun object |
2676 |
// |
// |
2677 |
if ( rhfirstev != firstev && !mishead ) mishead = true; |
if ( firstev != (lastev+1) ){ // could be a problem sometimes (?) |
2678 |
if ( rtlastev != lastev && !mistrail ) mistrail = true; |
if ( rhfirstev != firstev && !mishead ) mishead = true; |
2679 |
|
if ( rtlastev != lastev && !mistrail ) mistrail = true; |
2680 |
|
}; |
2681 |
// |
// |
2682 |
|
if ( IsDebug() ) printf(" bhere firstev is %i lastev is %i \n",firstev,lastev); |
2683 |
this->FillClass(mishead,mistrail,firstev,lastev); |
this->FillClass(mishead,mistrail,firstev,lastev); |
2684 |
|
if ( IsDebug() ) printf(" chere firstev is %i lastev is %i \n",firstev,lastev); |
2685 |
// |
// |
2686 |
if ( IsDebug() ) printf("The run is good, is it the other piece in the GL_RUN_FRAGMENTS table?\n"); |
if ( IsDebug() ) printf("The run is good, is it the other piece in the GL_RUN_FRAGMENTS table?\n"); |
2687 |
if ( IsDebug() ) printf(" C THIS RUN: RUNHEADER_OBT %u RUNTRAILER_OBT %u RUNHEADER_PKT %u RUNTRAILER_PKT %u \n", glrun->GetRUNHEADER_OBT(),glrun->GetRUNTRAILER_OBT(),glrun->GetRUNHEADER_PKT(),glrun->GetRUNTRAILER_PKT()); |
if ( IsDebug() ) printf(" C THIS RUN: RUNHEADER_OBT %u RUNTRAILER_OBT %u RUNHEADER_PKT %u RUNTRAILER_PKT %u \n", glrun->GetRUNHEADER_OBT(),glrun->GetRUNTRAILER_OBT(),glrun->GetRUNHEADER_PKT(),glrun->GetRUNTRAILER_PKT()); |
2776 |
// |
// |
2777 |
found = false; // default value |
found = false; // default value |
2778 |
// |
// |
2779 |
if ( IsDebug() ) printf(" Found a possible candidate, checking if it is the good one... \n"); |
if ( IsDebug() ) printf(" A Found a possible candidate, checking if it is the good one... \n"); |
2780 |
// |
// |
2781 |
// if we have both runheader and runtrailer we can check with pkt_counter: |
// if we have both runheader and runtrailer we can check with pkt_counter: |
2782 |
// |
// |
2792 |
if ( IsDebug() ) printf(" FOUND!!! check %llu pktt %llu \n",chkpkt,pktt); |
if ( IsDebug() ) printf(" FOUND!!! check %llu pktt %llu \n",chkpkt,pktt); |
2793 |
// |
// |
2794 |
found = true; |
found = true; |
2795 |
|
if ( IsDebug() ) printf(" where firstev is %i lastev is %i \n",firstev,lastev); |
2796 |
// |
// |
2797 |
} else { |
} else { |
2798 |
// |
// |
2858 |
oss << " ID="<<row->GetField(0)<<";"; |
oss << " ID="<<row->GetField(0)<<";"; |
2859 |
// |
// |
2860 |
glrun1->Query_GL_RUN_FRAGMENTS(oss.str().c_str(),conn); // here we have runheader infos |
glrun1->Query_GL_RUN_FRAGMENTS(oss.str().c_str(),conn); // here we have runheader infos |
2861 |
|
if ( IsDebug() ) printf(" there firstev is %i lastev is %i \n",firstev,lastev); |
2862 |
// |
// |
2863 |
// merge infos |
// merge infos |
2864 |
// |
// |
2889 |
glrun1->SetRUNTRAILER_OBT(glrun->GetRUNTRAILER_OBT()); |
glrun1->SetRUNTRAILER_OBT(glrun->GetRUNTRAILER_OBT()); |
2890 |
glrun1->SetRUNTRAILER_PKT(glrun->GetRUNTRAILER_PKT()); |
glrun1->SetRUNTRAILER_PKT(glrun->GetRUNTRAILER_PKT()); |
2891 |
// |
// |
2892 |
|
if ( IsDebug() ) printf(" here firstev is %i lastev is %i \n",firstev,lastev); |
2893 |
|
// |
2894 |
glrun->SetEV_FROM(firstev); |
glrun->SetEV_FROM(firstev); |
2895 |
glrun->SetNEVENTS(lastev-firstev+1); |
glrun->SetNEVENTS(lastev-firstev+1); |
2896 |
// |
// |
2983 |
// |
// |
2984 |
found = false; // default value |
found = false; // default value |
2985 |
// |
// |
2986 |
if ( IsDebug() ) printf(" Found a possible candidate, checking if it is the good one... \n"); |
if ( IsDebug() ) printf(" B Found a possible candidate, checking if it is the good one... \n"); |
2987 |
// |
// |
2988 |
// if we have both runheader and runtrailer we can check with pkt_counter: |
// if we have both runheader and runtrailer we can check with pkt_counter: |
2989 |
// |
// |
3212 |
glrun->SetID(this->AssignRunID()); |
glrun->SetID(this->AssignRunID()); |
3213 |
glrun->SetID_RUN_FRAG(0); |
glrun->SetID_RUN_FRAG(0); |
3214 |
glrun->Fill_GL_RUN(conn); // it'ok we arrive here only inside a file hence in the middle of the runs... |
glrun->Fill_GL_RUN(conn); // it'ok we arrive here only inside a file hence in the middle of the runs... |
3215 |
}; |
}; |
3216 |
// |
// |
3217 |
}; |
}; |
3218 |
// |
// |
3256 |
if ( firstev == lastev+1 || lastev == firstev ) { // no events inside the run! |
if ( firstev == lastev+1 || lastev == firstev ) { // no events inside the run! |
3257 |
//if ( firstev <= lastev+1 ) { // no events inside the run! |
//if ( firstev <= lastev+1 ) { // no events inside the run! |
3258 |
if ( IsDebug() ) printf(" Checking but no events in the run! \n"); |
if ( IsDebug() ) printf(" Checking but no events in the run! \n"); |
3259 |
|
firstev = lastev+1; // this is necessary for files with no Physics entries, should have no influence on other files |
3260 |
// return true is correct |
// return true is correct |
3261 |
return(true); |
return(true); |
3262 |
// |
// |
3512 |
// |
// |
3513 |
found = false; // default value |
found = false; // default value |
3514 |
// |
// |
3515 |
if ( IsDebug() ) printf(" Found a possible candidate, checking if it is the good one... \n"); |
if ( IsDebug() ) printf(" C Found a possible candidate, checking if it is the good one... \n"); |
3516 |
// |
// |
3517 |
// if we have both runheader and runtrailer we can check with pkt_counter: |
// if we have both runheader and runtrailer we can check with pkt_counter: |
3518 |
// |
// |