| 10 |
// |
// |
| 11 |
#include <TFile.h> |
#include <TFile.h> |
| 12 |
#include <TTree.h> |
#include <TTree.h> |
| 13 |
|
#include <TTimeStamp.h> |
| 14 |
#include <EventHeader.h> |
#include <EventHeader.h> |
| 15 |
#include <PscuHeader.h> |
#include <PscuHeader.h> |
| 16 |
// |
// |
| 154 |
obtfirst = 0; |
obtfirst = 0; |
| 155 |
pktfirst = 0; |
pktfirst = 0; |
| 156 |
toffset = 0; |
toffset = 0; |
| 157 |
ID = 0; |
// ID = 0; |
| 158 |
ID_RAW = 0; |
// ID_RAW = 0; |
| 159 |
OBT0 = 0; |
OBT0 = 0; |
| 160 |
TIMESYNC = 0; |
TIMESYNC = 0; |
| 161 |
TYPE = 0; |
TYPE = 0; |
| 862 |
if( Row == NULL ) break; |
if( Row == NULL ) break; |
| 863 |
// Set_GL_RUN(Row); |
// Set_GL_RUN(Row); |
| 864 |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
| 865 |
if (t== 0) ID = (UInt_t)atoll(Row->GetField(t)); |
if (t== 0) ID = (UInt_t)atoll(Row->GetField(t)); |
| 866 |
if (t== 1) ID_RUN_FRAG = (UInt_t)atoll(Row->GetField(t)); |
if (t== 1) ID_RUN_FRAG = (UInt_t)atoll(Row->GetField(t)); |
| 867 |
if (t== 2) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); |
if (t== 2) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); |
| 868 |
if (t== 3) ID_ROOT_L2 = (UInt_t)atoll(Row->GetField(t)); |
if (t== 3) ID_ROOT_L2 = (UInt_t)atoll(Row->GetField(t)); |
| 869 |
if (t== 4) RUNHEADER_TIME = (UInt_t)atoll(Row->GetField(t)); |
if (t== 4) RUNHEADER_TIME = (UInt_t)atoll(Row->GetField(t)); |
| 870 |
if (t== 5) RUNTRAILER_TIME = (UInt_t)atoll(Row->GetField(t)); |
if (t== 5) RUNTRAILER_TIME = (UInt_t)atoll(Row->GetField(t)); |
| 871 |
if (t== 6) RUNHEADER_OBT = (UInt_t)atoll(Row->GetField(t)); |
if (t== 6) RUNHEADER_OBT = (UInt_t)atoll(Row->GetField(t)); |
| 872 |
if (t== 7) RUNTRAILER_OBT = (UInt_t)atoll(Row->GetField(t)); |
if (t== 7) RUNTRAILER_OBT = (UInt_t)atoll(Row->GetField(t)); |
| 873 |
if (t== 8) RUNHEADER_PKT = (UInt_t)atoll(Row->GetField(t)); |
if (t== 8) RUNHEADER_PKT = (UInt_t)atoll(Row->GetField(t)); |
| 874 |
if (t== 9) RUNTRAILER_PKT = (UInt_t)atoll(Row->GetField(t)); |
if (t== 9) RUNTRAILER_PKT = (UInt_t)atoll(Row->GetField(t)); |
| 875 |
if (t==10) EV_FROM = (UInt_t)atoll(Row->GetField(t)); |
if (t==10) EV_FROM = (UInt_t)atoll(Row->GetField(t)); |
| 876 |
if (t==11) EV_TO = (UInt_t)atoll(Row->GetField(t)); |
if (t==11) EV_TO = (UInt_t)atoll(Row->GetField(t)); |
| 877 |
if (t==12) NEVENTS = (UInt_t)atoll(Row->GetField(t)); |
if (t==12) NEVENTS = (UInt_t)atoll(Row->GetField(t)); |
| 878 |
if (t==13) LAST_TIMESYNC = (UInt_t)atoll(Row->GetField(t)); |
if (t==13) LAST_TIMESYNC = (UInt_t)atoll(Row->GetField(t)); |
| 879 |
if (t==14) OBT_TIMESYNC = (UInt_t)atoll(Row->GetField(t)); |
if (t==14) OBT_TIMESYNC = (UInt_t)atoll(Row->GetField(t)); |
| 880 |
if (t==15) COMPILATIONTIMESTAMP = (UInt_t)atoll(Row->GetField(t)); |
if (t==15) COMPILATIONTIMESTAMP = (UInt_t)atoll(Row->GetField(t)); |
| 881 |
if (t==16) FAV_WRK_SCHEDULE = (UInt_t)atoll(Row->GetField(t)); |
if (t==16) FAV_WRK_SCHEDULE = (UInt_t)atoll(Row->GetField(t)); |
| 882 |
if (t==17) EFF_WRK_SCHEDULE = (UInt_t)atoll(Row->GetField(t)); |
if (t==17) EFF_WRK_SCHEDULE = (UInt_t)atoll(Row->GetField(t)); |
| 883 |
if (t==18) PRH_VAR_TRG_MODE_A= (UInt_t)atoll(Row->GetField(t)); |
if (t==18) PRH_VAR_TRG_MODE_A= (UInt_t)atoll(Row->GetField(t)); |
| 884 |
if (t==19) PRH_VAR_TRG_MODE_B= (UInt_t)atoll(Row->GetField(t)); |
if (t==19) PRH_VAR_TRG_MODE_B= (UInt_t)atoll(Row->GetField(t)); |
| 885 |
if (t==20) ACQ_BUILD_INFO = (UInt_t)atoll(Row->GetField(t)); |
if (t==20) ACQ_BUILD_INFO = (UInt_t)atoll(Row->GetField(t)); |
| 886 |
if (t==21) ACQ_VAR_INFO = (UInt_t)atoll(Row->GetField(t)); |
if (t==21) ACQ_VAR_INFO = (UInt_t)atoll(Row->GetField(t)); |
| 887 |
if (t==22) RM_ACQ_AFTER_CALIB= (UInt_t)atoll(Row->GetField(t)); |
if (t==22) RM_ACQ_AFTER_CALIB= (UInt_t)atoll(Row->GetField(t)); |
| 888 |
if (t==23) RM_ACQ_SETTING_MODE = (UInt_t)atoll(Row->GetField(t)); |
if (t==23) RM_ACQ_SETTING_MODE = (UInt_t)atoll(Row->GetField(t)); |
| 889 |
if (t==24) PKT_COUNTER = (UInt_t)atoll(Row->GetField(t)); |
if (t==24) PKT_COUNTER = (UInt_t)atoll(Row->GetField(t)); |
| 890 |
if (t==25) PKT_READY_COUNTER = (UInt_t)atoll(Row->GetField(t)); |
if (t==25) PKT_READY_COUNTER = (UInt_t)atoll(Row->GetField(t)); |
| 891 |
if (t==26) TRK_CALIB_USED = (UInt_t)atoll(Row->GetField(t)); |
if (t==26) TRK_CALIB_USED = (UInt_t)atoll(Row->GetField(t)); |
| 892 |
if (t==27) CAL_DSP_MASK = (UInt_t)atoll(Row->GetField(t)); |
if (t==27) CAL_DSP_MASK = (UInt_t)atoll(Row->GetField(t)); |
| 893 |
if (t==28) BOOT_NUMBER = (UInt_t)atoll(Row->GetField(t)); |
if (t==28) BOOT_NUMBER = (UInt_t)atoll(Row->GetField(t)); |
| 894 |
if (t==29) VALIDATION = (UInt_t)atoll(Row->GetField(t)); |
if (t==29) VALIDATION = (UInt_t)atoll(Row->GetField(t)); |
| 895 |
}; |
}; |
| 896 |
}; |
}; |
| 897 |
// delete pResult; |
// delete pResult; |
| 1304 |
// |
// |
| 1305 |
// look for Resurs offset |
// look for Resurs offset |
| 1306 |
// |
// |
| 1307 |
UInt_t t0 = 0; |
T0 = 0; |
| 1308 |
// |
// |
| 1309 |
// |
// |
| 1310 |
stringstream oss; |
stringstream oss; |
| 1347 |
}; |
}; |
| 1348 |
}; |
}; |
| 1349 |
// |
// |
| 1350 |
t0 = (UInt_t)TDatime(Row->GetField(0)).Convert(); |
// |
| 1351 |
// |
TDatime ti = TDatime(Row->GetField(0)); |
| 1352 |
// myquery.str(""); |
TTimeStamp tu = TTimeStamp((UInt_t)ti.GetYear(),(UInt_t)ti.GetMonth(),(UInt_t)ti.GetDay(),(UInt_t)ti.GetHour(),(UInt_t)ti.GetMinute(),(UInt_t)ti.GetSecond(),0,true,0); |
| 1353 |
// myquery << "SELECT OFFSET_DATE FROM GL_RESURS_OFFSET WHERE FROM_ID_RAW<= " |
T0 = (UInt_t)tu.GetSec(); |
|
// << idraw << " AND TO_ID_RAW >= " |
|
|
// << idraw << ";"; |
|
|
// pResult = dbc->Query(myquery.str().c_str()); |
|
|
// if ( pResult ){ |
|
|
// Row = pResult->Next(); |
|
|
// if ( Row ){ |
|
|
// // |
|
|
// t0 = (UInt_t)TDatime(Row->GetField(0)).Convert(); |
|
|
// // |
|
|
// }; |
|
|
// }; |
|
|
// |
|
| 1354 |
// |
// |
| 1355 |
// look for the correct timesync entry |
// look for the correct timesync entry |
| 1356 |
// |
// |
| 1357 |
myquery.str(""); |
myquery.str(""); |
| 1358 |
myquery << " SELECT OBT0,TIMESYNC FROM GL_TIMESYNC " |
myquery << " SELECT OBT0,TIMESYNC,TYPE FROM GL_TIMESYNC " |
| 1359 |
<< " WHERE ID_RAW = " << idraw |
<< " WHERE ID_RAW = " << idraw |
| 1360 |
<< ";"; |
<< ";"; |
| 1361 |
pResult = dbc->Query(myquery.str().c_str()); |
pResult = dbc->Query(myquery.str().c_str()); |
| 1362 |
if ( pResult ){ |
if ( pResult ){ |
| 1363 |
Row = pResult->Next(); |
Row = pResult->Next(); |
| 1364 |
if ( (Row != NULL) && ((UInt_t)atoll(Row->GetField(0)) > 0 ) ){ |
if ( (Row != NULL) && ((UInt_t)atoll(Row->GetField(0)) > 0 ) ){ |
| 1365 |
toffset = (UInt_t)atoll(Row->GetField(1)) - (UInt_t)(this->DBobt((UInt_t)atoll(Row->GetField(0)))/1000) + t0; |
OBT0 = (UInt_t)atoll(Row->GetField(0)); |
| 1366 |
|
TIMESYNC = (UInt_t)atoll(Row->GetField(1)); |
| 1367 |
|
TYPE = (UInt_t)atoll(Row->GetField(2)); |
| 1368 |
|
toffset = (UInt_t)atoll(Row->GetField(1)) - (UInt_t)(this->DBobt((UInt_t)atoll(Row->GetField(0)))/1000) + T0; |
| 1369 |
}; |
}; |
| 1370 |
}; |
}; |
| 1371 |
// |
// |
| 1384 |
// |
// |
| 1385 |
}; |
}; |
| 1386 |
|
|
| 1387 |
|
/** |
| 1388 |
|
* |
| 1389 |
|
* Returns the Resurs time given the OBT needed to process inclination and orbital infos |
| 1390 |
|
* |
| 1391 |
|
*/ |
| 1392 |
|
UInt_t GL_TIMESYNC::ResursTime(UInt_t OBT){ |
| 1393 |
|
// |
| 1394 |
|
return(((UInt_t)((this->DBobt(OBT)-this->DBobt(OBT0))/1000)+TIMESYNC)); |
| 1395 |
|
// |
| 1396 |
|
}; |
| 1397 |
|
|
| 1398 |
|
|
| 1399 |
ULong64_t GL_TIMESYNC::DBobt(UInt_t obt){ |
ULong64_t GL_TIMESYNC::DBobt(UInt_t obt){ |
| 1400 |
// |
// |
| 1438 |
*/ |
*/ |
| 1439 |
TString GL_TIMESYNC::ConvertTime(TString &tzone, UInt_t dbt){ |
TString GL_TIMESYNC::ConvertTime(TString &tzone, UInt_t dbt){ |
| 1440 |
// |
// |
| 1441 |
TDatime *time = new TDatime(); |
Int_t offset = 0; |
| 1442 |
TString rtime; |
TString rtime; |
| 1443 |
Bool_t found = false; |
Bool_t found = false; |
| 1444 |
// |
// |
|
time->Set(dbt,false); // UTC (Coordinated Universal Time) |
|
|
// |
|
| 1445 |
if ( !strcmp(tzone.Data(),"MSK") || !strcmp(tzone.Data(),"MWT") ){ |
if ( !strcmp(tzone.Data(),"MSK") || !strcmp(tzone.Data(),"MWT") ){ |
| 1446 |
// |
// |
| 1447 |
UInt_t timeMSK = time->Convert() + 60*60*3; // UTC (Coordinated Universal Time) + 3hs = Moscow Winter Time |
offset = 60*60*3; // UTC (Coordinated Universal Time) + 3hs = Moscow Winter Time |
|
time->Set(timeMSK,false); |
|
| 1448 |
found = true; |
found = true; |
| 1449 |
// |
// |
| 1450 |
}; |
}; |
| 1451 |
// |
// |
| 1452 |
if ( !strcmp(tzone.Data(),"CET") ){ |
if ( !strcmp(tzone.Data(),"CET") ){ |
| 1453 |
// |
// |
| 1454 |
UInt_t timeCET = time->Convert() + 60*60*1; // CET (Central European Time) = UTC + 1 hs |
offset = 60*60*1; // CET (Central European Time) = UTC + 1 hs |
|
time->Set(timeCET,false); |
|
| 1455 |
found = true; |
found = true; |
| 1456 |
// |
// |
| 1457 |
}; |
}; |
| 1458 |
// |
// |
| 1459 |
if ( !strcmp(tzone.Data(),"CEST") ){ |
if ( !strcmp(tzone.Data(),"CEST") ){ |
| 1460 |
// |
// |
| 1461 |
UInt_t timeCEST = time->Convert() + 60*60*2; // CEST (Central European Summer Time) = UTC + 2 h |
offset = 60*60*2; // CEST (Central European Summer Time) = UTC + 2 h |
|
time->Set(timeCEST,false); |
|
| 1462 |
found = true; |
found = true; |
| 1463 |
// |
// |
| 1464 |
}; |
}; |
| 1465 |
// |
// |
| 1466 |
if ( !strcmp(tzone.Data(),"MSD") || !strcmp(tzone.Data(),"MST")){ |
if ( !strcmp(tzone.Data(),"MSD") || !strcmp(tzone.Data(),"MST")){ |
| 1467 |
// |
// |
| 1468 |
UInt_t timeMSD = time->Convert() + 60*60*4; // MSD (Moscow Summer Time) = UTC + 4 h |
offset = 60*60*4; // MSD (Moscow Summer Time) = UTC + 4 h |
|
time->Set(timeMSD,false); |
|
| 1469 |
found = true; |
found = true; |
| 1470 |
// |
// |
| 1471 |
}; |
}; |
| 1475 |
tzone = "UTC"; |
tzone = "UTC"; |
| 1476 |
}; |
}; |
| 1477 |
// |
// |
| 1478 |
rtime = time->AsSQLString(); |
dbt += offset; |
| 1479 |
|
// |
| 1480 |
|
TTimeStamp *time = new TTimeStamp((time_t)dbt,0); |
| 1481 |
|
// |
| 1482 |
|
rtime = time->AsString("s"); |
| 1483 |
|
// |
| 1484 |
|
delete time; |
| 1485 |
// |
// |
| 1486 |
return(rtime); |
return(rtime); |
| 1487 |
} |
} |
| 1488 |
|
|
| 1489 |
/* |
/* |
| 1490 |
* |
* |
| 1491 |
* Convert the time in the DB from UInt_t to a string |
* Convert the time from TZONE to UTC |
| 1492 |
* |
* |
| 1493 |
* @param dbt time in the DB |
* @param dbt time in the DB |
| 1494 |
* @param tzone Time Zone, can be UTC,GMT,CET,CEST,MSD default is MSK |
* @param tzone Time Zone, can be UTC,GMT,CET,CEST,MSD default is MSK |
| 1496 |
*/ |
*/ |
| 1497 |
TString GL_TIMESYNC::UnConvertTime(TString &tzone, UInt_t dbt){ |
TString GL_TIMESYNC::UnConvertTime(TString &tzone, UInt_t dbt){ |
| 1498 |
// |
// |
| 1499 |
TDatime *time = new TDatime(); |
Int_t offset = 0; |
| 1500 |
TString rtime; |
TString rtime; |
| 1501 |
// |
// |
| 1502 |
Bool_t found = false; |
Bool_t found = false; |
| 1503 |
// |
// |
|
time->Set(dbt,false); // tzone |
|
|
// |
|
| 1504 |
if ( !strcmp(tzone.Data(),"MSK") || !strcmp(tzone.Data(),"MWT") ){ |
if ( !strcmp(tzone.Data(),"MSK") || !strcmp(tzone.Data(),"MWT") ){ |
| 1505 |
// |
// |
| 1506 |
UInt_t timeUTC = time->Convert() - 60*60*3; // UTC (Coordinated Universal Time) = Moscow Winter Time - 3hs |
offset = -60*60*3; // UTC (Coordinated Universal Time) = Moscow Winter Time - 3hs |
|
time->Set(timeUTC,false); |
|
| 1507 |
found = true; |
found = true; |
| 1508 |
// |
// |
| 1509 |
}; |
}; |
| 1510 |
// |
// |
| 1511 |
if ( !strcmp(tzone.Data(),"CET") ){ |
if ( !strcmp(tzone.Data(),"CET") ){ |
| 1512 |
// |
// |
| 1513 |
UInt_t timeCET = time->Convert() - 60*60*1; // CET (Central European Time) - 1 hs = UTC |
offset = -60*60*1; // CET (Central European Time) - 1 hs = UTC |
|
time->Set(timeCET,false); |
|
| 1514 |
found = true; |
found = true; |
| 1515 |
// |
// |
| 1516 |
}; |
}; |
| 1517 |
// |
// |
| 1518 |
if ( !strcmp(tzone.Data(),"CEST") ){ |
if ( !strcmp(tzone.Data(),"CEST") ){ |
| 1519 |
// |
// |
| 1520 |
UInt_t timeCEST = time->Convert() - 60*60*2; // CEST (Central European Summer Time) - 2 h = UTC |
offset = -60*60*2; // CEST (Central European Summer Time) - 2 h = UTC |
|
time->Set(timeCEST,false); |
|
| 1521 |
found = true; |
found = true; |
| 1522 |
// |
// |
| 1523 |
}; |
}; |
| 1524 |
// |
// |
| 1525 |
if ( !strcmp(tzone.Data(),"MSD") || !strcmp(tzone.Data(),"MST") ){ |
if ( !strcmp(tzone.Data(),"MSD") || !strcmp(tzone.Data(),"MST") ){ |
| 1526 |
// |
// |
| 1527 |
UInt_t timeMSD = time->Convert() - 60*60*4; // MSD (Moscow Summer Time) - 4 h = UTC |
offset = -60*60*4; // MSD (Moscow Summer Time) - 4 h = UTC |
|
time->Set(timeMSD,false); |
|
| 1528 |
found = true; |
found = true; |
| 1529 |
// |
// |
| 1530 |
}; |
}; |
| 1531 |
// |
// |
| 1532 |
if ( !found && strcmp(tzone.Data(),"UTC") && strcmp(tzone.Data(),"GMT") && strcmp(tzone.Data(),"") ){ |
if ( !found && strcmp(tzone.Data(),"UTC") && strcmp(tzone.Data(),"GMT") && strcmp(tzone.Data(),"") ){ |
| 1533 |
// |
// |
| 1534 |
|
offset = 0; |
| 1535 |
printf("\n Unknown time zone %s using UTC \n",tzone.Data()); |
printf("\n Unknown time zone %s using UTC \n",tzone.Data()); |
| 1536 |
tzone = "UTC"; |
tzone = "UTC"; |
| 1537 |
}; |
}; |
| 1538 |
// |
// |
| 1539 |
rtime = time->AsSQLString(); |
dbt += offset; |
| 1540 |
|
TTimeStamp *time = new TTimeStamp((time_t)dbt,0); |
| 1541 |
|
// |
| 1542 |
|
rtime = time->AsString("s"); |
| 1543 |
// |
// |
| 1544 |
return(rtime); |
return(rtime); |
| 1545 |
} |
} |