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