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(); |
// obtfirst = ph->GetOrbitalTime(); |
|
// |
|
|
// code = eh->GetCounter(); |
|
|
// UInt_t en = 0; |
|
|
// for(Iter = packetsNames.begin(); Iter != packetsNames.end(); Iter++){ |
|
|
// 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(); |
|
|
// // |
|
|
// }; |
|
|
// }; |
|
1887 |
// |
// |
1888 |
}; |
}; |
1889 |
// |
// |
1891 |
// |
// |
1892 |
T0 = 0; |
T0 = 0; |
1893 |
// |
// |
|
// |
|
1894 |
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(); |
|
1895 |
// |
// |
1896 |
TString name=rname.str().c_str(); |
TString name=rname.str().c_str(); |
1897 |
UInt_t dworbit = 0; |
// UInt_t dworbit = 0; |
1898 |
Int_t nlength = name.Length(); |
// Int_t nlength = name.Length(); |
1899 |
|
delete pResult; |
1900 |
|
if (Row){ |
1901 |
|
delete Row; |
1902 |
|
Row = NULL; |
1903 |
|
} |
1904 |
// |
// |
1905 |
// 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 |
1906 |
// |
// |
1907 |
if ( !Row ){ |
oss.str(""); |
1908 |
delete pResult; |
oss << "SELECT OBT0,TIMESYNC,TYPE,ID_RESURS_OFFSET from GL_TIMESYNC where ID=" << idtsy <<";"; |
1909 |
// |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return; |
1910 |
// New code, we have one more column on GL_TIMESYNC so we can trust that one for the Resurs offset |
this->GetGLTABLES()->AddQ(); |
1911 |
// |
pResult = dbc->Query(oss.str().c_str()); |
1912 |
oss.str(""); |
Bool_t fndit = false; |
1913 |
oss << "SELECT ID_RESURS_OFFSET from GL_TIMESYNC where ID_RAW=" << idraw <<";"; |
if ( pResult ){ |
1914 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return; |
if (Row) |
1915 |
this->GetGLTABLES()->AddQ(); |
delete Row; |
1916 |
pResult = dbc->Query(oss.str().c_str()); |
Row = pResult->Next(); |
1917 |
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 |
|
1918 |
// |
// |
1919 |
if ( nlength < 5 ) return; |
OBT0 = (UInt_t)atoll(Row->GetField(0)); |
1920 |
TString dwo = 0; |
obtfirst = OBT0; |
1921 |
for (Int_t i = 0; i<5; i++){ |
TIMESYNC = (UInt_t)atoll(Row->GetField(1)); |
1922 |
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; |
|
|
}; |
|
|
}; |
|
1923 |
// |
// |
1924 |
oss.str(""); |
oss.str(""); |
1925 |
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=" |
1926 |
<< dworbit << " order by FROM_ORBIT desc limit 1;"; |
<< Row->GetField(3) << ";"; |
1927 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return; |
if ( !this->GetGLTABLES()->IsConnected(dbc) ){ |
1928 |
|
delete pResult; |
1929 |
|
delete Row; |
1930 |
|
return; |
1931 |
|
} |
1932 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
1933 |
|
delete pResult; |
1934 |
pResult = dbc->Query(oss.str().c_str()); |
pResult = dbc->Query(oss.str().c_str()); |
1935 |
Row = pResult->Next(); |
if (pResult){ |
1936 |
if ( !Row ){ |
if (Row) |
1937 |
printf(" ERROR FROM GLTables! cannot determine Resurs offset \n"); |
delete Row; |
1938 |
return; |
Row = pResult->Next(); |
1939 |
|
if ( Row ){ |
1940 |
|
// printf(" GREAT! the DB structure is the new one! \n"); |
1941 |
|
fndit = true; |
1942 |
|
// dworbit = 1; |
1943 |
|
}; |
1944 |
}; |
}; |
1945 |
}; |
}; |
1946 |
}; |
}; |
1947 |
|
if ( !fndit ){ |
1948 |
|
// |
1949 |
|
printf(" ERROR OLD DB! \n"); |
1950 |
|
printf(" ERROR FROM GLTables! cannot determine Resurs offset \n"); |
1951 |
|
// |
1952 |
|
}; |
1953 |
// |
// |
1954 |
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); |
1955 |
T0 = (UInt_t)tu.GetSec(); |
T0 = (UInt_t)tu.GetSec(); |
1956 |
// |
// |
1957 |
// look for the correct timesync entry |
toffset = (UInt_t)TIMESYNC - (UInt_t)(this->DBobt(OBT0)/1000) + T0; |
1958 |
// |
// |
1959 |
|
// printf(" T0 %u toffset is %u \n",T0,toffset); |
1960 |
|
// |
1961 |
|
if ( file ) file->Close(); |
1962 |
|
if (Row) |
1963 |
|
delete Row; |
1964 |
|
delete pResult; |
1965 |
|
}; |
1966 |
|
|
1967 |
|
GL_TIMESYNC::GL_TIMESYNC(UInt_t id, TString type, TSQLServer *dbc, Bool_t usel0file){ |
1968 |
|
// MySQL variables |
1969 |
|
TFile *file = 0; |
1970 |
|
UInt_t idtsy = 0; |
1971 |
|
// |
1972 |
|
TSQLResult *pResult; |
1973 |
|
TSQLRow *Row = NULL; |
1974 |
|
stringstream myquery; |
1975 |
|
stringstream rname; |
1976 |
|
// pcksList packetsNames; |
1977 |
|
// pcksList::iterator Iter; |
1978 |
|
// getPacketsNames(packetsNames); |
1979 |
|
rname.str(""); |
1980 |
|
// ---------------- |
1981 |
myquery.str(""); |
myquery.str(""); |
1982 |
myquery << " SELECT OBT0,TIMESYNC,TYPE FROM GL_TIMESYNC " |
myquery << "select "; |
1983 |
<< " WHERE ID_RAW = " << idraw |
myquery << "PATH"; |
1984 |
<< ";"; |
myquery << ",NAME,ID_TIMESYNC"; |
1985 |
|
myquery << " from GL_ROOT where "; |
1986 |
|
myquery << type.Data(); |
1987 |
|
myquery << "=" << id << ";"; |
1988 |
|
// |
1989 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return; |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return; |
1990 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
1991 |
pResult = dbc->Query(myquery.str().c_str()); |
pResult = dbc->Query(myquery.str().c_str()); |
1992 |
|
if( pResult->GetRowCount() ){ |
1993 |
|
if (Row) |
1994 |
|
delete Row; |
1995 |
|
Row = pResult->Next(); |
1996 |
|
if( Row ){ |
1997 |
|
stringstream fname; |
1998 |
|
fname.str(""); |
1999 |
|
TString auxString(Row->GetField(0)); |
2000 |
|
gSystem->ExpandPathName(auxString); |
2001 |
|
fname << auxString << "/" << Row->GetField(1); |
2002 |
|
rname << Row->GetField(1); |
2003 |
|
if ( usel0file ) file = new TFile(fname.str().c_str(),"READ"); |
2004 |
|
idtsy = (UInt_t)atoll(Row->GetField(2)); |
2005 |
|
}; |
2006 |
|
}; |
2007 |
|
// |
2008 |
|
if ( usel0file && file && file->IsOpen() ){ |
2009 |
|
TTree *T=(TTree*)file->Get("Physics"); |
2010 |
|
pamela::EventHeader *eh = 0; |
2011 |
|
pamela::PscuHeader *ph = 0; |
2012 |
|
T->SetBranchAddress("Header", &eh); |
2013 |
|
// |
2014 |
|
T->GetEntry(0); |
2015 |
|
ph = eh->GetPscuHeader(); |
2016 |
|
pktfirst = ph->GetCounter(); |
2017 |
|
// obtfirst = ph->GetOrbitalTime(); |
2018 |
|
// |
2019 |
|
}; |
2020 |
|
if ( !usel0file ) pktfirst = 0; |
2021 |
|
// |
2022 |
|
// look for Resurs offset |
2023 |
|
// |
2024 |
|
T0 = 0; |
2025 |
|
// |
2026 |
|
stringstream oss; |
2027 |
|
// |
2028 |
|
TString name=rname.str().c_str(); |
2029 |
|
// UInt_t dworbit = 0; |
2030 |
|
// Int_t nlength = name.Length(); |
2031 |
|
delete pResult; |
2032 |
|
if (Row){ |
2033 |
|
delete Row; |
2034 |
|
Row = NULL; |
2035 |
|
} |
2036 |
|
// |
2037 |
|
// New code, we have one more column on GL_TIMESYNC so we can trust that one for the Resurs offset |
2038 |
|
// |
2039 |
|
oss.str(""); |
2040 |
|
oss << "SELECT OBT0,TIMESYNC,TYPE,ID_RESURS_OFFSET from GL_TIMESYNC where ID=" << idtsy <<";"; |
2041 |
|
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return; |
2042 |
|
this->GetGLTABLES()->AddQ(); |
2043 |
|
pResult = dbc->Query(oss.str().c_str()); |
2044 |
|
Bool_t fndit = false; |
2045 |
if ( pResult ){ |
if ( pResult ){ |
2046 |
|
if (Row) |
2047 |
|
delete Row; |
2048 |
Row = pResult->Next(); |
Row = pResult->Next(); |
2049 |
if ( (Row != NULL) && ((UInt_t)atoll(Row->GetField(0)) > 0 ) ){ |
if ( Row ){ |
2050 |
|
// |
2051 |
OBT0 = (UInt_t)atoll(Row->GetField(0)); |
OBT0 = (UInt_t)atoll(Row->GetField(0)); |
2052 |
|
obtfirst = OBT0; |
2053 |
TIMESYNC = (UInt_t)atoll(Row->GetField(1)); |
TIMESYNC = (UInt_t)atoll(Row->GetField(1)); |
2054 |
TYPE = (UInt_t)atoll(Row->GetField(2)); |
TYPE = (UInt_t)atoll(Row->GetField(2)); |
2055 |
toffset = (UInt_t)atoll(Row->GetField(1)) - (UInt_t)(this->DBobt((UInt_t)atoll(Row->GetField(0)))/1000) + T0; |
// |
2056 |
|
oss.str(""); |
2057 |
|
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=" |
2058 |
|
<< Row->GetField(3) << ";"; |
2059 |
|
if ( !this->GetGLTABLES()->IsConnected(dbc) ){ |
2060 |
|
delete pResult; |
2061 |
|
delete Row; |
2062 |
|
return; |
2063 |
|
} |
2064 |
|
this->GetGLTABLES()->AddQ(); |
2065 |
|
delete pResult; |
2066 |
|
pResult = dbc->Query(oss.str().c_str()); |
2067 |
|
if (pResult){ |
2068 |
|
if (Row) |
2069 |
|
delete Row; |
2070 |
|
Row = pResult->Next(); |
2071 |
|
if (Row){ |
2072 |
|
// printf(" GREAT! the DB structure is the new one! \n"); |
2073 |
|
fndit = true; |
2074 |
|
// dworbit = 1; |
2075 |
|
}; |
2076 |
|
}; |
2077 |
}; |
}; |
2078 |
}; |
}; |
2079 |
|
if ( !fndit ){ |
2080 |
|
// |
2081 |
|
printf(" ERROR OLD DB! \n"); |
2082 |
|
printf(" ERROR FROM GLTables! cannot determine Resurs offset \n"); |
2083 |
|
// |
2084 |
|
}; |
2085 |
// |
// |
2086 |
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); |
2087 |
|
T0 = (UInt_t)tu.GetSec(); |
2088 |
|
// |
2089 |
|
toffset = (UInt_t)TIMESYNC - (UInt_t)(this->DBobt(OBT0)/1000) + T0; |
2090 |
|
// |
2091 |
|
// printf(" T0 %u toffset is %u \n",T0,toffset); |
2092 |
|
// |
2093 |
|
if ( file ) file->Close(); |
2094 |
|
if (Row) |
2095 |
|
delete Row; |
2096 |
delete pResult; |
delete pResult; |
2097 |
}; |
}; |
2098 |
|
|
2103 |
*/ |
*/ |
2104 |
UInt_t GL_TIMESYNC::DBabsTime(UInt_t OBT){ |
UInt_t GL_TIMESYNC::DBabsTime(UInt_t OBT){ |
2105 |
// |
// |
2106 |
|
// printf(" OBT %u DBobt %llu toffset %u dbabstime %u\n",OBT,this->DBobt(OBT),toffset,((UInt_t)(this->DBobt(OBT)/1000)+toffset)); |
2107 |
return(((UInt_t)(this->DBobt(OBT)/1000)+toffset)); |
return(((UInt_t)(this->DBobt(OBT)/1000)+toffset)); |
2108 |
// |
// |
2109 |
}; |
}; |
2142 |
*/ |
*/ |
2143 |
Long64_t GL_TIMESYNC::DBobt(UInt_t obt){ |
Long64_t GL_TIMESYNC::DBobt(UInt_t obt){ |
2144 |
// |
// |
2145 |
if ( obt < (obtfirst/2) && obtfirst > (numeric_limits<UInt_t>::max()/2) ){ |
if ( obt < ((Long64_t)obtfirst/2) && obtfirst > (numeric_limits<UInt_t>::max()/2) ){ |
2146 |
return((Long64_t)obt+(Long64_t)numeric_limits<UInt_t>::max()); |
return((Long64_t)obt+(Long64_t)numeric_limits<UInt_t>::max()); |
2147 |
}; |
}; |
2148 |
// |
// |
2149 |
if ( obt > (obtfirst*2) && obt > (numeric_limits<UInt_t>::max()/2) ){ |
if ( obt > ((Long64_t)obtfirst*2) && obt > (numeric_limits<UInt_t>::max()/2) ){ |
2150 |
return((Long64_t)obt-(Long64_t)numeric_limits<UInt_t>::max()); |
return((Long64_t)obt-(Long64_t)numeric_limits<UInt_t>::max()); |
2151 |
}; |
}; |
2152 |
// |
// |
2363 |
// |
// |
2364 |
Int_t GL_TLE::DoQuery(TString myquery, TSQLServer *dbc){ |
Int_t GL_TLE::DoQuery(TString myquery, TSQLServer *dbc){ |
2365 |
TSQLResult *result; |
TSQLResult *result; |
2366 |
TSQLRow *row; |
TSQLRow *row = NULL; |
2367 |
|
|
2368 |
// Set the right time_zone (otherwise horrible things will occur! :) |
// Set the right time_zone (otherwise horrible things will occur! :) |
2369 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
2370 |
dbc->Query("SET time_zone = '+0:00'"); |
delete dbc->Query("SET time_zone = '+0:00';"); |
2371 |
|
delete dbc->Query("SET sql_mode = 'NO_UNSIGNED_SUBTRACTION';"); |
2372 |
|
|
2373 |
// Do the query |
// Do the query |
2374 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
2375 |
result = dbc->Query(myquery.Data()); |
result = dbc->Query(myquery.Data()); |
2376 |
if(! result->GetRowCount() ) { |
if(! result->GetRowCount() ) { |
2377 |
cerr << "GL_TLE: query failed: " << myquery.Data() << endl; |
cerr << "GL_TLE: query failed: " << myquery.Data() << endl; |
2378 |
|
delete result; |
2379 |
return 1; |
return 1; |
2380 |
} |
} |
2381 |
|
|
2384 |
tle = GiveTle(row); |
tle = GiveTle(row); |
2385 |
|
|
2386 |
tleFromTime = strtol(row->GetField(4), NULL, 10); |
tleFromTime = strtol(row->GetField(4), NULL, 10); |
2387 |
|
if (row) |
2388 |
|
delete row; |
2389 |
row = result->Next(); // second tle row |
row = result->Next(); // second tle row |
2390 |
if(row) |
if(row) |
2391 |
tleToTime = strtol(row->GetField(4), NULL, 10); |
tleToTime = strtol(row->GetField(4), NULL, 10); |
2394 |
tleToTime = UINT_MAX; |
tleToTime = UINT_MAX; |
2395 |
} |
} |
2396 |
|
|
2397 |
delete row; |
if (row) |
2398 |
|
delete row; |
2399 |
delete result; |
delete result; |
2400 |
|
|
2401 |
return 0; |
return 0; |