14 |
#include <TSQLRow.h> |
#include <TSQLRow.h> |
15 |
#include <TTree.h> |
#include <TTree.h> |
16 |
#include <TGraph.h> |
#include <TGraph.h> |
17 |
#include <TDatime.h> |
#include <TTimeStamp.h> |
18 |
#include <TF1.h> |
#include <TF1.h> |
19 |
// |
// |
20 |
#include <EventHeader.h> |
#include <EventHeader.h> |
112 |
// |
// |
113 |
void PamelaDBOperations::CheckValidate(Long64_t olderthan){ |
void PamelaDBOperations::CheckValidate(Long64_t olderthan){ |
114 |
clean_time = new TDatime(); |
clean_time = new TDatime(); |
115 |
|
// |
116 |
if(olderthan >= 0){ |
if(olderthan >= 0){ |
117 |
VALIDATE = true; |
VALIDATE = true; |
118 |
UInt_t timelim = 0; |
UInt_t timelim = 0; |
119 |
timelim = (UInt_t)clean_time->Convert() - olderthan; |
timelim = (UInt_t)clean_time->Convert(true) - olderthan; |
120 |
clean_time->Set(timelim,false); |
clean_time->Set(timelim,false); |
121 |
}; |
}; |
122 |
}; |
}; |
765 |
bool connect = conn->IsConnected(); |
bool connect = conn->IsConnected(); |
766 |
if( !connect ) throw -1; |
if( !connect ) throw -1; |
767 |
if ( !dworbit && strcmp(this->GetRootName().Data(),"") ) throw -27; |
if ( !dworbit && strcmp(this->GetRootName().Data(),"") ) throw -27; |
768 |
|
// |
769 |
|
// set DB timezone to UTC |
770 |
|
// |
771 |
|
stringstream oss; |
772 |
|
// |
773 |
|
oss.str(""); |
774 |
|
oss << "SET time_zone='+0:00';"; |
775 |
|
TSQLResult *result = 0; |
776 |
|
result = conn->Query(oss.str().c_str()); |
777 |
|
if ( !result ) throw -10; |
778 |
|
// |
779 |
}; |
}; |
780 |
|
|
781 |
/** |
/** |
955 |
if ( this->GetID_RAW() == 0 ) throw -11; |
if ( this->GetID_RAW() == 0 ) throw -11; |
956 |
// |
// |
957 |
oss.str(""); |
oss.str(""); |
958 |
oss << "SELECT OFFSET_DATE FROM GL_RESURS_OFFSET WHERE SPECIAL_FILE='" |
oss << "SELECT YEAR(OFFSET_DATE),MONTH(OFFSET_DATE),DAY(OFFSET_DATE),HOUR(OFFSET_DATE),MINUTE(OFFSET_DATE),SECOND(OFFSET_DATE) FROM GL_RESURS_OFFSET WHERE SPECIAL_FILE='" |
959 |
<< this->GetRawFile().Data() << "';"; |
<< this->GetRawFile().Data() << "';"; |
960 |
if ( IsDebug() ) printf(" %s \n",oss.str().c_str()); |
if ( IsDebug() ) printf(" %s \n",oss.str().c_str()); |
961 |
result = conn->Query(oss.str().c_str()); |
result = conn->Query(oss.str().c_str()); |
964 |
// |
// |
965 |
if ( !row ){ |
if ( !row ){ |
966 |
oss.str(""); |
oss.str(""); |
967 |
oss << "SELECT OFFSET_DATE FROM GL_RESURS_OFFSET WHERE FROM_ORBIT< " |
oss << "SELECT YEAR(OFFSET_DATE),MONTH(OFFSET_DATE),DAY(OFFSET_DATE),HOUR(OFFSET_DATE),MINUTE(OFFSET_DATE),SECOND(OFFSET_DATE) FROM GL_RESURS_OFFSET WHERE FROM_ORBIT< " |
968 |
<< dworbit << " order by FROM_ORBIT desc limit 1;"; |
<< dworbit << " order by FROM_ORBIT desc limit 1;"; |
969 |
if ( IsDebug() ) printf(" %s \n",oss.str().c_str()); |
if ( IsDebug() ) printf(" %s \n",oss.str().c_str()); |
970 |
result = conn->Query(oss.str().c_str()); |
result = conn->Query(oss.str().c_str()); |
973 |
if ( !row ) throw -10; |
if ( !row ) throw -10; |
974 |
}; |
}; |
975 |
// |
// |
976 |
t0 = (UInt_t)TDatime(row->GetField(0)).Convert(); |
TTimeStamp tu = TTimeStamp((UInt_t)atoi(row->GetField(0)),(UInt_t)atoi(row->GetField(1)),(UInt_t)atoi(row->GetField(2)),(UInt_t)atoi(row->GetField(3)),(UInt_t)atoi(row->GetField(4)),(UInt_t)atoi(row->GetField(5)),0,true,0); |
977 |
|
t0 = (UInt_t)tu.GetSec(); |
978 |
|
if ( IsDebug() ) printf(" t0 is %u ti is %s %s %s %s %s %s\n",t0,row->GetField(0),row->GetField(1),row->GetField(2),row->GetField(3),row->GetField(4),row->GetField(5)); |
979 |
|
// |
980 |
/* |
/* |
981 |
* Verify that the TIMESYNC have been not already processed |
* Verify that the TIMESYNC have been not already processed |
982 |
*/ |
*/ |
991 |
if (result == NULL) throw -10; |
if (result == NULL) throw -10; |
992 |
row = result->Next(); |
row = result->Next(); |
993 |
if ((row != NULL) && ((UInt_t)atoll(row->GetField(0)) > 0)){ |
if ((row != NULL) && ((UInt_t)atoll(row->GetField(0)) > 0)){ |
994 |
|
if ( IsDebug() ) printf(" found a timesync t0 is %u \n",t0); |
995 |
toffset = (UInt_t)atoll(row->GetField(2)) - (UInt_t)(this->OBT((UInt_t)atoll(row->GetField(1)))/1000) + t0; |
toffset = (UInt_t)atoll(row->GetField(2)) - (UInt_t)(this->OBT((UInt_t)atoll(row->GetField(1)))/1000) + t0; |
996 |
return(1); |
return(1); |
997 |
}; |
}; |
1186 |
conn->Query(oss.str().c_str()); |
conn->Query(oss.str().c_str()); |
1187 |
if ( IsDebug() ) printf(" Query the GL_TIMESYNC table to fill it:\n %s \n",oss.str().c_str()); |
if ( IsDebug() ) printf(" Query the GL_TIMESYNC table to fill it:\n %s \n",oss.str().c_str()); |
1188 |
// |
// |
1189 |
|
if ( IsDebug() ) printf(" found a timesync t0 is %u \n",t0); |
1190 |
toffset = (UInt_t)TSYNC - (UInt_t)(this->OBT(OBT)/1000) + t0; |
toffset = (UInt_t)TSYNC - (UInt_t)(this->OBT(OBT)/1000) + t0; |
1191 |
// |
// |
1192 |
delete result; |
delete result; |
1293 |
Bool_t found = false; |
Bool_t found = false; |
1294 |
for ( Int_t i = 0; i < trDumpEv->GetEntries(); i++){ |
for ( Int_t i = 0; i < trDumpEv->GetEntries(); i++){ |
1295 |
trDumpEv->GetEntry(i); |
trDumpEv->GetEntry(i); |
1296 |
vde->Records->GetEntries(); |
// vde->Records->GetEntries(); |
1297 |
if ( vde->Records->GetEntries()>0 ){ |
if ( vde->Records->GetEntries()>5 ){ |
1298 |
found = true; |
found = true; |
1299 |
goto fill; |
goto fill; |
1300 |
}; |
}; |
2749 |
// no calibrations in the db contain our calibration |
// no calibrations in the db contain our calibration |
2750 |
// |
// |
2751 |
if ( IsDebug() ) printf(" Calibration with fromtime lower than others to be inserted in the DB for section %i \n",section); |
if ( IsDebug() ) printf(" Calibration with fromtime lower than others to be inserted in the DB for section %i \n",section); |
2752 |
if ( fromtime < 1150863400 ){ |
if ( fromtime < 1150871000 ){ //1150866904 |
2753 |
if ( IsDebug() ) printf(" First PAMELA flight calibration at time %i \n",fromtime); |
if ( IsDebug() ) printf(" First PAMELA flight calibration at time %i \n",fromtime); |
2754 |
fromtime = 0;// the first flight calibration was taken at about 1156429100 s, this line allow to analyze first runs in raw mode |
fromtime = 0;// the first flight calibration was taken at about 1156429100 s, this line allow to analyze first runs in raw mode |
2755 |
}; |
}; |
2894 |
// no calibrations in the db contain our calibration |
// no calibrations in the db contain our calibration |
2895 |
// |
// |
2896 |
if ( IsDebug() ) printf(" Calibration with fromtime lower than others to be inserted in the DB\n"); |
if ( IsDebug() ) printf(" Calibration with fromtime lower than others to be inserted in the DB\n"); |
2897 |
if ( fromtime < 1150863400 ) fromtime = 0; // the first flight calibration was taken at about 1150863300 s, this line allows to analyze first runs in raw mode |
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 |
2898 |
// |
// |
2899 |
oss.str(""); |
oss.str(""); |
2900 |
oss << " SELECT FROM_TIME FROM GL_TRK_CALIB WHERE " |
oss << " SELECT FROM_TIME FROM GL_TRK_CALIB WHERE " |
3250 |
// no calibrations in the db contain our calibration |
// no calibrations in the db contain our calibration |
3251 |
// |
// |
3252 |
if ( IsDebug() ) printf(" Calibration with fromtime lower than others to be inserted in the DB \n"); |
if ( IsDebug() ) printf(" Calibration with fromtime lower than others to be inserted in the DB \n"); |
3253 |
if ( fromtime < 1150863400 ){ |
if ( fromtime < 1150871000 ){ |
3254 |
if ( IsDebug() ) printf(" First PAMELA flight calibration at time %i \n",fromtime); |
if ( IsDebug() ) printf(" First PAMELA flight calibration at time %i \n",fromtime); |
3255 |
fromtime = 0;// the first flight calibration was taken at about 1156429100 s, this line allow to analyze first runs in raw mode |
fromtime = 0;// the first flight calibration was taken at about 1156429100 s, this line allow to analyze first runs in raw mode |
3256 |
}; |
}; |