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

Annotation of /chewbacca/YodaProfiler/inc/PamelaDBOperations.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations) (download)
Thu Sep 25 12:13:52 2008 UTC (16 years, 2 months ago) by mocchiut
Branch: MAIN
Changes since 1.1: +3 -0 lines
File MIME type: text/plain
PhysEndRun TB variables added to DB and GL_RUN class, broken calo parameters in the DB fixed

1 mocchiut 1.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 mocchiut 1.2 #include <endrun/PhysEndRunEvent.h>
23     #include <endrun/TBEndRun.h>
24 mocchiut 1.1
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     //
187     void RemoveCALIBS();
188     void ValidationOFF();
189     void ReArrangeRUNS();
190     void RemoveRUNS();
191     void RemoveFILES();
192     //
193     Bool_t IsDebug(){return(debug);};
194     Bool_t IsRunAlreadyInserted();
195     Bool_t IsRunConsistent(Bool_t mishead, Bool_t mistrail, UInt_t &firstev, UInt_t &lastev);
196     Bool_t AutoBoot(){return(AUTOBOOT);};
197     //
198     Bool_t MissingTRK_CALIB(UInt_t t1,UInt_t t2);
199     //
200     Long64_t PKT(UInt_t pkt_num);
201     //
202     Long64_t OBT(UInt_t obt);
203     //
204     UInt_t AssignRunID();
205    
206     // GL_TLE related functions
207     int insertTle(cTle*);
208     bool isTlePresent(cTle*);
209    
210     public:
211     //
212     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
213     //
214     void Close(); // destructor
215     //
216     //
217     // Setters
218     //
219     void SetConnection(TString host, TString user, TString password);
220     void SetBOOTnumber(UInt_t boot);
221     void SetBOOTnumber(UInt_t boot, Bool_t gpamela);
222     void SetRawName(TString str);
223     void SetRootName(TString str);
224     void SetDebugFlag(Bool_t debug);
225     void SetID_RAW(UInt_t idr);
226     void SetID_ROOT(UInt_t idr);
227     void SetTsync(UInt_t ts);
228     void SetTsync(UInt_t ts, Bool_t gpamela);
229     void SetObt0(UInt_t ts);
230     void SetCommonGLRUN(UInt_t absth, UInt_t abstt);
231     void SetNOBOOT(Bool_t noboot);
232     void SetOlderThan(Long64_t oldthan);
233     void SetTLEPath(TString str);
234     void SetOrbitNo(UInt_t dwinput);
235     void SetNoFrag(Bool_t nf);
236     void SetAutoBoot(Bool_t nf);
237     void SetPedantic(Bool_t pd);
238 mocchiut 1.2 void SetPhysEndRunVariables();
239 mocchiut 1.1 //
240     Bool_t SetID_RAW();
241     //
242     Int_t SetUpperLimits();
243     void OpenL0File(TString filerootname);
244     //
245     // Getters
246     //
247     Bool_t GetNOBOOT(){return(NOBOOT);};
248     //
249     UInt_t GetID_RAW(){return(id);};
250     UInt_t GetID_ROOT(){return(idroot);};
251     UInt_t GetBOOTnumber(){return(BOOTNO);};
252     //
253     UInt_t GetAbsTime(UInt_t obt);
254     UInt_t GetTsync(){return(tsync);};
255     //
256     const PacketType* GetPacketType(const char* type);
257     //
258     TString GetRawFile(){return((TString)gSystem->BaseName(filerawname.Data()));};
259     TString GetRootFile(){return((TString)gSystem->BaseName(filerootname.Data()));};
260     TString GetRootName(){return(filerootname);};
261     TString GetRawName(){return(filerawname);};
262     TString GetRawPath();
263     TString GetRootPath();
264    
265     const char* GetCleanTime(){return clean_time->AsSQLString();};
266     //
267     // Functions
268     //
269     Int_t assignBOOT_NUMBER();
270     Int_t insertPamelaRootFile();
271     Int_t insertPamelaRawFile();
272     Int_t insertPamelaGL_TIMESYNC();
273     Int_t insertPamelaRUN();
274     Int_t insertCALO_CALIB();
275     Int_t insertCALOPULSE_CALIB();
276     Int_t insertTRK_CALIB();
277     Int_t insertS4_CALIB();
278     Int_t CleanGL_RUN_FRAGMENTS();
279     Int_t CleanGL_RUN_FRAGMENTS(TString fcleanfile);
280     Int_t CleanGL_RUN_FRAGMENTS(TString fcleanfile, Bool_t runpieces);
281     Int_t CleanGL_RUN_FRAGMENTS(Bool_t runpieces);
282     Int_t ValidateRuns();
283     Int_t ValidateRuns(TString valfile);
284     Int_t assignVALIDATION(UInt_t ,Bool_t );
285     Int_t removeFile(TString rootfilename);
286     //
287     // void OpenFile();
288     void CheckValidate(Long64_t olderthan);
289     void CheckConnection();
290     void CheckFile();
291     //
292     void LockTables();
293     void UnLockTables();
294     //
295    
296     Bool_t NoFrag(){return(NOFRAG);};
297     Bool_t InsertRoot(){return(INSERT_ROOT);};
298     Bool_t InsertRaw(){return(INSERT_RAW);};
299     Bool_t Validate(){return(VALIDATE);};
300    
301     // Functions for TLE
302     Int_t populateTLE();
303    
304     UInt_t ValidateTrkCalib( CalibTrk1Event* calibtrk , EventHeader* h);
305     UInt_t ValidateTrkCalib( CalibTrk2Event* calibtrk , EventHeader* h){return ValidateTrkCalib((CalibTrk1Event*)calibtrk,h); };
306    
307     UInt_t Check();
308     UInt_t Check(UInt_t from, UInt_t to);
309    
310     };
311     #endif /* PAMELA_DB_OPERATIONS_H */

  ViewVC Help
Powered by ViewVC 1.1.23