| 56 |
* @param debug debug flag. |
* @param debug debug flag. |
| 57 |
* @param tlefilename ascii file with TLE 3 line elements. |
* @param tlefilename ascii file with TLE 3 line elements. |
| 58 |
*/ |
*/ |
| 59 |
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){ |
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){ |
| 60 |
// |
// |
| 61 |
|
STATIC=false; |
| 62 |
|
if ( staticp ) STATIC=true; |
| 63 |
// |
// |
| 64 |
SetConnection(host,user,password); |
SetConnection(host,user,password); |
| 65 |
// |
// |
| 263 |
tlefilename = str; |
tlefilename = str; |
| 264 |
}; |
}; |
| 265 |
|
|
| 266 |
|
TString PamelaDBOperations::GetRawPath(){ |
| 267 |
|
if ( STATIC ){ |
| 268 |
|
return((TString)gSystem->DirName(filerawname.Data())+'/'); |
| 269 |
|
} else { |
| 270 |
|
return((TString)gSystem->ExpandPathName("$PAM_RAW")+'/'); |
| 271 |
|
}; |
| 272 |
|
}; |
| 273 |
|
|
| 274 |
|
TString PamelaDBOperations::GetRootPath(){ |
| 275 |
|
if ( STATIC ){ |
| 276 |
|
return((TString)gSystem->DirName(filerootname.Data())+'/'); |
| 277 |
|
} else { |
| 278 |
|
return((TString)gSystem->ExpandPathName("$PAM_L0")+'/'); |
| 279 |
|
}; |
| 280 |
|
}; |
| 281 |
|
|
| 282 |
/** |
/** |
| 283 |
* Store the olderthan variable |
* Store the olderthan variable |
| 284 |
* @param olderthan |
* @param olderthan |
| 295 |
TSQLResult *result = 0; |
TSQLResult *result = 0; |
| 296 |
TSQLRow *row = 0; |
TSQLRow *row = 0; |
| 297 |
oss.str(""); |
oss.str(""); |
| 298 |
oss << "SELECT ID FROM GL_RAW WHERE " |
if ( STATIC ){ |
| 299 |
<< " PATH = '" << this->GetRawPath().Data() << "' AND " |
oss << "SELECT ID FROM GL_RAW WHERE " |
| 300 |
<< " NAME = '" << this->GetRawFile().Data() << "' "; |
<< " PATH = '" << this->GetRawPath().Data() << "' AND " |
| 301 |
|
<< " NAME = '" << this->GetRawFile().Data() << "' "; |
| 302 |
|
} else { |
| 303 |
|
oss << "SELECT ID FROM GL_RAW WHERE " |
| 304 |
|
<< " PATH = '$PAM_RAW' AND " |
| 305 |
|
<< " NAME = '" << this->GetRawFile().Data() << "' "; |
| 306 |
|
} |
| 307 |
result = conn->Query(oss.str().c_str()); |
result = conn->Query(oss.str().c_str()); |
| 308 |
if ( result == NULL ) throw -4; |
if ( result == NULL ) throw -4; |
| 309 |
row = result->Next(); |
row = result->Next(); |
| 882 |
*/ |
*/ |
| 883 |
Long64_t PamelaDBOperations::OBT(UInt_t obt){ |
Long64_t PamelaDBOperations::OBT(UInt_t obt){ |
| 884 |
// |
// |
| 885 |
if ( obt < (pobtfirst/2) && pobtfirst > (numeric_limits<UInt_t>::max()/2) ) return((Long64_t)(obt+numeric_limits<UInt_t>::max())); |
if ( IsDebug() ) printf(" obt conversion: ob is %u obtfirst is %u (numeric_limits<UInt_t>::max()/2) is %u \n",obt,pobtfirst,(UInt_t)(numeric_limits<UInt_t>::max()/2)); |
| 886 |
|
// |
| 887 |
|
if ( obt < (pobtfirst/2) && pobtfirst > (numeric_limits<UInt_t>::max()/2) ){ |
| 888 |
|
if ( IsDebug() ) printf(" rise up obt %lld \n",(obt+numeric_limits<UInt_t>::max())); |
| 889 |
|
return((Long64_t)(obt+numeric_limits<UInt_t>::max())); |
| 890 |
|
}; |
| 891 |
// |
// |
| 892 |
if ( obt > (pobtfirst*2) && obt > (numeric_limits<UInt_t>::max()/2) ){ |
if ( obt > (pobtfirst*2) && obt > (numeric_limits<UInt_t>::max()/2) ){ |
| 893 |
|
if ( IsDebug() ) printf(" rise down pktnum %lld \n", (Long64_t)obt-(Long64_t)numeric_limits<UInt_t>::max()); |
| 894 |
return((Long64_t)obt-(Long64_t)numeric_limits<UInt_t>::max()); |
return((Long64_t)obt-(Long64_t)numeric_limits<UInt_t>::max()); |
| 895 |
}; |
}; |
| 896 |
// |
// |
| 897 |
|
if ( IsDebug() ) printf(" as it is %lld \n",(Long64_t)obt); |
| 898 |
return((Long64_t)obt); |
return((Long64_t)obt); |
| 899 |
}; |
}; |
| 900 |
|
|
| 1010 |
if ( idr ) return(1); |
if ( idr ) return(1); |
| 1011 |
// |
// |
| 1012 |
oss.str(""); |
oss.str(""); |
| 1013 |
oss << "INSERT INTO GL_RAW (PATH, NAME) VALUES ('" |
if ( STATIC ){ |
| 1014 |
<< this->GetRawPath().Data() << "', '" << this->GetRawFile().Data() << "')"; |
oss << "INSERT INTO GL_RAW (PATH, NAME) VALUES ('" |
| 1015 |
|
<< this->GetRawPath().Data() << "', '" << this->GetRawFile().Data() << "')"; |
| 1016 |
|
} else { |
| 1017 |
|
oss << "INSERT INTO GL_RAW (PATH, NAME) VALUES ('$PAM_RAW', '" << this->GetRawFile().Data() << "')"; |
| 1018 |
|
}; |
| 1019 |
if ( conn->Query(oss.str().c_str()) == 0 ) throw -4; |
if ( conn->Query(oss.str().c_str()) == 0 ) throw -4; |
| 1020 |
// |
// |
| 1021 |
idr = this->SetID_RAW(); |
idr = this->SetID_RAW(); |
| 1296 |
UInt_t idtimesync = 0; |
UInt_t idtimesync = 0; |
| 1297 |
// |
// |
| 1298 |
oss.str(""); |
oss.str(""); |
| 1299 |
oss << " SELECT COUNT(GL_ROOT.ID_RAW),GL_RAW.ID,GL_ROOT.ID FROM GL_RAW " |
if ( STATIC ){ |
| 1300 |
<< " LEFT JOIN GL_ROOT " |
oss << " SELECT COUNT(GL_ROOT.ID_RAW),GL_RAW.ID,GL_ROOT.ID FROM GL_RAW " |
| 1301 |
<< " ON GL_RAW.ID = GL_ROOT.ID_RAW " |
<< " LEFT JOIN GL_ROOT " |
| 1302 |
<< " WHERE GL_RAW.PATH = '" << this->GetRawPath().Data() << "' AND " |
<< " ON GL_RAW.ID = GL_ROOT.ID_RAW " |
| 1303 |
<< " GL_RAW.NAME = '" << this->GetRawFile().Data() << "' GROUP BY GL_RAW.ID "; |
<< " WHERE GL_RAW.PATH = '" << this->GetRawPath().Data() << "' AND " |
| 1304 |
|
<< " GL_RAW.NAME = '" << this->GetRawFile().Data() << "' GROUP BY GL_RAW.ID "; |
| 1305 |
|
} else { |
| 1306 |
|
oss << " SELECT COUNT(GL_ROOT.ID_RAW),GL_RAW.ID,GL_ROOT.ID FROM GL_RAW " |
| 1307 |
|
<< " LEFT JOIN GL_ROOT " |
| 1308 |
|
<< " ON GL_RAW.ID = GL_ROOT.ID_RAW " |
| 1309 |
|
<< " WHERE GL_RAW.PATH = '$PAM_RAW' AND " |
| 1310 |
|
<< " GL_RAW.NAME = '" << this->GetRawFile().Data() << "' GROUP BY GL_RAW.ID "; |
| 1311 |
|
}; |
| 1312 |
result = conn->Query(oss.str().c_str()); |
result = conn->Query(oss.str().c_str()); |
| 1313 |
// |
// |
| 1314 |
if ( !result ) throw -12; |
if ( !result ) throw -12; |
| 1335 |
idtimesync = (UInt_t)atoll(row->GetField(0)); |
idtimesync = (UInt_t)atoll(row->GetField(0)); |
| 1336 |
// |
// |
| 1337 |
oss.str(""); |
oss.str(""); |
| 1338 |
oss << "INSERT INTO GL_ROOT (ID_RAW, ID_TIMESYNC,PATH, NAME) VALUES ('" |
if ( STATIC ){ |
| 1339 |
<< this->GetID_RAW() << "', '" << idtimesync << "', '" << this->GetRootPath().Data() << "', '" << this->GetRootFile().Data() << "')"; |
oss << "INSERT INTO GL_ROOT (ID_RAW, ID_TIMESYNC,PATH, NAME) VALUES ('" |
| 1340 |
|
<< this->GetID_RAW() << "', '" << idtimesync << "', '" << this->GetRootPath().Data() << "', '" << this->GetRootFile().Data() << "')"; |
| 1341 |
|
} else { |
| 1342 |
|
oss << "INSERT INTO GL_ROOT (ID_RAW, ID_TIMESYNC,PATH, NAME) VALUES ('" |
| 1343 |
|
<< this->GetID_RAW() << "', '" << idtimesync << "', '$PAM_L0', '" << this->GetRootFile().Data() << "')"; |
| 1344 |
|
}; |
| 1345 |
// |
// |
| 1346 |
if (conn->Query(oss.str().c_str()) == 0) throw -4; |
if (conn->Query(oss.str().c_str()) == 0) throw -4; |
| 1347 |
// |
// |
| 1368 |
TSQLResult *result = 0; |
TSQLResult *result = 0; |
| 1369 |
TSQLRow *row = 0; |
TSQLRow *row = 0; |
| 1370 |
oss.str(""); |
oss.str(""); |
| 1371 |
oss << "SELECT ID, BOOT_NUMBER FROM GL_RAW WHERE " |
if ( STATIC ){ |
| 1372 |
<< " PATH = '" << this->GetRawPath().Data() << "' AND " |
oss << "SELECT ID, BOOT_NUMBER FROM GL_RAW WHERE " |
| 1373 |
<< " NAME = '" << this->GetRawFile().Data() << "' "; |
<< " PATH = '" << this->GetRawPath().Data() << "' AND " |
| 1374 |
|
<< " NAME = '" << this->GetRawFile().Data() << "' "; |
| 1375 |
|
} else { |
| 1376 |
|
oss << "SELECT ID, BOOT_NUMBER FROM GL_RAW WHERE " |
| 1377 |
|
<< " PATH = '$PAM_RAW' AND " |
| 1378 |
|
<< " NAME = '" << this->GetRawFile().Data() << "' "; |
| 1379 |
|
}; |
| 1380 |
result = conn->Query(oss.str().c_str()); |
result = conn->Query(oss.str().c_str()); |
| 1381 |
// |
// |
| 1382 |
if ( !result ) throw -4;; |
if ( !result ) throw -4;; |