1 |
mocchiut |
1.1 |
#ifndef PAMELA_DB_OPERATIONS_H |
2 |
|
|
#define PAMELA_DB_OPERATIONS_H |
3 |
|
|
|
4 |
|
|
#include <iostream> |
5 |
|
|
#include <list> |
6 |
mocchiut |
1.6 |
|
7 |
mocchiut |
1.17 |
#include <TFile.h> |
8 |
mocchiut |
1.1 |
#include <TSQLServer.h> |
9 |
|
|
#include <EventHeader.h> |
10 |
|
|
#include <PscuHeader.h> |
11 |
|
|
#include <mcmd/McmdEvent.h> |
12 |
|
|
#include <mcmd/McmdRecord.h> |
13 |
|
|
#include <RunHeaderEvent.h> |
14 |
|
|
#include <RunTrailerEvent.h> |
15 |
|
|
#include <CalibCalPedEvent.h> |
16 |
|
|
#include <CalibS4Event.h> |
17 |
|
|
#include <CalibTrk1Event.h> |
18 |
|
|
#include <CalibTrk2Event.h> |
19 |
|
|
#include <varDump/VarDumpEvent.h> |
20 |
|
|
#include <varDump/VarDumpRecord.h> |
21 |
|
|
#include <physics/S4/S4Event.h> |
22 |
mocchiut |
1.6 |
|
23 |
mocchiut |
1.1 |
#include <GLTables.h> |
24 |
|
|
|
25 |
mocchiut |
1.8 |
#include <sgp4.h> |
26 |
mocchiut |
1.6 |
|
27 |
mocchiut |
1.1 |
using namespace pamela; |
28 |
|
|
|
29 |
|
|
/** |
30 |
|
|
* Collections of Pamela specific operations over a database |
31 |
|
|
*/ |
32 |
|
|
class PamelaDBOperations { |
33 |
|
|
|
34 |
|
|
private: |
35 |
|
|
TSQLServer *conn; |
36 |
|
|
TFile *file; |
37 |
|
|
// |
38 |
|
|
RunHeaderEvent *runh; |
39 |
|
|
EventHeader *ehh; |
40 |
|
|
PscuHeader *phh; |
41 |
|
|
RunTrailerEvent *runt; |
42 |
|
|
EventHeader *eht; |
43 |
|
|
PscuHeader *pht; |
44 |
|
|
// |
45 |
|
|
GL_RUN *glrun; |
46 |
|
|
// |
47 |
|
|
TString filerawname; |
48 |
|
|
TString filerootname; |
49 |
|
|
// |
50 |
|
|
UInt_t tsync; |
51 |
|
|
UInt_t toffset; |
52 |
|
|
// |
53 |
mocchiut |
1.7 |
// Long64_t olderthan; |
54 |
|
|
UInt_t dworbit; |
55 |
mocchiut |
1.2 |
// |
56 |
mocchiut |
1.1 |
UInt_t BOOTNO; |
57 |
|
|
UInt_t obt0; |
58 |
|
|
UInt_t id; |
59 |
|
|
UInt_t idroot; |
60 |
|
|
UInt_t pktfirst; |
61 |
mocchiut |
1.10 |
UInt_t obtfirst; |
62 |
mocchiut |
1.14 |
UInt_t ppktfirst; |
63 |
|
|
UInt_t pobtfirst; |
64 |
mocchiut |
1.10 |
Long64_t upperobt; |
65 |
|
|
Long64_t upperpkt; |
66 |
mocchiut |
1.1 |
UInt_t upperentry; |
67 |
|
|
Int_t rtev; |
68 |
|
|
Int_t rhev; |
69 |
|
|
// |
70 |
|
|
// calibration variables |
71 |
|
|
// |
72 |
|
|
Int_t t1; |
73 |
|
|
Int_t t2; |
74 |
|
|
UInt_t fromtime; |
75 |
|
|
UInt_t obt1; |
76 |
|
|
UInt_t pkt1; |
77 |
|
|
UInt_t obt2; |
78 |
|
|
UInt_t pkt2; |
79 |
|
|
UInt_t valid; |
80 |
|
|
// |
81 |
|
|
// |
82 |
|
|
Bool_t NOBOOT; |
83 |
|
|
Bool_t debug; |
84 |
mocchiut |
1.6 |
|
85 |
|
|
// Path to tle file |
86 |
|
|
TString tlefilename; |
87 |
pam-fi |
1.4 |
|
88 |
mocchiut |
1.7 |
// flag to control profiler actions |
89 |
mocchiut |
1.15 |
Bool_t STATIC; |
90 |
mocchiut |
1.7 |
Bool_t INSERT_RAW; |
91 |
|
|
Bool_t INSERT_ROOT; |
92 |
|
|
Bool_t VALIDATE; |
93 |
mocchiut |
1.9 |
Bool_t NOFRAG; |
94 |
mocchiut |
1.10 |
Bool_t AUTOBOOT; |
95 |
mocchiut |
1.7 |
|
96 |
|
|
TDatime *clean_time; |
97 |
|
|
|
98 |
mocchiut |
1.1 |
// |
99 |
|
|
typedef std::list<const char*> pcksList; |
100 |
|
|
static void getPacketsNames(pcksList &pcksNames){ |
101 |
|
|
pcksNames.push_back("PhysEndRun"); |
102 |
|
|
pcksNames.push_back("CalibCalPulse1"); |
103 |
|
|
pcksNames.push_back("CalibCalPulse2"); |
104 |
|
|
pcksNames.push_back("Physics"); |
105 |
|
|
pcksNames.push_back("CalibTrkBoth"); |
106 |
|
|
pcksNames.push_back("CalibTrk1"); |
107 |
|
|
pcksNames.push_back("CalibTrk2"); |
108 |
|
|
pcksNames.push_back("CalibTof"); |
109 |
|
|
pcksNames.push_back("CalibS4"); |
110 |
|
|
pcksNames.push_back("CalibCalPed"); |
111 |
|
|
pcksNames.push_back("Calib1_Ac1"); |
112 |
|
|
pcksNames.push_back("Calib2_Ac1"); |
113 |
|
|
pcksNames.push_back("Calib1_Ac2"); |
114 |
|
|
pcksNames.push_back("Calib2_Ac2"); |
115 |
|
|
pcksNames.push_back("CalibCal"); |
116 |
|
|
pcksNames.push_back("RunHeader"); |
117 |
|
|
pcksNames.push_back("RunTrailer"); |
118 |
|
|
pcksNames.push_back("CalibHeader"); |
119 |
|
|
pcksNames.push_back("CalibTrailer"); |
120 |
|
|
pcksNames.push_back("InitHeader"); |
121 |
|
|
pcksNames.push_back("InitTrailer"); |
122 |
|
|
pcksNames.push_back("EventTrk"); |
123 |
|
|
pcksNames.push_back("Log"); |
124 |
|
|
pcksNames.push_back("VarDump"); |
125 |
|
|
pcksNames.push_back("ArrDump"); |
126 |
|
|
pcksNames.push_back("TabDump"); |
127 |
|
|
pcksNames.push_back("Tmtc"); |
128 |
|
|
pcksNames.push_back("Mcmd"); |
129 |
|
|
pcksNames.push_back("ForcedFECmd"); |
130 |
|
|
pcksNames.push_back("Ac1Init"); |
131 |
|
|
pcksNames.push_back("CalInit"); |
132 |
|
|
pcksNames.push_back("TrkInit"); |
133 |
|
|
pcksNames.push_back("TofInit"); |
134 |
|
|
pcksNames.push_back("TrgInit"); |
135 |
|
|
pcksNames.push_back("NdInit"); |
136 |
|
|
pcksNames.push_back("S4Init"); |
137 |
|
|
pcksNames.push_back("Ac2Init"); |
138 |
|
|
pcksNames.push_back("CalAlarm"); |
139 |
|
|
pcksNames.push_back("Ac1Alarm"); |
140 |
|
|
pcksNames.push_back("TrkAlarm"); |
141 |
|
|
pcksNames.push_back("TrgAlarm"); |
142 |
|
|
pcksNames.push_back("TofAlarm"); |
143 |
|
|
pcksNames.push_back("S4Alarm"); |
144 |
|
|
pcksNames.push_back("Ac2Alarm"); |
145 |
|
|
pcksNames.push_back("TsbT"); |
146 |
|
|
pcksNames.push_back("TsbB"); |
147 |
|
|
}; |
148 |
|
|
// |
149 |
|
|
// Functions |
150 |
|
|
// |
151 |
|
|
void HandleRun(); |
152 |
|
|
void HandleRunFragments(Bool_t mishead, Bool_t mistrail, UInt_t firstev, UInt_t lastev); |
153 |
|
|
void HandleMissingHoT(Bool_t mishead, Bool_t mistrail, UInt_t firstev, UInt_t lastev); |
154 |
|
|
void HandleSuspiciousRun(); |
155 |
|
|
void FillClass(); |
156 |
|
|
void FillClass(Bool_t mishead, Bool_t mistrail, UInt_t firstev, UInt_t lastev); |
157 |
|
|
void HandleTRK_CALIB(Bool_t pk1, Bool_t pk2); |
158 |
|
|
// |
159 |
mocchiut |
1.9 |
void RemoveCALIBS(); |
160 |
|
|
void ValidationOFF(); |
161 |
|
|
void ReArrangeRUNS(); |
162 |
|
|
void RemoveRUNS(); |
163 |
|
|
void RemoveFILES(); |
164 |
|
|
// |
165 |
mocchiut |
1.1 |
Bool_t IsDebug(){return(debug);}; |
166 |
|
|
Bool_t IsRunAlreadyInserted(); |
167 |
|
|
Bool_t IsRunConsistent(Bool_t mishead, Bool_t mistrail, UInt_t &firstev, UInt_t &lastev); |
168 |
mocchiut |
1.10 |
Bool_t AutoBoot(){return(AUTOBOOT);}; |
169 |
mocchiut |
1.5 |
// |
170 |
|
|
Bool_t MissingTRK_CALIB(UInt_t t1,UInt_t t2); |
171 |
|
|
// |
172 |
mocchiut |
1.10 |
Long64_t PKT(UInt_t pkt_num); |
173 |
mocchiut |
1.1 |
// |
174 |
mocchiut |
1.10 |
Long64_t OBT(UInt_t obt); |
175 |
mocchiut |
1.1 |
// |
176 |
mocchiut |
1.7 |
UInt_t AssignRunID(); |
177 |
mocchiut |
1.1 |
|
178 |
mocchiut |
1.6 |
// GL_TLE related functions |
179 |
|
|
int insertTle(cTle*); |
180 |
|
|
bool isTlePresent(cTle*); |
181 |
|
|
|
182 |
mocchiut |
1.1 |
public: |
183 |
|
|
// |
184 |
mocchiut |
1.16 |
PamelaDBOperations(TString host, TString user, TString password, TString filerawname, TString filerootname, UInt_t boot, UInt_t tsync, UInt_t obt0, Bool_t debug, TString tlefilename,UInt_t dwinput, Bool_t staticp, Bool_t gpamela); // constructor |
185 |
mocchiut |
1.1 |
// |
186 |
|
|
void Close(); // destructor |
187 |
|
|
// |
188 |
|
|
// |
189 |
|
|
// Setters |
190 |
|
|
// |
191 |
|
|
void SetConnection(TString host, TString user, TString password); |
192 |
|
|
void SetBOOTnumber(UInt_t boot); |
193 |
mocchiut |
1.16 |
void SetBOOTnumber(UInt_t boot, Bool_t gpamela); |
194 |
mocchiut |
1.1 |
void SetRawName(TString str); |
195 |
|
|
void SetRootName(TString str); |
196 |
|
|
void SetDebugFlag(Bool_t debug); |
197 |
|
|
void SetID_RAW(UInt_t idr); |
198 |
|
|
void SetID_ROOT(UInt_t idr); |
199 |
|
|
void SetTsync(UInt_t ts); |
200 |
mocchiut |
1.16 |
void SetTsync(UInt_t ts, Bool_t gpamela); |
201 |
mocchiut |
1.1 |
void SetObt0(UInt_t ts); |
202 |
|
|
void SetCommonGLRUN(UInt_t absth, UInt_t abstt); |
203 |
|
|
void SetNOBOOT(Bool_t noboot); |
204 |
mocchiut |
1.2 |
void SetOlderThan(Long64_t oldthan); |
205 |
mocchiut |
1.6 |
void SetTLEPath(TString str); |
206 |
mocchiut |
1.13 |
void SetOrbitNo(UInt_t dwinput); |
207 |
mocchiut |
1.9 |
void SetNoFrag(Bool_t nf); |
208 |
mocchiut |
1.10 |
void SetAutoBoot(Bool_t nf); |
209 |
mocchiut |
1.1 |
// |
210 |
|
|
Bool_t SetID_RAW(); |
211 |
|
|
// |
212 |
|
|
Int_t SetUpperLimits(); |
213 |
|
|
// |
214 |
|
|
// Getters |
215 |
|
|
// |
216 |
|
|
Bool_t GetNOBOOT(){return(NOBOOT);}; |
217 |
|
|
// |
218 |
|
|
UInt_t GetID_RAW(){return(id);}; |
219 |
|
|
UInt_t GetID_ROOT(){return(idroot);}; |
220 |
|
|
UInt_t GetBOOTnumber(){return(BOOTNO);}; |
221 |
|
|
// |
222 |
|
|
UInt_t GetAbsTime(UInt_t obt); |
223 |
|
|
UInt_t GetTsync(){return(tsync);}; |
224 |
|
|
// |
225 |
|
|
const PacketType* GetPacketType(const char* type); |
226 |
|
|
// |
227 |
|
|
TString GetRawFile(){return((TString)gSystem->BaseName(filerawname.Data()));}; |
228 |
|
|
TString GetRootFile(){return((TString)gSystem->BaseName(filerootname.Data()));}; |
229 |
|
|
TString GetRootName(){return(filerootname);}; |
230 |
|
|
TString GetRawName(){return(filerawname);}; |
231 |
mocchiut |
1.15 |
TString GetRawPath(); |
232 |
|
|
TString GetRootPath(); |
233 |
pam-fi |
1.4 |
|
234 |
mocchiut |
1.9 |
const char* GetCleanTime(){return clean_time->AsSQLString();}; |
235 |
mocchiut |
1.1 |
// |
236 |
|
|
// Functions |
237 |
|
|
// |
238 |
|
|
Int_t assignBOOT_NUMBER(); |
239 |
|
|
Int_t insertPamelaRootFile(); |
240 |
|
|
Int_t insertPamelaRawFile(); |
241 |
|
|
Int_t insertPamelaGL_TIMESYNC(); |
242 |
|
|
Int_t insertPamelaRUN(); |
243 |
|
|
Int_t insertCALO_CALIB(); |
244 |
|
|
Int_t insertTRK_CALIB(); |
245 |
|
|
Int_t insertS4_CALIB(); |
246 |
mocchiut |
1.2 |
Int_t CleanGL_RUN_FRAGMENTS(); |
247 |
mocchiut |
1.9 |
Int_t CleanGL_RUN_FRAGMENTS(TString fcleanfile); |
248 |
mocchiut |
1.2 |
Int_t ValidateRuns(); |
249 |
mocchiut |
1.9 |
Int_t ValidateRuns(TString valfile); |
250 |
mocchiut |
1.5 |
Int_t assignVALIDATION(UInt_t ,Bool_t ); |
251 |
mocchiut |
1.9 |
Int_t removeFile(TString rootfilename); |
252 |
mocchiut |
1.5 |
// |
253 |
|
|
// void OpenFile(); |
254 |
|
|
void CheckValidate(Long64_t olderthan); |
255 |
pam-fi |
1.4 |
void CheckConnection(); |
256 |
mocchiut |
1.5 |
void CheckFile(); |
257 |
mocchiut |
1.1 |
// |
258 |
pam-fi |
1.4 |
|
259 |
mocchiut |
1.9 |
Bool_t NoFrag(){return(NOFRAG);}; |
260 |
mocchiut |
1.6 |
Bool_t InsertRoot(){return(INSERT_ROOT);}; |
261 |
|
|
Bool_t InsertRaw(){return(INSERT_RAW);}; |
262 |
|
|
Bool_t Validate(){return(VALIDATE);}; |
263 |
|
|
|
264 |
|
|
// Functions for TLE |
265 |
|
|
Int_t populateTLE(); |
266 |
pam-fi |
1.11 |
|
267 |
|
|
UInt_t ValidateTrkCalib( CalibTrk1Event* calibtrk , EventHeader* h); |
268 |
|
|
UInt_t ValidateTrkCalib( CalibTrk2Event* calibtrk , EventHeader* h){return ValidateTrkCalib((CalibTrk1Event*)calibtrk,h); }; |
269 |
mocchiut |
1.12 |
|
270 |
|
|
UInt_t Check(); |
271 |
pam-fi |
1.4 |
|
272 |
mocchiut |
1.1 |
}; |
273 |
|
|
#endif /* PAMELA_DB_OPERATIONS_H */ |