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

Contents of /YodaProfiler/inc/PamelaDBOperations.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.20 - (show annotations) (download)
Mon Mar 10 10:58:00 2008 UTC (16 years, 8 months ago) by mocchiut
Branch: MAIN
CVS Tags: v5r00, v5r01, HEAD
Changes since 1.19: +1 -0 lines
File MIME type: text/plain
New checking features

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

  ViewVC Help
Powered by ViewVC 1.1.23