/[PAMELA software]/YodaProfiler/src/GLTables.cpp
ViewVC logotype

Contents of /YodaProfiler/src/GLTables.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.7 - (show annotations) (download)
Thu Sep 7 09:17:32 2006 UTC (18 years, 2 months ago) by mocchiut
Branch: MAIN
Changes since 1.6: +16 -5 lines
First release of the new YodaProfiler

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 //
10 #include <TFile.h>
11 #include <TTree.h>
12 #include <EventHeader.h>
13 #include <PscuHeader.h>
14 //
15 #include <GLTables.h>
16 //
17 ClassImp(GL_TRK_CALIB);
18 ClassImp(GL_RUN);
19 ClassImp(GL_ROOT);
20 ClassImp(GL_PARAM);
21 ClassImp(GL_S4_CALIB);
22 ClassImp(GL_CALO_CALIB);
23 ClassImp(GL_TIMESYNC);
24 //
25 using namespace std;
26
27 GL_RUN::GL_RUN() {
28 ID = 0;
29 ID_RUN_FRAG = 0;
30 ID_ROOT_L0 = 0;
31 ID_ROOT_L2 = 0;
32 RUNHEADER_TIME = 0;
33 RUNTRAILER_TIME = 0;
34 EV_FROM = 0;
35 EV_TO = 0;
36 TRK_CALIB_USED = 0;
37 EFF_WRK_SCHEDULE = 0;
38 PRH_VAR_TRG_MODE_A = 0;
39 PRH_VAR_TRG_MODE_B = 0;
40 ACQ_BUILD_INFO = 0;
41 ACQ_VAR_INFO = 0;
42 RUNHEADER_OBT = 0;
43 RUNTRAILER_OBT = 0;
44 RUNHEADER_PKT = 0;
45 RUNTRAILER_PKT = 0;
46 NEVENTS = 0;
47 LAST_TIMESYNC = 0;
48 OBT_TIMESYNC = 0;
49 COMPILATIONTIMESTAMP = 0;
50 FAV_WRK_SCHEDULE = 0;
51 RM_ACQ_AFTER_CALIB = 0;
52 RM_ACQ_SETTING_MODE = 0;
53 PKT_COUNTER = 0;
54 PKT_READY_COUNTER = 0;
55 TRK_CALIB_USED = 0;
56 CAL_DSP_MASK = 0;
57 BOOT_NUMBER = 0;
58 VALIDATION = 0;
59 }
60
61 void GL_RUN::Clear() {
62 ID = 0;
63 ID_RUN_FRAG = 0;
64 ID_ROOT_L0 = 0;
65 ID_ROOT_L2 = 0;
66 RUNHEADER_TIME = 0;
67 RUNTRAILER_TIME = 0;
68 EV_FROM = 0;
69 EV_TO = 0;
70 TRK_CALIB_USED = 0;
71 EFF_WRK_SCHEDULE = 0;
72 PRH_VAR_TRG_MODE_A = 0;
73 PRH_VAR_TRG_MODE_B = 0;
74 ACQ_BUILD_INFO = 0;
75 ACQ_VAR_INFO = 0;
76 RUNHEADER_OBT = 0;
77 RUNTRAILER_OBT = 0;
78 RUNHEADER_PKT = 0;
79 RUNTRAILER_PKT = 0;
80 NEVENTS = 0;
81 LAST_TIMESYNC = 0;
82 OBT_TIMESYNC = 0;
83 COMPILATIONTIMESTAMP = 0;
84 FAV_WRK_SCHEDULE = 0;
85 RM_ACQ_AFTER_CALIB = 0;
86 RM_ACQ_SETTING_MODE = 0;
87 PKT_COUNTER = 0;
88 PKT_READY_COUNTER = 0;
89 TRK_CALIB_USED = 0;
90 CAL_DSP_MASK = 0;
91 BOOT_NUMBER = 0;
92 VALIDATION = 0;
93 }
94
95 GL_ROOT::GL_ROOT(){
96 ID = 0;
97 ID_RAW = 0;
98 ID_TIMESYNC = 0;
99 PATH = "";
100 NAME = "";
101 }
102
103 GL_PARAM::GL_PARAM(){
104 ID = 0;
105 PATH = "";
106 NAME = "";
107 DESCR = "";
108 FROM_TIME = 0;
109 TO_TIME = 0;
110 TYPE = 0;
111 }
112
113
114 GL_TRK_CALIB::GL_TRK_CALIB(){
115 ID = 0;
116 ID_ROOT_L0 = 0;
117 EV_ROOT_CALIBTRK1 = 0;
118 EV_ROOT_CALIBTRK2 = 0;
119 FROM_TIME = 0;
120 TO_TIME = 0;
121 OBT1 = 0;
122 OBT2 = 0;
123 PKT1 = 0;
124 PKT2 = 0;
125 }
126
127 GL_CALO_CALIB::GL_CALO_CALIB(){
128 ID = 0;
129 ID_ROOT_L0 = 0;
130 EV_ROOT = 0;
131 FROM_TIME = 0;
132 TO_TIME = 0;
133 SECTION = 0;
134 }
135
136 GL_S4_CALIB::GL_S4_CALIB(){
137 ID = 0;
138 ID_ROOT_L0 = 0;
139 EV_ROOT = 0;
140 FROM_TIME = 0;
141 TO_TIME = 0;
142 PARAM_FIT0 = 0.;
143 PARAM_FIT1 = 0.;
144 }
145
146 GL_TIMESYNC::GL_TIMESYNC(){
147 obtfirst = 0;
148 pktfirst = 0;
149 toffset = 0;
150 ID = 0;
151 ID_RAW = 0;
152 OBT0 = 0;
153 TIMESYNC = 0;
154 TYPE = 0;
155 }// ****************************************************
156
157
158 void GL_RUN::SetEV_FROM(UInt_t evfrom){
159 EV_FROM = evfrom;
160 };
161
162 void GL_RUN::SetEV_TO(UInt_t evto){
163 EV_TO = evto;
164 };
165
166 void GL_RUN::SetNEVENTS(UInt_t nev){
167 NEVENTS = nev;
168 };
169
170 void GL_RUN::SetBOOTNUMBER(UInt_t boot){
171 BOOT_NUMBER = boot;
172 };
173
174 void GL_RUN::SetRUNHEADER_TIME(UInt_t absth){
175 RUNHEADER_TIME = absth;
176 };
177
178 void GL_RUN::SetRUNTRAILER_TIME(UInt_t abstt){
179 RUNTRAILER_TIME = abstt;
180 };
181
182 void GL_RUN::SetRUNHEADER_PKT(UInt_t absth){
183 RUNHEADER_PKT = absth;
184 };
185
186 void GL_RUN::SetRUNTRAILER_PKT(UInt_t abstt){
187 RUNTRAILER_PKT = abstt;
188 };
189
190 void GL_RUN::SetRUNHEADER_OBT(UInt_t absth){
191 RUNHEADER_OBT = absth;
192 };
193
194 void GL_RUN::SetRUNTRAILER_OBT(UInt_t abstt){
195 RUNTRAILER_OBT = abstt;
196 };
197
198 void GL_RUN::SetID_ROOT_L2(UInt_t idl2){
199 ID_ROOT_L2 = idl2;
200 };
201
202 void GL_RUN::SetID_ROOT_L0(UInt_t idroot){
203 ID_ROOT_L0 = idroot;
204 };
205
206 void GL_RUN::SetID_RUN_FRAG(UInt_t idfrag){
207 ID_RUN_FRAG = idfrag;
208 };
209
210 void GL_RUN::SetVALIDATION(UInt_t valid){
211 VALIDATION = valid;
212 };
213
214 void GL_RUN::SetLAST_TIMESYNC(UInt_t ts){
215 LAST_TIMESYNC = ts;
216 };
217
218 void GL_RUN::SetOBT_TIMESYNC(UInt_t ts){
219 OBT_TIMESYNC = ts;
220 };
221
222 void GL_RUN:: SetPKT_COUNTER(UInt_t value){
223 PKT_COUNTER = value;
224 };
225
226 void GL_RUN:: SetPKT_READY_COUNTER(UInt_t value){
227 PKT_READY_COUNTER = value;
228 };
229
230 void GL_RUN:: SetCOMPILATIONTIMESTAMP(UInt_t value){
231 COMPILATIONTIMESTAMP = value;
232 };
233
234 void GL_RUN:: SetFAV_WRK_SCHEDULE(UInt_t value){
235 FAV_WRK_SCHEDULE = value;
236 };
237
238 void GL_RUN:: SetEFF_WRK_SCHEDULE(UInt_t value){
239 EFF_WRK_SCHEDULE = value;
240 };
241
242 void GL_RUN:: SetPRH_VAR_TRG_MODE_A(UInt_t value){
243 PRH_VAR_TRG_MODE_A = value;
244 };
245
246 void GL_RUN:: SetPRH_VAR_TRG_MODE_B(UInt_t value){
247 PRH_VAR_TRG_MODE_B = value;
248 };
249
250 void GL_RUN:: SetACQ_BUILD_INFO(UInt_t value){
251 ACQ_BUILD_INFO = value;
252 };
253
254 void GL_RUN:: SetACQ_VAR_INFO(UInt_t value){
255 ACQ_VAR_INFO = value;
256 };
257
258 void GL_RUN:: SetRM_ACQ_AFTER_CALIB(UInt_t value){
259 RM_ACQ_AFTER_CALIB = value;
260 };
261
262 void GL_RUN:: SetRM_ACQ_SETTING_MODE(UInt_t value){
263 RM_ACQ_SETTING_MODE = value;
264 };
265
266 void GL_RUN:: SetTRK_CALIB_USED(UInt_t value){
267 TRK_CALIB_USED = value;
268 };
269
270 void GL_RUN:: SetCAL_DSP_MASK(UInt_t value){
271 CAL_DSP_MASK = value;
272 };
273
274 void GL_RUN:: SetID(UInt_t value){
275 ID = value;
276 };
277
278 void GL_RUN::Set_GL_RUNT(RunTrailerEvent *runt, PscuHeader *pht){
279 PKT_COUNTER = runt->PKT_COUNTER;
280 PKT_READY_COUNTER = runt->PKT_ReadyCounter;
281 RUNTRAILER_OBT = pht->GetOrbitalTime();
282 RUNTRAILER_PKT = pht->GetCounter();
283 };
284
285 void GL_RUN::Set_GL_RUNH(RunHeaderEvent *runh, PscuHeader *phh){
286 TRK_CALIB_USED = runh->TRK_CALIB_USED;
287 PRH_VAR_TRG_MODE_A = runh->PRH_VAR_TRIGGER_MODE_A;
288 PRH_VAR_TRG_MODE_B = runh->PRH_VAR_TRIGGER_MODE_B;
289 ACQ_BUILD_INFO = runh->ACQ_BUILD_INFO;
290 ACQ_VAR_INFO = runh->ACQ_VAR_INFO;
291 RUNHEADER_OBT = phh->GetOrbitalTime();
292 RUNHEADER_PKT = phh->GetCounter();
293 LAST_TIMESYNC = runh->LAST_TIME_SYNC_INFO;
294 OBT_TIMESYNC = runh->OBT_TIME_SYNC;
295 COMPILATIONTIMESTAMP = runh->COMPILATIONTIMESTAMP;
296 FAV_WRK_SCHEDULE = runh->FAVOURITE_WORKING_SCHEDULE;
297 EFF_WRK_SCHEDULE = runh->EFFECTIVE_WORKING_SCHEDULE;
298 RM_ACQ_AFTER_CALIB = runh->RM_ACQ_AFTER_CALIB;
299 RM_ACQ_SETTING_MODE = runh->RM_ACQ_SETTING_MODE;
300 TRK_CALIB_USED = runh->TRK_CALIB_USED;
301 CAL_DSP_MASK = runh->CAL_DSP_MASK;
302 };
303
304 void GL_RUN::Set_GL_RUNT0(){
305 PKT_COUNTER = 0;
306 PKT_READY_COUNTER = 0;
307 RUNTRAILER_OBT = 0;
308 RUNTRAILER_PKT = 0;
309 };
310
311 void GL_RUN::Set_GL_RUNH0(){
312 TRK_CALIB_USED = 0;
313 PRH_VAR_TRG_MODE_A = 0;
314 PRH_VAR_TRG_MODE_B = 0;
315 ACQ_BUILD_INFO = 0;
316 ACQ_VAR_INFO = 0;
317 RUNHEADER_OBT = 0;
318 RUNHEADER_PKT = 0;
319 LAST_TIMESYNC = 0;
320 OBT_TIMESYNC = 0;
321 COMPILATIONTIMESTAMP = 0;
322 FAV_WRK_SCHEDULE = 0;
323 EFF_WRK_SCHEDULE = 0;
324 RM_ACQ_AFTER_CALIB = 0;
325 RM_ACQ_SETTING_MODE = 0;
326 TRK_CALIB_USED = 0;
327 CAL_DSP_MASK = 0;
328 };
329
330
331 /**
332 * Function to fill the GL_RUN table of the DB.
333 *
334 * \param
335 *
336 */
337 Int_t GL_RUN::Fill_GL_RUN(TSQLServer *dbc){
338 // MySQL variables
339 stringstream myquery;
340 // ----------------
341 myquery.str("");
342 myquery << " INSERT INTO GL_RUN (";
343 myquery << "ID";
344 myquery << ",ID_RUN_FRAG";
345 myquery << ",ID_ROOT_L0";
346 myquery << ",ID_ROOT_L2";
347 myquery << ",RUNHEADER_TIME";
348 myquery << ",RUNTRAILER_TIME";
349 myquery << ",RUNHEADER_OBT";
350 myquery << ",RUNTRAILER_OBT";
351 myquery << ",RUNHEADER_PKT";
352 myquery << ",RUNTRAILER_PKT";
353 myquery << ",EV_FROM";
354 myquery << ",EV_TO";
355 myquery << ",NEVENTS";
356 myquery << ",LAST_TIMESYNC";
357 myquery << ",OBT_TIMESYNC";
358 myquery << ",COMPILATIONTIMESTAMP";
359 myquery << ",FAV_WRK_SCHEDULE";
360 myquery << ",EFF_WRK_SCHEDULE";
361 myquery << ",PRH_VAR_TRG_MODE_A";
362 myquery << ",PRH_VAR_TRG_MODE_B";
363 myquery << ",ACQ_BUILD_INFO";
364 myquery << ",ACQ_VAR_INFO";
365 myquery << ",RM_ACQ_AFTER_CALIB";
366 myquery << ",RM_ACQ_SETTING_MODE";
367 myquery << ",PKT_COUNTER";
368 myquery << ",PKT_READY_COUNTER";
369 myquery << ",TRK_CALIB_USED";
370 myquery << ",CAL_DSP_MASK";
371 myquery << ",BOOT_NUMBER";
372 myquery << ",VALIDATION";
373 myquery << ") VALUES ('";
374
375 myquery << (UInt_t)ID << "','";
376 myquery << (UInt_t)ID_RUN_FRAG << "','";
377 myquery << (UInt_t)ID_ROOT_L0 << "','";
378 myquery << (UInt_t)ID_ROOT_L2 << "','";
379 myquery << (UInt_t)RUNHEADER_TIME << "','";
380 myquery << (UInt_t)RUNTRAILER_TIME << "','";
381 myquery << (UInt_t)RUNHEADER_OBT << "','";
382 myquery << (UInt_t)RUNTRAILER_OBT << "','";
383 myquery << (UInt_t)RUNHEADER_PKT << "','";
384 myquery << (UInt_t)RUNTRAILER_PKT << "','";
385 myquery << (UInt_t)EV_FROM << "','";
386 myquery << (UInt_t)EV_TO << "','";
387 myquery << (UInt_t)NEVENTS << "','";
388 myquery << (UInt_t)LAST_TIMESYNC << "','";
389 myquery << (UInt_t)OBT_TIMESYNC << "','";
390 myquery << (UInt_t)COMPILATIONTIMESTAMP << "','";
391 myquery << (UInt_t)FAV_WRK_SCHEDULE << "','";
392 myquery << (UInt_t)EFF_WRK_SCHEDULE << "','";
393 myquery << (UInt_t)PRH_VAR_TRG_MODE_A << "','";
394 myquery << (UInt_t)PRH_VAR_TRG_MODE_B << "','";
395 myquery << (UInt_t)ACQ_BUILD_INFO << "','";
396 myquery << (UInt_t)ACQ_VAR_INFO << "','";
397 myquery << (UInt_t)RM_ACQ_AFTER_CALIB << "','";
398 myquery << (UInt_t)RM_ACQ_SETTING_MODE << "','";
399 myquery << (UInt_t)PKT_COUNTER << "','";
400 myquery << (UInt_t)PKT_READY_COUNTER << "','";
401 myquery << (UInt_t)TRK_CALIB_USED << "','";
402 myquery << (UInt_t)CAL_DSP_MASK << "','";
403 myquery << (UInt_t)BOOT_NUMBER << "','";
404 myquery << (UInt_t)VALIDATION << "');";
405 //
406 // printf("myquery is %s \n",myquery.str().c_str());
407 //
408 dbc->Query(myquery.str().c_str());
409 //
410 return 0;
411
412 };// ****************************************************
413
414 /**
415 * Function to fill the GL_RUN table of the DB.
416 *
417 * \param
418 *
419 */
420 Int_t GL_RUN::Fill_GL_RUN_FRAGMENTS(TSQLServer *dbc){
421 // MySQL variables
422 stringstream myquery;
423 // ----------------
424 myquery.str("");
425 myquery << " INSERT INTO GL_RUN_FRAGMENTS (";
426 myquery << "ID";
427 myquery << ",ID_ROOT_L0";
428 myquery << ",RUNHEADER_TIME";
429 myquery << ",RUNTRAILER_TIME";
430 myquery << ",RUNHEADER_OBT";
431 myquery << ",RUNTRAILER_OBT";
432 myquery << ",RUNHEADER_PKT";
433 myquery << ",RUNTRAILER_PKT";
434 myquery << ",EV_FROM";
435 myquery << ",EV_TO";
436 myquery << ",NEVENTS";
437 myquery << ",LAST_TIMESYNC";
438 myquery << ",OBT_TIMESYNC";
439 myquery << ",COMPILATIONTIMESTAMP";
440 myquery << ",FAV_WRK_SCHEDULE";
441 myquery << ",EFF_WRK_SCHEDULE";
442 myquery << ",PRH_VAR_TRG_MODE_A";
443 myquery << ",PRH_VAR_TRG_MODE_B";
444 myquery << ",ACQ_BUILD_INFO";
445 myquery << ",ACQ_VAR_INFO";
446 myquery << ",RM_ACQ_AFTER_CALIB";
447 myquery << ",RM_ACQ_SETTING_MODE";
448 myquery << ",PKT_COUNTER";
449 myquery << ",PKT_READY_COUNTER";
450 myquery << ",TRK_CALIB_USED";
451 myquery << ",CAL_DSP_MASK";
452 myquery << ",BOOT_NUMBER";
453 myquery << ") VALUES ('";
454 myquery << (UInt_t)ID << "','";
455 myquery << (UInt_t)ID_ROOT_L0 << "','";
456 myquery << (UInt_t)RUNHEADER_TIME << "','";
457 myquery << (UInt_t)RUNTRAILER_TIME << "','";
458 myquery << (UInt_t)RUNHEADER_OBT << "','";
459 myquery << (UInt_t)RUNTRAILER_OBT << "','";
460 myquery << (UInt_t)RUNHEADER_PKT << "','";
461 myquery << (UInt_t)RUNTRAILER_PKT << "','";
462 myquery << (UInt_t)EV_FROM << "','";
463 myquery << (UInt_t)EV_TO << "','";
464 myquery << (UInt_t)NEVENTS << "','";
465 myquery << (UInt_t)LAST_TIMESYNC << "','";
466 myquery << (UInt_t)OBT_TIMESYNC << "','";
467 myquery << (UInt_t)COMPILATIONTIMESTAMP << "','";
468 myquery << (UInt_t)FAV_WRK_SCHEDULE << "','";
469 myquery << (UInt_t)EFF_WRK_SCHEDULE << "','";
470 myquery << (UInt_t)PRH_VAR_TRG_MODE_A << "','";
471 myquery << (UInt_t)PRH_VAR_TRG_MODE_B << "','";
472 myquery << (UInt_t)ACQ_BUILD_INFO << "','";
473 myquery << (UInt_t)ACQ_VAR_INFO << "','";
474 myquery << (UInt_t)RM_ACQ_AFTER_CALIB << "','";
475 myquery << (UInt_t)RM_ACQ_SETTING_MODE << "','";
476 myquery << (UInt_t)PKT_COUNTER << "','";
477 myquery << (UInt_t)PKT_READY_COUNTER << "','";
478 myquery << (UInt_t)TRK_CALIB_USED << "','";
479 myquery << (UInt_t)CAL_DSP_MASK << "','";
480 myquery << (UInt_t)BOOT_NUMBER << "');";
481 //
482 // printf("myquery is %s \n",myquery.str().c_str());
483 //
484 dbc->Query(myquery.str().c_str());
485 //
486 return 0;
487
488 };// ****************************************************
489
490
491 /**
492 * Function to query the GL_RUN table of the DB.
493 *
494 * \param RUN id
495 * \return struct of type GL_RUN _data, which stores the query result
496 *
497 */
498 Int_t GL_RUN::Query_GL_RUN(UInt_t run, TSQLServer *dbc){
499 // MySQL variables
500 TSQLResult *pResult;
501 TSQLRow *Row;
502 int t;
503 int r;
504 stringstream myquery;
505 // ----------------
506 myquery.str("");
507 myquery << " select ";
508 myquery << "ID";
509 myquery << ",ID_RUN_FRAG";
510 myquery << ",ID_ROOT_L0";
511 myquery << ",ID_ROOT_L2";
512 myquery << ",RUNHEADER_TIME";
513 myquery << ",RUNTRAILER_TIME";
514 myquery << ",RUNHEADER_OBT";
515 myquery << ",RUNTRAILER_OBT";
516 myquery << ",RUNHEADER_PKT";
517 myquery << ",RUNTRAILER_PKT";
518 myquery << ",EV_FROM";
519 myquery << ",EV_TO";
520 myquery << ",NEVENTS";
521 myquery << ",LAST_TIMESYNC";
522 myquery << ",OBT_TIMESYNC";
523 myquery << ",COMPILATIONTIMESTAMP";
524 myquery << ",FAV_WRK_SCHEDULE";
525 myquery << ",EFF_WRK_SCHEDULE";
526 myquery << ",PRH_VAR_TRG_MODE_A";
527 myquery << ",PRH_VAR_TRG_MODE_B";
528 myquery << ",ACQ_BUILD_INFO";
529 myquery << ",ACQ_VAR_INFO";
530 myquery << ",RM_ACQ_AFTER_CALIB";
531 myquery << ",RM_ACQ_SETTING_MODE";
532 myquery << ",PKT_COUNTER";
533 myquery << ",PKT_READY_COUNTER";
534 myquery << ",TRK_CALIB_USED";
535 myquery << ",CAL_DSP_MASK";
536 myquery << ",BOOT_NUMBER";
537 myquery << ",VALIDATION";
538 myquery << " from GL_RUN where ID=" << run << ";";
539 //
540 // printf(" myquery is %s \n",myquery.str().c_str());
541 pResult = dbc->Query(myquery.str().c_str());
542 //
543 // printf(" getrowcount %i \n",pResult->GetRowCount());
544 //
545 if( !pResult->GetRowCount() ) return(-50);
546 //
547 for( r=0; r < 1000; r++){
548 Row = pResult->Next();
549 if( Row == NULL ) break;
550 for( t = 0; t < pResult->GetFieldCount(); t++){
551 if (t== 0) ID = (UInt_t)atoll(Row->GetField(t));
552 if (t== 1) ID_RUN_FRAG = (UInt_t)atoll(Row->GetField(t));
553 if (t== 2) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t));
554 if (t== 3) ID_ROOT_L2 = (UInt_t)atoll(Row->GetField(t));
555 if (t== 4) RUNHEADER_TIME = (UInt_t)atoll(Row->GetField(t));
556 if (t== 5) RUNTRAILER_TIME = (UInt_t)atoll(Row->GetField(t));
557 if (t== 6) RUNHEADER_OBT = (UInt_t)atoll(Row->GetField(t));
558 if (t== 7) RUNTRAILER_OBT = (UInt_t)atoll(Row->GetField(t));
559 if (t== 8) RUNHEADER_PKT = (UInt_t)atoll(Row->GetField(t));
560 if (t== 9) RUNTRAILER_PKT = (UInt_t)atoll(Row->GetField(t));
561 if (t==10) EV_FROM = (UInt_t)atoll(Row->GetField(t));
562 if (t==11) EV_TO = (UInt_t)atoll(Row->GetField(t));
563 if (t==12) NEVENTS = (UInt_t)atoll(Row->GetField(t));
564 if (t==13) LAST_TIMESYNC = (UInt_t)atoll(Row->GetField(t));
565 if (t==14) OBT_TIMESYNC = (UInt_t)atoll(Row->GetField(t));
566 if (t==15) COMPILATIONTIMESTAMP = (UInt_t)atoll(Row->GetField(t));
567 if (t==16) FAV_WRK_SCHEDULE = (UInt_t)atoll(Row->GetField(t));
568 if (t==17) EFF_WRK_SCHEDULE = (UInt_t)atoll(Row->GetField(t));
569 if (t==18) PRH_VAR_TRG_MODE_A= (UInt_t)atoll(Row->GetField(t));
570 if (t==19) PRH_VAR_TRG_MODE_B= (UInt_t)atoll(Row->GetField(t));
571 if (t==20) ACQ_BUILD_INFO = (UInt_t)atoll(Row->GetField(t));
572 if (t==21) ACQ_VAR_INFO = (UInt_t)atoll(Row->GetField(t));
573 if (t==22) RM_ACQ_AFTER_CALIB= (UInt_t)atoll(Row->GetField(t));
574 if (t==23) RM_ACQ_SETTING_MODE = (UInt_t)atoll(Row->GetField(t));
575 if (t==24) PKT_COUNTER = (UInt_t)atoll(Row->GetField(t));
576 if (t==25) PKT_READY_COUNTER = (UInt_t)atoll(Row->GetField(t));
577 if (t==26) TRK_CALIB_USED = (UInt_t)atoll(Row->GetField(t));
578 if (t==27) CAL_DSP_MASK = (UInt_t)atoll(Row->GetField(t));
579 if (t==28) BOOT_NUMBER = (UInt_t)atoll(Row->GetField(t));
580 if (t==29) VALIDATION = (UInt_t)atoll(Row->GetField(t));
581 };
582 };
583 // delete pResult;
584 return(0);
585 };
586
587 /**
588 * Function to query the GL_RUN table of the DB.
589 *
590 * \param where = condition string
591 * \return struct of type GL_RUN _data, which stores the query result
592 *
593 */
594 Int_t GL_RUN::Query_GL_RUN_FRAGMENTS(TString where, TSQLServer *dbc){
595 // MySQL variables
596 TSQLResult *pResult;
597 TSQLRow *Row;
598 int t;
599 int r;
600 stringstream myquery;
601 // ----------------
602 myquery.str("");
603 myquery << " select ";
604 myquery << "ID";
605 myquery << ",ID_RUN_FRAG";
606 myquery << ",ID_ROOT_L0";
607 myquery << ",ID_ROOT_L2";
608 myquery << ",RUNHEADER_TIME";
609 myquery << ",RUNTRAILER_TIME";
610 myquery << ",RUNHEADER_OBT";
611 myquery << ",RUNTRAILER_OBT";
612 myquery << ",RUNHEADER_PKT";
613 myquery << ",RUNTRAILER_PKT";
614 myquery << ",EV_FROM";
615 myquery << ",EV_TO";
616 myquery << ",NEVENTS";
617 myquery << ",LAST_TIMESYNC";
618 myquery << ",OBT_TIMESYNC";
619 myquery << ",COMPILATIONTIMESTAMP";
620 myquery << ",FAV_WRK_SCHEDULE";
621 myquery << ",EFF_WRK_SCHEDULE";
622 myquery << ",PRH_VAR_TRG_MODE_A";
623 myquery << ",PRH_VAR_TRG_MODE_B";
624 myquery << ",ACQ_BUILD_INFO";
625 myquery << ",ACQ_VAR_INFO";
626 myquery << ",RM_ACQ_AFTER_CALIB";
627 myquery << ",RM_ACQ_SETTING_MODE";
628 myquery << ",PKT_COUNTER";
629 myquery << ",PKT_READY_COUNTER";
630 myquery << ",TRK_CALIB_USED";
631 myquery << ",CAL_DSP_MASK";
632 myquery << ",BOOT_NUMBER";
633 myquery << ",VALIDATION";
634 myquery << " from GL_RUN_FRAGMENTS where " << where.Data() << ";";
635 //
636 // printf(" query is %s \n",myquery.str().c_str());
637 //
638 pResult = dbc->Query(myquery.str().c_str());
639 if(!pResult->GetRowCount())return(-50);
640 for( r=0; r < 1000; r++){
641 Row = pResult->Next();
642 if( Row == NULL ) break;
643 for( t = 0; t < pResult->GetFieldCount(); t++){
644 if (t== 0) ID = (UInt_t)atoll(Row->GetField(t));
645 if (t== 1) ID_RUN_FRAG = (UInt_t)atoll(Row->GetField(t));
646 if (t== 2) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t));
647 if (t== 3) ID_ROOT_L2 = (UInt_t)atoll(Row->GetField(t));
648 if (t== 4) RUNHEADER_TIME = (UInt_t)atoll(Row->GetField(t));
649 if (t== 5) RUNTRAILER_TIME = (UInt_t)atoll(Row->GetField(t));
650 if (t== 6) RUNHEADER_OBT = (UInt_t)atoll(Row->GetField(t));
651 if (t== 7) RUNTRAILER_OBT = (UInt_t)atoll(Row->GetField(t));
652 if (t== 8) RUNHEADER_PKT = (UInt_t)atoll(Row->GetField(t));
653 if (t== 9) RUNTRAILER_PKT = (UInt_t)atoll(Row->GetField(t));
654 if (t==10) EV_FROM = (UInt_t)atoll(Row->GetField(t));
655 if (t==11) EV_TO = (UInt_t)atoll(Row->GetField(t));
656 if (t==12) NEVENTS = (UInt_t)atoll(Row->GetField(t));
657 if (t==13) LAST_TIMESYNC = (UInt_t)atoll(Row->GetField(t));
658 if (t==14) OBT_TIMESYNC = (UInt_t)atoll(Row->GetField(t));
659 if (t==15) COMPILATIONTIMESTAMP = (UInt_t)atoll(Row->GetField(t));
660 if (t==16) FAV_WRK_SCHEDULE = (UInt_t)atoll(Row->GetField(t));
661 if (t==17) EFF_WRK_SCHEDULE = (UInt_t)atoll(Row->GetField(t));
662 if (t==18) PRH_VAR_TRG_MODE_A= (UInt_t)atoll(Row->GetField(t));
663 if (t==19) PRH_VAR_TRG_MODE_B= (UInt_t)atoll(Row->GetField(t));
664 if (t==20) ACQ_BUILD_INFO = (UInt_t)atoll(Row->GetField(t));
665 if (t==21) ACQ_VAR_INFO = (UInt_t)atoll(Row->GetField(t));
666 if (t==22) RM_ACQ_AFTER_CALIB= (UInt_t)atoll(Row->GetField(t));
667 if (t==23) RM_ACQ_SETTING_MODE = (UInt_t)atoll(Row->GetField(t));
668 if (t==24) PKT_COUNTER = (UInt_t)atoll(Row->GetField(t));
669 if (t==25) PKT_READY_COUNTER = (UInt_t)atoll(Row->GetField(t));
670 if (t==26) TRK_CALIB_USED = (UInt_t)atoll(Row->GetField(t));
671 if (t==27) CAL_DSP_MASK = (UInt_t)atoll(Row->GetField(t));
672 if (t==28) BOOT_NUMBER = (UInt_t)atoll(Row->GetField(t));
673 if (t==29) VALIDATION = (UInt_t)atoll(Row->GetField(t));
674 };
675 };
676 // delete pResult;
677 return(0);
678 };// ****************************************************
679
680 /**
681 * Function to query the GL_ROOT table of the DB.
682 *
683 * \param entry ID
684 * \return struct of type GL_ROOT_data, which stores the query result
685 */
686 Int_t GL_ROOT::Query_GL_ROOT(UInt_t id, TSQLServer *dbc){
687 // MySQL variables
688 TSQLResult *pResult;
689 TSQLRow *Row;
690 int t;
691 int r;
692 stringstream myquery;
693 // ----------------
694 myquery.str("");
695 myquery << "select ";
696 myquery << " ID";
697 myquery << ",ID_RAW";
698 myquery << ",ID_TIMESYNC";
699 myquery << ",PATH";
700 myquery << ",NAME";
701 myquery << " from GL_ROOT where ID=" << id << ";";
702 //
703 pResult = dbc->Query(myquery.str().c_str());
704 if(!pResult->GetRowCount())return (-51);
705 for( r=0; r < 1000; r++){
706 Row = pResult->Next();
707 if( Row == NULL ) break;
708 for( t = 0; t < pResult->GetFieldCount(); t++){
709 if(t==0) ID = (UInt_t)atoll(Row->GetField(t));
710 if(t==1) ID_RAW = (UInt_t)atoll(Row->GetField(t));
711 if(t==2) ID_TIMESYNC = (UInt_t)atoll(Row->GetField(t));
712 if(t==3) PATH = Row->GetField(t);
713 if(t==4) NAME = Row->GetField(t);
714 };
715 };
716 delete pResult;
717 return 0;
718 };
719 // ****************************************************
720 /**
721 * Function to query the GL_TRK_CALIB table of the DB.
722 *
723 * \param run starting time
724 * \return struct of type GL_TRK_CALIB_data, which stores the query result
725 */
726 Int_t GL_TRK_CALIB::Query_GL_TRK_CALIB(UInt_t time, TSQLServer *dbc){
727 // MySQL variables
728 TSQLResult *pResult;
729 TSQLRow *Row;
730 int t;
731 int r;
732 stringstream myquery;
733 // ----------------
734 myquery.str("");
735 myquery << "select ID,ID_ROOT_L0,EV_ROOT_CALIBTRK1,EV_ROOT_CALIBTRK2,FROM_TIME,TO_TIME,OBT1,OBT2,PKT1,PKT2 from GL_TRK_CALIB where FROM_TIME <= "<< time;
736 myquery << " AND VALIDATION=1 ORDER BY FROM_TIME DESC LIMIT 1;";
737 // myquery << " ORDER BY FROM_TIME DESC LIMIT 1;";
738 pResult = dbc->Query(myquery.str().c_str());
739 if(!pResult->GetRowCount())return (-53);
740 for( r=0; r < 1000; r++){
741 Row = pResult->Next();
742 if( Row == NULL ) break;
743 for( t = 0; t < pResult->GetFieldCount(); t++){
744 stringstream row;
745 row.str("");
746 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
747 if (t==0) ID = (UInt_t)atoll(Row->GetField(t));
748 if (t==1) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t));
749 if (t==2) EV_ROOT_CALIBTRK1 = (UInt_t)atoll(row.str().c_str());
750 if (t==3) EV_ROOT_CALIBTRK2 = (UInt_t)atoll(row.str().c_str());
751 if (t==4) FROM_TIME = (UInt_t)atoll(Row->GetField(t));
752 if (t==5) TO_TIME = (UInt_t)atoll(Row->GetField(t));
753 //
754 if (t==6) OBT1 = (UInt_t)atoll(Row->GetField(t));
755 if (t==7) OBT2 = (UInt_t)atoll(Row->GetField(t));
756 if (t==8) PKT1 = (UInt_t)atoll(Row->GetField(t));
757 if (t==9) PKT2 = (UInt_t)atoll(Row->GetField(t));
758 };
759 };
760 delete pResult;
761 //
762 if(TO_TIME < time)return(51);
763 if ( (!OBT1 && !PKT1 ) || (!OBT2 && !PKT2) ) return(52); // ONE CALIBRATION PACKET IS MISSING!
764 //
765 return 0;
766 };
767
768 // ****************************************************
769 /**
770 * Function to query the GL_CALO_CALIB table of the DB.
771 *
772 * \param run starting time
773 * \return struct of type GL_CALO_CALIB_data, which stores the query result
774 */
775 Int_t GL_CALO_CALIB::Query_GL_CALO_CALIB(UInt_t time, UInt_t &uptime, UInt_t section, TSQLServer *dbc){
776 // MySQL variables
777 TSQLResult *pResult;
778 TSQLRow *Row;
779 int t;
780 stringstream myquery;
781 uptime = 0;
782 //
783 // select the correct calibration
784 //
785 myquery.str("");
786 myquery << "select ID_ROOT_L0, FROM_TIME, TO_TIME, EV_ROOT,VALIDATION from GL_CALO_CALIB where SECTION=" << section;
787 myquery << " and FROM_TIME <= " << time;
788 myquery << " and TO_TIME > " << time;
789 myquery << " ;";
790 //myquery << " and VALIDATION=1;";
791 //
792 pResult = dbc->Query(myquery.str().c_str());
793 // printf(" mysquery is %s\n",myquery.str().c_str());
794 //
795 if( !pResult->GetRowCount() ) return(-54);
796 Row = pResult->Next();
797 if( Row == NULL ) return (-54);
798 //
799 uptime = (UInt_t)atoll(Row->GetField(2));
800 //
801 // if it is corrupted validation is 0 and we have no results from the query...
802 //
803 if( atoi(Row->GetField(4)) == 0 ){ // if validation = 0
804 //
805 // in this case take relax the conditions and take the valid calibration that preceed the correct one
806 //
807 myquery.str("");
808 myquery << "select ID_ROOT_L0, FROM_TIME, TO_TIME, EV_ROOT,VALIDATION from GL_CALO_CALIB where SECTION=" << section;
809 myquery << " and FROM_TIME <= " << time;
810 myquery << " and VALIDATION=1 ORDER BY FROM_TIME DESC LIMIT 1;";
811 pResult = dbc->Query(myquery.str().c_str());
812 // printf(" mysquery is %s\n",myquery.str().c_str());
813 //
814 // if no results yet quit with error
815 //
816 if( !pResult->GetRowCount() ) return (-54);
817 //
818 Row = pResult->Next();
819 //
820 };
821 //
822 // store infos and exit
823 //
824 if( Row == NULL ) return (-54);
825 for( t = 0; t < pResult->GetFieldCount(); t++){
826 if (t==0) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t));
827 if (t==1) FROM_TIME = (UInt_t)atoll(Row->GetField(t));
828 if (t==2) TO_TIME = (UInt_t)atoll(Row->GetField(t));
829 if (t==3) EV_ROOT = (UInt_t)atoll(Row->GetField(t));
830 };
831 pResult->Delete();
832 return 0;
833 };
834 // ****************************************************
835 /**
836 * Function to query the GL_S4_CALIB table of the DB.
837 *
838 * \param run starting time
839 * \return struct of type GL_S4_CALIB_data, which stores the query result
840 */
841 Int_t GL_S4_CALIB::Query_GL_S4_CALIB(UInt_t time, TSQLServer *dbc){
842 // MySQL variables
843 TSQLResult *pResult;
844 TSQLRow *Row;
845 int t;
846 int r;
847 stringstream myquery;
848 // ----------------
849 myquery.str("");
850 myquery << "select * from GL_S4_CALIB where FROM_TIME <= "<< time;
851 myquery << " ORDER BY FROM_TIME DESC LIMIT 1;";
852 // myquery << " ORDER BY FROM_TIME DESC LIMIT 1;";
853 pResult = dbc->Query(myquery.str().c_str());
854 if(!pResult->GetRowCount())return (-55);//throw -55;
855 for( r=0; r < 1000; r++){
856 Row = pResult->Next();
857 if( Row == NULL ) break;
858 for( t = 0; t < pResult->GetFieldCount(); t++){
859 if (t==0) ID = (UInt_t)atoll(Row->GetField(t));
860 if (t==1) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t));
861 if (t==2) EV_ROOT = (UInt_t)atoll(Row->GetField(t));
862 if (t==3) FROM_TIME = (UInt_t)atoll(Row->GetField(t));
863 if (t==4) TO_TIME = (UInt_t)atoll(Row->GetField(t));
864 if (t==5) PARAM_FIT0 = atof(Row->GetField(t));
865 if (t==6) PARAM_FIT1 = atof(Row->GetField(t));
866 };
867 };
868 delete pResult;
869 //
870 if(TO_TIME < time)return(51);
871 //
872 return 0;
873 };
874 // ****************************************************
875 /**
876 * Function to query the GL_PARAM table of the DB.
877 *
878 * \param run starting time
879 * \param parameter description (DESCR)
880 * \return struct of type GL_ROOT_data, which stores the query result
881 */
882 Int_t GL_PARAM::Query_GL_PARAM(UInt_t time, UInt_t type, TSQLServer *dbc){
883 // Bool_t debug = 1;
884 // MySQL variables
885 TSQLResult *pResult;
886 TSQLRow *Row;
887 int t;
888 int r;
889 stringstream myquery;
890 // ----------------
891 myquery.str("");
892 myquery << " select ";
893 myquery << " ID, PATH, NAME, DESCR, TYPE, FROM_TIME,TO_TIME ";
894 myquery << " from GL_PARAM ";
895 myquery << " where TYPE = '"<<type<<"' ";
896 myquery << " and FROM_TIME <= " << time;
897 myquery << " ORDER BY TO_TIME DESC LIMIT 1;";
898 //
899 pResult = dbc->Query(myquery.str().c_str());
900 if(!pResult->GetRowCount())return (-52);
901 for( r=0; r < 1000; r++){
902 Row = pResult->Next();
903 if( Row == NULL ) break;
904 for( t = 0; t < pResult->GetFieldCount(); t++){
905 if (t==0) ID = (UInt_t)atoll(Row->GetField(t));
906 if (t==1) PATH = Row->GetField(t);// put in fpath the path to that file
907 if (t==2) NAME = Row->GetField(t);
908 if (t==3) DESCR = Row->GetField(t);
909 if (t==4) FROM_TIME = (UInt_t)atoll(Row->GetField(t));
910 if (t==5) TO_TIME = (UInt_t)atoll(Row->GetField(t));
911 if (t==6) TYPE = (UInt_t)atoll(Row->GetField(t));
912 };
913 };
914 delete pResult;
915 //
916 if(TO_TIME==0) TO_TIME = numeric_limits<UInt_t>::max();
917 //
918 if(TO_TIME < time) return(51);
919 //
920 return 0;
921 };
922
923
924 /**
925 * Fills a struct cGLRun with values from a GLRun object (to put data into a F77 common).
926 */
927
928 void GL_RUN::GetLevel2Struct(cGLRun *l2) const{
929 l2->id = ID;
930 l2->id_reg_run = ID_ROOT_L0;
931 l2->id_reg_run_l2 = ID_ROOT_L2;
932 l2->runheader_time = RUNHEADER_TIME;
933 l2->runtrailer_time = RUNTRAILER_TIME;
934 l2->ev_from = EV_FROM;
935 l2->trk_calib_used = TRK_CALIB_USED;
936 l2->eff_wrk_schedule = EFF_WRK_SCHEDULE;
937 l2->prh_var_trg_mode_a = PRH_VAR_TRG_MODE_A;
938 l2->prh_var_trg_mode_b = PRH_VAR_TRG_MODE_B;
939 l2->acq_build_info = ACQ_BUILD_INFO;
940 l2->acq_var_info = ACQ_VAR_INFO;
941 };
942
943 GL_TIMESYNC::GL_TIMESYNC(UInt_t id, TString type, TSQLServer *dbc){
944 // MySQL variables
945 TFile *file = 0;
946 UInt_t idraw = 0;
947 //
948 TSQLResult *pResult;
949 TSQLRow *Row;
950 stringstream myquery;
951 // ----------------
952 myquery.str("");
953 myquery << "select ";
954 myquery << "PATH";
955 myquery << ",NAME,ID_RAW";
956 myquery << " from GL_ROOT where ";
957 myquery << type.Data();
958 myquery << "=" << id << ";";
959 //
960 pResult = dbc->Query(myquery.str().c_str());
961 if( pResult->GetRowCount() ){
962 Row = pResult->Next();
963 if( Row ){
964 stringstream fname;
965 fname.str("");
966 fname << Row->GetField(0) << "/" << Row->GetField(1);
967 file = new TFile(fname.str().c_str(),"READ");
968 idraw = (UInt_t)atoll(Row->GetField(2));
969 };
970 };
971 //
972 if ( file && file->IsOpen() ){
973 TTree *T=(TTree*)file->Get("Physics");
974 pamela::EventHeader *eh = 0;
975 pamela::PscuHeader *ph = 0;
976 T->SetBranchAddress("Header", &eh);
977 //
978 T->GetEntry(0);
979 ph = eh->GetPscuHeader();
980 pktfirst = ph->GetCounter();
981 obtfirst = ph->GetOrbitalTime();
982 };
983 //
984 // look for Resurs offset
985 //
986 UInt_t t0 = 0;
987 //
988 myquery.str("");
989 myquery << "SELECT OFFSET_DATE FROM GL_RESURS_OFFSET WHERE FROM_ID_RAW<= "
990 << idraw << " AND TO_ID_RAW >= "
991 << idraw << ";";
992 pResult = dbc->Query(myquery.str().c_str());
993 if ( pResult ){
994 Row = pResult->Next();
995 if ( Row ){
996 //
997 t0 = (UInt_t)TDatime(Row->GetField(0)).Convert();
998 //
999 };
1000 };
1001 //
1002 //
1003 // look for the correct timesync entry
1004 //
1005 myquery.str("");
1006 myquery << " SELECT OBT0,TIMESYNC FROM GL_TIMESYNC "
1007 << " WHERE ID_RAW = " << idraw
1008 << ";";
1009 pResult = dbc->Query(myquery.str().c_str());
1010 if ( pResult ){
1011 Row = pResult->Next();
1012 if ( (Row != NULL) && ((UInt_t)atoll(Row->GetField(0)) > 0 ) ){
1013 toffset = (UInt_t)atoll(Row->GetField(1)) - (UInt_t)(this->DBobt((UInt_t)atoll(Row->GetField(0)))/1000) + t0;
1014 };
1015 };
1016 //
1017 file->Close();
1018 delete pResult;
1019 };
1020
1021 /**
1022 *
1023 * Returns the DB absolute time needed to associate calibrations to data
1024 *
1025 */
1026 UInt_t GL_TIMESYNC::DBabsTime(UInt_t OBT){
1027 //
1028 return(((UInt_t)(this->DBobt(OBT)/1000)+toffset));
1029 //
1030 };
1031
1032
1033 ULong64_t GL_TIMESYNC::DBobt(UInt_t obt){
1034 //
1035 if ( obt < (obtfirst/2) && obtfirst > (numeric_limits<UInt_t>::max()/2) ) return((ULong64_t)(obt+numeric_limits<UInt_t>::max()));
1036 //
1037 if ( obt > (obtfirst*2) && obt > (numeric_limits<UInt_t>::max()/2) ){
1038 if ( (obt-numeric_limits<UInt_t>::max()) < 0 ){
1039 return((ULong64_t)(numeric_limits<UInt_t>::max()-obt));
1040 } else {
1041 return((ULong64_t)(obt-numeric_limits<UInt_t>::max()));
1042 };
1043 };
1044 //
1045 return((ULong64_t)obt);
1046 //
1047 };
1048
1049 UInt_t GL_TIMESYNC::DBpkt(UInt_t pkt_num){
1050 //
1051 if ( pkt_num < (pktfirst/2) && pktfirst > (16777214/2) ) return((pkt_num+16777215));
1052 //
1053 if ( pkt_num > pktfirst*2 && pkt_num > (16777214/2) ){
1054 if ( (pkt_num-16777215) < 0 ){
1055 return((16777215-pkt_num));
1056 } else {
1057 return((pkt_num-16777215));
1058 };
1059 };
1060 //
1061 return(pkt_num);
1062 //
1063 };
1064
1065 /*
1066 *
1067 * Convert the time in the DB from UInt_t to a string
1068 *
1069 * @param dbt time in the DB
1070 * @param tzone Time Zone, can be UTC,GMT,CET,CEST,MSD default is MSK
1071 *
1072 */
1073 TString GL_TIMESYNC::ConvertTime(TString tzone, UInt_t dbt){
1074 //
1075 TDatime *time = new TDatime();
1076 TString rtime;
1077 //
1078 time->Set(dbt,false); // MSK = Moscow Winter Time
1079 //
1080 if ( !strcmp(tzone.Data(),"UTC") || !strcmp(tzone.Data(),"GMT") ){
1081 //
1082 UInt_t timeUTC = time->Convert() - 60*60*3; // UTC (Coordinated Universal Time) = Moscow Winter Time - 3 hs
1083 time->Set(timeUTC,false);
1084 //
1085 };
1086 //
1087 if ( !strcmp(tzone.Data(),"CET") ){
1088 //
1089 UInt_t timeCET = time->Convert() - 60*60*2; // CET (Central European Time) = Moscow Winter Time - 2 hs
1090 time->Set(timeCET,false);
1091 //
1092 };
1093 //
1094 if ( !strcmp(tzone.Data(),"CEST") ){
1095 //
1096 UInt_t timeCEST = time->Convert() - 60*60*1; // CEST (Central European Summer Time) = Moscow Winter Time - 1 h
1097 time->Set(timeCEST,false);
1098 //
1099 };
1100 //
1101 if ( !strcmp(tzone.Data(),"MSD") ){
1102 //
1103 UInt_t timeMSD = time->Convert() + 60*60*1; // MSD (Moscow Summer Time) = Moscow Winter Time + 1 h
1104 time->Set(timeMSD,false);
1105 //
1106 };
1107 //
1108 rtime = time->AsSQLString();
1109 //
1110 return(rtime);
1111 }
1112
1113 /*
1114 *
1115 * Convert the time in the DB from UInt_t to a string
1116 *
1117 * @param dbt time in the DB
1118 * @param tzone Time Zone, can be UTC,GMT,CET,CEST,MSD default is MSK
1119 *
1120 */
1121 TString GL_TIMESYNC::UnConvertTime(TString tzone, UInt_t dbt){
1122 //
1123 TDatime *time = new TDatime();
1124 TString rtime;
1125 //
1126 time->Set(dbt,false); // MSK = Moscow Winter Time
1127 //
1128 if ( !strcmp(tzone.Data(),"UTC") || !strcmp(tzone.Data(),"GMT") ){
1129 //
1130 UInt_t timeUTC = time->Convert() + 60*60*3; // UTC (Coordinated Universal Time) +3 hs = Moscow Winter Time
1131 time->Set(timeUTC,false);
1132 //
1133 };
1134 //
1135 if ( !strcmp(tzone.Data(),"CET") ){
1136 //
1137 UInt_t timeCET = time->Convert() + 60*60*2; // CET (Central European Time) + 2 hs = Moscow Winter Time
1138 time->Set(timeCET,false);
1139 //
1140 };
1141 //
1142 if ( !strcmp(tzone.Data(),"CEST") ){
1143 //
1144 UInt_t timeCEST = time->Convert() + 60*60*1; // CEST (Central European Summer Time) + 1 h = Moscow Winter Time
1145 time->Set(timeCEST,false);
1146 //
1147 };
1148 //
1149 if ( !strcmp(tzone.Data(),"MSD") ){
1150 //
1151 UInt_t timeMSD = time->Convert() - 60*60*1; // MSD (Moscow Summer Time) - 1 h = Moscow Winter Time
1152 time->Set(timeMSD,false);
1153 //
1154 };
1155 //
1156 rtime = time->AsSQLString();
1157 //
1158 return(rtime);
1159 }

  ViewVC Help
Powered by ViewVC 1.1.23