| 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 |
mocchiut |
1.12 |
#include <iostream> |
| 10 |
mocchiut |
1.1 |
// |
| 11 |
|
|
#include <TFile.h> |
| 12 |
|
|
#include <TTree.h> |
| 13 |
|
|
#include <EventHeader.h> |
| 14 |
|
|
#include <PscuHeader.h> |
| 15 |
|
|
// |
| 16 |
|
|
#include <GLTables.h> |
| 17 |
mocchiut |
1.13 |
#include <sgp4.h> |
| 18 |
mocchiut |
1.1 |
// |
| 19 |
|
|
ClassImp(GL_TRK_CALIB); |
| 20 |
|
|
ClassImp(GL_RUN); |
| 21 |
|
|
ClassImp(GL_ROOT); |
| 22 |
|
|
ClassImp(GL_PARAM); |
| 23 |
|
|
ClassImp(GL_S4_CALIB); |
| 24 |
|
|
ClassImp(GL_CALO_CALIB); |
| 25 |
|
|
ClassImp(GL_TIMESYNC); |
| 26 |
mocchiut |
1.12 |
ClassImp(GL_TLE); |
| 27 |
mocchiut |
1.1 |
// |
| 28 |
|
|
using namespace std; |
| 29 |
|
|
|
| 30 |
|
|
GL_RUN::GL_RUN() { |
| 31 |
|
|
ID = 0; |
| 32 |
|
|
ID_RUN_FRAG = 0; |
| 33 |
|
|
ID_ROOT_L0 = 0; |
| 34 |
|
|
ID_ROOT_L2 = 0; |
| 35 |
|
|
RUNHEADER_TIME = 0; |
| 36 |
|
|
RUNTRAILER_TIME = 0; |
| 37 |
|
|
EV_FROM = 0; |
| 38 |
|
|
EV_TO = 0; |
| 39 |
|
|
TRK_CALIB_USED = 0; |
| 40 |
|
|
EFF_WRK_SCHEDULE = 0; |
| 41 |
|
|
PRH_VAR_TRG_MODE_A = 0; |
| 42 |
|
|
PRH_VAR_TRG_MODE_B = 0; |
| 43 |
|
|
ACQ_BUILD_INFO = 0; |
| 44 |
|
|
ACQ_VAR_INFO = 0; |
| 45 |
|
|
RUNHEADER_OBT = 0; |
| 46 |
|
|
RUNTRAILER_OBT = 0; |
| 47 |
|
|
RUNHEADER_PKT = 0; |
| 48 |
|
|
RUNTRAILER_PKT = 0; |
| 49 |
|
|
NEVENTS = 0; |
| 50 |
|
|
LAST_TIMESYNC = 0; |
| 51 |
|
|
OBT_TIMESYNC = 0; |
| 52 |
|
|
COMPILATIONTIMESTAMP = 0; |
| 53 |
|
|
FAV_WRK_SCHEDULE = 0; |
| 54 |
|
|
RM_ACQ_AFTER_CALIB = 0; |
| 55 |
|
|
RM_ACQ_SETTING_MODE = 0; |
| 56 |
|
|
PKT_COUNTER = 0; |
| 57 |
|
|
PKT_READY_COUNTER = 0; |
| 58 |
|
|
TRK_CALIB_USED = 0; |
| 59 |
|
|
CAL_DSP_MASK = 0; |
| 60 |
|
|
BOOT_NUMBER = 0; |
| 61 |
|
|
VALIDATION = 0; |
| 62 |
|
|
} |
| 63 |
|
|
|
| 64 |
pam-fi |
1.9 |
|
| 65 |
mocchiut |
1.1 |
void GL_RUN::Clear() { |
| 66 |
|
|
ID = 0; |
| 67 |
|
|
ID_RUN_FRAG = 0; |
| 68 |
|
|
ID_ROOT_L0 = 0; |
| 69 |
|
|
ID_ROOT_L2 = 0; |
| 70 |
|
|
RUNHEADER_TIME = 0; |
| 71 |
|
|
RUNTRAILER_TIME = 0; |
| 72 |
|
|
EV_FROM = 0; |
| 73 |
|
|
EV_TO = 0; |
| 74 |
|
|
TRK_CALIB_USED = 0; |
| 75 |
|
|
EFF_WRK_SCHEDULE = 0; |
| 76 |
|
|
PRH_VAR_TRG_MODE_A = 0; |
| 77 |
|
|
PRH_VAR_TRG_MODE_B = 0; |
| 78 |
|
|
ACQ_BUILD_INFO = 0; |
| 79 |
|
|
ACQ_VAR_INFO = 0; |
| 80 |
|
|
RUNHEADER_OBT = 0; |
| 81 |
|
|
RUNTRAILER_OBT = 0; |
| 82 |
|
|
RUNHEADER_PKT = 0; |
| 83 |
|
|
RUNTRAILER_PKT = 0; |
| 84 |
|
|
NEVENTS = 0; |
| 85 |
|
|
LAST_TIMESYNC = 0; |
| 86 |
|
|
OBT_TIMESYNC = 0; |
| 87 |
|
|
COMPILATIONTIMESTAMP = 0; |
| 88 |
|
|
FAV_WRK_SCHEDULE = 0; |
| 89 |
|
|
RM_ACQ_AFTER_CALIB = 0; |
| 90 |
|
|
RM_ACQ_SETTING_MODE = 0; |
| 91 |
|
|
PKT_COUNTER = 0; |
| 92 |
|
|
PKT_READY_COUNTER = 0; |
| 93 |
|
|
TRK_CALIB_USED = 0; |
| 94 |
|
|
CAL_DSP_MASK = 0; |
| 95 |
|
|
BOOT_NUMBER = 0; |
| 96 |
|
|
VALIDATION = 0; |
| 97 |
|
|
} |
| 98 |
|
|
|
| 99 |
|
|
GL_ROOT::GL_ROOT(){ |
| 100 |
|
|
ID = 0; |
| 101 |
|
|
ID_RAW = 0; |
| 102 |
|
|
ID_TIMESYNC = 0; |
| 103 |
|
|
PATH = ""; |
| 104 |
|
|
NAME = ""; |
| 105 |
|
|
} |
| 106 |
|
|
|
| 107 |
|
|
GL_PARAM::GL_PARAM(){ |
| 108 |
|
|
ID = 0; |
| 109 |
|
|
PATH = ""; |
| 110 |
|
|
NAME = ""; |
| 111 |
|
|
DESCR = ""; |
| 112 |
|
|
FROM_TIME = 0; |
| 113 |
|
|
TO_TIME = 0; |
| 114 |
|
|
TYPE = 0; |
| 115 |
|
|
} |
| 116 |
|
|
|
| 117 |
|
|
|
| 118 |
|
|
GL_TRK_CALIB::GL_TRK_CALIB(){ |
| 119 |
|
|
ID = 0; |
| 120 |
|
|
ID_ROOT_L0 = 0; |
| 121 |
|
|
EV_ROOT_CALIBTRK1 = 0; |
| 122 |
|
|
EV_ROOT_CALIBTRK2 = 0; |
| 123 |
|
|
FROM_TIME = 0; |
| 124 |
|
|
TO_TIME = 0; |
| 125 |
|
|
OBT1 = 0; |
| 126 |
|
|
OBT2 = 0; |
| 127 |
|
|
PKT1 = 0; |
| 128 |
|
|
PKT2 = 0; |
| 129 |
pam-fi |
1.9 |
BOOT_NUMBER = 0; |
| 130 |
|
|
VALIDATION = 0; |
| 131 |
mocchiut |
1.1 |
} |
| 132 |
|
|
|
| 133 |
|
|
GL_CALO_CALIB::GL_CALO_CALIB(){ |
| 134 |
|
|
ID = 0; |
| 135 |
|
|
ID_ROOT_L0 = 0; |
| 136 |
|
|
EV_ROOT = 0; |
| 137 |
|
|
FROM_TIME = 0; |
| 138 |
|
|
TO_TIME = 0; |
| 139 |
|
|
SECTION = 0; |
| 140 |
|
|
} |
| 141 |
|
|
|
| 142 |
|
|
GL_S4_CALIB::GL_S4_CALIB(){ |
| 143 |
|
|
ID = 0; |
| 144 |
|
|
ID_ROOT_L0 = 0; |
| 145 |
|
|
EV_ROOT = 0; |
| 146 |
|
|
FROM_TIME = 0; |
| 147 |
|
|
TO_TIME = 0; |
| 148 |
|
|
PARAM_FIT0 = 0.; |
| 149 |
|
|
PARAM_FIT1 = 0.; |
| 150 |
|
|
} |
| 151 |
|
|
|
| 152 |
|
|
GL_TIMESYNC::GL_TIMESYNC(){ |
| 153 |
|
|
obtfirst = 0; |
| 154 |
|
|
pktfirst = 0; |
| 155 |
|
|
toffset = 0; |
| 156 |
|
|
ID = 0; |
| 157 |
|
|
ID_RAW = 0; |
| 158 |
|
|
OBT0 = 0; |
| 159 |
|
|
TIMESYNC = 0; |
| 160 |
|
|
TYPE = 0; |
| 161 |
mocchiut |
1.12 |
} |
| 162 |
|
|
|
| 163 |
|
|
GL_TLE::GL_TLE(){ |
| 164 |
|
|
} |
| 165 |
mocchiut |
1.1 |
|
| 166 |
mocchiut |
1.12 |
// **************************************************** |
| 167 |
mocchiut |
1.1 |
|
| 168 |
|
|
void GL_RUN::SetEV_FROM(UInt_t evfrom){ |
| 169 |
|
|
EV_FROM = evfrom; |
| 170 |
|
|
}; |
| 171 |
|
|
|
| 172 |
|
|
void GL_RUN::SetEV_TO(UInt_t evto){ |
| 173 |
|
|
EV_TO = evto; |
| 174 |
|
|
}; |
| 175 |
|
|
|
| 176 |
|
|
void GL_RUN::SetNEVENTS(UInt_t nev){ |
| 177 |
|
|
NEVENTS = nev; |
| 178 |
|
|
}; |
| 179 |
|
|
|
| 180 |
|
|
void GL_RUN::SetBOOTNUMBER(UInt_t boot){ |
| 181 |
|
|
BOOT_NUMBER = boot; |
| 182 |
|
|
}; |
| 183 |
|
|
|
| 184 |
|
|
void GL_RUN::SetRUNHEADER_TIME(UInt_t absth){ |
| 185 |
|
|
RUNHEADER_TIME = absth; |
| 186 |
|
|
}; |
| 187 |
|
|
|
| 188 |
|
|
void GL_RUN::SetRUNTRAILER_TIME(UInt_t abstt){ |
| 189 |
|
|
RUNTRAILER_TIME = abstt; |
| 190 |
|
|
}; |
| 191 |
|
|
|
| 192 |
|
|
void GL_RUN::SetRUNHEADER_PKT(UInt_t absth){ |
| 193 |
|
|
RUNHEADER_PKT = absth; |
| 194 |
|
|
}; |
| 195 |
|
|
|
| 196 |
|
|
void GL_RUN::SetRUNTRAILER_PKT(UInt_t abstt){ |
| 197 |
|
|
RUNTRAILER_PKT = abstt; |
| 198 |
|
|
}; |
| 199 |
|
|
|
| 200 |
|
|
void GL_RUN::SetRUNHEADER_OBT(UInt_t absth){ |
| 201 |
|
|
RUNHEADER_OBT = absth; |
| 202 |
|
|
}; |
| 203 |
|
|
|
| 204 |
|
|
void GL_RUN::SetRUNTRAILER_OBT(UInt_t abstt){ |
| 205 |
|
|
RUNTRAILER_OBT = abstt; |
| 206 |
|
|
}; |
| 207 |
|
|
|
| 208 |
|
|
void GL_RUN::SetID_ROOT_L2(UInt_t idl2){ |
| 209 |
|
|
ID_ROOT_L2 = idl2; |
| 210 |
|
|
}; |
| 211 |
|
|
|
| 212 |
|
|
void GL_RUN::SetID_ROOT_L0(UInt_t idroot){ |
| 213 |
|
|
ID_ROOT_L0 = idroot; |
| 214 |
|
|
}; |
| 215 |
|
|
|
| 216 |
|
|
void GL_RUN::SetID_RUN_FRAG(UInt_t idfrag){ |
| 217 |
|
|
ID_RUN_FRAG = idfrag; |
| 218 |
|
|
}; |
| 219 |
|
|
|
| 220 |
|
|
void GL_RUN::SetVALIDATION(UInt_t valid){ |
| 221 |
|
|
VALIDATION = valid; |
| 222 |
|
|
}; |
| 223 |
|
|
|
| 224 |
|
|
void GL_RUN::SetLAST_TIMESYNC(UInt_t ts){ |
| 225 |
|
|
LAST_TIMESYNC = ts; |
| 226 |
|
|
}; |
| 227 |
|
|
|
| 228 |
|
|
void GL_RUN::SetOBT_TIMESYNC(UInt_t ts){ |
| 229 |
|
|
OBT_TIMESYNC = ts; |
| 230 |
|
|
}; |
| 231 |
|
|
|
| 232 |
|
|
void GL_RUN:: SetPKT_COUNTER(UInt_t value){ |
| 233 |
|
|
PKT_COUNTER = value; |
| 234 |
|
|
}; |
| 235 |
|
|
|
| 236 |
|
|
void GL_RUN:: SetPKT_READY_COUNTER(UInt_t value){ |
| 237 |
|
|
PKT_READY_COUNTER = value; |
| 238 |
|
|
}; |
| 239 |
|
|
|
| 240 |
|
|
void GL_RUN:: SetCOMPILATIONTIMESTAMP(UInt_t value){ |
| 241 |
|
|
COMPILATIONTIMESTAMP = value; |
| 242 |
|
|
}; |
| 243 |
|
|
|
| 244 |
|
|
void GL_RUN:: SetFAV_WRK_SCHEDULE(UInt_t value){ |
| 245 |
|
|
FAV_WRK_SCHEDULE = value; |
| 246 |
|
|
}; |
| 247 |
|
|
|
| 248 |
|
|
void GL_RUN:: SetEFF_WRK_SCHEDULE(UInt_t value){ |
| 249 |
|
|
EFF_WRK_SCHEDULE = value; |
| 250 |
|
|
}; |
| 251 |
|
|
|
| 252 |
|
|
void GL_RUN:: SetPRH_VAR_TRG_MODE_A(UInt_t value){ |
| 253 |
|
|
PRH_VAR_TRG_MODE_A = value; |
| 254 |
|
|
}; |
| 255 |
|
|
|
| 256 |
|
|
void GL_RUN:: SetPRH_VAR_TRG_MODE_B(UInt_t value){ |
| 257 |
|
|
PRH_VAR_TRG_MODE_B = value; |
| 258 |
|
|
}; |
| 259 |
|
|
|
| 260 |
|
|
void GL_RUN:: SetACQ_BUILD_INFO(UInt_t value){ |
| 261 |
|
|
ACQ_BUILD_INFO = value; |
| 262 |
|
|
}; |
| 263 |
|
|
|
| 264 |
|
|
void GL_RUN:: SetACQ_VAR_INFO(UInt_t value){ |
| 265 |
|
|
ACQ_VAR_INFO = value; |
| 266 |
|
|
}; |
| 267 |
|
|
|
| 268 |
|
|
void GL_RUN:: SetRM_ACQ_AFTER_CALIB(UInt_t value){ |
| 269 |
|
|
RM_ACQ_AFTER_CALIB = value; |
| 270 |
|
|
}; |
| 271 |
|
|
|
| 272 |
|
|
void GL_RUN:: SetRM_ACQ_SETTING_MODE(UInt_t value){ |
| 273 |
|
|
RM_ACQ_SETTING_MODE = value; |
| 274 |
|
|
}; |
| 275 |
|
|
|
| 276 |
|
|
void GL_RUN:: SetTRK_CALIB_USED(UInt_t value){ |
| 277 |
|
|
TRK_CALIB_USED = value; |
| 278 |
|
|
}; |
| 279 |
|
|
|
| 280 |
|
|
void GL_RUN:: SetCAL_DSP_MASK(UInt_t value){ |
| 281 |
|
|
CAL_DSP_MASK = value; |
| 282 |
|
|
}; |
| 283 |
|
|
|
| 284 |
|
|
void GL_RUN:: SetID(UInt_t value){ |
| 285 |
|
|
ID = value; |
| 286 |
|
|
}; |
| 287 |
|
|
|
| 288 |
|
|
void GL_RUN::Set_GL_RUNT(RunTrailerEvent *runt, PscuHeader *pht){ |
| 289 |
|
|
PKT_COUNTER = runt->PKT_COUNTER; |
| 290 |
|
|
PKT_READY_COUNTER = runt->PKT_ReadyCounter; |
| 291 |
|
|
RUNTRAILER_OBT = pht->GetOrbitalTime(); |
| 292 |
|
|
RUNTRAILER_PKT = pht->GetCounter(); |
| 293 |
|
|
}; |
| 294 |
|
|
|
| 295 |
|
|
void GL_RUN::Set_GL_RUNH(RunHeaderEvent *runh, PscuHeader *phh){ |
| 296 |
|
|
TRK_CALIB_USED = runh->TRK_CALIB_USED; |
| 297 |
|
|
PRH_VAR_TRG_MODE_A = runh->PRH_VAR_TRIGGER_MODE_A; |
| 298 |
|
|
PRH_VAR_TRG_MODE_B = runh->PRH_VAR_TRIGGER_MODE_B; |
| 299 |
|
|
ACQ_BUILD_INFO = runh->ACQ_BUILD_INFO; |
| 300 |
|
|
ACQ_VAR_INFO = runh->ACQ_VAR_INFO; |
| 301 |
|
|
RUNHEADER_OBT = phh->GetOrbitalTime(); |
| 302 |
|
|
RUNHEADER_PKT = phh->GetCounter(); |
| 303 |
|
|
LAST_TIMESYNC = runh->LAST_TIME_SYNC_INFO; |
| 304 |
|
|
OBT_TIMESYNC = runh->OBT_TIME_SYNC; |
| 305 |
|
|
COMPILATIONTIMESTAMP = runh->COMPILATIONTIMESTAMP; |
| 306 |
|
|
FAV_WRK_SCHEDULE = runh->FAVOURITE_WORKING_SCHEDULE; |
| 307 |
|
|
EFF_WRK_SCHEDULE = runh->EFFECTIVE_WORKING_SCHEDULE; |
| 308 |
|
|
RM_ACQ_AFTER_CALIB = runh->RM_ACQ_AFTER_CALIB; |
| 309 |
|
|
RM_ACQ_SETTING_MODE = runh->RM_ACQ_SETTING_MODE; |
| 310 |
|
|
TRK_CALIB_USED = runh->TRK_CALIB_USED; |
| 311 |
|
|
CAL_DSP_MASK = runh->CAL_DSP_MASK; |
| 312 |
|
|
}; |
| 313 |
|
|
|
| 314 |
|
|
void GL_RUN::Set_GL_RUNT0(){ |
| 315 |
|
|
PKT_COUNTER = 0; |
| 316 |
|
|
PKT_READY_COUNTER = 0; |
| 317 |
|
|
RUNTRAILER_OBT = 0; |
| 318 |
|
|
RUNTRAILER_PKT = 0; |
| 319 |
|
|
}; |
| 320 |
|
|
|
| 321 |
|
|
void GL_RUN::Set_GL_RUNH0(){ |
| 322 |
|
|
TRK_CALIB_USED = 0; |
| 323 |
|
|
PRH_VAR_TRG_MODE_A = 0; |
| 324 |
|
|
PRH_VAR_TRG_MODE_B = 0; |
| 325 |
|
|
ACQ_BUILD_INFO = 0; |
| 326 |
|
|
ACQ_VAR_INFO = 0; |
| 327 |
|
|
RUNHEADER_OBT = 0; |
| 328 |
|
|
RUNHEADER_PKT = 0; |
| 329 |
|
|
LAST_TIMESYNC = 0; |
| 330 |
|
|
OBT_TIMESYNC = 0; |
| 331 |
|
|
COMPILATIONTIMESTAMP = 0; |
| 332 |
|
|
FAV_WRK_SCHEDULE = 0; |
| 333 |
|
|
EFF_WRK_SCHEDULE = 0; |
| 334 |
|
|
RM_ACQ_AFTER_CALIB = 0; |
| 335 |
|
|
RM_ACQ_SETTING_MODE = 0; |
| 336 |
|
|
TRK_CALIB_USED = 0; |
| 337 |
|
|
CAL_DSP_MASK = 0; |
| 338 |
|
|
}; |
| 339 |
|
|
|
| 340 |
pam-fi |
1.9 |
void GL_RUN::Set_GL_RUN(TSQLRow *Row){ |
| 341 |
|
|
for( Int_t t = 0; t < 30; t++){ |
| 342 |
|
|
if (t== 0) ID = (UInt_t)atoll(Row->GetField(t)); |
| 343 |
|
|
if (t== 1) ID_RUN_FRAG = (UInt_t)atoll(Row->GetField(t)); |
| 344 |
|
|
if (t== 2) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); |
| 345 |
|
|
if (t== 3) ID_ROOT_L2 = (UInt_t)atoll(Row->GetField(t)); |
| 346 |
|
|
if (t== 4) RUNHEADER_TIME = (UInt_t)atoll(Row->GetField(t)); |
| 347 |
|
|
if (t== 5) RUNTRAILER_TIME = (UInt_t)atoll(Row->GetField(t)); |
| 348 |
|
|
if (t== 6) RUNHEADER_OBT = (UInt_t)atoll(Row->GetField(t)); |
| 349 |
|
|
if (t== 7) RUNTRAILER_OBT = (UInt_t)atoll(Row->GetField(t)); |
| 350 |
|
|
if (t== 8) RUNHEADER_PKT = (UInt_t)atoll(Row->GetField(t)); |
| 351 |
|
|
if (t== 9) RUNTRAILER_PKT = (UInt_t)atoll(Row->GetField(t)); |
| 352 |
|
|
if (t==10) BOOT_NUMBER = (UInt_t)atoll(Row->GetField(t)); |
| 353 |
|
|
if (t==11) EV_FROM = (UInt_t)atoll(Row->GetField(t)); |
| 354 |
|
|
if (t==12) EV_TO = (UInt_t)atoll(Row->GetField(t)); |
| 355 |
|
|
if (t==13) NEVENTS = (UInt_t)atoll(Row->GetField(t)); |
| 356 |
|
|
if (t==14) PKT_COUNTER = (UInt_t)atoll(Row->GetField(t)); |
| 357 |
|
|
if (t==15) PKT_READY_COUNTER = (UInt_t)atoll(Row->GetField(t)); |
| 358 |
|
|
if (t==16) COMPILATIONTIMESTAMP = (UInt_t)atoll(Row->GetField(t)); |
| 359 |
|
|
if (t==17) FAV_WRK_SCHEDULE = (UInt_t)atoll(Row->GetField(t)); |
| 360 |
|
|
if (t==18) EFF_WRK_SCHEDULE = (UInt_t)atoll(Row->GetField(t)); |
| 361 |
|
|
if (t==19) PRH_VAR_TRG_MODE_A= (UInt_t)atoll(Row->GetField(t)); |
| 362 |
|
|
if (t==20) PRH_VAR_TRG_MODE_B= (UInt_t)atoll(Row->GetField(t)); |
| 363 |
|
|
if (t==21) ACQ_BUILD_INFO = (UInt_t)atoll(Row->GetField(t)); |
| 364 |
|
|
if (t==22) ACQ_VAR_INFO = (UInt_t)atoll(Row->GetField(t)); |
| 365 |
|
|
if (t==23) RM_ACQ_AFTER_CALIB= (UInt_t)atoll(Row->GetField(t)); |
| 366 |
|
|
if (t==24) RM_ACQ_SETTING_MODE = (UInt_t)atoll(Row->GetField(t)); |
| 367 |
|
|
if (t==25) TRK_CALIB_USED = (UInt_t)atoll(Row->GetField(t)); |
| 368 |
|
|
if (t==26) CAL_DSP_MASK = (UInt_t)atoll(Row->GetField(t)); |
| 369 |
|
|
if (t==27) LAST_TIMESYNC = (UInt_t)atoll(Row->GetField(t)); |
| 370 |
|
|
if (t==28) OBT_TIMESYNC = (UInt_t)atoll(Row->GetField(t)); |
| 371 |
|
|
if (t==29) VALIDATION = (UInt_t)atoll(Row->GetField(t)); |
| 372 |
|
|
}; |
| 373 |
|
|
|
| 374 |
|
|
} |
| 375 |
|
|
|
| 376 |
mocchiut |
1.1 |
|
| 377 |
|
|
/** |
| 378 |
|
|
* Function to fill the GL_RUN table of the DB. |
| 379 |
|
|
* |
| 380 |
|
|
* \param |
| 381 |
|
|
* |
| 382 |
|
|
*/ |
| 383 |
|
|
Int_t GL_RUN::Fill_GL_RUN(TSQLServer *dbc){ |
| 384 |
|
|
// MySQL variables |
| 385 |
|
|
stringstream myquery; |
| 386 |
|
|
// ---------------- |
| 387 |
|
|
myquery.str(""); |
| 388 |
|
|
myquery << " INSERT INTO GL_RUN ("; |
| 389 |
|
|
myquery << "ID"; |
| 390 |
|
|
myquery << ",ID_RUN_FRAG"; |
| 391 |
|
|
myquery << ",ID_ROOT_L0"; |
| 392 |
|
|
myquery << ",ID_ROOT_L2"; |
| 393 |
|
|
myquery << ",RUNHEADER_TIME"; |
| 394 |
|
|
myquery << ",RUNTRAILER_TIME"; |
| 395 |
|
|
myquery << ",RUNHEADER_OBT"; |
| 396 |
|
|
myquery << ",RUNTRAILER_OBT"; |
| 397 |
|
|
myquery << ",RUNHEADER_PKT"; |
| 398 |
|
|
myquery << ",RUNTRAILER_PKT"; |
| 399 |
|
|
myquery << ",EV_FROM"; |
| 400 |
|
|
myquery << ",EV_TO"; |
| 401 |
|
|
myquery << ",NEVENTS"; |
| 402 |
|
|
myquery << ",LAST_TIMESYNC"; |
| 403 |
|
|
myquery << ",OBT_TIMESYNC"; |
| 404 |
|
|
myquery << ",COMPILATIONTIMESTAMP"; |
| 405 |
|
|
myquery << ",FAV_WRK_SCHEDULE"; |
| 406 |
|
|
myquery << ",EFF_WRK_SCHEDULE"; |
| 407 |
|
|
myquery << ",PRH_VAR_TRG_MODE_A"; |
| 408 |
|
|
myquery << ",PRH_VAR_TRG_MODE_B"; |
| 409 |
|
|
myquery << ",ACQ_BUILD_INFO"; |
| 410 |
|
|
myquery << ",ACQ_VAR_INFO"; |
| 411 |
|
|
myquery << ",RM_ACQ_AFTER_CALIB"; |
| 412 |
|
|
myquery << ",RM_ACQ_SETTING_MODE"; |
| 413 |
|
|
myquery << ",PKT_COUNTER"; |
| 414 |
|
|
myquery << ",PKT_READY_COUNTER"; |
| 415 |
|
|
myquery << ",TRK_CALIB_USED"; |
| 416 |
|
|
myquery << ",CAL_DSP_MASK"; |
| 417 |
|
|
myquery << ",BOOT_NUMBER"; |
| 418 |
|
|
myquery << ",VALIDATION"; |
| 419 |
|
|
myquery << ") VALUES ('"; |
| 420 |
|
|
|
| 421 |
|
|
myquery << (UInt_t)ID << "','"; |
| 422 |
|
|
myquery << (UInt_t)ID_RUN_FRAG << "','"; |
| 423 |
|
|
myquery << (UInt_t)ID_ROOT_L0 << "','"; |
| 424 |
|
|
myquery << (UInt_t)ID_ROOT_L2 << "','"; |
| 425 |
|
|
myquery << (UInt_t)RUNHEADER_TIME << "','"; |
| 426 |
|
|
myquery << (UInt_t)RUNTRAILER_TIME << "','"; |
| 427 |
|
|
myquery << (UInt_t)RUNHEADER_OBT << "','"; |
| 428 |
|
|
myquery << (UInt_t)RUNTRAILER_OBT << "','"; |
| 429 |
|
|
myquery << (UInt_t)RUNHEADER_PKT << "','"; |
| 430 |
|
|
myquery << (UInt_t)RUNTRAILER_PKT << "','"; |
| 431 |
|
|
myquery << (UInt_t)EV_FROM << "','"; |
| 432 |
|
|
myquery << (UInt_t)EV_TO << "','"; |
| 433 |
|
|
myquery << (UInt_t)NEVENTS << "','"; |
| 434 |
|
|
myquery << (UInt_t)LAST_TIMESYNC << "','"; |
| 435 |
|
|
myquery << (UInt_t)OBT_TIMESYNC << "','"; |
| 436 |
|
|
myquery << (UInt_t)COMPILATIONTIMESTAMP << "','"; |
| 437 |
|
|
myquery << (UInt_t)FAV_WRK_SCHEDULE << "','"; |
| 438 |
|
|
myquery << (UInt_t)EFF_WRK_SCHEDULE << "','"; |
| 439 |
|
|
myquery << (UInt_t)PRH_VAR_TRG_MODE_A << "','"; |
| 440 |
|
|
myquery << (UInt_t)PRH_VAR_TRG_MODE_B << "','"; |
| 441 |
|
|
myquery << (UInt_t)ACQ_BUILD_INFO << "','"; |
| 442 |
|
|
myquery << (UInt_t)ACQ_VAR_INFO << "','"; |
| 443 |
|
|
myquery << (UInt_t)RM_ACQ_AFTER_CALIB << "','"; |
| 444 |
|
|
myquery << (UInt_t)RM_ACQ_SETTING_MODE << "','"; |
| 445 |
|
|
myquery << (UInt_t)PKT_COUNTER << "','"; |
| 446 |
|
|
myquery << (UInt_t)PKT_READY_COUNTER << "','"; |
| 447 |
|
|
myquery << (UInt_t)TRK_CALIB_USED << "','"; |
| 448 |
|
|
myquery << (UInt_t)CAL_DSP_MASK << "','"; |
| 449 |
|
|
myquery << (UInt_t)BOOT_NUMBER << "','"; |
| 450 |
|
|
myquery << (UInt_t)VALIDATION << "');"; |
| 451 |
|
|
// |
| 452 |
mocchiut |
1.2 |
// printf("myquery is %s \n",myquery.str().c_str()); |
| 453 |
mocchiut |
1.1 |
// |
| 454 |
|
|
dbc->Query(myquery.str().c_str()); |
| 455 |
|
|
// |
| 456 |
|
|
return 0; |
| 457 |
|
|
|
| 458 |
|
|
};// **************************************************** |
| 459 |
|
|
|
| 460 |
|
|
/** |
| 461 |
|
|
* Function to fill the GL_RUN table of the DB. |
| 462 |
|
|
* |
| 463 |
|
|
* \param |
| 464 |
|
|
* |
| 465 |
|
|
*/ |
| 466 |
|
|
Int_t GL_RUN::Fill_GL_RUN_FRAGMENTS(TSQLServer *dbc){ |
| 467 |
|
|
// MySQL variables |
| 468 |
|
|
stringstream myquery; |
| 469 |
|
|
// ---------------- |
| 470 |
|
|
myquery.str(""); |
| 471 |
|
|
myquery << " INSERT INTO GL_RUN_FRAGMENTS ("; |
| 472 |
|
|
myquery << "ID"; |
| 473 |
|
|
myquery << ",ID_ROOT_L0"; |
| 474 |
|
|
myquery << ",RUNHEADER_TIME"; |
| 475 |
|
|
myquery << ",RUNTRAILER_TIME"; |
| 476 |
|
|
myquery << ",RUNHEADER_OBT"; |
| 477 |
|
|
myquery << ",RUNTRAILER_OBT"; |
| 478 |
|
|
myquery << ",RUNHEADER_PKT"; |
| 479 |
|
|
myquery << ",RUNTRAILER_PKT"; |
| 480 |
|
|
myquery << ",EV_FROM"; |
| 481 |
|
|
myquery << ",EV_TO"; |
| 482 |
|
|
myquery << ",NEVENTS"; |
| 483 |
|
|
myquery << ",LAST_TIMESYNC"; |
| 484 |
|
|
myquery << ",OBT_TIMESYNC"; |
| 485 |
|
|
myquery << ",COMPILATIONTIMESTAMP"; |
| 486 |
|
|
myquery << ",FAV_WRK_SCHEDULE"; |
| 487 |
|
|
myquery << ",EFF_WRK_SCHEDULE"; |
| 488 |
|
|
myquery << ",PRH_VAR_TRG_MODE_A"; |
| 489 |
|
|
myquery << ",PRH_VAR_TRG_MODE_B"; |
| 490 |
|
|
myquery << ",ACQ_BUILD_INFO"; |
| 491 |
|
|
myquery << ",ACQ_VAR_INFO"; |
| 492 |
|
|
myquery << ",RM_ACQ_AFTER_CALIB"; |
| 493 |
|
|
myquery << ",RM_ACQ_SETTING_MODE"; |
| 494 |
|
|
myquery << ",PKT_COUNTER"; |
| 495 |
|
|
myquery << ",PKT_READY_COUNTER"; |
| 496 |
|
|
myquery << ",TRK_CALIB_USED"; |
| 497 |
|
|
myquery << ",CAL_DSP_MASK"; |
| 498 |
|
|
myquery << ",BOOT_NUMBER"; |
| 499 |
|
|
myquery << ") VALUES ('"; |
| 500 |
|
|
myquery << (UInt_t)ID << "','"; |
| 501 |
|
|
myquery << (UInt_t)ID_ROOT_L0 << "','"; |
| 502 |
|
|
myquery << (UInt_t)RUNHEADER_TIME << "','"; |
| 503 |
|
|
myquery << (UInt_t)RUNTRAILER_TIME << "','"; |
| 504 |
|
|
myquery << (UInt_t)RUNHEADER_OBT << "','"; |
| 505 |
|
|
myquery << (UInt_t)RUNTRAILER_OBT << "','"; |
| 506 |
|
|
myquery << (UInt_t)RUNHEADER_PKT << "','"; |
| 507 |
|
|
myquery << (UInt_t)RUNTRAILER_PKT << "','"; |
| 508 |
|
|
myquery << (UInt_t)EV_FROM << "','"; |
| 509 |
|
|
myquery << (UInt_t)EV_TO << "','"; |
| 510 |
|
|
myquery << (UInt_t)NEVENTS << "','"; |
| 511 |
|
|
myquery << (UInt_t)LAST_TIMESYNC << "','"; |
| 512 |
|
|
myquery << (UInt_t)OBT_TIMESYNC << "','"; |
| 513 |
|
|
myquery << (UInt_t)COMPILATIONTIMESTAMP << "','"; |
| 514 |
|
|
myquery << (UInt_t)FAV_WRK_SCHEDULE << "','"; |
| 515 |
|
|
myquery << (UInt_t)EFF_WRK_SCHEDULE << "','"; |
| 516 |
|
|
myquery << (UInt_t)PRH_VAR_TRG_MODE_A << "','"; |
| 517 |
|
|
myquery << (UInt_t)PRH_VAR_TRG_MODE_B << "','"; |
| 518 |
|
|
myquery << (UInt_t)ACQ_BUILD_INFO << "','"; |
| 519 |
|
|
myquery << (UInt_t)ACQ_VAR_INFO << "','"; |
| 520 |
|
|
myquery << (UInt_t)RM_ACQ_AFTER_CALIB << "','"; |
| 521 |
|
|
myquery << (UInt_t)RM_ACQ_SETTING_MODE << "','"; |
| 522 |
|
|
myquery << (UInt_t)PKT_COUNTER << "','"; |
| 523 |
|
|
myquery << (UInt_t)PKT_READY_COUNTER << "','"; |
| 524 |
|
|
myquery << (UInt_t)TRK_CALIB_USED << "','"; |
| 525 |
|
|
myquery << (UInt_t)CAL_DSP_MASK << "','"; |
| 526 |
|
|
myquery << (UInt_t)BOOT_NUMBER << "');"; |
| 527 |
|
|
// |
| 528 |
|
|
// printf("myquery is %s \n",myquery.str().c_str()); |
| 529 |
|
|
// |
| 530 |
|
|
dbc->Query(myquery.str().c_str()); |
| 531 |
|
|
// |
| 532 |
|
|
return 0; |
| 533 |
|
|
|
| 534 |
|
|
};// **************************************************** |
| 535 |
|
|
|
| 536 |
|
|
|
| 537 |
|
|
/** |
| 538 |
|
|
* Function to query the GL_RUN table of the DB. |
| 539 |
|
|
* |
| 540 |
|
|
* \param RUN id |
| 541 |
|
|
* \return struct of type GL_RUN _data, which stores the query result |
| 542 |
|
|
* |
| 543 |
|
|
*/ |
| 544 |
|
|
Int_t GL_RUN::Query_GL_RUN(UInt_t run, TSQLServer *dbc){ |
| 545 |
|
|
// MySQL variables |
| 546 |
|
|
TSQLResult *pResult; |
| 547 |
|
|
TSQLRow *Row; |
| 548 |
|
|
int t; |
| 549 |
|
|
int r; |
| 550 |
|
|
stringstream myquery; |
| 551 |
|
|
// ---------------- |
| 552 |
|
|
myquery.str(""); |
| 553 |
|
|
myquery << " select "; |
| 554 |
|
|
myquery << "ID"; |
| 555 |
|
|
myquery << ",ID_RUN_FRAG"; |
| 556 |
|
|
myquery << ",ID_ROOT_L0"; |
| 557 |
|
|
myquery << ",ID_ROOT_L2"; |
| 558 |
|
|
myquery << ",RUNHEADER_TIME"; |
| 559 |
|
|
myquery << ",RUNTRAILER_TIME"; |
| 560 |
|
|
myquery << ",RUNHEADER_OBT"; |
| 561 |
|
|
myquery << ",RUNTRAILER_OBT"; |
| 562 |
|
|
myquery << ",RUNHEADER_PKT"; |
| 563 |
|
|
myquery << ",RUNTRAILER_PKT"; |
| 564 |
|
|
myquery << ",EV_FROM"; |
| 565 |
|
|
myquery << ",EV_TO"; |
| 566 |
|
|
myquery << ",NEVENTS"; |
| 567 |
|
|
myquery << ",LAST_TIMESYNC"; |
| 568 |
|
|
myquery << ",OBT_TIMESYNC"; |
| 569 |
|
|
myquery << ",COMPILATIONTIMESTAMP"; |
| 570 |
|
|
myquery << ",FAV_WRK_SCHEDULE"; |
| 571 |
|
|
myquery << ",EFF_WRK_SCHEDULE"; |
| 572 |
|
|
myquery << ",PRH_VAR_TRG_MODE_A"; |
| 573 |
|
|
myquery << ",PRH_VAR_TRG_MODE_B"; |
| 574 |
|
|
myquery << ",ACQ_BUILD_INFO"; |
| 575 |
|
|
myquery << ",ACQ_VAR_INFO"; |
| 576 |
|
|
myquery << ",RM_ACQ_AFTER_CALIB"; |
| 577 |
|
|
myquery << ",RM_ACQ_SETTING_MODE"; |
| 578 |
|
|
myquery << ",PKT_COUNTER"; |
| 579 |
|
|
myquery << ",PKT_READY_COUNTER"; |
| 580 |
|
|
myquery << ",TRK_CALIB_USED"; |
| 581 |
|
|
myquery << ",CAL_DSP_MASK"; |
| 582 |
|
|
myquery << ",BOOT_NUMBER"; |
| 583 |
|
|
myquery << ",VALIDATION"; |
| 584 |
|
|
myquery << " from GL_RUN where ID=" << run << ";"; |
| 585 |
|
|
// |
| 586 |
mocchiut |
1.4 |
// printf(" myquery is %s \n",myquery.str().c_str()); |
| 587 |
mocchiut |
1.1 |
pResult = dbc->Query(myquery.str().c_str()); |
| 588 |
mocchiut |
1.4 |
// |
| 589 |
|
|
// printf(" getrowcount %i \n",pResult->GetRowCount()); |
| 590 |
|
|
// |
| 591 |
|
|
if( !pResult->GetRowCount() ) return(-50); |
| 592 |
|
|
// |
| 593 |
mocchiut |
1.1 |
for( r=0; r < 1000; r++){ |
| 594 |
|
|
Row = pResult->Next(); |
| 595 |
|
|
if( Row == NULL ) break; |
| 596 |
pam-fi |
1.9 |
// Set_GL_RUN(Row); |
| 597 |
mocchiut |
1.1 |
for( t = 0; t < pResult->GetFieldCount(); t++){ |
| 598 |
pam-fi |
1.9 |
if (t== 0) ID = (UInt_t)atoll(Row->GetField(t)); |
| 599 |
|
|
if (t== 1) ID_RUN_FRAG = (UInt_t)atoll(Row->GetField(t)); |
| 600 |
|
|
if (t== 2) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); |
| 601 |
|
|
if (t== 3) ID_ROOT_L2 = (UInt_t)atoll(Row->GetField(t)); |
| 602 |
|
|
if (t== 4) RUNHEADER_TIME = (UInt_t)atoll(Row->GetField(t)); |
| 603 |
|
|
if (t== 5) RUNTRAILER_TIME = (UInt_t)atoll(Row->GetField(t)); |
| 604 |
|
|
if (t== 6) RUNHEADER_OBT = (UInt_t)atoll(Row->GetField(t)); |
| 605 |
|
|
if (t== 7) RUNTRAILER_OBT = (UInt_t)atoll(Row->GetField(t)); |
| 606 |
|
|
if (t== 8) RUNHEADER_PKT = (UInt_t)atoll(Row->GetField(t)); |
| 607 |
|
|
if (t== 9) RUNTRAILER_PKT = (UInt_t)atoll(Row->GetField(t)); |
| 608 |
|
|
if (t==10) EV_FROM = (UInt_t)atoll(Row->GetField(t)); |
| 609 |
|
|
if (t==11) EV_TO = (UInt_t)atoll(Row->GetField(t)); |
| 610 |
|
|
if (t==12) NEVENTS = (UInt_t)atoll(Row->GetField(t)); |
| 611 |
|
|
if (t==13) LAST_TIMESYNC = (UInt_t)atoll(Row->GetField(t)); |
| 612 |
|
|
if (t==14) OBT_TIMESYNC = (UInt_t)atoll(Row->GetField(t)); |
| 613 |
|
|
if (t==15) COMPILATIONTIMESTAMP = (UInt_t)atoll(Row->GetField(t)); |
| 614 |
|
|
if (t==16) FAV_WRK_SCHEDULE = (UInt_t)atoll(Row->GetField(t)); |
| 615 |
|
|
if (t==17) EFF_WRK_SCHEDULE = (UInt_t)atoll(Row->GetField(t)); |
| 616 |
|
|
if (t==18) PRH_VAR_TRG_MODE_A= (UInt_t)atoll(Row->GetField(t)); |
| 617 |
|
|
if (t==19) PRH_VAR_TRG_MODE_B= (UInt_t)atoll(Row->GetField(t)); |
| 618 |
|
|
if (t==20) ACQ_BUILD_INFO = (UInt_t)atoll(Row->GetField(t)); |
| 619 |
|
|
if (t==21) ACQ_VAR_INFO = (UInt_t)atoll(Row->GetField(t)); |
| 620 |
|
|
if (t==22) RM_ACQ_AFTER_CALIB= (UInt_t)atoll(Row->GetField(t)); |
| 621 |
|
|
if (t==23) RM_ACQ_SETTING_MODE = (UInt_t)atoll(Row->GetField(t)); |
| 622 |
|
|
if (t==24) PKT_COUNTER = (UInt_t)atoll(Row->GetField(t)); |
| 623 |
|
|
if (t==25) PKT_READY_COUNTER = (UInt_t)atoll(Row->GetField(t)); |
| 624 |
|
|
if (t==26) TRK_CALIB_USED = (UInt_t)atoll(Row->GetField(t)); |
| 625 |
|
|
if (t==27) CAL_DSP_MASK = (UInt_t)atoll(Row->GetField(t)); |
| 626 |
|
|
if (t==28) BOOT_NUMBER = (UInt_t)atoll(Row->GetField(t)); |
| 627 |
|
|
if (t==29) VALIDATION = (UInt_t)atoll(Row->GetField(t)); |
| 628 |
mocchiut |
1.1 |
}; |
| 629 |
|
|
}; |
| 630 |
mocchiut |
1.4 |
// delete pResult; |
| 631 |
|
|
return(0); |
| 632 |
mocchiut |
1.1 |
}; |
| 633 |
|
|
|
| 634 |
|
|
/** |
| 635 |
|
|
* Function to query the GL_RUN table of the DB. |
| 636 |
|
|
* |
| 637 |
|
|
* \param where = condition string |
| 638 |
|
|
* \return struct of type GL_RUN _data, which stores the query result |
| 639 |
|
|
* |
| 640 |
|
|
*/ |
| 641 |
|
|
Int_t GL_RUN::Query_GL_RUN_FRAGMENTS(TString where, TSQLServer *dbc){ |
| 642 |
|
|
// MySQL variables |
| 643 |
|
|
TSQLResult *pResult; |
| 644 |
|
|
TSQLRow *Row; |
| 645 |
|
|
int t; |
| 646 |
|
|
int r; |
| 647 |
|
|
stringstream myquery; |
| 648 |
|
|
// ---------------- |
| 649 |
|
|
myquery.str(""); |
| 650 |
|
|
myquery << " select "; |
| 651 |
|
|
myquery << "ID"; |
| 652 |
mocchiut |
1.2 |
myquery << ",ID_RUN_FRAG"; |
| 653 |
mocchiut |
1.1 |
myquery << ",ID_ROOT_L0"; |
| 654 |
mocchiut |
1.2 |
myquery << ",ID_ROOT_L2"; |
| 655 |
mocchiut |
1.1 |
myquery << ",RUNHEADER_TIME"; |
| 656 |
|
|
myquery << ",RUNTRAILER_TIME"; |
| 657 |
|
|
myquery << ",RUNHEADER_OBT"; |
| 658 |
|
|
myquery << ",RUNTRAILER_OBT"; |
| 659 |
|
|
myquery << ",RUNHEADER_PKT"; |
| 660 |
|
|
myquery << ",RUNTRAILER_PKT"; |
| 661 |
|
|
myquery << ",EV_FROM"; |
| 662 |
|
|
myquery << ",EV_TO"; |
| 663 |
|
|
myquery << ",NEVENTS"; |
| 664 |
|
|
myquery << ",LAST_TIMESYNC"; |
| 665 |
|
|
myquery << ",OBT_TIMESYNC"; |
| 666 |
|
|
myquery << ",COMPILATIONTIMESTAMP"; |
| 667 |
|
|
myquery << ",FAV_WRK_SCHEDULE"; |
| 668 |
|
|
myquery << ",EFF_WRK_SCHEDULE"; |
| 669 |
|
|
myquery << ",PRH_VAR_TRG_MODE_A"; |
| 670 |
|
|
myquery << ",PRH_VAR_TRG_MODE_B"; |
| 671 |
|
|
myquery << ",ACQ_BUILD_INFO"; |
| 672 |
|
|
myquery << ",ACQ_VAR_INFO"; |
| 673 |
|
|
myquery << ",RM_ACQ_AFTER_CALIB"; |
| 674 |
|
|
myquery << ",RM_ACQ_SETTING_MODE"; |
| 675 |
|
|
myquery << ",PKT_COUNTER"; |
| 676 |
|
|
myquery << ",PKT_READY_COUNTER"; |
| 677 |
|
|
myquery << ",TRK_CALIB_USED"; |
| 678 |
|
|
myquery << ",CAL_DSP_MASK"; |
| 679 |
|
|
myquery << ",BOOT_NUMBER"; |
| 680 |
mocchiut |
1.2 |
myquery << ",VALIDATION"; |
| 681 |
mocchiut |
1.1 |
myquery << " from GL_RUN_FRAGMENTS where " << where.Data() << ";"; |
| 682 |
|
|
// |
| 683 |
mocchiut |
1.2 |
// printf(" query is %s \n",myquery.str().c_str()); |
| 684 |
|
|
// |
| 685 |
mocchiut |
1.1 |
pResult = dbc->Query(myquery.str().c_str()); |
| 686 |
|
|
if(!pResult->GetRowCount())return(-50); |
| 687 |
|
|
for( r=0; r < 1000; r++){ |
| 688 |
mocchiut |
1.2 |
Row = pResult->Next(); |
| 689 |
|
|
if( Row == NULL ) break; |
| 690 |
|
|
for( t = 0; t < pResult->GetFieldCount(); t++){ |
| 691 |
|
|
if (t== 0) ID = (UInt_t)atoll(Row->GetField(t)); |
| 692 |
|
|
if (t== 1) ID_RUN_FRAG = (UInt_t)atoll(Row->GetField(t)); |
| 693 |
|
|
if (t== 2) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); |
| 694 |
|
|
if (t== 3) ID_ROOT_L2 = (UInt_t)atoll(Row->GetField(t)); |
| 695 |
|
|
if (t== 4) RUNHEADER_TIME = (UInt_t)atoll(Row->GetField(t)); |
| 696 |
|
|
if (t== 5) RUNTRAILER_TIME = (UInt_t)atoll(Row->GetField(t)); |
| 697 |
|
|
if (t== 6) RUNHEADER_OBT = (UInt_t)atoll(Row->GetField(t)); |
| 698 |
|
|
if (t== 7) RUNTRAILER_OBT = (UInt_t)atoll(Row->GetField(t)); |
| 699 |
|
|
if (t== 8) RUNHEADER_PKT = (UInt_t)atoll(Row->GetField(t)); |
| 700 |
|
|
if (t== 9) RUNTRAILER_PKT = (UInt_t)atoll(Row->GetField(t)); |
| 701 |
|
|
if (t==10) EV_FROM = (UInt_t)atoll(Row->GetField(t)); |
| 702 |
|
|
if (t==11) EV_TO = (UInt_t)atoll(Row->GetField(t)); |
| 703 |
|
|
if (t==12) NEVENTS = (UInt_t)atoll(Row->GetField(t)); |
| 704 |
|
|
if (t==13) LAST_TIMESYNC = (UInt_t)atoll(Row->GetField(t)); |
| 705 |
|
|
if (t==14) OBT_TIMESYNC = (UInt_t)atoll(Row->GetField(t)); |
| 706 |
|
|
if (t==15) COMPILATIONTIMESTAMP = (UInt_t)atoll(Row->GetField(t)); |
| 707 |
|
|
if (t==16) FAV_WRK_SCHEDULE = (UInt_t)atoll(Row->GetField(t)); |
| 708 |
|
|
if (t==17) EFF_WRK_SCHEDULE = (UInt_t)atoll(Row->GetField(t)); |
| 709 |
|
|
if (t==18) PRH_VAR_TRG_MODE_A= (UInt_t)atoll(Row->GetField(t)); |
| 710 |
|
|
if (t==19) PRH_VAR_TRG_MODE_B= (UInt_t)atoll(Row->GetField(t)); |
| 711 |
|
|
if (t==20) ACQ_BUILD_INFO = (UInt_t)atoll(Row->GetField(t)); |
| 712 |
|
|
if (t==21) ACQ_VAR_INFO = (UInt_t)atoll(Row->GetField(t)); |
| 713 |
|
|
if (t==22) RM_ACQ_AFTER_CALIB= (UInt_t)atoll(Row->GetField(t)); |
| 714 |
|
|
if (t==23) RM_ACQ_SETTING_MODE = (UInt_t)atoll(Row->GetField(t)); |
| 715 |
|
|
if (t==24) PKT_COUNTER = (UInt_t)atoll(Row->GetField(t)); |
| 716 |
|
|
if (t==25) PKT_READY_COUNTER = (UInt_t)atoll(Row->GetField(t)); |
| 717 |
|
|
if (t==26) TRK_CALIB_USED = (UInt_t)atoll(Row->GetField(t)); |
| 718 |
|
|
if (t==27) CAL_DSP_MASK = (UInt_t)atoll(Row->GetField(t)); |
| 719 |
|
|
if (t==28) BOOT_NUMBER = (UInt_t)atoll(Row->GetField(t)); |
| 720 |
|
|
if (t==29) VALIDATION = (UInt_t)atoll(Row->GetField(t)); |
| 721 |
|
|
}; |
| 722 |
mocchiut |
1.1 |
}; |
| 723 |
mocchiut |
1.2 |
// delete pResult; |
| 724 |
|
|
return(0); |
| 725 |
|
|
};// **************************************************** |
| 726 |
mocchiut |
1.1 |
|
| 727 |
|
|
/** |
| 728 |
|
|
* Function to query the GL_ROOT table of the DB. |
| 729 |
|
|
* |
| 730 |
|
|
* \param entry ID |
| 731 |
|
|
* \return struct of type GL_ROOT_data, which stores the query result |
| 732 |
|
|
*/ |
| 733 |
|
|
Int_t GL_ROOT::Query_GL_ROOT(UInt_t id, TSQLServer *dbc){ |
| 734 |
|
|
// MySQL variables |
| 735 |
|
|
TSQLResult *pResult; |
| 736 |
|
|
TSQLRow *Row; |
| 737 |
|
|
int t; |
| 738 |
|
|
int r; |
| 739 |
|
|
stringstream myquery; |
| 740 |
|
|
// ---------------- |
| 741 |
|
|
myquery.str(""); |
| 742 |
|
|
myquery << "select "; |
| 743 |
|
|
myquery << " ID"; |
| 744 |
|
|
myquery << ",ID_RAW"; |
| 745 |
|
|
myquery << ",ID_TIMESYNC"; |
| 746 |
|
|
myquery << ",PATH"; |
| 747 |
|
|
myquery << ",NAME"; |
| 748 |
|
|
myquery << " from GL_ROOT where ID=" << id << ";"; |
| 749 |
|
|
// |
| 750 |
|
|
pResult = dbc->Query(myquery.str().c_str()); |
| 751 |
|
|
if(!pResult->GetRowCount())return (-51); |
| 752 |
|
|
for( r=0; r < 1000; r++){ |
| 753 |
|
|
Row = pResult->Next(); |
| 754 |
|
|
if( Row == NULL ) break; |
| 755 |
|
|
for( t = 0; t < pResult->GetFieldCount(); t++){ |
| 756 |
|
|
if(t==0) ID = (UInt_t)atoll(Row->GetField(t)); |
| 757 |
|
|
if(t==1) ID_RAW = (UInt_t)atoll(Row->GetField(t)); |
| 758 |
|
|
if(t==2) ID_TIMESYNC = (UInt_t)atoll(Row->GetField(t)); |
| 759 |
|
|
if(t==3) PATH = Row->GetField(t); |
| 760 |
|
|
if(t==4) NAME = Row->GetField(t); |
| 761 |
|
|
}; |
| 762 |
|
|
}; |
| 763 |
|
|
delete pResult; |
| 764 |
|
|
return 0; |
| 765 |
|
|
}; |
| 766 |
|
|
// **************************************************** |
| 767 |
|
|
/** |
| 768 |
|
|
* Function to query the GL_TRK_CALIB table of the DB. |
| 769 |
|
|
* |
| 770 |
|
|
* \param run starting time |
| 771 |
pam-fi |
1.9 |
* \param dbc DB server |
| 772 |
mocchiut |
1.1 |
* \return struct of type GL_TRK_CALIB_data, which stores the query result |
| 773 |
|
|
*/ |
| 774 |
|
|
Int_t GL_TRK_CALIB::Query_GL_TRK_CALIB(UInt_t time, TSQLServer *dbc){ |
| 775 |
|
|
// MySQL variables |
| 776 |
|
|
TSQLResult *pResult; |
| 777 |
|
|
TSQLRow *Row; |
| 778 |
|
|
int t; |
| 779 |
|
|
int r; |
| 780 |
|
|
stringstream myquery; |
| 781 |
|
|
// ---------------- |
| 782 |
|
|
myquery.str(""); |
| 783 |
pam-fi |
1.9 |
myquery << "select ID,ID_ROOT_L0,EV_ROOT_CALIBTRK1,EV_ROOT_CALIBTRK2,FROM_TIME,TO_TIME,OBT1,OBT2,PKT1,PKT2,BOOT_NUMBER,VALIDATION from GL_TRK_CALIB where FROM_TIME <= "<< time; |
| 784 |
mocchiut |
1.1 |
myquery << " AND VALIDATION=1 ORDER BY FROM_TIME DESC LIMIT 1;"; |
| 785 |
|
|
// myquery << " ORDER BY FROM_TIME DESC LIMIT 1;"; |
| 786 |
|
|
pResult = dbc->Query(myquery.str().c_str()); |
| 787 |
|
|
if(!pResult->GetRowCount())return (-53); |
| 788 |
|
|
for( r=0; r < 1000; r++){ |
| 789 |
|
|
Row = pResult->Next(); |
| 790 |
|
|
if( Row == NULL ) break; |
| 791 |
|
|
for( t = 0; t < pResult->GetFieldCount(); t++){ |
| 792 |
mocchiut |
1.2 |
stringstream row; |
| 793 |
|
|
row.str(""); |
| 794 |
|
|
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 |
| 795 |
pam-fi |
1.9 |
if (t==0) ID = (UInt_t)atoll(Row->GetField(t)); |
| 796 |
|
|
if (t==1) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); |
| 797 |
mocchiut |
1.2 |
if (t==2) EV_ROOT_CALIBTRK1 = (UInt_t)atoll(row.str().c_str()); |
| 798 |
|
|
if (t==3) EV_ROOT_CALIBTRK2 = (UInt_t)atoll(row.str().c_str()); |
| 799 |
pam-fi |
1.9 |
if (t==4) FROM_TIME = (UInt_t)atoll(Row->GetField(t)); |
| 800 |
|
|
if (t==5) TO_TIME = (UInt_t)atoll(Row->GetField(t)); |
| 801 |
mocchiut |
1.1 |
// |
| 802 |
pam-fi |
1.9 |
if (t==6) OBT1 = (UInt_t)atoll(Row->GetField(t)); |
| 803 |
|
|
if (t==7) OBT2 = (UInt_t)atoll(Row->GetField(t)); |
| 804 |
|
|
if (t==8) PKT1 = (UInt_t)atoll(Row->GetField(t)); |
| 805 |
|
|
if (t==9) PKT2 = (UInt_t)atoll(Row->GetField(t)); |
| 806 |
|
|
if (t==10) BOOT_NUMBER = (UInt_t)atoll(Row->GetField(t)); |
| 807 |
|
|
if (t==11) VALIDATION = (UInt_t)atoll(Row->GetField(t)); |
| 808 |
|
|
}; |
| 809 |
mocchiut |
1.1 |
}; |
| 810 |
pam-fi |
1.9 |
delete pResult; |
| 811 |
mocchiut |
1.1 |
// |
| 812 |
pam-fi |
1.9 |
// if ( TO_TIME < time ) return(51); |
| 813 |
mocchiut |
1.8 |
// |
| 814 |
mocchiut |
1.1 |
if ( (!OBT1 && !PKT1 ) || (!OBT2 && !PKT2) ) return(52); // ONE CALIBRATION PACKET IS MISSING! |
| 815 |
|
|
// |
| 816 |
|
|
return 0; |
| 817 |
|
|
}; |
| 818 |
|
|
|
| 819 |
|
|
// **************************************************** |
| 820 |
|
|
/** |
| 821 |
|
|
* Function to query the GL_CALO_CALIB table of the DB. |
| 822 |
|
|
* |
| 823 |
|
|
* \param run starting time |
| 824 |
|
|
* \return struct of type GL_CALO_CALIB_data, which stores the query result |
| 825 |
|
|
*/ |
| 826 |
mocchiut |
1.7 |
Int_t GL_CALO_CALIB::Query_GL_CALO_CALIB(UInt_t time, UInt_t &uptime, UInt_t section, TSQLServer *dbc){ |
| 827 |
mocchiut |
1.1 |
// MySQL variables |
| 828 |
|
|
TSQLResult *pResult; |
| 829 |
|
|
TSQLRow *Row; |
| 830 |
|
|
int t; |
| 831 |
|
|
stringstream myquery; |
| 832 |
mocchiut |
1.7 |
uptime = 0; |
| 833 |
mocchiut |
1.1 |
// |
| 834 |
|
|
// select the correct calibration |
| 835 |
|
|
// |
| 836 |
|
|
myquery.str(""); |
| 837 |
|
|
myquery << "select ID_ROOT_L0, FROM_TIME, TO_TIME, EV_ROOT,VALIDATION from GL_CALO_CALIB where SECTION=" << section; |
| 838 |
|
|
myquery << " and FROM_TIME <= " << time; |
| 839 |
|
|
myquery << " and TO_TIME > " << time; |
| 840 |
mocchiut |
1.7 |
myquery << " ;"; |
| 841 |
|
|
//myquery << " and VALIDATION=1;"; |
| 842 |
mocchiut |
1.1 |
// |
| 843 |
|
|
pResult = dbc->Query(myquery.str().c_str()); |
| 844 |
mocchiut |
1.7 |
// printf(" mysquery is %s\n",myquery.str().c_str()); |
| 845 |
|
|
// |
| 846 |
|
|
if( !pResult->GetRowCount() ) return(-54); |
| 847 |
|
|
Row = pResult->Next(); |
| 848 |
|
|
if( Row == NULL ) return (-54); |
| 849 |
|
|
// |
| 850 |
|
|
uptime = (UInt_t)atoll(Row->GetField(2)); |
| 851 |
mocchiut |
1.1 |
// |
| 852 |
|
|
// if it is corrupted validation is 0 and we have no results from the query... |
| 853 |
|
|
// |
| 854 |
mocchiut |
1.7 |
if( atoi(Row->GetField(4)) == 0 ){ // if validation = 0 |
| 855 |
mocchiut |
1.1 |
// |
| 856 |
|
|
// in this case take relax the conditions and take the valid calibration that preceed the correct one |
| 857 |
|
|
// |
| 858 |
|
|
myquery.str(""); |
| 859 |
|
|
myquery << "select ID_ROOT_L0, FROM_TIME, TO_TIME, EV_ROOT,VALIDATION from GL_CALO_CALIB where SECTION=" << section; |
| 860 |
|
|
myquery << " and FROM_TIME <= " << time; |
| 861 |
|
|
myquery << " and VALIDATION=1 ORDER BY FROM_TIME DESC LIMIT 1;"; |
| 862 |
|
|
pResult = dbc->Query(myquery.str().c_str()); |
| 863 |
mocchiut |
1.7 |
// printf(" mysquery is %s\n",myquery.str().c_str()); |
| 864 |
mocchiut |
1.1 |
// |
| 865 |
|
|
// if no results yet quit with error |
| 866 |
|
|
// |
| 867 |
|
|
if( !pResult->GetRowCount() ) return (-54); |
| 868 |
mocchiut |
1.7 |
// |
| 869 |
|
|
Row = pResult->Next(); |
| 870 |
|
|
// |
| 871 |
mocchiut |
1.1 |
}; |
| 872 |
|
|
// |
| 873 |
|
|
// store infos and exit |
| 874 |
|
|
// |
| 875 |
|
|
if( Row == NULL ) return (-54); |
| 876 |
|
|
for( t = 0; t < pResult->GetFieldCount(); t++){ |
| 877 |
|
|
if (t==0) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); |
| 878 |
|
|
if (t==1) FROM_TIME = (UInt_t)atoll(Row->GetField(t)); |
| 879 |
|
|
if (t==2) TO_TIME = (UInt_t)atoll(Row->GetField(t)); |
| 880 |
|
|
if (t==3) EV_ROOT = (UInt_t)atoll(Row->GetField(t)); |
| 881 |
|
|
}; |
| 882 |
|
|
pResult->Delete(); |
| 883 |
|
|
return 0; |
| 884 |
|
|
}; |
| 885 |
|
|
// **************************************************** |
| 886 |
|
|
/** |
| 887 |
|
|
* Function to query the GL_S4_CALIB table of the DB. |
| 888 |
|
|
* |
| 889 |
|
|
* \param run starting time |
| 890 |
|
|
* \return struct of type GL_S4_CALIB_data, which stores the query result |
| 891 |
|
|
*/ |
| 892 |
|
|
Int_t GL_S4_CALIB::Query_GL_S4_CALIB(UInt_t time, TSQLServer *dbc){ |
| 893 |
|
|
// MySQL variables |
| 894 |
|
|
TSQLResult *pResult; |
| 895 |
|
|
TSQLRow *Row; |
| 896 |
|
|
int t; |
| 897 |
|
|
int r; |
| 898 |
|
|
stringstream myquery; |
| 899 |
|
|
// ---------------- |
| 900 |
|
|
myquery.str(""); |
| 901 |
|
|
myquery << "select * from GL_S4_CALIB where FROM_TIME <= "<< time; |
| 902 |
mocchiut |
1.5 |
myquery << " ORDER BY FROM_TIME DESC LIMIT 1;"; |
| 903 |
mocchiut |
1.1 |
// myquery << " ORDER BY FROM_TIME DESC LIMIT 1;"; |
| 904 |
|
|
pResult = dbc->Query(myquery.str().c_str()); |
| 905 |
|
|
if(!pResult->GetRowCount())return (-55);//throw -55; |
| 906 |
|
|
for( r=0; r < 1000; r++){ |
| 907 |
|
|
Row = pResult->Next(); |
| 908 |
|
|
if( Row == NULL ) break; |
| 909 |
|
|
for( t = 0; t < pResult->GetFieldCount(); t++){ |
| 910 |
|
|
if (t==0) ID = (UInt_t)atoll(Row->GetField(t)); |
| 911 |
|
|
if (t==1) ID_ROOT_L0 = (UInt_t)atoll(Row->GetField(t)); |
| 912 |
|
|
if (t==2) EV_ROOT = (UInt_t)atoll(Row->GetField(t)); |
| 913 |
|
|
if (t==3) FROM_TIME = (UInt_t)atoll(Row->GetField(t)); |
| 914 |
|
|
if (t==4) TO_TIME = (UInt_t)atoll(Row->GetField(t)); |
| 915 |
|
|
if (t==5) PARAM_FIT0 = atof(Row->GetField(t)); |
| 916 |
|
|
if (t==6) PARAM_FIT1 = atof(Row->GetField(t)); |
| 917 |
|
|
}; |
| 918 |
|
|
}; |
| 919 |
|
|
delete pResult; |
| 920 |
|
|
// |
| 921 |
|
|
if(TO_TIME < time)return(51); |
| 922 |
|
|
// |
| 923 |
|
|
return 0; |
| 924 |
|
|
}; |
| 925 |
|
|
// **************************************************** |
| 926 |
|
|
/** |
| 927 |
|
|
* Function to query the GL_PARAM table of the DB. |
| 928 |
|
|
* |
| 929 |
|
|
* \param run starting time |
| 930 |
|
|
* \param parameter description (DESCR) |
| 931 |
|
|
* \return struct of type GL_ROOT_data, which stores the query result |
| 932 |
|
|
*/ |
| 933 |
|
|
Int_t GL_PARAM::Query_GL_PARAM(UInt_t time, UInt_t type, TSQLServer *dbc){ |
| 934 |
|
|
// Bool_t debug = 1; |
| 935 |
|
|
// MySQL variables |
| 936 |
|
|
TSQLResult *pResult; |
| 937 |
|
|
TSQLRow *Row; |
| 938 |
|
|
int t; |
| 939 |
|
|
int r; |
| 940 |
|
|
stringstream myquery; |
| 941 |
|
|
// ---------------- |
| 942 |
|
|
myquery.str(""); |
| 943 |
|
|
myquery << " select "; |
| 944 |
|
|
myquery << " ID, PATH, NAME, DESCR, TYPE, FROM_TIME,TO_TIME "; |
| 945 |
|
|
myquery << " from GL_PARAM "; |
| 946 |
|
|
myquery << " where TYPE = '"<<type<<"' "; |
| 947 |
|
|
myquery << " and FROM_TIME <= " << time; |
| 948 |
|
|
myquery << " ORDER BY TO_TIME DESC LIMIT 1;"; |
| 949 |
|
|
// |
| 950 |
|
|
pResult = dbc->Query(myquery.str().c_str()); |
| 951 |
|
|
if(!pResult->GetRowCount())return (-52); |
| 952 |
|
|
for( r=0; r < 1000; r++){ |
| 953 |
|
|
Row = pResult->Next(); |
| 954 |
|
|
if( Row == NULL ) break; |
| 955 |
|
|
for( t = 0; t < pResult->GetFieldCount(); t++){ |
| 956 |
|
|
if (t==0) ID = (UInt_t)atoll(Row->GetField(t)); |
| 957 |
|
|
if (t==1) PATH = Row->GetField(t);// put in fpath the path to that file |
| 958 |
|
|
if (t==2) NAME = Row->GetField(t); |
| 959 |
|
|
if (t==3) DESCR = Row->GetField(t); |
| 960 |
|
|
if (t==4) FROM_TIME = (UInt_t)atoll(Row->GetField(t)); |
| 961 |
|
|
if (t==5) TO_TIME = (UInt_t)atoll(Row->GetField(t)); |
| 962 |
|
|
if (t==6) TYPE = (UInt_t)atoll(Row->GetField(t)); |
| 963 |
|
|
}; |
| 964 |
|
|
}; |
| 965 |
|
|
delete pResult; |
| 966 |
|
|
// |
| 967 |
|
|
if(TO_TIME==0) TO_TIME = numeric_limits<UInt_t>::max(); |
| 968 |
|
|
// |
| 969 |
|
|
if(TO_TIME < time) return(51); |
| 970 |
|
|
// |
| 971 |
|
|
return 0; |
| 972 |
|
|
}; |
| 973 |
|
|
|
| 974 |
|
|
|
| 975 |
|
|
/** |
| 976 |
|
|
* Fills a struct cGLRun with values from a GLRun object (to put data into a F77 common). |
| 977 |
|
|
*/ |
| 978 |
|
|
|
| 979 |
|
|
void GL_RUN::GetLevel2Struct(cGLRun *l2) const{ |
| 980 |
|
|
l2->id = ID; |
| 981 |
|
|
l2->id_reg_run = ID_ROOT_L0; |
| 982 |
|
|
l2->id_reg_run_l2 = ID_ROOT_L2; |
| 983 |
|
|
l2->runheader_time = RUNHEADER_TIME; |
| 984 |
|
|
l2->runtrailer_time = RUNTRAILER_TIME; |
| 985 |
|
|
l2->ev_from = EV_FROM; |
| 986 |
|
|
l2->trk_calib_used = TRK_CALIB_USED; |
| 987 |
|
|
l2->eff_wrk_schedule = EFF_WRK_SCHEDULE; |
| 988 |
|
|
l2->prh_var_trg_mode_a = PRH_VAR_TRG_MODE_A; |
| 989 |
|
|
l2->prh_var_trg_mode_b = PRH_VAR_TRG_MODE_B; |
| 990 |
|
|
l2->acq_build_info = ACQ_BUILD_INFO; |
| 991 |
|
|
l2->acq_var_info = ACQ_VAR_INFO; |
| 992 |
|
|
}; |
| 993 |
|
|
|
| 994 |
|
|
GL_TIMESYNC::GL_TIMESYNC(UInt_t id, TString type, TSQLServer *dbc){ |
| 995 |
|
|
// MySQL variables |
| 996 |
|
|
TFile *file = 0; |
| 997 |
|
|
UInt_t idraw = 0; |
| 998 |
|
|
// |
| 999 |
|
|
TSQLResult *pResult; |
| 1000 |
|
|
TSQLRow *Row; |
| 1001 |
|
|
stringstream myquery; |
| 1002 |
|
|
// ---------------- |
| 1003 |
|
|
myquery.str(""); |
| 1004 |
|
|
myquery << "select "; |
| 1005 |
|
|
myquery << "PATH"; |
| 1006 |
|
|
myquery << ",NAME,ID_RAW"; |
| 1007 |
|
|
myquery << " from GL_ROOT where "; |
| 1008 |
|
|
myquery << type.Data(); |
| 1009 |
|
|
myquery << "=" << id << ";"; |
| 1010 |
|
|
// |
| 1011 |
|
|
pResult = dbc->Query(myquery.str().c_str()); |
| 1012 |
|
|
if( pResult->GetRowCount() ){ |
| 1013 |
|
|
Row = pResult->Next(); |
| 1014 |
|
|
if( Row ){ |
| 1015 |
|
|
stringstream fname; |
| 1016 |
|
|
fname.str(""); |
| 1017 |
|
|
fname << Row->GetField(0) << "/" << Row->GetField(1); |
| 1018 |
|
|
file = new TFile(fname.str().c_str(),"READ"); |
| 1019 |
|
|
idraw = (UInt_t)atoll(Row->GetField(2)); |
| 1020 |
|
|
}; |
| 1021 |
|
|
}; |
| 1022 |
|
|
// |
| 1023 |
|
|
if ( file && file->IsOpen() ){ |
| 1024 |
|
|
TTree *T=(TTree*)file->Get("Physics"); |
| 1025 |
|
|
pamela::EventHeader *eh = 0; |
| 1026 |
|
|
pamela::PscuHeader *ph = 0; |
| 1027 |
|
|
T->SetBranchAddress("Header", &eh); |
| 1028 |
|
|
// |
| 1029 |
|
|
T->GetEntry(0); |
| 1030 |
|
|
ph = eh->GetPscuHeader(); |
| 1031 |
|
|
pktfirst = ph->GetCounter(); |
| 1032 |
|
|
obtfirst = ph->GetOrbitalTime(); |
| 1033 |
|
|
}; |
| 1034 |
|
|
// |
| 1035 |
|
|
// look for Resurs offset |
| 1036 |
|
|
// |
| 1037 |
|
|
UInt_t t0 = 0; |
| 1038 |
|
|
// |
| 1039 |
|
|
myquery.str(""); |
| 1040 |
|
|
myquery << "SELECT OFFSET_DATE FROM GL_RESURS_OFFSET WHERE FROM_ID_RAW<= " |
| 1041 |
|
|
<< idraw << " AND TO_ID_RAW >= " |
| 1042 |
|
|
<< idraw << ";"; |
| 1043 |
|
|
pResult = dbc->Query(myquery.str().c_str()); |
| 1044 |
|
|
if ( pResult ){ |
| 1045 |
|
|
Row = pResult->Next(); |
| 1046 |
|
|
if ( Row ){ |
| 1047 |
|
|
// |
| 1048 |
|
|
t0 = (UInt_t)TDatime(Row->GetField(0)).Convert(); |
| 1049 |
|
|
// |
| 1050 |
|
|
}; |
| 1051 |
|
|
}; |
| 1052 |
|
|
// |
| 1053 |
|
|
// |
| 1054 |
|
|
// look for the correct timesync entry |
| 1055 |
|
|
// |
| 1056 |
|
|
myquery.str(""); |
| 1057 |
|
|
myquery << " SELECT OBT0,TIMESYNC FROM GL_TIMESYNC " |
| 1058 |
|
|
<< " WHERE ID_RAW = " << idraw |
| 1059 |
|
|
<< ";"; |
| 1060 |
|
|
pResult = dbc->Query(myquery.str().c_str()); |
| 1061 |
|
|
if ( pResult ){ |
| 1062 |
|
|
Row = pResult->Next(); |
| 1063 |
|
|
if ( (Row != NULL) && ((UInt_t)atoll(Row->GetField(0)) > 0 ) ){ |
| 1064 |
|
|
toffset = (UInt_t)atoll(Row->GetField(1)) - (UInt_t)(this->DBobt((UInt_t)atoll(Row->GetField(0)))/1000) + t0; |
| 1065 |
|
|
}; |
| 1066 |
|
|
}; |
| 1067 |
mocchiut |
1.3 |
// |
| 1068 |
|
|
file->Close(); |
| 1069 |
mocchiut |
1.1 |
delete pResult; |
| 1070 |
|
|
}; |
| 1071 |
|
|
|
| 1072 |
|
|
/** |
| 1073 |
|
|
* |
| 1074 |
|
|
* Returns the DB absolute time needed to associate calibrations to data |
| 1075 |
|
|
* |
| 1076 |
|
|
*/ |
| 1077 |
|
|
UInt_t GL_TIMESYNC::DBabsTime(UInt_t OBT){ |
| 1078 |
|
|
// |
| 1079 |
|
|
return(((UInt_t)(this->DBobt(OBT)/1000)+toffset)); |
| 1080 |
|
|
// |
| 1081 |
|
|
}; |
| 1082 |
|
|
|
| 1083 |
|
|
|
| 1084 |
|
|
ULong64_t GL_TIMESYNC::DBobt(UInt_t obt){ |
| 1085 |
|
|
// |
| 1086 |
|
|
if ( obt < (obtfirst/2) && obtfirst > (numeric_limits<UInt_t>::max()/2) ) return((ULong64_t)(obt+numeric_limits<UInt_t>::max())); |
| 1087 |
|
|
// |
| 1088 |
|
|
if ( obt > (obtfirst*2) && obt > (numeric_limits<UInt_t>::max()/2) ){ |
| 1089 |
|
|
if ( (obt-numeric_limits<UInt_t>::max()) < 0 ){ |
| 1090 |
|
|
return((ULong64_t)(numeric_limits<UInt_t>::max()-obt)); |
| 1091 |
|
|
} else { |
| 1092 |
|
|
return((ULong64_t)(obt-numeric_limits<UInt_t>::max())); |
| 1093 |
|
|
}; |
| 1094 |
|
|
}; |
| 1095 |
|
|
// |
| 1096 |
|
|
return((ULong64_t)obt); |
| 1097 |
|
|
// |
| 1098 |
|
|
}; |
| 1099 |
|
|
|
| 1100 |
|
|
UInt_t GL_TIMESYNC::DBpkt(UInt_t pkt_num){ |
| 1101 |
|
|
// |
| 1102 |
|
|
if ( pkt_num < (pktfirst/2) && pktfirst > (16777214/2) ) return((pkt_num+16777215)); |
| 1103 |
|
|
// |
| 1104 |
|
|
if ( pkt_num > pktfirst*2 && pkt_num > (16777214/2) ){ |
| 1105 |
|
|
if ( (pkt_num-16777215) < 0 ){ |
| 1106 |
|
|
return((16777215-pkt_num)); |
| 1107 |
|
|
} else { |
| 1108 |
|
|
return((pkt_num-16777215)); |
| 1109 |
|
|
}; |
| 1110 |
|
|
}; |
| 1111 |
|
|
// |
| 1112 |
|
|
return(pkt_num); |
| 1113 |
|
|
// |
| 1114 |
|
|
}; |
| 1115 |
mocchiut |
1.5 |
|
| 1116 |
|
|
/* |
| 1117 |
|
|
* |
| 1118 |
|
|
* Convert the time in the DB from UInt_t to a string |
| 1119 |
|
|
* |
| 1120 |
|
|
* @param dbt time in the DB |
| 1121 |
|
|
* @param tzone Time Zone, can be UTC,GMT,CET,CEST,MSD default is MSK |
| 1122 |
|
|
* |
| 1123 |
|
|
*/ |
| 1124 |
mocchiut |
1.10 |
TString GL_TIMESYNC::ConvertTime(TString &tzone, UInt_t dbt){ |
| 1125 |
mocchiut |
1.5 |
// |
| 1126 |
|
|
TDatime *time = new TDatime(); |
| 1127 |
|
|
TString rtime; |
| 1128 |
mocchiut |
1.10 |
Bool_t found = false; |
| 1129 |
mocchiut |
1.5 |
// |
| 1130 |
mocchiut |
1.11 |
time->Set(dbt,false); // UTC (Coordinated Universal Time) |
| 1131 |
mocchiut |
1.5 |
// |
| 1132 |
mocchiut |
1.11 |
if ( !strcmp(tzone.Data(),"MSK") || !strcmp(tzone.Data(),"MWT") ){ |
| 1133 |
mocchiut |
1.5 |
// |
| 1134 |
mocchiut |
1.11 |
UInt_t timeMSK = time->Convert() + 60*60*3; // UTC (Coordinated Universal Time) + 3hs = Moscow Winter Time |
| 1135 |
|
|
time->Set(timeMSK,false); |
| 1136 |
mocchiut |
1.10 |
found = true; |
| 1137 |
mocchiut |
1.5 |
// |
| 1138 |
|
|
}; |
| 1139 |
|
|
// |
| 1140 |
|
|
if ( !strcmp(tzone.Data(),"CET") ){ |
| 1141 |
|
|
// |
| 1142 |
mocchiut |
1.11 |
UInt_t timeCET = time->Convert() + 60*60*1; // CET (Central European Time) = UTC + 1 hs |
| 1143 |
mocchiut |
1.5 |
time->Set(timeCET,false); |
| 1144 |
mocchiut |
1.10 |
found = true; |
| 1145 |
mocchiut |
1.5 |
// |
| 1146 |
|
|
}; |
| 1147 |
|
|
// |
| 1148 |
|
|
if ( !strcmp(tzone.Data(),"CEST") ){ |
| 1149 |
|
|
// |
| 1150 |
mocchiut |
1.11 |
UInt_t timeCEST = time->Convert() + 60*60*2; // CEST (Central European Summer Time) = UTC + 2 h |
| 1151 |
mocchiut |
1.5 |
time->Set(timeCEST,false); |
| 1152 |
mocchiut |
1.10 |
found = true; |
| 1153 |
mocchiut |
1.5 |
// |
| 1154 |
|
|
}; |
| 1155 |
|
|
// |
| 1156 |
mocchiut |
1.11 |
if ( !strcmp(tzone.Data(),"MSD") || !strcmp(tzone.Data(),"MST")){ |
| 1157 |
mocchiut |
1.5 |
// |
| 1158 |
mocchiut |
1.11 |
UInt_t timeMSD = time->Convert() + 60*60*4; // MSD (Moscow Summer Time) = UTC + 4 h |
| 1159 |
mocchiut |
1.5 |
time->Set(timeMSD,false); |
| 1160 |
mocchiut |
1.10 |
found = true; |
| 1161 |
mocchiut |
1.5 |
// |
| 1162 |
|
|
}; |
| 1163 |
|
|
// |
| 1164 |
mocchiut |
1.11 |
if ( !found && strcmp(tzone.Data(),"UTC") && strcmp(tzone.Data(),"GMT") && strcmp(tzone.Data(),"") ){ |
| 1165 |
|
|
printf("\n Unknown time zone %s using UTC \n",tzone.Data()); |
| 1166 |
|
|
tzone = "UTC"; |
| 1167 |
mocchiut |
1.10 |
}; |
| 1168 |
|
|
// |
| 1169 |
mocchiut |
1.5 |
rtime = time->AsSQLString(); |
| 1170 |
|
|
// |
| 1171 |
|
|
return(rtime); |
| 1172 |
|
|
} |
| 1173 |
mocchiut |
1.6 |
|
| 1174 |
|
|
/* |
| 1175 |
|
|
* |
| 1176 |
|
|
* Convert the time in the DB from UInt_t to a string |
| 1177 |
|
|
* |
| 1178 |
|
|
* @param dbt time in the DB |
| 1179 |
|
|
* @param tzone Time Zone, can be UTC,GMT,CET,CEST,MSD default is MSK |
| 1180 |
|
|
* |
| 1181 |
|
|
*/ |
| 1182 |
mocchiut |
1.10 |
TString GL_TIMESYNC::UnConvertTime(TString &tzone, UInt_t dbt){ |
| 1183 |
mocchiut |
1.6 |
// |
| 1184 |
|
|
TDatime *time = new TDatime(); |
| 1185 |
|
|
TString rtime; |
| 1186 |
|
|
// |
| 1187 |
mocchiut |
1.10 |
Bool_t found = false; |
| 1188 |
|
|
// |
| 1189 |
mocchiut |
1.11 |
time->Set(dbt,false); // tzone |
| 1190 |
mocchiut |
1.6 |
// |
| 1191 |
mocchiut |
1.11 |
if ( !strcmp(tzone.Data(),"MSK") || !strcmp(tzone.Data(),"MWT") ){ |
| 1192 |
mocchiut |
1.6 |
// |
| 1193 |
mocchiut |
1.11 |
UInt_t timeUTC = time->Convert() - 60*60*3; // UTC (Coordinated Universal Time) = Moscow Winter Time - 3hs |
| 1194 |
mocchiut |
1.6 |
time->Set(timeUTC,false); |
| 1195 |
mocchiut |
1.10 |
found = true; |
| 1196 |
mocchiut |
1.6 |
// |
| 1197 |
|
|
}; |
| 1198 |
|
|
// |
| 1199 |
|
|
if ( !strcmp(tzone.Data(),"CET") ){ |
| 1200 |
|
|
// |
| 1201 |
mocchiut |
1.11 |
UInt_t timeCET = time->Convert() - 60*60*1; // CET (Central European Time) - 1 hs = UTC |
| 1202 |
mocchiut |
1.6 |
time->Set(timeCET,false); |
| 1203 |
mocchiut |
1.10 |
found = true; |
| 1204 |
mocchiut |
1.6 |
// |
| 1205 |
|
|
}; |
| 1206 |
|
|
// |
| 1207 |
|
|
if ( !strcmp(tzone.Data(),"CEST") ){ |
| 1208 |
|
|
// |
| 1209 |
mocchiut |
1.11 |
UInt_t timeCEST = time->Convert() - 60*60*2; // CEST (Central European Summer Time) - 2 h = UTC |
| 1210 |
mocchiut |
1.6 |
time->Set(timeCEST,false); |
| 1211 |
mocchiut |
1.10 |
found = true; |
| 1212 |
mocchiut |
1.6 |
// |
| 1213 |
|
|
}; |
| 1214 |
|
|
// |
| 1215 |
mocchiut |
1.10 |
if ( !strcmp(tzone.Data(),"MSD") || !strcmp(tzone.Data(),"MST") ){ |
| 1216 |
mocchiut |
1.6 |
// |
| 1217 |
mocchiut |
1.11 |
UInt_t timeMSD = time->Convert() - 60*60*4; // MSD (Moscow Summer Time) - 4 h = UTC |
| 1218 |
mocchiut |
1.6 |
time->Set(timeMSD,false); |
| 1219 |
mocchiut |
1.10 |
found = true; |
| 1220 |
|
|
// |
| 1221 |
|
|
}; |
| 1222 |
|
|
// |
| 1223 |
mocchiut |
1.11 |
if ( !found && strcmp(tzone.Data(),"UTC") && strcmp(tzone.Data(),"GMT") && strcmp(tzone.Data(),"") ){ |
| 1224 |
mocchiut |
1.6 |
// |
| 1225 |
mocchiut |
1.11 |
printf("\n Unknown time zone %s using UTC \n",tzone.Data()); |
| 1226 |
|
|
tzone = "UTC"; |
| 1227 |
mocchiut |
1.6 |
}; |
| 1228 |
|
|
// |
| 1229 |
|
|
rtime = time->AsSQLString(); |
| 1230 |
|
|
// |
| 1231 |
|
|
return(rtime); |
| 1232 |
|
|
} |
| 1233 |
mocchiut |
1.12 |
|
| 1234 |
|
|
|
| 1235 |
|
|
// **************************************************** |
| 1236 |
|
|
/** |
| 1237 |
|
|
* Function to query the GL_TLE table of the DB. |
| 1238 |
|
|
* |
| 1239 |
|
|
* time is the unix time for which a good tle is requested. |
| 1240 |
|
|
* |
| 1241 |
|
|
* Return the pointer to a cTle object that has the closest and |
| 1242 |
|
|
* previous date compared with time. |
| 1243 |
|
|
* |
| 1244 |
|
|
* If errors occurs it returns NULL. |
| 1245 |
|
|
*/ |
| 1246 |
|
|
cTle* GL_TLE::Query_GL_TLE(UInt_t time, TSQLServer *dbc){ |
| 1247 |
|
|
stringstream myquery; |
| 1248 |
|
|
myquery.str(""); |
| 1249 |
|
|
|
| 1250 |
|
|
myquery << "SELECT TLE1, TLE2, TLE3 FROM GL_TLE " |
| 1251 |
|
|
<< "WHERE FROM_TIME < FROM_UNIXTIME(" << time << ") ORDER BY FROM_TIME DESC LIMIT 1;"; |
| 1252 |
|
|
|
| 1253 |
|
|
|
| 1254 |
|
|
return Query_GL_TLE_go(myquery.str(), dbc); |
| 1255 |
|
|
} |
| 1256 |
|
|
|
| 1257 |
|
|
|
| 1258 |
|
|
// **************************************************** |
| 1259 |
|
|
/** |
| 1260 |
|
|
* Function to query the GL_TLE table of the DB. |
| 1261 |
|
|
* |
| 1262 |
|
|
* date is a datetime format YYYY-MM-DD hh:mm:ss for which a good tle |
| 1263 |
|
|
* is requested. |
| 1264 |
|
|
* |
| 1265 |
|
|
* Return the pointer to a cTle object that has the closest and |
| 1266 |
|
|
* previous date compared with time. |
| 1267 |
|
|
* |
| 1268 |
|
|
* If errors occurs it returns NULL. |
| 1269 |
|
|
*/ |
| 1270 |
|
|
cTle* GL_TLE::Query_GL_TLE(TString date, TSQLServer *dbc){ |
| 1271 |
|
|
stringstream myquery; |
| 1272 |
|
|
myquery.str(""); |
| 1273 |
|
|
|
| 1274 |
|
|
myquery << "SELECT TLE1, TLE2, TLE3 FROM GL_TLE " |
| 1275 |
|
|
<< "WHERE FROM_TIME < '" << date.Data() << "' ORDER BY FROM_TIME DESC LIMIT 1;"; |
| 1276 |
|
|
|
| 1277 |
|
|
|
| 1278 |
|
|
return Query_GL_TLE_go(myquery.str(), dbc); |
| 1279 |
|
|
} |
| 1280 |
|
|
|
| 1281 |
|
|
|
| 1282 |
|
|
// **************************************************** |
| 1283 |
|
|
/** |
| 1284 |
|
|
* Private function used by Query_GL_TLE methods. |
| 1285 |
|
|
* |
| 1286 |
|
|
* myquery is the query string. |
| 1287 |
|
|
* |
| 1288 |
|
|
* Return the pointer to a cTle object that has the closest and |
| 1289 |
|
|
* previous date compared with time. |
| 1290 |
|
|
* |
| 1291 |
|
|
* If errors occurs it returns NULL. |
| 1292 |
|
|
*/ |
| 1293 |
|
|
cTle* GL_TLE::Query_GL_TLE_go(TString myquery, TSQLServer *dbc){ |
| 1294 |
|
|
cTle *tle; |
| 1295 |
|
|
string tle1, tle2, tle3; |
| 1296 |
|
|
|
| 1297 |
|
|
// MySQL variables |
| 1298 |
|
|
TSQLResult *result; |
| 1299 |
|
|
TSQLRow *row; |
| 1300 |
|
|
|
| 1301 |
|
|
result = dbc->Query(myquery.Data()); |
| 1302 |
|
|
if(! result->GetRowCount() ) return NULL; |
| 1303 |
|
|
|
| 1304 |
|
|
row = result->Next(); |
| 1305 |
|
|
tle1 = row->GetField(0); |
| 1306 |
|
|
tle2 = row->GetField(1); |
| 1307 |
|
|
tle3 = row->GetField(2); |
| 1308 |
|
|
|
| 1309 |
|
|
tle = new cTle(tle1, tle2, tle3); |
| 1310 |
|
|
|
| 1311 |
|
|
delete result; |
| 1312 |
|
|
delete row; |
| 1313 |
|
|
|
| 1314 |
|
|
return tle; |
| 1315 |
|
|
} |