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 |
// |
// |
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(""); |
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; |
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)); |
770 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
771 |
pResult = dbc->Query(myquery.str().c_str()); |
pResult = dbc->Query(myquery.str().c_str()); |
772 |
// |
// |
773 |
|
if (Row) |
774 |
|
delete Row; |
775 |
Row = pResult->Next(); |
Row = pResult->Next(); |
776 |
if( Row != NULL ){ |
if( Row != NULL ){ |
777 |
fileL0 = (TString)Row->GetField(0); |
fileL0 = (TString)Row->GetField(0); |
789 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
790 |
pResult = dbc->Query(myquery.str().c_str()); |
pResult = dbc->Query(myquery.str().c_str()); |
791 |
// |
// |
792 |
|
if (Row) |
793 |
|
delete Row; |
794 |
Row = pResult->Next(); |
Row = pResult->Next(); |
795 |
if( Row != NULL ){ |
if( Row != NULL ){ |
796 |
fileL2 = (TString)Row->GetField(0); |
fileL2 = (TString)Row->GetField(0); |
797 |
}; |
} |
798 |
|
if (Row){ |
799 |
|
delete Row; |
800 |
|
Row = NULL; // This variable is not used below |
801 |
|
} |
802 |
// |
// |
803 |
// |
// |
804 |
// |
// |
863 |
//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; |
864 |
// MySQL variables |
// MySQL variables |
865 |
TSQLResult *pResult; |
TSQLResult *pResult; |
866 |
TSQLRow *Row; |
TSQLRow *Row = NULL; |
867 |
stringstream myquery; |
stringstream myquery; |
868 |
// |
// |
869 |
if ( !IDRUN ) IDRUN = ID; |
if ( !IDRUN ) IDRUN = ID; |
1164 |
Int_t GL_RUN::Query_GL_RUN(UInt_t run, TSQLServer *dbc){ |
Int_t GL_RUN::Query_GL_RUN(UInt_t run, TSQLServer *dbc){ |
1165 |
// MySQL variables |
// MySQL variables |
1166 |
TSQLResult *pResult; |
TSQLResult *pResult; |
1167 |
TSQLRow *Row; |
TSQLRow *Row = NULL; |
|
int t; |
|
1168 |
int r; |
int r; |
1169 |
stringstream myquery; |
stringstream myquery; |
1170 |
// ---------------- |
// ---------------- |
1213 |
// |
// |
1214 |
if( !pResult->GetRowCount() ) return(-50); |
if( !pResult->GetRowCount() ) return(-50); |
1215 |
// |
// |
1216 |
for( r=0; r < 1000; r++){ |
for( r=0; r < 1000; r++){ |
1217 |
|
if (Row) |
1218 |
|
delete Row; |
1219 |
Row = pResult->Next(); |
Row = pResult->Next(); |
1220 |
if( Row == NULL ) break; |
if( Row == NULL ) break; |
1221 |
// Set_GL_RUN(Row); |
// Set_GL_RUN(Row); |
1222 |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
for( int t = 0; t < pResult->GetFieldCount(); t++){ |
1223 |
if (t== 0) ID = (UInt_t)atoll(Row->GetField(t)); |
if (t== 0) ID = (UInt_t)atoll(Row->GetField(t)); |
1224 |
if (t== 1) ID_RUN_FRAG = (UInt_t)atoll(Row->GetField(t)); |
if (t== 1) ID_RUN_FRAG = (UInt_t)atoll(Row->GetField(t)); |
1225 |
if (t== 2) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); |
if (t== 2) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); |
1253 |
if (t==30) PHYSENDRUN_MASK_S11CRC = (UInt_t)atoll(Row->GetField(t)); |
if (t==30) PHYSENDRUN_MASK_S11CRC = (UInt_t)atoll(Row->GetField(t)); |
1254 |
if (t==31) VALIDATION = (UInt_t)atoll(Row->GetField(t)); |
if (t==31) VALIDATION = (UInt_t)atoll(Row->GetField(t)); |
1255 |
}; |
}; |
1256 |
}; |
} |
1257 |
// delete pResult; |
|
1258 |
|
if (Row) |
1259 |
|
delete Row; |
1260 |
|
delete pResult; |
1261 |
return(0); |
return(0); |
1262 |
}; |
}; |
1263 |
|
|
1271 |
Int_t GL_RUN::Query_GL_RUN_FRAGMENTS(TString where, TSQLServer *dbc){ |
Int_t GL_RUN::Query_GL_RUN_FRAGMENTS(TString where, TSQLServer *dbc){ |
1272 |
// MySQL variables |
// MySQL variables |
1273 |
TSQLResult *pResult; |
TSQLResult *pResult; |
1274 |
TSQLRow *Row; |
TSQLRow *Row = NULL; |
1275 |
int t; |
int t; |
1276 |
int r; |
int r; |
1277 |
stringstream myquery; |
stringstream myquery; |
1319 |
pResult = dbc->Query(myquery.str().c_str()); |
pResult = dbc->Query(myquery.str().c_str()); |
1320 |
if(!pResult->GetRowCount())return(-50); |
if(!pResult->GetRowCount())return(-50); |
1321 |
for( r=0; r < 1000; r++){ |
for( r=0; r < 1000; r++){ |
1322 |
|
if (Row) |
1323 |
|
delete Row; |
1324 |
Row = pResult->Next(); |
Row = pResult->Next(); |
1325 |
if( Row == NULL ) break; |
if( Row == NULL ) break; |
1326 |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
1357 |
if (t==30) PHYSENDRUN_MASK_S11CRC = (UInt_t)atoll(Row->GetField(t)); |
if (t==30) PHYSENDRUN_MASK_S11CRC = (UInt_t)atoll(Row->GetField(t)); |
1358 |
if (t==31) VALIDATION = (UInt_t)atoll(Row->GetField(t)); |
if (t==31) VALIDATION = (UInt_t)atoll(Row->GetField(t)); |
1359 |
}; |
}; |
1360 |
}; |
} |
1361 |
// delete pResult; |
|
1362 |
|
if (Row) |
1363 |
|
delete Row; |
1364 |
|
delete pResult; |
1365 |
return(0); |
return(0); |
1366 |
};// **************************************************** |
};// **************************************************** |
1367 |
|
|
1374 |
Int_t GL_ROOT::Query_GL_ROOT(UInt_t id, TSQLServer *dbc){ |
Int_t GL_ROOT::Query_GL_ROOT(UInt_t id, TSQLServer *dbc){ |
1375 |
// MySQL variables |
// MySQL variables |
1376 |
TSQLResult *pResult; |
TSQLResult *pResult; |
1377 |
TSQLRow *Row; |
TSQLRow *Row = NULL; |
1378 |
int t; |
int t; |
1379 |
int r; |
int r; |
1380 |
stringstream myquery; |
stringstream myquery; |
1393 |
pResult = dbc->Query(myquery.str().c_str()); |
pResult = dbc->Query(myquery.str().c_str()); |
1394 |
if(!pResult->GetRowCount())return (-51); |
if(!pResult->GetRowCount())return (-51); |
1395 |
for( r=0; r < 1000; r++){ |
for( r=0; r < 1000; r++){ |
1396 |
|
if (Row) |
1397 |
|
delete Row; |
1398 |
Row = pResult->Next(); |
Row = pResult->Next(); |
1399 |
if( Row == NULL ) break; |
if( Row == NULL ) break; |
1400 |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
1403 |
if(t==2) ID_TIMESYNC = (UInt_t)atoll(Row->GetField(t)); |
if(t==2) ID_TIMESYNC = (UInt_t)atoll(Row->GetField(t)); |
1404 |
if(t==3) PATH = (TString)gSystem->ExpandPathName(Row->GetField(t))+'/'; |
if(t==3) PATH = (TString)gSystem->ExpandPathName(Row->GetField(t))+'/'; |
1405 |
if(t==4) NAME = Row->GetField(t); |
if(t==4) NAME = Row->GetField(t); |
1406 |
}; |
} |
1407 |
}; |
} |
1408 |
|
if (Row) |
1409 |
|
delete Row; |
1410 |
delete pResult; |
delete pResult; |
1411 |
return 0; |
return 0; |
1412 |
}; |
}; |
1421 |
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){ |
1422 |
// MySQL variables |
// MySQL variables |
1423 |
TSQLResult *pResult; |
TSQLResult *pResult; |
1424 |
TSQLRow *Row; |
TSQLRow *Row = NULL; |
1425 |
int t; |
int t; |
1426 |
int r; |
int r; |
1427 |
stringstream myquery; |
stringstream myquery; |
1437 |
pResult = dbc->Query(myquery.str().c_str()); |
pResult = dbc->Query(myquery.str().c_str()); |
1438 |
if(!pResult->GetRowCount())return (-53); |
if(!pResult->GetRowCount())return (-53); |
1439 |
for( r=0; r < 1000; r++){ |
for( r=0; r < 1000; r++){ |
1440 |
|
if (Row) |
1441 |
|
delete Row; |
1442 |
Row = pResult->Next(); |
Row = pResult->Next(); |
1443 |
if( Row == NULL ) break; |
if( Row == NULL ) break; |
1444 |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
1459 |
if (t==10) BOOT_NUMBER = (UInt_t)atoll(Row->GetField(t)); |
if (t==10) BOOT_NUMBER = (UInt_t)atoll(Row->GetField(t)); |
1460 |
if (t==11) VALIDATION = (UInt_t)atoll(Row->GetField(t)); |
if (t==11) VALIDATION = (UInt_t)atoll(Row->GetField(t)); |
1461 |
}; |
}; |
1462 |
}; |
} |
1463 |
|
if (Row) |
1464 |
|
delete Row; |
1465 |
delete pResult; |
delete pResult; |
1466 |
// |
// |
1467 |
// if ( TO_TIME < time ) return(51); |
// if ( TO_TIME < time ) return(51); |
1481 |
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){ |
1482 |
// MySQL variables |
// MySQL variables |
1483 |
TSQLResult *pResult; |
TSQLResult *pResult; |
1484 |
TSQLRow *Row; |
TSQLRow *Row = NULL; |
1485 |
int t; |
int t; |
1486 |
stringstream myquery; |
stringstream myquery; |
1487 |
uptime = 0; |
uptime = 0; |
1501 |
// printf(" mysquery is %s\n",myquery.str().c_str()); |
// printf(" mysquery is %s\n",myquery.str().c_str()); |
1502 |
// |
// |
1503 |
if( !pResult->GetRowCount() ) return(-54); |
if( !pResult->GetRowCount() ) return(-54); |
1504 |
|
if (Row) |
1505 |
|
delete Row; |
1506 |
Row = pResult->Next(); |
Row = pResult->Next(); |
1507 |
if( Row == NULL ) return (-54); |
if( Row == NULL ) return (-54); |
1508 |
// |
// |
1530 |
// |
// |
1531 |
if( !pResult->GetRowCount() ) return (-54); |
if( !pResult->GetRowCount() ) return (-54); |
1532 |
// |
// |
1533 |
|
if (Row) |
1534 |
|
delete Row; |
1535 |
Row = pResult->Next(); |
Row = pResult->Next(); |
1536 |
// |
// |
1537 |
myfromtime = (UInt_t)atoll(Row->GetField(1)); |
myfromtime = (UInt_t)atoll(Row->GetField(1)); |
1554 |
// |
// |
1555 |
if( !pResult->GetRowCount() ) return (-54); |
if( !pResult->GetRowCount() ) return (-54); |
1556 |
// |
// |
1557 |
|
if (Row) |
1558 |
|
delete Row; |
1559 |
Row = pResult->Next(); |
Row = pResult->Next(); |
1560 |
// |
// |
1561 |
}; |
}; |
1568 |
if (t==1) FROM_TIME = myfromtime; |
if (t==1) FROM_TIME = myfromtime; |
1569 |
if (t==2) TO_TIME = mytotime; |
if (t==2) TO_TIME = mytotime; |
1570 |
if (t==3) EV_ROOT = (UInt_t)atoll(Row->GetField(t)); |
if (t==3) EV_ROOT = (UInt_t)atoll(Row->GetField(t)); |
1571 |
}; |
} |
1572 |
|
if (Row) |
1573 |
|
delete Row; |
1574 |
pResult->Delete(); |
pResult->Delete(); |
1575 |
return 0; |
return 0; |
1576 |
}; |
}; |
1586 |
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){ |
1587 |
// MySQL variables |
// MySQL variables |
1588 |
TSQLResult *pResult; |
TSQLResult *pResult; |
1589 |
TSQLRow *Row; |
TSQLRow *Row = NULL; |
1590 |
int t; |
int t; |
1591 |
stringstream myquery; |
stringstream myquery; |
1592 |
// |
// |
1604 |
// |
// |
1605 |
if( !pResult ) return(-54); |
if( !pResult ) return(-54); |
1606 |
// |
// |
1607 |
|
if (Row) |
1608 |
|
delete Row; |
1609 |
Row = pResult->Next(); |
Row = pResult->Next(); |
1610 |
// |
// |
1611 |
if( !Row ) return (-54); |
if( !Row ) return (-54); |
1618 |
if (t==1) FROM_TIME = (UInt_t)atoll(Row->GetField(t)); |
if (t==1) FROM_TIME = (UInt_t)atoll(Row->GetField(t)); |
1619 |
if (t==2) TO_TIME = (UInt_t)atoll(Row->GetField(t)); |
if (t==2) TO_TIME = (UInt_t)atoll(Row->GetField(t)); |
1620 |
if (t==3) EV_ROOT = (UInt_t)atoll(Row->GetField(t)); |
if (t==3) EV_ROOT = (UInt_t)atoll(Row->GetField(t)); |
1621 |
}; |
} |
1622 |
|
if (Row) |
1623 |
|
delete Row; |
1624 |
pResult->Delete(); |
pResult->Delete(); |
1625 |
return 0; |
return 0; |
1626 |
}; |
}; |
1636 |
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){ |
1637 |
// MySQL variables |
// MySQL variables |
1638 |
TSQLResult *pResult; |
TSQLResult *pResult; |
1639 |
TSQLRow *Row; |
TSQLRow *Row = NULL; |
1640 |
int t; |
int t; |
1641 |
int r; |
int r; |
1642 |
stringstream myquery; |
stringstream myquery; |
1650 |
pResult = dbc->Query(myquery.str().c_str()); |
pResult = dbc->Query(myquery.str().c_str()); |
1651 |
if(!pResult->GetRowCount())return (-55);//throw -55; |
if(!pResult->GetRowCount())return (-55);//throw -55; |
1652 |
for( r=0; r < 1000; r++){ |
for( r=0; r < 1000; r++){ |
1653 |
|
if (Row) |
1654 |
|
delete Row; |
1655 |
Row = pResult->Next(); |
Row = pResult->Next(); |
1656 |
if( Row == NULL ) break; |
if( Row == NULL ) break; |
1657 |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
1661 |
if (t==3) FROM_TIME = (UInt_t)atoll(Row->GetField(t)); |
if (t==3) FROM_TIME = (UInt_t)atoll(Row->GetField(t)); |
1662 |
if (t==4) TO_TIME = (UInt_t)atoll(Row->GetField(t)); |
if (t==4) TO_TIME = (UInt_t)atoll(Row->GetField(t)); |
1663 |
}; |
}; |
1664 |
}; |
} |
1665 |
|
if (Row) |
1666 |
|
delete Row; |
1667 |
delete pResult; |
delete pResult; |
1668 |
// |
// |
1669 |
if(TO_TIME < time)return(51); |
if(TO_TIME < time)return(51); |
1682 |
// Bool_t debug = 1; |
// Bool_t debug = 1; |
1683 |
// MySQL variables |
// MySQL variables |
1684 |
TSQLResult *pResult; |
TSQLResult *pResult; |
1685 |
TSQLRow *Row; |
TSQLRow *Row = NULL; |
1686 |
int t; |
int t; |
1687 |
int r; |
int r; |
1688 |
stringstream myquery; |
stringstream myquery; |
1700 |
pResult = dbc->Query(myquery.str().c_str()); |
pResult = dbc->Query(myquery.str().c_str()); |
1701 |
if(!pResult->GetRowCount())return (-52); |
if(!pResult->GetRowCount())return (-52); |
1702 |
for( r=0; r < 1000; r++){ |
for( r=0; r < 1000; r++){ |
1703 |
|
if (Row) |
1704 |
|
delete Row; |
1705 |
Row = pResult->Next(); |
Row = pResult->Next(); |
1706 |
if( Row == NULL ) break; |
if( Row == NULL ) break; |
1707 |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
1713 |
if (t==5) TO_TIME = (UInt_t)atoll(Row->GetField(t)); |
if (t==5) TO_TIME = (UInt_t)atoll(Row->GetField(t)); |
1714 |
if (t==6) TYPE = (UInt_t)atoll(Row->GetField(t)); |
if (t==6) TYPE = (UInt_t)atoll(Row->GetField(t)); |
1715 |
}; |
}; |
1716 |
}; |
} |
1717 |
|
if (Row) |
1718 |
|
delete Row; |
1719 |
delete pResult; |
delete pResult; |
1720 |
// |
// |
1721 |
if(TO_TIME==0) TO_TIME = numeric_limits<UInt_t>::max(); |
if(TO_TIME==0) TO_TIME = numeric_limits<UInt_t>::max(); |
1751 |
UInt_t idtsy = 0; |
UInt_t idtsy = 0; |
1752 |
// |
// |
1753 |
TSQLResult *pResult; |
TSQLResult *pResult; |
1754 |
TSQLRow *Row = 0; |
TSQLRow *Row = NULL; |
1755 |
stringstream myquery; |
stringstream myquery; |
1756 |
stringstream rname; |
stringstream rname; |
1757 |
// pcksList packetsNames; |
// pcksList packetsNames; |
1771 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
1772 |
pResult = dbc->Query(myquery.str().c_str()); |
pResult = dbc->Query(myquery.str().c_str()); |
1773 |
if( pResult->GetRowCount() ){ |
if( pResult->GetRowCount() ){ |
1774 |
|
if (Row) |
1775 |
|
delete Row; |
1776 |
Row = pResult->Next(); |
Row = pResult->Next(); |
1777 |
if( Row ){ |
if( Row ){ |
1778 |
stringstream fname; |
stringstream fname; |
1817 |
pResult = dbc->Query(oss.str().c_str()); |
pResult = dbc->Query(oss.str().c_str()); |
1818 |
Bool_t fndit = false; |
Bool_t fndit = false; |
1819 |
if ( pResult ){ |
if ( pResult ){ |
1820 |
|
if (Row) |
1821 |
|
delete Row; |
1822 |
Row = pResult->Next(); |
Row = pResult->Next(); |
1823 |
if ( Row ){ |
if ( Row ){ |
1824 |
// |
// |
1834 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
1835 |
delete pResult; |
delete pResult; |
1836 |
pResult = dbc->Query(oss.str().c_str()); |
pResult = dbc->Query(oss.str().c_str()); |
1837 |
if ( pResult ){ |
if (pResult){ |
1838 |
Row = pResult->Next(); |
if (Row) |
1839 |
if ( Row ){ |
delete Row; |
1840 |
// printf(" GREAT! the DB structure is the new one! \n"); |
Row = pResult->Next(); |
1841 |
fndit = true; |
if ( Row ){ |
1842 |
dworbit = 1; |
// printf(" GREAT! the DB structure is the new one! \n"); |
1843 |
}; |
fndit = true; |
1844 |
|
dworbit = 1; |
1845 |
|
}; |
1846 |
}; |
}; |
1847 |
}; |
}; |
1848 |
}; |
}; |
1861 |
// printf(" T0 %u toffset is %u \n",T0,toffset); |
// printf(" T0 %u toffset is %u \n",T0,toffset); |
1862 |
// |
// |
1863 |
if ( file ) file->Close(); |
if ( file ) file->Close(); |
1864 |
|
if (Row) |
1865 |
|
delete Row; |
1866 |
delete pResult; |
delete pResult; |
1867 |
}; |
}; |
1868 |
|
|
1872 |
UInt_t idtsy = 0; |
UInt_t idtsy = 0; |
1873 |
// |
// |
1874 |
TSQLResult *pResult; |
TSQLResult *pResult; |
1875 |
TSQLRow *Row = 0; |
TSQLRow *Row = NULL; |
1876 |
stringstream myquery; |
stringstream myquery; |
1877 |
stringstream rname; |
stringstream rname; |
1878 |
// pcksList packetsNames; |
// pcksList packetsNames; |
1892 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
1893 |
pResult = dbc->Query(myquery.str().c_str()); |
pResult = dbc->Query(myquery.str().c_str()); |
1894 |
if( pResult->GetRowCount() ){ |
if( pResult->GetRowCount() ){ |
1895 |
|
if (Row) |
1896 |
|
delete Row; |
1897 |
Row = pResult->Next(); |
Row = pResult->Next(); |
1898 |
if( Row ){ |
if( Row ){ |
1899 |
stringstream fname; |
stringstream fname; |
1939 |
pResult = dbc->Query(oss.str().c_str()); |
pResult = dbc->Query(oss.str().c_str()); |
1940 |
Bool_t fndit = false; |
Bool_t fndit = false; |
1941 |
if ( pResult ){ |
if ( pResult ){ |
1942 |
|
if (Row) |
1943 |
|
delete Row; |
1944 |
Row = pResult->Next(); |
Row = pResult->Next(); |
1945 |
if ( Row ){ |
if ( Row ){ |
1946 |
// |
// |
1956 |
this->GetGLTABLES()->AddQ(); |
this->GetGLTABLES()->AddQ(); |
1957 |
delete pResult; |
delete pResult; |
1958 |
pResult = dbc->Query(oss.str().c_str()); |
pResult = dbc->Query(oss.str().c_str()); |
1959 |
if ( pResult ){ |
if (pResult){ |
1960 |
Row = pResult->Next(); |
if (Row) |
1961 |
if ( Row ){ |
delete Row; |
1962 |
// printf(" GREAT! the DB structure is the new one! \n"); |
Row = pResult->Next(); |
1963 |
fndit = true; |
if (Row){ |
1964 |
dworbit = 1; |
// printf(" GREAT! the DB structure is the new one! \n"); |
1965 |
}; |
fndit = true; |
1966 |
|
dworbit = 1; |
1967 |
|
}; |
1968 |
}; |
}; |
1969 |
}; |
}; |
1970 |
}; |
}; |
1983 |
// printf(" T0 %u toffset is %u \n",T0,toffset); |
// printf(" T0 %u toffset is %u \n",T0,toffset); |
1984 |
// |
// |
1985 |
if ( file ) file->Close(); |
if ( file ) file->Close(); |
1986 |
|
if (Row) |
1987 |
|
delete Row; |
1988 |
delete pResult; |
delete pResult; |
1989 |
}; |
}; |
1990 |
|
|
2255 |
// |
// |
2256 |
Int_t GL_TLE::DoQuery(TString myquery, TSQLServer *dbc){ |
Int_t GL_TLE::DoQuery(TString myquery, TSQLServer *dbc){ |
2257 |
TSQLResult *result; |
TSQLResult *result; |
2258 |
TSQLRow *row; |
TSQLRow *row = NULL; |
2259 |
|
|
2260 |
// Set the right time_zone (otherwise horrible things will occur! :) |
// Set the right time_zone (otherwise horrible things will occur! :) |
2261 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
2274 |
tle = GiveTle(row); |
tle = GiveTle(row); |
2275 |
|
|
2276 |
tleFromTime = strtol(row->GetField(4), NULL, 10); |
tleFromTime = strtol(row->GetField(4), NULL, 10); |
2277 |
|
if (row) |
2278 |
|
delete row; |
2279 |
row = result->Next(); // second tle row |
row = result->Next(); // second tle row |
2280 |
if(row) |
if(row) |
2281 |
tleToTime = strtol(row->GetField(4), NULL, 10); |
tleToTime = strtol(row->GetField(4), NULL, 10); |
2284 |
tleToTime = UINT_MAX; |
tleToTime = UINT_MAX; |
2285 |
} |
} |
2286 |
|
|
2287 |
delete row; |
if (row) |
2288 |
|
delete row; |
2289 |
delete result; |
delete result; |
2290 |
|
|
2291 |
return 0; |
return 0; |