1 |
/** |
2 |
* \file GLTables.cpp |
3 |
* \author Elena Vannuccini |
4 |
* |
5 |
* The file contains implementation of the methods to query the DB. |
6 |
*/ |
7 |
// |
8 |
#include <sstream> |
9 |
#include <iostream> |
10 |
#include <limits.h> |
11 |
// |
12 |
#include <TFile.h> |
13 |
#include <TTree.h> |
14 |
#include <TTimeStamp.h> |
15 |
#include <EventHeader.h> |
16 |
#include <PscuHeader.h> |
17 |
// |
18 |
#include <GLTables.h> |
19 |
#include <sgp4.h> |
20 |
// |
21 |
ClassImp(Q2TH); |
22 |
ClassImp(GL_TABLES); |
23 |
ClassImp(GL_TRK_CALIB); |
24 |
ClassImp(GL_RUN); |
25 |
ClassImp(GL_ROOT); |
26 |
ClassImp(GL_PARAM); |
27 |
ClassImp(GL_S4_CALIB); |
28 |
ClassImp(GL_CALO_CALIB); |
29 |
ClassImp(GL_CALOPULSE_CALIB); |
30 |
ClassImp(GL_TIMESYNC); |
31 |
ClassImp(GL_TLE); |
32 |
// |
33 |
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 |
pResult = dbc->Query(query.Data()); |
72 |
// |
73 |
Row = pResult->Next(); |
74 |
// |
75 |
Int_t dim = pResult->GetFieldCount(); |
76 |
if ( dim < 1 || dim > 2 ){ |
77 |
printf(" Dim == %i not supported yet \n",dim); |
78 |
return NULL; |
79 |
}; |
80 |
// |
81 |
TH1D *h1 = NULL; |
82 |
TH2D *h2 = NULL; |
83 |
Double_t f1 = 0.; |
84 |
Double_t minf1 = numeric_limits<Double_t>::max(); |
85 |
Double_t maxf1 = numeric_limits<Double_t>::min(); |
86 |
Double_t f2 = 0.; |
87 |
Double_t minf2 = numeric_limits<Double_t>::max(); |
88 |
Double_t maxf2 = numeric_limits<Double_t>::min(); |
89 |
// |
90 |
while ( Row ){ |
91 |
f1 = (Double_t)atof(Row->GetField(0)); |
92 |
if ( f1 > maxf1 ) maxf1 = f1; |
93 |
if ( f1 < minf1 ) minf1 = f1; |
94 |
if ( dim == 2 ){ |
95 |
f2 = (Double_t)atof(Row->GetField(1)); |
96 |
if ( f2 > maxf2 ) maxf2 = f2; |
97 |
if ( f2 < minf2 ) minf2 = f2; |
98 |
|
99 |
}; |
100 |
Row = pResult->Next(); |
101 |
}; |
102 |
pResult->Delete(); |
103 |
// |
104 |
|
105 |
// |
106 |
Int_t f1bin = 70; |
107 |
Int_t f2bin = 70; |
108 |
if ( dim == 1 ){ |
109 |
f1bin = int((maxf1-minf1)/1000.); |
110 |
if ( f1bin < 70 ) f1bin = 70; |
111 |
if ( f1bin > 1000 ) f1bin = 1000; |
112 |
if ( !strcmp(hname.Data(),"q2th") ) hname += "1"; |
113 |
// h1 = dynamic_cast<TH1D*>(gDirectory->FindObject(hname.Data())); |
114 |
h1 = (TH1D*)(gDirectory->FindObject(hname.Data())); |
115 |
if ( !strcmp(hname.Data(),"q2th1") ){ |
116 |
if ( h1 ) h1->Delete(); |
117 |
}; |
118 |
if ( !h1 ) h1 = new TH1D(hname.Data(),hname.Data(),f1bin,minf1*0.98,maxf1*1.02); |
119 |
// h1->SetBit(TH1::kCanRebin); |
120 |
if ( verbose ) printf("\n\n Row %s \n",pResult->GetFieldName(0)); |
121 |
}; |
122 |
if ( dim == 2 ){ |
123 |
f2bin = int((maxf2-minf2)/1000.); |
124 |
if ( f2bin < 70 ) f2bin = 70; |
125 |
if ( f2bin > 1000 ) f2bin = 1000; |
126 |
if ( !strcmp(hname.Data(),"q2th") ) hname += "2"; |
127 |
// h2 = dynamic_cast<TH2D*>(gDirectory->FindObject(hname.Data())); |
128 |
h2 = (TH2D*)(gDirectory->FindObject(hname.Data())); |
129 |
if ( !strcmp(hname.Data(),"q2th2") ){ |
130 |
if ( h2 ) h2->Delete(); |
131 |
}; |
132 |
if ( !h2 ) h2 = new TH2D(hname.Data(),hname.Data(),f1bin,minf1*0.98,maxf1*1.02,f2bin,minf2*0.98,maxf2*1.02); |
133 |
// h2->SetBit(TH2::kCanRebin); |
134 |
if ( verbose ) printf("\n\n Row %s %s \n",pResult->GetFieldName(0),pResult->GetFieldName(1)); |
135 |
}; |
136 |
// |
137 |
pResult = dbc->Query(query.Data()); |
138 |
// |
139 |
Row = pResult->Next(); |
140 |
// |
141 |
Int_t r = 0; |
142 |
// |
143 |
while ( Row ){ |
144 |
f1 = (Double_t)atof(Row->GetField(0)); |
145 |
if ( dim == 1 ){ |
146 |
if ( verbose ) printf(" %i %f \n",r,f1); |
147 |
h1->Fill(f1); |
148 |
} else { |
149 |
f2 = (Double_t)atof(Row->GetField(1)); |
150 |
if ( verbose ) printf(" %i %f %f \n",r,f1,f2); |
151 |
h2->Fill(f1,f2); |
152 |
}; |
153 |
r++; |
154 |
Row = pResult->Next(); |
155 |
}; |
156 |
// |
157 |
TCanvas *c = NULL; |
158 |
TString cname = Form("%sc",hname.Data()); |
159 |
// c = dynamic_cast<TCanvas*>(gDirectory->FindObject(hname.Data())); |
160 |
c = (TCanvas*)(gDirectory->FindObject(cname.Data())); |
161 |
if ( !c ) c = new TCanvas(Form("%sc",cname.Data())); |
162 |
c->Clear(); |
163 |
c->cd(); |
164 |
if ( dim == 1 ) h1->Draw(); |
165 |
if ( dim == 2 ) h2->Draw(); |
166 |
// |
167 |
pResult->Delete(); |
168 |
if ( dim == 1 ) return h1; |
169 |
if ( dim == 2 ) return h2; |
170 |
// |
171 |
return NULL; |
172 |
}; |
173 |
|
174 |
GL_TABLES::GL_TABLES(){ |
175 |
}; |
176 |
|
177 |
GL_TABLES::GL_TABLES(TString host, TString user, TString psw){ |
178 |
fHost = new TString(host.Data()); |
179 |
fUser = new TString(user.Data()); |
180 |
fPsw = new TString(psw.Data()); |
181 |
fSet = true; |
182 |
fNquery = 0; |
183 |
mh = host.Data(); |
184 |
mu = user.Data(); |
185 |
mp = psw.Data(); |
186 |
}; |
187 |
|
188 |
|
189 |
void GL_TABLES::Set(TString host, TString user, TString psw){ |
190 |
fHost = new TString(host.Data()); |
191 |
fUser = new TString(user.Data()); |
192 |
fPsw = new TString(psw.Data()); |
193 |
fSet = true; |
194 |
fNquery = 0; |
195 |
mh = host.Data(); |
196 |
mu = user.Data(); |
197 |
mp = psw.Data(); |
198 |
}; |
199 |
|
200 |
//Bool_t GL_TABLES::IsConnected(TSQLServer *&dbc){ |
201 |
Bool_t GL_TABLES::IsConnected(TSQLServer *dbc){ |
202 |
// |
203 |
// |
204 |
// |
205 |
if ( !fSet ){ |
206 |
return true; |
207 |
}; |
208 |
// |
209 |
// printf(" host is %s \n",fHost->Data()); |
210 |
// |
211 |
stringstream myquery; |
212 |
myquery.str(""); |
213 |
myquery << "show databases;"; |
214 |
if ( dbc ){ |
215 |
if ( dbc->IsConnected() ){ |
216 |
dbc->Query(myquery.str().c_str()); |
217 |
fNquery++; |
218 |
if ( !(dbc->GetErrorCode()) ){ |
219 |
// printf("ok\n"); |
220 |
// |
221 |
// if ( (dbc->GetErrorCode() != 2013 && dbc->GetErrorCode() != 2006) ){ |
222 |
// if ( !(dbc->GetErrorCode()) ){ |
223 |
// is connected |
224 |
return true; |
225 |
// }; |
226 |
}; |
227 |
}; |
228 |
}; |
229 |
// |
230 |
if ( true ) { |
231 |
// |
232 |
printf(" WARNING: Lost connection to DB! try to recover... \n"); |
233 |
// |
234 |
TString host = fHost->Data(); |
235 |
TString user = fUser->Data(); |
236 |
TString psw = fPsw->Data(); |
237 |
if ( dbc ){ |
238 |
dbc->Close(); |
239 |
delete dbc; |
240 |
}; |
241 |
dbc = TSQLServer::Connect(host.Data(),user.Data(),psw.Data()); |
242 |
// |
243 |
myquery.str(""); |
244 |
myquery << "show databases;"; |
245 |
dbc->Query(myquery.str().c_str()); |
246 |
fNquery++; |
247 |
// if ( dbc->GetErrorCode() != 2013 && dbc->GetErrorCode() != 2006 ){ |
248 |
if ( !(dbc->GetErrorCode()) ){ |
249 |
// |
250 |
printf(" ...connection recovered, I can continue! \n"); |
251 |
// |
252 |
myquery.str(""); |
253 |
myquery << "SET time_zone='+0:00'"; |
254 |
dbc->Query(myquery.str().c_str()); |
255 |
fNquery++; |
256 |
myquery.str(""); |
257 |
myquery << "SET wait_timeout=173000;"; |
258 |
dbc->Query(myquery.str().c_str()); |
259 |
fNquery++; |
260 |
return true; |
261 |
}; |
262 |
}; |
263 |
// |
264 |
printf(" GLTABLES: connection is gone away, query will fail\n"); |
265 |
// |
266 |
return false; |
267 |
// |
268 |
}; |
269 |
|
270 |
void GL_TABLES::ResetCounters(){ |
271 |
fNquery = 0; |
272 |
}; |
273 |
|
274 |
void GL_TABLES::AddQ(){ |
275 |
if ( fSet ) fNquery++; |
276 |
}; |
277 |
|
278 |
UInt_t GL_TABLES::GetNqueries(){ |
279 |
UInt_t rn = 0; |
280 |
rn += (UInt_t&)fNquery; |
281 |
return(rn); |
282 |
}; |
283 |
|
284 |
GL_RUN::GL_RUN() { |
285 |
ID = 0; |
286 |
ID_RUN_FRAG = 0; |
287 |
ID_ROOT_L0 = 0; |
288 |
ID_ROOT_L2 = 0; |
289 |
RUNHEADER_TIME = 0; |
290 |
RUNTRAILER_TIME = 0; |
291 |
EV_FROM = 0; |
292 |
EV_TO = 0; |
293 |
TRK_CALIB_USED = 0; |
294 |
EFF_WRK_SCHEDULE = 0; |
295 |
PRH_VAR_TRG_MODE_A = 0; |
296 |
PRH_VAR_TRG_MODE_B = 0; |
297 |
ACQ_BUILD_INFO = 0; |
298 |
ACQ_VAR_INFO = 0; |
299 |
RUNHEADER_OBT = 0; |
300 |
RUNTRAILER_OBT = 0; |
301 |
RUNHEADER_PKT = 0; |
302 |
RUNTRAILER_PKT = 0; |
303 |
NEVENTS = 0; |
304 |
LAST_TIMESYNC = 0; |
305 |
OBT_TIMESYNC = 0; |
306 |
COMPILATIONTIMESTAMP = 0; |
307 |
FAV_WRK_SCHEDULE = 0; |
308 |
RM_ACQ_AFTER_CALIB = 0; |
309 |
RM_ACQ_SETTING_MODE = 0; |
310 |
PKT_COUNTER = 0; |
311 |
PKT_READY_COUNTER = 0; |
312 |
TRK_CALIB_USED = 0; |
313 |
CAL_DSP_MASK = 0; |
314 |
BOOT_NUMBER = 0; |
315 |
PHYSENDRUN_MASK_S3S2S12 = 0; |
316 |
PHYSENDRUN_MASK_S11CRC = 0; |
317 |
VALIDATION = 0; |
318 |
} |
319 |
|
320 |
|
321 |
void GL_RUN::Clear(Option_t *t) { |
322 |
ID = 0; |
323 |
ID_RUN_FRAG = 0; |
324 |
ID_ROOT_L0 = 0; |
325 |
ID_ROOT_L2 = 0; |
326 |
RUNHEADER_TIME = 0; |
327 |
RUNTRAILER_TIME = 0; |
328 |
EV_FROM = 0; |
329 |
EV_TO = 0; |
330 |
TRK_CALIB_USED = 0; |
331 |
EFF_WRK_SCHEDULE = 0; |
332 |
PRH_VAR_TRG_MODE_A = 0; |
333 |
PRH_VAR_TRG_MODE_B = 0; |
334 |
ACQ_BUILD_INFO = 0; |
335 |
ACQ_VAR_INFO = 0; |
336 |
RUNHEADER_OBT = 0; |
337 |
RUNTRAILER_OBT = 0; |
338 |
RUNHEADER_PKT = 0; |
339 |
RUNTRAILER_PKT = 0; |
340 |
NEVENTS = 0; |
341 |
LAST_TIMESYNC = 0; |
342 |
OBT_TIMESYNC = 0; |
343 |
COMPILATIONTIMESTAMP = 0; |
344 |
FAV_WRK_SCHEDULE = 0; |
345 |
RM_ACQ_AFTER_CALIB = 0; |
346 |
RM_ACQ_SETTING_MODE = 0; |
347 |
PKT_COUNTER = 0; |
348 |
PKT_READY_COUNTER = 0; |
349 |
TRK_CALIB_USED = 0; |
350 |
CAL_DSP_MASK = 0; |
351 |
BOOT_NUMBER = 0; |
352 |
PHYSENDRUN_MASK_S3S2S12 = 0; |
353 |
PHYSENDRUN_MASK_S11CRC = 0; |
354 |
VALIDATION = 0; |
355 |
} |
356 |
|
357 |
GL_ROOT::GL_ROOT(){ |
358 |
ID = 0; |
359 |
ID_RAW = 0; |
360 |
ID_TIMESYNC = 0; |
361 |
PATH = ""; |
362 |
NAME = ""; |
363 |
} |
364 |
|
365 |
GL_RAW::GL_RAW(){ |
366 |
ID = 0; |
367 |
PATH = ""; |
368 |
NAME = ""; |
369 |
BOOT_NUMBER = 0; |
370 |
} |
371 |
|
372 |
GL_PARAM::GL_PARAM(){ |
373 |
ID = 0; |
374 |
PATH = ""; |
375 |
NAME = ""; |
376 |
DESCR = ""; |
377 |
FROM_TIME = 0; |
378 |
TO_TIME = 0; |
379 |
TYPE = 0; |
380 |
} |
381 |
|
382 |
|
383 |
GL_TRK_CALIB::GL_TRK_CALIB(){ |
384 |
ID = 0; |
385 |
ID_ROOT_L0 = 0; |
386 |
EV_ROOT_CALIBTRK1 = 0; |
387 |
EV_ROOT_CALIBTRK2 = 0; |
388 |
FROM_TIME = 0; |
389 |
TO_TIME = 0; |
390 |
OBT1 = 0; |
391 |
OBT2 = 0; |
392 |
PKT1 = 0; |
393 |
PKT2 = 0; |
394 |
BOOT_NUMBER = 0; |
395 |
VALIDATION = 0; |
396 |
} |
397 |
|
398 |
GL_CALO_CALIB::GL_CALO_CALIB(){ |
399 |
ID = 0; |
400 |
ID_ROOT_L0 = 0; |
401 |
EV_ROOT = 0; |
402 |
FROM_TIME = 0; |
403 |
TO_TIME = 0; |
404 |
SECTION = 0; |
405 |
OBT = 0; |
406 |
PKT = 0; |
407 |
BOOT_NUMBER = 0; |
408 |
VALIDATION = 0; |
409 |
} |
410 |
|
411 |
GL_CALOPULSE_CALIB::GL_CALOPULSE_CALIB(){ |
412 |
ID = 0; |
413 |
ID_ROOT_L0 = 0; |
414 |
EV_ROOT = 0; |
415 |
FROM_TIME = 0; |
416 |
TO_TIME = 0; |
417 |
SECTION = 0; |
418 |
PULSED_STRIP = 0; |
419 |
PULSE_AMPLITUDE = 0; |
420 |
OBT = 0; |
421 |
PKT = 0; |
422 |
BOOT_NUMBER = 0; |
423 |
VALIDATION = 0; |
424 |
} |
425 |
|
426 |
GL_S4_CALIB::GL_S4_CALIB(){ |
427 |
ID = 0; |
428 |
ID_ROOT_L0 = 0; |
429 |
EV_ROOT = 0; |
430 |
FROM_TIME = 0; |
431 |
TO_TIME = 0; |
432 |
OBT = 0; |
433 |
PKT = 0; |
434 |
BOOT_NUMBER = 0; |
435 |
} |
436 |
|
437 |
GL_TIMESYNC::GL_TIMESYNC(){ |
438 |
obtfirst = 0; |
439 |
pktfirst = 0; |
440 |
ID_RESURS_OFFSET = 0; |
441 |
ID = 0; |
442 |
ID_RAW = 0; |
443 |
OBT0 = 0; |
444 |
TIMESYNC = 0; |
445 |
TYPE = 0; |
446 |
} |
447 |
|
448 |
// **************************************************** |
449 |
|
450 |
void GL_RUN::SetEV_FROM(UInt_t evfrom){ |
451 |
EV_FROM = evfrom; |
452 |
}; |
453 |
|
454 |
void GL_RUN::SetEV_TO(UInt_t evto){ |
455 |
EV_TO = evto; |
456 |
}; |
457 |
|
458 |
void GL_RUN::SetNEVENTS(UInt_t nev){ |
459 |
NEVENTS = nev; |
460 |
}; |
461 |
|
462 |
void GL_RUN::SetBOOTNUMBER(UInt_t boot){ |
463 |
BOOT_NUMBER = boot; |
464 |
}; |
465 |
|
466 |
void GL_RUN::SetRUNHEADER_TIME(UInt_t absth){ |
467 |
RUNHEADER_TIME = absth; |
468 |
}; |
469 |
|
470 |
void GL_RUN::SetRUNTRAILER_TIME(UInt_t abstt){ |
471 |
RUNTRAILER_TIME = abstt; |
472 |
}; |
473 |
|
474 |
void GL_RUN::SetRUNHEADER_PKT(UInt_t absth){ |
475 |
RUNHEADER_PKT = absth; |
476 |
}; |
477 |
|
478 |
void GL_RUN::SetRUNTRAILER_PKT(UInt_t abstt){ |
479 |
RUNTRAILER_PKT = abstt; |
480 |
}; |
481 |
|
482 |
void GL_RUN::SetRUNHEADER_OBT(UInt_t absth){ |
483 |
RUNHEADER_OBT = absth; |
484 |
}; |
485 |
|
486 |
void GL_RUN::SetRUNTRAILER_OBT(UInt_t abstt){ |
487 |
RUNTRAILER_OBT = abstt; |
488 |
}; |
489 |
|
490 |
void GL_RUN::SetID_ROOT_L2(UInt_t idl2){ |
491 |
ID_ROOT_L2 = idl2; |
492 |
}; |
493 |
|
494 |
void GL_RUN::SetID_ROOT_L0(UInt_t idroot){ |
495 |
ID_ROOT_L0 = idroot; |
496 |
}; |
497 |
|
498 |
void GL_RUN::SetID_RUN_FRAG(UInt_t idfrag){ |
499 |
ID_RUN_FRAG = idfrag; |
500 |
}; |
501 |
|
502 |
void GL_RUN::SetVALIDATION(UInt_t valid){ |
503 |
VALIDATION = valid; |
504 |
}; |
505 |
|
506 |
void GL_RUN::SetLAST_TIMESYNC(UInt_t ts){ |
507 |
LAST_TIMESYNC = ts; |
508 |
}; |
509 |
|
510 |
void GL_RUN::SetOBT_TIMESYNC(UInt_t ts){ |
511 |
OBT_TIMESYNC = ts; |
512 |
}; |
513 |
|
514 |
void GL_RUN:: SetPKT_COUNTER(UInt_t value){ |
515 |
PKT_COUNTER = value; |
516 |
}; |
517 |
|
518 |
void GL_RUN:: SetPKT_READY_COUNTER(UInt_t value){ |
519 |
PKT_READY_COUNTER = value; |
520 |
}; |
521 |
|
522 |
void GL_RUN:: SetCOMPILATIONTIMESTAMP(UInt_t value){ |
523 |
COMPILATIONTIMESTAMP = value; |
524 |
}; |
525 |
|
526 |
void GL_RUN:: SetPHYSENDRUN_MASK_S3S2S12(UInt_t value){ |
527 |
PHYSENDRUN_MASK_S3S2S12 = value; |
528 |
}; |
529 |
|
530 |
void GL_RUN:: SetPHYSENDRUN_MASK_S11CRC(UInt_t value){ |
531 |
PHYSENDRUN_MASK_S11CRC = value; |
532 |
}; |
533 |
|
534 |
|
535 |
void GL_RUN:: SetFAV_WRK_SCHEDULE(UInt_t value){ |
536 |
FAV_WRK_SCHEDULE = value; |
537 |
}; |
538 |
|
539 |
void GL_RUN:: SetEFF_WRK_SCHEDULE(UInt_t value){ |
540 |
EFF_WRK_SCHEDULE = value; |
541 |
}; |
542 |
|
543 |
void GL_RUN:: SetPRH_VAR_TRG_MODE_A(UInt_t value){ |
544 |
PRH_VAR_TRG_MODE_A = value; |
545 |
}; |
546 |
|
547 |
void GL_RUN:: SetPRH_VAR_TRG_MODE_B(UInt_t value){ |
548 |
PRH_VAR_TRG_MODE_B = value; |
549 |
}; |
550 |
|
551 |
void GL_RUN:: SetACQ_BUILD_INFO(UInt_t value){ |
552 |
ACQ_BUILD_INFO = value; |
553 |
}; |
554 |
|
555 |
void GL_RUN:: SetACQ_VAR_INFO(UInt_t value){ |
556 |
ACQ_VAR_INFO = value; |
557 |
}; |
558 |
|
559 |
void GL_RUN:: SetRM_ACQ_AFTER_CALIB(UInt_t value){ |
560 |
RM_ACQ_AFTER_CALIB = value; |
561 |
}; |
562 |
|
563 |
void GL_RUN:: SetRM_ACQ_SETTING_MODE(UInt_t value){ |
564 |
RM_ACQ_SETTING_MODE = value; |
565 |
}; |
566 |
|
567 |
void GL_RUN:: SetTRK_CALIB_USED(UInt_t value){ |
568 |
TRK_CALIB_USED = value; |
569 |
}; |
570 |
|
571 |
void GL_RUN:: SetCAL_DSP_MASK(UInt_t value){ |
572 |
CAL_DSP_MASK = value; |
573 |
}; |
574 |
|
575 |
void GL_RUN:: SetID(UInt_t value){ |
576 |
ID = value; |
577 |
}; |
578 |
|
579 |
void GL_RUN::Set_GL_RUNT(RunTrailerEvent *runt, PscuHeader *pht){ |
580 |
PKT_COUNTER = runt->PKT_COUNTER; |
581 |
PKT_READY_COUNTER = runt->PKT_ReadyCounter; |
582 |
RUNTRAILER_OBT = pht->GetOrbitalTime(); |
583 |
RUNTRAILER_PKT = pht->GetCounter(); |
584 |
}; |
585 |
|
586 |
void GL_RUN::Set_GL_RUNH(RunHeaderEvent *runh, PscuHeader *phh){ |
587 |
TRK_CALIB_USED = runh->TRK_CALIB_USED; |
588 |
PRH_VAR_TRG_MODE_A = runh->PRH_VAR_TRIGGER_MODE_A; |
589 |
PRH_VAR_TRG_MODE_B = runh->PRH_VAR_TRIGGER_MODE_B; |
590 |
ACQ_BUILD_INFO = runh->ACQ_BUILD_INFO; |
591 |
ACQ_VAR_INFO = runh->ACQ_VAR_INFO; |
592 |
RUNHEADER_OBT = phh->GetOrbitalTime(); |
593 |
RUNHEADER_PKT = phh->GetCounter(); |
594 |
LAST_TIMESYNC = runh->LAST_TIME_SYNC_INFO; |
595 |
OBT_TIMESYNC = runh->OBT_TIME_SYNC; |
596 |
COMPILATIONTIMESTAMP = runh->COMPILATIONTIMESTAMP; |
597 |
FAV_WRK_SCHEDULE = runh->FAVOURITE_WORKING_SCHEDULE; |
598 |
EFF_WRK_SCHEDULE = runh->EFFECTIVE_WORKING_SCHEDULE; |
599 |
RM_ACQ_AFTER_CALIB = runh->RM_ACQ_AFTER_CALIB; |
600 |
RM_ACQ_SETTING_MODE = runh->RM_ACQ_SETTING_MODE; |
601 |
TRK_CALIB_USED = runh->TRK_CALIB_USED; |
602 |
CAL_DSP_MASK = runh->CAL_DSP_MASK; |
603 |
}; |
604 |
|
605 |
void GL_RUN::Set_GL_RUNT0(){ |
606 |
PKT_COUNTER = 0; |
607 |
PKT_READY_COUNTER = 0; |
608 |
RUNTRAILER_OBT = 0; |
609 |
RUNTRAILER_PKT = 0; |
610 |
}; |
611 |
|
612 |
void GL_RUN::Set_GL_RUNH0(){ |
613 |
TRK_CALIB_USED = 0; |
614 |
PRH_VAR_TRG_MODE_A = 0; |
615 |
PRH_VAR_TRG_MODE_B = 0; |
616 |
ACQ_BUILD_INFO = 0; |
617 |
ACQ_VAR_INFO = 0; |
618 |
RUNHEADER_OBT = 0; |
619 |
RUNHEADER_PKT = 0; |
620 |
LAST_TIMESYNC = 0; |
621 |
OBT_TIMESYNC = 0; |
622 |
COMPILATIONTIMESTAMP = 0; |
623 |
FAV_WRK_SCHEDULE = 0; |
624 |
EFF_WRK_SCHEDULE = 0; |
625 |
RM_ACQ_AFTER_CALIB = 0; |
626 |
RM_ACQ_SETTING_MODE = 0; |
627 |
TRK_CALIB_USED = 0; |
628 |
CAL_DSP_MASK = 0; |
629 |
}; |
630 |
|
631 |
void GL_RUN::Set_GL_RUN(TSQLRow *Row){ |
632 |
for( Int_t t = 0; t < 32; t++){ |
633 |
if (t== 0) ID = (UInt_t)atoll(Row->GetField(t)); |
634 |
if (t== 1) ID_RUN_FRAG = (UInt_t)atoll(Row->GetField(t)); |
635 |
if (t== 2) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); |
636 |
if (t== 3) ID_ROOT_L2 = (UInt_t)atoll(Row->GetField(t)); |
637 |
if (t== 4) RUNHEADER_TIME = (UInt_t)atoll(Row->GetField(t)); |
638 |
if (t== 5) RUNTRAILER_TIME = (UInt_t)atoll(Row->GetField(t)); |
639 |
if (t== 6) RUNHEADER_OBT = (UInt_t)atoll(Row->GetField(t)); |
640 |
if (t== 7) RUNTRAILER_OBT = (UInt_t)atoll(Row->GetField(t)); |
641 |
if (t== 8) RUNHEADER_PKT = (UInt_t)atoll(Row->GetField(t)); |
642 |
if (t== 9) RUNTRAILER_PKT = (UInt_t)atoll(Row->GetField(t)); |
643 |
if (t==10) BOOT_NUMBER = (UInt_t)atoll(Row->GetField(t)); |
644 |
if (t==11) EV_FROM = (UInt_t)atoll(Row->GetField(t)); |
645 |
if (t==12) EV_TO = (UInt_t)atoll(Row->GetField(t)); |
646 |
if (t==13) NEVENTS = (UInt_t)atoll(Row->GetField(t)); |
647 |
if (t==14) PKT_COUNTER = (UInt_t)atoll(Row->GetField(t)); |
648 |
if (t==15) PKT_READY_COUNTER = (UInt_t)atoll(Row->GetField(t)); |
649 |
if (t==16) COMPILATIONTIMESTAMP = (UInt_t)atoll(Row->GetField(t)); |
650 |
if (t==17) FAV_WRK_SCHEDULE = (UInt_t)atoll(Row->GetField(t)); |
651 |
if (t==18) EFF_WRK_SCHEDULE = (UInt_t)atoll(Row->GetField(t)); |
652 |
if (t==19) PRH_VAR_TRG_MODE_A= (UInt_t)atoll(Row->GetField(t)); |
653 |
if (t==20) PRH_VAR_TRG_MODE_B= (UInt_t)atoll(Row->GetField(t)); |
654 |
if (t==21) ACQ_BUILD_INFO = (UInt_t)atoll(Row->GetField(t)); |
655 |
if (t==22) ACQ_VAR_INFO = (UInt_t)atoll(Row->GetField(t)); |
656 |
if (t==23) RM_ACQ_AFTER_CALIB= (UInt_t)atoll(Row->GetField(t)); |
657 |
if (t==24) RM_ACQ_SETTING_MODE = (UInt_t)atoll(Row->GetField(t)); |
658 |
if (t==25) TRK_CALIB_USED = (UInt_t)atoll(Row->GetField(t)); |
659 |
if (t==26) CAL_DSP_MASK = (UInt_t)atoll(Row->GetField(t)); |
660 |
if (t==27) LAST_TIMESYNC = (UInt_t)atoll(Row->GetField(t)); |
661 |
if (t==28) OBT_TIMESYNC = (UInt_t)atoll(Row->GetField(t)); |
662 |
if (t==29) PHYSENDRUN_MASK_S3S2S12 = (UInt_t)atoll(Row->GetField(t)); |
663 |
if (t==30) PHYSENDRUN_MASK_S11CRC = (UInt_t)atoll(Row->GetField(t)); |
664 |
if (t==31) VALIDATION = (UInt_t)atoll(Row->GetField(t)); |
665 |
}; |
666 |
|
667 |
} |
668 |
|
669 |
/** |
670 |
* This method delete the run from the "FromTable" table and store it in the GL_RUN_TRASH table |
671 |
* If IDRUN is 0 "this->ID" run is used. |
672 |
* |
673 |
**/ |
674 |
Int_t GL_RUN::DeleteRun(TSQLServer *dbc,UInt_t IDRUN,TString FromTable){ |
675 |
// MySQL variables |
676 |
TSQLResult *pResult; |
677 |
TSQLRow *Row = NULL; |
678 |
stringstream myquery; |
679 |
// |
680 |
if ( !IDRUN ) IDRUN = ID; |
681 |
if ( !IDRUN ) return 1; |
682 |
// ---------------- |
683 |
myquery.str(""); |
684 |
myquery << " INSERT INTO GL_RUN_TRASH ("; |
685 |
myquery << "ID"; |
686 |
myquery << ",ID_RUN_FRAG"; |
687 |
myquery << ",ID_ROOT_L0"; |
688 |
myquery << ",ID_ROOT_L2"; |
689 |
myquery << ",RUNHEADER_TIME"; |
690 |
myquery << ",RUNTRAILER_TIME"; |
691 |
myquery << ",RUNHEADER_OBT"; |
692 |
myquery << ",RUNTRAILER_OBT"; |
693 |
myquery << ",RUNHEADER_PKT"; |
694 |
myquery << ",RUNTRAILER_PKT"; |
695 |
myquery << ",BOOT_NUMBER"; |
696 |
myquery << ",EV_FROM"; |
697 |
myquery << ",EV_TO"; |
698 |
myquery << ",NEVENTS"; |
699 |
myquery << ",PKT_COUNTER"; |
700 |
myquery << ",PKT_READY_COUNTER"; |
701 |
myquery << ",COMPILATIONTIMESTAMP"; |
702 |
myquery << ",FAV_WRK_SCHEDULE"; |
703 |
myquery << ",EFF_WRK_SCHEDULE"; |
704 |
myquery << ",PRH_VAR_TRG_MODE_A"; |
705 |
myquery << ",PRH_VAR_TRG_MODE_B"; |
706 |
myquery << ",ACQ_BUILD_INFO"; |
707 |
myquery << ",ACQ_VAR_INFO"; |
708 |
myquery << ",RM_ACQ_AFTER_CALIB"; |
709 |
myquery << ",RM_ACQ_SETTING_MODE"; |
710 |
myquery << ",TRK_CALIB_USED"; |
711 |
myquery << ",CAL_DSP_MASK"; |
712 |
myquery << ",LAST_TIMESYNC"; |
713 |
myquery << ",OBT_TIMESYNC"; |
714 |
myquery << ",PHYSENDRUN_MASK_S3S2S12"; |
715 |
myquery << ",PHYSENDRUN_MASK_S11CRC"; |
716 |
myquery << ",VALIDATION"; |
717 |
myquery << ",INSERT_TIME"; |
718 |
myquery << ") SELECT * FROM "; |
719 |
myquery << FromTable.Data(); |
720 |
myquery << " WHERE ID="; |
721 |
myquery << (UInt_t)IDRUN << ";"; |
722 |
// |
723 |
// printf("1myquery is %s \n",myquery.str().c_str()); |
724 |
// |
725 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
726 |
this->GetGLTABLES()->AddQ(); |
727 |
dbc->Query(myquery.str().c_str()); |
728 |
// |
729 |
// retrieve this ID_TRASH |
730 |
// |
731 |
myquery.str(""); |
732 |
myquery << " SELECT ID_TRASH,ID_ROOT_L0,ID_ROOT_L2 FROM GL_RUN_TRASH ORDER BY ID_TRASH DESC LIMIT 1"; |
733 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
734 |
this->GetGLTABLES()->AddQ(); |
735 |
pResult = dbc->Query(myquery.str().c_str()); |
736 |
// |
737 |
UInt_t idtrash = 0; |
738 |
UInt_t idl0 = 0; |
739 |
UInt_t idl2 = 0; |
740 |
// |
741 |
if (Row) |
742 |
delete Row; |
743 |
Row = pResult->Next(); |
744 |
if( Row != NULL ){ |
745 |
idtrash = (UInt_t)atoll(Row->GetField(0)); |
746 |
idl0 = (UInt_t)atoll(Row->GetField(1)); |
747 |
idl2 = (UInt_t)atoll(Row->GetField(2)); |
748 |
}; |
749 |
// |
750 |
TString fileL0 = ""; |
751 |
TString fileL2 = ""; |
752 |
myquery.str(""); |
753 |
myquery << " SELECT NAME FROM GL_ROOT WHERE ID="; |
754 |
myquery << idl0 << ";"; |
755 |
// |
756 |
// printf("2myquery is %s \n",myquery.str().c_str()); |
757 |
// |
758 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
759 |
this->GetGLTABLES()->AddQ(); |
760 |
pResult = dbc->Query(myquery.str().c_str()); |
761 |
// |
762 |
if (Row) |
763 |
delete Row; |
764 |
Row = pResult->Next(); |
765 |
if( Row != NULL ){ |
766 |
fileL0 = (TString)Row->GetField(0); |
767 |
}; |
768 |
// |
769 |
// |
770 |
// |
771 |
myquery.str(""); |
772 |
myquery << " SELECT NAME FROM GL_ROOT WHERE ID="; |
773 |
myquery << idl2 << ";"; |
774 |
// |
775 |
// printf("3myquery is %s \n",myquery.str().c_str()); |
776 |
// |
777 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
778 |
this->GetGLTABLES()->AddQ(); |
779 |
pResult = dbc->Query(myquery.str().c_str()); |
780 |
// |
781 |
if (Row) |
782 |
delete Row; |
783 |
Row = pResult->Next(); |
784 |
if( Row != NULL ){ |
785 |
fileL2 = (TString)Row->GetField(0); |
786 |
} |
787 |
if (Row){ |
788 |
delete Row; |
789 |
Row = NULL; // This variable is not used below |
790 |
} |
791 |
// |
792 |
// |
793 |
// |
794 |
myquery.str(""); |
795 |
myquery << " UPDATE GL_RUN_TRASH SET FILENAMEL0='"; |
796 |
myquery << fileL0.Data() << "' where ID_TRASH="; |
797 |
myquery << idtrash << ";"; |
798 |
// |
799 |
// printf("4myquery is %s \n",myquery.str().c_str()); |
800 |
// |
801 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
802 |
this->GetGLTABLES()->AddQ(); |
803 |
dbc->Query(myquery.str().c_str()); |
804 |
// |
805 |
myquery.str(""); |
806 |
myquery << " UPDATE GL_RUN_TRASH SET FILENAMEL2='"; |
807 |
myquery << fileL2.Data() << "' where ID_TRASH="; |
808 |
myquery << idtrash << ";"; |
809 |
// |
810 |
// printf("4myquery is %s \n",myquery.str().c_str()); |
811 |
// |
812 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
813 |
this->GetGLTABLES()->AddQ(); |
814 |
dbc->Query(myquery.str().c_str()); |
815 |
// |
816 |
myquery.str(""); |
817 |
myquery << " UPDATE GL_RUN_TRASH SET BELONGED_TO='"; |
818 |
myquery << FromTable.Data() << "' where ID_TRASH="; |
819 |
myquery << idtrash << ";"; |
820 |
// |
821 |
// printf("4myquery is %s \n",myquery.str().c_str()); |
822 |
// |
823 |
// |
824 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
825 |
this->GetGLTABLES()->AddQ(); |
826 |
dbc->Query(myquery.str().c_str()); |
827 |
// |
828 |
myquery.str(""); |
829 |
myquery << " DELETE FROM "; |
830 |
myquery << FromTable.Data() << " where ID="; |
831 |
myquery << IDRUN << ";"; |
832 |
// |
833 |
// printf("5myquery is %s \n",myquery.str().c_str()); |
834 |
// |
835 |
// |
836 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
837 |
this->GetGLTABLES()->AddQ(); |
838 |
dbc->Query(myquery.str().c_str()); |
839 |
// |
840 |
return 0; |
841 |
}; |
842 |
|
843 |
|
844 |
|
845 |
/** |
846 |
* This method restore a run from the GL_RUN_TRASH table. |
847 |
* If ID is 0 "this->ID" is used; if "ToTable" is empty BELONG_TO field of GL_RUN_TRASH is used. |
848 |
* |
849 |
**/ |
850 |
Int_t GL_RUN::RestoreRun(TSQLServer *dbc,UInt_t IDRUN,TString ToTable){ |
851 |
// insert into GL_RUN_FRAGMENTS select * FROM GL_RUN where ID=11; |
852 |
//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; |
853 |
// MySQL variables |
854 |
TSQLResult *pResult; |
855 |
TSQLRow *Row = NULL; |
856 |
stringstream myquery; |
857 |
// |
858 |
if ( !IDRUN ) IDRUN = ID; |
859 |
if ( !IDRUN ) return 1; |
860 |
// |
861 |
if ( !strcmp(ToTable.Data(),"") ){ |
862 |
// |
863 |
myquery.str(""); |
864 |
myquery << " SELECT BELONGED_TO FROM GL_RUN_TRASH WHERE ID="; |
865 |
myquery << (UInt_t)IDRUN << ";"; |
866 |
// |
867 |
printf(" qui? myquery is %s \n",myquery.str().c_str()); |
868 |
// |
869 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
870 |
this->GetGLTABLES()->AddQ(); |
871 |
pResult = dbc->Query(myquery.str().c_str()); |
872 |
// |
873 |
Row = pResult->Next(); |
874 |
if( Row != NULL ){ |
875 |
ToTable = (TString)Row->GetField(0); |
876 |
} else { |
877 |
return 1; |
878 |
}; |
879 |
}; |
880 |
// ---------------- |
881 |
myquery.str(""); |
882 |
myquery << " INSERT INTO "; |
883 |
myquery << ToTable.Data(); |
884 |
myquery << " ("; |
885 |
myquery << "ID"; |
886 |
myquery << ",ID_RUN_FRAG"; |
887 |
myquery << ",ID_ROOT_L0"; |
888 |
myquery << ",ID_ROOT_L2"; |
889 |
myquery << ",RUNHEADER_TIME"; |
890 |
myquery << ",RUNTRAILER_TIME"; |
891 |
myquery << ",RUNHEADER_OBT"; |
892 |
myquery << ",RUNTRAILER_OBT"; |
893 |
myquery << ",RUNHEADER_PKT"; |
894 |
myquery << ",RUNTRAILER_PKT"; |
895 |
myquery << ",BOOT_NUMBER"; |
896 |
myquery << ",EV_FROM"; |
897 |
myquery << ",EV_TO"; |
898 |
myquery << ",NEVENTS"; |
899 |
myquery << ",PKT_COUNTER"; |
900 |
myquery << ",PKT_READY_COUNTER"; |
901 |
myquery << ",COMPILATIONTIMESTAMP"; |
902 |
myquery << ",FAV_WRK_SCHEDULE"; |
903 |
myquery << ",EFF_WRK_SCHEDULE"; |
904 |
myquery << ",PRH_VAR_TRG_MODE_A"; |
905 |
myquery << ",PRH_VAR_TRG_MODE_B"; |
906 |
myquery << ",ACQ_BUILD_INFO"; |
907 |
myquery << ",ACQ_VAR_INFO"; |
908 |
myquery << ",RM_ACQ_AFTER_CALIB"; |
909 |
myquery << ",RM_ACQ_SETTING_MODE"; |
910 |
myquery << ",TRK_CALIB_USED"; |
911 |
myquery << ",CAL_DSP_MASK"; |
912 |
myquery << ",LAST_TIMESYNC"; |
913 |
myquery << ",OBT_TIMESYNC"; |
914 |
myquery << ",PHYSENDRUN_MASK_S3S2S12"; |
915 |
myquery << ",PHYSENDRUN_MASK_S11CRC"; |
916 |
myquery << ",VALIDATION"; |
917 |
myquery << ",INSERT_TIME"; |
918 |
myquery << ") SELECT "; |
919 |
myquery << "ID"; |
920 |
myquery << ",ID_RUN_FRAG"; |
921 |
myquery << ",ID_ROOT_L0"; |
922 |
myquery << ",ID_ROOT_L2"; |
923 |
myquery << ",RUNHEADER_TIME"; |
924 |
myquery << ",RUNTRAILER_TIME"; |
925 |
myquery << ",RUNHEADER_OBT"; |
926 |
myquery << ",RUNTRAILER_OBT"; |
927 |
myquery << ",RUNHEADER_PKT"; |
928 |
myquery << ",RUNTRAILER_PKT"; |
929 |
myquery << ",BOOT_NUMBER"; |
930 |
myquery << ",EV_FROM"; |
931 |
myquery << ",EV_TO"; |
932 |
myquery << ",NEVENTS"; |
933 |
myquery << ",PKT_COUNTER"; |
934 |
myquery << ",PKT_READY_COUNTER"; |
935 |
myquery << ",COMPILATIONTIMESTAMP"; |
936 |
myquery << ",FAV_WRK_SCHEDULE"; |
937 |
myquery << ",EFF_WRK_SCHEDULE"; |
938 |
myquery << ",PRH_VAR_TRG_MODE_A"; |
939 |
myquery << ",PRH_VAR_TRG_MODE_B"; |
940 |
myquery << ",ACQ_BUILD_INFO"; |
941 |
myquery << ",ACQ_VAR_INFO"; |
942 |
myquery << ",RM_ACQ_AFTER_CALIB"; |
943 |
myquery << ",RM_ACQ_SETTING_MODE"; |
944 |
myquery << ",TRK_CALIB_USED"; |
945 |
myquery << ",CAL_DSP_MASK"; |
946 |
myquery << ",LAST_TIMESYNC"; |
947 |
myquery << ",OBT_TIMESYNC"; |
948 |
myquery << ",PHYSENDRUN_MASK_S3S2S12"; |
949 |
myquery << ",PHYSENDRUN_MASK_S11CRC"; |
950 |
myquery << ",VALIDATION"; |
951 |
myquery << ",INSERT_TIME"; |
952 |
myquery << " FROM GL_RUN_TRASH "; |
953 |
myquery << " WHERE BELONGED_TO='GL_RUN_FRAGMENTS' AND ID="; |
954 |
myquery << (UInt_t)IDRUN << ";"; |
955 |
// |
956 |
// printf("5myquery is %s \n",myquery.str().c_str()); |
957 |
// |
958 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
959 |
this->GetGLTABLES()->AddQ(); |
960 |
dbc->Query(myquery.str().c_str()); |
961 |
// |
962 |
// |
963 |
myquery.str(""); |
964 |
myquery << " DELETE FROM GL_RUN_TRASH where BELONGED_TO='GL_RUN_FRAGMENTS' AND ID="; |
965 |
myquery << IDRUN << ";"; |
966 |
// |
967 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
968 |
this->GetGLTABLES()->AddQ(); |
969 |
dbc->Query(myquery.str().c_str()); |
970 |
// |
971 |
return 0; |
972 |
}; |
973 |
|
974 |
/** |
975 |
* Function to fill the GL_RUN table of the DB. |
976 |
* |
977 |
* \param |
978 |
* |
979 |
*/ |
980 |
Int_t GL_RUN::Fill_GL_RUN(TSQLServer *dbc){ |
981 |
// MySQL variables |
982 |
stringstream myquery; |
983 |
// ---------------- |
984 |
myquery.str(""); |
985 |
myquery << " INSERT INTO GL_RUN ("; |
986 |
myquery << "ID"; |
987 |
myquery << ",ID_RUN_FRAG"; |
988 |
myquery << ",ID_ROOT_L0"; |
989 |
myquery << ",ID_ROOT_L2"; |
990 |
myquery << ",RUNHEADER_TIME"; |
991 |
myquery << ",RUNTRAILER_TIME"; |
992 |
myquery << ",RUNHEADER_OBT"; |
993 |
myquery << ",RUNTRAILER_OBT"; |
994 |
myquery << ",RUNHEADER_PKT"; |
995 |
myquery << ",RUNTRAILER_PKT"; |
996 |
myquery << ",EV_FROM"; |
997 |
myquery << ",EV_TO"; |
998 |
myquery << ",NEVENTS"; |
999 |
myquery << ",LAST_TIMESYNC"; |
1000 |
myquery << ",OBT_TIMESYNC"; |
1001 |
myquery << ",COMPILATIONTIMESTAMP"; |
1002 |
myquery << ",FAV_WRK_SCHEDULE"; |
1003 |
myquery << ",EFF_WRK_SCHEDULE"; |
1004 |
myquery << ",PRH_VAR_TRG_MODE_A"; |
1005 |
myquery << ",PRH_VAR_TRG_MODE_B"; |
1006 |
myquery << ",ACQ_BUILD_INFO"; |
1007 |
myquery << ",ACQ_VAR_INFO"; |
1008 |
myquery << ",RM_ACQ_AFTER_CALIB"; |
1009 |
myquery << ",RM_ACQ_SETTING_MODE"; |
1010 |
myquery << ",PKT_COUNTER"; |
1011 |
myquery << ",PKT_READY_COUNTER"; |
1012 |
myquery << ",TRK_CALIB_USED"; |
1013 |
myquery << ",CAL_DSP_MASK"; |
1014 |
myquery << ",BOOT_NUMBER"; |
1015 |
myquery << ",PHYSENDRUN_MASK_S3S2S12"; |
1016 |
myquery << ",PHYSENDRUN_MASK_S11CRC"; |
1017 |
myquery << ",VALIDATION"; |
1018 |
myquery << ") VALUES ('"; |
1019 |
|
1020 |
myquery << (UInt_t)ID << "','"; |
1021 |
myquery << (UInt_t)ID_RUN_FRAG << "','"; |
1022 |
myquery << (UInt_t)ID_ROOT_L0 << "','"; |
1023 |
myquery << (UInt_t)ID_ROOT_L2 << "','"; |
1024 |
myquery << (UInt_t)RUNHEADER_TIME << "','"; |
1025 |
myquery << (UInt_t)RUNTRAILER_TIME << "','"; |
1026 |
myquery << (UInt_t)RUNHEADER_OBT << "','"; |
1027 |
myquery << (UInt_t)RUNTRAILER_OBT << "','"; |
1028 |
myquery << (UInt_t)RUNHEADER_PKT << "','"; |
1029 |
myquery << (UInt_t)RUNTRAILER_PKT << "','"; |
1030 |
myquery << (UInt_t)EV_FROM << "','"; |
1031 |
myquery << (UInt_t)EV_TO << "','"; |
1032 |
myquery << (UInt_t)NEVENTS << "','"; |
1033 |
myquery << (UInt_t)LAST_TIMESYNC << "','"; |
1034 |
myquery << (UInt_t)OBT_TIMESYNC << "','"; |
1035 |
myquery << (UInt_t)COMPILATIONTIMESTAMP << "','"; |
1036 |
myquery << (UInt_t)FAV_WRK_SCHEDULE << "','"; |
1037 |
myquery << (UInt_t)EFF_WRK_SCHEDULE << "','"; |
1038 |
myquery << (UInt_t)PRH_VAR_TRG_MODE_A << "','"; |
1039 |
myquery << (UInt_t)PRH_VAR_TRG_MODE_B << "','"; |
1040 |
myquery << (UInt_t)ACQ_BUILD_INFO << "','"; |
1041 |
myquery << (UInt_t)ACQ_VAR_INFO << "','"; |
1042 |
myquery << (UInt_t)RM_ACQ_AFTER_CALIB << "','"; |
1043 |
myquery << (UInt_t)RM_ACQ_SETTING_MODE << "','"; |
1044 |
myquery << (UInt_t)PKT_COUNTER << "','"; |
1045 |
myquery << (UInt_t)PKT_READY_COUNTER << "','"; |
1046 |
myquery << (UInt_t)TRK_CALIB_USED << "','"; |
1047 |
myquery << (UInt_t)CAL_DSP_MASK << "','"; |
1048 |
myquery << (UInt_t)BOOT_NUMBER << "','"; |
1049 |
myquery << (UInt_t)PHYSENDRUN_MASK_S3S2S12 << "','"; |
1050 |
myquery << (UInt_t)PHYSENDRUN_MASK_S11CRC << "','"; |
1051 |
myquery << (UInt_t)VALIDATION << "');"; |
1052 |
// |
1053 |
// printf("myquery is %s \n",myquery.str().c_str()); |
1054 |
// |
1055 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
1056 |
this->GetGLTABLES()->AddQ(); |
1057 |
dbc->Query(myquery.str().c_str()); |
1058 |
// |
1059 |
return 0; |
1060 |
|
1061 |
};// **************************************************** |
1062 |
|
1063 |
/** |
1064 |
* Function to fill the GL_RUN table of the DB. |
1065 |
* |
1066 |
* \param |
1067 |
* |
1068 |
*/ |
1069 |
Int_t GL_RUN::Fill_GL_RUN_FRAGMENTS(TSQLServer *dbc){ |
1070 |
// MySQL variables |
1071 |
stringstream myquery; |
1072 |
// ---------------- |
1073 |
myquery.str(""); |
1074 |
myquery << " INSERT INTO GL_RUN_FRAGMENTS ("; |
1075 |
myquery << "ID"; |
1076 |
myquery << ",ID_ROOT_L0"; |
1077 |
myquery << ",RUNHEADER_TIME"; |
1078 |
myquery << ",RUNTRAILER_TIME"; |
1079 |
myquery << ",RUNHEADER_OBT"; |
1080 |
myquery << ",RUNTRAILER_OBT"; |
1081 |
myquery << ",RUNHEADER_PKT"; |
1082 |
myquery << ",RUNTRAILER_PKT"; |
1083 |
myquery << ",EV_FROM"; |
1084 |
myquery << ",EV_TO"; |
1085 |
myquery << ",NEVENTS"; |
1086 |
myquery << ",LAST_TIMESYNC"; |
1087 |
myquery << ",OBT_TIMESYNC"; |
1088 |
myquery << ",COMPILATIONTIMESTAMP"; |
1089 |
myquery << ",FAV_WRK_SCHEDULE"; |
1090 |
myquery << ",EFF_WRK_SCHEDULE"; |
1091 |
myquery << ",PRH_VAR_TRG_MODE_A"; |
1092 |
myquery << ",PRH_VAR_TRG_MODE_B"; |
1093 |
myquery << ",ACQ_BUILD_INFO"; |
1094 |
myquery << ",ACQ_VAR_INFO"; |
1095 |
myquery << ",RM_ACQ_AFTER_CALIB"; |
1096 |
myquery << ",RM_ACQ_SETTING_MODE"; |
1097 |
myquery << ",PKT_COUNTER"; |
1098 |
myquery << ",PKT_READY_COUNTER"; |
1099 |
myquery << ",TRK_CALIB_USED"; |
1100 |
myquery << ",CAL_DSP_MASK"; |
1101 |
myquery << ",BOOT_NUMBER"; |
1102 |
myquery << ",PHYSENDRUN_MASK_S3S2S12"; |
1103 |
myquery << ",PHYSENDRUN_MASK_S11CRC"; |
1104 |
myquery << ") VALUES ('"; |
1105 |
myquery << (UInt_t)ID << "','"; |
1106 |
myquery << (UInt_t)ID_ROOT_L0 << "','"; |
1107 |
myquery << (UInt_t)RUNHEADER_TIME << "','"; |
1108 |
myquery << (UInt_t)RUNTRAILER_TIME << "','"; |
1109 |
myquery << (UInt_t)RUNHEADER_OBT << "','"; |
1110 |
myquery << (UInt_t)RUNTRAILER_OBT << "','"; |
1111 |
myquery << (UInt_t)RUNHEADER_PKT << "','"; |
1112 |
myquery << (UInt_t)RUNTRAILER_PKT << "','"; |
1113 |
myquery << (UInt_t)EV_FROM << "','"; |
1114 |
myquery << (UInt_t)EV_TO << "','"; |
1115 |
myquery << (UInt_t)NEVENTS << "','"; |
1116 |
myquery << (UInt_t)LAST_TIMESYNC << "','"; |
1117 |
myquery << (UInt_t)OBT_TIMESYNC << "','"; |
1118 |
myquery << (UInt_t)COMPILATIONTIMESTAMP << "','"; |
1119 |
myquery << (UInt_t)FAV_WRK_SCHEDULE << "','"; |
1120 |
myquery << (UInt_t)EFF_WRK_SCHEDULE << "','"; |
1121 |
myquery << (UInt_t)PRH_VAR_TRG_MODE_A << "','"; |
1122 |
myquery << (UInt_t)PRH_VAR_TRG_MODE_B << "','"; |
1123 |
myquery << (UInt_t)ACQ_BUILD_INFO << "','"; |
1124 |
myquery << (UInt_t)ACQ_VAR_INFO << "','"; |
1125 |
myquery << (UInt_t)RM_ACQ_AFTER_CALIB << "','"; |
1126 |
myquery << (UInt_t)RM_ACQ_SETTING_MODE << "','"; |
1127 |
myquery << (UInt_t)PKT_COUNTER << "','"; |
1128 |
myquery << (UInt_t)PKT_READY_COUNTER << "','"; |
1129 |
myquery << (UInt_t)TRK_CALIB_USED << "','"; |
1130 |
myquery << (UInt_t)CAL_DSP_MASK << "','"; |
1131 |
myquery << (UInt_t)BOOT_NUMBER << "','"; |
1132 |
myquery << (UInt_t)PHYSENDRUN_MASK_S3S2S12 << "','"; |
1133 |
myquery << (UInt_t)PHYSENDRUN_MASK_S11CRC << "');"; |
1134 |
// |
1135 |
// printf("myquery is %s \n",myquery.str().c_str()); |
1136 |
// |
1137 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
1138 |
this->GetGLTABLES()->AddQ(); |
1139 |
dbc->Query(myquery.str().c_str()); |
1140 |
// |
1141 |
return 0; |
1142 |
|
1143 |
};// **************************************************** |
1144 |
|
1145 |
|
1146 |
/** |
1147 |
* Function to query the GL_RUN table of the DB. |
1148 |
* |
1149 |
* \param RUN id |
1150 |
* \return struct of type GL_RUN _data, which stores the query result |
1151 |
* |
1152 |
*/ |
1153 |
Int_t GL_RUN::Query_GL_RUN(UInt_t run, TSQLServer *dbc){ |
1154 |
// MySQL variables |
1155 |
TSQLResult *pResult; |
1156 |
TSQLRow *Row = NULL; |
1157 |
int r; |
1158 |
stringstream myquery; |
1159 |
// ---------------- |
1160 |
myquery.str(""); |
1161 |
myquery << " select "; |
1162 |
myquery << "ID"; |
1163 |
myquery << ",ID_RUN_FRAG"; |
1164 |
myquery << ",ID_ROOT_L0"; |
1165 |
myquery << ",ID_ROOT_L2"; |
1166 |
myquery << ",RUNHEADER_TIME"; |
1167 |
myquery << ",RUNTRAILER_TIME"; |
1168 |
myquery << ",RUNHEADER_OBT"; |
1169 |
myquery << ",RUNTRAILER_OBT"; |
1170 |
myquery << ",RUNHEADER_PKT"; |
1171 |
myquery << ",RUNTRAILER_PKT"; |
1172 |
myquery << ",EV_FROM"; |
1173 |
myquery << ",EV_TO"; |
1174 |
myquery << ",NEVENTS"; |
1175 |
myquery << ",LAST_TIMESYNC"; |
1176 |
myquery << ",OBT_TIMESYNC"; |
1177 |
myquery << ",COMPILATIONTIMESTAMP"; |
1178 |
myquery << ",FAV_WRK_SCHEDULE"; |
1179 |
myquery << ",EFF_WRK_SCHEDULE"; |
1180 |
myquery << ",PRH_VAR_TRG_MODE_A"; |
1181 |
myquery << ",PRH_VAR_TRG_MODE_B"; |
1182 |
myquery << ",ACQ_BUILD_INFO"; |
1183 |
myquery << ",ACQ_VAR_INFO"; |
1184 |
myquery << ",RM_ACQ_AFTER_CALIB"; |
1185 |
myquery << ",RM_ACQ_SETTING_MODE"; |
1186 |
myquery << ",PKT_COUNTER"; |
1187 |
myquery << ",PKT_READY_COUNTER"; |
1188 |
myquery << ",TRK_CALIB_USED"; |
1189 |
myquery << ",CAL_DSP_MASK"; |
1190 |
myquery << ",BOOT_NUMBER"; |
1191 |
myquery << ",PHYSENDRUN_MASK_S3S2S12"; |
1192 |
myquery << ",PHYSENDRUN_MASK_S11CRC"; |
1193 |
myquery << ",VALIDATION"; |
1194 |
myquery << " from GL_RUN where ID=" << run << ";"; |
1195 |
// |
1196 |
// printf(" myquery is %s \n",myquery.str().c_str()); |
1197 |
if ( !this->IsConnected(dbc) ) return -57; |
1198 |
this->AddQ(); |
1199 |
pResult = dbc->Query(myquery.str().c_str()); |
1200 |
// |
1201 |
// printf(" getrowcount %i \n",pResult->GetRowCount()); |
1202 |
// |
1203 |
if( !pResult->GetRowCount() ) return(-50); |
1204 |
// |
1205 |
for( r=0; r < 1000; r++){ |
1206 |
if (Row) |
1207 |
delete Row; |
1208 |
Row = pResult->Next(); |
1209 |
if( Row == NULL ) break; |
1210 |
// Set_GL_RUN(Row); |
1211 |
for( int t = 0; t < pResult->GetFieldCount(); t++){ |
1212 |
if (t== 0) ID = (UInt_t)atoll(Row->GetField(t)); |
1213 |
if (t== 1) ID_RUN_FRAG = (UInt_t)atoll(Row->GetField(t)); |
1214 |
if (t== 2) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); |
1215 |
if (t== 3) ID_ROOT_L2 = (UInt_t)atoll(Row->GetField(t)); |
1216 |
if (t== 4) RUNHEADER_TIME = (UInt_t)atoll(Row->GetField(t)); |
1217 |
if (t== 5) RUNTRAILER_TIME = (UInt_t)atoll(Row->GetField(t)); |
1218 |
if (t== 6) RUNHEADER_OBT = (UInt_t)atoll(Row->GetField(t)); |
1219 |
if (t== 7) RUNTRAILER_OBT = (UInt_t)atoll(Row->GetField(t)); |
1220 |
if (t== 8) RUNHEADER_PKT = (UInt_t)atoll(Row->GetField(t)); |
1221 |
if (t== 9) RUNTRAILER_PKT = (UInt_t)atoll(Row->GetField(t)); |
1222 |
if (t==10) EV_FROM = (UInt_t)atoll(Row->GetField(t)); |
1223 |
if (t==11) EV_TO = (UInt_t)atoll(Row->GetField(t)); |
1224 |
if (t==12) NEVENTS = (UInt_t)atoll(Row->GetField(t)); |
1225 |
if (t==13) LAST_TIMESYNC = (UInt_t)atoll(Row->GetField(t)); |
1226 |
if (t==14) OBT_TIMESYNC = (UInt_t)atoll(Row->GetField(t)); |
1227 |
if (t==15) COMPILATIONTIMESTAMP = (UInt_t)atoll(Row->GetField(t)); |
1228 |
if (t==16) FAV_WRK_SCHEDULE = (UInt_t)atoll(Row->GetField(t)); |
1229 |
if (t==17) EFF_WRK_SCHEDULE = (UInt_t)atoll(Row->GetField(t)); |
1230 |
if (t==18) PRH_VAR_TRG_MODE_A= (UInt_t)atoll(Row->GetField(t)); |
1231 |
if (t==19) PRH_VAR_TRG_MODE_B= (UInt_t)atoll(Row->GetField(t)); |
1232 |
if (t==20) ACQ_BUILD_INFO = (UInt_t)atoll(Row->GetField(t)); |
1233 |
if (t==21) ACQ_VAR_INFO = (UInt_t)atoll(Row->GetField(t)); |
1234 |
if (t==22) RM_ACQ_AFTER_CALIB= (UInt_t)atoll(Row->GetField(t)); |
1235 |
if (t==23) RM_ACQ_SETTING_MODE = (UInt_t)atoll(Row->GetField(t)); |
1236 |
if (t==24) PKT_COUNTER = (UInt_t)atoll(Row->GetField(t)); |
1237 |
if (t==25) PKT_READY_COUNTER = (UInt_t)atoll(Row->GetField(t)); |
1238 |
if (t==26) TRK_CALIB_USED = (UInt_t)atoll(Row->GetField(t)); |
1239 |
if (t==27) CAL_DSP_MASK = (UInt_t)atoll(Row->GetField(t)); |
1240 |
if (t==28) BOOT_NUMBER = (UInt_t)atoll(Row->GetField(t)); |
1241 |
if (t==29) PHYSENDRUN_MASK_S3S2S12 = (UInt_t)atoll(Row->GetField(t)); |
1242 |
if (t==30) PHYSENDRUN_MASK_S11CRC = (UInt_t)atoll(Row->GetField(t)); |
1243 |
if (t==31) VALIDATION = (UInt_t)atoll(Row->GetField(t)); |
1244 |
}; |
1245 |
} |
1246 |
|
1247 |
if (Row) |
1248 |
delete Row; |
1249 |
delete pResult; |
1250 |
return(0); |
1251 |
}; |
1252 |
|
1253 |
/** |
1254 |
* Function to query the GL_RUN table of the DB. |
1255 |
* |
1256 |
* \param where = condition string |
1257 |
* \return struct of type GL_RUN _data, which stores the query result |
1258 |
* |
1259 |
*/ |
1260 |
Int_t GL_RUN::Query_GL_RUN_FRAGMENTS(TString where, TSQLServer *dbc){ |
1261 |
// MySQL variables |
1262 |
TSQLResult *pResult; |
1263 |
TSQLRow *Row = NULL; |
1264 |
int t; |
1265 |
int r; |
1266 |
stringstream myquery; |
1267 |
// ---------------- |
1268 |
myquery.str(""); |
1269 |
myquery << " select "; |
1270 |
myquery << "ID"; |
1271 |
myquery << ",ID_RUN_FRAG"; |
1272 |
myquery << ",ID_ROOT_L0"; |
1273 |
myquery << ",ID_ROOT_L2"; |
1274 |
myquery << ",RUNHEADER_TIME"; |
1275 |
myquery << ",RUNTRAILER_TIME"; |
1276 |
myquery << ",RUNHEADER_OBT"; |
1277 |
myquery << ",RUNTRAILER_OBT"; |
1278 |
myquery << ",RUNHEADER_PKT"; |
1279 |
myquery << ",RUNTRAILER_PKT"; |
1280 |
myquery << ",EV_FROM"; |
1281 |
myquery << ",EV_TO"; |
1282 |
myquery << ",NEVENTS"; |
1283 |
myquery << ",LAST_TIMESYNC"; |
1284 |
myquery << ",OBT_TIMESYNC"; |
1285 |
myquery << ",COMPILATIONTIMESTAMP"; |
1286 |
myquery << ",FAV_WRK_SCHEDULE"; |
1287 |
myquery << ",EFF_WRK_SCHEDULE"; |
1288 |
myquery << ",PRH_VAR_TRG_MODE_A"; |
1289 |
myquery << ",PRH_VAR_TRG_MODE_B"; |
1290 |
myquery << ",ACQ_BUILD_INFO"; |
1291 |
myquery << ",ACQ_VAR_INFO"; |
1292 |
myquery << ",RM_ACQ_AFTER_CALIB"; |
1293 |
myquery << ",RM_ACQ_SETTING_MODE"; |
1294 |
myquery << ",PKT_COUNTER"; |
1295 |
myquery << ",PKT_READY_COUNTER"; |
1296 |
myquery << ",TRK_CALIB_USED"; |
1297 |
myquery << ",CAL_DSP_MASK"; |
1298 |
myquery << ",BOOT_NUMBER"; |
1299 |
myquery << ",PHYSENDRUN_MASK_S3S2S12"; |
1300 |
myquery << ",PHYSENDRUN_MASK_S11CRC"; |
1301 |
myquery << ",VALIDATION"; |
1302 |
myquery << " from GL_RUN_FRAGMENTS where " << where.Data() << ";"; |
1303 |
// |
1304 |
// printf(" query is %s \n",myquery.str().c_str()); |
1305 |
// |
1306 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
1307 |
this->GetGLTABLES()->AddQ(); |
1308 |
pResult = dbc->Query(myquery.str().c_str()); |
1309 |
if(!pResult->GetRowCount())return(-50); |
1310 |
for( r=0; r < 1000; r++){ |
1311 |
if (Row) |
1312 |
delete Row; |
1313 |
Row = pResult->Next(); |
1314 |
if( Row == NULL ) break; |
1315 |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
1316 |
if (t== 0) ID = (UInt_t)atoll(Row->GetField(t)); |
1317 |
if (t== 1) ID_RUN_FRAG = (UInt_t)atoll(Row->GetField(t)); |
1318 |
if (t== 2) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); |
1319 |
if (t== 3) ID_ROOT_L2 = (UInt_t)atoll(Row->GetField(t)); |
1320 |
if (t== 4) RUNHEADER_TIME = (UInt_t)atoll(Row->GetField(t)); |
1321 |
if (t== 5) RUNTRAILER_TIME = (UInt_t)atoll(Row->GetField(t)); |
1322 |
if (t== 6) RUNHEADER_OBT = (UInt_t)atoll(Row->GetField(t)); |
1323 |
if (t== 7) RUNTRAILER_OBT = (UInt_t)atoll(Row->GetField(t)); |
1324 |
if (t== 8) RUNHEADER_PKT = (UInt_t)atoll(Row->GetField(t)); |
1325 |
if (t== 9) RUNTRAILER_PKT = (UInt_t)atoll(Row->GetField(t)); |
1326 |
if (t==10) EV_FROM = (UInt_t)atoll(Row->GetField(t)); |
1327 |
if (t==11) EV_TO = (UInt_t)atoll(Row->GetField(t)); |
1328 |
if (t==12) NEVENTS = (UInt_t)atoll(Row->GetField(t)); |
1329 |
if (t==13) LAST_TIMESYNC = (UInt_t)atoll(Row->GetField(t)); |
1330 |
if (t==14) OBT_TIMESYNC = (UInt_t)atoll(Row->GetField(t)); |
1331 |
if (t==15) COMPILATIONTIMESTAMP = (UInt_t)atoll(Row->GetField(t)); |
1332 |
if (t==16) FAV_WRK_SCHEDULE = (UInt_t)atoll(Row->GetField(t)); |
1333 |
if (t==17) EFF_WRK_SCHEDULE = (UInt_t)atoll(Row->GetField(t)); |
1334 |
if (t==18) PRH_VAR_TRG_MODE_A= (UInt_t)atoll(Row->GetField(t)); |
1335 |
if (t==19) PRH_VAR_TRG_MODE_B= (UInt_t)atoll(Row->GetField(t)); |
1336 |
if (t==20) ACQ_BUILD_INFO = (UInt_t)atoll(Row->GetField(t)); |
1337 |
if (t==21) ACQ_VAR_INFO = (UInt_t)atoll(Row->GetField(t)); |
1338 |
if (t==22) RM_ACQ_AFTER_CALIB= (UInt_t)atoll(Row->GetField(t)); |
1339 |
if (t==23) RM_ACQ_SETTING_MODE = (UInt_t)atoll(Row->GetField(t)); |
1340 |
if (t==24) PKT_COUNTER = (UInt_t)atoll(Row->GetField(t)); |
1341 |
if (t==25) PKT_READY_COUNTER = (UInt_t)atoll(Row->GetField(t)); |
1342 |
if (t==26) TRK_CALIB_USED = (UInt_t)atoll(Row->GetField(t)); |
1343 |
if (t==27) CAL_DSP_MASK = (UInt_t)atoll(Row->GetField(t)); |
1344 |
if (t==28) BOOT_NUMBER = (UInt_t)atoll(Row->GetField(t)); |
1345 |
if (t==29) PHYSENDRUN_MASK_S3S2S12 = (UInt_t)atoll(Row->GetField(t)); |
1346 |
if (t==30) PHYSENDRUN_MASK_S11CRC = (UInt_t)atoll(Row->GetField(t)); |
1347 |
if (t==31) VALIDATION = (UInt_t)atoll(Row->GetField(t)); |
1348 |
}; |
1349 |
} |
1350 |
|
1351 |
if (Row) |
1352 |
delete Row; |
1353 |
delete pResult; |
1354 |
return(0); |
1355 |
};// **************************************************** |
1356 |
|
1357 |
/** |
1358 |
* Function to query the GL_ROOT table of the DB. |
1359 |
* |
1360 |
* \param entry ID |
1361 |
* \return struct of type GL_ROOT_data, which stores the query result |
1362 |
*/ |
1363 |
Int_t GL_ROOT::Query_GL_ROOT(UInt_t id, TSQLServer *dbc){ |
1364 |
// MySQL variables |
1365 |
TSQLResult *pResult; |
1366 |
TSQLRow *Row = NULL; |
1367 |
int t; |
1368 |
int r; |
1369 |
stringstream myquery; |
1370 |
// ---------------- |
1371 |
myquery.str(""); |
1372 |
myquery << "select "; |
1373 |
myquery << " ID"; |
1374 |
myquery << ",ID_RAW"; |
1375 |
myquery << ",ID_TIMESYNC"; |
1376 |
myquery << ",PATH"; |
1377 |
myquery << ",NAME"; |
1378 |
myquery << " from GL_ROOT where ID=" << id << ";"; |
1379 |
// |
1380 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
1381 |
this->GetGLTABLES()->AddQ(); |
1382 |
pResult = dbc->Query(myquery.str().c_str()); |
1383 |
if(!pResult->GetRowCount())return (-51); |
1384 |
for( r=0; r < 1000; r++){ |
1385 |
if (Row) |
1386 |
delete Row; |
1387 |
Row = pResult->Next(); |
1388 |
if( Row == NULL ) break; |
1389 |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
1390 |
if(t==0) ID = (UInt_t)atoll(Row->GetField(t)); |
1391 |
if(t==1) ID_RAW = (UInt_t)atoll(Row->GetField(t)); |
1392 |
if(t==2) ID_TIMESYNC = (UInt_t)atoll(Row->GetField(t)); |
1393 |
if(t==3) PATH = (TString)gSystem->ExpandPathName(Row->GetField(t))+'/'; |
1394 |
if(t==4) NAME = Row->GetField(t); |
1395 |
} |
1396 |
} |
1397 |
if (Row) |
1398 |
delete Row; |
1399 |
delete pResult; |
1400 |
return 0; |
1401 |
}; |
1402 |
// **************************************************** |
1403 |
/** |
1404 |
* Function to query the GL_TRK_CALIB table of the DB. |
1405 |
* |
1406 |
* \param run starting time |
1407 |
* \param dbc DB server |
1408 |
* \return struct of type GL_TRK_CALIB_data, which stores the query result |
1409 |
*/ |
1410 |
Int_t GL_TRK_CALIB::Query_GL_TRK_CALIB(UInt_t time, TSQLServer *dbc){ |
1411 |
// MySQL variables |
1412 |
TSQLResult *pResult; |
1413 |
TSQLRow *Row = NULL; |
1414 |
int t; |
1415 |
int r; |
1416 |
stringstream myquery; |
1417 |
// ---------------- |
1418 |
myquery.str(""); |
1419 |
myquery << "select ID,ID_ROOT_L0,EV_ROOT_CALIBTRK1,EV_ROOT_CALIBTRK2,FROM_TIME,TO_TIME,OBT1,OBT2,PKT1,PKT2,BOOT_NUMBER,VALIDATION from GL_TRK_CALIB where FROM_TIME <= "<< time; |
1420 |
// myquery << " AND VALIDATION=1 ORDER BY FROM_TIME DESC LIMIT 1;"; // RIVEDERE LA VALIDAZIONE!!! |
1421 |
myquery << " and EV_ROOT_CALIBTRK1>=0 and EV_ROOT_CALIBTRK2>=0 "; // EM! SE MANCA UN PACCHETTO DEI DUE IL PROCESSAMENTO CRASHA... DA RIVEDERE LA VALIDAZIONE |
1422 |
myquery << " ORDER BY FROM_TIME DESC LIMIT 1;"; |
1423 |
// myquery << " ORDER BY FROM_TIME DESC LIMIT 1;"; |
1424 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
1425 |
this->GetGLTABLES()->AddQ(); |
1426 |
pResult = dbc->Query(myquery.str().c_str()); |
1427 |
if(!pResult->GetRowCount())return (-53); |
1428 |
for( r=0; r < 1000; r++){ |
1429 |
if (Row) |
1430 |
delete Row; |
1431 |
Row = pResult->Next(); |
1432 |
if( Row == NULL ) break; |
1433 |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
1434 |
stringstream row; |
1435 |
row.str(""); |
1436 |
row << "0" << Row->GetField(t); // add leading 0 since we have two fields that could be "null" and we want to avoid crashes due to atoll |
1437 |
if (t==0) ID = (UInt_t)atoll(Row->GetField(t)); |
1438 |
if (t==1) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); |
1439 |
if (t==2) EV_ROOT_CALIBTRK1 = (UInt_t)atoll(row.str().c_str()); |
1440 |
if (t==3) EV_ROOT_CALIBTRK2 = (UInt_t)atoll(row.str().c_str()); |
1441 |
if (t==4) FROM_TIME = (UInt_t)atoll(Row->GetField(t)); |
1442 |
if (t==5) TO_TIME = (UInt_t)atoll(Row->GetField(t)); |
1443 |
// |
1444 |
if (t==6) OBT1 = (UInt_t)atoll(Row->GetField(t)); |
1445 |
if (t==7) OBT2 = (UInt_t)atoll(Row->GetField(t)); |
1446 |
if (t==8) PKT1 = (UInt_t)atoll(Row->GetField(t)); |
1447 |
if (t==9) PKT2 = (UInt_t)atoll(Row->GetField(t)); |
1448 |
if (t==10) BOOT_NUMBER = (UInt_t)atoll(Row->GetField(t)); |
1449 |
if (t==11) VALIDATION = (UInt_t)atoll(Row->GetField(t)); |
1450 |
}; |
1451 |
} |
1452 |
if (Row) |
1453 |
delete Row; |
1454 |
delete pResult; |
1455 |
// |
1456 |
// if ( TO_TIME < time ) return(51); |
1457 |
// |
1458 |
if ( (!OBT1 && !PKT1 ) || (!OBT2 && !PKT2) ) return(52); // ONE CALIBRATION PACKET IS MISSING! |
1459 |
// |
1460 |
return 0; |
1461 |
}; |
1462 |
|
1463 |
// **************************************************** |
1464 |
/** |
1465 |
* Function to query the GL_CALO_CALIB table of the DB. |
1466 |
* |
1467 |
* \param run starting time |
1468 |
* \return struct of type GL_CALO_CALIB_data, which stores the query result |
1469 |
*/ |
1470 |
Int_t GL_CALO_CALIB::Query_GL_CALO_CALIB(UInt_t time, UInt_t &uptime, UInt_t section, TSQLServer *dbc){ |
1471 |
// MySQL variables |
1472 |
TSQLResult *pResult; |
1473 |
TSQLRow *Row = NULL; |
1474 |
int t; |
1475 |
stringstream myquery; |
1476 |
uptime = 0; |
1477 |
// |
1478 |
// select the correct calibration |
1479 |
// |
1480 |
myquery.str(""); |
1481 |
myquery << "select ID_ROOT_L0, FROM_TIME, TO_TIME, EV_ROOT,VALIDATION from GL_CALO_CALIB where SECTION=" << section; |
1482 |
myquery << " and FROM_TIME <= " << time; |
1483 |
myquery << " and TO_TIME > " << time; |
1484 |
myquery << " ;"; |
1485 |
//myquery << " and VALIDATION=1;"; |
1486 |
// |
1487 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
1488 |
this->GetGLTABLES()->AddQ(); |
1489 |
pResult = dbc->Query(myquery.str().c_str()); |
1490 |
// printf(" mysquery is %s\n",myquery.str().c_str()); |
1491 |
// |
1492 |
if( !pResult->GetRowCount() ) return(-54); |
1493 |
if (Row) |
1494 |
delete Row; |
1495 |
Row = pResult->Next(); |
1496 |
if( Row == NULL ) return (-54); |
1497 |
// |
1498 |
uptime = (UInt_t)atoll(Row->GetField(2)); |
1499 |
// |
1500 |
UInt_t myfromtime = (UInt_t)atoll(Row->GetField(1)); |
1501 |
UInt_t mytotime = (UInt_t)atoll(Row->GetField(2)); |
1502 |
// |
1503 |
// if it is corrupted validation is 0 and we have no results from the query... |
1504 |
// |
1505 |
if( atoi(Row->GetField(4)) == 0 ){ // if validation = 0 |
1506 |
// |
1507 |
// in this case take relax the conditions and take the valid calibration that preceed the correct one |
1508 |
// |
1509 |
myquery.str(""); |
1510 |
myquery << "select ID_ROOT_L0, FROM_TIME, TO_TIME, EV_ROOT,VALIDATION from GL_CALO_CALIB where SECTION=" << section; |
1511 |
myquery << " and FROM_TIME <= " << time; |
1512 |
myquery << " and VALIDATION=1 ORDER BY FROM_TIME DESC LIMIT 1;"; |
1513 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
1514 |
this->GetGLTABLES()->AddQ(); |
1515 |
pResult = dbc->Query(myquery.str().c_str()); |
1516 |
// printf(" mysquery is %s\n",myquery.str().c_str()); |
1517 |
// |
1518 |
// if no results yet quit with error |
1519 |
// |
1520 |
if( !pResult->GetRowCount() ) return (-54); |
1521 |
// |
1522 |
if (Row) |
1523 |
delete Row; |
1524 |
Row = pResult->Next(); |
1525 |
// |
1526 |
myfromtime = (UInt_t)atoll(Row->GetField(1)); |
1527 |
// |
1528 |
}; |
1529 |
// |
1530 |
// if the selected calibration is too old (more than 5 orbits old) try to take the closest not corrupted one |
1531 |
// |
1532 |
if ( (time-myfromtime)>28500 && myfromtime > 0 ){ |
1533 |
// |
1534 |
myquery.str(""); |
1535 |
myquery << "select ID_ROOT_L0, FROM_TIME, TO_TIME, EV_ROOT from GL_CALO_CALIB where SECTION=" << section; |
1536 |
myquery << " and VALIDATION=1 ORDER BY ABS(" << time << "-FROM_TIME) asc limit 1;"; |
1537 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
1538 |
this->GetGLTABLES()->AddQ(); |
1539 |
pResult = dbc->Query(myquery.str().c_str()); |
1540 |
// printf(" mysquery is %s\n",myquery.str().c_str()); |
1541 |
// |
1542 |
// if no results yet quit with error |
1543 |
// |
1544 |
if( !pResult->GetRowCount() ) return (-54); |
1545 |
// |
1546 |
Row = pResult->Next(); |
1547 |
// |
1548 |
}; |
1549 |
// |
1550 |
// store infos and exit |
1551 |
// |
1552 |
if( Row == NULL ) return (-54); |
1553 |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
1554 |
if (t==0) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); |
1555 |
if (t==1) FROM_TIME = myfromtime; |
1556 |
if (t==2) TO_TIME = mytotime; |
1557 |
if (t==3) EV_ROOT = (UInt_t)atoll(Row->GetField(t)); |
1558 |
} |
1559 |
if (Row) |
1560 |
delete Row; |
1561 |
pResult->Delete(); |
1562 |
return 0; |
1563 |
}; |
1564 |
|
1565 |
|
1566 |
// **************************************************** |
1567 |
/** |
1568 |
* Function to query the GL_CALOPULSE_CALIB table of the DB. |
1569 |
* |
1570 |
* \param run starting time |
1571 |
* \return struct of type GL_CALOPULSE_CALIB_data, which stores the query result |
1572 |
*/ |
1573 |
Int_t GL_CALOPULSE_CALIB::Query_GL_CALOPULSE_CALIB(UInt_t time, UInt_t section, UInt_t pampli, TSQLServer *dbc){ |
1574 |
// MySQL variables |
1575 |
TSQLResult *pResult; |
1576 |
TSQLRow *Row = NULL; |
1577 |
int t; |
1578 |
stringstream myquery; |
1579 |
// |
1580 |
// select the correct calibration i.e. the closest to our time |
1581 |
// |
1582 |
myquery.str(""); |
1583 |
myquery << "select ID_ROOT_L0, FROM_TIME, TO_TIME, EV_ROOT from GL_CALOPULSE_CALIB where SECTION=" << section; |
1584 |
myquery << " and PULSE_AMPLITUDE=" << pampli; |
1585 |
myquery << " and VALIDATION=1 and (PULSED_STRIP IS NULL OR PULSED_STRIP<100) ORDER BY ABS(" << time << "-FROM_TIME) asc limit 1;"; |
1586 |
// printf(" myq is %s \n",myquery.str().c_str()); |
1587 |
// |
1588 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
1589 |
this->GetGLTABLES()->AddQ(); |
1590 |
pResult = dbc->Query(myquery.str().c_str()); |
1591 |
// |
1592 |
if( !pResult ) return(-54); |
1593 |
// |
1594 |
if (Row) |
1595 |
delete Row; |
1596 |
Row = pResult->Next(); |
1597 |
// |
1598 |
if( !Row ) return (-54); |
1599 |
// |
1600 |
// store infos and exit |
1601 |
// |
1602 |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
1603 |
// printf(" field %i is %s \n",t,Row->GetField(t)); |
1604 |
if (t==0) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); |
1605 |
if (t==1) FROM_TIME = (UInt_t)atoll(Row->GetField(t)); |
1606 |
if (t==2) TO_TIME = (UInt_t)atoll(Row->GetField(t)); |
1607 |
if (t==3) EV_ROOT = (UInt_t)atoll(Row->GetField(t)); |
1608 |
} |
1609 |
if (Row) |
1610 |
delete Row; |
1611 |
pResult->Delete(); |
1612 |
return 0; |
1613 |
}; |
1614 |
|
1615 |
|
1616 |
// **************************************************** |
1617 |
/** |
1618 |
* Function to query the GL_S4_CALIB table of the DB. |
1619 |
* |
1620 |
* \param run starting time |
1621 |
* \return struct of type GL_S4_CALIB_data, which stores the query result |
1622 |
*/ |
1623 |
Int_t GL_S4_CALIB::Query_GL_S4_CALIB(UInt_t time, TSQLServer *dbc){ |
1624 |
// MySQL variables |
1625 |
TSQLResult *pResult; |
1626 |
TSQLRow *Row = NULL; |
1627 |
int t; |
1628 |
int r; |
1629 |
stringstream myquery; |
1630 |
// ---------------- |
1631 |
myquery.str(""); |
1632 |
myquery << "select ID,ID_ROOT_L0,EV_ROOT,FROM_TIME,TO_TIME from GL_S4_CALIB where FROM_TIME <= "<< time; |
1633 |
myquery << " ORDER BY FROM_TIME DESC LIMIT 1;"; |
1634 |
// myquery << " ORDER BY FROM_TIME DESC LIMIT 1;"; |
1635 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
1636 |
this->GetGLTABLES()->AddQ(); |
1637 |
pResult = dbc->Query(myquery.str().c_str()); |
1638 |
if(!pResult->GetRowCount())return (-55);//throw -55; |
1639 |
for( r=0; r < 1000; r++){ |
1640 |
if (Row) |
1641 |
delete Row; |
1642 |
Row = pResult->Next(); |
1643 |
if( Row == NULL ) break; |
1644 |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
1645 |
if (t==0) ID = (UInt_t)atoll(Row->GetField(t)); |
1646 |
if (t==1) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); |
1647 |
if (t==2) EV_ROOT = (UInt_t)atoll(Row->GetField(t)); |
1648 |
if (t==3) FROM_TIME = (UInt_t)atoll(Row->GetField(t)); |
1649 |
if (t==4) TO_TIME = (UInt_t)atoll(Row->GetField(t)); |
1650 |
}; |
1651 |
} |
1652 |
if (Row) |
1653 |
delete Row; |
1654 |
delete pResult; |
1655 |
// |
1656 |
if(TO_TIME < time)return(51); |
1657 |
// |
1658 |
return 0; |
1659 |
}; |
1660 |
// **************************************************** |
1661 |
/** |
1662 |
* Function to query the GL_PARAM table of the DB. |
1663 |
* |
1664 |
* \param run starting time |
1665 |
* \param parameter description (DESCR) |
1666 |
* \return struct of type GL_ROOT_data, which stores the query result |
1667 |
*/ |
1668 |
Int_t GL_PARAM::Query_GL_PARAM(UInt_t time, UInt_t type, TSQLServer *dbc){ |
1669 |
// Bool_t debug = 1; |
1670 |
// MySQL variables |
1671 |
TSQLResult *pResult; |
1672 |
TSQLRow *Row = NULL; |
1673 |
int t; |
1674 |
int r; |
1675 |
stringstream myquery; |
1676 |
// ---------------- |
1677 |
myquery.str(""); |
1678 |
myquery << " select "; |
1679 |
myquery << " ID, PATH, NAME, DESCR, FROM_TIME,TO_TIME, TYPE "; |
1680 |
myquery << " from GL_PARAM "; |
1681 |
myquery << " where TYPE = '"<<type<<"' "; |
1682 |
myquery << " and FROM_TIME <= " << time; |
1683 |
myquery << " ORDER BY TO_TIME DESC LIMIT 1;"; |
1684 |
// |
1685 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
1686 |
this->GetGLTABLES()->AddQ(); |
1687 |
pResult = dbc->Query(myquery.str().c_str()); |
1688 |
if(!pResult->GetRowCount())return (-52); |
1689 |
for( r=0; r < 1000; r++){ |
1690 |
if (Row) |
1691 |
delete Row; |
1692 |
Row = pResult->Next(); |
1693 |
if( Row == NULL ) break; |
1694 |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
1695 |
if (t==0) ID = (UInt_t)atoll(Row->GetField(t)); |
1696 |
if (t==1) PATH = (TString)gSystem->ExpandPathName(Row->GetField(t))+'/';// put in fpath the path to that file |
1697 |
if (t==2) NAME = Row->GetField(t); |
1698 |
if (t==3) DESCR = Row->GetField(t); |
1699 |
if (t==4) FROM_TIME = (UInt_t)atoll(Row->GetField(t)); |
1700 |
if (t==5) TO_TIME = (UInt_t)atoll(Row->GetField(t)); |
1701 |
if (t==6) TYPE = (UInt_t)atoll(Row->GetField(t)); |
1702 |
}; |
1703 |
} |
1704 |
if (Row) |
1705 |
delete Row; |
1706 |
delete pResult; |
1707 |
// |
1708 |
if(TO_TIME==0) TO_TIME = numeric_limits<UInt_t>::max(); |
1709 |
// |
1710 |
if(TO_TIME < time) return(51); |
1711 |
// |
1712 |
return 0; |
1713 |
}; |
1714 |
|
1715 |
|
1716 |
/** |
1717 |
* Fills a struct cGLRun with values from a GLRun object (to put data into a F77 common). |
1718 |
*/ |
1719 |
|
1720 |
void GL_RUN::GetLevel2Struct(cGLRun *l2) const{ |
1721 |
l2->id = ID; |
1722 |
l2->id_reg_run = ID_ROOT_L0; |
1723 |
l2->id_reg_run_l2 = ID_ROOT_L2; |
1724 |
l2->runheader_time = RUNHEADER_TIME; |
1725 |
l2->runtrailer_time = RUNTRAILER_TIME; |
1726 |
l2->ev_from = EV_FROM; |
1727 |
l2->trk_calib_used = TRK_CALIB_USED; |
1728 |
l2->eff_wrk_schedule = EFF_WRK_SCHEDULE; |
1729 |
l2->prh_var_trg_mode_a = PRH_VAR_TRG_MODE_A; |
1730 |
l2->prh_var_trg_mode_b = PRH_VAR_TRG_MODE_B; |
1731 |
l2->acq_build_info = ACQ_BUILD_INFO; |
1732 |
l2->acq_var_info = ACQ_VAR_INFO; |
1733 |
}; |
1734 |
|
1735 |
GL_TIMESYNC::GL_TIMESYNC(UInt_t id, TString type, TSQLServer *dbc){ |
1736 |
// MySQL variables |
1737 |
TFile *file = 0; |
1738 |
UInt_t idtsy = 0; |
1739 |
// |
1740 |
TSQLResult *pResult; |
1741 |
TSQLRow *Row = NULL; |
1742 |
stringstream myquery; |
1743 |
stringstream rname; |
1744 |
// pcksList packetsNames; |
1745 |
// pcksList::iterator Iter; |
1746 |
// getPacketsNames(packetsNames); |
1747 |
rname.str(""); |
1748 |
// ---------------- |
1749 |
myquery.str(""); |
1750 |
myquery << "select "; |
1751 |
myquery << "PATH"; |
1752 |
myquery << ",NAME,ID_TIMESYNC"; |
1753 |
myquery << " from GL_ROOT where "; |
1754 |
myquery << type.Data(); |
1755 |
myquery << "=" << id << ";"; |
1756 |
// |
1757 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return; |
1758 |
this->GetGLTABLES()->AddQ(); |
1759 |
pResult = dbc->Query(myquery.str().c_str()); |
1760 |
if( pResult->GetRowCount() ){ |
1761 |
if (Row) |
1762 |
delete Row; |
1763 |
Row = pResult->Next(); |
1764 |
if( Row ){ |
1765 |
stringstream fname; |
1766 |
fname.str(""); |
1767 |
fname << gSystem->ExpandPathName(Row->GetField(0)) << "/" << Row->GetField(1); |
1768 |
rname << Row->GetField(1); |
1769 |
file = new TFile(fname.str().c_str(),"READ"); |
1770 |
idtsy = (UInt_t)atoll(Row->GetField(2)); |
1771 |
}; |
1772 |
}; |
1773 |
// |
1774 |
if ( file && file->IsOpen() ){ |
1775 |
TTree *T=(TTree*)file->Get("Physics"); |
1776 |
pamela::EventHeader *eh = 0; |
1777 |
pamela::PscuHeader *ph = 0; |
1778 |
T->SetBranchAddress("Header", &eh); |
1779 |
// |
1780 |
T->GetEntry(0); |
1781 |
ph = eh->GetPscuHeader(); |
1782 |
pktfirst = ph->GetCounter(); |
1783 |
// obtfirst = ph->GetOrbitalTime(); |
1784 |
// |
1785 |
}; |
1786 |
// |
1787 |
// look for Resurs offset |
1788 |
// |
1789 |
T0 = 0; |
1790 |
// |
1791 |
stringstream oss; |
1792 |
// |
1793 |
TString name=rname.str().c_str(); |
1794 |
UInt_t dworbit = 0; |
1795 |
// Int_t nlength = name.Length(); |
1796 |
delete pResult; |
1797 |
// |
1798 |
// New code, we have one more column on GL_TIMESYNC so we can trust that one for the Resurs offset |
1799 |
// |
1800 |
oss.str(""); |
1801 |
oss << "SELECT OBT0,TIMESYNC,TYPE,ID_RESURS_OFFSET from GL_TIMESYNC where ID=" << idtsy <<";"; |
1802 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return; |
1803 |
this->GetGLTABLES()->AddQ(); |
1804 |
pResult = dbc->Query(oss.str().c_str()); |
1805 |
Bool_t fndit = false; |
1806 |
if ( pResult ){ |
1807 |
if (Row) |
1808 |
delete Row; |
1809 |
Row = pResult->Next(); |
1810 |
if ( Row ){ |
1811 |
// |
1812 |
OBT0 = (UInt_t)atoll(Row->GetField(0)); |
1813 |
obtfirst = OBT0; |
1814 |
TIMESYNC = (UInt_t)atoll(Row->GetField(1)); |
1815 |
TYPE = (UInt_t)atoll(Row->GetField(2)); |
1816 |
// |
1817 |
oss.str(""); |
1818 |
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=" |
1819 |
<< Row->GetField(3) << ";"; |
1820 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return; |
1821 |
this->GetGLTABLES()->AddQ(); |
1822 |
delete pResult; |
1823 |
pResult = dbc->Query(oss.str().c_str()); |
1824 |
if (pResult){ |
1825 |
if (Row) |
1826 |
delete Row; |
1827 |
Row = pResult->Next(); |
1828 |
if ( Row ){ |
1829 |
// printf(" GREAT! the DB structure is the new one! \n"); |
1830 |
fndit = true; |
1831 |
dworbit = 1; |
1832 |
}; |
1833 |
}; |
1834 |
}; |
1835 |
}; |
1836 |
if ( !fndit ){ |
1837 |
// |
1838 |
printf(" ERROR OLD DB! \n"); |
1839 |
printf(" ERROR FROM GLTables! cannot determine Resurs offset \n"); |
1840 |
// |
1841 |
}; |
1842 |
// |
1843 |
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); |
1844 |
T0 = (UInt_t)tu.GetSec(); |
1845 |
// |
1846 |
toffset = (UInt_t)TIMESYNC - (UInt_t)(this->DBobt(OBT0)/1000) + T0; |
1847 |
// |
1848 |
// printf(" T0 %u toffset is %u \n",T0,toffset); |
1849 |
// |
1850 |
if ( file ) file->Close(); |
1851 |
if (Row) |
1852 |
delete Row; |
1853 |
delete pResult; |
1854 |
}; |
1855 |
|
1856 |
GL_TIMESYNC::GL_TIMESYNC(UInt_t id, TString type, TSQLServer *dbc, Bool_t usel0file){ |
1857 |
// MySQL variables |
1858 |
TFile *file = 0; |
1859 |
UInt_t idtsy = 0; |
1860 |
// |
1861 |
TSQLResult *pResult; |
1862 |
TSQLRow *Row = NULL; |
1863 |
stringstream myquery; |
1864 |
stringstream rname; |
1865 |
// pcksList packetsNames; |
1866 |
// pcksList::iterator Iter; |
1867 |
// getPacketsNames(packetsNames); |
1868 |
rname.str(""); |
1869 |
// ---------------- |
1870 |
myquery.str(""); |
1871 |
myquery << "select "; |
1872 |
myquery << "PATH"; |
1873 |
myquery << ",NAME,ID_TIMESYNC"; |
1874 |
myquery << " from GL_ROOT where "; |
1875 |
myquery << type.Data(); |
1876 |
myquery << "=" << id << ";"; |
1877 |
// |
1878 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return; |
1879 |
this->GetGLTABLES()->AddQ(); |
1880 |
pResult = dbc->Query(myquery.str().c_str()); |
1881 |
if( pResult->GetRowCount() ){ |
1882 |
if (Row) |
1883 |
delete Row; |
1884 |
Row = pResult->Next(); |
1885 |
if( Row ){ |
1886 |
stringstream fname; |
1887 |
fname.str(""); |
1888 |
fname << gSystem->ExpandPathName(Row->GetField(0)) << "/" << Row->GetField(1); |
1889 |
rname << Row->GetField(1); |
1890 |
if ( usel0file ) file = new TFile(fname.str().c_str(),"READ"); |
1891 |
idtsy = (UInt_t)atoll(Row->GetField(2)); |
1892 |
}; |
1893 |
}; |
1894 |
// |
1895 |
if ( usel0file && file && file->IsOpen() ){ |
1896 |
TTree *T=(TTree*)file->Get("Physics"); |
1897 |
pamela::EventHeader *eh = 0; |
1898 |
pamela::PscuHeader *ph = 0; |
1899 |
T->SetBranchAddress("Header", &eh); |
1900 |
// |
1901 |
T->GetEntry(0); |
1902 |
ph = eh->GetPscuHeader(); |
1903 |
pktfirst = ph->GetCounter(); |
1904 |
// obtfirst = ph->GetOrbitalTime(); |
1905 |
// |
1906 |
}; |
1907 |
if ( !usel0file ) pktfirst = 0; |
1908 |
// |
1909 |
// look for Resurs offset |
1910 |
// |
1911 |
T0 = 0; |
1912 |
// |
1913 |
stringstream oss; |
1914 |
// |
1915 |
TString name=rname.str().c_str(); |
1916 |
UInt_t dworbit = 0; |
1917 |
// Int_t nlength = name.Length(); |
1918 |
delete pResult; |
1919 |
// |
1920 |
// New code, we have one more column on GL_TIMESYNC so we can trust that one for the Resurs offset |
1921 |
// |
1922 |
oss.str(""); |
1923 |
oss << "SELECT OBT0,TIMESYNC,TYPE,ID_RESURS_OFFSET from GL_TIMESYNC where ID=" << idtsy <<";"; |
1924 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return; |
1925 |
this->GetGLTABLES()->AddQ(); |
1926 |
pResult = dbc->Query(oss.str().c_str()); |
1927 |
Bool_t fndit = false; |
1928 |
if ( pResult ){ |
1929 |
if (Row) |
1930 |
delete Row; |
1931 |
Row = pResult->Next(); |
1932 |
if ( Row ){ |
1933 |
// |
1934 |
OBT0 = (UInt_t)atoll(Row->GetField(0)); |
1935 |
obtfirst = OBT0; |
1936 |
TIMESYNC = (UInt_t)atoll(Row->GetField(1)); |
1937 |
TYPE = (UInt_t)atoll(Row->GetField(2)); |
1938 |
// |
1939 |
oss.str(""); |
1940 |
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=" |
1941 |
<< Row->GetField(3) << ";"; |
1942 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return; |
1943 |
this->GetGLTABLES()->AddQ(); |
1944 |
delete pResult; |
1945 |
pResult = dbc->Query(oss.str().c_str()); |
1946 |
if (pResult){ |
1947 |
if (Row) |
1948 |
delete Row; |
1949 |
Row = pResult->Next(); |
1950 |
if (Row){ |
1951 |
// printf(" GREAT! the DB structure is the new one! \n"); |
1952 |
fndit = true; |
1953 |
dworbit = 1; |
1954 |
}; |
1955 |
}; |
1956 |
}; |
1957 |
}; |
1958 |
if ( !fndit ){ |
1959 |
// |
1960 |
printf(" ERROR OLD DB! \n"); |
1961 |
printf(" ERROR FROM GLTables! cannot determine Resurs offset \n"); |
1962 |
// |
1963 |
}; |
1964 |
// |
1965 |
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); |
1966 |
T0 = (UInt_t)tu.GetSec(); |
1967 |
// |
1968 |
toffset = (UInt_t)TIMESYNC - (UInt_t)(this->DBobt(OBT0)/1000) + T0; |
1969 |
// |
1970 |
// printf(" T0 %u toffset is %u \n",T0,toffset); |
1971 |
// |
1972 |
if ( file ) file->Close(); |
1973 |
if (Row) |
1974 |
delete Row; |
1975 |
delete pResult; |
1976 |
}; |
1977 |
|
1978 |
/** |
1979 |
* |
1980 |
* Returns the DB absolute time needed to associate calibrations to data |
1981 |
* |
1982 |
*/ |
1983 |
UInt_t GL_TIMESYNC::DBabsTime(UInt_t OBT){ |
1984 |
// |
1985 |
// printf(" OBT %u DBobt %llu toffset %u dbabstime %u\n",OBT,this->DBobt(OBT),toffset,((UInt_t)(this->DBobt(OBT)/1000)+toffset)); |
1986 |
return(((UInt_t)(this->DBobt(OBT)/1000)+toffset)); |
1987 |
// |
1988 |
}; |
1989 |
|
1990 |
/** |
1991 |
* |
1992 |
* Returns the Resurs time given the OBT needed to process inclination and orbital infos |
1993 |
* |
1994 |
*/ |
1995 |
UInt_t GL_TIMESYNC::ResursTime(UInt_t OBT){ |
1996 |
// |
1997 |
return(((UInt_t)((Int_t)(this->DBobt(OBT)-this->DBobt(OBT0)/1000))+TIMESYNC)); |
1998 |
// |
1999 |
}; |
2000 |
|
2001 |
|
2002 |
/** |
2003 |
* Return the correct packet number if we went back to zero |
2004 |
*/ |
2005 |
Long64_t GL_TIMESYNC::DBpkt(UInt_t pkt_num){ |
2006 |
// |
2007 |
if ( pkt_num < (pktfirst/2) && pktfirst > (16777214/2) ){ |
2008 |
return((Long64_t)pkt_num+16777215LL); |
2009 |
}; |
2010 |
// |
2011 |
if ( pkt_num > pktfirst*2 && pkt_num > (16777214/2) ){ |
2012 |
return((Long64_t)pkt_num-16777215LL); |
2013 |
}; |
2014 |
// |
2015 |
return((Long64_t)pkt_num); |
2016 |
// |
2017 |
}; |
2018 |
|
2019 |
/** |
2020 |
* Return the correct On Board Time if we went back to zero |
2021 |
*/ |
2022 |
Long64_t GL_TIMESYNC::DBobt(UInt_t obt){ |
2023 |
// |
2024 |
if ( obt < ((Long64_t)obtfirst/2) && obtfirst > (numeric_limits<UInt_t>::max()/2) ){ |
2025 |
return((Long64_t)obt+(Long64_t)numeric_limits<UInt_t>::max()); |
2026 |
}; |
2027 |
// |
2028 |
if ( obt > ((Long64_t)obtfirst*2) && obt > (numeric_limits<UInt_t>::max()/2) ){ |
2029 |
return((Long64_t)obt-(Long64_t)numeric_limits<UInt_t>::max()); |
2030 |
}; |
2031 |
// |
2032 |
return((Long64_t)obt); |
2033 |
}; |
2034 |
|
2035 |
|
2036 |
|
2037 |
// ULong64_t GL_TIMESYNC::DBobt(UInt_t obt){ |
2038 |
// // |
2039 |
// if ( obt < (obtfirst/2) && obtfirst > (numeric_limits<UInt_t>::max()/2) ) return((ULong64_t)(obt+numeric_limits<UInt_t>::max())); |
2040 |
// // |
2041 |
// if ( obt > (obtfirst*2) && obt > (numeric_limits<UInt_t>::max()/2) ){ |
2042 |
// if ( (obt-numeric_limits<UInt_t>::max()) < 0 ){ |
2043 |
// return((ULong64_t)(numeric_limits<UInt_t>::max()-obt)); |
2044 |
// } else { |
2045 |
// return((ULong64_t)(obt-numeric_limits<UInt_t>::max())); |
2046 |
// }; |
2047 |
// }; |
2048 |
// // |
2049 |
// return((ULong64_t)obt); |
2050 |
// // |
2051 |
// }; |
2052 |
|
2053 |
// UInt_t GL_TIMESYNC::DBpkt(UInt_t pkt_num){ |
2054 |
// // |
2055 |
// if ( pkt_num < (pktfirst/2) && pktfirst > (16777214/2) ) return((pkt_num+16777215)); |
2056 |
// // |
2057 |
// if ( pkt_num > pktfirst*2 && pkt_num > (16777214/2) ){ |
2058 |
// if ( (pkt_num-16777215) < 0 ){ |
2059 |
// return((16777215-pkt_num)); |
2060 |
// } else { |
2061 |
// return((pkt_num-16777215)); |
2062 |
// }; |
2063 |
// }; |
2064 |
// // |
2065 |
// return(pkt_num); |
2066 |
// // |
2067 |
// }; |
2068 |
|
2069 |
/* |
2070 |
* |
2071 |
* Convert the time in the DB from UInt_t to a string |
2072 |
* |
2073 |
* @param dbt time in the DB |
2074 |
* @param tzone Time Zone, can be UTC,GMT,CET,CEST,MSD default is MSK |
2075 |
* |
2076 |
*/ |
2077 |
TString GL_TIMESYNC::ConvertTime(TString &tzone, UInt_t dbt){ |
2078 |
// |
2079 |
Int_t offset = 0; |
2080 |
TString rtime; |
2081 |
Bool_t found = false; |
2082 |
// |
2083 |
if ( !strcmp(tzone.Data(),"MSK") || !strcmp(tzone.Data(),"MWT") ){ |
2084 |
// |
2085 |
offset = 60*60*3; // UTC (Coordinated Universal Time) + 3hs = Moscow Winter Time |
2086 |
found = true; |
2087 |
// |
2088 |
}; |
2089 |
// |
2090 |
if ( !strcmp(tzone.Data(),"CET") ){ |
2091 |
// |
2092 |
offset = 60*60*1; // CET (Central European Time) = UTC + 1 hs |
2093 |
found = true; |
2094 |
// |
2095 |
}; |
2096 |
// |
2097 |
if ( !strcmp(tzone.Data(),"CEST") ){ |
2098 |
// |
2099 |
offset = 60*60*2; // CEST (Central European Summer Time) = UTC + 2 h |
2100 |
found = true; |
2101 |
// |
2102 |
}; |
2103 |
// |
2104 |
if ( !strcmp(tzone.Data(),"MSD") || !strcmp(tzone.Data(),"MST")){ |
2105 |
// |
2106 |
offset = 60*60*4; // MSD (Moscow Summer Time) = UTC + 4 h |
2107 |
found = true; |
2108 |
// |
2109 |
}; |
2110 |
// |
2111 |
if ( !found && strcmp(tzone.Data(),"UTC") && strcmp(tzone.Data(),"GMT") && strcmp(tzone.Data(),"") ){ |
2112 |
printf("\n Unknown time zone %s using UTC \n",tzone.Data()); |
2113 |
tzone = "UTC"; |
2114 |
}; |
2115 |
// |
2116 |
dbt += offset; |
2117 |
// |
2118 |
TTimeStamp *time = new TTimeStamp((time_t)dbt,0); |
2119 |
// |
2120 |
rtime = time->AsString("s"); |
2121 |
// |
2122 |
delete time; |
2123 |
// |
2124 |
return(rtime); |
2125 |
} |
2126 |
|
2127 |
/* |
2128 |
* |
2129 |
* Convert the time from TZONE to UTC |
2130 |
* |
2131 |
* @param dbt time in the DB |
2132 |
* @param tzone Time Zone, can be UTC,GMT,CET,CEST,MSD default is MSK |
2133 |
* |
2134 |
*/ |
2135 |
TString GL_TIMESYNC::UnConvertTime(TString &tzone, UInt_t dbt){ |
2136 |
// |
2137 |
Int_t offset = 0; |
2138 |
TString rtime; |
2139 |
// |
2140 |
Bool_t found = false; |
2141 |
// |
2142 |
if ( !strcmp(tzone.Data(),"MSK") || !strcmp(tzone.Data(),"MWT") ){ |
2143 |
// |
2144 |
offset = -60*60*3; // UTC (Coordinated Universal Time) = Moscow Winter Time - 3hs |
2145 |
found = true; |
2146 |
// |
2147 |
}; |
2148 |
// |
2149 |
if ( !strcmp(tzone.Data(),"CET") ){ |
2150 |
// |
2151 |
offset = -60*60*1; // CET (Central European Time) - 1 hs = UTC |
2152 |
found = true; |
2153 |
// |
2154 |
}; |
2155 |
// |
2156 |
if ( !strcmp(tzone.Data(),"CEST") ){ |
2157 |
// |
2158 |
offset = -60*60*2; // CEST (Central European Summer Time) - 2 h = UTC |
2159 |
found = true; |
2160 |
// |
2161 |
}; |
2162 |
// |
2163 |
if ( !strcmp(tzone.Data(),"MSD") || !strcmp(tzone.Data(),"MST") ){ |
2164 |
// |
2165 |
offset = -60*60*4; // MSD (Moscow Summer Time) - 4 h = UTC |
2166 |
found = true; |
2167 |
// |
2168 |
}; |
2169 |
// |
2170 |
if ( !found && strcmp(tzone.Data(),"UTC") && strcmp(tzone.Data(),"GMT") && strcmp(tzone.Data(),"") ){ |
2171 |
// |
2172 |
offset = 0; |
2173 |
printf("\n Unknown time zone %s using UTC \n",tzone.Data()); |
2174 |
tzone = "UTC"; |
2175 |
}; |
2176 |
// |
2177 |
dbt += offset; |
2178 |
TTimeStamp *time = new TTimeStamp((time_t)dbt,0); |
2179 |
// |
2180 |
rtime = time->AsString("s"); |
2181 |
// |
2182 |
return(rtime); |
2183 |
} |
2184 |
|
2185 |
|
2186 |
// |
2187 |
// Build a query and call DoQuery. |
2188 |
// |
2189 |
// date it's an SQL datetime date and dbc is the connection to be |
2190 |
// used. It will query for the tle with the nearest but previous date |
2191 |
// and the immediatly next one. |
2192 |
// |
2193 |
Int_t GL_TLE::Query(TString date, TSQLServer *dbc){ |
2194 |
stringstream myquery; |
2195 |
myquery.str(""); |
2196 |
|
2197 |
myquery << "(SELECT ID, TLE1, TLE2, TLE3, UNIX_TIMESTAMP(FROM_TIME) FROM GL_TLE " |
2198 |
<< "WHERE FROM_TIME <= '" << date.Data() |
2199 |
<< "' ORDER BY FROM_TIME DESC LIMIT 1) " |
2200 |
<< "UNION " |
2201 |
<< "(SELECT ID, TLE1, TLE2, TLE3, UNIX_TIMESTAMP(FROM_TIME) FROM GL_TLE " |
2202 |
<< "WHERE FROM_TIME > '" << date.Data() |
2203 |
<< "' ORDER BY FROM_TIME ASC LIMIT 1)"; |
2204 |
|
2205 |
return DoQuery(myquery.str().c_str(), dbc); |
2206 |
} |
2207 |
|
2208 |
|
2209 |
// |
2210 |
// Build a query and call DoQuery. |
2211 |
// |
2212 |
// time is the UTC date in unix time (UTC) and dbc is the connection |
2213 |
// to be used. It will query for the tle with the nearest but |
2214 |
// previous date and the immediatly next one. |
2215 |
// |
2216 |
// Returns the value returned by DoQuery(). |
2217 |
// |
2218 |
Int_t GL_TLE::Query(UInt_t time, TSQLServer *dbc){ |
2219 |
stringstream myquery; |
2220 |
myquery.str(""); |
2221 |
|
2222 |
myquery << "(SELECT ID, TLE1, TLE2, TLE3, UNIX_TIMESTAMP(FROM_TIME) FROM GL_TLE " |
2223 |
<< "WHERE FROM_TIME <= FROM_UNIXTIME('" << time |
2224 |
<< "') ORDER BY FROM_TIME DESC LIMIT 1) " |
2225 |
<< "UNION " |
2226 |
<< "(SELECT ID, TLE1, TLE2, TLE3, UNIX_TIMESTAMP(FROM_TIME) FROM GL_TLE " |
2227 |
<< "WHERE FROM_TIME > FROM_UNIXTIME('" << time |
2228 |
<< "') ORDER BY FROM_TIME ASC LIMIT 1)"; |
2229 |
|
2230 |
return DoQuery(myquery.str().c_str(), dbc); |
2231 |
} |
2232 |
|
2233 |
|
2234 |
// |
2235 |
// Do the query myquery on the connectio dbc. Initialize tle, |
2236 |
// tleFromTime and tleToTime. |
2237 |
// |
2238 |
// We should have two rows (unless the table is old). From the last |
2239 |
// one we only take tleToTime. |
2240 |
// |
2241 |
// Returns 0 for success, 1 for failure. |
2242 |
// |
2243 |
Int_t GL_TLE::DoQuery(TString myquery, TSQLServer *dbc){ |
2244 |
TSQLResult *result; |
2245 |
TSQLRow *row = NULL; |
2246 |
|
2247 |
// Set the right time_zone (otherwise horrible things will occur! :) |
2248 |
if ( !this->GetGLTABLES()->IsConnected(dbc) ) return -57; |
2249 |
dbc->Query("SET time_zone = '+0:00'"); |
2250 |
|
2251 |
// Do the query |
2252 |
this->GetGLTABLES()->AddQ(); |
2253 |
result = dbc->Query(myquery.Data()); |
2254 |
if(! result->GetRowCount() ) { |
2255 |
cerr << "GL_TLE: query failed: " << myquery.Data() << endl; |
2256 |
return 1; |
2257 |
} |
2258 |
|
2259 |
// Get results |
2260 |
row = result->Next(); // first tle row |
2261 |
tle = GiveTle(row); |
2262 |
|
2263 |
tleFromTime = strtol(row->GetField(4), NULL, 10); |
2264 |
if (row) |
2265 |
delete row; |
2266 |
row = result->Next(); // second tle row |
2267 |
if(row) |
2268 |
tleToTime = strtol(row->GetField(4), NULL, 10); |
2269 |
else { |
2270 |
cerr << "GL_TLE: Warning: using last avaible TLE. Please update GL_TLE table!\n"; |
2271 |
tleToTime = UINT_MAX; |
2272 |
} |
2273 |
|
2274 |
if (row) |
2275 |
delete row; |
2276 |
delete result; |
2277 |
|
2278 |
return 0; |
2279 |
} |
2280 |
|
2281 |
|
2282 |
// |
2283 |
// Build a cTle object from the GL_TLE row. |
2284 |
// |
2285 |
cTle* GL_TLE::GiveTle(TSQLRow *row) { |
2286 |
cTle *thistle = NULL; |
2287 |
string tle1, tle2, tle3; |
2288 |
|
2289 |
// Build cTle object |
2290 |
tle1 = row->GetField(1); |
2291 |
tle2 = row->GetField(2); |
2292 |
tle3 = row->GetField(3); |
2293 |
|
2294 |
thistle = new cTle(tle1, tle2, tle3); |
2295 |
|
2296 |
return thistle; |
2297 |
} |