/[PAMELA software]/chewbacca/YodaProfiler/inc/GLTables.h
ViewVC logotype

Contents of /chewbacca/YodaProfiler/inc/GLTables.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.9 - (show annotations) (download)
Tue Dec 15 10:23:28 2009 UTC (15 years ago) by mocchiut
Branch: MAIN
CVS Tags: v10RED, v9r00, v9r01, HEAD
Changes since 1.8: +3 -0 lines
File MIME type: text/plain
Small Q2TH class upgrade

1 #ifndef gltables_h
2 #define gltables_h
3
4 #include <TString.h>
5 #include <TObject.h>
6 #include <TSQLServer.h>
7 #include <TSQLRow.h>
8 #include <TSQLResult.h>
9 #include <TCanvas.h>
10 #include <TDirectory.h>
11 #include <TH1D.h>
12 #include <TH2D.h>
13 #include <TSystem.h>
14 #include <GLTablesStruct.h>
15 #include <EventHeader.h>
16 #include <PscuHeader.h>
17 #include <RunHeaderEvent.h>
18 #include <RunTrailerEvent.h>
19 #include <sgp4.h>
20 //
21
22 using namespace pamela;
23 //
24
25 static const TString *fHost;
26 static const TString *fUser;
27 static const TString *fPsw;
28 static UInt_t fNquery;
29 static Bool_t fSet;
30
31 // ==================================================================
32 /**
33 * \brief Class to store GL_RUN data
34 */
35 class GL_TABLES : public TObject {
36 private:
37
38 public:
39 //
40 TString mh; //!
41 TString mp; //!
42 TString mu; //!
43 GL_TABLES();
44 GL_TABLES(TString, TString, TString);
45 //
46 void Set(TString, TString, TString);
47 //
48 // Bool_t IsConnected(TSQLServer *&);
49 Bool_t IsConnected(TSQLServer *);
50 //
51 void ResetCounters();
52 void AddQ();
53 //
54 const TString* GetHost(){return(fHost);};
55 const TString* GetUser(){return(fUser);};
56 const TString* GetPsw(){return(fPsw);};
57 TString CGetHost(){return(mh);};
58 TString CGetUser(){return(mu);};
59 TString CGetPsw(){return(mp);};
60 UInt_t GetfNquery(){return(fNquery);};
61 UInt_t GetNqueries();
62 Bool_t IsSet(){return(fSet);};
63 //
64 GL_TABLES *GetGLTABLES(){return this;};
65 //
66 ClassDef(GL_TABLES,0); // 2
67 };
68
69 // ==================================================================
70 class Q2TH : public TObject {
71 private:
72 TSQLServer *dbc;
73 TSQLResult *pResult;
74 TSQLRow *Row;
75 TString fh;
76 TString fp;
77 TString fu;
78
79 public:
80
81 Q2TH(TString h="$PAM_DBHOST", TString u="$PAM_DBUSER", TString p="$PAM_DBPSW");
82 ~Q2TH(){ if ( dbc ) dbc->Close(); delete dbc; };
83
84 TObject *Draw(TString query, Bool_t verbose = false, TString hname="q2th");
85 void Open(TString h="$PAM_DBHOST", TString u="$PAM_DBUSER", TString p="$PAM_DBPSW");
86 void Close(){ if ( dbc ) dbc->Close(); delete dbc; };
87
88 ClassDef(Q2TH,1); // 2
89
90 };
91
92 /**
93 * \brief Class to store GL_RUN data
94 */
95 //class GL_RUN : public TObject {
96 class GL_RUN : public GL_TABLES {
97 private:
98
99 public:
100 //
101 UInt_t ID;
102 UInt_t ID_RUN_FRAG;
103 UInt_t ID_ROOT_L0;
104 UInt_t ID_ROOT_L2;
105 UInt_t RUNHEADER_TIME;
106 UInt_t RUNTRAILER_TIME;
107 UInt_t RUNHEADER_OBT;
108 UInt_t RUNTRAILER_OBT;
109 UInt_t RUNHEADER_PKT;
110 UInt_t RUNTRAILER_PKT;
111 UInt_t BOOT_NUMBER;
112 UInt_t EV_FROM;
113 UInt_t EV_TO;
114 UInt_t NEVENTS;
115 UInt_t PKT_COUNTER;
116 UInt_t PKT_READY_COUNTER;
117 UInt_t COMPILATIONTIMESTAMP;
118 UInt_t FAV_WRK_SCHEDULE;
119 UInt_t EFF_WRK_SCHEDULE;
120 UInt_t PRH_VAR_TRG_MODE_A;
121 UInt_t PRH_VAR_TRG_MODE_B;
122 UInt_t ACQ_BUILD_INFO;
123 UInt_t ACQ_VAR_INFO;
124 UInt_t RM_ACQ_AFTER_CALIB;
125 UInt_t RM_ACQ_SETTING_MODE;
126 UInt_t TRK_CALIB_USED;
127 UInt_t CAL_DSP_MASK;
128 UInt_t LAST_TIMESYNC;
129 UInt_t OBT_TIMESYNC;
130 UInt_t PHYSENDRUN_MASK_S3S2S12;
131 UInt_t PHYSENDRUN_MASK_S11CRC;
132 UInt_t VALIDATION;
133 //
134 //
135 //
136 GL_RUN();
137 //
138 // functions
139 //
140 Int_t Query_GL_RUN(UInt_t, TSQLServer*);
141 Int_t Fill_GL_RUN(TSQLServer*);
142 Int_t Query_GL_RUN_FRAGMENTS(TString, TSQLServer*);
143 Int_t Fill_GL_RUN_FRAGMENTS(TSQLServer*);
144 Int_t DeleteRun(TSQLServer*, UInt_t, TString);
145 Int_t RestoreRun(TSQLServer*, UInt_t, TString);
146 void Clear(Option_t *t="");
147 //
148 // SETTERS
149 //
150 void Set_GL_RUNT(RunTrailerEvent *runt, PscuHeader *pht);
151 void Set_GL_RUNH(RunHeaderEvent *runt, PscuHeader *pht);
152 void Set_GL_RUNT0();
153 void Set_GL_RUNH0();
154 //
155 void Set_GL_RUN(TSQLRow *row);
156 //
157 void SetRUNHEADER_TIME(UInt_t abst);
158 void SetRUNTRAILER_TIME(UInt_t abst);
159 void SetRUNHEADER_PKT(UInt_t abst);
160 void SetRUNTRAILER_PKT(UInt_t abst);
161 void SetRUNHEADER_OBT(UInt_t abst);
162 void SetRUNTRAILER_OBT(UInt_t abst);
163 void SetBOOTNUMBER(UInt_t abst);
164 void SetID(UInt_t);
165 void SetID_ROOT_L2(UInt_t L2);
166 void SetID_ROOT_L0(UInt_t L0);
167 void SetID_RUN_FRAG(UInt_t RUN);
168 void SetVALIDATION(UInt_t valid);
169 void SetEV_FROM(UInt_t evfrom);
170 void SetEV_TO(UInt_t evto);
171 void SetNEVENTS(UInt_t nev);
172 void SetLAST_TIMESYNC(UInt_t ts);
173 void SetOBT_TIMESYNC(UInt_t ts);
174 void SetPKT_COUNTER(UInt_t);
175 void SetPKT_READY_COUNTER(UInt_t);
176 void SetCOMPILATIONTIMESTAMP(UInt_t);
177 void SetFAV_WRK_SCHEDULE(UInt_t);
178 void SetEFF_WRK_SCHEDULE(UInt_t);
179 void SetPRH_VAR_TRG_MODE_A(UInt_t);
180 void SetPRH_VAR_TRG_MODE_B(UInt_t);
181 void SetACQ_BUILD_INFO(UInt_t);
182 void SetACQ_VAR_INFO(UInt_t);
183 void SetRM_ACQ_AFTER_CALIB(UInt_t);
184 void SetRM_ACQ_SETTING_MODE(UInt_t);
185 void SetTRK_CALIB_USED(UInt_t);
186 void SetCAL_DSP_MASK(UInt_t);
187 void SetPHYSENDRUN_MASK_S3S2S12(UInt_t);
188 void SetPHYSENDRUN_MASK_S11CRC(UInt_t);
189 //
190 // GETTERS
191 //
192 void GetLevel2Struct(cGLRun *l2) const;
193 UInt_t GetID(){return(ID);};
194 UInt_t GetRUNHEADER_PKT(){return(RUNHEADER_PKT);};
195 UInt_t GetRUNTRAILER_PKT(){return(RUNTRAILER_PKT);};
196 UInt_t GetRUNHEADER_TIME(){return(RUNHEADER_TIME);};
197 UInt_t GetRUNTRAILER_TIME(){return(RUNTRAILER_TIME);};
198 UInt_t GetRUNHEADER_OBT(){return(RUNHEADER_OBT);};
199 UInt_t GetRUNTRAILER_OBT(){return(RUNTRAILER_OBT);};
200 UInt_t GetNEVENTS(){return(NEVENTS);};
201 UInt_t GetBOOT_NUMBER(){return(BOOT_NUMBER);};
202 UInt_t GetTRK_CALIB(){return(TRK_CALIB_USED);};
203 UInt_t GetPKT_COUNTER(){return(PKT_COUNTER);};
204 UInt_t GetLAST_TIMESYNC(){return(LAST_TIMESYNC);};
205 UInt_t GetOBT_TIMESYNC(){return(OBT_TIMESYNC);};
206 UInt_t GetPKT_READY_COUNTER(){return(PKT_READY_COUNTER);};
207 UInt_t GetCOMPILATIONTIMESTAMP(){return(COMPILATIONTIMESTAMP);};
208 UInt_t GetFAV_WRK_SCHEDULE(){return(FAV_WRK_SCHEDULE);};
209 UInt_t GetEFF_WRK_SCHEDULE(){return(EFF_WRK_SCHEDULE);};
210 UInt_t GetPRH_VAR_TRG_MODE_A(){return(PRH_VAR_TRG_MODE_A);};
211 UInt_t GetPRH_VAR_TRG_MODE_B(){return(PRH_VAR_TRG_MODE_B);};
212 UInt_t GetACQ_BUILD_INFO(){return(ACQ_BUILD_INFO);};
213 UInt_t GetACQ_VAR_INFO(){return(ACQ_VAR_INFO);};
214 UInt_t GetRM_ACQ_AFTER_CALIB(){return(RM_ACQ_AFTER_CALIB);};
215 UInt_t GetRM_ACQ_SETTING_MODE(){return(RM_ACQ_SETTING_MODE);};
216 UInt_t GetTRK_CALIB_USED(){return(TRK_CALIB_USED);};
217 UInt_t GetCAL_DSP_MASK(){return(CAL_DSP_MASK);};
218 UInt_t GetPHYSENDRUN_MASK_S3S2S12(){return (PHYSENDRUN_MASK_S3S2S12);};
219 UInt_t GetPHYSENDRUN_MASK_S11CRC(){return (PHYSENDRUN_MASK_S11CRC);};
220 //
221 GL_RUN* GetGL_RUN(){return this;};
222 //
223 ClassDef(GL_RUN,2);
224 };
225
226 // ==================================================================
227 /**
228 * \brief Class to store GL_ROOT
229 */
230 class GL_ROOT : public GL_TABLES {
231 //class GL_ROOT : public TObject{
232 private:
233
234 public:
235 //
236 UInt_t ID;
237 UInt_t ID_RAW;
238 UInt_t ID_TIMESYNC;
239 TString PATH;
240 TString NAME;
241
242 GL_ROOT();
243
244 Int_t Query_GL_ROOT(UInt_t id, TSQLServer *dbc);
245
246 ClassDef(GL_ROOT,1);
247 };
248 // ==================================================================
249 /**
250 * \brief Class to store GL_RAW
251 */
252 class GL_RAW : public GL_TABLES {
253 //class GL_ROOT : public TObject{
254 private:
255
256 public:
257 //
258 UInt_t ID;
259 TString PATH;
260 TString NAME;
261 UInt_t BOOT_NUMBER;
262
263 GL_RAW();
264
265 // Int_t Query_GL_RAW(UInt_t id, TSQLServer *dbc);
266
267 ClassDef(GL_RAW,1);
268 };
269 // ==================================================================
270 /**
271 * \brief Class to store GL_PARAM data
272 */
273 class GL_PARAM : public GL_TABLES {
274 //class GL_PARAM : public TObject{
275 private:
276
277 public:
278 //
279 UInt_t ID;
280 TString PATH;
281 TString NAME;
282 UInt_t FROM_TIME;
283 UInt_t TO_TIME;
284 UInt_t TYPE;
285 TString DESCR;
286
287 GL_PARAM();
288
289 Int_t Query_GL_PARAM(UInt_t time, UInt_t type, TSQLServer *dbc);
290
291 ClassDef(GL_PARAM,1);
292 };
293 // ==================================================================
294 /**
295 * \brief Class to store GL_TRK_CALIB data
296 */
297 //class GL_TRK_CALIB : public TObject{
298 class GL_TRK_CALIB : public GL_TABLES {
299 private:
300
301 public:
302 //
303 UInt_t ID;
304 UInt_t ID_ROOT_L0;
305 UInt_t EV_ROOT_CALIBTRK1 ;
306 UInt_t EV_ROOT_CALIBTRK2 ;
307 UInt_t FROM_TIME;
308 UInt_t TO_TIME;
309 UInt_t OBT1;
310 UInt_t OBT2;
311 UInt_t PKT1;
312 UInt_t PKT2;
313 UInt_t BOOT_NUMBER;
314 UInt_t VALIDATION;
315
316 GL_TRK_CALIB();
317
318 Int_t Query_GL_TRK_CALIB(UInt_t time, TSQLServer *dbc);
319
320 ClassDef(GL_TRK_CALIB,1);
321 };
322
323 // ==================================================================
324 /**
325 * \brief Class to store GL_CALO_CALIB data
326 */
327 class GL_CALO_CALIB : public GL_TABLES {
328 //class GL_CALO_CALIB : public TObject{
329 private:
330
331 public:
332 //
333 UInt_t ID;
334 UInt_t ID_ROOT_L0;
335 UInt_t EV_ROOT;
336 UInt_t FROM_TIME;
337 UInt_t TO_TIME;
338 UInt_t SECTION;
339 UInt_t OBT;
340 UInt_t PKT;
341 UInt_t BOOT_NUMBER;
342 UInt_t VALIDATION;
343
344 GL_CALO_CALIB();
345
346 Int_t Query_GL_CALO_CALIB(UInt_t time, UInt_t &uptime, UInt_t section, TSQLServer *dbc);
347
348 ClassDef(GL_CALO_CALIB,2);
349 };
350
351 // ==================================================================
352 /**
353 * \brief Class to store GL_CALOPULSE_CALIB data
354 */
355 class GL_CALOPULSE_CALIB : public GL_TABLES {
356 private:
357
358 public:
359 //
360 UInt_t ID;
361 UInt_t ID_ROOT_L0;
362 UInt_t EV_ROOT;
363 UInt_t FROM_TIME;
364 UInt_t TO_TIME;
365 UInt_t SECTION;
366 UInt_t PULSED_STRIP;
367 UInt_t PULSE_AMPLITUDE;
368 UInt_t OBT;
369 UInt_t PKT;
370 UInt_t BOOT_NUMBER;
371 UInt_t VALIDATION;
372
373 GL_CALOPULSE_CALIB();
374
375 Int_t Query_GL_CALOPULSE_CALIB(UInt_t time, UInt_t section, UInt_t pampli, TSQLServer *dbc);
376
377 ClassDef(GL_CALOPULSE_CALIB,1);
378 };
379 // ==================================================================
380 /**
381 * \brief Class to store GL_S4_CALIB data
382 */
383 class GL_S4_CALIB : public GL_TABLES {
384 //class GL_S4_CALIB : public TObject{
385 private:
386
387 public:
388 //
389 UInt_t ID;
390 UInt_t ID_ROOT_L0;
391 UInt_t EV_ROOT;
392 UInt_t FROM_TIME;
393 UInt_t TO_TIME;
394 UInt_t OBT;
395 UInt_t PKT;
396 UInt_t BOOT_NUMBER;
397
398 GL_S4_CALIB();
399
400 Int_t Query_GL_S4_CALIB(UInt_t time, TSQLServer *dbc);
401
402 ClassDef(GL_S4_CALIB,2);
403 };
404
405 // ==================================================================
406 /**
407 * \brief Class to store TIMESYNC data
408 */
409 class GL_TIMESYNC : public GL_TABLES {
410 //class GL_TIMESYNC : public TObject{
411 private:
412 UInt_t obtfirst;
413 UInt_t pktfirst;
414 UInt_t toffset;
415 //
416 UInt_t ID;
417 UInt_t ID_RAW;
418 UInt_t ID_RESURS_OFFSET;
419 UInt_t OBT0;
420 UInt_t TIMESYNC;
421 UInt_t TYPE;
422 UInt_t T0;
423
424 public:
425 //
426 GL_TIMESYNC();
427 GL_TIMESYNC(UInt_t ID, TString TYPE, TSQLServer *dbc);
428 GL_TIMESYNC(UInt_t ID, TString TYPE, TSQLServer *dbc, Bool_t usel0file);
429 //
430 UInt_t DBabsTime(UInt_t OBT);
431 UInt_t ResursTime(UInt_t OBT);
432 //
433 Long64_t DBpkt(UInt_t PKT);
434 Long64_t DBobt(UInt_t OBT);
435 //
436 TString ConvertTime(TString &tzone, UInt_t dbt);
437 TString UnConvertTime(TString &tzone, UInt_t dbt);
438 //
439 UInt_t GetTimesync() { return TIMESYNC; };
440 UInt_t GetObt0() { return OBT0; };
441 UInt_t GetT0() { return T0; };
442 UInt_t GetType() { return TYPE; };
443 //
444 ClassDef(GL_TIMESYNC,3);
445 };
446
447
448 /*
449 * Class to query a TLE from the db.
450 *
451 * Two non default constructor are avaiable. It is the same to call
452 * the Query method.
453 *
454 * The class looks for a TLE in the GL_TLE table using the connection
455 * dbc. You need to pass an UTC date in SQL datetime format or in
456 * unix time (UTC) and it will look for the tle with the nearest and
457 * previous date. Then it initialize tle to a cTle object,
458 * tleFromTime to the UTC unix time of the tle and tleToTime to the
459 * UTC unix time of the next avaible tle.
460 */
461 class GL_TLE : public GL_TABLES {
462 //class GL_TLE : public TObject{
463 private:
464 Int_t DoQuery(TString query, TSQLServer *dbc);
465 cTle* GiveTle(TSQLRow*);
466
467 cTle *tle; // the requested tle
468 UInt_t tleFromTime; // unix time (UTC) of the tle
469 UInt_t tleToTime; // unix time (UTC) of the next tle
470
471 public:
472 GL_TLE(){
473 tle = NULL;
474 tleFromTime = 0;
475 tleToTime = 0;
476 };
477
478 GL_TLE(UInt_t unixtime, TSQLServer *dbc) {
479 Query(unixtime, dbc);
480 };
481
482 GL_TLE(TString date, TSQLServer *dbc) {
483 Query(date, dbc);
484 };
485
486 Int_t Query(UInt_t unixtime, TSQLServer *dbc);
487 Int_t Query(TString date, TSQLServer *dbc);
488
489 cTle* GetTle() const { return tle; }
490 UInt_t GetFromTime() const { return tleFromTime; }
491 UInt_t GetToTime() const { return tleToTime; }
492
493 ClassDef(GL_TLE,1);
494 };
495
496 #endif
497

  ViewVC Help
Powered by ViewVC 1.1.23