/[PAMELA software]/chewbacca/YodaProfiler/inc/PamelaDBOperations.h
ViewVC logotype

Contents of /chewbacca/YodaProfiler/inc/PamelaDBOperations.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (show annotations) (download)
Fri Nov 7 08:56:12 2008 UTC (16 years, 1 month ago) by mocchiut
Branch: MAIN
Changes since 1.4: +1 -1 lines
File MIME type: text/plain
Some bugs fixed

1 #ifndef PAMELA_DB_OPERATIONS_H
2 #define PAMELA_DB_OPERATIONS_H
3
4 #include <iostream>
5 #include <list>
6
7 #include <TFile.h>
8 #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 #include <endrun/PhysEndRunEvent.h>
23 #include <endrun/TBEndRun.h>
24
25 #include <GLTables.h>
26
27 #include <sgp4.h>
28
29 using namespace pamela;
30
31 /**
32 * Collections of Pamela specific operations over a database
33 */
34 class PamelaDBOperations {
35
36 private:
37 TSQLServer *conn;
38 TFile *file;
39 //
40 RunHeaderEvent *runh;
41 EventHeader *ehh;
42 PscuHeader *phh;
43 RunTrailerEvent *runt;
44 EventHeader *eht;
45 PscuHeader *pht;
46 //
47 GL_RUN *glrun;
48 //
49 TString filerawname;
50 TString filerootname;
51 //
52 UInt_t tsync;
53 UInt_t toffset;
54 //
55 // Long64_t olderthan;
56 UInt_t dworbit;
57 //
58 UInt_t BOOTNO;
59 UInt_t obt0;
60 UInt_t id;
61 UInt_t idroot;
62 UInt_t pktfirst;
63 UInt_t obtfirst;
64 UInt_t ppktfirst;
65 UInt_t pobtfirst;
66 Long64_t upperobt;
67 Long64_t upperpkt;
68 UInt_t upperentry;
69 Int_t rtev;
70 Int_t rhev;
71 Int_t nrtev;
72 Int_t nrhev;
73 //
74 // calibration variables
75 //
76 Int_t t1;
77 Int_t t2;
78 UInt_t fromtime;
79 UInt_t obt1;
80 UInt_t pkt1;
81 UInt_t obt2;
82 UInt_t pkt2;
83 UInt_t valid;
84 //
85 //
86 Bool_t NOBOOT;
87 Bool_t debug;
88
89 // Path to tle file
90 TString tlefilename;
91
92 // flag to control profiler actions
93 Bool_t STATIC;
94 Bool_t KEEPENV;
95 Bool_t INSERT_RAW;
96 Bool_t INSERT_ROOT;
97 Bool_t VALIDATE;
98 Bool_t NOFRAG;
99 Bool_t AUTOBOOT;
100 Bool_t PEDANTIC;
101
102 // flags and variables for chewbacca
103 Bool_t chewbacca;
104 UInt_t chID;
105 //
106 TString tag;
107 TString chiby;
108 //
109 UInt_t chpktinit;
110 UInt_t chpktfinal;
111 UInt_t chobtinit;
112 UInt_t chobtfinal;
113 Int_t nrhbef;
114 Int_t nrhaf;
115 Int_t nrtbef;
116 Int_t nrtaf;
117 //
118 UInt_t chpktmin;
119 UInt_t chpktmax;
120 UInt_t chobtmin;
121 UInt_t chobtmax;
122 UInt_t chobtts;
123 UInt_t chlastts;
124 UInt_t chresursts;
125 UInt_t chboot;
126 UInt_t chminentry;
127
128 TDatime *clean_time;
129
130 //
131 typedef std::list<const char*> pcksList;
132 static void getPacketsNames(pcksList &pcksNames){
133 pcksNames.push_back("PhysEndRun");
134 pcksNames.push_back("CalibCalPulse1");
135 pcksNames.push_back("CalibCalPulse2");
136 pcksNames.push_back("Physics");
137 pcksNames.push_back("CalibTrkBoth");
138 pcksNames.push_back("CalibTrk1");
139 pcksNames.push_back("CalibTrk2");
140 pcksNames.push_back("CalibTof");
141 pcksNames.push_back("CalibS4");
142 pcksNames.push_back("CalibCalPed");
143 pcksNames.push_back("Calib1_Ac1");
144 pcksNames.push_back("Calib2_Ac1");
145 pcksNames.push_back("Calib1_Ac2");
146 pcksNames.push_back("Calib2_Ac2");
147 pcksNames.push_back("CalibCal");
148 pcksNames.push_back("RunHeader");
149 pcksNames.push_back("RunTrailer");
150 pcksNames.push_back("CalibHeader");
151 pcksNames.push_back("CalibTrailer");
152 pcksNames.push_back("InitHeader");
153 pcksNames.push_back("InitTrailer");
154 pcksNames.push_back("EventTrk");
155 pcksNames.push_back("Log");
156 pcksNames.push_back("VarDump");
157 pcksNames.push_back("ArrDump");
158 pcksNames.push_back("TabDump");
159 pcksNames.push_back("Tmtc");
160 pcksNames.push_back("Mcmd");
161 pcksNames.push_back("ForcedFECmd");
162 pcksNames.push_back("Ac1Init");
163 pcksNames.push_back("CalInit");
164 pcksNames.push_back("TrkInit");
165 pcksNames.push_back("TofInit");
166 pcksNames.push_back("TrgInit");
167 pcksNames.push_back("NdInit");
168 pcksNames.push_back("S4Init");
169 pcksNames.push_back("Ac2Init");
170 pcksNames.push_back("CalAlarm");
171 pcksNames.push_back("Ac1Alarm");
172 pcksNames.push_back("TrkAlarm");
173 pcksNames.push_back("TrgAlarm");
174 pcksNames.push_back("TofAlarm");
175 pcksNames.push_back("S4Alarm");
176 pcksNames.push_back("Ac2Alarm");
177 pcksNames.push_back("TsbT");
178 pcksNames.push_back("TsbB");
179 };
180 //
181 // Functions
182 //
183 void HandleRun();
184 void HandleRunFragments(Bool_t mishead, Bool_t mistrail, UInt_t firstev, UInt_t lastev);
185 void HandleMissingHoT(Bool_t mishead, Bool_t mistrail, UInt_t firstev, UInt_t lastev);
186 void HandleSuspiciousRun();
187 void FillClass();
188 void FillClass(Bool_t mishead, Bool_t mistrail, Int_t firstev, Int_t lastev);
189 void HandleTRK_CALIB(Bool_t pk1, Bool_t pk2);
190 void HandleTRK_CALIB(GL_TRK_CALIB*);
191 //
192 void RemoveCALIBS();
193 void ValidationOFF();
194 void ReArrangeRUNS();
195 void RemoveRUNS();
196 void RemoveFILES(UInt_t idtsy);
197 //
198 Bool_t IsDebug(){return(debug);};
199 Bool_t IsRunAlreadyInserted();
200 Bool_t IsRunConsistent(Bool_t mishead, Bool_t mistrail, UInt_t &firstev, UInt_t &lastev);
201 Bool_t AutoBoot(){return(AUTOBOOT);};
202 //
203 Bool_t MissingTRK_CALIB(UInt_t t1,UInt_t t2);
204 //
205 Long64_t PKT(UInt_t pkt_num);
206 //
207 Long64_t OBT(UInt_t obt);
208 //
209 UInt_t AssignRunID();
210
211 // GL_TLE related functions
212 int insertTle(cTle*);
213 bool isTlePresent(cTle*);
214
215 public:
216 //
217 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, Bool_t keepenv); // constructor
218 //
219 void Close(); // destructor
220 //
221 //
222 // Setters
223 //
224 void SetConnection(TString host, TString user, TString password);
225 void SetBOOTnumber(UInt_t boot);
226 void SetBOOTnumber(UInt_t boot, Bool_t gpamela);
227 void SetRawName(TString str);
228 void SetRootName(TString str);
229 void SetDebugFlag(Bool_t debug);
230 void SetID_RAW(UInt_t idr);
231 void SetID_ROOT(UInt_t idr);
232 void SetTsync(UInt_t ts);
233 void SetTsync(UInt_t ts, Bool_t gpamela);
234 void SetObt0(UInt_t ts);
235 void SetCommonGLRUN(UInt_t absth, UInt_t abstt);
236 void SetNOBOOT(Bool_t noboot);
237 void SetOlderThan(Long64_t oldthan);
238 void SetTLEPath(TString str);
239 void SetOrbitNo(UInt_t dwinput);
240 void SetNoFrag(Bool_t nf);
241 void SetAutoBoot(Bool_t nf);
242 void SetPedantic(Bool_t pd);
243 void SetPhysEndRunVariables();
244 //
245 void SetTag(TString ntag){tag=ntag;};
246 //
247 Bool_t SetID_RAW();
248 //
249 Int_t SetUpperLimits();
250 void OpenL0File(TString filerootname);
251 //
252 // Getters
253 //
254 Bool_t GetNOBOOT(){return(NOBOOT);};
255 //
256 UInt_t GetID_RAW(){return(id);};
257 UInt_t GetID_ROOT(){return(idroot);};
258 UInt_t GetBOOTnumber(){return(BOOTNO);};
259 //
260 UInt_t GetAbsTime(UInt_t obt);
261 UInt_t GetTsync(){return(tsync);};
262 //
263 const PacketType* GetPacketType(const char* type);
264 //
265 TString GetRawFile(){return((TString)gSystem->BaseName(filerawname.Data()));};
266 TString GetRootFile(){return((TString)gSystem->BaseName(filerootname.Data()));};
267 TString GetRootName(){return((TString)gSystem->ExpandPathName(filerootname.Data()));};
268 TString GetRawName(){return(filerawname);};
269 TString GetRawPath();
270 TString GetRootPath();
271
272 const char* GetCleanTime(){return clean_time->AsSQLString();};
273 //
274 // Functions
275 //
276 Int_t assignBOOT_NUMBER();
277 Int_t insertPamelaRootFile();
278 Int_t insertPamelaRootFile(GL_ROOT*);
279 Int_t insertPamelaRawFile();
280 Int_t insertPamelaRawFile(GL_RAW*);
281 Int_t insertPamelaGL_TIMESYNC();
282 Int_t insertPamelaRUN();
283 Int_t insertCALO_CALIB();
284 Int_t insertCALOPULSE_CALIB();
285 Int_t insertTRK_CALIB();
286 Int_t insertS4_CALIB();
287 Int_t CleanGL_RUN_FRAGMENTS();
288 Int_t CleanGL_RUN_FRAGMENTS(TString fcleanfile);
289 Int_t CleanGL_RUN_FRAGMENTS(TString fcleanfile, Bool_t runpieces);
290 Int_t CleanGL_RUN_FRAGMENTS(Bool_t runpieces);
291 Int_t ValidateRuns();
292 Int_t ValidateRuns(TString valfile);
293 Int_t assignVALIDATION(UInt_t ,Bool_t );
294 Int_t removeFile(TString rootfilename);
295 //
296 Bool_t IsChewbacca(){return chewbacca;};
297 // void OpenFile();
298 void CheckValidate(Long64_t olderthan);
299 void CheckConnection();
300 void CheckFile();
301 //
302 void LockTables();
303 void UnLockTables();
304 //
305
306 Bool_t NoFrag(){return(NOFRAG);};
307 Bool_t InsertRoot(){return(INSERT_ROOT);};
308 Bool_t InsertRaw(){return(INSERT_RAW);};
309 Bool_t Validate(){return(VALIDATE);};
310
311 // Functions for TLE
312 Int_t populateTLE();
313
314 UInt_t ValidateTrkCalib( CalibTrk1Event* calibtrk , EventHeader* h, TFile* file);
315 UInt_t ValidateTrkCalib( CalibTrk2Event* calibtrk , EventHeader* h, TFile* file){return ValidateTrkCalib((CalibTrk1Event*)calibtrk,h,file); };
316
317 UInt_t ValidateTrkCalib( CalibTrk1Event* calibtrk , EventHeader* h){return ValidateTrkCalib((CalibTrk1Event*)calibtrk,h,file); };
318 UInt_t ValidateTrkCalib( CalibTrk2Event* calibtrk , EventHeader* h){return ValidateTrkCalib((CalibTrk1Event*)calibtrk,h,file); };
319
320 UInt_t Check();
321 UInt_t Check(UInt_t from, UInt_t to);
322
323 };
324 #endif /* PAMELA_DB_OPERATIONS_H */

  ViewVC Help
Powered by ViewVC 1.1.23