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

Contents of /YodaProfiler/inc/PamelaDBOperations.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.6 - (show annotations) (download)
Tue Oct 17 15:19:56 2006 UTC (18 years, 1 month ago) by mocchiut
Branch: MAIN
Changes since 1.5: +19 -8 lines
File MIME type: text/plain
Added TLE filling, minor bugs fixed

1 #ifndef PAMELA_DB_OPERATIONS_H
2 #define PAMELA_DB_OPERATIONS_H
3
4 #include <iostream>
5 #include <list>
6
7 #include <TSQLServer.h>
8 #include <EventHeader.h>
9 #include <PscuHeader.h>
10 #include <mcmd/McmdEvent.h>
11 #include <mcmd/McmdRecord.h>
12 #include <RunHeaderEvent.h>
13 #include <RunTrailerEvent.h>
14 #include <CalibCalPedEvent.h>
15 #include <CalibS4Event.h>
16 #include <CalibTrk1Event.h>
17 #include <CalibTrk2Event.h>
18 #include <varDump/VarDumpEvent.h>
19 #include <varDump/VarDumpRecord.h>
20 #include <physics/S4/S4Event.h>
21
22 #include <GLTables.h>
23
24 #include <cTle.h>
25
26 using namespace pamela;
27
28 /**
29 * Collections of Pamela specific operations over a database
30 */
31 class PamelaDBOperations {
32
33 private:
34 TSQLServer *conn;
35 TFile *file;
36 //
37 RunHeaderEvent *runh;
38 EventHeader *ehh;
39 PscuHeader *phh;
40 RunTrailerEvent *runt;
41 EventHeader *eht;
42 PscuHeader *pht;
43 //
44 GL_RUN *glrun;
45 //
46 TString filerawname;
47 TString filerootname;
48 //
49 UInt_t tsync;
50 UInt_t toffset;
51 //
52 // Long64_t olderthan;
53 //
54 UInt_t BOOTNO;
55 UInt_t obt0;
56 UInt_t id;
57 UInt_t idroot;
58 UInt_t pktfirst;
59 ULong64_t obtfirst;
60 ULong64_t upperobt;
61 UInt_t upperpkt;
62 UInt_t upperentry;
63 Int_t rtev;
64 Int_t rhev;
65 //
66 // calibration variables
67 //
68 Int_t t1;
69 Int_t t2;
70 UInt_t fromtime;
71 UInt_t obt1;
72 UInt_t pkt1;
73 UInt_t obt2;
74 UInt_t pkt2;
75 UInt_t valid;
76 //
77 //
78 Bool_t NOBOOT;
79 Bool_t debug;
80
81 // Path to tle file
82 TString tlefilename;
83
84 // flag to control profiler actions
85 Bool_t INSERT_RAW;
86 Bool_t INSERT_ROOT;
87 Bool_t VALIDATE;
88
89 TDatime *clean_time;
90
91 //
92 typedef std::list<const char*> pcksList;
93 static void getPacketsNames(pcksList &pcksNames){
94 pcksNames.push_back("PhysEndRun");
95 pcksNames.push_back("CalibCalPulse1");
96 pcksNames.push_back("CalibCalPulse2");
97 pcksNames.push_back("Physics");
98 pcksNames.push_back("CalibTrkBoth");
99 pcksNames.push_back("CalibTrk1");
100 pcksNames.push_back("CalibTrk2");
101 pcksNames.push_back("CalibTof");
102 pcksNames.push_back("CalibS4");
103 pcksNames.push_back("CalibCalPed");
104 pcksNames.push_back("Calib1_Ac1");
105 pcksNames.push_back("Calib2_Ac1");
106 pcksNames.push_back("Calib1_Ac2");
107 pcksNames.push_back("Calib2_Ac2");
108 pcksNames.push_back("CalibCal");
109 pcksNames.push_back("RunHeader");
110 pcksNames.push_back("RunTrailer");
111 pcksNames.push_back("CalibHeader");
112 pcksNames.push_back("CalibTrailer");
113 pcksNames.push_back("InitHeader");
114 pcksNames.push_back("InitTrailer");
115 pcksNames.push_back("EventTrk");
116 pcksNames.push_back("Log");
117 pcksNames.push_back("VarDump");
118 pcksNames.push_back("ArrDump");
119 pcksNames.push_back("TabDump");
120 pcksNames.push_back("Tmtc");
121 pcksNames.push_back("Mcmd");
122 pcksNames.push_back("ForcedFECmd");
123 pcksNames.push_back("Ac1Init");
124 pcksNames.push_back("CalInit");
125 pcksNames.push_back("TrkInit");
126 pcksNames.push_back("TofInit");
127 pcksNames.push_back("TrgInit");
128 pcksNames.push_back("NdInit");
129 pcksNames.push_back("S4Init");
130 pcksNames.push_back("Ac2Init");
131 pcksNames.push_back("CalAlarm");
132 pcksNames.push_back("Ac1Alarm");
133 pcksNames.push_back("TrkAlarm");
134 pcksNames.push_back("TrgAlarm");
135 pcksNames.push_back("TofAlarm");
136 pcksNames.push_back("S4Alarm");
137 pcksNames.push_back("Ac2Alarm");
138 pcksNames.push_back("TsbT");
139 pcksNames.push_back("TsbB");
140 };
141 //
142 // Functions
143 //
144 void HandleRun();
145 void HandleRunFragments(Bool_t mishead, Bool_t mistrail, UInt_t firstev, UInt_t lastev);
146 void HandleMissingHoT(Bool_t mishead, Bool_t mistrail, UInt_t firstev, UInt_t lastev);
147 void HandleSuspiciousRun();
148 void FillClass();
149 void FillClass(Bool_t mishead, Bool_t mistrail, UInt_t firstev, UInt_t lastev);
150 void HandleTRK_CALIB(Bool_t pk1, Bool_t pk2);
151 //
152 Bool_t IsDebug(){return(debug);};
153 Bool_t IsRunAlreadyInserted();
154 Bool_t IsRunConsistent(Bool_t mishead, Bool_t mistrail, UInt_t &firstev, UInt_t &lastev);
155 //
156 Bool_t MissingTRK_CALIB(UInt_t t1,UInt_t t2);
157 //
158 UInt_t PKT(UInt_t pkt_num);
159 //
160 ULong64_t OBT(UInt_t obt);
161 //
162
163 // GL_TLE related functions
164 int insertTle(cTle*);
165 bool isTlePresent(cTle*);
166
167 public:
168 //
169 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); // constructor
170 //
171 void Close(); // destructor
172 //
173 //
174 // Setters
175 //
176 void SetConnection(TString host, TString user, TString password);
177 void SetBOOTnumber(UInt_t boot);
178 void SetRawName(TString str);
179 void SetRootName(TString str);
180 void SetDebugFlag(Bool_t debug);
181 void SetID_RAW(UInt_t idr);
182 void SetID_ROOT(UInt_t idr);
183 void SetTsync(UInt_t ts);
184 void SetObt0(UInt_t ts);
185 void SetCommonGLRUN(UInt_t absth, UInt_t abstt);
186 void SetNOBOOT(Bool_t noboot);
187 void SetOlderThan(Long64_t oldthan);
188 void SetTLEPath(TString str);
189 //
190 Bool_t SetID_RAW();
191 //
192 Int_t SetUpperLimits();
193 //
194 // Getters
195 //
196 Bool_t GetNOBOOT(){return(NOBOOT);};
197 //
198 UInt_t GetID_RAW(){return(id);};
199 UInt_t GetID_ROOT(){return(idroot);};
200 UInt_t GetBOOTnumber(){return(BOOTNO);};
201 //
202 UInt_t GetAbsTime(UInt_t obt);
203 UInt_t GetTsync(){return(tsync);};
204 //
205 const PacketType* GetPacketType(const char* type);
206 //
207 TString GetRawFile(){return((TString)gSystem->BaseName(filerawname.Data()));};
208 TString GetRawPath(){return((TString)gSystem->DirName(filerawname.Data())+'/');};
209 TString GetRootFile(){return((TString)gSystem->BaseName(filerootname.Data()));};
210 TString GetRootPath(){return((TString)gSystem->DirName(filerootname.Data())+'/');};
211 TString GetRootName(){return(filerootname);};
212 TString GetRawName(){return(filerawname);};
213
214 const char* GetCleanTime(){return clean_time->AsSQLString();};
215 //
216 // Functions
217 //
218 Int_t assignBOOT_NUMBER();
219 Int_t insertPamelaRootFile();
220 Int_t insertPamelaRawFile();
221 Int_t insertPamelaGL_TIMESYNC();
222 Int_t insertPamelaRUN();
223 Int_t insertCALO_CALIB();
224 Int_t insertTRK_CALIB();
225 Int_t insertS4_CALIB();
226 Int_t CleanGL_RUN_FRAGMENTS();
227 Int_t ValidateRuns();
228 Int_t assignVALIDATION(UInt_t ,Bool_t );
229 //
230 // void OpenFile();
231 void CheckValidate(Long64_t olderthan);
232 void CheckConnection();
233 void CheckFile();
234 //
235
236 Bool_t InsertRoot(){return(INSERT_ROOT);};
237 Bool_t InsertRaw(){return(INSERT_RAW);};
238 Bool_t Validate(){return(VALIDATE);};
239
240 // Functions for TLE
241 Int_t populateTLE();
242
243 };
244 #endif /* PAMELA_DB_OPERATIONS_H */

  ViewVC Help
Powered by ViewVC 1.1.23