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

Annotation of /YodaProfiler/src/GLTables.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.8 - (hide annotations) (download)
Fri Sep 8 08:48:04 2006 UTC (18 years, 2 months ago) by mocchiut
Branch: MAIN
Changes since 1.7: +2 -1 lines
small bug fixed

1 mocchiut 1.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 mocchiut 1.2 // printf("myquery is %s \n",myquery.str().c_str());
407 mocchiut 1.1 //
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 mocchiut 1.4 // printf(" myquery is %s \n",myquery.str().c_str());
541 mocchiut 1.1 pResult = dbc->Query(myquery.str().c_str());
542 mocchiut 1.4 //
543     // printf(" getrowcount %i \n",pResult->GetRowCount());
544     //
545     if( !pResult->GetRowCount() ) return(-50);
546     //
547 mocchiut 1.1 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 mocchiut 1.4 // delete pResult;
584     return(0);
585 mocchiut 1.1 };
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 mocchiut 1.2 myquery << ",ID_RUN_FRAG";
606 mocchiut 1.1 myquery << ",ID_ROOT_L0";
607 mocchiut 1.2 myquery << ",ID_ROOT_L2";
608 mocchiut 1.1 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 mocchiut 1.2 myquery << ",VALIDATION";
634 mocchiut 1.1 myquery << " from GL_RUN_FRAGMENTS where " << where.Data() << ";";
635     //
636 mocchiut 1.2 // printf(" query is %s \n",myquery.str().c_str());
637     //
638 mocchiut 1.1 pResult = dbc->Query(myquery.str().c_str());
639     if(!pResult->GetRowCount())return(-50);
640     for( r=0; r < 1000; r++){
641 mocchiut 1.2 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 mocchiut 1.1 };
676 mocchiut 1.2 // delete pResult;
677     return(0);
678     };// ****************************************************
679 mocchiut 1.1
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 mocchiut 1.2 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 mocchiut 1.1 if (t==0) ID = (UInt_t)atoll(Row->GetField(t));
748     if (t==1) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t));
749 mocchiut 1.2 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 mocchiut 1.1 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 mocchiut 1.8 if ( TO_TIME < time ) return(51);
763     //
764 mocchiut 1.1 if ( (!OBT1 && !PKT1 ) || (!OBT2 && !PKT2) ) return(52); // ONE CALIBRATION PACKET IS MISSING!
765     //
766     return 0;
767     };
768    
769     // ****************************************************
770     /**
771     * Function to query the GL_CALO_CALIB table of the DB.
772     *
773     * \param run starting time
774     * \return struct of type GL_CALO_CALIB_data, which stores the query result
775     */
776 mocchiut 1.7 Int_t GL_CALO_CALIB::Query_GL_CALO_CALIB(UInt_t time, UInt_t &uptime, UInt_t section, TSQLServer *dbc){
777 mocchiut 1.1 // MySQL variables
778     TSQLResult *pResult;
779     TSQLRow *Row;
780     int t;
781     stringstream myquery;
782 mocchiut 1.7 uptime = 0;
783 mocchiut 1.1 //
784     // select the correct calibration
785     //
786     myquery.str("");
787     myquery << "select ID_ROOT_L0, FROM_TIME, TO_TIME, EV_ROOT,VALIDATION from GL_CALO_CALIB where SECTION=" << section;
788     myquery << " and FROM_TIME <= " << time;
789     myquery << " and TO_TIME > " << time;
790 mocchiut 1.7 myquery << " ;";
791     //myquery << " and VALIDATION=1;";
792 mocchiut 1.1 //
793     pResult = dbc->Query(myquery.str().c_str());
794 mocchiut 1.7 // printf(" mysquery is %s\n",myquery.str().c_str());
795     //
796     if( !pResult->GetRowCount() ) return(-54);
797     Row = pResult->Next();
798     if( Row == NULL ) return (-54);
799     //
800     uptime = (UInt_t)atoll(Row->GetField(2));
801 mocchiut 1.1 //
802     // if it is corrupted validation is 0 and we have no results from the query...
803     //
804 mocchiut 1.7 if( atoi(Row->GetField(4)) == 0 ){ // if validation = 0
805 mocchiut 1.1 //
806     // in this case take relax the conditions and take the valid calibration that preceed the correct one
807     //
808     myquery.str("");
809     myquery << "select ID_ROOT_L0, FROM_TIME, TO_TIME, EV_ROOT,VALIDATION from GL_CALO_CALIB where SECTION=" << section;
810     myquery << " and FROM_TIME <= " << time;
811     myquery << " and VALIDATION=1 ORDER BY FROM_TIME DESC LIMIT 1;";
812     pResult = dbc->Query(myquery.str().c_str());
813 mocchiut 1.7 // printf(" mysquery is %s\n",myquery.str().c_str());
814 mocchiut 1.1 //
815     // if no results yet quit with error
816     //
817     if( !pResult->GetRowCount() ) return (-54);
818 mocchiut 1.7 //
819     Row = pResult->Next();
820     //
821 mocchiut 1.1 };
822     //
823     // store infos and exit
824     //
825     if( Row == NULL ) return (-54);
826     for( t = 0; t < pResult->GetFieldCount(); t++){
827     if (t==0) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t));
828     if (t==1) FROM_TIME = (UInt_t)atoll(Row->GetField(t));
829     if (t==2) TO_TIME = (UInt_t)atoll(Row->GetField(t));
830     if (t==3) EV_ROOT = (UInt_t)atoll(Row->GetField(t));
831     };
832     pResult->Delete();
833     return 0;
834     };
835     // ****************************************************
836     /**
837     * Function to query the GL_S4_CALIB table of the DB.
838     *
839     * \param run starting time
840     * \return struct of type GL_S4_CALIB_data, which stores the query result
841     */
842     Int_t GL_S4_CALIB::Query_GL_S4_CALIB(UInt_t time, TSQLServer *dbc){
843     // MySQL variables
844     TSQLResult *pResult;
845     TSQLRow *Row;
846     int t;
847     int r;
848     stringstream myquery;
849     // ----------------
850     myquery.str("");
851     myquery << "select * from GL_S4_CALIB where FROM_TIME <= "<< time;
852 mocchiut 1.5 myquery << " ORDER BY FROM_TIME DESC LIMIT 1;";
853 mocchiut 1.1 // myquery << " ORDER BY FROM_TIME DESC LIMIT 1;";
854     pResult = dbc->Query(myquery.str().c_str());
855     if(!pResult->GetRowCount())return (-55);//throw -55;
856     for( r=0; r < 1000; r++){
857     Row = pResult->Next();
858     if( Row == NULL ) break;
859     for( t = 0; t < pResult->GetFieldCount(); t++){
860     if (t==0) ID = (UInt_t)atoll(Row->GetField(t));
861     if (t==1) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t));
862     if (t==2) EV_ROOT = (UInt_t)atoll(Row->GetField(t));
863     if (t==3) FROM_TIME = (UInt_t)atoll(Row->GetField(t));
864     if (t==4) TO_TIME = (UInt_t)atoll(Row->GetField(t));
865     if (t==5) PARAM_FIT0 = atof(Row->GetField(t));
866     if (t==6) PARAM_FIT1 = atof(Row->GetField(t));
867     };
868     };
869     delete pResult;
870     //
871     if(TO_TIME < time)return(51);
872     //
873     return 0;
874     };
875     // ****************************************************
876     /**
877     * Function to query the GL_PARAM table of the DB.
878     *
879     * \param run starting time
880     * \param parameter description (DESCR)
881     * \return struct of type GL_ROOT_data, which stores the query result
882     */
883     Int_t GL_PARAM::Query_GL_PARAM(UInt_t time, UInt_t type, TSQLServer *dbc){
884     // Bool_t debug = 1;
885     // MySQL variables
886     TSQLResult *pResult;
887     TSQLRow *Row;
888     int t;
889     int r;
890     stringstream myquery;
891     // ----------------
892     myquery.str("");
893     myquery << " select ";
894     myquery << " ID, PATH, NAME, DESCR, TYPE, FROM_TIME,TO_TIME ";
895     myquery << " from GL_PARAM ";
896     myquery << " where TYPE = '"<<type<<"' ";
897     myquery << " and FROM_TIME <= " << time;
898     myquery << " ORDER BY TO_TIME DESC LIMIT 1;";
899     //
900     pResult = dbc->Query(myquery.str().c_str());
901     if(!pResult->GetRowCount())return (-52);
902     for( r=0; r < 1000; r++){
903     Row = pResult->Next();
904     if( Row == NULL ) break;
905     for( t = 0; t < pResult->GetFieldCount(); t++){
906     if (t==0) ID = (UInt_t)atoll(Row->GetField(t));
907     if (t==1) PATH = Row->GetField(t);// put in fpath the path to that file
908     if (t==2) NAME = Row->GetField(t);
909     if (t==3) DESCR = Row->GetField(t);
910     if (t==4) FROM_TIME = (UInt_t)atoll(Row->GetField(t));
911     if (t==5) TO_TIME = (UInt_t)atoll(Row->GetField(t));
912     if (t==6) TYPE = (UInt_t)atoll(Row->GetField(t));
913     };
914     };
915     delete pResult;
916     //
917     if(TO_TIME==0) TO_TIME = numeric_limits<UInt_t>::max();
918     //
919     if(TO_TIME < time) return(51);
920     //
921     return 0;
922     };
923    
924    
925     /**
926     * Fills a struct cGLRun with values from a GLRun object (to put data into a F77 common).
927     */
928    
929     void GL_RUN::GetLevel2Struct(cGLRun *l2) const{
930     l2->id = ID;
931     l2->id_reg_run = ID_ROOT_L0;
932     l2->id_reg_run_l2 = ID_ROOT_L2;
933     l2->runheader_time = RUNHEADER_TIME;
934     l2->runtrailer_time = RUNTRAILER_TIME;
935     l2->ev_from = EV_FROM;
936     l2->trk_calib_used = TRK_CALIB_USED;
937     l2->eff_wrk_schedule = EFF_WRK_SCHEDULE;
938     l2->prh_var_trg_mode_a = PRH_VAR_TRG_MODE_A;
939     l2->prh_var_trg_mode_b = PRH_VAR_TRG_MODE_B;
940     l2->acq_build_info = ACQ_BUILD_INFO;
941     l2->acq_var_info = ACQ_VAR_INFO;
942     };
943    
944     GL_TIMESYNC::GL_TIMESYNC(UInt_t id, TString type, TSQLServer *dbc){
945     // MySQL variables
946     TFile *file = 0;
947     UInt_t idraw = 0;
948     //
949     TSQLResult *pResult;
950     TSQLRow *Row;
951     stringstream myquery;
952     // ----------------
953     myquery.str("");
954     myquery << "select ";
955     myquery << "PATH";
956     myquery << ",NAME,ID_RAW";
957     myquery << " from GL_ROOT where ";
958     myquery << type.Data();
959     myquery << "=" << id << ";";
960     //
961     pResult = dbc->Query(myquery.str().c_str());
962     if( pResult->GetRowCount() ){
963     Row = pResult->Next();
964     if( Row ){
965     stringstream fname;
966     fname.str("");
967     fname << Row->GetField(0) << "/" << Row->GetField(1);
968     file = new TFile(fname.str().c_str(),"READ");
969     idraw = (UInt_t)atoll(Row->GetField(2));
970     };
971     };
972     //
973     if ( file && file->IsOpen() ){
974     TTree *T=(TTree*)file->Get("Physics");
975     pamela::EventHeader *eh = 0;
976     pamela::PscuHeader *ph = 0;
977     T->SetBranchAddress("Header", &eh);
978     //
979     T->GetEntry(0);
980     ph = eh->GetPscuHeader();
981     pktfirst = ph->GetCounter();
982     obtfirst = ph->GetOrbitalTime();
983     };
984     //
985     // look for Resurs offset
986     //
987     UInt_t t0 = 0;
988     //
989     myquery.str("");
990     myquery << "SELECT OFFSET_DATE FROM GL_RESURS_OFFSET WHERE FROM_ID_RAW<= "
991     << idraw << " AND TO_ID_RAW >= "
992     << idraw << ";";
993     pResult = dbc->Query(myquery.str().c_str());
994     if ( pResult ){
995     Row = pResult->Next();
996     if ( Row ){
997     //
998     t0 = (UInt_t)TDatime(Row->GetField(0)).Convert();
999     //
1000     };
1001     };
1002     //
1003     //
1004     // look for the correct timesync entry
1005     //
1006     myquery.str("");
1007     myquery << " SELECT OBT0,TIMESYNC FROM GL_TIMESYNC "
1008     << " WHERE ID_RAW = " << idraw
1009     << ";";
1010     pResult = dbc->Query(myquery.str().c_str());
1011     if ( pResult ){
1012     Row = pResult->Next();
1013     if ( (Row != NULL) && ((UInt_t)atoll(Row->GetField(0)) > 0 ) ){
1014     toffset = (UInt_t)atoll(Row->GetField(1)) - (UInt_t)(this->DBobt((UInt_t)atoll(Row->GetField(0)))/1000) + t0;
1015     };
1016     };
1017 mocchiut 1.3 //
1018     file->Close();
1019 mocchiut 1.1 delete pResult;
1020     };
1021    
1022     /**
1023     *
1024     * Returns the DB absolute time needed to associate calibrations to data
1025     *
1026     */
1027     UInt_t GL_TIMESYNC::DBabsTime(UInt_t OBT){
1028     //
1029     return(((UInt_t)(this->DBobt(OBT)/1000)+toffset));
1030     //
1031     };
1032    
1033    
1034     ULong64_t GL_TIMESYNC::DBobt(UInt_t obt){
1035     //
1036     if ( obt < (obtfirst/2) && obtfirst > (numeric_limits<UInt_t>::max()/2) ) return((ULong64_t)(obt+numeric_limits<UInt_t>::max()));
1037     //
1038     if ( obt > (obtfirst*2) && obt > (numeric_limits<UInt_t>::max()/2) ){
1039     if ( (obt-numeric_limits<UInt_t>::max()) < 0 ){
1040     return((ULong64_t)(numeric_limits<UInt_t>::max()-obt));
1041     } else {
1042     return((ULong64_t)(obt-numeric_limits<UInt_t>::max()));
1043     };
1044     };
1045     //
1046     return((ULong64_t)obt);
1047     //
1048     };
1049    
1050     UInt_t GL_TIMESYNC::DBpkt(UInt_t pkt_num){
1051     //
1052     if ( pkt_num < (pktfirst/2) && pktfirst > (16777214/2) ) return((pkt_num+16777215));
1053     //
1054     if ( pkt_num > pktfirst*2 && pkt_num > (16777214/2) ){
1055     if ( (pkt_num-16777215) < 0 ){
1056     return((16777215-pkt_num));
1057     } else {
1058     return((pkt_num-16777215));
1059     };
1060     };
1061     //
1062     return(pkt_num);
1063     //
1064     };
1065 mocchiut 1.5
1066     /*
1067     *
1068     * Convert the time in the DB from UInt_t to a string
1069     *
1070     * @param dbt time in the DB
1071     * @param tzone Time Zone, can be UTC,GMT,CET,CEST,MSD default is MSK
1072     *
1073     */
1074     TString GL_TIMESYNC::ConvertTime(TString tzone, UInt_t dbt){
1075     //
1076     TDatime *time = new TDatime();
1077     TString rtime;
1078     //
1079     time->Set(dbt,false); // MSK = Moscow Winter Time
1080     //
1081     if ( !strcmp(tzone.Data(),"UTC") || !strcmp(tzone.Data(),"GMT") ){
1082     //
1083     UInt_t timeUTC = time->Convert() - 60*60*3; // UTC (Coordinated Universal Time) = Moscow Winter Time - 3 hs
1084     time->Set(timeUTC,false);
1085     //
1086     };
1087     //
1088     if ( !strcmp(tzone.Data(),"CET") ){
1089     //
1090     UInt_t timeCET = time->Convert() - 60*60*2; // CET (Central European Time) = Moscow Winter Time - 2 hs
1091     time->Set(timeCET,false);
1092     //
1093     };
1094     //
1095     if ( !strcmp(tzone.Data(),"CEST") ){
1096     //
1097     UInt_t timeCEST = time->Convert() - 60*60*1; // CEST (Central European Summer Time) = Moscow Winter Time - 1 h
1098     time->Set(timeCEST,false);
1099     //
1100     };
1101     //
1102     if ( !strcmp(tzone.Data(),"MSD") ){
1103     //
1104     UInt_t timeMSD = time->Convert() + 60*60*1; // MSD (Moscow Summer Time) = Moscow Winter Time + 1 h
1105     time->Set(timeMSD,false);
1106     //
1107     };
1108     //
1109     rtime = time->AsSQLString();
1110     //
1111     return(rtime);
1112     }
1113 mocchiut 1.6
1114     /*
1115     *
1116     * Convert the time in the DB from UInt_t to a string
1117     *
1118     * @param dbt time in the DB
1119     * @param tzone Time Zone, can be UTC,GMT,CET,CEST,MSD default is MSK
1120     *
1121     */
1122     TString GL_TIMESYNC::UnConvertTime(TString tzone, UInt_t dbt){
1123     //
1124     TDatime *time = new TDatime();
1125     TString rtime;
1126     //
1127     time->Set(dbt,false); // MSK = Moscow Winter Time
1128     //
1129     if ( !strcmp(tzone.Data(),"UTC") || !strcmp(tzone.Data(),"GMT") ){
1130     //
1131     UInt_t timeUTC = time->Convert() + 60*60*3; // UTC (Coordinated Universal Time) +3 hs = Moscow Winter Time
1132     time->Set(timeUTC,false);
1133     //
1134     };
1135     //
1136     if ( !strcmp(tzone.Data(),"CET") ){
1137     //
1138     UInt_t timeCET = time->Convert() + 60*60*2; // CET (Central European Time) + 2 hs = Moscow Winter Time
1139     time->Set(timeCET,false);
1140     //
1141     };
1142     //
1143     if ( !strcmp(tzone.Data(),"CEST") ){
1144     //
1145     UInt_t timeCEST = time->Convert() + 60*60*1; // CEST (Central European Summer Time) + 1 h = Moscow Winter Time
1146     time->Set(timeCEST,false);
1147     //
1148     };
1149     //
1150     if ( !strcmp(tzone.Data(),"MSD") ){
1151     //
1152     UInt_t timeMSD = time->Convert() - 60*60*1; // MSD (Moscow Summer Time) - 1 h = Moscow Winter Time
1153     time->Set(timeMSD,false);
1154     //
1155     };
1156     //
1157     rtime = time->AsSQLString();
1158     //
1159     return(rtime);
1160     }

  ViewVC Help
Powered by ViewVC 1.1.23