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