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 |
|
|
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 section, TSQLServer *dbc){ |
776 |
|
|
// MySQL variables |
777 |
|
|
TSQLResult *pResult; |
778 |
|
|
TSQLRow *Row; |
779 |
|
|
int t; |
780 |
|
|
stringstream myquery; |
781 |
|
|
// |
782 |
|
|
// select the correct calibration |
783 |
|
|
// |
784 |
|
|
myquery.str(""); |
785 |
|
|
myquery << "select ID_ROOT_L0, FROM_TIME, TO_TIME, EV_ROOT,VALIDATION from GL_CALO_CALIB where SECTION=" << section; |
786 |
|
|
myquery << " and FROM_TIME <= " << time; |
787 |
|
|
myquery << " and TO_TIME > " << time; |
788 |
|
|
myquery << " and VALIDATION=1;"; |
789 |
|
|
// |
790 |
|
|
pResult = dbc->Query(myquery.str().c_str()); |
791 |
|
|
// |
792 |
|
|
// if it is corrupted validation is 0 and we have no results from the query... |
793 |
|
|
// |
794 |
|
|
if( !pResult->GetRowCount() ){ |
795 |
|
|
// pResult->Delete(); |
796 |
|
|
// |
797 |
|
|
// in this case take relax the conditions and take the valid calibration that preceed the correct one |
798 |
|
|
// |
799 |
|
|
myquery.str(""); |
800 |
|
|
myquery << "select ID_ROOT_L0, FROM_TIME, TO_TIME, EV_ROOT,VALIDATION from GL_CALO_CALIB where SECTION=" << section; |
801 |
|
|
myquery << " and FROM_TIME <= " << time; |
802 |
|
|
myquery << " and VALIDATION=1 ORDER BY FROM_TIME DESC LIMIT 1;"; |
803 |
|
|
pResult = dbc->Query(myquery.str().c_str()); |
804 |
|
|
// |
805 |
|
|
// if no results yet quit with error |
806 |
|
|
// |
807 |
|
|
if( !pResult->GetRowCount() ) return (-54); |
808 |
|
|
}; |
809 |
|
|
// |
810 |
|
|
// store infos and exit |
811 |
|
|
// |
812 |
|
|
Row = pResult->Next(); |
813 |
|
|
if( Row == NULL ) return (-54); |
814 |
|
|
for( t = 0; t < pResult->GetFieldCount(); t++){ |
815 |
|
|
if (t==0) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); |
816 |
|
|
if (t==1) FROM_TIME = (UInt_t)atoll(Row->GetField(t)); |
817 |
|
|
if (t==2) TO_TIME = (UInt_t)atoll(Row->GetField(t)); |
818 |
|
|
if (t==3) EV_ROOT = (UInt_t)atoll(Row->GetField(t)); |
819 |
|
|
}; |
820 |
|
|
pResult->Delete(); |
821 |
|
|
return 0; |
822 |
|
|
}; |
823 |
|
|
// **************************************************** |
824 |
|
|
/** |
825 |
|
|
* Function to query the GL_S4_CALIB table of the DB. |
826 |
|
|
* |
827 |
|
|
* \param run starting time |
828 |
|
|
* \return struct of type GL_S4_CALIB_data, which stores the query result |
829 |
|
|
*/ |
830 |
|
|
Int_t GL_S4_CALIB::Query_GL_S4_CALIB(UInt_t time, TSQLServer *dbc){ |
831 |
|
|
// MySQL variables |
832 |
|
|
TSQLResult *pResult; |
833 |
|
|
TSQLRow *Row; |
834 |
|
|
int t; |
835 |
|
|
int r; |
836 |
|
|
stringstream myquery; |
837 |
|
|
// ---------------- |
838 |
|
|
myquery.str(""); |
839 |
|
|
myquery << "select * from GL_S4_CALIB where FROM_TIME <= "<< time; |
840 |
|
|
myquery << " AND VALIDATION = 1 ORDER BY FROM_TIME DESC LIMIT 1;"; |
841 |
|
|
// myquery << " ORDER BY FROM_TIME DESC LIMIT 1;"; |
842 |
|
|
pResult = dbc->Query(myquery.str().c_str()); |
843 |
|
|
if(!pResult->GetRowCount())return (-55);//throw -55; |
844 |
|
|
for( r=0; r < 1000; r++){ |
845 |
|
|
Row = pResult->Next(); |
846 |
|
|
if( Row == NULL ) break; |
847 |
|
|
for( t = 0; t < pResult->GetFieldCount(); t++){ |
848 |
|
|
if (t==0) ID = (UInt_t)atoll(Row->GetField(t)); |
849 |
|
|
if (t==1) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); |
850 |
|
|
if (t==2) EV_ROOT = (UInt_t)atoll(Row->GetField(t)); |
851 |
|
|
if (t==3) FROM_TIME = (UInt_t)atoll(Row->GetField(t)); |
852 |
|
|
if (t==4) TO_TIME = (UInt_t)atoll(Row->GetField(t)); |
853 |
|
|
if (t==5) PARAM_FIT0 = atof(Row->GetField(t)); |
854 |
|
|
if (t==6) PARAM_FIT1 = atof(Row->GetField(t)); |
855 |
|
|
}; |
856 |
|
|
}; |
857 |
|
|
delete pResult; |
858 |
|
|
// |
859 |
|
|
if(TO_TIME < time)return(51); |
860 |
|
|
// |
861 |
|
|
return 0; |
862 |
|
|
}; |
863 |
|
|
// **************************************************** |
864 |
|
|
/** |
865 |
|
|
* Function to query the GL_PARAM table of the DB. |
866 |
|
|
* |
867 |
|
|
* \param run starting time |
868 |
|
|
* \param parameter description (DESCR) |
869 |
|
|
* \return struct of type GL_ROOT_data, which stores the query result |
870 |
|
|
*/ |
871 |
|
|
Int_t GL_PARAM::Query_GL_PARAM(UInt_t time, UInt_t type, TSQLServer *dbc){ |
872 |
|
|
// Bool_t debug = 1; |
873 |
|
|
// MySQL variables |
874 |
|
|
TSQLResult *pResult; |
875 |
|
|
TSQLRow *Row; |
876 |
|
|
int t; |
877 |
|
|
int r; |
878 |
|
|
stringstream myquery; |
879 |
|
|
// ---------------- |
880 |
|
|
myquery.str(""); |
881 |
|
|
myquery << " select "; |
882 |
|
|
myquery << " ID, PATH, NAME, DESCR, TYPE, FROM_TIME,TO_TIME "; |
883 |
|
|
myquery << " from GL_PARAM "; |
884 |
|
|
myquery << " where TYPE = '"<<type<<"' "; |
885 |
|
|
myquery << " and FROM_TIME <= " << time; |
886 |
|
|
myquery << " ORDER BY TO_TIME DESC LIMIT 1;"; |
887 |
|
|
// |
888 |
|
|
pResult = dbc->Query(myquery.str().c_str()); |
889 |
|
|
if(!pResult->GetRowCount())return (-52); |
890 |
|
|
for( r=0; r < 1000; r++){ |
891 |
|
|
Row = pResult->Next(); |
892 |
|
|
if( Row == NULL ) break; |
893 |
|
|
for( t = 0; t < pResult->GetFieldCount(); t++){ |
894 |
|
|
if (t==0) ID = (UInt_t)atoll(Row->GetField(t)); |
895 |
|
|
if (t==1) PATH = Row->GetField(t);// put in fpath the path to that file |
896 |
|
|
if (t==2) NAME = Row->GetField(t); |
897 |
|
|
if (t==3) DESCR = Row->GetField(t); |
898 |
|
|
if (t==4) FROM_TIME = (UInt_t)atoll(Row->GetField(t)); |
899 |
|
|
if (t==5) TO_TIME = (UInt_t)atoll(Row->GetField(t)); |
900 |
|
|
if (t==6) TYPE = (UInt_t)atoll(Row->GetField(t)); |
901 |
|
|
}; |
902 |
|
|
}; |
903 |
|
|
delete pResult; |
904 |
|
|
// |
905 |
|
|
if(TO_TIME==0) TO_TIME = numeric_limits<UInt_t>::max(); |
906 |
|
|
// |
907 |
|
|
if(TO_TIME < time) return(51); |
908 |
|
|
// |
909 |
|
|
return 0; |
910 |
|
|
}; |
911 |
|
|
|
912 |
|
|
|
913 |
|
|
/** |
914 |
|
|
* Fills a struct cGLRun with values from a GLRun object (to put data into a F77 common). |
915 |
|
|
*/ |
916 |
|
|
|
917 |
|
|
void GL_RUN::GetLevel2Struct(cGLRun *l2) const{ |
918 |
|
|
l2->id = ID; |
919 |
|
|
l2->id_reg_run = ID_ROOT_L0; |
920 |
|
|
l2->id_reg_run_l2 = ID_ROOT_L2; |
921 |
|
|
l2->runheader_time = RUNHEADER_TIME; |
922 |
|
|
l2->runtrailer_time = RUNTRAILER_TIME; |
923 |
|
|
l2->ev_from = EV_FROM; |
924 |
|
|
l2->trk_calib_used = TRK_CALIB_USED; |
925 |
|
|
l2->eff_wrk_schedule = EFF_WRK_SCHEDULE; |
926 |
|
|
l2->prh_var_trg_mode_a = PRH_VAR_TRG_MODE_A; |
927 |
|
|
l2->prh_var_trg_mode_b = PRH_VAR_TRG_MODE_B; |
928 |
|
|
l2->acq_build_info = ACQ_BUILD_INFO; |
929 |
|
|
l2->acq_var_info = ACQ_VAR_INFO; |
930 |
|
|
}; |
931 |
|
|
|
932 |
|
|
GL_TIMESYNC::GL_TIMESYNC(UInt_t id, TString type, TSQLServer *dbc){ |
933 |
|
|
// MySQL variables |
934 |
|
|
TFile *file = 0; |
935 |
|
|
UInt_t idraw = 0; |
936 |
|
|
// |
937 |
|
|
TSQLResult *pResult; |
938 |
|
|
TSQLRow *Row; |
939 |
|
|
stringstream myquery; |
940 |
|
|
// ---------------- |
941 |
|
|
myquery.str(""); |
942 |
|
|
myquery << "select "; |
943 |
|
|
myquery << "PATH"; |
944 |
|
|
myquery << ",NAME,ID_RAW"; |
945 |
|
|
myquery << " from GL_ROOT where "; |
946 |
|
|
myquery << type.Data(); |
947 |
|
|
myquery << "=" << id << ";"; |
948 |
|
|
// |
949 |
|
|
pResult = dbc->Query(myquery.str().c_str()); |
950 |
|
|
if( pResult->GetRowCount() ){ |
951 |
|
|
Row = pResult->Next(); |
952 |
|
|
if( Row ){ |
953 |
|
|
stringstream fname; |
954 |
|
|
fname.str(""); |
955 |
|
|
fname << Row->GetField(0) << "/" << Row->GetField(1); |
956 |
|
|
file = new TFile(fname.str().c_str(),"READ"); |
957 |
|
|
idraw = (UInt_t)atoll(Row->GetField(2)); |
958 |
|
|
}; |
959 |
|
|
}; |
960 |
|
|
// |
961 |
|
|
if ( file && file->IsOpen() ){ |
962 |
|
|
TTree *T=(TTree*)file->Get("Physics"); |
963 |
|
|
pamela::EventHeader *eh = 0; |
964 |
|
|
pamela::PscuHeader *ph = 0; |
965 |
|
|
T->SetBranchAddress("Header", &eh); |
966 |
|
|
// |
967 |
|
|
T->GetEntry(0); |
968 |
|
|
ph = eh->GetPscuHeader(); |
969 |
|
|
pktfirst = ph->GetCounter(); |
970 |
|
|
obtfirst = ph->GetOrbitalTime(); |
971 |
|
|
}; |
972 |
|
|
// |
973 |
|
|
// look for Resurs offset |
974 |
|
|
// |
975 |
|
|
UInt_t t0 = 0; |
976 |
|
|
// |
977 |
|
|
myquery.str(""); |
978 |
|
|
myquery << "SELECT OFFSET_DATE FROM GL_RESURS_OFFSET WHERE FROM_ID_RAW<= " |
979 |
|
|
<< idraw << " AND TO_ID_RAW >= " |
980 |
|
|
<< idraw << ";"; |
981 |
|
|
pResult = dbc->Query(myquery.str().c_str()); |
982 |
|
|
if ( pResult ){ |
983 |
|
|
Row = pResult->Next(); |
984 |
|
|
if ( Row ){ |
985 |
|
|
// |
986 |
|
|
t0 = (UInt_t)TDatime(Row->GetField(0)).Convert(); |
987 |
|
|
// |
988 |
|
|
}; |
989 |
|
|
}; |
990 |
|
|
// |
991 |
|
|
// |
992 |
|
|
// look for the correct timesync entry |
993 |
|
|
// |
994 |
|
|
myquery.str(""); |
995 |
|
|
myquery << " SELECT OBT0,TIMESYNC FROM GL_TIMESYNC " |
996 |
|
|
<< " WHERE ID_RAW = " << idraw |
997 |
|
|
<< ";"; |
998 |
|
|
pResult = dbc->Query(myquery.str().c_str()); |
999 |
|
|
if ( pResult ){ |
1000 |
|
|
Row = pResult->Next(); |
1001 |
|
|
if ( (Row != NULL) && ((UInt_t)atoll(Row->GetField(0)) > 0 ) ){ |
1002 |
|
|
toffset = (UInt_t)atoll(Row->GetField(1)) - (UInt_t)(this->DBobt((UInt_t)atoll(Row->GetField(0)))/1000) + t0; |
1003 |
|
|
}; |
1004 |
|
|
}; |
1005 |
mocchiut |
1.3 |
// |
1006 |
|
|
file->Close(); |
1007 |
mocchiut |
1.1 |
delete pResult; |
1008 |
|
|
}; |
1009 |
|
|
|
1010 |
|
|
/** |
1011 |
|
|
* |
1012 |
|
|
* Returns the DB absolute time needed to associate calibrations to data |
1013 |
|
|
* |
1014 |
|
|
*/ |
1015 |
|
|
UInt_t GL_TIMESYNC::DBabsTime(UInt_t OBT){ |
1016 |
|
|
// |
1017 |
|
|
return(((UInt_t)(this->DBobt(OBT)/1000)+toffset)); |
1018 |
|
|
// |
1019 |
|
|
}; |
1020 |
|
|
|
1021 |
|
|
|
1022 |
|
|
ULong64_t GL_TIMESYNC::DBobt(UInt_t obt){ |
1023 |
|
|
// |
1024 |
|
|
if ( obt < (obtfirst/2) && obtfirst > (numeric_limits<UInt_t>::max()/2) ) return((ULong64_t)(obt+numeric_limits<UInt_t>::max())); |
1025 |
|
|
// |
1026 |
|
|
if ( obt > (obtfirst*2) && obt > (numeric_limits<UInt_t>::max()/2) ){ |
1027 |
|
|
if ( (obt-numeric_limits<UInt_t>::max()) < 0 ){ |
1028 |
|
|
return((ULong64_t)(numeric_limits<UInt_t>::max()-obt)); |
1029 |
|
|
} else { |
1030 |
|
|
return((ULong64_t)(obt-numeric_limits<UInt_t>::max())); |
1031 |
|
|
}; |
1032 |
|
|
}; |
1033 |
|
|
// |
1034 |
|
|
return((ULong64_t)obt); |
1035 |
|
|
// |
1036 |
|
|
}; |
1037 |
|
|
|
1038 |
|
|
UInt_t GL_TIMESYNC::DBpkt(UInt_t pkt_num){ |
1039 |
|
|
// |
1040 |
|
|
if ( pkt_num < (pktfirst/2) && pktfirst > (16777214/2) ) return((pkt_num+16777215)); |
1041 |
|
|
// |
1042 |
|
|
if ( pkt_num > pktfirst*2 && pkt_num > (16777214/2) ){ |
1043 |
|
|
if ( (pkt_num-16777215) < 0 ){ |
1044 |
|
|
return((16777215-pkt_num)); |
1045 |
|
|
} else { |
1046 |
|
|
return((pkt_num-16777215)); |
1047 |
|
|
}; |
1048 |
|
|
}; |
1049 |
|
|
// |
1050 |
|
|
return(pkt_num); |
1051 |
|
|
// |
1052 |
|
|
}; |