7 |
// |
// |
8 |
#include <sstream> |
#include <sstream> |
9 |
#include <iostream> |
#include <iostream> |
10 |
|
#include <limits.h> |
11 |
// |
// |
12 |
#include <TFile.h> |
#include <TFile.h> |
13 |
#include <TTree.h> |
#include <TTree.h> |
18 |
#include <GLTables.h> |
#include <GLTables.h> |
19 |
#include <sgp4.h> |
#include <sgp4.h> |
20 |
// |
// |
21 |
|
ClassImp(Q2TH); |
22 |
ClassImp(GL_TABLES); |
ClassImp(GL_TABLES); |
23 |
ClassImp(GL_TRK_CALIB); |
ClassImp(GL_TRK_CALIB); |
24 |
ClassImp(GL_RUN); |
ClassImp(GL_RUN); |
32 |
// |
// |
33 |
using namespace std; |
using namespace std; |
34 |
|
|
35 |
|
Q2TH::Q2TH(TString host, TString user, TString psw){ |
36 |
|
this->Open(host,user,psw); |
37 |
|
}; |
38 |
|
|
39 |
|
void Q2TH::Open(TString host, TString user, TString psw){ |
40 |
|
fh = gSystem->ExpandPathName(host.Data()); |
41 |
|
fu = gSystem->ExpandPathName(user.Data()); |
42 |
|
fp = gSystem->ExpandPathName(psw.Data()); |
43 |
|
printf(" Connecting to DB %s \n",fh.Data()); |
44 |
|
dbc = TSQLServer::Connect(fh.Data(),fu.Data(),fp.Data()); |
45 |
|
if ( dbc && dbc->IsConnected() ){ |
46 |
|
printf(" connected! \n"); |
47 |
|
} else { |
48 |
|
printf(" ERROR! not connected... :( \n"); |
49 |
|
}; |
50 |
|
}; |
51 |
|
|
52 |
|
TObject *Q2TH::Draw(TString query, Bool_t verbose, TString hname){ |
53 |
|
// |
54 |
|
if ( !strcmp(query.Data(),"help") ){ |
55 |
|
printf(" USAGE: \n"); |
56 |
|
printf(" 1) start root and create Q2TH object with \n"); |
57 |
|
printf(" Q2TH *qt = new Q2TH() \n"); |
58 |
|
printf(" or \n"); |
59 |
|
printf(" Q2TH *qt = new Q2TH(\"mysql://srvg-g2-01.ts.infn.it/pamelaProcessing9_TS\",\"pamelaprod_ro\",\"mypassword\") \n"); |
60 |
|
printf(" 2) query the DB with \n"); |
61 |
|
printf(" qt->Draw(\"select REAL_TIME_INIT,BAD_PKT_PERCENTAGE from ROOT_TABLE_MERGING;\"); \n"); |
62 |
|
printf(" qt->Draw(\"select REAL_TIME_INIT,BAD_PKT_PERCENTAGE from ROOT_TABLE_MERGING;\",true); this will print numbers on screen \n"); |
63 |
|
printf(" qt->Draw(\"select REAL_TIME_INIT from ROOT_TABLE_MERGING;\",true,\"myhisto\"); this will print numbers on screen and create histo \"myhisto\"\n"); |
64 |
|
printf(" 3) to use your own THxD create it and then query the DB giving as argument the name of histo: \n"); |
65 |
|
printf(" TH2D *myhisto=new TH2D(\"myhisto\",\"myhisto\",5000,1140000000.,1240000000.,10000,0.,1.) \n"); |
66 |
|
printf(" qt->Draw(\"select REAL_TIME_INIT,BAD_PKT_PERCENTAGE from ROOT_TABLE_MERGING;\",false,\"myhisto\")\n\n\n"); |
67 |
|
|
68 |
|
return NULL; |
69 |
|
}; |
70 |
|
// |
71 |
|
if (Row) |
72 |
|
delete Row; |
73 |
|
pResult = dbc->Query(query.Data()); |
74 |
|
// |
75 |
|
Row = pResult->Next(); |
76 |
|
// |
77 |
|
Int_t dim = pResult->GetFieldCount(); |
78 |
|
if ( dim < 1 || dim > 2 ){ |
79 |
|
printf(" Dim == %i not supported yet \n",dim); |
80 |
|
return NULL; |
81 |
|
}; |
82 |
|
// |
83 |
|
TH1D *h1 = NULL; |
84 |
|
TH2D *h2 = NULL; |
85 |
|
Double_t f1 = 0.; |
86 |
|
Double_t minf1 = numeric_limits<Double_t>::max(); |
87 |
|
Double_t maxf1 = numeric_limits<Double_t>::min(); |
88 |
|
Double_t f2 = 0.; |
89 |
|
Double_t minf2 = numeric_limits<Double_t>::max(); |
90 |
|
Double_t maxf2 = numeric_limits<Double_t>::min(); |
91 |
|
// |
92 |
|
while ( Row ){ |
93 |
|
f1 = (Double_t)atof(Row->GetField(0)); |
94 |
|
if ( f1 > maxf1 ) maxf1 = f1; |
95 |
|
if ( f1 < minf1 ) minf1 = f1; |
96 |
|
if ( dim == 2 ){ |
97 |
|
f2 = (Double_t)atof(Row->GetField(1)); |
98 |
|
if ( f2 > maxf2 ) maxf2 = f2; |
99 |
|
if ( f2 < minf2 ) minf2 = f2; |
100 |
|
|
101 |
|
}; |
102 |
|
if (Row) |
103 |
|
delete Row; |
104 |
|
Row = pResult->Next(); |
105 |
|
}; |
106 |
|
pResult->Delete(); |
107 |
|
// |
108 |
|
|
109 |
|
// |
110 |
|
Int_t f1bin = 70; |
111 |
|
Int_t f2bin = 70; |
112 |
|
if ( dim == 1 ){ |
113 |
|
f1bin = int((maxf1-minf1)/1000.); |
114 |
|
if ( f1bin < 70 ) f1bin = 70; |
115 |
|
if ( f1bin > 1000 ) f1bin = 1000; |
116 |
|
if ( !strcmp(hname.Data(),"q2th") ) hname += "1"; |
117 |
|
// h1 = dynamic_cast<TH1D*>(gDirectory->FindObject(hname.Data())); |
118 |
|
h1 = (TH1D*)(gDirectory->FindObject(hname.Data())); |
119 |
|
if ( !strcmp(hname.Data(),"q2th1") ){ |
120 |
|
if ( h1 ) h1->Delete(); |
121 |
|
}; |
122 |
|
if ( !h1 ) h1 = new TH1D(hname.Data(),hname.Data(),f1bin,minf1*0.98,maxf1*1.02); |
123 |
|
// h1->SetBit(TH1::kCanRebin); |
124 |
|
if ( verbose ) printf("\n\n Row %s \n",pResult->GetFieldName(0)); |
125 |
|
}; |
126 |
|
if ( dim == 2 ){ |
127 |
|
f2bin = int((maxf2-minf2)/1000.); |
128 |
|
if ( f2bin < 70 ) f2bin = 70; |
129 |
|
if ( f2bin > 1000 ) f2bin = 1000; |
130 |
|
if ( !strcmp(hname.Data(),"q2th") ) hname += "2"; |
131 |
|
// h2 = dynamic_cast<TH2D*>(gDirectory->FindObject(hname.Data())); |
132 |
|
h2 = (TH2D*)(gDirectory->FindObject(hname.Data())); |
133 |
|
if ( !strcmp(hname.Data(),"q2th2") ){ |
134 |
|
if ( h2 ) h2->Delete(); |
135 |
|
}; |
136 |
|
if ( !h2 ) h2 = new TH2D(hname.Data(),hname.Data(),f1bin,minf1*0.98,maxf1*1.02,f2bin,minf2*0.98,maxf2*1.02); |
137 |
|
// h2->SetBit(TH2::kCanRebin); |
138 |
|
if ( verbose ) printf("\n\n Row %s %s \n",pResult->GetFieldName(0),pResult->GetFieldName(1)); |
139 |
|
}; |
140 |
|
// |
141 |
|
pResult = dbc->Query(query.Data()); |
142 |
|
// |
143 |
|
if (Row) |
144 |
|
delete Row; |
145 |
|
Row = pResult->Next(); |
146 |
|
// |
147 |
|
Int_t r = 0; |
148 |
|
// |
149 |
|
while ( Row ){ |
150 |
|
f1 = (Double_t)atof(Row->GetField(0)); |
151 |
|
if ( dim == 1 ){ |
152 |
|
if ( verbose ) printf(" %i %f \n",r,f1); |
153 |
|
h1->Fill(f1); |
154 |
|
} else { |
155 |
|
f2 = (Double_t)atof(Row->GetField(1)); |
156 |
|
if ( verbose ) printf(" %i %f %f \n",r,f1,f2); |
157 |
|
h2->Fill(f1,f2); |
158 |
|
}; |
159 |
|
r++; |
160 |
|
if (Row) |
161 |
|
delete Row; |
162 |
|
Row = pResult->Next(); |
163 |
|
}; |
164 |
|
// |
165 |
|
TCanvas *c = NULL; |
166 |
|
TString cname = Form("%sc",hname.Data()); |
167 |
|
// c = dynamic_cast<TCanvas*>(gDirectory->FindObject(hname.Data())); |
168 |
|
c = (TCanvas*)(gDirectory->FindObject(cname.Data())); |
169 |
|
if ( !c ) c = new TCanvas(Form("%sc",cname.Data())); |
170 |
|
c->Clear(); |
171 |
|
c->cd(); |
172 |
|
if ( dim == 1 ) h1->Draw(); |
173 |
|
if ( dim == 2 ) h2->Draw(); |
174 |
|
// |
175 |
|
if (Row) |
176 |
|
delete Row; |
177 |
|
pResult->Delete(); |
178 |
|
if ( dim == 1 ) return h1; |
179 |
|
if ( dim == 2 ) return h2; |
180 |
|
// |
181 |
|
return NULL; |
182 |
|
}; |
183 |
|
|
184 |
GL_TABLES::GL_TABLES(){ |
GL_TABLES::GL_TABLES(){ |
185 |
}; |
}; |
186 |
|
|
207 |
mp = psw.Data(); |
mp = psw.Data(); |
208 |
}; |
}; |
209 |
|
|
210 |
Bool_t GL_TABLES::IsConnected(TSQLServer *&dbc){ |
//Bool_t GL_TABLES::IsConnected(TSQLServer *&dbc){ |
211 |
|
Bool_t GL_TABLES::IsConnected(TSQLServer *dbc){ |
212 |
// |
// |
213 |
// |
// |
214 |
// |
// |
223 |
myquery << "show databases;"; |
myquery << "show databases;"; |
224 |
if ( dbc ){ |
if ( dbc ){ |
225 |
if ( dbc->IsConnected() ){ |
if ( dbc->IsConnected() ){ |
226 |
dbc->Query(myquery.str().c_str()); |
delete dbc->Query(myquery.str().c_str()); |
227 |
fNquery++; |
fNquery++; |
228 |
if ( !(dbc->GetErrorCode()) ){ |
if ( !(dbc->GetErrorCode()) ){ |
229 |
// printf("ok\n"); |
// printf("ok\n"); |
244 |
TString host = fHost->Data(); |
TString host = fHost->Data(); |
245 |
TString user = fUser->Data(); |
TString user = fUser->Data(); |
246 |
TString psw = fPsw->Data(); |
TString psw = fPsw->Data(); |
247 |
dbc->Close(); |
if ( dbc ){ |
248 |
delete dbc; |
dbc->Close(); |
249 |
|
delete dbc; |
250 |
|
dbc = 0; |
251 |
|
}; |
252 |
dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
253 |
// |
// |
254 |
myquery.str(""); |
myquery.str(""); |
255 |
myquery << "show databases;"; |
myquery << "show databases;"; |
256 |
dbc->Query(myquery.str().c_str()); |
delete dbc->Query(myquery.str().c_str()); |
257 |
fNquery++; |
fNquery++; |
258 |
// if ( dbc->GetErrorCode() != 2013 && dbc->GetErrorCode() != 2006 ){ |
// if ( dbc->GetErrorCode() != 2013 && dbc->GetErrorCode() != 2006 ){ |
259 |
if ( !(dbc->GetErrorCode()) ){ |
if ( !(dbc->GetErrorCode()) ){ |
261 |
printf(" ...connection recovered, I can continue! \n"); |
printf(" ...connection recovered, I can continue! \n"); |
262 |
// |
// |
263 |
myquery.str(""); |
myquery.str(""); |
264 |
myquery << "SET time_zone='+0:00'"; |
myquery << "SET time_zone='+0:00';"; |
265 |
dbc->Query(myquery.str().c_str()); |
delete dbc->Query(myquery.str().c_str()); |
266 |
|
fNquery++; |
267 |
|
myquery.str(""); |
268 |
|
myquery << "SET sql_mode = 'NO_UNSIGNED_SUBTRACTION';"; |
269 |
|
delete dbc->Query(myquery.str().c_str()); |
270 |
fNquery++; |
fNquery++; |
271 |
myquery.str(""); |
myquery.str(""); |
272 |
myquery << "SET wait_timeout=173000;"; |
myquery << "SET wait_timeout=173000;"; |
273 |
dbc->Query(myquery.str().c_str()); |
delete dbc->Query(myquery.str().c_str()); |
274 |
fNquery++; |
fNquery++; |
275 |
return true; |
return true; |
276 |
}; |
}; |
377 |
NAME = ""; |
NAME = ""; |
378 |
} |
} |
379 |
|
|
380 |
|
GL_RAW::GL_RAW(){ |
381 |
|
ID = 0; |
382 |
|
PATH = ""; |
383 |
|
NAME = ""; |
384 |
|
BOOT_NUMBER = 0; |
385 |
|
} |
386 |
|
|
387 |
GL_PARAM::GL_PARAM(){ |
GL_PARAM::GL_PARAM(){ |
388 |
ID = 0; |
ID = 0; |
389 |
PATH = ""; |
PATH = ""; |
689 |
Int_t GL_RUN::DeleteRun(TSQLServer *dbc,UInt_t IDRUN,TString FromTable){ |
Int_t GL_RUN::DeleteRun(TSQLServer *dbc,UInt_t IDRUN,TString FromTable){ |
690 |
// MySQL variables |
// MySQL variables |
691 |
TSQLResult *pResult; |
TSQLResult *pResult; |
692 |
TSQLRow *Row; |
TSQLRow *Row = NULL; |
693 |
stringstream myquery; |
stringstream myquery; |
694 |
// |
// |
695 |
if ( !IDRUN ) IDRUN = ID; |
if ( !IDRUN ) IDRUN = ID; |
739 |
// |
// |
740 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
741 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
742 |
dbc->Query(myquery.str().c_str()); |
delete dbc->Query(myquery.str().c_str()); |
743 |
// |
// |
744 |
// retrieve this ID_TRASH |
// retrieve this ID_TRASH |
745 |
// |
// |
753 |
UInt_t idl0 = 0; |
UInt_t idl0 = 0; |
754 |
UInt_t idl2 = 0; |
UInt_t idl2 = 0; |
755 |
// |
// |
756 |
|
if (Row) |
757 |
|
delete Row; |
758 |
Row = pResult->Next(); |
Row = pResult->Next(); |
759 |
if( Row != NULL ){ |
if( Row != NULL ){ |
760 |
idtrash = (UInt_t)atoll(Row->GetField(0)); |
idtrash = (UInt_t)atoll(Row->GetField(0)); |
770 |
// |
// |
771 |
// printf("2myquery is %s \n",myquery.str().c_str()); |
// printf("2myquery is %s \n",myquery.str().c_str()); |
772 |
// |
// |
773 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
if ( !this->GetGLTABLES()->IsConnected(dbc) ){ |
774 |
|
if (pResult) |
775 |
|
delete pResult; |
776 |
|
if (Row) |
777 |
|
delete Row; |
778 |
|
return -57; |
779 |
|
} |
780 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
781 |
pResult = dbc->Query(myquery.str().c_str()); |
pResult = dbc->Query(myquery.str().c_str()); |
782 |
// |
// |
783 |
|
if (Row) |
784 |
|
delete Row; |
785 |
Row = pResult->Next(); |
Row = pResult->Next(); |
786 |
if( Row != NULL ){ |
if( Row != NULL ){ |
787 |
fileL0 = (TString)Row->GetField(0); |
fileL0 = (TString)Row->GetField(0); |
795 |
// |
// |
796 |
// printf("3myquery is %s \n",myquery.str().c_str()); |
// printf("3myquery is %s \n",myquery.str().c_str()); |
797 |
// |
// |
798 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
if ( !this->GetGLTABLES()->IsConnected(dbc) ){ |
799 |
|
if (pResult) |
800 |
|
delete pResult; |
801 |
|
if (Row) |
802 |
|
delete Row; |
803 |
|
return -57; |
804 |
|
} |
805 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
806 |
pResult = dbc->Query(myquery.str().c_str()); |
pResult = dbc->Query(myquery.str().c_str()); |
807 |
// |
// |
808 |
|
if (Row) |
809 |
|
delete Row; |
810 |
Row = pResult->Next(); |
Row = pResult->Next(); |
811 |
if( Row != NULL ){ |
if( Row != NULL ){ |
812 |
fileL2 = (TString)Row->GetField(0); |
fileL2 = (TString)Row->GetField(0); |
813 |
}; |
} |
814 |
|
delete pResult; |
815 |
|
pResult = NULL; |
816 |
|
if (Row){ |
817 |
|
delete Row; |
818 |
|
Row = NULL; // This variable is not used below |
819 |
|
} |
820 |
// |
// |
821 |
// |
// |
822 |
// |
// |
829 |
// |
// |
830 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
831 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
832 |
dbc->Query(myquery.str().c_str()); |
delete dbc->Query(myquery.str().c_str()); |
833 |
// |
// |
834 |
myquery.str(""); |
myquery.str(""); |
835 |
myquery << " UPDATE GL_RUN_TRASH SET FILENAMEL2='"; |
myquery << " UPDATE GL_RUN_TRASH SET FILENAMEL2='"; |
840 |
// |
// |
841 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
842 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
843 |
dbc->Query(myquery.str().c_str()); |
delete dbc->Query(myquery.str().c_str()); |
844 |
// |
// |
845 |
myquery.str(""); |
myquery.str(""); |
846 |
myquery << " UPDATE GL_RUN_TRASH SET BELONGED_TO='"; |
myquery << " UPDATE GL_RUN_TRASH SET BELONGED_TO='"; |
852 |
// |
// |
853 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
854 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
855 |
dbc->Query(myquery.str().c_str()); |
delete dbc->Query(myquery.str().c_str()); |
856 |
// |
// |
857 |
myquery.str(""); |
myquery.str(""); |
858 |
myquery << " DELETE FROM "; |
myquery << " DELETE FROM "; |
864 |
// |
// |
865 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
866 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
867 |
dbc->Query(myquery.str().c_str()); |
delete dbc->Query(myquery.str().c_str()); |
868 |
// |
// |
869 |
return 0; |
return 0; |
870 |
}; |
}; |
880 |
// insert into GL_RUN_FRAGMENTS select * FROM GL_RUN where ID=11; |
// insert into GL_RUN_FRAGMENTS select * FROM GL_RUN where ID=11; |
881 |
//insert into GL_RUN_TRASH VALUES (ID , ID_RUN_FRAG , ID_ROOT_L0 , ID_ROOT_L2 , RUNHEADER_TIME , RUNTRAILER_TIME , RUNHEADER_OBT , RUNTRAILER_OBT , RUNHEADER_PKT , RUNTRAILER_PKT , BOOT_NUMBER , EV_FROM , EV_TO , NEVENTS , PKT_COUNTER , PKT_READY_COUNTER , COMPILATIONTIMESTAMP , FAV_WRK_SCHEDULE , EFF_WRK_SCHEDULE , PRH_VAR_TRG_MODE_A , PRH_VAR_TRG_MODE_B , ACQ_BUILD_INFO , ACQ_VAR_INFO , RM_ACQ_AFTER_CALIB , RM_ACQ_SETTING_MODE, TRK_CALIB_USED,CAL_DSP_MASK, LAST_TIMESYNC, OBT_TIMESYNC, VALIDATION, INSERT_TIME) select * FROM GL_RUN where ID=11; |
//insert into GL_RUN_TRASH VALUES (ID , ID_RUN_FRAG , ID_ROOT_L0 , ID_ROOT_L2 , RUNHEADER_TIME , RUNTRAILER_TIME , RUNHEADER_OBT , RUNTRAILER_OBT , RUNHEADER_PKT , RUNTRAILER_PKT , BOOT_NUMBER , EV_FROM , EV_TO , NEVENTS , PKT_COUNTER , PKT_READY_COUNTER , COMPILATIONTIMESTAMP , FAV_WRK_SCHEDULE , EFF_WRK_SCHEDULE , PRH_VAR_TRG_MODE_A , PRH_VAR_TRG_MODE_B , ACQ_BUILD_INFO , ACQ_VAR_INFO , RM_ACQ_AFTER_CALIB , RM_ACQ_SETTING_MODE, TRK_CALIB_USED,CAL_DSP_MASK, LAST_TIMESYNC, OBT_TIMESYNC, VALIDATION, INSERT_TIME) select * FROM GL_RUN where ID=11; |
882 |
// MySQL variables |
// MySQL variables |
883 |
TSQLResult *pResult; |
TSQLResult *pResult = NULL; |
884 |
TSQLRow *Row; |
TSQLRow *Row = NULL; |
885 |
stringstream myquery; |
stringstream myquery; |
886 |
// |
// |
887 |
if ( !IDRUN ) IDRUN = ID; |
if ( !IDRUN ) IDRUN = ID; |
903 |
if( Row != NULL ){ |
if( Row != NULL ){ |
904 |
ToTable = (TString)Row->GetField(0); |
ToTable = (TString)Row->GetField(0); |
905 |
} else { |
} else { |
906 |
|
delete pResult; |
907 |
return 1; |
return 1; |
908 |
}; |
}; |
909 |
}; |
}; |
910 |
|
|
911 |
|
if (pResult) |
912 |
|
delete pResult; |
913 |
|
if (Row) |
914 |
|
delete Row; |
915 |
// ---------------- |
// ---------------- |
916 |
myquery.str(""); |
myquery.str(""); |
917 |
myquery << " INSERT INTO "; |
myquery << " INSERT INTO "; |
992 |
// |
// |
993 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
994 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
995 |
dbc->Query(myquery.str().c_str()); |
delete dbc->Query(myquery.str().c_str()); |
996 |
// |
// |
997 |
// |
// |
998 |
myquery.str(""); |
myquery.str(""); |
1001 |
// |
// |
1002 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
1003 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
1004 |
dbc->Query(myquery.str().c_str()); |
delete dbc->Query(myquery.str().c_str()); |
1005 |
// |
// |
1006 |
return 0; |
return 0; |
1007 |
}; |
}; |
1089 |
// |
// |
1090 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
1091 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
1092 |
dbc->Query(myquery.str().c_str()); |
delete dbc->Query(myquery.str().c_str()); |
1093 |
// |
// |
1094 |
return 0; |
return 0; |
1095 |
|
|
1171 |
// |
// |
1172 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
1173 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
1174 |
dbc->Query(myquery.str().c_str()); |
delete dbc->Query(myquery.str().c_str()); |
1175 |
// |
// |
1176 |
return 0; |
return 0; |
1177 |
|
|
1188 |
Int_t GL_RUN::Query_GL_RUN(UInt_t run, TSQLServer *dbc){ |
Int_t GL_RUN::Query_GL_RUN(UInt_t run, TSQLServer *dbc){ |
1189 |
// MySQL variables |
// MySQL variables |
1190 |
TSQLResult *pResult; |
TSQLResult *pResult; |
1191 |
TSQLRow *Row; |
TSQLRow *Row = NULL; |
|
int t; |
|
1192 |
int r; |
int r; |
1193 |
stringstream myquery; |
stringstream myquery; |
1194 |
// ---------------- |
// ---------------- |
1235 |
// |
// |
1236 |
// printf(" getrowcount %i \n",pResult->GetRowCount()); |
// printf(" getrowcount %i \n",pResult->GetRowCount()); |
1237 |
// |
// |
1238 |
if( !pResult->GetRowCount() ) return(-50); |
if( !pResult->GetRowCount() ){ |
1239 |
|
delete pResult; |
1240 |
|
if (Row) |
1241 |
|
delete Row; |
1242 |
|
return(-50); |
1243 |
|
} |
1244 |
// |
// |
1245 |
for( r=0; r < 1000; r++){ |
for( r=0; r < 1000; r++){ |
1246 |
|
if (Row) |
1247 |
|
delete Row; |
1248 |
Row = pResult->Next(); |
Row = pResult->Next(); |
1249 |
if( Row == NULL ) break; |
if( Row == NULL ) break; |
1250 |
// Set_GL_RUN(Row); |
// Set_GL_RUN(Row); |
1251 |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
for( int t = 0; t < pResult->GetFieldCount(); t++){ |
1252 |
if (t== 0) ID = (UInt_t)atoll(Row->GetField(t)); |
if (t== 0) ID = (UInt_t)atoll(Row->GetField(t)); |
1253 |
if (t== 1) ID_RUN_FRAG = (UInt_t)atoll(Row->GetField(t)); |
if (t== 1) ID_RUN_FRAG = (UInt_t)atoll(Row->GetField(t)); |
1254 |
if (t== 2) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); |
if (t== 2) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); |
1282 |
if (t==30) PHYSENDRUN_MASK_S11CRC = (UInt_t)atoll(Row->GetField(t)); |
if (t==30) PHYSENDRUN_MASK_S11CRC = (UInt_t)atoll(Row->GetField(t)); |
1283 |
if (t==31) VALIDATION = (UInt_t)atoll(Row->GetField(t)); |
if (t==31) VALIDATION = (UInt_t)atoll(Row->GetField(t)); |
1284 |
}; |
}; |
1285 |
}; |
} |
1286 |
// delete pResult; |
|
1287 |
|
if (Row) |
1288 |
|
delete Row; |
1289 |
|
delete pResult; |
1290 |
return(0); |
return(0); |
1291 |
}; |
}; |
1292 |
|
|
1300 |
Int_t GL_RUN::Query_GL_RUN_FRAGMENTS(TString where, TSQLServer *dbc){ |
Int_t GL_RUN::Query_GL_RUN_FRAGMENTS(TString where, TSQLServer *dbc){ |
1301 |
// MySQL variables |
// MySQL variables |
1302 |
TSQLResult *pResult; |
TSQLResult *pResult; |
1303 |
TSQLRow *Row; |
TSQLRow *Row = NULL; |
1304 |
int t; |
int t; |
1305 |
int r; |
int r; |
1306 |
stringstream myquery; |
stringstream myquery; |
1346 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
1347 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
1348 |
pResult = dbc->Query(myquery.str().c_str()); |
pResult = dbc->Query(myquery.str().c_str()); |
1349 |
if(!pResult->GetRowCount())return(-50); |
if(!pResult->GetRowCount()){ |
1350 |
|
delete pResult; |
1351 |
|
if (Row) |
1352 |
|
delete Row; |
1353 |
|
return(-50); |
1354 |
|
} |
1355 |
for( r=0; r < 1000; r++){ |
for( r=0; r < 1000; r++){ |
1356 |
|
if (Row) |
1357 |
|
delete Row; |
1358 |
Row = pResult->Next(); |
Row = pResult->Next(); |
1359 |
if( Row == NULL ) break; |
if( Row == NULL ) break; |
1360 |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
1391 |
if (t==30) PHYSENDRUN_MASK_S11CRC = (UInt_t)atoll(Row->GetField(t)); |
if (t==30) PHYSENDRUN_MASK_S11CRC = (UInt_t)atoll(Row->GetField(t)); |
1392 |
if (t==31) VALIDATION = (UInt_t)atoll(Row->GetField(t)); |
if (t==31) VALIDATION = (UInt_t)atoll(Row->GetField(t)); |
1393 |
}; |
}; |
1394 |
}; |
} |
1395 |
// delete pResult; |
|
1396 |
|
if (Row) |
1397 |
|
delete Row; |
1398 |
|
delete pResult; |
1399 |
return(0); |
return(0); |
1400 |
};// **************************************************** |
};// **************************************************** |
1401 |
|
|
1408 |
Int_t GL_ROOT::Query_GL_ROOT(UInt_t id, TSQLServer *dbc){ |
Int_t GL_ROOT::Query_GL_ROOT(UInt_t id, TSQLServer *dbc){ |
1409 |
// MySQL variables |
// MySQL variables |
1410 |
TSQLResult *pResult; |
TSQLResult *pResult; |
1411 |
TSQLRow *Row; |
TSQLRow *Row = NULL; |
1412 |
int t; |
int t; |
1413 |
int r; |
int r; |
1414 |
stringstream myquery; |
stringstream myquery; |
1425 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
1426 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
1427 |
pResult = dbc->Query(myquery.str().c_str()); |
pResult = dbc->Query(myquery.str().c_str()); |
1428 |
if(!pResult->GetRowCount())return (-51); |
if(!pResult->GetRowCount()){ |
1429 |
|
delete pResult; |
1430 |
|
if (Row) |
1431 |
|
delete Row; |
1432 |
|
return (-51); |
1433 |
|
} |
1434 |
for( r=0; r < 1000; r++){ |
for( r=0; r < 1000; r++){ |
1435 |
|
if (Row) |
1436 |
|
delete Row; |
1437 |
Row = pResult->Next(); |
Row = pResult->Next(); |
1438 |
if( Row == NULL ) break; |
if( Row == NULL ) break; |
1439 |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
1440 |
if(t==0) ID = (UInt_t)atoll(Row->GetField(t)); |
if(t==0) ID = (UInt_t)atoll(Row->GetField(t)); |
1441 |
if(t==1) ID_RAW = (UInt_t)atoll(Row->GetField(t)); |
if(t==1) ID_RAW = (UInt_t)atoll(Row->GetField(t)); |
1442 |
if(t==2) ID_TIMESYNC = (UInt_t)atoll(Row->GetField(t)); |
if(t==2) ID_TIMESYNC = (UInt_t)atoll(Row->GetField(t)); |
1443 |
if(t==3) PATH = (TString)gSystem->ExpandPathName(Row->GetField(t))+'/'; |
if(t==3){ |
1444 |
|
PATH = TString(Row->GetField(t)) + '/'; |
1445 |
|
gSystem->ExpandPathName(PATH); |
1446 |
|
} |
1447 |
if(t==4) NAME = Row->GetField(t); |
if(t==4) NAME = Row->GetField(t); |
1448 |
}; |
} |
1449 |
}; |
} |
1450 |
|
if (Row) |
1451 |
|
delete Row; |
1452 |
delete pResult; |
delete pResult; |
1453 |
return 0; |
return 0; |
1454 |
}; |
}; |
1463 |
Int_t GL_TRK_CALIB::Query_GL_TRK_CALIB(UInt_t time, TSQLServer *dbc){ |
Int_t GL_TRK_CALIB::Query_GL_TRK_CALIB(UInt_t time, TSQLServer *dbc){ |
1464 |
// MySQL variables |
// MySQL variables |
1465 |
TSQLResult *pResult; |
TSQLResult *pResult; |
1466 |
TSQLRow *Row; |
TSQLRow *Row = NULL; |
1467 |
int t; |
int t; |
1468 |
int r; |
int r; |
1469 |
stringstream myquery; |
stringstream myquery; |
1477 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
1478 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
1479 |
pResult = dbc->Query(myquery.str().c_str()); |
pResult = dbc->Query(myquery.str().c_str()); |
1480 |
if(!pResult->GetRowCount())return (-53); |
if(!pResult->GetRowCount()){ |
1481 |
|
delete pResult; |
1482 |
|
return (-53); |
1483 |
|
} |
1484 |
for( r=0; r < 1000; r++){ |
for( r=0; r < 1000; r++){ |
1485 |
|
if (Row) |
1486 |
|
delete Row; |
1487 |
Row = pResult->Next(); |
Row = pResult->Next(); |
1488 |
if( Row == NULL ) break; |
if( Row == NULL ) break; |
1489 |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
1504 |
if (t==10) BOOT_NUMBER = (UInt_t)atoll(Row->GetField(t)); |
if (t==10) BOOT_NUMBER = (UInt_t)atoll(Row->GetField(t)); |
1505 |
if (t==11) VALIDATION = (UInt_t)atoll(Row->GetField(t)); |
if (t==11) VALIDATION = (UInt_t)atoll(Row->GetField(t)); |
1506 |
}; |
}; |
1507 |
}; |
} |
1508 |
|
if (Row) |
1509 |
|
delete Row; |
1510 |
delete pResult; |
delete pResult; |
1511 |
// |
// |
1512 |
// if ( TO_TIME < time ) return(51); |
// if ( TO_TIME < time ) return(51); |
1526 |
Int_t GL_CALO_CALIB::Query_GL_CALO_CALIB(UInt_t time, UInt_t &uptime, UInt_t section, TSQLServer *dbc){ |
Int_t GL_CALO_CALIB::Query_GL_CALO_CALIB(UInt_t time, UInt_t &uptime, UInt_t section, TSQLServer *dbc){ |
1527 |
// MySQL variables |
// MySQL variables |
1528 |
TSQLResult *pResult; |
TSQLResult *pResult; |
1529 |
TSQLRow *Row; |
TSQLRow *Row = NULL; |
1530 |
int t; |
int t; |
1531 |
stringstream myquery; |
stringstream myquery; |
1532 |
uptime = 0; |
uptime = 0; |
1543 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
1544 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
1545 |
pResult = dbc->Query(myquery.str().c_str()); |
pResult = dbc->Query(myquery.str().c_str()); |
1546 |
// printf(" mysquery is %s\n",myquery.str().c_str()); |
// printf(" mysquery is %s\n",myquery.str().c_str()); |
1547 |
// |
// |
1548 |
if( !pResult->GetRowCount() ) return(-54); |
if (Row) |
1549 |
|
delete Row; |
1550 |
|
if( !pResult->GetRowCount() ){ |
1551 |
|
delete pResult; |
1552 |
|
return(-54); |
1553 |
|
} |
1554 |
Row = pResult->Next(); |
Row = pResult->Next(); |
1555 |
if( Row == NULL ) return (-54); |
if( Row == NULL ){ |
1556 |
|
delete pResult; |
1557 |
|
return (-54); |
1558 |
|
} |
1559 |
// |
// |
1560 |
uptime = (UInt_t)atoll(Row->GetField(2)); |
uptime = (UInt_t)atoll(Row->GetField(2)); |
1561 |
// |
// |
1572 |
myquery << "select ID_ROOT_L0, FROM_TIME, TO_TIME, EV_ROOT,VALIDATION from GL_CALO_CALIB where SECTION=" << section; |
myquery << "select ID_ROOT_L0, FROM_TIME, TO_TIME, EV_ROOT,VALIDATION from GL_CALO_CALIB where SECTION=" << section; |
1573 |
myquery << " and FROM_TIME <= " << time; |
myquery << " and FROM_TIME <= " << time; |
1574 |
myquery << " and VALIDATION=1 ORDER BY FROM_TIME DESC LIMIT 1;"; |
myquery << " and VALIDATION=1 ORDER BY FROM_TIME DESC LIMIT 1;"; |
1575 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
if ( !this->GetGLTABLES()->IsConnected(dbc) ){ |
1576 |
|
if(pResult) |
1577 |
|
delete pResult; |
1578 |
|
if(Row) |
1579 |
|
delete Row; |
1580 |
|
return -57; |
1581 |
|
} |
1582 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
1583 |
pResult = dbc->Query(myquery.str().c_str()); |
pResult = dbc->Query(myquery.str().c_str()); |
1584 |
// printf(" mysquery is %s\n",myquery.str().c_str()); |
// printf(" mysquery is %s\n",myquery.str().c_str()); |
1585 |
// |
// |
1586 |
// if no results yet quit with error |
// if no results yet quit with error |
1587 |
// |
// |
1588 |
if( !pResult->GetRowCount() ) return (-54); |
if( !pResult->GetRowCount() ){ |
1589 |
|
delete pResult; |
1590 |
|
if(Row) |
1591 |
|
delete Row; |
1592 |
|
return (-54); |
1593 |
|
} |
1594 |
// |
// |
1595 |
|
if (Row) |
1596 |
|
delete Row; |
1597 |
Row = pResult->Next(); |
Row = pResult->Next(); |
1598 |
// |
// |
1599 |
myfromtime = (UInt_t)atoll(Row->GetField(1)); |
myfromtime = (UInt_t)atoll(Row->GetField(1)); |
1607 |
myquery.str(""); |
myquery.str(""); |
1608 |
myquery << "select ID_ROOT_L0, FROM_TIME, TO_TIME, EV_ROOT from GL_CALO_CALIB where SECTION=" << section; |
myquery << "select ID_ROOT_L0, FROM_TIME, TO_TIME, EV_ROOT from GL_CALO_CALIB where SECTION=" << section; |
1609 |
myquery << " and VALIDATION=1 ORDER BY ABS(" << time << "-FROM_TIME) asc limit 1;"; |
myquery << " and VALIDATION=1 ORDER BY ABS(" << time << "-FROM_TIME) asc limit 1;"; |
1610 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
if ( !this->GetGLTABLES()->IsConnected(dbc) ){ |
1611 |
|
if(pResult) |
1612 |
|
delete pResult; |
1613 |
|
if(Row) |
1614 |
|
delete Row; |
1615 |
|
return -57; |
1616 |
|
} |
1617 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
1618 |
pResult = dbc->Query(myquery.str().c_str()); |
pResult = dbc->Query(myquery.str().c_str()); |
1619 |
// printf(" mysquery is %s\n",myquery.str().c_str()); |
// printf(" mysquery is %s\n",myquery.str().c_str()); |
1620 |
// |
// |
1621 |
// if no results yet quit with error |
// if no results yet quit with error |
1622 |
// |
// |
1623 |
if( !pResult->GetRowCount() ) return (-54); |
if( !pResult->GetRowCount() ){ |
1624 |
|
if (Row) |
1625 |
|
delete Row; |
1626 |
|
delete pResult; |
1627 |
|
return (-54); |
1628 |
|
} |
1629 |
// |
// |
1630 |
|
if (Row) |
1631 |
|
delete Row; |
1632 |
Row = pResult->Next(); |
Row = pResult->Next(); |
1633 |
// |
// |
1634 |
}; |
}; |
1635 |
// |
// |
1636 |
// store infos and exit |
// store infos and exit |
1637 |
// |
// |
1638 |
if( Row == NULL ) return (-54); |
if( Row == NULL ){ |
1639 |
|
delete pResult; |
1640 |
|
return (-54); |
1641 |
|
} |
1642 |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
1643 |
if (t==0) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); |
if (t==0) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); |
1644 |
if (t==1) FROM_TIME = myfromtime; |
if (t==1) FROM_TIME = myfromtime; |
1645 |
if (t==2) TO_TIME = mytotime; |
if (t==2) TO_TIME = mytotime; |
1646 |
if (t==3) EV_ROOT = (UInt_t)atoll(Row->GetField(t)); |
if (t==3) EV_ROOT = (UInt_t)atoll(Row->GetField(t)); |
1647 |
}; |
} |
1648 |
pResult->Delete(); |
if (Row) |
1649 |
|
delete Row; |
1650 |
|
delete pResult; |
1651 |
return 0; |
return 0; |
1652 |
}; |
}; |
1653 |
|
|
1662 |
Int_t GL_CALOPULSE_CALIB::Query_GL_CALOPULSE_CALIB(UInt_t time, UInt_t section, UInt_t pampli, TSQLServer *dbc){ |
Int_t GL_CALOPULSE_CALIB::Query_GL_CALOPULSE_CALIB(UInt_t time, UInt_t section, UInt_t pampli, TSQLServer *dbc){ |
1663 |
// MySQL variables |
// MySQL variables |
1664 |
TSQLResult *pResult; |
TSQLResult *pResult; |
1665 |
TSQLRow *Row; |
TSQLRow *Row = NULL; |
1666 |
int t; |
int t; |
1667 |
stringstream myquery; |
stringstream myquery; |
1668 |
// |
// |
1680 |
// |
// |
1681 |
if( !pResult ) return(-54); |
if( !pResult ) return(-54); |
1682 |
// |
// |
1683 |
|
if (Row) |
1684 |
|
delete Row; |
1685 |
Row = pResult->Next(); |
Row = pResult->Next(); |
1686 |
// |
// |
1687 |
if( !Row ) return (-54); |
if( !Row ){ |
1688 |
|
delete pResult; |
1689 |
|
return (-54); |
1690 |
|
} |
1691 |
// |
// |
1692 |
// store infos and exit |
// store infos and exit |
1693 |
// |
// |
1697 |
if (t==1) FROM_TIME = (UInt_t)atoll(Row->GetField(t)); |
if (t==1) FROM_TIME = (UInt_t)atoll(Row->GetField(t)); |
1698 |
if (t==2) TO_TIME = (UInt_t)atoll(Row->GetField(t)); |
if (t==2) TO_TIME = (UInt_t)atoll(Row->GetField(t)); |
1699 |
if (t==3) EV_ROOT = (UInt_t)atoll(Row->GetField(t)); |
if (t==3) EV_ROOT = (UInt_t)atoll(Row->GetField(t)); |
1700 |
}; |
} |
1701 |
|
if (Row) |
1702 |
|
delete Row; |
1703 |
pResult->Delete(); |
pResult->Delete(); |
1704 |
return 0; |
return 0; |
1705 |
}; |
}; |
1715 |
Int_t GL_S4_CALIB::Query_GL_S4_CALIB(UInt_t time, TSQLServer *dbc){ |
Int_t GL_S4_CALIB::Query_GL_S4_CALIB(UInt_t time, TSQLServer *dbc){ |
1716 |
// MySQL variables |
// MySQL variables |
1717 |
TSQLResult *pResult; |
TSQLResult *pResult; |
1718 |
TSQLRow *Row; |
TSQLRow *Row = NULL; |
1719 |
int t; |
int t; |
1720 |
int r; |
int r; |
1721 |
stringstream myquery; |
stringstream myquery; |
1727 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
1728 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
1729 |
pResult = dbc->Query(myquery.str().c_str()); |
pResult = dbc->Query(myquery.str().c_str()); |
1730 |
if(!pResult->GetRowCount())return (-55);//throw -55; |
if(!pResult->GetRowCount()){ |
1731 |
|
delete pResult; |
1732 |
|
return (-55);//throw -55; |
1733 |
|
} |
1734 |
for( r=0; r < 1000; r++){ |
for( r=0; r < 1000; r++){ |
1735 |
|
if (Row) |
1736 |
|
delete Row; |
1737 |
Row = pResult->Next(); |
Row = pResult->Next(); |
1738 |
if( Row == NULL ) break; |
if( Row == NULL ) break; |
1739 |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
1743 |
if (t==3) FROM_TIME = (UInt_t)atoll(Row->GetField(t)); |
if (t==3) FROM_TIME = (UInt_t)atoll(Row->GetField(t)); |
1744 |
if (t==4) TO_TIME = (UInt_t)atoll(Row->GetField(t)); |
if (t==4) TO_TIME = (UInt_t)atoll(Row->GetField(t)); |
1745 |
}; |
}; |
1746 |
}; |
} |
1747 |
|
if (Row) |
1748 |
|
delete Row; |
1749 |
delete pResult; |
delete pResult; |
1750 |
// |
// |
1751 |
if(TO_TIME < time)return(51); |
if(TO_TIME < time)return(51); |
1764 |
// Bool_t debug = 1; |
// Bool_t debug = 1; |
1765 |
// MySQL variables |
// MySQL variables |
1766 |
TSQLResult *pResult; |
TSQLResult *pResult; |
1767 |
TSQLRow *Row; |
TSQLRow *Row = NULL; |
1768 |
int t; |
int t; |
1769 |
int r; |
int r; |
1770 |
stringstream myquery; |
stringstream myquery; |
1780 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
1781 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
1782 |
pResult = dbc->Query(myquery.str().c_str()); |
pResult = dbc->Query(myquery.str().c_str()); |
1783 |
if(!pResult->GetRowCount())return (-52); |
if(!pResult->GetRowCount()){ |
1784 |
|
delete pResult; |
1785 |
|
return (-52); |
1786 |
|
} |
1787 |
for( r=0; r < 1000; r++){ |
for( r=0; r < 1000; r++){ |
1788 |
|
if (Row) |
1789 |
|
delete Row; |
1790 |
Row = pResult->Next(); |
Row = pResult->Next(); |
1791 |
if( Row == NULL ) break; |
if( Row == NULL ) break; |
1792 |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
1793 |
if (t==0) ID = (UInt_t)atoll(Row->GetField(t)); |
if (t==0) ID = (UInt_t)atoll(Row->GetField(t)); |
1794 |
if (t==1) PATH = (TString)gSystem->ExpandPathName(Row->GetField(t))+'/';// put in fpath the path to that file |
if (t==1) { |
1795 |
if (t==2) NAME = Row->GetField(t); |
PATH = TString(Row->GetField(t)) + "/";// put in fpath the path to that file |
1796 |
if (t==3) DESCR = Row->GetField(t); |
gSystem->ExpandPathName(PATH); |
1797 |
if (t==4) FROM_TIME = (UInt_t)atoll(Row->GetField(t)); |
} |
1798 |
if (t==5) TO_TIME = (UInt_t)atoll(Row->GetField(t)); |
if (t==2) NAME = Row->GetField(t); |
1799 |
if (t==6) TYPE = (UInt_t)atoll(Row->GetField(t)); |
if (t==3) DESCR = Row->GetField(t); |
1800 |
|
if (t==4) FROM_TIME = (UInt_t)atoll(Row->GetField(t)); |
1801 |
|
if (t==5) TO_TIME = (UInt_t)atoll(Row->GetField(t)); |
1802 |
|
if (t==6) TYPE = (UInt_t)atoll(Row->GetField(t)); |
1803 |
}; |
}; |
1804 |
}; |
} |
1805 |
|
if (Row) |
1806 |
|
delete Row; |
1807 |
delete pResult; |
delete pResult; |
1808 |
// |
// |
1809 |
if(TO_TIME==0) TO_TIME = numeric_limits<UInt_t>::max(); |
if(TO_TIME==0) TO_TIME = numeric_limits<UInt_t>::max(); |
1836 |
GL_TIMESYNC::GL_TIMESYNC(UInt_t id, TString type, TSQLServer *dbc){ |
GL_TIMESYNC::GL_TIMESYNC(UInt_t id, TString type, TSQLServer *dbc){ |
1837 |
// MySQL variables |
// MySQL variables |
1838 |
TFile *file = 0; |
TFile *file = 0; |
1839 |
UInt_t idraw = 0; |
UInt_t idtsy = 0; |
1840 |
// |
// |
1841 |
TSQLResult *pResult; |
TSQLResult *pResult; |
1842 |
TSQLRow *Row; |
TSQLRow *Row = NULL; |
1843 |
stringstream myquery; |
stringstream myquery; |
1844 |
stringstream rname; |
stringstream rname; |
1845 |
// pcksList packetsNames; |
// pcksList packetsNames; |
1850 |
myquery.str(""); |
myquery.str(""); |
1851 |
myquery << "select "; |
myquery << "select "; |
1852 |
myquery << "PATH"; |
myquery << "PATH"; |
1853 |
myquery << ",NAME,ID_RAW"; |
myquery << ",NAME,ID_TIMESYNC"; |
1854 |
myquery << " from GL_ROOT where "; |
myquery << " from GL_ROOT where "; |
1855 |
myquery << type.Data(); |
myquery << type.Data(); |
1856 |
myquery << "=" << id << ";"; |
myquery << "=" << id << ";"; |
1859 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
1860 |
pResult = dbc->Query(myquery.str().c_str()); |
pResult = dbc->Query(myquery.str().c_str()); |
1861 |
if( pResult->GetRowCount() ){ |
if( pResult->GetRowCount() ){ |
1862 |
|
if (Row) |
1863 |
|
delete Row; |
1864 |
Row = pResult->Next(); |
Row = pResult->Next(); |
1865 |
if( Row ){ |
if( Row ){ |
1866 |
stringstream fname; |
stringstream fname; |
1867 |
fname.str(""); |
fname.str(""); |
1868 |
fname << gSystem->ExpandPathName(Row->GetField(0)) << "/" << Row->GetField(1); |
TString auxStr(Row->GetField(0)); |
1869 |
|
gSystem->ExpandPathName(auxStr); |
1870 |
|
fname << auxStr << "/" << Row->GetField(1); |
1871 |
rname << Row->GetField(1); |
rname << Row->GetField(1); |
1872 |
file = new TFile(fname.str().c_str(),"READ"); |
file = new TFile(fname.str().c_str(),"READ"); |
1873 |
idraw = (UInt_t)atoll(Row->GetField(2)); |
idtsy = (UInt_t)atoll(Row->GetField(2)); |
1874 |
}; |
}; |
1875 |
}; |
}; |
1876 |
// |
// |
1883 |
T->GetEntry(0); |
T->GetEntry(0); |
1884 |
ph = eh->GetPscuHeader(); |
ph = eh->GetPscuHeader(); |
1885 |
pktfirst = ph->GetCounter(); |
pktfirst = ph->GetCounter(); |
1886 |
obtfirst = ph->GetOrbitalTime(); |
if ( eh ){ |
1887 |
// |
delete eh; |
1888 |
// code = eh->GetCounter(); |
eh = 0; |
1889 |
// UInt_t en = 0; |
} |
1890 |
// for(Iter = packetsNames.begin(); Iter != packetsNames.end(); Iter++){ |
// obtfirst = ph->GetOrbitalTime(); |
|
// en = code->Get(GetPacketType(*Iter)); |
|
|
// if ( !strcmp("CalibCalPed",*Iter) || !strcmp("CalibTrk1",*Iter) || !strcmp("CalibTrk2",*Iter) || !strcmp("CalibS4",*Iter) ){ |
|
|
// // |
|
|
// TTree *TC = 0; |
|
|
// TC = (TTree*)file->Get("CalibCalPed"); |
|
|
// if ( !TC || TC->IsZombie() ) return; |
|
|
// EventHeader *ehc = 0; |
|
|
// PscuHeader *phc = 0; |
|
|
// TC->SetBranchAddress("Header", &ehc); |
|
|
// TC->GetEntry(0); |
|
|
// phc = ehc->GetPscuHeader(); |
|
|
// pktfirst = phc->GetCounter(); |
|
|
// obtfirst = phc->GetOrbitalTime(); |
|
|
// // |
|
|
// }; |
|
|
// }; |
|
1891 |
// |
// |
1892 |
}; |
}; |
1893 |
// |
// |
1895 |
// |
// |
1896 |
T0 = 0; |
T0 = 0; |
1897 |
// |
// |
|
// |
|
1898 |
stringstream oss; |
stringstream oss; |
|
TString frn = rname.str().c_str(); |
|
|
frn = frn.ReplaceAll(".root",5,".pam",4); |
|
|
oss.str(""); |
|
|
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='" |
|
|
<< frn.Data() << "';"; |
|
|
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return; |
|
|
this->GetGLTABLES()->AddQ(); |
|
|
pResult = dbc->Query(oss.str().c_str()); |
|
|
Row = pResult->Next(); |
|
1899 |
// |
// |
1900 |
TString name=rname.str().c_str(); |
TString name=rname.str().c_str(); |
1901 |
UInt_t dworbit = 0; |
// UInt_t dworbit = 0; |
1902 |
Int_t nlength = name.Length(); |
// Int_t nlength = name.Length(); |
1903 |
|
delete pResult; |
1904 |
|
if (Row){ |
1905 |
|
delete Row; |
1906 |
|
Row = NULL; |
1907 |
|
} |
1908 |
// |
// |
1909 |
// Is not a special file |
// New code, we have one more column on GL_TIMESYNC so we can trust that one for the Resurs offset |
1910 |
// |
// |
1911 |
if ( !Row ){ |
oss.str(""); |
1912 |
delete pResult; |
oss << "SELECT OBT0,TIMESYNC,TYPE,ID_RESURS_OFFSET from GL_TIMESYNC where ID=" << idtsy <<";"; |
1913 |
// |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return; |
1914 |
// New code, we have one more column on GL_TIMESYNC so we can trust that one for the Resurs offset |
this->GetGLTABLES()->AddQ(); |
1915 |
// |
pResult = dbc->Query(oss.str().c_str()); |
1916 |
oss.str(""); |
Bool_t fndit = false; |
1917 |
oss << "SELECT ID_RESURS_OFFSET from GL_TIMESYNC where ID_RAW=" << idraw <<";"; |
if ( pResult ){ |
1918 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return; |
if (Row) |
1919 |
this->GetGLTABLES()->AddQ(); |
delete Row; |
1920 |
pResult = dbc->Query(oss.str().c_str()); |
Row = pResult->Next(); |
1921 |
Bool_t fndit = false; |
if ( Row ){ |
|
if ( pResult ){ |
|
|
Row = pResult->Next(); |
|
|
if ( Row ){ |
|
|
oss.str(""); |
|
|
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 ID=" |
|
|
<< Row->GetField(0) << ";"; |
|
|
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return; |
|
|
this->GetGLTABLES()->AddQ(); |
|
|
pResult = dbc->Query(oss.str().c_str()); |
|
|
if ( pResult ){ |
|
|
Row = pResult->Next(); |
|
|
if ( Row ){ |
|
|
// printf(" GREAT! the DB structure is the new one! \n"); |
|
|
fndit = true; |
|
|
dworbit = 1; |
|
|
}; |
|
|
}; |
|
|
}; |
|
|
}; |
|
|
if ( !fndit ){ |
|
|
delete pResult; |
|
|
// |
|
|
printf(" OK, you got an error because this is the old database\n Using backward compability code, hence you can continue safetly \n"); |
|
|
// |
|
|
// Old code, we must trust the filename |
|
1922 |
// |
// |
1923 |
if ( nlength < 5 ) return; |
OBT0 = (UInt_t)atoll(Row->GetField(0)); |
1924 |
TString dwo = 0; |
obtfirst = OBT0; |
1925 |
for (Int_t i = 0; i<5; i++){ |
TIMESYNC = (UInt_t)atoll(Row->GetField(1)); |
1926 |
dwo.Append(name[i],1); |
TYPE = (UInt_t)atoll(Row->GetField(2)); |
|
}; |
|
|
if ( dwo.IsDigit() ){ |
|
|
dworbit = (UInt_t)dwo.Atoi(); |
|
|
} else { |
|
|
dwo=""; |
|
|
for (Int_t i = 8; i<13; i++){ |
|
|
dwo.Append(name[i],1); |
|
|
}; |
|
|
if ( dwo.IsDigit() ){ |
|
|
dworbit = (UInt_t)dwo.Atoi(); |
|
|
} else { |
|
|
dworbit = 1; |
|
|
}; |
|
|
}; |
|
1927 |
// |
// |
1928 |
oss.str(""); |
oss.str(""); |
1929 |
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< " |
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 ID=" |
1930 |
<< dworbit << " order by FROM_ORBIT desc limit 1;"; |
<< Row->GetField(3) << ";"; |
1931 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return; |
if ( !this->GetGLTABLES()->IsConnected(dbc) ){ |
1932 |
|
delete pResult; |
1933 |
|
delete Row; |
1934 |
|
return; |
1935 |
|
} |
1936 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
1937 |
|
delete pResult; |
1938 |
pResult = dbc->Query(oss.str().c_str()); |
pResult = dbc->Query(oss.str().c_str()); |
1939 |
Row = pResult->Next(); |
if (pResult){ |
1940 |
if ( !Row ){ |
if (Row) |
1941 |
printf(" ERROR FROM GLTables! cannot determine Resurs offset \n"); |
delete Row; |
1942 |
return; |
Row = pResult->Next(); |
1943 |
|
if ( Row ){ |
1944 |
|
// printf(" GREAT! the DB structure is the new one! \n"); |
1945 |
|
fndit = true; |
1946 |
|
// dworbit = 1; |
1947 |
|
}; |
1948 |
}; |
}; |
1949 |
}; |
}; |
1950 |
}; |
}; |
1951 |
|
if ( !fndit ){ |
1952 |
|
// |
1953 |
|
printf(" ERROR OLD DB! \n"); |
1954 |
|
printf(" ERROR FROM GLTables! cannot determine Resurs offset \n"); |
1955 |
|
// |
1956 |
|
}; |
1957 |
// |
// |
1958 |
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); |
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); |
1959 |
T0 = (UInt_t)tu.GetSec(); |
T0 = (UInt_t)tu.GetSec(); |
1960 |
// |
// |
1961 |
// look for the correct timesync entry |
toffset = (UInt_t)TIMESYNC - (UInt_t)(this->DBobt(OBT0)/1000) + T0; |
1962 |
// |
// |
1963 |
|
// printf(" T0 %u toffset is %u \n",T0,toffset); |
1964 |
|
// |
1965 |
|
if ( file ) file->Close(); |
1966 |
|
if (Row) |
1967 |
|
delete Row; |
1968 |
|
delete pResult; |
1969 |
|
}; |
1970 |
|
|
1971 |
|
GL_TIMESYNC::GL_TIMESYNC(UInt_t id, TString type, TSQLServer *dbc, Bool_t usel0file){ |
1972 |
|
// MySQL variables |
1973 |
|
TFile *file = 0; |
1974 |
|
UInt_t idtsy = 0; |
1975 |
|
// |
1976 |
|
TSQLResult *pResult; |
1977 |
|
TSQLRow *Row = NULL; |
1978 |
|
stringstream myquery; |
1979 |
|
stringstream rname; |
1980 |
|
// pcksList packetsNames; |
1981 |
|
// pcksList::iterator Iter; |
1982 |
|
// getPacketsNames(packetsNames); |
1983 |
|
rname.str(""); |
1984 |
|
// ---------------- |
1985 |
myquery.str(""); |
myquery.str(""); |
1986 |
myquery << " SELECT OBT0,TIMESYNC,TYPE FROM GL_TIMESYNC " |
myquery << "select "; |
1987 |
<< " WHERE ID_RAW = " << idraw |
myquery << "PATH"; |
1988 |
<< ";"; |
myquery << ",NAME,ID_TIMESYNC"; |
1989 |
|
myquery << " from GL_ROOT where "; |
1990 |
|
myquery << type.Data(); |
1991 |
|
myquery << "=" << id << ";"; |
1992 |
|
// |
1993 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return; |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return; |
1994 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
1995 |
pResult = dbc->Query(myquery.str().c_str()); |
pResult = dbc->Query(myquery.str().c_str()); |
1996 |
|
if( pResult->GetRowCount() ){ |
1997 |
|
if (Row) |
1998 |
|
delete Row; |
1999 |
|
Row = pResult->Next(); |
2000 |
|
if( Row ){ |
2001 |
|
stringstream fname; |
2002 |
|
fname.str(""); |
2003 |
|
TString auxString(Row->GetField(0)); |
2004 |
|
gSystem->ExpandPathName(auxString); |
2005 |
|
fname << auxString << "/" << Row->GetField(1); |
2006 |
|
rname << Row->GetField(1); |
2007 |
|
if ( usel0file ) file = new TFile(fname.str().c_str(),"READ"); |
2008 |
|
idtsy = (UInt_t)atoll(Row->GetField(2)); |
2009 |
|
}; |
2010 |
|
}; |
2011 |
|
// |
2012 |
|
if ( usel0file && file && file->IsOpen() ){ |
2013 |
|
TTree *T=(TTree*)file->Get("Physics"); |
2014 |
|
pamela::EventHeader *eh = 0; |
2015 |
|
pamela::PscuHeader *ph = 0; |
2016 |
|
T->SetBranchAddress("Header", &eh); |
2017 |
|
// |
2018 |
|
T->GetEntry(0); |
2019 |
|
ph = eh->GetPscuHeader(); |
2020 |
|
pktfirst = ph->GetCounter(); |
2021 |
|
if ( eh ){ |
2022 |
|
delete eh; |
2023 |
|
eh = 0; |
2024 |
|
} |
2025 |
|
// obtfirst = ph->GetOrbitalTime(); |
2026 |
|
// |
2027 |
|
}; |
2028 |
|
if ( !usel0file ) pktfirst = 0; |
2029 |
|
// |
2030 |
|
// look for Resurs offset |
2031 |
|
// |
2032 |
|
T0 = 0; |
2033 |
|
// |
2034 |
|
stringstream oss; |
2035 |
|
// |
2036 |
|
TString name=rname.str().c_str(); |
2037 |
|
// UInt_t dworbit = 0; |
2038 |
|
// Int_t nlength = name.Length(); |
2039 |
|
delete pResult; |
2040 |
|
if (Row){ |
2041 |
|
delete Row; |
2042 |
|
Row = NULL; |
2043 |
|
} |
2044 |
|
// |
2045 |
|
// New code, we have one more column on GL_TIMESYNC so we can trust that one for the Resurs offset |
2046 |
|
// |
2047 |
|
oss.str(""); |
2048 |
|
oss << "SELECT OBT0,TIMESYNC,TYPE,ID_RESURS_OFFSET from GL_TIMESYNC where ID=" << idtsy <<";"; |
2049 |
|
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return; |
2050 |
|
this->GetGLTABLES()->AddQ(); |
2051 |
|
pResult = dbc->Query(oss.str().c_str()); |
2052 |
|
Bool_t fndit = false; |
2053 |
if ( pResult ){ |
if ( pResult ){ |
2054 |
|
if (Row) |
2055 |
|
delete Row; |
2056 |
Row = pResult->Next(); |
Row = pResult->Next(); |
2057 |
if ( (Row != NULL) && ((UInt_t)atoll(Row->GetField(0)) > 0 ) ){ |
if ( Row ){ |
2058 |
|
// |
2059 |
OBT0 = (UInt_t)atoll(Row->GetField(0)); |
OBT0 = (UInt_t)atoll(Row->GetField(0)); |
2060 |
|
obtfirst = OBT0; |
2061 |
TIMESYNC = (UInt_t)atoll(Row->GetField(1)); |
TIMESYNC = (UInt_t)atoll(Row->GetField(1)); |
2062 |
TYPE = (UInt_t)atoll(Row->GetField(2)); |
TYPE = (UInt_t)atoll(Row->GetField(2)); |
2063 |
toffset = (UInt_t)atoll(Row->GetField(1)) - (UInt_t)(this->DBobt((UInt_t)atoll(Row->GetField(0)))/1000) + T0; |
// |
2064 |
|
oss.str(""); |
2065 |
|
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 ID=" |
2066 |
|
<< Row->GetField(3) << ";"; |
2067 |
|
if ( !this->GetGLTABLES()->IsConnected(dbc) ){ |
2068 |
|
delete pResult; |
2069 |
|
delete Row; |
2070 |
|
return; |
2071 |
|
} |
2072 |
|
this->GetGLTABLES()->AddQ(); |
2073 |
|
delete pResult; |
2074 |
|
pResult = dbc->Query(oss.str().c_str()); |
2075 |
|
if (pResult){ |
2076 |
|
if (Row) |
2077 |
|
delete Row; |
2078 |
|
Row = pResult->Next(); |
2079 |
|
if (Row){ |
2080 |
|
// printf(" GREAT! the DB structure is the new one! \n"); |
2081 |
|
fndit = true; |
2082 |
|
// dworbit = 1; |
2083 |
|
}; |
2084 |
|
}; |
2085 |
}; |
}; |
2086 |
}; |
}; |
2087 |
|
if ( !fndit ){ |
2088 |
|
// |
2089 |
|
printf(" ERROR OLD DB! \n"); |
2090 |
|
printf(" ERROR FROM GLTables! cannot determine Resurs offset \n"); |
2091 |
|
// |
2092 |
|
}; |
2093 |
// |
// |
2094 |
file->Close(); |
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); |
2095 |
|
T0 = (UInt_t)tu.GetSec(); |
2096 |
|
// |
2097 |
|
toffset = (UInt_t)TIMESYNC - (UInt_t)(this->DBobt(OBT0)/1000) + T0; |
2098 |
|
// |
2099 |
|
// printf(" T0 %u toffset is %u \n",T0,toffset); |
2100 |
|
// |
2101 |
|
if ( file ) file->Close(); |
2102 |
|
if (Row) |
2103 |
|
delete Row; |
2104 |
delete pResult; |
delete pResult; |
2105 |
}; |
}; |
2106 |
|
|
2111 |
*/ |
*/ |
2112 |
UInt_t GL_TIMESYNC::DBabsTime(UInt_t OBT){ |
UInt_t GL_TIMESYNC::DBabsTime(UInt_t OBT){ |
2113 |
// |
// |
2114 |
|
// printf(" OBT %u DBobt %llu toffset %u dbabstime %u\n",OBT,this->DBobt(OBT),toffset,((UInt_t)(this->DBobt(OBT)/1000)+toffset)); |
2115 |
return(((UInt_t)(this->DBobt(OBT)/1000)+toffset)); |
return(((UInt_t)(this->DBobt(OBT)/1000)+toffset)); |
2116 |
// |
// |
2117 |
}; |
}; |
2150 |
*/ |
*/ |
2151 |
Long64_t GL_TIMESYNC::DBobt(UInt_t obt){ |
Long64_t GL_TIMESYNC::DBobt(UInt_t obt){ |
2152 |
// |
// |
2153 |
if ( obt < (obtfirst/2) && obtfirst > (numeric_limits<UInt_t>::max()/2) ){ |
if ( obt < ((Long64_t)obtfirst/2) && obtfirst > (numeric_limits<UInt_t>::max()/2) ){ |
2154 |
return((Long64_t)obt+(Long64_t)numeric_limits<UInt_t>::max()); |
return((Long64_t)obt+(Long64_t)numeric_limits<UInt_t>::max()); |
2155 |
}; |
}; |
2156 |
// |
// |
2157 |
if ( obt > (obtfirst*2) && obt > (numeric_limits<UInt_t>::max()/2) ){ |
if ( obt > ((Long64_t)obtfirst*2) && obt > (numeric_limits<UInt_t>::max()/2) ){ |
2158 |
return((Long64_t)obt-(Long64_t)numeric_limits<UInt_t>::max()); |
return((Long64_t)obt-(Long64_t)numeric_limits<UInt_t>::max()); |
2159 |
}; |
}; |
2160 |
// |
// |
2371 |
// |
// |
2372 |
Int_t GL_TLE::DoQuery(TString myquery, TSQLServer *dbc){ |
Int_t GL_TLE::DoQuery(TString myquery, TSQLServer *dbc){ |
2373 |
TSQLResult *result; |
TSQLResult *result; |
2374 |
TSQLRow *row; |
TSQLRow *row = NULL; |
2375 |
|
|
2376 |
// Set the right time_zone (otherwise horrible things will occur! :) |
// Set the right time_zone (otherwise horrible things will occur! :) |
2377 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
2378 |
dbc->Query("SET time_zone = '+0:00'"); |
delete dbc->Query("SET time_zone = '+0:00';"); |
2379 |
|
delete dbc->Query("SET sql_mode = 'NO_UNSIGNED_SUBTRACTION';"); |
2380 |
|
|
2381 |
// Do the query |
// Do the query |
2382 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
2383 |
result = dbc->Query(myquery.Data()); |
result = dbc->Query(myquery.Data()); |
2384 |
if(! result->GetRowCount() ) { |
if(! result->GetRowCount() ) { |
2385 |
cerr << "GL_TLE: query failed: " << myquery.Data() << endl; |
cerr << "GL_TLE: query failed: " << myquery.Data() << endl; |
2386 |
|
delete result; |
2387 |
return 1; |
return 1; |
2388 |
} |
} |
2389 |
|
|
2392 |
tle = GiveTle(row); |
tle = GiveTle(row); |
2393 |
|
|
2394 |
tleFromTime = strtol(row->GetField(4), NULL, 10); |
tleFromTime = strtol(row->GetField(4), NULL, 10); |
2395 |
|
if (row) |
2396 |
|
delete row; |
2397 |
row = result->Next(); // second tle row |
row = result->Next(); // second tle row |
2398 |
if(row) |
if(row) |
2399 |
tleToTime = strtol(row->GetField(4), NULL, 10); |
tleToTime = strtol(row->GetField(4), NULL, 10); |
2402 |
tleToTime = UINT_MAX; |
tleToTime = UINT_MAX; |
2403 |
} |
} |
2404 |
|
|
2405 |
delete row; |
if (row) |
2406 |
|
delete row; |
2407 |
delete result; |
delete result; |
2408 |
|
|
2409 |
return 0; |
return 0; |