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 |
// |
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 |
using namespace pamela; |
26 |
|
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 |
typedef std::list<const char*> pcksList; |
82 |
static void getPacketsNames(pcksList &pcksNames){ |
83 |
pcksNames.push_back("PhysEndRun"); |
84 |
pcksNames.push_back("CalibCalPulse1"); |
85 |
pcksNames.push_back("CalibCalPulse2"); |
86 |
pcksNames.push_back("Physics"); |
87 |
pcksNames.push_back("CalibTrkBoth"); |
88 |
pcksNames.push_back("CalibTrk1"); |
89 |
pcksNames.push_back("CalibTrk2"); |
90 |
pcksNames.push_back("CalibTof"); |
91 |
pcksNames.push_back("CalibS4"); |
92 |
pcksNames.push_back("CalibCalPed"); |
93 |
pcksNames.push_back("Calib1_Ac1"); |
94 |
pcksNames.push_back("Calib2_Ac1"); |
95 |
pcksNames.push_back("Calib1_Ac2"); |
96 |
pcksNames.push_back("Calib2_Ac2"); |
97 |
pcksNames.push_back("CalibCal"); |
98 |
pcksNames.push_back("RunHeader"); |
99 |
pcksNames.push_back("RunTrailer"); |
100 |
pcksNames.push_back("CalibHeader"); |
101 |
pcksNames.push_back("CalibTrailer"); |
102 |
pcksNames.push_back("InitHeader"); |
103 |
pcksNames.push_back("InitTrailer"); |
104 |
pcksNames.push_back("EventTrk"); |
105 |
pcksNames.push_back("Log"); |
106 |
pcksNames.push_back("VarDump"); |
107 |
pcksNames.push_back("ArrDump"); |
108 |
pcksNames.push_back("TabDump"); |
109 |
pcksNames.push_back("Tmtc"); |
110 |
pcksNames.push_back("Mcmd"); |
111 |
pcksNames.push_back("ForcedFECmd"); |
112 |
pcksNames.push_back("Ac1Init"); |
113 |
pcksNames.push_back("CalInit"); |
114 |
pcksNames.push_back("TrkInit"); |
115 |
pcksNames.push_back("TofInit"); |
116 |
pcksNames.push_back("TrgInit"); |
117 |
pcksNames.push_back("NdInit"); |
118 |
pcksNames.push_back("S4Init"); |
119 |
pcksNames.push_back("Ac2Init"); |
120 |
pcksNames.push_back("CalAlarm"); |
121 |
pcksNames.push_back("Ac1Alarm"); |
122 |
pcksNames.push_back("TrkAlarm"); |
123 |
pcksNames.push_back("TrgAlarm"); |
124 |
pcksNames.push_back("TofAlarm"); |
125 |
pcksNames.push_back("S4Alarm"); |
126 |
pcksNames.push_back("Ac2Alarm"); |
127 |
pcksNames.push_back("TsbT"); |
128 |
pcksNames.push_back("TsbB"); |
129 |
}; |
130 |
// |
131 |
// Functions |
132 |
// |
133 |
void HandleRun(); |
134 |
void HandleRunFragments(Bool_t mishead, Bool_t mistrail, UInt_t firstev, UInt_t lastev); |
135 |
void HandleMissingHoT(Bool_t mishead, Bool_t mistrail, UInt_t firstev, UInt_t lastev); |
136 |
void HandleSuspiciousRun(); |
137 |
void FillClass(); |
138 |
void FillClass(Bool_t mishead, Bool_t mistrail, UInt_t firstev, UInt_t lastev); |
139 |
void HandleTRK_CALIB(Bool_t pk1, Bool_t pk2); |
140 |
// |
141 |
Bool_t IsDebug(){return(debug);}; |
142 |
Bool_t IsRunAlreadyInserted(); |
143 |
Bool_t IsRunConsistent(Bool_t mishead, Bool_t mistrail, UInt_t &firstev, UInt_t &lastev); |
144 |
// |
145 |
UInt_t PKT(UInt_t pkt_num); |
146 |
// |
147 |
ULong64_t OBT(UInt_t obt); |
148 |
// |
149 |
|
150 |
public: |
151 |
// |
152 |
PamelaDBOperations(TString host, TString user, TString password, TString filerawname, TString filerootname, UInt_t boot, UInt_t tsync, UInt_t obt0, Bool_t debug); // constructor |
153 |
// |
154 |
void Close(); // destructor |
155 |
// |
156 |
// |
157 |
// Setters |
158 |
// |
159 |
void SetConnection(TString host, TString user, TString password); |
160 |
void SetBOOTnumber(UInt_t boot); |
161 |
void SetRawName(TString str); |
162 |
void SetRootName(TString str); |
163 |
void SetDebugFlag(Bool_t debug); |
164 |
void SetID_RAW(UInt_t idr); |
165 |
void SetID_ROOT(UInt_t idr); |
166 |
void SetTsync(UInt_t ts); |
167 |
void SetObt0(UInt_t ts); |
168 |
void SetCommonGLRUN(UInt_t absth, UInt_t abstt); |
169 |
void SetNOBOOT(Bool_t noboot); |
170 |
void SetOlderThan(Long64_t oldthan); |
171 |
// |
172 |
Bool_t SetID_RAW(); |
173 |
// |
174 |
Int_t SetUpperLimits(); |
175 |
// |
176 |
// Getters |
177 |
// |
178 |
Bool_t GetNOBOOT(){return(NOBOOT);}; |
179 |
// |
180 |
UInt_t GetID_RAW(){return(id);}; |
181 |
UInt_t GetID_ROOT(){return(idroot);}; |
182 |
UInt_t GetBOOTnumber(){return(BOOTNO);}; |
183 |
// |
184 |
UInt_t GetAbsTime(UInt_t obt); |
185 |
UInt_t GetTsync(){return(tsync);}; |
186 |
// |
187 |
const PacketType* GetPacketType(const char* type); |
188 |
// |
189 |
TString GetRawFile(){return((TString)gSystem->BaseName(filerawname.Data()));}; |
190 |
TString GetRawPath(){return((TString)gSystem->DirName(filerawname.Data())+'/');}; |
191 |
TString GetRootFile(){return((TString)gSystem->BaseName(filerootname.Data()));}; |
192 |
TString GetRootPath(){return((TString)gSystem->DirName(filerootname.Data())+'/');}; |
193 |
TString GetRootName(){return(filerootname);}; |
194 |
TString GetRawName(){return(filerawname);}; |
195 |
// |
196 |
// Functions |
197 |
// |
198 |
Int_t assignBOOT_NUMBER(); |
199 |
Int_t insertPamelaRootFile(); |
200 |
Int_t insertPamelaRawFile(); |
201 |
Int_t insertPamelaGL_TIMESYNC(); |
202 |
Int_t insertPamelaRUN(); |
203 |
Int_t insertCALO_CALIB(); |
204 |
Int_t insertTRK_CALIB(); |
205 |
Int_t insertS4_CALIB(); |
206 |
Int_t CleanGL_RUN_FRAGMENTS(); |
207 |
Int_t ValidateRuns(); |
208 |
// |
209 |
void OpenFile(); |
210 |
void CheckFile(); |
211 |
// |
212 |
}; |
213 |
#endif /* PAMELA_DB_OPERATIONS_H */ |