/[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.1 - (show annotations) (download)
Tue Sep 23 07:20:32 2008 UTC (16 years, 2 months ago) by mocchiut
Branch: MAIN
Branch point for: v0r00
File MIME type: text/plain
Initial revision

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

  ViewVC Help
Powered by ViewVC 1.1.23