6 |
*/ |
*/ |
7 |
// |
// |
8 |
#include <sstream> |
#include <sstream> |
9 |
|
#include <iostream> |
10 |
// |
// |
11 |
#include <TFile.h> |
#include <TFile.h> |
12 |
#include <TTree.h> |
#include <TTree.h> |
14 |
#include <PscuHeader.h> |
#include <PscuHeader.h> |
15 |
// |
// |
16 |
#include <GLTables.h> |
#include <GLTables.h> |
17 |
|
#include <cTle.h> |
18 |
// |
// |
19 |
ClassImp(GL_TRK_CALIB); |
ClassImp(GL_TRK_CALIB); |
20 |
ClassImp(GL_RUN); |
ClassImp(GL_RUN); |
23 |
ClassImp(GL_S4_CALIB); |
ClassImp(GL_S4_CALIB); |
24 |
ClassImp(GL_CALO_CALIB); |
ClassImp(GL_CALO_CALIB); |
25 |
ClassImp(GL_TIMESYNC); |
ClassImp(GL_TIMESYNC); |
26 |
|
ClassImp(GL_TLE); |
27 |
// |
// |
28 |
using namespace std; |
using namespace std; |
29 |
|
|
158 |
OBT0 = 0; |
OBT0 = 0; |
159 |
TIMESYNC = 0; |
TIMESYNC = 0; |
160 |
TYPE = 0; |
TYPE = 0; |
161 |
}// **************************************************** |
} |
162 |
|
|
163 |
|
GL_TLE::GL_TLE(){ |
164 |
|
} |
165 |
|
|
166 |
|
// **************************************************** |
167 |
|
|
168 |
void GL_RUN::SetEV_FROM(UInt_t evfrom){ |
void GL_RUN::SetEV_FROM(UInt_t evfrom){ |
169 |
EV_FROM = evfrom; |
EV_FROM = evfrom; |
1230 |
// |
// |
1231 |
return(rtime); |
return(rtime); |
1232 |
} |
} |
1233 |
|
|
1234 |
|
|
1235 |
|
// **************************************************** |
1236 |
|
/** |
1237 |
|
* Function to query the GL_TLE table of the DB. |
1238 |
|
* |
1239 |
|
* time is the unix time for which a good tle is requested. |
1240 |
|
* |
1241 |
|
* Return the pointer to a cTle object that has the closest and |
1242 |
|
* previous date compared with time. |
1243 |
|
* |
1244 |
|
* If errors occurs it returns NULL. |
1245 |
|
*/ |
1246 |
|
cTle* GL_TLE::Query_GL_TLE(UInt_t time, TSQLServer *dbc){ |
1247 |
|
stringstream myquery; |
1248 |
|
myquery.str(""); |
1249 |
|
|
1250 |
|
myquery << "SELECT TLE1, TLE2, TLE3 FROM GL_TLE " |
1251 |
|
<< "WHERE FROM_TIME < FROM_UNIXTIME(" << time << ") ORDER BY FROM_TIME DESC LIMIT 1;"; |
1252 |
|
|
1253 |
|
|
1254 |
|
return Query_GL_TLE_go(myquery.str(), dbc); |
1255 |
|
} |
1256 |
|
|
1257 |
|
|
1258 |
|
// **************************************************** |
1259 |
|
/** |
1260 |
|
* Function to query the GL_TLE table of the DB. |
1261 |
|
* |
1262 |
|
* date is a datetime format YYYY-MM-DD hh:mm:ss for which a good tle |
1263 |
|
* is requested. |
1264 |
|
* |
1265 |
|
* Return the pointer to a cTle object that has the closest and |
1266 |
|
* previous date compared with time. |
1267 |
|
* |
1268 |
|
* If errors occurs it returns NULL. |
1269 |
|
*/ |
1270 |
|
cTle* GL_TLE::Query_GL_TLE(TString date, TSQLServer *dbc){ |
1271 |
|
stringstream myquery; |
1272 |
|
myquery.str(""); |
1273 |
|
|
1274 |
|
myquery << "SELECT TLE1, TLE2, TLE3 FROM GL_TLE " |
1275 |
|
<< "WHERE FROM_TIME < '" << date.Data() << "' ORDER BY FROM_TIME DESC LIMIT 1;"; |
1276 |
|
|
1277 |
|
|
1278 |
|
return Query_GL_TLE_go(myquery.str(), dbc); |
1279 |
|
} |
1280 |
|
|
1281 |
|
|
1282 |
|
// **************************************************** |
1283 |
|
/** |
1284 |
|
* Private function used by Query_GL_TLE methods. |
1285 |
|
* |
1286 |
|
* myquery is the query string. |
1287 |
|
* |
1288 |
|
* Return the pointer to a cTle object that has the closest and |
1289 |
|
* previous date compared with time. |
1290 |
|
* |
1291 |
|
* If errors occurs it returns NULL. |
1292 |
|
*/ |
1293 |
|
cTle* GL_TLE::Query_GL_TLE_go(TString myquery, TSQLServer *dbc){ |
1294 |
|
cTle *tle; |
1295 |
|
string tle1, tle2, tle3; |
1296 |
|
|
1297 |
|
// MySQL variables |
1298 |
|
TSQLResult *result; |
1299 |
|
TSQLRow *row; |
1300 |
|
|
1301 |
|
result = dbc->Query(myquery.Data()); |
1302 |
|
if(! result->GetRowCount() ) return NULL; |
1303 |
|
|
1304 |
|
row = result->Next(); |
1305 |
|
tle1 = row->GetField(0); |
1306 |
|
tle2 = row->GetField(1); |
1307 |
|
tle3 = row->GetField(2); |
1308 |
|
|
1309 |
|
tle = new cTle(tle1, tle2, tle3); |
1310 |
|
|
1311 |
|
delete result; |
1312 |
|
delete row; |
1313 |
|
|
1314 |
|
return tle; |
1315 |
|
} |