| 101 |
if (INSERT_RAW) SetRawName(filerawname); |
if (INSERT_RAW) SetRawName(filerawname); |
| 102 |
// |
// |
| 103 |
INSERT_ROOT = !filerootname.IsNull(); |
INSERT_ROOT = !filerootname.IsNull(); |
| 104 |
|
if ( INSERT_ROOT ) this->SetRootName(filerootname); |
| 105 |
this->SetOrbitNo(dwinput); |
this->SetOrbitNo(dwinput); |
| 106 |
// |
// |
| 107 |
this->SetID_RAW(0); |
this->SetID_RAW(0); |
| 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 limit 1;"; |
| 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 ){ |
| 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 |
|
}; |
| 196 |
|
}; |
| 197 |
|
}; |
| 198 |
|
// |
| 199 |
chpktinit = (UInt_t)atoll(row2->GetField(6)); |
chpktinit = (UInt_t)atoll(row2->GetField(6)); |
| 200 |
chpktfinal = (UInt_t)atoll(row2->GetField(7)); |
chpktfinal = (UInt_t)atoll(row2->GetField(7)); |
| 201 |
chobtinit = (UInt_t)atoll(row2->GetField(8)); |
chobtinit = (UInt_t)atoll(row2->GetField(8)); |
| 208 |
throw -85; |
throw -85; |
| 209 |
}; |
}; |
| 210 |
filerootname = chpath + chfile;// + ".root"; |
filerootname = chpath + chfile;// + ".root"; |
|
if ( debug ) printf(" chewbacca: filename is %s \n",filerootname.Data()); |
|
| 211 |
}; |
}; |
| 212 |
this->SetRootName(filerootname); |
this->SetRootName(filerootname); |
|
file = TFile::Open(this->GetRootName().Data()); |
|
|
} else { |
|
|
this->SetRootName(""); |
|
| 213 |
}; |
}; |
| 214 |
|
if ( debug ) printf(" Filename is %s \n",filerootname.Data()); |
| 215 |
|
file = TFile::Open(this->GetRootName().Data()); |
| 216 |
|
// } else { |
| 217 |
|
// this->SetRootName(""); |
| 218 |
|
// this->SetRootName(filerootname); |
| 219 |
|
// }; |
| 220 |
} |
} |
| 221 |
|
|
| 222 |
// |
// |
| 416 |
return; |
return; |
| 417 |
}; |
}; |
| 418 |
// |
// |
| 419 |
TString name = this->GetRootFile(); |
if ( !chewbacca ){ |
| 420 |
Int_t nlength = name.Length(); |
TString name = this->GetRootFile(); |
| 421 |
if ( nlength < 5 ) return; |
Int_t nlength = name.Length(); |
| 422 |
TString dwo = 0; |
if ( nlength < 5 ){ |
| 423 |
for (Int_t i = 0; i<5; i++){ |
if ( IsDebug() ) printf(" Agh problems determining the orbit number! name = %s \n",name.Data()); |
| 424 |
dwo.Append(name[i],1); |
return; |
| 425 |
}; |
}; |
| 426 |
if ( dwo.IsDigit() ){ |
TString dwo = 0; |
| 427 |
dworbit = (UInt_t)dwo.Atoi(); |
for (Int_t i = 0; i<5; i++){ |
|
} else { |
|
|
dwo=""; |
|
|
for (Int_t i = 8; i<13; i++){ |
|
| 428 |
dwo.Append(name[i],1); |
dwo.Append(name[i],1); |
| 429 |
}; |
}; |
| 430 |
if ( dwo.IsDigit() ) dworbit = (UInt_t)dwo.Atoi(); |
if ( dwo.IsDigit() ){ |
| 431 |
|
dworbit = (UInt_t)dwo.Atoi(); |
| 432 |
|
} else { |
| 433 |
|
dwo=""; |
| 434 |
|
for (Int_t i = 8; i<13; i++){ |
| 435 |
|
dwo.Append(name[i],1); |
| 436 |
|
}; |
| 437 |
|
if ( dwo.IsDigit() ) dworbit = (UInt_t)dwo.Atoi(); |
| 438 |
|
}; |
| 439 |
|
if ( IsDebug() ) printf(" Downlink orbit is %i (dwo = %s) \n",dworbit,dwo.Data()); |
| 440 |
}; |
}; |
|
if ( IsDebug() ) printf(" Downlink orbit is %i (dwo = %s) \n",dworbit,dwo.Data()); |
|
| 441 |
return; |
return; |
| 442 |
}; |
}; |
| 443 |
|
|
| 686 |
UInt_t tjump = 50000; |
UInt_t tjump = 50000; |
| 687 |
//UInt_t tjump = 100; |
//UInt_t tjump = 100; |
| 688 |
while ( tjump > 0 ){ |
while ( tjump > 0 ){ |
| 689 |
pktlast = numeric_limits<UInt_t>::max(); |
// pktlast = numeric_limits<UInt_t>::max(); |
| 690 |
while ( pktlast > chpktmax && (Int_t)(nevent-1-it) >= 0 ){ |
pktlast = chpktmax + 1; |
| 691 |
|
while ( PKT(pktlast) > PKT(chpktmax) && (Int_t)(nevent-1-it) >= 0 ){ |
| 692 |
if ( (Int_t)(nevent-1-it) >= 0 ){ |
if ( (Int_t)(nevent-1-it) >= 0 ){ |
| 693 |
T->GetEntry(nevent-1-it); |
T->GetEntry(nevent-1-it); |
| 694 |
ph = eh->GetPscuHeader(); |
ph = eh->GetPscuHeader(); |
| 696 |
} else { |
} else { |
| 697 |
pktlast = chpktmax + 1; |
pktlast = chpktmax + 1; |
| 698 |
}; |
}; |
| 699 |
if ( (!(it%1000) || abs((int)pktlast - (int)chpktmax)<1000 ) && debug ) printf(" look for up %i %i %i nevent %u (nevent-1-it) %i \n",it,pktlast,chpktmax,nevent,(Int_t)(nevent-1-it)); |
if ( (!(it%1000) || abs((int)(PKT(pktlast) - PKT(chpktmax)))<1000 ) && debug ) printf(" look for up %i %i %i nevent %u (nevent-1-it) %i \n",it,pktlast,chpktmax,nevent,(Int_t)(nevent-1-it)); |
| 700 |
it += tjump; |
it += tjump; |
| 701 |
}; |
}; |
| 702 |
if ( tjump > 1 ) it -= 2*tjump; |
if ( tjump > 1 ) it -= 2*tjump; |
| 720 |
tjump = 50000; |
tjump = 50000; |
| 721 |
//tjump = 100; |
//tjump = 100; |
| 722 |
while ( tjump > 0 ){ |
while ( tjump > 0 ){ |
| 723 |
pktlast = 0; |
// pktlast = 0; |
| 724 |
while ( pktlast < chpktmin && it < (Int_t)nevent ){ |
pktlast = chpktmin - 1; |
| 725 |
|
if ( debug ) printf("LLlook for down %i %i %llu %llu \n",it,pktlast,PKT(pktlast),PKT(chpktmin)); |
| 726 |
|
while ( PKT(pktlast) < PKT(chpktmin) && it < (Int_t)nevent ){ |
| 727 |
if ( it < (Int_t)nevent ){ |
if ( it < (Int_t)nevent ){ |
| 728 |
T->GetEntry(it); |
T->GetEntry(it); |
| 729 |
ph = eh->GetPscuHeader(); |
ph = eh->GetPscuHeader(); |
| 1378 |
// |
// |
| 1379 |
// if ( IsDebug() ) printf(" obt conversion: obt is %u obtfirst is %u (numeric_limits<UInt_t>::max()/2) is %u \n",obt,pobtfirst,(UInt_t)(numeric_limits<UInt_t>::max()/2)); |
// if ( IsDebug() ) printf(" obt conversion: obt is %u obtfirst is %u (numeric_limits<UInt_t>::max()/2) is %u \n",obt,pobtfirst,(UInt_t)(numeric_limits<UInt_t>::max()/2)); |
| 1380 |
// |
// |
| 1381 |
if ( obt < (pobtfirst/2) && pobtfirst > (numeric_limits<UInt_t>::max()/2) ){ |
if ( obt < ((Long64_t)pobtfirst/2) && pobtfirst > (numeric_limits<UInt_t>::max()/2) ){ |
| 1382 |
// if ( IsDebug() ) printf(" rise up obt %lld \n",(Long64_t)obt+(Long64_t)numeric_limits<UInt_t>::max()); |
// if ( IsDebug() ) printf(" rise up obt %lld \n",(Long64_t)obt+(Long64_t)numeric_limits<UInt_t>::max()); |
| 1383 |
return((Long64_t)obt+(Long64_t)numeric_limits<UInt_t>::max()); |
return((Long64_t)obt+(Long64_t)numeric_limits<UInt_t>::max()); |
| 1384 |
}; |
}; |
| 1603 |
result = conn->Query(oss.str().c_str()); |
result = conn->Query(oss.str().c_str()); |
| 1604 |
if ( !result ) throw -10; |
if ( !result ) throw -10; |
| 1605 |
row = result->Next(); |
row = result->Next(); |
| 1606 |
|
if ( !row ) throw -92; |
| 1607 |
idresof = (UInt_t)atoll(row->GetField(0)); |
idresof = (UInt_t)atoll(row->GetField(0)); |
| 1608 |
existsts = true; |
existsts = true; |
| 1609 |
goto eout; |
goto eout; |
| 2266 |
ptht = cod->Get(pctp->RunHeader) - 1; |
ptht = cod->Get(pctp->RunHeader) - 1; |
| 2267 |
// evbeft = cod->Get(pctp->Physics); |
// evbeft = cod->Get(pctp->Physics); |
| 2268 |
tcod = (UInt_t)cod->Get(pctp->Physics); |
tcod = (UInt_t)cod->Get(pctp->Physics); |
| 2269 |
if ( !tcod ) tcod = 1; |
if ( !tcod ) tcod = 1; // IS A BUG SINCE RUNS WITH ZERO EVENTS WILL LOOK LIKE RUNS WITH ONE EVENT |
| 2270 |
evbeft = TMath::Min(upperentry,(tcod-1)); |
evbeft = TMath::Min(upperentry,(tcod-1)); |
| 2271 |
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)); |
| 2272 |
// |
// |
| 2305 |
obth = phh->GetOrbitalTime(); |
obth = phh->GetOrbitalTime(); |
| 2306 |
cod = ehh->GetCounter(); |
cod = ehh->GetCounter(); |
| 2307 |
tcod = (UInt_t)cod->Get(pctp->Physics); |
tcod = (UInt_t)cod->Get(pctp->Physics); |
| 2308 |
if ( !tcod ) tcod = 1; |
if ( !tcod ) tcod = 1; // IS A BUG SINCE RUNS WITH ZERO EVENTS WILL LOOK LIKE RUNS WITH ONE EVENT |
| 2309 |
evbefh = TMath::Max(chminentry,(tcod-1)); |
evbefh = TMath::Max(chminentry,(tcod-1)); |
| 2310 |
// |
// |
| 2311 |
if ( PKT(pkth) >= PKT(pktfirst) && PKT(pkth) <= upperpkt ){ |
if ( PKT(pkth) >= PKT(pktfirst) && PKT(pkth) <= upperpkt ){ |
| 2344 |
// |
// |
| 2345 |
this->HandleRunFragments(true,true,chminentry,(evbefh)); |
this->HandleRunFragments(true,true,chminentry,(evbefh)); |
| 2346 |
// |
// |
| 2347 |
|
// what about pth=ptht-1 |
| 2348 |
}; |
}; |
| 2349 |
}; |
}; |
| 2350 |
// |
// |
| 2367 |
cod = ehh->GetCounter(); |
cod = ehh->GetCounter(); |
| 2368 |
// evbeft = cod->Get(pctp->Physics); |
// evbeft = cod->Get(pctp->Physics); |
| 2369 |
tcod = (UInt_t)cod->Get(pctp->Physics); |
tcod = (UInt_t)cod->Get(pctp->Physics); |
| 2370 |
if ( !tcod ) tcod = 1; |
if ( !tcod ) tcod = 1; // IS A BUG SINCE RUNS WITH ZERO EVENTS WILL LOOK LIKE RUNS WITH ONE EVENT |
| 2371 |
evbeft = TMath::Min(upperentry,(tcod-1)); |
evbeft = TMath::Min(upperentry,(tcod-1)); |
| 2372 |
rh->GetEntry(pth); |
rh->GetEntry(pth); |
| 2373 |
phh = ehh->GetPscuHeader(); |
phh = ehh->GetPscuHeader(); |
| 2407 |
// if ( ptt+1 == rtev){ |
// if ( ptt+1 == rtev){ |
| 2408 |
if ( conptt+1 == nrtev ){ |
if ( conptt+1 == nrtev ){ |
| 2409 |
// if ( conptt+1 == (nrtev+nrtbef )){ |
// if ( conptt+1 == (nrtev+nrtbef )){ |
| 2410 |
|
if ( IsDebug() ) printf(" >>>>>>>>>>> %i %u %i %u \n",ptht,rhev,nrtev,conptt); |
| 2411 |
ptht++; |
ptht++; |
| 2412 |
if ( ptht < rhev ){ |
if ( ptht < rhev ){ |
| 2413 |
rh->GetEntry(ptht); |
rh->GetEntry(ptht); |
| 2414 |
|
//pth++; |
| 2415 |
|
//if ( pth < rhev ){ |
| 2416 |
|
//rh->GetEntry(pth); |
| 2417 |
phh = ehh->GetPscuHeader(); |
phh = ehh->GetPscuHeader(); |
| 2418 |
pkth = phh->GetCounter(); |
pkth = phh->GetCounter(); |
| 2419 |
obth = phh->GetOrbitalTime(); |
obth = phh->GetOrbitalTime(); |
| 2437 |
if ( (UInt_t)evbeft < upperentry-1 && upperentry>0 ){ |
if ( (UInt_t)evbeft < upperentry-1 && upperentry>0 ){ |
| 2438 |
if ( IsDebug() ) printf(" Piece of run at the end of the file with NO RUNHEADER! evbeft %u upperentry-1 %u \n",(UInt_t)evbeft,upperentry-1); |
if ( IsDebug() ) printf(" Piece of run at the end of the file with NO RUNHEADER! evbeft %u upperentry-1 %u \n",(UInt_t)evbeft,upperentry-1); |
| 2439 |
// |
// |
| 2440 |
if ( (ptt-1) < 0 ) throw -15; // should never arrive here! |
// if ( (ptt-1) < 0 ) throw -15; // should never arrive here! |
| 2441 |
rt->GetEntry(ptt-1); |
if ( (rtev-1) < 0 || ptt < 0 ) throw -15; // should never arrive here! |
| 2442 |
|
// rt->GetEntry(ptt-1); |
| 2443 |
|
rt->GetEntry(rtev-1); |
| 2444 |
cod = eht->GetCounter(); |
cod = eht->GetCounter(); |
| 2445 |
tcod = (UInt_t)cod->Get(pctp->Physics); |
tcod = (UInt_t)cod->Get(pctp->Physics)+1; |
| 2446 |
evbefh = TMath::Max(chminentry,tcod); |
evbefh = TMath::Max(chminentry,tcod); |
| 2447 |
// evbefh = cod->Get(pctp->Physics); |
// evbefh = cod->Get(pctp->Physics); |
| 2448 |
rt->GetEntry(ptt); |
rt->GetEntry(ptt); |
| 2673 |
// |
// |
| 2674 |
// 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 |
| 2675 |
// |
// |
| 2676 |
if ( rhfirstev != firstev && !mishead ) mishead = true; |
if ( firstev != (lastev+1) ){ // could be a problem sometimes (?) |
| 2677 |
if ( rtlastev != lastev && !mistrail ) mistrail = true; |
if ( rhfirstev != firstev && !mishead ) mishead = true; |
| 2678 |
|
if ( rtlastev != lastev && !mistrail ) mistrail = true; |
| 2679 |
|
}; |
| 2680 |
// |
// |
| 2681 |
|
if ( IsDebug() ) printf(" bhere firstev is %i lastev is %i \n",firstev,lastev); |
| 2682 |
this->FillClass(mishead,mistrail,firstev,lastev); |
this->FillClass(mishead,mistrail,firstev,lastev); |
| 2683 |
|
if ( IsDebug() ) printf(" chere firstev is %i lastev is %i \n",firstev,lastev); |
| 2684 |
// |
// |
| 2685 |
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"); |
| 2686 |
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()); |
| 2775 |
// |
// |
| 2776 |
found = false; // default value |
found = false; // default value |
| 2777 |
// |
// |
| 2778 |
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"); |
| 2779 |
// |
// |
| 2780 |
// 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: |
| 2781 |
// |
// |
| 2791 |
if ( IsDebug() ) printf(" FOUND!!! check %llu pktt %llu \n",chkpkt,pktt); |
if ( IsDebug() ) printf(" FOUND!!! check %llu pktt %llu \n",chkpkt,pktt); |
| 2792 |
// |
// |
| 2793 |
found = true; |
found = true; |
| 2794 |
|
if ( IsDebug() ) printf(" where firstev is %i lastev is %i \n",firstev,lastev); |
| 2795 |
// |
// |
| 2796 |
} else { |
} else { |
| 2797 |
// |
// |
| 2857 |
oss << " ID="<<row->GetField(0)<<";"; |
oss << " ID="<<row->GetField(0)<<";"; |
| 2858 |
// |
// |
| 2859 |
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 |
| 2860 |
|
if ( IsDebug() ) printf(" there firstev is %i lastev is %i \n",firstev,lastev); |
| 2861 |
// |
// |
| 2862 |
// merge infos |
// merge infos |
| 2863 |
// |
// |
| 2888 |
glrun1->SetRUNTRAILER_OBT(glrun->GetRUNTRAILER_OBT()); |
glrun1->SetRUNTRAILER_OBT(glrun->GetRUNTRAILER_OBT()); |
| 2889 |
glrun1->SetRUNTRAILER_PKT(glrun->GetRUNTRAILER_PKT()); |
glrun1->SetRUNTRAILER_PKT(glrun->GetRUNTRAILER_PKT()); |
| 2890 |
// |
// |
| 2891 |
|
if ( IsDebug() ) printf(" here firstev is %i lastev is %i \n",firstev,lastev); |
| 2892 |
|
// |
| 2893 |
glrun->SetEV_FROM(firstev); |
glrun->SetEV_FROM(firstev); |
| 2894 |
glrun->SetNEVENTS(lastev-firstev+1); |
glrun->SetNEVENTS(lastev-firstev+1); |
| 2895 |
// |
// |
| 2982 |
// |
// |
| 2983 |
found = false; // default value |
found = false; // default value |
| 2984 |
// |
// |
| 2985 |
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"); |
| 2986 |
// |
// |
| 2987 |
// 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: |
| 2988 |
// |
// |
| 3211 |
glrun->SetID(this->AssignRunID()); |
glrun->SetID(this->AssignRunID()); |
| 3212 |
glrun->SetID_RUN_FRAG(0); |
glrun->SetID_RUN_FRAG(0); |
| 3213 |
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... |
| 3214 |
}; |
}; |
| 3215 |
// |
// |
| 3216 |
}; |
}; |
| 3217 |
// |
// |
| 3255 |
if ( firstev == lastev+1 || lastev == firstev ) { // no events inside the run! |
if ( firstev == lastev+1 || lastev == firstev ) { // no events inside the run! |
| 3256 |
//if ( firstev <= lastev+1 ) { // no events inside the run! |
//if ( firstev <= lastev+1 ) { // no events inside the run! |
| 3257 |
if ( IsDebug() ) printf(" Checking but no events in the run! \n"); |
if ( IsDebug() ) printf(" Checking but no events in the run! \n"); |
| 3258 |
|
firstev = lastev+1; // this is necessary for files with no Physics entries, should have no influence on other files |
| 3259 |
// return true is correct |
// return true is correct |
| 3260 |
return(true); |
return(true); |
| 3261 |
// |
// |
| 3285 |
// |
// |
| 3286 |
} else { |
} else { |
| 3287 |
// |
// |
| 3288 |
if ( IsDebug() ) printf(" There are no-phyics packets inside the run!\n"); |
if ( IsDebug() ) printf(" There are no-physics packets inside the run!\n"); |
| 3289 |
// |
// |
| 3290 |
// HERE WE MUST HANDLE THAT RUNS AND GO BACK |
// HERE WE MUST HANDLE THAT RUNS AND GO BACK |
| 3291 |
// |
// |
| 3295 |
UInt_t check = 0; |
UInt_t check = 0; |
| 3296 |
UInt_t lastevtemp = lastev; |
UInt_t lastevtemp = lastev; |
| 3297 |
UInt_t firstevno = firstev; |
UInt_t firstevno = firstev; |
| 3298 |
|
UInt_t rhchko=0; |
| 3299 |
|
UInt_t rhchk=0; |
| 3300 |
// |
// |
| 3301 |
for (UInt_t i=firstev; i<=lastev; i++){ |
for (UInt_t i=firstev; i<=lastev; i++){ |
| 3302 |
// |
// |
| 3305 |
// |
// |
| 3306 |
check = 0; |
check = 0; |
| 3307 |
// |
// |
| 3308 |
|
|
| 3309 |
|
// if we have a runheader set lastev then exit |
| 3310 |
|
// |
| 3311 |
for(Iter = packetsNames.begin(); Iter != packetsNames.end(); Iter++){ |
for(Iter = packetsNames.begin(); Iter != packetsNames.end(); Iter++){ |
| 3312 |
if ( strcmp(*Iter,"Physics") ) check += code->Get(GetPacketType(*Iter)); |
if ( strcmp(*Iter,"Physics") ) check += code->Get(GetPacketType(*Iter)); |
| 3313 |
}; |
}; |
| 3314 |
|
// check here if we have a runheader |
| 3315 |
|
rhchko = rhchk; |
| 3316 |
|
rhchk = code->Get(GetPacketType("RunHeader")); |
| 3317 |
// |
// |
| 3318 |
if ( checkfirst < check || i == lastev ){ |
if ( checkfirst < check || i == lastev ){ |
| 3319 |
// |
// |
| 3511 |
// |
// |
| 3512 |
found = false; // default value |
found = false; // default value |
| 3513 |
// |
// |
| 3514 |
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"); |
| 3515 |
// |
// |
| 3516 |
// 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: |
| 3517 |
// |
// |
| 3730 |
// |
// |
| 3731 |
}; |
}; |
| 3732 |
// |
// |
| 3733 |
|
if ( i > firstev ){ |
| 3734 |
|
if ( rhchko != rhchk ){ |
| 3735 |
|
if ( IsDebug() ) printf("oh oh... we have a runheader! stop here and handle later the remaining piece\n"); |
| 3736 |
|
lastev = i; |
| 3737 |
|
return(false); |
| 3738 |
|
}; |
| 3739 |
|
}; |
| 3740 |
|
// |
| 3741 |
if ( check == checklast && i != lastev ){ |
if ( check == checklast && i != lastev ){ |
| 3742 |
lastevtemp = i - 1; |
lastevtemp = i - 1; |
| 3743 |
i = lastev - 1; |
i = lastev - 1; |
| 4954 |
// |
// |
| 4955 |
}; |
}; |
| 4956 |
// |
// |
| 4957 |
|
|
| 4958 |
|
if( !(MISSING_pkt1&MISSING_pkt2) ){ |
| 4959 |
|
this->HandleTRK_CALIB(!MISSING_pkt1,!MISSING_pkt2); |
| 4960 |
|
ncalib++; |
| 4961 |
|
if( MISSING_pkt1||MISSING_pkt2||!valid )try_to_recover=true; |
| 4962 |
|
} |
| 4963 |
|
|
| 4964 |
|
|
| 4965 |
} else { |
} else { |
| 4966 |
// |
// |
| 4967 |
if ( IsDebug() ) printf(" Trk calibration1 at time %u obt %u pkt %u OUTSIDE the considered time interval \n",fromtime,obt1,pkt1); |
if ( IsDebug() ) printf(" Trk calibration1 at time %u obt %u pkt %u OUTSIDE the considered time interval \n",fromtime,obt1,pkt1); |
| 4968 |
// if ( PEDANTIC ) throw -79; |
// if ( PEDANTIC ) throw -79; |
| 4969 |
// |
// |
| 4970 |
}; |
}; |
| 4971 |
// |
// |
| 4972 |
|
|
|
if( !(MISSING_pkt1&MISSING_pkt2) ){ |
|
|
this->HandleTRK_CALIB(!MISSING_pkt1,!MISSING_pkt2); |
|
|
ncalib++; |
|
|
if( MISSING_pkt1||MISSING_pkt2||!valid )try_to_recover=true; |
|
|
} |
|
|
|
|
| 4973 |
}; //end loop on pkt1 |
}; //end loop on pkt1 |
| 4974 |
|
|
| 4975 |
|
|
| 5194 |
// ------------------------------------------------------ |
// ------------------------------------------------------ |
| 5195 |
// ... retrieve the calibration packets. |
// ... retrieve the calibration packets. |
| 5196 |
// ------------------------------------------------------ |
// ------------------------------------------------------ |
| 5197 |
TFile *file = new TFile((TString)gSystem->ExpandPathName(path)+"/"+name); // EM, path could be symbolic and we must expand it |
if ( IsDebug() ) printf(" file is %s/%s \n",((TString)gSystem->ExpandPathName(path.Data())).Data(),name.Data()); |
| 5198 |
|
TFile *file = new TFile(((TString)gSystem->ExpandPathName(path.Data()))+"/"+name); // EM, path could be symbolic and we must expand it |
| 5199 |
if(!file)throw -100; |
if(!file)throw -100; |
| 5200 |
if(file->IsZombie())throw -100; |
if(file->IsZombie())throw -100; |
| 5201 |
// |
// |
| 6119 |
// 2) get the OBT of the last validated run |
// 2) get the OBT of the last validated run |
| 6120 |
// -------------------------------------------------------------- |
// -------------------------------------------------------------- |
| 6121 |
oss.str(""); |
oss.str(""); |
| 6122 |
oss << " SELECT * FROM GL_RUN WHERE VALIDATION=1 AND RUNHEADER_TIME<="<< t_start |
// oss << " SELECT * FROM GL_RUN WHERE VALIDATION=1 AND RUNHEADER_TIME<="<< t_start |
| 6123 |
|
oss << " SELECT * FROM GL_RUN WHERE VALIDATION>0 AND RUNHEADER_TIME<="<< t_start |
| 6124 |
<<" ORDER BY RUNHEADER_TIME DESC LIMIT 1;"; |
<<" ORDER BY RUNHEADER_TIME DESC LIMIT 1;"; |
| 6125 |
if ( IsDebug() ) printf(" Get stop validation-time: query is \n %s \n",oss.str().c_str()); |
if ( IsDebug() ) printf(" Get stop validation-time: query is \n %s \n",oss.str().c_str()); |
| 6126 |
result = conn->Query(oss.str().c_str()); |
result = conn->Query(oss.str().c_str()); |
| 6263 |
if( interval >= calibtime )CHECK = true; //more than calibtime s => there might be a calibration |
if( interval >= calibtime )CHECK = true; //more than calibtime s => there might be a calibration |
| 6264 |
|
|
| 6265 |
if( !CHECK && this_run->VALIDATION ){ |
if( !CHECK && this_run->VALIDATION ){ |
| 6266 |
for (Int_t irun = 0; irun < nseq; irun++)assignVALIDATION(sequence[irun],true); |
// for (Int_t irun = 0; irun < nseq; irun++)assignVALIDATION(sequence[irun],true); |
| 6267 |
|
for (Int_t irun = 0; irun < nseq; irun++)assignVALIDATION(sequence[irun],this_run->VALIDATION); |
| 6268 |
nseq=0; |
nseq=0; |
| 6269 |
} |
} |
| 6270 |
|
|
| 6285 |
if( CHECK ){ |
if( CHECK ){ |
| 6286 |
// check if calibration exists |
// check if calibration exists |
| 6287 |
if ( IsDebug() )printf("DT %i ===> CHECK Missing calibration\n",interval); |
if ( IsDebug() )printf("DT %i ===> CHECK Missing calibration\n",interval); |
| 6288 |
Bool_t MISSING = MissingTRK_CALIB(t1,t2); |
// Bool_t MISSING = MissingTRK_CALIB(t1,t2); |
| 6289 |
for (Int_t irun = 0; irun < nseq; irun++)assignVALIDATION(sequence[irun],!MISSING); |
UInt_t MISSING = MissingTRK_CALIB(t1,t2); |
| 6290 |
|
UInt_t val = 0; |
| 6291 |
|
if ( MISSING == 1 ) val = 0; |
| 6292 |
|
if ( MISSING == 0 ) val = 1; |
| 6293 |
|
if ( MISSING == 2 ) val = 2; |
| 6294 |
|
for (Int_t irun = 0; irun < nseq; irun++)assignVALIDATION(sequence[irun],val); |
| 6295 |
nseq=0; |
nseq=0; |
| 6296 |
}; |
}; |
| 6297 |
//-------------- |
//-------------- |
| 6321 |
* @param t2 To absolute time |
* @param t2 To absolute time |
| 6322 |
* @return true if there might be a missing calibration |
* @return true if there might be a missing calibration |
| 6323 |
*/ |
*/ |
| 6324 |
Bool_t PamelaDBOperations::MissingTRK_CALIB(UInt_t t1,UInt_t t2){ |
//Bool_t PamelaDBOperations::MissingTRK_CALIB(UInt_t t1,UInt_t t2){ |
| 6325 |
|
UInt_t PamelaDBOperations::MissingTRK_CALIB(UInt_t t1,UInt_t t2){ |
| 6326 |
|
|
| 6327 |
GL_TRK_CALIB* trkcalib = new GL_TRK_CALIB(); |
GL_TRK_CALIB* trkcalib = new GL_TRK_CALIB(); |
| 6328 |
|
|
| 6329 |
// get the closest calibration before the run start (t2) |
// get the closest calibration before the run start (t2) |
| 6330 |
if ( trkcalib->Query_GL_TRK_CALIB(t2, conn) )return(true); //>>> missing |
// if ( trkcalib->Query_GL_TRK_CALIB(t2, conn) )return(true); //>>> missing |
| 6331 |
|
if ( trkcalib->Query_GL_TRK_CALIB(t2, conn) )return(1); //>>> missing |
| 6332 |
|
|
| 6333 |
if ( trkcalib->TO_TIME < t2 ) return(true); //>>> missing |
// if ( trkcalib->TO_TIME < t2 ) return(true); //>>> missing |
| 6334 |
|
if ( trkcalib->TO_TIME < t2 ) return(1); //>>> missing |
| 6335 |
|
|
| 6336 |
//============================================================== |
//============================================================== |
| 6337 |
// Check is done first on the basis of time between calibration, |
// Check is done first on the basis of time between calibration, |
| 6348 |
//============================================================== |
//============================================================== |
| 6349 |
Bool_t DOWNLOAD = false; |
Bool_t DOWNLOAD = false; |
| 6350 |
// check if the calib was skipped becouse of download .... DA FARE!! |
// check if the calib was skipped becouse of download .... DA FARE!! |
| 6351 |
if(DOWNLOAD)return(false); |
// if(DOWNLOAD)return(false); |
| 6352 |
|
if(DOWNLOAD)return(0); |
| 6353 |
|
|
| 6354 |
return(true); //>>> missing |
// return(true); //>>> missing |
| 6355 |
|
return(1); //>>> missing |
| 6356 |
|
|
| 6357 |
}; |
}; |
| 6358 |
|
|
| 6362 |
//============================================================== |
//============================================================== |
| 6363 |
// the long time interval bewteen runs might be due to download |
// the long time interval bewteen runs might be due to download |
| 6364 |
if ( IsDebug() )printf("Short time between calib and run start %u :-) ==> OK! \n",t2 - trkcalib->FROM_TIME); |
if ( IsDebug() )printf("Short time between calib and run start %u :-) ==> OK! \n",t2 - trkcalib->FROM_TIME); |
| 6365 |
return(false); |
if ( trkcalib->VALIDATION ) return(0); |
| 6366 |
|
if ( IsDebug() )printf("Calibration is not validated... :-/ ==> OK but with VALIDATION=2! \n"); |
| 6367 |
|
return(2); |
| 6368 |
|
|
| 6369 |
}; |
}; |
| 6370 |
/** |
/** |
| 6373 |
* @param validation true/false |
* @param validation true/false |
| 6374 |
*/ |
*/ |
| 6375 |
Int_t PamelaDBOperations::assignVALIDATION(UInt_t idrun, Bool_t validation){ |
Int_t PamelaDBOperations::assignVALIDATION(UInt_t idrun, Bool_t validation){ |
| 6376 |
|
return(this->assignVALIDATION(idrun,(UInt_t)validation)); |
| 6377 |
|
} |
| 6378 |
|
|
| 6379 |
|
Int_t PamelaDBOperations::assignVALIDATION(UInt_t idrun, UInt_t validation){ |
| 6380 |
TSQLResult *result = 0; |
TSQLResult *result = 0; |
| 6381 |
stringstream oss; |
stringstream oss; |
| 6382 |
oss.str(""); |
oss.str(""); |
| 6573 |
stringstream myquery; |
stringstream myquery; |
| 6574 |
// |
// |
| 6575 |
myquery.str(""); |
myquery.str(""); |
| 6576 |
myquery << " SELECT ID, ID_RAW FROM GL_ROOT where NAME='"<<remfile.Data() <<"';"; |
myquery << " SELECT ID,ID_RAW,ID_TIMESYNC FROM GL_ROOT where NAME='"<<remfile.Data() <<"';"; |
| 6577 |
// |
// |
| 6578 |
pResult = conn->Query(myquery.str().c_str()); |
pResult = conn->Query(myquery.str().c_str()); |
| 6579 |
// |
// |
| 6589 |
// |
// |
| 6590 |
this->SetID_ROOT((UInt_t)atoll(Row->GetField(0))); |
this->SetID_ROOT((UInt_t)atoll(Row->GetField(0))); |
| 6591 |
this->SetID_RAW((UInt_t)atoll(Row->GetField(1))); |
this->SetID_RAW((UInt_t)atoll(Row->GetField(1))); |
| 6592 |
|
UInt_t idtsy=(UInt_t)atoll(Row->GetField(2)); |
| 6593 |
// |
// |
| 6594 |
this->ValidationOFF(); |
this->ValidationOFF(); |
| 6595 |
// |
// |
| 6597 |
// |
// |
| 6598 |
this->RemoveRUNS(); |
this->RemoveRUNS(); |
| 6599 |
// |
// |
| 6600 |
this->RemoveFILES(); |
this->RemoveFILES(idtsy); |
| 6601 |
// |
// |
| 6602 |
this->SetID_ROOT(0); |
this->SetID_ROOT(0); |
| 6603 |
this->SetID_RAW(0); |
this->SetID_RAW(0); |
| 6817 |
* Rearrange calibration tables |
* Rearrange calibration tables |
| 6818 |
* |
* |
| 6819 |
**/ |
**/ |
| 6820 |
void PamelaDBOperations::RemoveFILES(){ |
void PamelaDBOperations::RemoveFILES(UInt_t idtsy){ |
| 6821 |
stringstream myquery; |
stringstream myquery; |
| 6822 |
// |
// |
| 6823 |
myquery.str(""); |
myquery.str(""); |
| 6827 |
// |
// |
| 6828 |
conn->Query(myquery.str().c_str()); |
conn->Query(myquery.str().c_str()); |
| 6829 |
// |
// |
| 6830 |
|
myquery.str(""); |
| 6831 |
|
myquery << " DELETE FROM GL_ROOT WHERE ID=" <<this->GetID_ROOT() <<";"; |
| 6832 |
|
// |
| 6833 |
|
if ( IsDebug() ) printf(" query is \n %s \n",myquery.str().c_str()); |
| 6834 |
|
// |
| 6835 |
|
conn->Query(myquery.str().c_str()); // |
| 6836 |
|
// |
| 6837 |
|
if ( !chewbacca ){ |
| 6838 |
|
myquery.str(""); |
| 6839 |
|
myquery << " DELETE FROM GL_TIMESYNC WHERE ID=" << idtsy <<";"; |
| 6840 |
|
// |
| 6841 |
|
if ( IsDebug() ) printf(" query is \n %s \n",myquery.str().c_str()); |
| 6842 |
|
// |
| 6843 |
|
conn->Query(myquery.str().c_str()); |
| 6844 |
|
}; |
| 6845 |
|
// |
| 6846 |
}; |
}; |
| 6847 |
|
|
| 6848 |
/** |
/** |