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 ( 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) ) return((Long64_t)(obt+numeric_limits<UInt_t>::max())); |
if ( obt < (pobtfirst/2) && pobtfirst > (numeric_limits<UInt_t>::max()/2) ) return((Long64_t)(obt+numeric_limits<UInt_t>::max())); |
888 |
// |
// |
889 |
if ( obt > (pobtfirst*2) && obt > (numeric_limits<UInt_t>::max()/2) ){ |
if ( obt > (pobtfirst*2) && obt > (numeric_limits<UInt_t>::max()/2) ){ |
1005 |
if ( idr ) return(1); |
if ( idr ) return(1); |
1006 |
// |
// |
1007 |
oss.str(""); |
oss.str(""); |
1008 |
oss << "INSERT INTO GL_RAW (PATH, NAME) VALUES ('" |
if ( STATIC ){ |
1009 |
<< this->GetRawPath().Data() << "', '" << this->GetRawFile().Data() << "')"; |
oss << "INSERT INTO GL_RAW (PATH, NAME) VALUES ('" |
1010 |
|
<< this->GetRawPath().Data() << "', '" << this->GetRawFile().Data() << "')"; |
1011 |
|
} else { |
1012 |
|
oss << "INSERT INTO GL_RAW (PATH, NAME) VALUES ('$PAM_RAW', '" << this->GetRawFile().Data() << "')"; |
1013 |
|
}; |
1014 |
if ( conn->Query(oss.str().c_str()) == 0 ) throw -4; |
if ( conn->Query(oss.str().c_str()) == 0 ) throw -4; |
1015 |
// |
// |
1016 |
idr = this->SetID_RAW(); |
idr = this->SetID_RAW(); |
1291 |
UInt_t idtimesync = 0; |
UInt_t idtimesync = 0; |
1292 |
// |
// |
1293 |
oss.str(""); |
oss.str(""); |
1294 |
oss << " SELECT COUNT(GL_ROOT.ID_RAW),GL_RAW.ID,GL_ROOT.ID FROM GL_RAW " |
if ( STATIC ){ |
1295 |
<< " LEFT JOIN GL_ROOT " |
oss << " SELECT COUNT(GL_ROOT.ID_RAW),GL_RAW.ID,GL_ROOT.ID FROM GL_RAW " |
1296 |
<< " ON GL_RAW.ID = GL_ROOT.ID_RAW " |
<< " LEFT JOIN GL_ROOT " |
1297 |
<< " WHERE GL_RAW.PATH = '" << this->GetRawPath().Data() << "' AND " |
<< " ON GL_RAW.ID = GL_ROOT.ID_RAW " |
1298 |
<< " GL_RAW.NAME = '" << this->GetRawFile().Data() << "' GROUP BY GL_RAW.ID "; |
<< " WHERE GL_RAW.PATH = '" << this->GetRawPath().Data() << "' AND " |
1299 |
|
<< " GL_RAW.NAME = '" << this->GetRawFile().Data() << "' GROUP BY GL_RAW.ID "; |
1300 |
|
} else { |
1301 |
|
oss << " SELECT COUNT(GL_ROOT.ID_RAW),GL_RAW.ID,GL_ROOT.ID FROM GL_RAW " |
1302 |
|
<< " LEFT JOIN GL_ROOT " |
1303 |
|
<< " ON GL_RAW.ID = GL_ROOT.ID_RAW " |
1304 |
|
<< " WHERE GL_RAW.PATH = '$PAM_RAW' AND " |
1305 |
|
<< " GL_RAW.NAME = '" << this->GetRawFile().Data() << "' GROUP BY GL_RAW.ID "; |
1306 |
|
}; |
1307 |
result = conn->Query(oss.str().c_str()); |
result = conn->Query(oss.str().c_str()); |
1308 |
// |
// |
1309 |
if ( !result ) throw -12; |
if ( !result ) throw -12; |
1330 |
idtimesync = (UInt_t)atoll(row->GetField(0)); |
idtimesync = (UInt_t)atoll(row->GetField(0)); |
1331 |
// |
// |
1332 |
oss.str(""); |
oss.str(""); |
1333 |
oss << "INSERT INTO GL_ROOT (ID_RAW, ID_TIMESYNC,PATH, NAME) VALUES ('" |
if ( STATIC ){ |
1334 |
<< this->GetID_RAW() << "', '" << idtimesync << "', '" << this->GetRootPath().Data() << "', '" << this->GetRootFile().Data() << "')"; |
oss << "INSERT INTO GL_ROOT (ID_RAW, ID_TIMESYNC,PATH, NAME) VALUES ('" |
1335 |
|
<< this->GetID_RAW() << "', '" << idtimesync << "', '" << this->GetRootPath().Data() << "', '" << this->GetRootFile().Data() << "')"; |
1336 |
|
} else { |
1337 |
|
oss << "INSERT INTO GL_ROOT (ID_RAW, ID_TIMESYNC,PATH, NAME) VALUES ('" |
1338 |
|
<< this->GetID_RAW() << "', '" << idtimesync << "', '$PAM_L0', '" << this->GetRootFile().Data() << "')"; |
1339 |
|
}; |
1340 |
// |
// |
1341 |
if (conn->Query(oss.str().c_str()) == 0) throw -4; |
if (conn->Query(oss.str().c_str()) == 0) throw -4; |
1342 |
// |
// |
1363 |
TSQLResult *result = 0; |
TSQLResult *result = 0; |
1364 |
TSQLRow *row = 0; |
TSQLRow *row = 0; |
1365 |
oss.str(""); |
oss.str(""); |
1366 |
oss << "SELECT ID, BOOT_NUMBER FROM GL_RAW WHERE " |
if ( STATIC ){ |
1367 |
<< " PATH = '" << this->GetRawPath().Data() << "' AND " |
oss << "SELECT ID, BOOT_NUMBER FROM GL_RAW WHERE " |
1368 |
<< " NAME = '" << this->GetRawFile().Data() << "' "; |
<< " PATH = '" << this->GetRawPath().Data() << "' AND " |
1369 |
|
<< " NAME = '" << this->GetRawFile().Data() << "' "; |
1370 |
|
} else { |
1371 |
|
oss << "SELECT ID, BOOT_NUMBER FROM GL_RAW WHERE " |
1372 |
|
<< " PATH = '$PAM_RAW' AND " |
1373 |
|
<< " NAME = '" << this->GetRawFile().Data() << "' "; |
1374 |
|
}; |
1375 |
result = conn->Query(oss.str().c_str()); |
result = conn->Query(oss.str().c_str()); |
1376 |
// |
// |
1377 |
if ( !result ) throw -4;; |
if ( !result ) throw -4;; |