/[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.6 - (hide annotations) (download)
Fri Nov 28 10:57:43 2008 UTC (16 years ago) by mocchiut
Branch: MAIN
CVS Tags: v1r00
Changes since 1.5: +3 -1 lines
File MIME type: text/plain
New run validation algorithm: if calibration is corrupted => VALIDATION=2

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

  ViewVC Help
Powered by ViewVC 1.1.23