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()) ){ |
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++; |
fNquery++; |
267 |
myquery.str(""); |
myquery.str(""); |
268 |
myquery << "SET wait_timeout=173000;"; |
myquery << "SET wait_timeout=173000;"; |
269 |
dbc->Query(myquery.str().c_str()); |
delete dbc->Query(myquery.str().c_str()); |
270 |
fNquery++; |
fNquery++; |
271 |
return true; |
return true; |
272 |
}; |
}; |
373 |
NAME = ""; |
NAME = ""; |
374 |
} |
} |
375 |
|
|
376 |
|
GL_RAW::GL_RAW(){ |
377 |
|
ID = 0; |
378 |
|
PATH = ""; |
379 |
|
NAME = ""; |
380 |
|
BOOT_NUMBER = 0; |
381 |
|
} |
382 |
|
|
383 |
GL_PARAM::GL_PARAM(){ |
GL_PARAM::GL_PARAM(){ |
384 |
ID = 0; |
ID = 0; |
385 |
PATH = ""; |
PATH = ""; |
685 |
Int_t GL_RUN::DeleteRun(TSQLServer *dbc,UInt_t IDRUN,TString FromTable){ |
Int_t GL_RUN::DeleteRun(TSQLServer *dbc,UInt_t IDRUN,TString FromTable){ |
686 |
// MySQL variables |
// MySQL variables |
687 |
TSQLResult *pResult; |
TSQLResult *pResult; |
688 |
TSQLRow *Row; |
TSQLRow *Row = NULL; |
689 |
stringstream myquery; |
stringstream myquery; |
690 |
// |
// |
691 |
if ( !IDRUN ) IDRUN = ID; |
if ( !IDRUN ) IDRUN = ID; |
735 |
// |
// |
736 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
737 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
738 |
dbc->Query(myquery.str().c_str()); |
delete dbc->Query(myquery.str().c_str()); |
739 |
// |
// |
740 |
// retrieve this ID_TRASH |
// retrieve this ID_TRASH |
741 |
// |
// |
749 |
UInt_t idl0 = 0; |
UInt_t idl0 = 0; |
750 |
UInt_t idl2 = 0; |
UInt_t idl2 = 0; |
751 |
// |
// |
752 |
|
if (Row) |
753 |
|
delete Row; |
754 |
Row = pResult->Next(); |
Row = pResult->Next(); |
755 |
if( Row != NULL ){ |
if( Row != NULL ){ |
756 |
idtrash = (UInt_t)atoll(Row->GetField(0)); |
idtrash = (UInt_t)atoll(Row->GetField(0)); |
766 |
// |
// |
767 |
// printf("2myquery is %s \n",myquery.str().c_str()); |
// printf("2myquery is %s \n",myquery.str().c_str()); |
768 |
// |
// |
769 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
if ( !this->GetGLTABLES()->IsConnected(dbc) ){ |
770 |
|
if (pResult) |
771 |
|
delete pResult; |
772 |
|
if (Row) |
773 |
|
delete Row; |
774 |
|
return -57; |
775 |
|
} |
776 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
777 |
pResult = dbc->Query(myquery.str().c_str()); |
pResult = dbc->Query(myquery.str().c_str()); |
778 |
// |
// |
779 |
|
if (Row) |
780 |
|
delete Row; |
781 |
Row = pResult->Next(); |
Row = pResult->Next(); |
782 |
if( Row != NULL ){ |
if( Row != NULL ){ |
783 |
fileL0 = (TString)Row->GetField(0); |
fileL0 = (TString)Row->GetField(0); |
791 |
// |
// |
792 |
// printf("3myquery is %s \n",myquery.str().c_str()); |
// printf("3myquery is %s \n",myquery.str().c_str()); |
793 |
// |
// |
794 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
if ( !this->GetGLTABLES()->IsConnected(dbc) ){ |
795 |
|
if (pResult) |
796 |
|
delete pResult; |
797 |
|
if (Row) |
798 |
|
delete Row; |
799 |
|
return -57; |
800 |
|
} |
801 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
802 |
pResult = dbc->Query(myquery.str().c_str()); |
pResult = dbc->Query(myquery.str().c_str()); |
803 |
// |
// |
804 |
|
if (Row) |
805 |
|
delete Row; |
806 |
Row = pResult->Next(); |
Row = pResult->Next(); |
807 |
if( Row != NULL ){ |
if( Row != NULL ){ |
808 |
fileL2 = (TString)Row->GetField(0); |
fileL2 = (TString)Row->GetField(0); |
809 |
}; |
} |
810 |
|
delete pResult; |
811 |
|
pResult = NULL; |
812 |
|
if (Row){ |
813 |
|
delete Row; |
814 |
|
Row = NULL; // This variable is not used below |
815 |
|
} |
816 |
// |
// |
817 |
// |
// |
818 |
// |
// |
825 |
// |
// |
826 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
827 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
828 |
dbc->Query(myquery.str().c_str()); |
delete dbc->Query(myquery.str().c_str()); |
829 |
// |
// |
830 |
myquery.str(""); |
myquery.str(""); |
831 |
myquery << " UPDATE GL_RUN_TRASH SET FILENAMEL2='"; |
myquery << " UPDATE GL_RUN_TRASH SET FILENAMEL2='"; |
836 |
// |
// |
837 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
838 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
839 |
dbc->Query(myquery.str().c_str()); |
delete dbc->Query(myquery.str().c_str()); |
840 |
// |
// |
841 |
myquery.str(""); |
myquery.str(""); |
842 |
myquery << " UPDATE GL_RUN_TRASH SET BELONGED_TO='"; |
myquery << " UPDATE GL_RUN_TRASH SET BELONGED_TO='"; |
848 |
// |
// |
849 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
850 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
851 |
dbc->Query(myquery.str().c_str()); |
delete dbc->Query(myquery.str().c_str()); |
852 |
// |
// |
853 |
myquery.str(""); |
myquery.str(""); |
854 |
myquery << " DELETE FROM "; |
myquery << " DELETE FROM "; |
860 |
// |
// |
861 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
862 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
863 |
dbc->Query(myquery.str().c_str()); |
delete dbc->Query(myquery.str().c_str()); |
864 |
// |
// |
865 |
return 0; |
return 0; |
866 |
}; |
}; |
876 |
// insert into GL_RUN_FRAGMENTS select * FROM GL_RUN where ID=11; |
// insert into GL_RUN_FRAGMENTS select * FROM GL_RUN where ID=11; |
877 |
//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; |
878 |
// MySQL variables |
// MySQL variables |
879 |
TSQLResult *pResult; |
TSQLResult *pResult = NULL; |
880 |
TSQLRow *Row; |
TSQLRow *Row = NULL; |
881 |
stringstream myquery; |
stringstream myquery; |
882 |
// |
// |
883 |
if ( !IDRUN ) IDRUN = ID; |
if ( !IDRUN ) IDRUN = ID; |
899 |
if( Row != NULL ){ |
if( Row != NULL ){ |
900 |
ToTable = (TString)Row->GetField(0); |
ToTable = (TString)Row->GetField(0); |
901 |
} else { |
} else { |
902 |
|
delete pResult; |
903 |
return 1; |
return 1; |
904 |
}; |
}; |
905 |
}; |
}; |
906 |
|
|
907 |
|
if (pResult) |
908 |
|
delete pResult; |
909 |
|
if (Row) |
910 |
|
delete Row; |
911 |
// ---------------- |
// ---------------- |
912 |
myquery.str(""); |
myquery.str(""); |
913 |
myquery << " INSERT INTO "; |
myquery << " INSERT INTO "; |
988 |
// |
// |
989 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
990 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
991 |
dbc->Query(myquery.str().c_str()); |
delete dbc->Query(myquery.str().c_str()); |
992 |
// |
// |
993 |
// |
// |
994 |
myquery.str(""); |
myquery.str(""); |
997 |
// |
// |
998 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
999 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
1000 |
dbc->Query(myquery.str().c_str()); |
delete dbc->Query(myquery.str().c_str()); |
1001 |
// |
// |
1002 |
return 0; |
return 0; |
1003 |
}; |
}; |
1085 |
// |
// |
1086 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
1087 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
1088 |
dbc->Query(myquery.str().c_str()); |
delete dbc->Query(myquery.str().c_str()); |
1089 |
// |
// |
1090 |
return 0; |
return 0; |
1091 |
|
|
1167 |
// |
// |
1168 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
1169 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
1170 |
dbc->Query(myquery.str().c_str()); |
delete dbc->Query(myquery.str().c_str()); |
1171 |
// |
// |
1172 |
return 0; |
return 0; |
1173 |
|
|
1184 |
Int_t GL_RUN::Query_GL_RUN(UInt_t run, TSQLServer *dbc){ |
Int_t GL_RUN::Query_GL_RUN(UInt_t run, TSQLServer *dbc){ |
1185 |
// MySQL variables |
// MySQL variables |
1186 |
TSQLResult *pResult; |
TSQLResult *pResult; |
1187 |
TSQLRow *Row; |
TSQLRow *Row = NULL; |
|
int t; |
|
1188 |
int r; |
int r; |
1189 |
stringstream myquery; |
stringstream myquery; |
1190 |
// ---------------- |
// ---------------- |
1231 |
// |
// |
1232 |
// printf(" getrowcount %i \n",pResult->GetRowCount()); |
// printf(" getrowcount %i \n",pResult->GetRowCount()); |
1233 |
// |
// |
1234 |
if( !pResult->GetRowCount() ) return(-50); |
if( !pResult->GetRowCount() ){ |
1235 |
|
delete pResult; |
1236 |
|
if (Row) |
1237 |
|
delete Row; |
1238 |
|
return(-50); |
1239 |
|
} |
1240 |
// |
// |
1241 |
for( r=0; r < 1000; r++){ |
for( r=0; r < 1000; r++){ |
1242 |
|
if (Row) |
1243 |
|
delete Row; |
1244 |
Row = pResult->Next(); |
Row = pResult->Next(); |
1245 |
if( Row == NULL ) break; |
if( Row == NULL ) break; |
1246 |
// Set_GL_RUN(Row); |
// Set_GL_RUN(Row); |
1247 |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
for( int t = 0; t < pResult->GetFieldCount(); t++){ |
1248 |
if (t== 0) ID = (UInt_t)atoll(Row->GetField(t)); |
if (t== 0) ID = (UInt_t)atoll(Row->GetField(t)); |
1249 |
if (t== 1) ID_RUN_FRAG = (UInt_t)atoll(Row->GetField(t)); |
if (t== 1) ID_RUN_FRAG = (UInt_t)atoll(Row->GetField(t)); |
1250 |
if (t== 2) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); |
if (t== 2) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); |
1278 |
if (t==30) PHYSENDRUN_MASK_S11CRC = (UInt_t)atoll(Row->GetField(t)); |
if (t==30) PHYSENDRUN_MASK_S11CRC = (UInt_t)atoll(Row->GetField(t)); |
1279 |
if (t==31) VALIDATION = (UInt_t)atoll(Row->GetField(t)); |
if (t==31) VALIDATION = (UInt_t)atoll(Row->GetField(t)); |
1280 |
}; |
}; |
1281 |
}; |
} |
1282 |
// delete pResult; |
|
1283 |
|
if (Row) |
1284 |
|
delete Row; |
1285 |
|
delete pResult; |
1286 |
return(0); |
return(0); |
1287 |
}; |
}; |
1288 |
|
|
1296 |
Int_t GL_RUN::Query_GL_RUN_FRAGMENTS(TString where, TSQLServer *dbc){ |
Int_t GL_RUN::Query_GL_RUN_FRAGMENTS(TString where, TSQLServer *dbc){ |
1297 |
// MySQL variables |
// MySQL variables |
1298 |
TSQLResult *pResult; |
TSQLResult *pResult; |
1299 |
TSQLRow *Row; |
TSQLRow *Row = NULL; |
1300 |
int t; |
int t; |
1301 |
int r; |
int r; |
1302 |
stringstream myquery; |
stringstream myquery; |
1342 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
1343 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
1344 |
pResult = dbc->Query(myquery.str().c_str()); |
pResult = dbc->Query(myquery.str().c_str()); |
1345 |
if(!pResult->GetRowCount())return(-50); |
if(!pResult->GetRowCount()){ |
1346 |
|
delete pResult; |
1347 |
|
if (Row) |
1348 |
|
delete Row; |
1349 |
|
return(-50); |
1350 |
|
} |
1351 |
for( r=0; r < 1000; r++){ |
for( r=0; r < 1000; r++){ |
1352 |
|
if (Row) |
1353 |
|
delete Row; |
1354 |
Row = pResult->Next(); |
Row = pResult->Next(); |
1355 |
if( Row == NULL ) break; |
if( Row == NULL ) break; |
1356 |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
1387 |
if (t==30) PHYSENDRUN_MASK_S11CRC = (UInt_t)atoll(Row->GetField(t)); |
if (t==30) PHYSENDRUN_MASK_S11CRC = (UInt_t)atoll(Row->GetField(t)); |
1388 |
if (t==31) VALIDATION = (UInt_t)atoll(Row->GetField(t)); |
if (t==31) VALIDATION = (UInt_t)atoll(Row->GetField(t)); |
1389 |
}; |
}; |
1390 |
}; |
} |
1391 |
// delete pResult; |
|
1392 |
|
if (Row) |
1393 |
|
delete Row; |
1394 |
|
delete pResult; |
1395 |
return(0); |
return(0); |
1396 |
};// **************************************************** |
};// **************************************************** |
1397 |
|
|
1404 |
Int_t GL_ROOT::Query_GL_ROOT(UInt_t id, TSQLServer *dbc){ |
Int_t GL_ROOT::Query_GL_ROOT(UInt_t id, TSQLServer *dbc){ |
1405 |
// MySQL variables |
// MySQL variables |
1406 |
TSQLResult *pResult; |
TSQLResult *pResult; |
1407 |
TSQLRow *Row; |
TSQLRow *Row = NULL; |
1408 |
int t; |
int t; |
1409 |
int r; |
int r; |
1410 |
stringstream myquery; |
stringstream myquery; |
1421 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
1422 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
1423 |
pResult = dbc->Query(myquery.str().c_str()); |
pResult = dbc->Query(myquery.str().c_str()); |
1424 |
if(!pResult->GetRowCount())return (-51); |
if(!pResult->GetRowCount()){ |
1425 |
|
delete pResult; |
1426 |
|
if (Row) |
1427 |
|
delete Row; |
1428 |
|
return (-51); |
1429 |
|
} |
1430 |
for( r=0; r < 1000; r++){ |
for( r=0; r < 1000; r++){ |
1431 |
|
if (Row) |
1432 |
|
delete Row; |
1433 |
Row = pResult->Next(); |
Row = pResult->Next(); |
1434 |
if( Row == NULL ) break; |
if( Row == NULL ) break; |
1435 |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
1436 |
if(t==0) ID = (UInt_t)atoll(Row->GetField(t)); |
if(t==0) ID = (UInt_t)atoll(Row->GetField(t)); |
1437 |
if(t==1) ID_RAW = (UInt_t)atoll(Row->GetField(t)); |
if(t==1) ID_RAW = (UInt_t)atoll(Row->GetField(t)); |
1438 |
if(t==2) ID_TIMESYNC = (UInt_t)atoll(Row->GetField(t)); |
if(t==2) ID_TIMESYNC = (UInt_t)atoll(Row->GetField(t)); |
1439 |
if(t==3) PATH = (TString)gSystem->ExpandPathName(Row->GetField(t))+'/'; |
if(t==3){ |
1440 |
|
PATH = TString(Row->GetField(t)) + '/'; |
1441 |
|
gSystem->ExpandPathName(PATH); |
1442 |
|
} |
1443 |
if(t==4) NAME = Row->GetField(t); |
if(t==4) NAME = Row->GetField(t); |
1444 |
}; |
} |
1445 |
}; |
} |
1446 |
|
if (Row) |
1447 |
|
delete Row; |
1448 |
delete pResult; |
delete pResult; |
1449 |
return 0; |
return 0; |
1450 |
}; |
}; |
1459 |
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){ |
1460 |
// MySQL variables |
// MySQL variables |
1461 |
TSQLResult *pResult; |
TSQLResult *pResult; |
1462 |
TSQLRow *Row; |
TSQLRow *Row = NULL; |
1463 |
int t; |
int t; |
1464 |
int r; |
int r; |
1465 |
stringstream myquery; |
stringstream myquery; |
1473 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
1474 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
1475 |
pResult = dbc->Query(myquery.str().c_str()); |
pResult = dbc->Query(myquery.str().c_str()); |
1476 |
if(!pResult->GetRowCount())return (-53); |
if(!pResult->GetRowCount()){ |
1477 |
|
delete pResult; |
1478 |
|
return (-53); |
1479 |
|
} |
1480 |
for( r=0; r < 1000; r++){ |
for( r=0; r < 1000; r++){ |
1481 |
|
if (Row) |
1482 |
|
delete Row; |
1483 |
Row = pResult->Next(); |
Row = pResult->Next(); |
1484 |
if( Row == NULL ) break; |
if( Row == NULL ) break; |
1485 |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
1500 |
if (t==10) BOOT_NUMBER = (UInt_t)atoll(Row->GetField(t)); |
if (t==10) BOOT_NUMBER = (UInt_t)atoll(Row->GetField(t)); |
1501 |
if (t==11) VALIDATION = (UInt_t)atoll(Row->GetField(t)); |
if (t==11) VALIDATION = (UInt_t)atoll(Row->GetField(t)); |
1502 |
}; |
}; |
1503 |
}; |
} |
1504 |
|
if (Row) |
1505 |
|
delete Row; |
1506 |
delete pResult; |
delete pResult; |
1507 |
// |
// |
1508 |
// if ( TO_TIME < time ) return(51); |
// if ( TO_TIME < time ) return(51); |
1522 |
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){ |
1523 |
// MySQL variables |
// MySQL variables |
1524 |
TSQLResult *pResult; |
TSQLResult *pResult; |
1525 |
TSQLRow *Row; |
TSQLRow *Row = NULL; |
1526 |
int t; |
int t; |
1527 |
stringstream myquery; |
stringstream myquery; |
1528 |
uptime = 0; |
uptime = 0; |
1539 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
1540 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
1541 |
pResult = dbc->Query(myquery.str().c_str()); |
pResult = dbc->Query(myquery.str().c_str()); |
1542 |
// printf(" mysquery is %s\n",myquery.str().c_str()); |
// printf(" mysquery is %s\n",myquery.str().c_str()); |
1543 |
// |
// |
1544 |
if( !pResult->GetRowCount() ) return(-54); |
if (Row) |
1545 |
|
delete Row; |
1546 |
|
if( !pResult->GetRowCount() ){ |
1547 |
|
delete pResult; |
1548 |
|
return(-54); |
1549 |
|
} |
1550 |
Row = pResult->Next(); |
Row = pResult->Next(); |
1551 |
if( Row == NULL ) return (-54); |
if( Row == NULL ){ |
1552 |
|
delete pResult; |
1553 |
|
return (-54); |
1554 |
|
} |
1555 |
// |
// |
1556 |
uptime = (UInt_t)atoll(Row->GetField(2)); |
uptime = (UInt_t)atoll(Row->GetField(2)); |
1557 |
// |
// |
1568 |
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; |
1569 |
myquery << " and FROM_TIME <= " << time; |
myquery << " and FROM_TIME <= " << time; |
1570 |
myquery << " and VALIDATION=1 ORDER BY FROM_TIME DESC LIMIT 1;"; |
myquery << " and VALIDATION=1 ORDER BY FROM_TIME DESC LIMIT 1;"; |
1571 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
if ( !this->GetGLTABLES()->IsConnected(dbc) ){ |
1572 |
|
if(pResult) |
1573 |
|
delete pResult; |
1574 |
|
if(Row) |
1575 |
|
delete Row; |
1576 |
|
return -57; |
1577 |
|
} |
1578 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
1579 |
pResult = dbc->Query(myquery.str().c_str()); |
pResult = dbc->Query(myquery.str().c_str()); |
1580 |
// printf(" mysquery is %s\n",myquery.str().c_str()); |
// printf(" mysquery is %s\n",myquery.str().c_str()); |
1581 |
// |
// |
1582 |
// if no results yet quit with error |
// if no results yet quit with error |
1583 |
// |
// |
1584 |
if( !pResult->GetRowCount() ) return (-54); |
if( !pResult->GetRowCount() ){ |
1585 |
|
delete pResult; |
1586 |
|
if(Row) |
1587 |
|
delete Row; |
1588 |
|
return (-54); |
1589 |
|
} |
1590 |
// |
// |
1591 |
|
if (Row) |
1592 |
|
delete Row; |
1593 |
Row = pResult->Next(); |
Row = pResult->Next(); |
1594 |
// |
// |
1595 |
myfromtime = (UInt_t)atoll(Row->GetField(1)); |
myfromtime = (UInt_t)atoll(Row->GetField(1)); |
1603 |
myquery.str(""); |
myquery.str(""); |
1604 |
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; |
1605 |
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;"; |
1606 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
if ( !this->GetGLTABLES()->IsConnected(dbc) ){ |
1607 |
|
if(pResult) |
1608 |
|
delete pResult; |
1609 |
|
if(Row) |
1610 |
|
delete Row; |
1611 |
|
return -57; |
1612 |
|
} |
1613 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
1614 |
pResult = dbc->Query(myquery.str().c_str()); |
pResult = dbc->Query(myquery.str().c_str()); |
1615 |
// printf(" mysquery is %s\n",myquery.str().c_str()); |
// printf(" mysquery is %s\n",myquery.str().c_str()); |
1616 |
// |
// |
1617 |
// if no results yet quit with error |
// if no results yet quit with error |
1618 |
// |
// |
1619 |
if( !pResult->GetRowCount() ) return (-54); |
if( !pResult->GetRowCount() ){ |
1620 |
|
if (Row) |
1621 |
|
delete Row; |
1622 |
|
delete pResult; |
1623 |
|
return (-54); |
1624 |
|
} |
1625 |
// |
// |
1626 |
|
if (Row) |
1627 |
|
delete Row; |
1628 |
Row = pResult->Next(); |
Row = pResult->Next(); |
1629 |
// |
// |
1630 |
}; |
}; |
1631 |
// |
// |
1632 |
// store infos and exit |
// store infos and exit |
1633 |
// |
// |
1634 |
if( Row == NULL ) return (-54); |
if( Row == NULL ){ |
1635 |
|
delete pResult; |
1636 |
|
return (-54); |
1637 |
|
} |
1638 |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
1639 |
if (t==0) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); |
if (t==0) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); |
1640 |
if (t==1) FROM_TIME = myfromtime; |
if (t==1) FROM_TIME = myfromtime; |
1641 |
if (t==2) TO_TIME = mytotime; |
if (t==2) TO_TIME = mytotime; |
1642 |
if (t==3) EV_ROOT = (UInt_t)atoll(Row->GetField(t)); |
if (t==3) EV_ROOT = (UInt_t)atoll(Row->GetField(t)); |
1643 |
}; |
} |
1644 |
pResult->Delete(); |
if (Row) |
1645 |
|
delete Row; |
1646 |
|
delete pResult; |
1647 |
return 0; |
return 0; |
1648 |
}; |
}; |
1649 |
|
|
1658 |
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){ |
1659 |
// MySQL variables |
// MySQL variables |
1660 |
TSQLResult *pResult; |
TSQLResult *pResult; |
1661 |
TSQLRow *Row; |
TSQLRow *Row = NULL; |
1662 |
int t; |
int t; |
1663 |
stringstream myquery; |
stringstream myquery; |
1664 |
// |
// |
1676 |
// |
// |
1677 |
if( !pResult ) return(-54); |
if( !pResult ) return(-54); |
1678 |
// |
// |
1679 |
|
if (Row) |
1680 |
|
delete Row; |
1681 |
Row = pResult->Next(); |
Row = pResult->Next(); |
1682 |
// |
// |
1683 |
if( !Row ) return (-54); |
if( !Row ){ |
1684 |
|
delete pResult; |
1685 |
|
return (-54); |
1686 |
|
} |
1687 |
// |
// |
1688 |
// store infos and exit |
// store infos and exit |
1689 |
// |
// |
1693 |
if (t==1) FROM_TIME = (UInt_t)atoll(Row->GetField(t)); |
if (t==1) FROM_TIME = (UInt_t)atoll(Row->GetField(t)); |
1694 |
if (t==2) TO_TIME = (UInt_t)atoll(Row->GetField(t)); |
if (t==2) TO_TIME = (UInt_t)atoll(Row->GetField(t)); |
1695 |
if (t==3) EV_ROOT = (UInt_t)atoll(Row->GetField(t)); |
if (t==3) EV_ROOT = (UInt_t)atoll(Row->GetField(t)); |
1696 |
}; |
} |
1697 |
|
if (Row) |
1698 |
|
delete Row; |
1699 |
pResult->Delete(); |
pResult->Delete(); |
1700 |
return 0; |
return 0; |
1701 |
}; |
}; |
1711 |
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){ |
1712 |
// MySQL variables |
// MySQL variables |
1713 |
TSQLResult *pResult; |
TSQLResult *pResult; |
1714 |
TSQLRow *Row; |
TSQLRow *Row = NULL; |
1715 |
int t; |
int t; |
1716 |
int r; |
int r; |
1717 |
stringstream myquery; |
stringstream myquery; |
1723 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
1724 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
1725 |
pResult = dbc->Query(myquery.str().c_str()); |
pResult = dbc->Query(myquery.str().c_str()); |
1726 |
if(!pResult->GetRowCount())return (-55);//throw -55; |
if(!pResult->GetRowCount()){ |
1727 |
|
delete pResult; |
1728 |
|
return (-55);//throw -55; |
1729 |
|
} |
1730 |
for( r=0; r < 1000; r++){ |
for( r=0; r < 1000; r++){ |
1731 |
|
if (Row) |
1732 |
|
delete Row; |
1733 |
Row = pResult->Next(); |
Row = pResult->Next(); |
1734 |
if( Row == NULL ) break; |
if( Row == NULL ) break; |
1735 |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
1739 |
if (t==3) FROM_TIME = (UInt_t)atoll(Row->GetField(t)); |
if (t==3) FROM_TIME = (UInt_t)atoll(Row->GetField(t)); |
1740 |
if (t==4) TO_TIME = (UInt_t)atoll(Row->GetField(t)); |
if (t==4) TO_TIME = (UInt_t)atoll(Row->GetField(t)); |
1741 |
}; |
}; |
1742 |
}; |
} |
1743 |
|
if (Row) |
1744 |
|
delete Row; |
1745 |
delete pResult; |
delete pResult; |
1746 |
// |
// |
1747 |
if(TO_TIME < time)return(51); |
if(TO_TIME < time)return(51); |
1760 |
// Bool_t debug = 1; |
// Bool_t debug = 1; |
1761 |
// MySQL variables |
// MySQL variables |
1762 |
TSQLResult *pResult; |
TSQLResult *pResult; |
1763 |
TSQLRow *Row; |
TSQLRow *Row = NULL; |
1764 |
int t; |
int t; |
1765 |
int r; |
int r; |
1766 |
stringstream myquery; |
stringstream myquery; |
1776 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
1777 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
1778 |
pResult = dbc->Query(myquery.str().c_str()); |
pResult = dbc->Query(myquery.str().c_str()); |
1779 |
if(!pResult->GetRowCount())return (-52); |
if(!pResult->GetRowCount()){ |
1780 |
|
delete pResult; |
1781 |
|
return (-52); |
1782 |
|
} |
1783 |
for( r=0; r < 1000; r++){ |
for( r=0; r < 1000; r++){ |
1784 |
|
if (Row) |
1785 |
|
delete Row; |
1786 |
Row = pResult->Next(); |
Row = pResult->Next(); |
1787 |
if( Row == NULL ) break; |
if( Row == NULL ) break; |
1788 |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
1789 |
if (t==0) ID = (UInt_t)atoll(Row->GetField(t)); |
if (t==0) ID = (UInt_t)atoll(Row->GetField(t)); |
1790 |
if (t==1) PATH = (TString)gSystem->ExpandPathName(Row->GetField(t))+'/';// put in fpath the path to that file |
if (t==1) { |
1791 |
if (t==2) NAME = Row->GetField(t); |
PATH = TString(Row->GetField(t)) + "/";// put in fpath the path to that file |
1792 |
if (t==3) DESCR = Row->GetField(t); |
gSystem->ExpandPathName(PATH); |
1793 |
if (t==4) FROM_TIME = (UInt_t)atoll(Row->GetField(t)); |
} |
1794 |
if (t==5) TO_TIME = (UInt_t)atoll(Row->GetField(t)); |
if (t==2) NAME = Row->GetField(t); |
1795 |
if (t==6) TYPE = (UInt_t)atoll(Row->GetField(t)); |
if (t==3) DESCR = Row->GetField(t); |
1796 |
|
if (t==4) FROM_TIME = (UInt_t)atoll(Row->GetField(t)); |
1797 |
|
if (t==5) TO_TIME = (UInt_t)atoll(Row->GetField(t)); |
1798 |
|
if (t==6) TYPE = (UInt_t)atoll(Row->GetField(t)); |
1799 |
}; |
}; |
1800 |
}; |
} |
1801 |
|
if (Row) |
1802 |
|
delete Row; |
1803 |
delete pResult; |
delete pResult; |
1804 |
// |
// |
1805 |
if(TO_TIME==0) TO_TIME = numeric_limits<UInt_t>::max(); |
if(TO_TIME==0) TO_TIME = numeric_limits<UInt_t>::max(); |
1832 |
GL_TIMESYNC::GL_TIMESYNC(UInt_t id, TString type, TSQLServer *dbc){ |
GL_TIMESYNC::GL_TIMESYNC(UInt_t id, TString type, TSQLServer *dbc){ |
1833 |
// MySQL variables |
// MySQL variables |
1834 |
TFile *file = 0; |
TFile *file = 0; |
1835 |
UInt_t idraw = 0; |
UInt_t idtsy = 0; |
1836 |
// |
// |
1837 |
TSQLResult *pResult; |
TSQLResult *pResult; |
1838 |
TSQLRow *Row; |
TSQLRow *Row = NULL; |
1839 |
stringstream myquery; |
stringstream myquery; |
1840 |
stringstream rname; |
stringstream rname; |
1841 |
// pcksList packetsNames; |
// pcksList packetsNames; |
1846 |
myquery.str(""); |
myquery.str(""); |
1847 |
myquery << "select "; |
myquery << "select "; |
1848 |
myquery << "PATH"; |
myquery << "PATH"; |
1849 |
myquery << ",NAME,ID_RAW"; |
myquery << ",NAME,ID_TIMESYNC"; |
1850 |
myquery << " from GL_ROOT where "; |
myquery << " from GL_ROOT where "; |
1851 |
myquery << type.Data(); |
myquery << type.Data(); |
1852 |
myquery << "=" << id << ";"; |
myquery << "=" << id << ";"; |
1855 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
1856 |
pResult = dbc->Query(myquery.str().c_str()); |
pResult = dbc->Query(myquery.str().c_str()); |
1857 |
if( pResult->GetRowCount() ){ |
if( pResult->GetRowCount() ){ |
1858 |
|
if (Row) |
1859 |
|
delete Row; |
1860 |
Row = pResult->Next(); |
Row = pResult->Next(); |
1861 |
if( Row ){ |
if( Row ){ |
1862 |
stringstream fname; |
stringstream fname; |
1863 |
fname.str(""); |
fname.str(""); |
1864 |
fname << gSystem->ExpandPathName(Row->GetField(0)) << "/" << Row->GetField(1); |
TString auxStr(Row->GetField(0)); |
1865 |
|
gSystem->ExpandPathName(auxStr); |
1866 |
|
fname << auxStr << "/" << Row->GetField(1); |
1867 |
rname << Row->GetField(1); |
rname << Row->GetField(1); |
1868 |
file = new TFile(fname.str().c_str(),"READ"); |
file = new TFile(fname.str().c_str(),"READ"); |
1869 |
idraw = (UInt_t)atoll(Row->GetField(2)); |
idtsy = (UInt_t)atoll(Row->GetField(2)); |
1870 |
}; |
}; |
1871 |
}; |
}; |
1872 |
// |
// |
1879 |
T->GetEntry(0); |
T->GetEntry(0); |
1880 |
ph = eh->GetPscuHeader(); |
ph = eh->GetPscuHeader(); |
1881 |
pktfirst = ph->GetCounter(); |
pktfirst = ph->GetCounter(); |
1882 |
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(); |
|
|
// // |
|
|
// }; |
|
|
// }; |
|
1883 |
// |
// |
1884 |
}; |
}; |
1885 |
// |
// |
1887 |
// |
// |
1888 |
T0 = 0; |
T0 = 0; |
1889 |
// |
// |
|
// |
|
1890 |
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(); |
|
1891 |
// |
// |
1892 |
TString name=rname.str().c_str(); |
TString name=rname.str().c_str(); |
1893 |
UInt_t dworbit = 0; |
// UInt_t dworbit = 0; |
1894 |
Int_t nlength = name.Length(); |
// Int_t nlength = name.Length(); |
1895 |
|
delete pResult; |
1896 |
|
if (Row){ |
1897 |
|
delete Row; |
1898 |
|
Row = NULL; |
1899 |
|
} |
1900 |
// |
// |
1901 |
// 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 |
1902 |
// |
// |
1903 |
if ( !Row ){ |
oss.str(""); |
1904 |
delete pResult; |
oss << "SELECT OBT0,TIMESYNC,TYPE,ID_RESURS_OFFSET from GL_TIMESYNC where ID=" << idtsy <<";"; |
1905 |
// |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return; |
1906 |
// New code, we have one more column on GL_TIMESYNC so we can trust that one for the Resurs offset |
this->GetGLTABLES()->AddQ(); |
1907 |
// |
pResult = dbc->Query(oss.str().c_str()); |
1908 |
oss.str(""); |
Bool_t fndit = false; |
1909 |
oss << "SELECT ID_RESURS_OFFSET from GL_TIMESYNC where ID_RAW=" << idraw <<";"; |
if ( pResult ){ |
1910 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return; |
if (Row) |
1911 |
this->GetGLTABLES()->AddQ(); |
delete Row; |
1912 |
pResult = dbc->Query(oss.str().c_str()); |
Row = pResult->Next(); |
1913 |
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 |
|
1914 |
// |
// |
1915 |
if ( nlength < 5 ) return; |
OBT0 = (UInt_t)atoll(Row->GetField(0)); |
1916 |
TString dwo = 0; |
obtfirst = OBT0; |
1917 |
for (Int_t i = 0; i<5; i++){ |
TIMESYNC = (UInt_t)atoll(Row->GetField(1)); |
1918 |
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; |
|
|
}; |
|
|
}; |
|
1919 |
// |
// |
1920 |
oss.str(""); |
oss.str(""); |
1921 |
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=" |
1922 |
<< dworbit << " order by FROM_ORBIT desc limit 1;"; |
<< Row->GetField(3) << ";"; |
1923 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return; |
if ( !this->GetGLTABLES()->IsConnected(dbc) ){ |
1924 |
|
delete pResult; |
1925 |
|
delete Row; |
1926 |
|
return; |
1927 |
|
} |
1928 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
1929 |
|
delete pResult; |
1930 |
pResult = dbc->Query(oss.str().c_str()); |
pResult = dbc->Query(oss.str().c_str()); |
1931 |
Row = pResult->Next(); |
if (pResult){ |
1932 |
if ( !Row ){ |
if (Row) |
1933 |
printf(" ERROR FROM GLTables! cannot determine Resurs offset \n"); |
delete Row; |
1934 |
return; |
Row = pResult->Next(); |
1935 |
|
if ( Row ){ |
1936 |
|
// printf(" GREAT! the DB structure is the new one! \n"); |
1937 |
|
fndit = true; |
1938 |
|
// dworbit = 1; |
1939 |
|
}; |
1940 |
}; |
}; |
1941 |
}; |
}; |
1942 |
}; |
}; |
1943 |
|
if ( !fndit ){ |
1944 |
|
// |
1945 |
|
printf(" ERROR OLD DB! \n"); |
1946 |
|
printf(" ERROR FROM GLTables! cannot determine Resurs offset \n"); |
1947 |
|
// |
1948 |
|
}; |
1949 |
// |
// |
1950 |
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); |
1951 |
T0 = (UInt_t)tu.GetSec(); |
T0 = (UInt_t)tu.GetSec(); |
1952 |
// |
// |
1953 |
// look for the correct timesync entry |
toffset = (UInt_t)TIMESYNC - (UInt_t)(this->DBobt(OBT0)/1000) + T0; |
1954 |
|
// |
1955 |
|
// printf(" T0 %u toffset is %u \n",T0,toffset); |
1956 |
// |
// |
1957 |
|
if ( file ) file->Close(); |
1958 |
|
if (Row) |
1959 |
|
delete Row; |
1960 |
|
delete pResult; |
1961 |
|
}; |
1962 |
|
|
1963 |
|
GL_TIMESYNC::GL_TIMESYNC(UInt_t id, TString type, TSQLServer *dbc, Bool_t usel0file){ |
1964 |
|
// MySQL variables |
1965 |
|
TFile *file = 0; |
1966 |
|
UInt_t idtsy = 0; |
1967 |
|
// |
1968 |
|
TSQLResult *pResult; |
1969 |
|
TSQLRow *Row = NULL; |
1970 |
|
stringstream myquery; |
1971 |
|
stringstream rname; |
1972 |
|
// pcksList packetsNames; |
1973 |
|
// pcksList::iterator Iter; |
1974 |
|
// getPacketsNames(packetsNames); |
1975 |
|
rname.str(""); |
1976 |
|
// ---------------- |
1977 |
myquery.str(""); |
myquery.str(""); |
1978 |
myquery << " SELECT OBT0,TIMESYNC,TYPE FROM GL_TIMESYNC " |
myquery << "select "; |
1979 |
<< " WHERE ID_RAW = " << idraw |
myquery << "PATH"; |
1980 |
<< ";"; |
myquery << ",NAME,ID_TIMESYNC"; |
1981 |
|
myquery << " from GL_ROOT where "; |
1982 |
|
myquery << type.Data(); |
1983 |
|
myquery << "=" << id << ";"; |
1984 |
|
// |
1985 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return; |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return; |
1986 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
1987 |
pResult = dbc->Query(myquery.str().c_str()); |
pResult = dbc->Query(myquery.str().c_str()); |
1988 |
|
if( pResult->GetRowCount() ){ |
1989 |
|
if (Row) |
1990 |
|
delete Row; |
1991 |
|
Row = pResult->Next(); |
1992 |
|
if( Row ){ |
1993 |
|
stringstream fname; |
1994 |
|
fname.str(""); |
1995 |
|
TString auxString(Row->GetField(0)); |
1996 |
|
gSystem->ExpandPathName(auxString); |
1997 |
|
fname << auxString << "/" << Row->GetField(1); |
1998 |
|
rname << Row->GetField(1); |
1999 |
|
if ( usel0file ) file = new TFile(fname.str().c_str(),"READ"); |
2000 |
|
idtsy = (UInt_t)atoll(Row->GetField(2)); |
2001 |
|
}; |
2002 |
|
}; |
2003 |
|
// |
2004 |
|
if ( usel0file && file && file->IsOpen() ){ |
2005 |
|
TTree *T=(TTree*)file->Get("Physics"); |
2006 |
|
pamela::EventHeader *eh = 0; |
2007 |
|
pamela::PscuHeader *ph = 0; |
2008 |
|
T->SetBranchAddress("Header", &eh); |
2009 |
|
// |
2010 |
|
T->GetEntry(0); |
2011 |
|
ph = eh->GetPscuHeader(); |
2012 |
|
pktfirst = ph->GetCounter(); |
2013 |
|
// obtfirst = ph->GetOrbitalTime(); |
2014 |
|
// |
2015 |
|
}; |
2016 |
|
if ( !usel0file ) pktfirst = 0; |
2017 |
|
// |
2018 |
|
// look for Resurs offset |
2019 |
|
// |
2020 |
|
T0 = 0; |
2021 |
|
// |
2022 |
|
stringstream oss; |
2023 |
|
// |
2024 |
|
TString name=rname.str().c_str(); |
2025 |
|
// UInt_t dworbit = 0; |
2026 |
|
// Int_t nlength = name.Length(); |
2027 |
|
delete pResult; |
2028 |
|
if (Row){ |
2029 |
|
delete Row; |
2030 |
|
Row = NULL; |
2031 |
|
} |
2032 |
|
// |
2033 |
|
// New code, we have one more column on GL_TIMESYNC so we can trust that one for the Resurs offset |
2034 |
|
// |
2035 |
|
oss.str(""); |
2036 |
|
oss << "SELECT OBT0,TIMESYNC,TYPE,ID_RESURS_OFFSET from GL_TIMESYNC where ID=" << idtsy <<";"; |
2037 |
|
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return; |
2038 |
|
this->GetGLTABLES()->AddQ(); |
2039 |
|
pResult = dbc->Query(oss.str().c_str()); |
2040 |
|
Bool_t fndit = false; |
2041 |
if ( pResult ){ |
if ( pResult ){ |
2042 |
|
if (Row) |
2043 |
|
delete Row; |
2044 |
Row = pResult->Next(); |
Row = pResult->Next(); |
2045 |
if ( (Row != NULL) && ((UInt_t)atoll(Row->GetField(0)) > 0 ) ){ |
if ( Row ){ |
2046 |
|
// |
2047 |
OBT0 = (UInt_t)atoll(Row->GetField(0)); |
OBT0 = (UInt_t)atoll(Row->GetField(0)); |
2048 |
|
obtfirst = OBT0; |
2049 |
TIMESYNC = (UInt_t)atoll(Row->GetField(1)); |
TIMESYNC = (UInt_t)atoll(Row->GetField(1)); |
2050 |
TYPE = (UInt_t)atoll(Row->GetField(2)); |
TYPE = (UInt_t)atoll(Row->GetField(2)); |
2051 |
toffset = (UInt_t)atoll(Row->GetField(1)) - (UInt_t)(this->DBobt((UInt_t)atoll(Row->GetField(0)))/1000) + T0; |
// |
2052 |
|
oss.str(""); |
2053 |
|
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=" |
2054 |
|
<< Row->GetField(3) << ";"; |
2055 |
|
if ( !this->GetGLTABLES()->IsConnected(dbc) ){ |
2056 |
|
delete pResult; |
2057 |
|
delete Row; |
2058 |
|
return; |
2059 |
|
} |
2060 |
|
this->GetGLTABLES()->AddQ(); |
2061 |
|
delete pResult; |
2062 |
|
pResult = dbc->Query(oss.str().c_str()); |
2063 |
|
if (pResult){ |
2064 |
|
if (Row) |
2065 |
|
delete Row; |
2066 |
|
Row = pResult->Next(); |
2067 |
|
if (Row){ |
2068 |
|
// printf(" GREAT! the DB structure is the new one! \n"); |
2069 |
|
fndit = true; |
2070 |
|
// dworbit = 1; |
2071 |
|
}; |
2072 |
|
}; |
2073 |
}; |
}; |
2074 |
}; |
}; |
2075 |
|
if ( !fndit ){ |
2076 |
|
// |
2077 |
|
printf(" ERROR OLD DB! \n"); |
2078 |
|
printf(" ERROR FROM GLTables! cannot determine Resurs offset \n"); |
2079 |
|
// |
2080 |
|
}; |
2081 |
// |
// |
2082 |
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); |
2083 |
|
T0 = (UInt_t)tu.GetSec(); |
2084 |
|
// |
2085 |
|
toffset = (UInt_t)TIMESYNC - (UInt_t)(this->DBobt(OBT0)/1000) + T0; |
2086 |
|
// |
2087 |
|
// printf(" T0 %u toffset is %u \n",T0,toffset); |
2088 |
|
// |
2089 |
|
if ( file ) file->Close(); |
2090 |
|
if (Row) |
2091 |
|
delete Row; |
2092 |
delete pResult; |
delete pResult; |
2093 |
}; |
}; |
2094 |
|
|
2099 |
*/ |
*/ |
2100 |
UInt_t GL_TIMESYNC::DBabsTime(UInt_t OBT){ |
UInt_t GL_TIMESYNC::DBabsTime(UInt_t OBT){ |
2101 |
// |
// |
2102 |
|
// printf(" OBT %u DBobt %llu toffset %u dbabstime %u\n",OBT,this->DBobt(OBT),toffset,((UInt_t)(this->DBobt(OBT)/1000)+toffset)); |
2103 |
return(((UInt_t)(this->DBobt(OBT)/1000)+toffset)); |
return(((UInt_t)(this->DBobt(OBT)/1000)+toffset)); |
2104 |
// |
// |
2105 |
}; |
}; |
2138 |
*/ |
*/ |
2139 |
Long64_t GL_TIMESYNC::DBobt(UInt_t obt){ |
Long64_t GL_TIMESYNC::DBobt(UInt_t obt){ |
2140 |
// |
// |
2141 |
if ( obt < (obtfirst/2) && obtfirst > (numeric_limits<UInt_t>::max()/2) ){ |
if ( obt < ((Long64_t)obtfirst/2) && obtfirst > (numeric_limits<UInt_t>::max()/2) ){ |
2142 |
return((Long64_t)obt+(Long64_t)numeric_limits<UInt_t>::max()); |
return((Long64_t)obt+(Long64_t)numeric_limits<UInt_t>::max()); |
2143 |
}; |
}; |
2144 |
// |
// |
2145 |
if ( obt > (obtfirst*2) && obt > (numeric_limits<UInt_t>::max()/2) ){ |
if ( obt > ((Long64_t)obtfirst*2) && obt > (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 |
// |
// |
2359 |
// |
// |
2360 |
Int_t GL_TLE::DoQuery(TString myquery, TSQLServer *dbc){ |
Int_t GL_TLE::DoQuery(TString myquery, TSQLServer *dbc){ |
2361 |
TSQLResult *result; |
TSQLResult *result; |
2362 |
TSQLRow *row; |
TSQLRow *row = NULL; |
2363 |
|
|
2364 |
// Set the right time_zone (otherwise horrible things will occur! :) |
// Set the right time_zone (otherwise horrible things will occur! :) |
2365 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
2366 |
dbc->Query("SET time_zone = '+0:00'"); |
delete dbc->Query("SET time_zone = '+0:00'"); |
2367 |
|
|
2368 |
// Do the query |
// Do the query |
2369 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
2370 |
result = dbc->Query(myquery.Data()); |
result = dbc->Query(myquery.Data()); |
2371 |
if(! result->GetRowCount() ) { |
if(! result->GetRowCount() ) { |
2372 |
cerr << "GL_TLE: query failed: " << myquery.Data() << endl; |
cerr << "GL_TLE: query failed: " << myquery.Data() << endl; |
2373 |
|
delete result; |
2374 |
return 1; |
return 1; |
2375 |
} |
} |
2376 |
|
|
2379 |
tle = GiveTle(row); |
tle = GiveTle(row); |
2380 |
|
|
2381 |
tleFromTime = strtol(row->GetField(4), NULL, 10); |
tleFromTime = strtol(row->GetField(4), NULL, 10); |
2382 |
|
if (row) |
2383 |
|
delete row; |
2384 |
row = result->Next(); // second tle row |
row = result->Next(); // second tle row |
2385 |
if(row) |
if(row) |
2386 |
tleToTime = strtol(row->GetField(4), NULL, 10); |
tleToTime = strtol(row->GetField(4), NULL, 10); |
2389 |
tleToTime = UINT_MAX; |
tleToTime = UINT_MAX; |
2390 |
} |
} |
2391 |
|
|
2392 |
delete row; |
if (row) |
2393 |
|
delete row; |
2394 |
delete result; |
delete result; |
2395 |
|
|
2396 |
return 0; |
return 0; |