| 58 |
* @param debug debug flag. |
* @param debug debug flag. |
| 59 |
* @param tlefilename ascii file with TLE 3 line elements. |
* @param tlefilename ascii file with TLE 3 line elements. |
| 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){ |
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 |
chewbacca = false; |
chewbacca = false; |
| 64 |
chminentry = 0; |
chminentry = 0; |
| 76 |
// |
// |
| 77 |
}; |
}; |
| 78 |
// |
// |
| 79 |
|
KEEPENV = false; |
| 80 |
|
if ( keepenv ) KEEPENV=true; |
| 81 |
STATIC=false; |
STATIC=false; |
| 82 |
if ( staticp ) STATIC=true; |
if ( staticp ) STATIC=true; |
| 83 |
// |
// |
| 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); |
| 141 |
TString chfile; |
TString chfile; |
| 142 |
UInt_t ridn = 0; |
UInt_t ridn = 0; |
| 143 |
qu.str(""); |
qu.str(""); |
| 144 |
qu << "SELECT ROOT_ID_N,PKT_NUMBER_INIT,PKT_NUMBER_FINAL,PKT_OBT_INIT,PKT_OBT_FINAL 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 from ROOT_TABLE_MERGING where ID_N=" << chID << ";"; |
| 145 |
if ( debug ) printf(" chewbacca: query is %s \n",qu.str().c_str()); |
if ( debug ) printf(" chewbacca: query is %s \n",qu.str().c_str()); |
| 146 |
result = conn->Query(qu.str().c_str()); |
result = conn->Query(qu.str().c_str()); |
| 147 |
if ( result ){ |
if ( result ){ |
| 152 |
chpktmax = (UInt_t)atoll(row->GetField(2)); |
chpktmax = (UInt_t)atoll(row->GetField(2)); |
| 153 |
chobtmin = (UInt_t)atoll(row->GetField(3)); |
chobtmin = (UInt_t)atoll(row->GetField(3)); |
| 154 |
chobtmax = (UInt_t)atoll(row->GetField(4)); |
chobtmax = (UInt_t)atoll(row->GetField(4)); |
| 155 |
|
chiby = (TString)(row->GetField(5)); |
| 156 |
} else { |
} else { |
| 157 |
throw -84; |
throw -84; |
| 158 |
}; |
}; |
| 167 |
if ( result2 ){ |
if ( result2 ){ |
| 168 |
row2 = result2->Next(); |
row2 = result2->Next(); |
| 169 |
if ( row2 ){ |
if ( row2 ){ |
| 170 |
chpath = (TString)gSystem->ExpandPathName(row2->GetField(0))+'/'; |
if ( KEEPENV ){ |
| 171 |
|
chpath = (TString)(row2->GetField(0))+'/'; |
| 172 |
|
} else { |
| 173 |
|
chpath = (TString)gSystem->ExpandPathName(row2->GetField(0))+'/'; |
| 174 |
|
}; |
| 175 |
chfile = (TString)(row2->GetField(1)); |
chfile = (TString)(row2->GetField(1)); |
| 176 |
chobtts = (UInt_t)atoll(row2->GetField(2)); |
chobtts = (UInt_t)atoll(row2->GetField(2)); |
| 177 |
chlastts = (UInt_t)atoll(row2->GetField(3)); |
chlastts = (UInt_t)atoll(row2->GetField(3)); |
| 190 |
throw -85; |
throw -85; |
| 191 |
}; |
}; |
| 192 |
filerootname = chpath + chfile;// + ".root"; |
filerootname = chpath + chfile;// + ".root"; |
|
if ( debug ) printf(" chewbacca: filename is %s \n",filerootname.Data()); |
|
| 193 |
}; |
}; |
| 194 |
this->SetRootName(filerootname); |
this->SetRootName(filerootname); |
|
file = TFile::Open(this->GetRootName().Data()); |
|
|
} else { |
|
|
this->SetRootName(""); |
|
| 195 |
}; |
}; |
| 196 |
|
if ( debug ) printf(" Filename is %s \n",filerootname.Data()); |
| 197 |
|
file = TFile::Open(this->GetRootName().Data()); |
| 198 |
|
// } else { |
| 199 |
|
// this->SetRootName(""); |
| 200 |
|
// this->SetRootName(filerootname); |
| 201 |
|
// }; |
| 202 |
} |
} |
| 203 |
|
|
| 204 |
// |
// |
| 398 |
return; |
return; |
| 399 |
}; |
}; |
| 400 |
// |
// |
| 401 |
TString name = this->GetRootFile(); |
if ( !chewbacca ){ |
| 402 |
Int_t nlength = name.Length(); |
TString name = this->GetRootFile(); |
| 403 |
if ( nlength < 5 ) return; |
Int_t nlength = name.Length(); |
| 404 |
TString dwo = 0; |
if ( nlength < 5 ){ |
| 405 |
for (Int_t i = 0; i<5; i++){ |
if ( IsDebug() ) printf(" Agh problems determining the orbit number! name = %s \n",name.Data()); |
| 406 |
dwo.Append(name[i],1); |
return; |
| 407 |
}; |
}; |
| 408 |
if ( dwo.IsDigit() ){ |
TString dwo = 0; |
| 409 |
dworbit = (UInt_t)dwo.Atoi(); |
for (Int_t i = 0; i<5; i++){ |
|
} else { |
|
|
dwo=""; |
|
|
for (Int_t i = 8; i<13; i++){ |
|
| 410 |
dwo.Append(name[i],1); |
dwo.Append(name[i],1); |
| 411 |
}; |
}; |
| 412 |
if ( dwo.IsDigit() ) dworbit = (UInt_t)dwo.Atoi(); |
if ( dwo.IsDigit() ){ |
| 413 |
|
dworbit = (UInt_t)dwo.Atoi(); |
| 414 |
|
} else { |
| 415 |
|
dwo=""; |
| 416 |
|
for (Int_t i = 8; i<13; i++){ |
| 417 |
|
dwo.Append(name[i],1); |
| 418 |
|
}; |
| 419 |
|
if ( dwo.IsDigit() ) dworbit = (UInt_t)dwo.Atoi(); |
| 420 |
|
}; |
| 421 |
|
if ( IsDebug() ) printf(" Downlink orbit is %i (dwo = %s) \n",dworbit,dwo.Data()); |
| 422 |
}; |
}; |
|
if ( IsDebug() ) printf(" Downlink orbit is %i (dwo = %s) \n",dworbit,dwo.Data()); |
|
| 423 |
return; |
return; |
| 424 |
}; |
}; |
| 425 |
|
|
| 450 |
|
|
| 451 |
TString PamelaDBOperations::GetRootPath(){ |
TString PamelaDBOperations::GetRootPath(){ |
| 452 |
if ( STATIC ){ |
if ( STATIC ){ |
| 453 |
return((TString)gSystem->DirName(filerootname.Data())+'/'); |
return((TString)gSystem->DirName(this->GetRootName().Data())+'/'); |
| 454 |
} else { |
} else { |
| 455 |
return((TString)gSystem->ExpandPathName("$PAM_L0")+'/'); |
if ( KEEPENV ){ |
| 456 |
|
return((TString)gSystem->ExpandPathName(gSystem->DirName(filerootname.Data()))+'/'); |
| 457 |
|
} else { |
| 458 |
|
return((TString)gSystem->ExpandPathName("$PAM_L0")+'/'); |
| 459 |
|
}; |
| 460 |
}; |
}; |
| 461 |
}; |
}; |
| 462 |
|
|
| 668 |
UInt_t tjump = 50000; |
UInt_t tjump = 50000; |
| 669 |
//UInt_t tjump = 100; |
//UInt_t tjump = 100; |
| 670 |
while ( tjump > 0 ){ |
while ( tjump > 0 ){ |
| 671 |
pktlast = numeric_limits<UInt_t>::max(); |
// pktlast = numeric_limits<UInt_t>::max(); |
| 672 |
while ( pktlast > chpktmax && (Int_t)(nevent-1-it) >= 0 ){ |
pktlast = chpktmax + 1; |
| 673 |
|
while ( PKT(pktlast) > PKT(chpktmax) && (Int_t)(nevent-1-it) >= 0 ){ |
| 674 |
if ( (Int_t)(nevent-1-it) >= 0 ){ |
if ( (Int_t)(nevent-1-it) >= 0 ){ |
| 675 |
T->GetEntry(nevent-1-it); |
T->GetEntry(nevent-1-it); |
| 676 |
ph = eh->GetPscuHeader(); |
ph = eh->GetPscuHeader(); |
| 678 |
} else { |
} else { |
| 679 |
pktlast = chpktmax + 1; |
pktlast = chpktmax + 1; |
| 680 |
}; |
}; |
| 681 |
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)); |
| 682 |
it += tjump; |
it += tjump; |
| 683 |
}; |
}; |
| 684 |
if ( tjump > 1 ) it -= 2*tjump; |
if ( tjump > 1 ) it -= 2*tjump; |
| 702 |
tjump = 50000; |
tjump = 50000; |
| 703 |
//tjump = 100; |
//tjump = 100; |
| 704 |
while ( tjump > 0 ){ |
while ( tjump > 0 ){ |
| 705 |
pktlast = 0; |
// pktlast = 0; |
| 706 |
while ( pktlast < chpktmin && it < (Int_t)nevent ){ |
pktlast = chpktmin - 1; |
| 707 |
|
if ( debug ) printf("LLlook for down %i %i %llu %llu \n",it,pktlast,PKT(pktlast),PKT(chpktmin)); |
| 708 |
|
while ( PKT(pktlast) < PKT(chpktmin) && it < (Int_t)nevent ){ |
| 709 |
if ( it < (Int_t)nevent ){ |
if ( it < (Int_t)nevent ){ |
| 710 |
T->GetEntry(it); |
T->GetEntry(it); |
| 711 |
ph = eh->GetPscuHeader(); |
ph = eh->GetPscuHeader(); |
| 1147 |
stringstream oss; |
stringstream oss; |
| 1148 |
// |
// |
| 1149 |
oss.str(""); |
oss.str(""); |
| 1150 |
oss << "INSERT INTO _RUNID_GEN VALUES (NULL);"; |
if ( chewbacca ){// if chewbacca and tag=none then use chewbacca tag (chiby = chewbacca inserted by), if chewbacca and tag!=none then use tag, if not chewbacca use tag. |
| 1151 |
|
if ( !strcmp(tag.Data(),"NONE") ){ |
| 1152 |
|
oss << "INSERT INTO _RUNID_GEN VALUES (NULL,'"<< chiby.Data() <<"');"; |
| 1153 |
|
} else { |
| 1154 |
|
oss << "INSERT INTO _RUNID_GEN VALUES (NULL,'"<< tag.Data() <<"');"; |
| 1155 |
|
}; |
| 1156 |
|
} else { |
| 1157 |
|
oss << "INSERT INTO _RUNID_GEN VALUES (NULL,'"<< tag.Data() <<"');"; |
| 1158 |
|
}; |
| 1159 |
result = conn->Query(oss.str().c_str()); |
result = conn->Query(oss.str().c_str()); |
| 1160 |
if ( !result ) throw -10; |
if ( !result ) throw -10; |
| 1161 |
oss.str(""); |
oss.str(""); |
| 1360 |
// |
// |
| 1361 |
// 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)); |
| 1362 |
// |
// |
| 1363 |
if ( obt < (pobtfirst/2) && pobtfirst > (numeric_limits<UInt_t>::max()/2) ){ |
if ( obt < ((Long64_t)pobtfirst/2) && pobtfirst > (numeric_limits<UInt_t>::max()/2) ){ |
| 1364 |
// 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()); |
| 1365 |
return((Long64_t)obt+(Long64_t)numeric_limits<UInt_t>::max()); |
return((Long64_t)obt+(Long64_t)numeric_limits<UInt_t>::max()); |
| 1366 |
}; |
}; |
| 1494 |
// PUBLIC FUNCTIONS |
// PUBLIC FUNCTIONS |
| 1495 |
// |
// |
| 1496 |
|
|
|
// /** |
|
|
// * Insert a new row into GL_RAW table. |
|
|
// */ |
|
|
// Int_t PamelaDBOperations::insertPamelaRawFile(){ |
|
|
// // |
|
|
// stringstream oss; |
|
|
// // |
|
|
// Bool_t idr = this->SetID_RAW(); |
|
|
// if ( idr ) return(1); |
|
|
// // |
|
|
// oss.str(""); |
|
|
// if ( STATIC ){ |
|
|
// oss << "INSERT INTO GL_RAW (PATH, NAME) VALUES ('" |
|
|
// << this->GetRawPath().Data() << "', '" << this->GetRawFile().Data() << "')"; |
|
|
// } else { |
|
|
// oss << "INSERT INTO GL_RAW (PATH, NAME) VALUES ('$PAM_RAW', '" << this->GetRawFile().Data() << "')"; |
|
|
// }; |
|
|
// if ( conn->Query(oss.str().c_str()) == 0 ) throw -4; |
|
|
// // |
|
|
// idr = this->SetID_RAW(); |
|
|
// if ( !idr ) throw -11; |
|
|
// // |
|
|
// return(0); |
|
|
// } |
|
| 1497 |
/** |
/** |
| 1498 |
* Insert a new row into GL_RAW table. |
* Insert a new row into GL_RAW table. |
| 1499 |
*/ |
*/ |
| 1507 |
|
|
| 1508 |
glraw.PATH = GetRawPath(); |
glraw.PATH = GetRawPath(); |
| 1509 |
glraw.NAME = GetRawFile(); |
glraw.NAME = GetRawFile(); |
| 1510 |
glraw.BOOT_NUMBER = 0;//??? |
// glraw.BOOT_NUMBER = 0;//??? |
| 1511 |
|
glraw.BOOT_NUMBER = this->GetBOOTnumber(); |
| 1512 |
|
|
| 1513 |
if( insertPamelaRawFile(&glraw) )return(1); |
if( insertPamelaRawFile(&glraw) )return(1); |
| 1514 |
// |
// |
| 1522 |
*/ |
*/ |
| 1523 |
Int_t PamelaDBOperations::insertPamelaRawFile(GL_RAW *glraw){ |
Int_t PamelaDBOperations::insertPamelaRawFile(GL_RAW *glraw){ |
| 1524 |
// |
// |
| 1525 |
if(!glraw)return(1);//?? |
if(!glraw)return(1);//?? ok I think |
| 1526 |
// |
// |
| 1527 |
stringstream oss; |
stringstream oss; |
| 1528 |
// |
// |
| 1585 |
result = conn->Query(oss.str().c_str()); |
result = conn->Query(oss.str().c_str()); |
| 1586 |
if ( !result ) throw -10; |
if ( !result ) throw -10; |
| 1587 |
row = result->Next(); |
row = result->Next(); |
| 1588 |
|
if ( !row ) throw -92; |
| 1589 |
idresof = (UInt_t)atoll(row->GetField(0)); |
idresof = (UInt_t)atoll(row->GetField(0)); |
| 1590 |
existsts = true; |
existsts = true; |
| 1591 |
goto eout; |
goto eout; |
| 1860 |
return(signal); |
return(signal); |
| 1861 |
} |
} |
| 1862 |
|
|
|
// /** |
|
|
// * Insert all the new rows into GL_ROOT. |
|
|
// * The raw file indicates in the parameters should be already been stored in the database. |
|
|
// */ |
|
|
// Int_t PamelaDBOperations::insertPamelaRootFile(){ |
|
|
// stringstream oss; |
|
|
// TSQLResult *result = 0; |
|
|
// TSQLRow *row = 0; |
|
|
// UInt_t idtimesync = 0; |
|
|
// // |
|
|
// // |
|
|
// if ( chewbacca ){ |
|
|
// oss.str(""); |
|
|
// oss << " SELECT ID FROM GL_TIMESYNC where TIMESYNC="<<chlastts<<" AND OBT0="<<chobtts*1000<<" limit 1;"; |
|
|
// if ( debug ) printf(" query is %s \n",oss.str().c_str()); |
|
|
// result = conn->Query(oss.str().c_str()); |
|
|
// // |
|
|
// if ( !result ) throw -3; |
|
|
// // |
|
|
// row = result->Next(); |
|
|
// // |
|
|
// if ( !row ) throw -3; |
|
|
// idtimesync = (UInt_t)atoll(row->GetField(0)); |
|
|
// } else { |
|
|
// oss.str(""); |
|
|
// if ( STATIC ){ |
|
|
// oss << " SELECT COUNT(GL_ROOT.ID_RAW),GL_RAW.ID,GL_ROOT.ID FROM GL_RAW " |
|
|
// << " LEFT JOIN GL_ROOT " |
|
|
// << " ON GL_RAW.ID = GL_ROOT.ID_RAW " |
|
|
// << " WHERE GL_RAW.PATH = '" << this->GetRawPath().Data() << "' AND " |
|
|
// << " GL_RAW.NAME = '" << this->GetRawFile().Data() << "' GROUP BY GL_RAW.ID "; |
|
|
// } else { |
|
|
// oss << " SELECT COUNT(GL_ROOT.ID_RAW),GL_RAW.ID,GL_ROOT.ID FROM GL_RAW " |
|
|
// << " LEFT JOIN GL_ROOT " |
|
|
// << " ON GL_RAW.ID = GL_ROOT.ID_RAW " |
|
|
// << " WHERE GL_RAW.PATH = '$PAM_RAW' AND " |
|
|
// << " GL_RAW.NAME = '" << this->GetRawFile().Data() << "' GROUP BY GL_RAW.ID "; |
|
|
// }; |
|
|
// result = conn->Query(oss.str().c_str()); |
|
|
// // |
|
|
// if ( !result ) throw -12; |
|
|
// // |
|
|
// row = result->Next(); |
|
|
// // |
|
|
// if ( !row ) throw -10; |
|
|
// if ( row != NULL && (UInt_t)atoll(row->GetField(0))>0 ){ |
|
|
// idroot = (UInt_t)atoll(row->GetField(2)); |
|
|
// return(1); |
|
|
// }; |
|
|
// // |
|
|
// // determine which timesync has to be used |
|
|
// // |
|
|
// oss.str(""); |
|
|
// oss << "SELECT GL_TIMESYNC.ID FROM GL_TIMESYNC LEFT JOIN GL_RAW ON GL_RAW.ID = GL_TIMESYNC.ID_RAW ORDER BY GL_TIMESYNC.ID DESC LIMIT 1;"; |
|
|
// result = conn->Query(oss.str().c_str()); |
|
|
// // |
|
|
// if ( !result ) throw -3; |
|
|
// // |
|
|
// row = result->Next(); |
|
|
// // |
|
|
// if ( !row ) throw -3; |
|
|
// idtimesync = (UInt_t)atoll(row->GetField(0)); |
|
|
// }; |
|
|
// // |
|
|
// oss.str(""); |
|
|
// if ( STATIC ){ |
|
|
// oss << "INSERT INTO GL_ROOT (ID_RAW, ID_TIMESYNC,PATH, NAME) VALUES ('" |
|
|
// << this->GetID_RAW() << "', '" << idtimesync << "', '" << this->GetRootPath().Data() << "', '" << this->GetRootFile().Data() << "')"; |
|
|
// } else { |
|
|
// oss << "INSERT INTO GL_ROOT (ID_RAW, ID_TIMESYNC,PATH, NAME) VALUES ('" |
|
|
// << this->GetID_RAW() << "', '" << idtimesync << "', '$PAM_L0', '" << this->GetRootFile().Data() << "')"; |
|
|
// }; |
|
|
// // |
|
|
// if ( debug ) printf(" query is %s \n",oss.str().c_str()); |
|
|
// if (conn->Query(oss.str().c_str()) == 0) throw -4; |
|
|
// // |
|
|
// delete result; |
|
|
// // |
|
|
// oss.str(""); |
|
|
// // oss << "SELECT ID FROM GL_ROOT WHERE ID_RAW=" << this->GetID_RAW() << ";"; |
|
|
// if ( STATIC ){ |
|
|
// oss << "SELECT ID FROM GL_ROOT WHERE PATH='" << this->GetRootPath().Data() << "' and NAME='"<< this->GetRootFile().Data() <<"';"; |
|
|
// } else { |
|
|
// oss << "SELECT ID FROM GL_ROOT WHERE PATH='$PAM_L0' and NAME='"<< this->GetRootFile().Data() <<"';"; |
|
|
// }; |
|
|
// // |
|
|
// if ( debug ) printf(" query is %s \n",oss.str().c_str()); |
|
|
// result = conn->Query(oss.str().c_str()); |
|
|
// if ( !result ) throw -12; |
|
|
// row = result->Next(); |
|
|
// if ( !row ) throw -3; |
|
|
// this->SetID_ROOT((UInt_t)atoll(row->GetField(0))); |
|
|
// if ( debug ) printf(" The ID of the ROOT file is %u \n",this->GetID_ROOT()); |
|
|
// // |
|
|
// delete result; |
|
|
// // |
|
|
// return(0); |
|
|
// } |
|
| 1863 |
/** |
/** |
| 1864 |
* Insert all the new rows into GL_ROOT. |
* Insert all the new rows into GL_ROOT. |
| 1865 |
* The raw file indicates in the parameters should be already been stored in the database. |
* The raw file indicates in the parameters should be already been stored in the database. |
| 1869 |
stringstream oss; |
stringstream oss; |
| 1870 |
TSQLResult *result = 0; |
TSQLResult *result = 0; |
| 1871 |
TSQLRow *row = 0; |
TSQLRow *row = 0; |
| 1872 |
// |
// |
| 1873 |
// ---------------------- |
// ---------------------- |
| 1874 |
// determine the timesync |
// determine the timesync |
| 1875 |
// ---------------------- |
// ---------------------- |
| 1941 |
|
|
| 1942 |
glroot.ID_RAW = GetID_RAW(); |
glroot.ID_RAW = GetID_RAW(); |
| 1943 |
glroot.ID_TIMESYNC = idtimesync; |
glroot.ID_TIMESYNC = idtimesync; |
| 1944 |
glroot.PATH = GetRootPath(); |
if ( STATIC ){ |
| 1945 |
|
glroot.PATH = GetRootPath(); |
| 1946 |
|
} else { |
| 1947 |
|
if ( KEEPENV ){ |
| 1948 |
|
glroot.PATH = gSystem->DirName(filerootname.Data()); |
| 1949 |
|
} else { |
| 1950 |
|
glroot.PATH = "$PAM_L0"; |
| 1951 |
|
}; |
| 1952 |
|
}; |
| 1953 |
glroot.NAME = GetRootFile(); |
glroot.NAME = GetRootFile(); |
| 1954 |
|
|
| 1955 |
if ( insertPamelaRootFile(&glroot) )return 1; |
if ( insertPamelaRootFile(&glroot) )return 1; |
| 1964 |
* The raw file indicates in the parameters should be already been stored in the database. |
* The raw file indicates in the parameters should be already been stored in the database. |
| 1965 |
*/ |
*/ |
| 1966 |
Int_t PamelaDBOperations::insertPamelaRootFile(GL_ROOT *glroot){ |
Int_t PamelaDBOperations::insertPamelaRootFile(GL_ROOT *glroot){ |
|
|
|
|
|
|
|
|
|
| 1967 |
stringstream oss; |
stringstream oss; |
| 1968 |
TSQLResult *result = 0; |
TSQLResult *result = 0; |
| 1969 |
TSQLRow *row = 0; |
TSQLRow *row = 0; |
| 1970 |
// |
// |
| 1971 |
// |
// |
| 1972 |
oss.str(""); |
oss.str(""); |
| 1973 |
if ( STATIC ){ |
oss << "INSERT INTO GL_ROOT (ID_RAW, ID_TIMESYNC,PATH, NAME) VALUES ('" |
| 1974 |
oss << "INSERT INTO GL_ROOT (ID_RAW, ID_TIMESYNC,PATH, NAME) VALUES ('" |
<< glroot->ID_RAW << "', '" << glroot->ID_TIMESYNC << "', '" << glroot->PATH << "', '" << glroot->NAME << "')"; |
|
<< glroot->ID_RAW << "', '" << glroot->ID_TIMESYNC << "', '" << glroot->PATH << "', '" << glroot->NAME << "')"; |
|
|
} else { |
|
|
oss << "INSERT INTO GL_ROOT (ID_RAW, ID_TIMESYNC,PATH, NAME) VALUES ('" |
|
|
<< glroot->ID_RAW << "', '" << glroot->ID_TIMESYNC << "', '$PAM_L0', '" << glroot->NAME << "')"; |
|
|
}; |
|
| 1975 |
// |
// |
| 1976 |
if ( debug ) printf("%s \n",oss.str().c_str()); |
if ( debug ) printf("%s \n",oss.str().c_str()); |
| 1977 |
if (conn->Query(oss.str().c_str()) == 0) throw -4; |
if (conn->Query(oss.str().c_str()) == 0) throw -4; |
| 1980 |
// |
// |
| 1981 |
oss.str(""); |
oss.str(""); |
| 1982 |
// oss << "SELECT ID FROM GL_ROOT WHERE ID_RAW=" << this->GetID_RAW() << ";"; |
// oss << "SELECT ID FROM GL_ROOT WHERE ID_RAW=" << this->GetID_RAW() << ";"; |
| 1983 |
if ( STATIC ){ |
oss << "SELECT ID FROM GL_ROOT WHERE PATH='" << glroot->PATH << "' and NAME='"<< glroot->NAME <<"';"; |
|
oss << "SELECT ID FROM GL_ROOT WHERE PATH='" << glroot->PATH << "' and NAME='"<< glroot->NAME <<"';"; |
|
|
} else { |
|
|
oss << "SELECT ID FROM GL_ROOT WHERE PATH='$PAM_L0' and NAME='"<< glroot->NAME <<"';"; |
|
|
}; |
|
| 1984 |
// |
// |
| 1985 |
if ( debug ) printf("%s \n",oss.str().c_str()); |
if ( debug ) printf("%s \n",oss.str().c_str()); |
| 1986 |
result = conn->Query(oss.str().c_str()); |
result = conn->Query(oss.str().c_str()); |
| 2248 |
ptht = cod->Get(pctp->RunHeader) - 1; |
ptht = cod->Get(pctp->RunHeader) - 1; |
| 2249 |
// evbeft = cod->Get(pctp->Physics); |
// evbeft = cod->Get(pctp->Physics); |
| 2250 |
tcod = (UInt_t)cod->Get(pctp->Physics); |
tcod = (UInt_t)cod->Get(pctp->Physics); |
| 2251 |
if ( !tcod ) tcod = 1; |
if ( !tcod ) tcod = 1; // IS A BUG SINCE RUNS WITH ZERO EVENTS WILL LOOK LIKE RUNS WITH ONE EVENT |
| 2252 |
evbeft = TMath::Min(upperentry,(tcod-1)); |
evbeft = TMath::Min(upperentry,(tcod-1)); |
| 2253 |
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)); |
| 2254 |
// |
// |
| 2287 |
obth = phh->GetOrbitalTime(); |
obth = phh->GetOrbitalTime(); |
| 2288 |
cod = ehh->GetCounter(); |
cod = ehh->GetCounter(); |
| 2289 |
tcod = (UInt_t)cod->Get(pctp->Physics); |
tcod = (UInt_t)cod->Get(pctp->Physics); |
| 2290 |
if ( !tcod ) tcod = 1; |
if ( !tcod ) tcod = 1; // IS A BUG SINCE RUNS WITH ZERO EVENTS WILL LOOK LIKE RUNS WITH ONE EVENT |
| 2291 |
evbefh = TMath::Max(chminentry,(tcod-1)); |
evbefh = TMath::Max(chminentry,(tcod-1)); |
| 2292 |
// |
// |
| 2293 |
if ( PKT(pkth) >= PKT(pktfirst) && PKT(pkth) <= upperpkt ){ |
if ( PKT(pkth) >= PKT(pktfirst) && PKT(pkth) <= upperpkt ){ |
| 2326 |
// |
// |
| 2327 |
this->HandleRunFragments(true,true,chminentry,(evbefh)); |
this->HandleRunFragments(true,true,chminentry,(evbefh)); |
| 2328 |
// |
// |
| 2329 |
|
// what about pth=ptht-1 |
| 2330 |
}; |
}; |
| 2331 |
}; |
}; |
| 2332 |
// |
// |
| 2349 |
cod = ehh->GetCounter(); |
cod = ehh->GetCounter(); |
| 2350 |
// evbeft = cod->Get(pctp->Physics); |
// evbeft = cod->Get(pctp->Physics); |
| 2351 |
tcod = (UInt_t)cod->Get(pctp->Physics); |
tcod = (UInt_t)cod->Get(pctp->Physics); |
| 2352 |
if ( !tcod ) tcod = 1; |
if ( !tcod ) tcod = 1; // IS A BUG SINCE RUNS WITH ZERO EVENTS WILL LOOK LIKE RUNS WITH ONE EVENT |
| 2353 |
evbeft = TMath::Min(upperentry,(tcod-1)); |
evbeft = TMath::Min(upperentry,(tcod-1)); |
| 2354 |
rh->GetEntry(pth); |
rh->GetEntry(pth); |
| 2355 |
phh = ehh->GetPscuHeader(); |
phh = ehh->GetPscuHeader(); |
| 2389 |
// if ( ptt+1 == rtev){ |
// if ( ptt+1 == rtev){ |
| 2390 |
if ( conptt+1 == nrtev ){ |
if ( conptt+1 == nrtev ){ |
| 2391 |
// if ( conptt+1 == (nrtev+nrtbef )){ |
// if ( conptt+1 == (nrtev+nrtbef )){ |
| 2392 |
|
if ( IsDebug() ) printf(" >>>>>>>>>>> %i %u %i %u \n",ptht,rhev,nrtev,conptt); |
| 2393 |
ptht++; |
ptht++; |
| 2394 |
if ( ptht < rhev ){ |
if ( ptht < rhev ){ |
| 2395 |
rh->GetEntry(ptht); |
rh->GetEntry(ptht); |
| 2396 |
|
//pth++; |
| 2397 |
|
//if ( pth < rhev ){ |
| 2398 |
|
//rh->GetEntry(pth); |
| 2399 |
phh = ehh->GetPscuHeader(); |
phh = ehh->GetPscuHeader(); |
| 2400 |
pkth = phh->GetCounter(); |
pkth = phh->GetCounter(); |
| 2401 |
obth = phh->GetOrbitalTime(); |
obth = phh->GetOrbitalTime(); |
| 2419 |
if ( (UInt_t)evbeft < upperentry-1 && upperentry>0 ){ |
if ( (UInt_t)evbeft < upperentry-1 && upperentry>0 ){ |
| 2420 |
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); |
| 2421 |
// |
// |
| 2422 |
if ( (ptt-1) < 0 ) throw -15; // should never arrive here! |
// if ( (ptt-1) < 0 ) throw -15; // should never arrive here! |
| 2423 |
rt->GetEntry(ptt-1); |
if ( (rtev-1) < 0 || ptt < 0 ) throw -15; // should never arrive here! |
| 2424 |
|
// rt->GetEntry(ptt-1); |
| 2425 |
|
rt->GetEntry(rtev-1); |
| 2426 |
cod = eht->GetCounter(); |
cod = eht->GetCounter(); |
| 2427 |
tcod = (UInt_t)cod->Get(pctp->Physics); |
tcod = (UInt_t)cod->Get(pctp->Physics)+1; |
| 2428 |
evbefh = TMath::Max(chminentry,tcod); |
evbefh = TMath::Max(chminentry,tcod); |
| 2429 |
// evbefh = cod->Get(pctp->Physics); |
// evbefh = cod->Get(pctp->Physics); |
| 2430 |
rt->GetEntry(ptt); |
rt->GetEntry(ptt); |
| 2655 |
// |
// |
| 2656 |
// 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 |
| 2657 |
// |
// |
| 2658 |
if ( rhfirstev != firstev && !mishead ) mishead = true; |
if ( firstev != (lastev+1) ){ // could be a problem sometimes (?) |
| 2659 |
if ( rtlastev != lastev && !mistrail ) mistrail = true; |
if ( rhfirstev != firstev && !mishead ) mishead = true; |
| 2660 |
|
if ( rtlastev != lastev && !mistrail ) mistrail = true; |
| 2661 |
|
}; |
| 2662 |
// |
// |
| 2663 |
|
if ( IsDebug() ) printf(" bhere firstev is %i lastev is %i \n",firstev,lastev); |
| 2664 |
this->FillClass(mishead,mistrail,firstev,lastev); |
this->FillClass(mishead,mistrail,firstev,lastev); |
| 2665 |
|
if ( IsDebug() ) printf(" chere firstev is %i lastev is %i \n",firstev,lastev); |
| 2666 |
// |
// |
| 2667 |
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"); |
| 2668 |
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()); |
| 2757 |
// |
// |
| 2758 |
found = false; // default value |
found = false; // default value |
| 2759 |
// |
// |
| 2760 |
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"); |
| 2761 |
// |
// |
| 2762 |
// 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: |
| 2763 |
// |
// |
| 2773 |
if ( IsDebug() ) printf(" FOUND!!! check %llu pktt %llu \n",chkpkt,pktt); |
if ( IsDebug() ) printf(" FOUND!!! check %llu pktt %llu \n",chkpkt,pktt); |
| 2774 |
// |
// |
| 2775 |
found = true; |
found = true; |
| 2776 |
|
if ( IsDebug() ) printf(" where firstev is %i lastev is %i \n",firstev,lastev); |
| 2777 |
// |
// |
| 2778 |
} else { |
} else { |
| 2779 |
// |
// |
| 2839 |
oss << " ID="<<row->GetField(0)<<";"; |
oss << " ID="<<row->GetField(0)<<";"; |
| 2840 |
// |
// |
| 2841 |
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 |
| 2842 |
|
if ( IsDebug() ) printf(" there firstev is %i lastev is %i \n",firstev,lastev); |
| 2843 |
// |
// |
| 2844 |
// merge infos |
// merge infos |
| 2845 |
// |
// |
| 2870 |
glrun1->SetRUNTRAILER_OBT(glrun->GetRUNTRAILER_OBT()); |
glrun1->SetRUNTRAILER_OBT(glrun->GetRUNTRAILER_OBT()); |
| 2871 |
glrun1->SetRUNTRAILER_PKT(glrun->GetRUNTRAILER_PKT()); |
glrun1->SetRUNTRAILER_PKT(glrun->GetRUNTRAILER_PKT()); |
| 2872 |
// |
// |
| 2873 |
|
if ( IsDebug() ) printf(" here firstev is %i lastev is %i \n",firstev,lastev); |
| 2874 |
|
// |
| 2875 |
glrun->SetEV_FROM(firstev); |
glrun->SetEV_FROM(firstev); |
| 2876 |
glrun->SetNEVENTS(lastev-firstev+1); |
glrun->SetNEVENTS(lastev-firstev+1); |
| 2877 |
// |
// |
| 2964 |
// |
// |
| 2965 |
found = false; // default value |
found = false; // default value |
| 2966 |
// |
// |
| 2967 |
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"); |
| 2968 |
// |
// |
| 2969 |
// 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: |
| 2970 |
// |
// |
| 3193 |
glrun->SetID(this->AssignRunID()); |
glrun->SetID(this->AssignRunID()); |
| 3194 |
glrun->SetID_RUN_FRAG(0); |
glrun->SetID_RUN_FRAG(0); |
| 3195 |
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... |
| 3196 |
}; |
}; |
| 3197 |
// |
// |
| 3198 |
}; |
}; |
| 3199 |
// |
// |
| 3237 |
if ( firstev == lastev+1 || lastev == firstev ) { // no events inside the run! |
if ( firstev == lastev+1 || lastev == firstev ) { // no events inside the run! |
| 3238 |
//if ( firstev <= lastev+1 ) { // no events inside the run! |
//if ( firstev <= lastev+1 ) { // no events inside the run! |
| 3239 |
if ( IsDebug() ) printf(" Checking but no events in the run! \n"); |
if ( IsDebug() ) printf(" Checking but no events in the run! \n"); |
| 3240 |
|
firstev = lastev+1; // this is necessary for files with no Physics entries, should have no influence on other files |
| 3241 |
// return true is correct |
// return true is correct |
| 3242 |
return(true); |
return(true); |
| 3243 |
// |
// |
| 3267 |
// |
// |
| 3268 |
} else { |
} else { |
| 3269 |
// |
// |
| 3270 |
if ( IsDebug() ) printf(" There are no-phyics packets inside the run!\n"); |
if ( IsDebug() ) printf(" There are no-physics packets inside the run!\n"); |
| 3271 |
// |
// |
| 3272 |
// HERE WE MUST HANDLE THAT RUNS AND GO BACK |
// HERE WE MUST HANDLE THAT RUNS AND GO BACK |
| 3273 |
// |
// |
| 3277 |
UInt_t check = 0; |
UInt_t check = 0; |
| 3278 |
UInt_t lastevtemp = lastev; |
UInt_t lastevtemp = lastev; |
| 3279 |
UInt_t firstevno = firstev; |
UInt_t firstevno = firstev; |
| 3280 |
|
UInt_t rhchko=0; |
| 3281 |
|
UInt_t rhchk=0; |
| 3282 |
// |
// |
| 3283 |
for (UInt_t i=firstev; i<=lastev; i++){ |
for (UInt_t i=firstev; i<=lastev; i++){ |
| 3284 |
// |
// |
| 3287 |
// |
// |
| 3288 |
check = 0; |
check = 0; |
| 3289 |
// |
// |
| 3290 |
|
|
| 3291 |
|
// if we have a runheader set lastev then exit |
| 3292 |
|
// |
| 3293 |
for(Iter = packetsNames.begin(); Iter != packetsNames.end(); Iter++){ |
for(Iter = packetsNames.begin(); Iter != packetsNames.end(); Iter++){ |
| 3294 |
if ( strcmp(*Iter,"Physics") ) check += code->Get(GetPacketType(*Iter)); |
if ( strcmp(*Iter,"Physics") ) check += code->Get(GetPacketType(*Iter)); |
| 3295 |
}; |
}; |
| 3296 |
|
// check here if we have a runheader |
| 3297 |
|
rhchko = rhchk; |
| 3298 |
|
rhchk = code->Get(GetPacketType("RunHeader")); |
| 3299 |
// |
// |
| 3300 |
if ( checkfirst < check || i == lastev ){ |
if ( checkfirst < check || i == lastev ){ |
| 3301 |
// |
// |
| 3379 |
// this->HandleRunFragments(true,mistrail,firstentry,lastentry); // cannot call it here since it enters a loop which will destroy the already stored variables if we arrive here from HandleRunFragments |
// this->HandleRunFragments(true,mistrail,firstentry,lastentry); // cannot call it here since it enters a loop which will destroy the already stored variables if we arrive here from HandleRunFragments |
| 3380 |
// |
// |
| 3381 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3382 |
mishead = true; |
mishead = true; |
| 3383 |
|
|
| 3384 |
|
|
| 3493 |
// |
// |
| 3494 |
found = false; // default value |
found = false; // default value |
| 3495 |
// |
// |
| 3496 |
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"); |
| 3497 |
// |
// |
| 3498 |
// 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: |
| 3499 |
// |
// |
| 3698 |
}; // EEE |
}; // EEE |
| 3699 |
|
|
| 3700 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3701 |
} else { |
} else { |
| 3702 |
if ( !IsRunAlreadyInserted() ){ |
if ( !IsRunAlreadyInserted() ){ |
| 3703 |
glrun->SetID(this->AssignRunID()); |
glrun->SetID(this->AssignRunID()); |
| 3712 |
// |
// |
| 3713 |
}; |
}; |
| 3714 |
// |
// |
| 3715 |
|
if ( i > firstev ){ |
| 3716 |
|
if ( rhchko != rhchk ){ |
| 3717 |
|
if ( IsDebug() ) printf("oh oh... we have a runheader! stop here and handle later the remaining piece\n"); |
| 3718 |
|
lastev = i; |
| 3719 |
|
return(false); |
| 3720 |
|
}; |
| 3721 |
|
}; |
| 3722 |
|
// |
| 3723 |
if ( check == checklast && i != lastev ){ |
if ( check == checklast && i != lastev ){ |
| 3724 |
lastevtemp = i - 1; |
lastevtemp = i - 1; |
| 3725 |
i = lastev - 1; |
i = lastev - 1; |
| 4536 |
return(0); |
return(0); |
| 4537 |
}; |
}; |
| 4538 |
|
|
|
// /** |
|
|
// * Fill the GL_TRK_CALIB table |
|
|
// */ |
|
|
// void PamelaDBOperations::HandleTRK_CALIB(Bool_t pk1, Bool_t pk2){ |
|
|
// // |
|
|
// TSQLResult *result = 0; |
|
|
// TSQLRow *row = 0; |
|
|
// // |
|
|
// stringstream oss; |
|
|
// oss.str(""); |
|
|
// // |
|
|
// UInt_t totime = 0; |
|
|
// // |
|
|
// if ( !pk1 && !pk2 ){ |
|
|
// if ( IsDebug() ) printf(" Cannot handle trk calibration with both packet missing!\n"); |
|
|
// return; |
|
|
// }; |
|
|
// // |
|
|
// // check if the calibration has already been inserted |
|
|
// // |
|
|
// oss.str(""); |
|
|
// oss << " SELECT ID FROM GL_TRK_CALIB WHERE " |
|
|
// << " BOOT_NUMBER = "<< this->GetBOOTnumber(); // |
|
|
// oss << " AND ( ( "; |
|
|
// if ( pk1 ){ |
|
|
// oss << " OBT1 = "<< obt1 << " AND " |
|
|
// << " PKT1 = "<< pkt1 |
|
|
// << " ) OR ( "; |
|
|
// } else { |
|
|
// oss << " PKT1 = "<< pkt2-1 |
|
|
// << " ) OR ( "; |
|
|
// }; |
|
|
// if ( pk2 ){ |
|
|
// oss << " OBT2 = "<< obt2 << " AND " |
|
|
// << " PKT2 = "<< pkt2; |
|
|
// } else { |
|
|
// oss << " PKT2 = "<< pkt1+1; |
|
|
// }; |
|
|
// oss << " ) );"; |
|
|
// // |
|
|
// if ( IsDebug() ) printf(" Check if the trk calibration has already been inserted: query is \n %s \n",oss.str().c_str()); |
|
|
// result = conn->Query(oss.str().c_str()); |
|
|
// // |
|
|
// if ( !result ) throw -4; |
|
|
// // |
|
|
// row = result->Next(); |
|
|
// // |
|
|
// if ( row ){ |
|
|
// // |
|
|
// if ( IsDebug() ) printf(" Trk calibration already inserted in the DB\n"); |
|
|
// if ( PEDANTIC ) throw -80; |
|
|
// // |
|
|
// } else { |
|
|
// // |
|
|
// // we have to insert a new calibration, check where to place it |
|
|
// // |
|
|
// oss.str(""); |
|
|
// oss << " SELECT ID,TO_TIME FROM GL_TRK_CALIB WHERE " |
|
|
// << " FROM_TIME < "<< fromtime << " AND " |
|
|
// << " TO_TIME > "<< fromtime << ";"; |
|
|
// // |
|
|
// if ( IsDebug() ) printf(" Check where to place the trk calibration: query is \n %s \n",oss.str().c_str()); |
|
|
// result = conn->Query(oss.str().c_str()); |
|
|
// // |
|
|
// if ( !result ) throw -4; |
|
|
// // |
|
|
// row = result->Next(); |
|
|
// // |
|
|
// if ( !row ){ |
|
|
// // |
|
|
// // no calibrations in the db contain our calibration |
|
|
// // |
|
|
// if ( IsDebug() ) printf(" Calibration with fromtime lower than others to be inserted in the DB\n"); |
|
|
// if ( fromtime < 1150871000 ) fromtime = 0; // the first flight calibration was taken at about 1150863300 s, this line allows to analyze first runs in raw mode |
|
|
// // |
|
|
// oss.str(""); |
|
|
// oss << " SELECT FROM_TIME FROM GL_TRK_CALIB WHERE " |
|
|
// << " FROM_TIME > "<< fromtime << " ORDER BY FROM_TIME ASC LIMIT 1;"; |
|
|
// // |
|
|
// if ( IsDebug() ) printf(" Check the upper limit for calibration: query is \n %s \n",oss.str().c_str()); |
|
|
// result = conn->Query(oss.str().c_str()); |
|
|
// // |
|
|
// if ( !result ) throw -4; |
|
|
// // |
|
|
// row = result->Next(); |
|
|
// if ( !row ){ |
|
|
// totime = numeric_limits<UInt_t>::max(); |
|
|
// } else { |
|
|
// totime = (UInt_t)atoll(row->GetField(0)); |
|
|
// }; |
|
|
// // |
|
|
// } else { |
|
|
// // |
|
|
// // determine upper and lower limits and make space for the new calibration |
|
|
// // |
|
|
// totime = (UInt_t)atoll(row->GetField(1)); |
|
|
// // |
|
|
// oss.str(""); |
|
|
// oss << " UPDATE GL_TRK_CALIB SET " |
|
|
// << " TO_TIME = "<< fromtime << " WHERE " // NOTICE: to_time is equal to from_time of the calibration before, so the interval is: [from_time,to_time[ |
|
|
// << " ID = "<< row->GetField(0) << ";"; |
|
|
// // |
|
|
// if ( IsDebug() ) printf(" Make space for the new trk calibration: query is \n %s \n",oss.str().c_str()); |
|
|
// result = conn->Query(oss.str().c_str()); |
|
|
// // |
|
|
// if ( !result ) throw -4; |
|
|
// // |
|
|
// }; |
|
|
// // |
|
|
// oss.str(""); |
|
|
// oss << " INSERT INTO GL_TRK_CALIB (ID,ID_ROOT_L0,EV_ROOT_CALIBTRK1,EV_ROOT_CALIBTRK2,FROM_TIME,TO_TIME,OBT1,PKT1,OBT2,PKT2,BOOT_NUMBER,VALIDATION) " |
|
|
// << " VALUES (NULL,' " |
|
|
// << idroot << "',"; |
|
|
// // |
|
|
// if ( !pk1 ){ |
|
|
// oss << "NULL,"; |
|
|
// } else { |
|
|
// oss << "'" |
|
|
// << t1 << "',"; |
|
|
// }; |
|
|
// // |
|
|
// if ( !pk2 ){ |
|
|
// oss << "NULL,'"; |
|
|
// } else { |
|
|
// oss << "'" |
|
|
// << t2 << "','"; |
|
|
// }; |
|
|
// // |
|
|
// oss << fromtime << "','" |
|
|
// << totime << "','" |
|
|
// << obt1 << "','" |
|
|
// << pkt1 << "','" |
|
|
// << obt2 << "','" |
|
|
// << pkt2 << "','" |
|
|
// << this->GetBOOTnumber() << "','" |
|
|
// << valid << "');"; |
|
|
// // |
|
|
// if ( IsDebug() ) printf(" Insert the new trk calibration: query is \n %s \n",oss.str().c_str()); |
|
|
// // |
|
|
// result = conn->Query(oss.str().c_str()); |
|
|
// // |
|
|
// if ( !result ) throw -4; |
|
|
// // |
|
|
// }; |
|
|
// // |
|
|
// }; |
|
| 4539 |
/** |
/** |
| 4540 |
* Fill the GL_TRK_CALIB table |
* Fill the GL_TRK_CALIB table |
| 4541 |
*/ |
*/ |
| 4936 |
// |
// |
| 4937 |
}; |
}; |
| 4938 |
// |
// |
| 4939 |
|
|
| 4940 |
|
if( !(MISSING_pkt1&MISSING_pkt2) ){ |
| 4941 |
|
this->HandleTRK_CALIB(!MISSING_pkt1,!MISSING_pkt2); |
| 4942 |
|
ncalib++; |
| 4943 |
|
if( MISSING_pkt1||MISSING_pkt2||!valid )try_to_recover=true; |
| 4944 |
|
} |
| 4945 |
|
|
| 4946 |
|
|
| 4947 |
} else { |
} else { |
| 4948 |
// |
// |
| 4949 |
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); |
| 4950 |
// if ( PEDANTIC ) throw -79; |
// if ( PEDANTIC ) throw -79; |
| 4951 |
// |
// |
| 4952 |
}; |
}; |
| 4953 |
// |
// |
| 4954 |
|
|
|
if( !(MISSING_pkt1&MISSING_pkt2) ){ |
|
|
this->HandleTRK_CALIB(!MISSING_pkt1,!MISSING_pkt2); |
|
|
ncalib++; |
|
|
if( MISSING_pkt1||MISSING_pkt2||!valid )try_to_recover=true; |
|
|
} |
|
|
|
|
| 4955 |
}; //end loop on pkt1 |
}; //end loop on pkt1 |
| 4956 |
|
|
| 4957 |
|
|
| 5167 |
|
|
| 5168 |
if ( IsDebug() ) cout << "- - - - - - - - - - -" <<endl; |
if ( IsDebug() ) cout << "- - - - - - - - - - -" <<endl; |
| 5169 |
// cout << path <<endl; |
// cout << path <<endl; |
| 5170 |
cout << "File : " <<name <<endl; |
// cout << "File : " <<name <<endl; |
| 5171 |
// cout << obt0 <<endl; |
// cout << obt0 <<endl; |
| 5172 |
// cout << timesync <<endl; |
// cout << timesync <<endl; |
| 5173 |
cout << "boot n. : "<<boot_number <<endl; |
// cout << "boot n. : "<<boot_number <<endl; |
| 5174 |
// cout << raw <<endl; |
// cout << raw <<endl; |
| 5175 |
|
|
| 5176 |
// ------------------------------------------------------ |
// ------------------------------------------------------ |
| 5177 |
// ... retrieve the calibration packets. |
// ... retrieve the calibration packets. |
| 5178 |
// ------------------------------------------------------ |
// ------------------------------------------------------ |
| 5179 |
TFile *file = new TFile(path+"/"+name); |
if ( IsDebug() ) printf(" file is %s/%s \n",((TString)gSystem->ExpandPathName(path.Data())).Data(),name.Data()); |
| 5180 |
|
TFile *file = new TFile(((TString)gSystem->ExpandPathName(path.Data()))+"/"+name); // EM, path could be symbolic and we must expand it |
| 5181 |
if(!file)throw -100; |
if(!file)throw -100; |
| 5182 |
if(file->IsZombie())throw -100; |
if(file->IsZombie())throw -100; |
| 5183 |
// |
// |
| 5247 |
// |
// |
| 5248 |
// check if the raw file already exist |
// check if the raw file already exist |
| 5249 |
// |
// |
| 5250 |
UInt_t id_raw = 0; |
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 |
| 5251 |
oss.str(""); |
// oss.str(""); |
| 5252 |
oss << "SELECT ID FROM GL_RAW where NAME=\"" << gSystem->BaseName(raw.Data()) <<"\";"; |
// oss << "SELECT ID FROM GL_RAW where NAME=\"" << gSystem->BaseName(raw.Data()) <<"\";"; |
| 5253 |
if ( IsDebug() ) cout << oss.str().c_str() << endl; |
// if ( IsDebug() ) cout << oss.str().c_str() << endl; |
| 5254 |
|
|
| 5255 |
result = conn->Query(oss.str().c_str()); |
// result = conn->Query(oss.str().c_str()); |
| 5256 |
if ( !result ) throw -4;; |
// if ( !result ) throw -4;; |
| 5257 |
if ( IsDebug() ) cout <<"Rows: "<<result->GetRowCount()<<endl; |
// if ( IsDebug() ) cout <<"Rows: "<<result->GetRowCount()<<endl; |
| 5258 |
if( result->GetRowCount() == 0){ |
// if( result->GetRowCount() == 0){ |
| 5259 |
if ( IsDebug() ) cout << " << Insert new RAW file >> "<<endl; |
// if ( IsDebug() ) cout << " << Insert new RAW file >> "<<endl; |
| 5260 |
// - - - - - - - - - - - |
// // - - - - - - - - - - - |
| 5261 |
// insert new raw file |
// // insert new raw file |
| 5262 |
// - - - - - - - - - - - |
// // - - - - - - - - - - - |
| 5263 |
GL_RAW glraw = GL_RAW(); |
// GL_RAW glraw = GL_RAW(); |
| 5264 |
glraw.PATH = gSystem->DirName(raw.Data()); |
// glraw.PATH = gSystem->DirName(raw.Data()); |
| 5265 |
glraw.NAME = gSystem->BaseName(raw.Data()); |
// glraw.NAME = gSystem->BaseName(raw.Data()); |
| 5266 |
glraw.BOOT_NUMBER = boot_number; |
// glraw.BOOT_NUMBER = boot_number; |
| 5267 |
// |
// // |
| 5268 |
insertPamelaRawFile( &glraw ); |
// insertPamelaRawFile( &glraw ); |
| 5269 |
// |
// // |
| 5270 |
id_raw = glraw.ID; |
// id_raw = glraw.ID; |
| 5271 |
}else{ |
// }else{ |
| 5272 |
row = result->Next(); |
// row = result->Next(); |
| 5273 |
id_raw = (UInt_t)atoll(row->GetField(0)); |
// id_raw = (UInt_t)atoll(row->GetField(0)); |
| 5274 |
} |
// } |
| 5275 |
if ( IsDebug() ) cout << "ID_RAW = "<<id_raw<<endl; |
// if ( IsDebug() ) cout << "ID_RAW = "<<id_raw<<endl; |
| 5276 |
|
|
| 5277 |
// --------------------------------------------------------------------- |
// --------------------------------------------------------------------- |
| 5278 |
// step 1(bis): retrieve the timesync id associated to the file |
// step 1(bis): retrieve the timesync id associated to the file |
| 5293 |
// step 2: insert a new root file in GL_ROOT |
// step 2: insert a new root file in GL_ROOT |
| 5294 |
// --------------------------------------------------------------------- |
// --------------------------------------------------------------------- |
| 5295 |
// |
// |
| 5296 |
// check if the raw file already exist |
// check if the root file already exist |
| 5297 |
// |
// |
| 5298 |
UInt_t id_root = 0; |
UInt_t id_root = 0; |
| 5299 |
oss.str(""); |
oss.str(""); |
| 5311 |
GL_ROOT glroot = GL_ROOT(); |
GL_ROOT glroot = GL_ROOT(); |
| 5312 |
glroot.ID_RAW = id_raw; |
glroot.ID_RAW = id_raw; |
| 5313 |
glroot.ID_TIMESYNC = idtimesync; |
glroot.ID_TIMESYNC = idtimesync; |
| 5314 |
glroot.PATH = path; |
// |
| 5315 |
|
// EM STATIC = the full expanded path must be put in the DB, KEEPENV = the path given as input (or found in ROOT_TABLE) must be used, |
| 5316 |
|
// NOT STATIC NOT KEEPENV = $PAM_L0 must be used in the DB |
| 5317 |
|
// |
| 5318 |
|
if ( STATIC ){ |
| 5319 |
|
glroot.PATH = (TString)gSystem->ExpandPathName(path); |
| 5320 |
|
} else { |
| 5321 |
|
if ( KEEPENV ){ |
| 5322 |
|
glroot.PATH = path; |
| 5323 |
|
} else { |
| 5324 |
|
glroot.PATH = "$PAM_L0"; |
| 5325 |
|
}; |
| 5326 |
|
}; |
| 5327 |
|
// glroot.PATH = path; |
| 5328 |
glroot.NAME = name; |
glroot.NAME = name; |
| 5329 |
// |
// |
| 5330 |
insertPamelaRootFile( &glroot ); |
insertPamelaRootFile( &glroot ); |
| 6101 |
// 2) get the OBT of the last validated run |
// 2) get the OBT of the last validated run |
| 6102 |
// -------------------------------------------------------------- |
// -------------------------------------------------------------- |
| 6103 |
oss.str(""); |
oss.str(""); |
| 6104 |
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 |
| 6105 |
|
oss << " SELECT * FROM GL_RUN WHERE VALIDATION>0 AND RUNHEADER_TIME<="<< t_start |
| 6106 |
<<" ORDER BY RUNHEADER_TIME DESC LIMIT 1;"; |
<<" ORDER BY RUNHEADER_TIME DESC LIMIT 1;"; |
| 6107 |
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()); |
| 6108 |
result = conn->Query(oss.str().c_str()); |
result = conn->Query(oss.str().c_str()); |
| 6245 |
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 |
| 6246 |
|
|
| 6247 |
if( !CHECK && this_run->VALIDATION ){ |
if( !CHECK && this_run->VALIDATION ){ |
| 6248 |
for (Int_t irun = 0; irun < nseq; irun++)assignVALIDATION(sequence[irun],true); |
// for (Int_t irun = 0; irun < nseq; irun++)assignVALIDATION(sequence[irun],true); |
| 6249 |
|
for (Int_t irun = 0; irun < nseq; irun++)assignVALIDATION(sequence[irun],this_run->VALIDATION); |
| 6250 |
nseq=0; |
nseq=0; |
| 6251 |
} |
} |
| 6252 |
|
|
| 6267 |
if( CHECK ){ |
if( CHECK ){ |
| 6268 |
// check if calibration exists |
// check if calibration exists |
| 6269 |
if ( IsDebug() )printf("DT %i ===> CHECK Missing calibration\n",interval); |
if ( IsDebug() )printf("DT %i ===> CHECK Missing calibration\n",interval); |
| 6270 |
Bool_t MISSING = MissingTRK_CALIB(t1,t2); |
// Bool_t MISSING = MissingTRK_CALIB(t1,t2); |
| 6271 |
for (Int_t irun = 0; irun < nseq; irun++)assignVALIDATION(sequence[irun],!MISSING); |
UInt_t MISSING = MissingTRK_CALIB(t1,t2); |
| 6272 |
|
UInt_t val = 0; |
| 6273 |
|
if ( MISSING == 1 ) val = 0; |
| 6274 |
|
if ( MISSING == 0 ) val = 1; |
| 6275 |
|
if ( MISSING == 2 ) val = 2; |
| 6276 |
|
for (Int_t irun = 0; irun < nseq; irun++)assignVALIDATION(sequence[irun],val); |
| 6277 |
nseq=0; |
nseq=0; |
| 6278 |
}; |
}; |
| 6279 |
//-------------- |
//-------------- |
| 6303 |
* @param t2 To absolute time |
* @param t2 To absolute time |
| 6304 |
* @return true if there might be a missing calibration |
* @return true if there might be a missing calibration |
| 6305 |
*/ |
*/ |
| 6306 |
Bool_t PamelaDBOperations::MissingTRK_CALIB(UInt_t t1,UInt_t t2){ |
//Bool_t PamelaDBOperations::MissingTRK_CALIB(UInt_t t1,UInt_t t2){ |
| 6307 |
|
UInt_t PamelaDBOperations::MissingTRK_CALIB(UInt_t t1,UInt_t t2){ |
| 6308 |
|
|
| 6309 |
GL_TRK_CALIB* trkcalib = new GL_TRK_CALIB(); |
GL_TRK_CALIB* trkcalib = new GL_TRK_CALIB(); |
| 6310 |
|
|
| 6311 |
// get the closest calibration before the run start (t2) |
// get the closest calibration before the run start (t2) |
| 6312 |
if ( trkcalib->Query_GL_TRK_CALIB(t2, conn) )return(true); //>>> missing |
// if ( trkcalib->Query_GL_TRK_CALIB(t2, conn) )return(true); //>>> missing |
| 6313 |
|
if ( trkcalib->Query_GL_TRK_CALIB(t2, conn) )return(1); //>>> missing |
| 6314 |
|
|
| 6315 |
if ( trkcalib->TO_TIME < t2 ) return(true); //>>> missing |
// if ( trkcalib->TO_TIME < t2 ) return(true); //>>> missing |
| 6316 |
|
if ( trkcalib->TO_TIME < t2 ) return(1); //>>> missing |
| 6317 |
|
|
| 6318 |
//============================================================== |
//============================================================== |
| 6319 |
// Check is done first on the basis of time between calibration, |
// Check is done first on the basis of time between calibration, |
| 6330 |
//============================================================== |
//============================================================== |
| 6331 |
Bool_t DOWNLOAD = false; |
Bool_t DOWNLOAD = false; |
| 6332 |
// check if the calib was skipped becouse of download .... DA FARE!! |
// check if the calib was skipped becouse of download .... DA FARE!! |
| 6333 |
if(DOWNLOAD)return(false); |
// if(DOWNLOAD)return(false); |
| 6334 |
|
if(DOWNLOAD)return(0); |
| 6335 |
|
|
| 6336 |
return(true); //>>> missing |
// return(true); //>>> missing |
| 6337 |
|
return(1); //>>> missing |
| 6338 |
|
|
| 6339 |
}; |
}; |
| 6340 |
|
|
| 6344 |
//============================================================== |
//============================================================== |
| 6345 |
// the long time interval bewteen runs might be due to download |
// the long time interval bewteen runs might be due to download |
| 6346 |
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); |
| 6347 |
return(false); |
if ( trkcalib->VALIDATION ) return(0); |
| 6348 |
|
if ( IsDebug() )printf("Calibration is not validated... :-/ ==> OK but with VALIDATION=2! \n"); |
| 6349 |
|
return(2); |
| 6350 |
|
|
| 6351 |
}; |
}; |
| 6352 |
/** |
/** |
| 6355 |
* @param validation true/false |
* @param validation true/false |
| 6356 |
*/ |
*/ |
| 6357 |
Int_t PamelaDBOperations::assignVALIDATION(UInt_t idrun, Bool_t validation){ |
Int_t PamelaDBOperations::assignVALIDATION(UInt_t idrun, Bool_t validation){ |
| 6358 |
|
return(this->assignVALIDATION(idrun,(UInt_t)validation)); |
| 6359 |
|
} |
| 6360 |
|
|
| 6361 |
|
Int_t PamelaDBOperations::assignVALIDATION(UInt_t idrun, UInt_t validation){ |
| 6362 |
TSQLResult *result = 0; |
TSQLResult *result = 0; |
| 6363 |
stringstream oss; |
stringstream oss; |
| 6364 |
oss.str(""); |
oss.str(""); |
| 6555 |
stringstream myquery; |
stringstream myquery; |
| 6556 |
// |
// |
| 6557 |
myquery.str(""); |
myquery.str(""); |
| 6558 |
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() <<"';"; |
| 6559 |
// |
// |
| 6560 |
pResult = conn->Query(myquery.str().c_str()); |
pResult = conn->Query(myquery.str().c_str()); |
| 6561 |
// |
// |
| 6571 |
// |
// |
| 6572 |
this->SetID_ROOT((UInt_t)atoll(Row->GetField(0))); |
this->SetID_ROOT((UInt_t)atoll(Row->GetField(0))); |
| 6573 |
this->SetID_RAW((UInt_t)atoll(Row->GetField(1))); |
this->SetID_RAW((UInt_t)atoll(Row->GetField(1))); |
| 6574 |
|
UInt_t idtsy=(UInt_t)atoll(Row->GetField(2)); |
| 6575 |
// |
// |
| 6576 |
this->ValidationOFF(); |
this->ValidationOFF(); |
| 6577 |
// |
// |
| 6579 |
// |
// |
| 6580 |
this->RemoveRUNS(); |
this->RemoveRUNS(); |
| 6581 |
// |
// |
| 6582 |
this->RemoveFILES(); |
this->RemoveFILES(idtsy); |
| 6583 |
// |
// |
| 6584 |
this->SetID_ROOT(0); |
this->SetID_ROOT(0); |
| 6585 |
this->SetID_RAW(0); |
this->SetID_RAW(0); |
| 6799 |
* Rearrange calibration tables |
* Rearrange calibration tables |
| 6800 |
* |
* |
| 6801 |
**/ |
**/ |
| 6802 |
void PamelaDBOperations::RemoveFILES(){ |
void PamelaDBOperations::RemoveFILES(UInt_t idtsy){ |
| 6803 |
stringstream myquery; |
stringstream myquery; |
| 6804 |
// |
// |
| 6805 |
myquery.str(""); |
myquery.str(""); |
| 6809 |
// |
// |
| 6810 |
conn->Query(myquery.str().c_str()); |
conn->Query(myquery.str().c_str()); |
| 6811 |
// |
// |
| 6812 |
|
myquery.str(""); |
| 6813 |
|
myquery << " DELETE FROM GL_ROOT WHERE ID=" <<this->GetID_ROOT() <<";"; |
| 6814 |
|
// |
| 6815 |
|
if ( IsDebug() ) printf(" query is \n %s \n",myquery.str().c_str()); |
| 6816 |
|
// |
| 6817 |
|
conn->Query(myquery.str().c_str()); // |
| 6818 |
|
// |
| 6819 |
|
if ( !chewbacca ){ |
| 6820 |
|
myquery.str(""); |
| 6821 |
|
myquery << " DELETE FROM GL_TIMESYNC WHERE ID=" << idtsy <<";"; |
| 6822 |
|
// |
| 6823 |
|
if ( IsDebug() ) printf(" query is \n %s \n",myquery.str().c_str()); |
| 6824 |
|
// |
| 6825 |
|
conn->Query(myquery.str().c_str()); |
| 6826 |
|
}; |
| 6827 |
|
// |
| 6828 |
}; |
}; |
| 6829 |
|
|
| 6830 |
/** |
/** |
| 7174 |
|
|
| 7175 |
|
|
| 7176 |
} |
} |
|
// UInt_t PamelaDBOperations::ValidateTrkCalib( CalibTrk1Event* caltrk, EventHeader *eh ){ |
|
|
|
|
|
// if(!caltrk || !eh) return 0; |
|
|
|
|
|
// Int_t vorder[]={5,5,3,3,4,4,2,2,1,1,0,0}; |
|
|
// UInt_t timeaftercalib=120000; //2000; |
|
|
// // ---------- |
|
|
// // Check CRCs |
|
|
// // ---------- |
|
|
// for(Int_t ipkt=0; ipkt<6; ipkt++){ |
|
|
// if( caltrk->crc_hcal[ipkt] )return 0; // :-( |
|
|
// for(Int_t ilad=0; ilad<3; ilad++)if( caltrk->crc_cal[ipkt][ilad] )return 0; // :-( |
|
|
// } |
|
|
// // ----------------------- |
|
|
// // Check missing packets: |
|
|
// // ----------------------- |
|
|
// // Readout order: |
|
|
// // ------------------ |
|
|
// // DSP packet board |
|
|
// // ------------------ |
|
|
// // 12 0 1 |
|
|
// // 10 1 1 |
|
|
// // 8 2 1 |
|
|
// // 4 3 1 |
|
|
// // 6 4 1 |
|
|
// // 2 5 1 |
|
|
// // ------------------ |
|
|
// // 11 0 2 |
|
|
// // 9 1 2 |
|
|
// // 7 2 2 |
|
|
// // 3 3 2 |
|
|
// // 5 4 2 |
|
|
// // 1 5 2 |
|
|
// // ------------------ |
|
|
// // ------------------------------------------------- |
|
|
// // Check if it is first or second calibration packet |
|
|
// // ------------------------------------------------- |
|
|
// UInt_t build=0; |
|
|
// TString classname = caltrk->GetName(); |
|
|
// UInt_t base=0; |
|
|
// UInt_t mask=0; |
|
|
// if(classname.Contains("CalibTrk1Event")){ |
|
|
// base=12; |
|
|
// mask=0x03F000; |
|
|
// } |
|
|
// if(classname.Contains("CalibTrk2Event")){ |
|
|
// base=18; |
|
|
// mask=0xFC0000; |
|
|
// } |
|
|
// // ------------------------------------------------- |
|
|
// // Count number of packets and set build variable |
|
|
// // ------------------------------------------------- |
|
|
// Int_t npkts=0; |
|
|
// for(Int_t ipkt=0; ipkt<6; ipkt++){ |
|
|
// if(caltrk->DSPnumber[ipkt]>0 && caltrk->DSPnumber[ipkt]<=12){ |
|
|
// npkts++; |
|
|
// build = build | ( 1<<(base+vorder[caltrk->DSPnumber[ipkt]-1]) ); |
|
|
// } |
|
|
// } |
|
|
// // if( npkts==6 )return 1; // :-) |
|
|
|
|
|
// // cout << classname << " "<<eh->GetPscuHeader()->GetOrbitalTime()<<endl; |
|
|
|
|
|
// // ----------------------------------------------- |
|
|
// // If missing packets: check the acq configuration |
|
|
// // (some DSPs might be excluded from acquisition) |
|
|
// // ----------------------------------------------- |
|
|
|
|
|
// // ----------------------------------------------- |
|
|
// // retrieve the first run header after calib |
|
|
// // ----------------------------------------------- |
|
|
// PacketType *pctp; |
|
|
// EventCounter *cod; |
|
|
// cod = eh->GetCounter(); |
|
|
// Int_t irun = cod->Get(pctp->RunHeader); |
|
|
// TTree *rh=(TTree*)file->Get("RunHeader"); |
|
|
// if ( !rh || rh->IsZombie() ) throw -17; |
|
|
// if( rh->GetEntries() == irun ){ |
|
|
// if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) no runs after calib (1) -- cannot validate :-( "<<endl; |
|
|
// return 0; // :-( |
|
|
// } |
|
|
|
|
|
// RunHeaderEvent *run = 0; |
|
|
// EventHeader *hrun = 0; |
|
|
// rh->SetBranchAddress("RunHeader", &run); |
|
|
// rh->SetBranchAddress("Header", &hrun); |
|
|
// rh->GetEntry(irun); |
|
|
// // cout << classname << " "<<eh->GetPscuHeader()->GetOrbitalTime() << " Run " << hrun->GetPscuHeader()->GetOrbitalTime() <<endl; |
|
|
|
|
|
// if( OBT(hrun->GetPscuHeader()->GetOrbitalTime()) < OBT(eh->GetPscuHeader()->GetOrbitalTime())){ |
|
|
// if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) no runs after calib (2) -- cannot validate :-( "<<endl; |
|
|
// return 0; // :-( |
|
|
// } |
|
|
|
|
|
// if( !run->RM_ACQ_AFTER_CALIB ){ |
|
|
// if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) RM_ACQ_AFTER_CALIB=0 -- cannot validate :-( "<<endl; |
|
|
// return 0; // :-( |
|
|
// } |
|
|
|
|
|
// UInt_t dtime = OBT(hrun->GetPscuHeader()->GetOrbitalTime()) - OBT(eh->GetPscuHeader()->GetOrbitalTime()); |
|
|
// if( dtime > timeaftercalib ){ |
|
|
// if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) run after calib too far ( "<<dtime<<"ms ) -- cannot validate :-( "<<endl; |
|
|
// return 0; // :-( |
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
// if( (run->ACQ_BUILD_INFO & mask) != build ){ |
|
|
// if ( IsDebug() ) cout << "ValidateTrkCalib: (MISSING VIEW) ACQ_BUILD_INFO= >>> "<<hex << (run->ACQ_BUILD_INFO&mask) << " != "<< build << dec<<endl; |
|
|
// return 0; // :-( |
|
|
// } |
|
|
// return 1; // :-) |
|
|
|
|
|
// } |
|
| 7177 |
|
|
| 7178 |
/** |
/** |
| 7179 |
* |
* |