/[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.9 - (hide annotations) (download)
Tue Oct 14 12:59:12 2014 UTC (10 years, 2 months ago) by mocchiut
Branch: MAIN
CVS Tags: v10RED, HEAD
Changes since 1.8: +1 -0 lines
File MIME type: text/plain
10RED bug fixed: wrong timesync association into GL_ROOT table (back to the future bug)

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

  ViewVC Help
Powered by ViewVC 1.1.23