/[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.3 - (show annotations) (download)
Fri Oct 31 11:21:42 2008 UTC (16 years, 1 month ago) by pam-fi
Branch: MAIN
Changes since 1.2: +8 -2 lines
File MIME type: text/plain
added tracker calibration recovery from chewbacca ROOT_TABLE

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

  ViewVC Help
Powered by ViewVC 1.1.23