/[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.7 - (show annotations) (download)
Mon Jan 12 18:23:36 2009 UTC (15 years, 11 months ago) by mocchiut
Branch: MAIN
CVS Tags: v1r02, v1r01
Changes since 1.6: +3 -0 lines
File MIME type: text/plain
Several small 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 Bool_t RELAXED;
102
103 // flags and variables for chewbacca
104 Bool_t chewbacca;
105 UInt_t chID;
106 //
107 TString tag;
108 TString chiby;
109 //
110 UInt_t chpktinit;
111 UInt_t chpktfinal;
112 UInt_t chobtinit;
113 UInt_t chobtfinal;
114 UInt_t chrtinit;
115 Int_t nrhbef;
116 Int_t nrhaf;
117 Int_t nrtbef;
118 Int_t nrtaf;
119 //
120 UInt_t chpktmin;
121 UInt_t chpktmax;
122 UInt_t chobtmin;
123 UInt_t chobtmax;
124 UInt_t chobtts;
125 UInt_t chlastts;
126 UInt_t chresursts;
127 UInt_t chboot;
128 UInt_t chminentry;
129
130 TDatime *clean_time;
131
132 //
133 typedef std::list<const char*> pcksList;
134 static void getPacketsNames(pcksList &pcksNames){
135 pcksNames.push_back("PhysEndRun");
136 pcksNames.push_back("CalibCalPulse1");
137 pcksNames.push_back("CalibCalPulse2");
138 pcksNames.push_back("Physics");
139 pcksNames.push_back("CalibTrkBoth");
140 pcksNames.push_back("CalibTrk1");
141 pcksNames.push_back("CalibTrk2");
142 pcksNames.push_back("CalibTof");
143 pcksNames.push_back("CalibS4");
144 pcksNames.push_back("CalibCalPed");
145 pcksNames.push_back("Calib1_Ac1");
146 pcksNames.push_back("Calib2_Ac1");
147 pcksNames.push_back("Calib1_Ac2");
148 pcksNames.push_back("Calib2_Ac2");
149 pcksNames.push_back("CalibCal");
150 pcksNames.push_back("RunHeader");
151 pcksNames.push_back("RunTrailer");
152 pcksNames.push_back("CalibHeader");
153 pcksNames.push_back("CalibTrailer");
154 pcksNames.push_back("InitHeader");
155 pcksNames.push_back("InitTrailer");
156 pcksNames.push_back("EventTrk");
157 pcksNames.push_back("Log");
158 pcksNames.push_back("VarDump");
159 pcksNames.push_back("ArrDump");
160 pcksNames.push_back("TabDump");
161 pcksNames.push_back("Tmtc");
162 pcksNames.push_back("Mcmd");
163 pcksNames.push_back("ForcedFECmd");
164 pcksNames.push_back("Ac1Init");
165 pcksNames.push_back("CalInit");
166 pcksNames.push_back("TrkInit");
167 pcksNames.push_back("TofInit");
168 pcksNames.push_back("TrgInit");
169 pcksNames.push_back("NdInit");
170 pcksNames.push_back("S4Init");
171 pcksNames.push_back("Ac2Init");
172 pcksNames.push_back("CalAlarm");
173 pcksNames.push_back("Ac1Alarm");
174 pcksNames.push_back("TrkAlarm");
175 pcksNames.push_back("TrgAlarm");
176 pcksNames.push_back("TofAlarm");
177 pcksNames.push_back("S4Alarm");
178 pcksNames.push_back("Ac2Alarm");
179 pcksNames.push_back("TsbT");
180 pcksNames.push_back("TsbB");
181 };
182 //
183 // Functions
184 //
185 void HandleRun();
186 void HandleRunFragments(Bool_t mishead, Bool_t mistrail, UInt_t firstev, UInt_t lastev);
187 void HandleMissingHoT(Bool_t mishead, Bool_t mistrail, UInt_t firstev, UInt_t lastev);
188 void HandleSuspiciousRun();
189 void FillClass();
190 void FillClass(Bool_t mishead, Bool_t mistrail, Int_t firstev, Int_t lastev);
191 void HandleTRK_CALIB(Bool_t pk1, Bool_t pk2);
192 void HandleTRK_CALIB(GL_TRK_CALIB*);
193 //
194 void RemoveCALIBS();
195 void ValidationOFF();
196 void ReArrangeRUNS();
197 void RemoveRUNS();
198 void RemoveFILES(UInt_t idtsy);
199 //
200 Bool_t IsDebug(){return(debug);};
201 Bool_t IsRunAlreadyInserted();
202 Bool_t IsRunConsistent(Bool_t mishead, Bool_t mistrail, UInt_t &firstev, UInt_t &lastev);
203 Bool_t AutoBoot(){return(AUTOBOOT);};
204 //
205 // Bool_t MissingTRK_CALIB(UInt_t t1,UInt_t t2);
206 UInt_t MissingTRK_CALIB(UInt_t t1,UInt_t t2);
207 //
208 Long64_t PKT(UInt_t pkt_num);
209 //
210 Long64_t OBT(UInt_t obt);
211 //
212 UInt_t AssignRunID();
213
214 // GL_TLE related functions
215 int insertTle(cTle*);
216 bool isTlePresent(cTle*);
217
218 public:
219 //
220 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
221 //
222 void Close(); // destructor
223 //
224 //
225 // Setters
226 //
227 void SetConnection(TString host, TString user, TString password);
228 void SetBOOTnumber(UInt_t boot);
229 void SetBOOTnumber(UInt_t boot, Bool_t gpamela);
230 void SetRawName(TString str);
231 void SetRootName(TString str);
232 void SetDebugFlag(Bool_t debug);
233 void SetID_RAW(UInt_t idr);
234 void SetID_ROOT(UInt_t idr);
235 void SetTsync(UInt_t ts);
236 void SetTsync(UInt_t ts, Bool_t gpamela);
237 void SetObt0(UInt_t ts);
238 void SetCommonGLRUN(UInt_t absth, UInt_t abstt);
239 void SetNOBOOT(Bool_t noboot);
240 void SetOlderThan(Long64_t oldthan);
241 void SetTLEPath(TString str);
242 void SetOrbitNo(UInt_t dwinput);
243 void SetNoFrag(Bool_t nf);
244 void SetAutoBoot(Bool_t nf);
245 void SetPedantic(Bool_t pd);
246 void SetRelaxed(Bool_t pd){ if ( pd ) printf(" WARNING: USING RELAXED CONDITIONS, ARE YOU SURE ON WHAT YOU'RE DOING? \n"); RELAXED=pd;};
247 void SetPhysEndRunVariables();
248 //
249 void SetTag(TString ntag){tag=ntag;};
250 //
251 Bool_t SetID_RAW();
252 //
253 Int_t SetUpperLimits();
254 void OpenL0File(TString filerootname);
255 //
256 // Getters
257 //
258 Bool_t GetNOBOOT(){return(NOBOOT);};
259 //
260 UInt_t GetID_RAW(){return(id);};
261 UInt_t GetID_ROOT(){return(idroot);};
262 UInt_t GetBOOTnumber(){return(BOOTNO);};
263 //
264 UInt_t GetAbsTime(UInt_t obt);
265 UInt_t GetTsync(){return(tsync);};
266 //
267 const PacketType* GetPacketType(const char* type);
268 //
269 TString GetRawFile(){return((TString)gSystem->BaseName(filerawname.Data()));};
270 TString GetRootFile(){return((TString)gSystem->BaseName(filerootname.Data()));};
271 TString GetRootName(){return((TString)gSystem->ExpandPathName(filerootname.Data()));};
272 TString GetRawName(){return(filerawname);};
273 TString GetRawPath();
274 TString GetRootPath();
275
276 const char* GetCleanTime(){return clean_time->AsSQLString();};
277 //
278 // Functions
279 //
280 Int_t assignBOOT_NUMBER();
281 Int_t insertPamelaRootFile();
282 Int_t insertPamelaRootFile(GL_ROOT*);
283 Int_t insertPamelaRawFile();
284 Int_t insertPamelaRawFile(GL_RAW*);
285 Int_t insertPamelaGL_TIMESYNC();
286 Int_t insertPamelaRUN();
287 Int_t insertCALO_CALIB();
288 Int_t insertCALOPULSE_CALIB();
289 Int_t insertTRK_CALIB();
290 Int_t insertS4_CALIB();
291 Int_t CleanGL_RUN_FRAGMENTS();
292 Int_t CleanGL_RUN_FRAGMENTS(TString fcleanfile);
293 Int_t CleanGL_RUN_FRAGMENTS(TString fcleanfile, Bool_t runpieces);
294 Int_t CleanGL_RUN_FRAGMENTS(Bool_t runpieces);
295 Int_t ValidateRuns();
296 Int_t ValidateRuns(TString valfile);
297 Int_t assignVALIDATION(UInt_t ,Bool_t );
298 Int_t assignVALIDATION(UInt_t ,UInt_t );
299 Int_t removeFile(TString rootfilename);
300 //
301 Bool_t IsChewbacca(){return chewbacca;};
302 // void OpenFile();
303 void CheckValidate(Long64_t olderthan);
304 void CheckConnection();
305 void CheckFile();
306 //
307 void LockTables();
308 void UnLockTables();
309 //
310
311 Bool_t NoFrag(){return(NOFRAG);};
312 Bool_t InsertRoot(){return(INSERT_ROOT);};
313 Bool_t InsertRaw(){return(INSERT_RAW);};
314 Bool_t Validate(){return(VALIDATE);};
315
316 // Functions for TLE
317 Int_t populateTLE();
318
319 UInt_t ValidateTrkCalib( CalibTrk1Event* calibtrk , EventHeader* h, TFile* file);
320 UInt_t ValidateTrkCalib( CalibTrk2Event* calibtrk , EventHeader* h, TFile* file){return ValidateTrkCalib((CalibTrk1Event*)calibtrk,h,file); };
321
322 UInt_t ValidateTrkCalib( CalibTrk1Event* calibtrk , EventHeader* h){return ValidateTrkCalib((CalibTrk1Event*)calibtrk,h,file); };
323 UInt_t ValidateTrkCalib( CalibTrk2Event* calibtrk , EventHeader* h){return ValidateTrkCalib((CalibTrk1Event*)calibtrk,h,file); };
324
325 UInt_t Check();
326 UInt_t Check(UInt_t from, UInt_t to);
327
328 };
329 #endif /* PAMELA_DB_OPERATIONS_H */

  ViewVC Help
Powered by ViewVC 1.1.23