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 <TSQLServer.h> |
8 |
|
|
#include <TArrayD.h> |
9 |
|
|
// |
10 |
|
|
#include <EventHeader.h> |
11 |
|
|
#include <PscuHeader.h> |
12 |
|
|
#include <mcmd/McmdEvent.h> |
13 |
|
|
#include <mcmd/McmdRecord.h> |
14 |
|
|
#include <RunHeaderEvent.h> |
15 |
|
|
#include <RunTrailerEvent.h> |
16 |
|
|
#include <CalibCalPedEvent.h> |
17 |
|
|
#include <CalibS4Event.h> |
18 |
|
|
#include <CalibTrk1Event.h> |
19 |
|
|
#include <CalibTrk2Event.h> |
20 |
|
|
#include <varDump/VarDumpEvent.h> |
21 |
|
|
#include <varDump/VarDumpRecord.h> |
22 |
|
|
#include <physics/S4/S4Event.h> |
23 |
|
|
// |
24 |
|
|
#include <GLTables.h> |
25 |
|
|
|
26 |
|
|
using namespace pamela; |
27 |
|
|
|
28 |
|
|
|
29 |
|
|
/** |
30 |
|
|
* Collections of Pamela specific operations over a database |
31 |
|
|
*/ |
32 |
|
|
class PamelaDBOperations { |
33 |
|
|
|
34 |
|
|
private: |
35 |
|
|
TSQLServer *conn; |
36 |
|
|
TFile *file; |
37 |
|
|
// |
38 |
|
|
RunHeaderEvent *runh; |
39 |
|
|
EventHeader *ehh; |
40 |
|
|
PscuHeader *phh; |
41 |
|
|
RunTrailerEvent *runt; |
42 |
|
|
EventHeader *eht; |
43 |
|
|
PscuHeader *pht; |
44 |
|
|
// |
45 |
|
|
GL_RUN *glrun; |
46 |
|
|
// |
47 |
|
|
TString filerawname; |
48 |
|
|
TString filerootname; |
49 |
|
|
// |
50 |
|
|
UInt_t tsync; |
51 |
|
|
UInt_t toffset; |
52 |
|
|
// |
53 |
|
|
UInt_t BOOTNO; |
54 |
|
|
UInt_t obt0; |
55 |
|
|
UInt_t id; |
56 |
|
|
UInt_t idroot; |
57 |
|
|
UInt_t pktfirst; |
58 |
|
|
ULong64_t obtfirst; |
59 |
|
|
ULong64_t upperobt; |
60 |
|
|
UInt_t upperpkt; |
61 |
|
|
UInt_t upperentry; |
62 |
|
|
Int_t rtev; |
63 |
|
|
Int_t rhev; |
64 |
|
|
// |
65 |
|
|
// calibration variables |
66 |
|
|
// |
67 |
|
|
Int_t t1; |
68 |
|
|
Int_t t2; |
69 |
|
|
UInt_t fromtime; |
70 |
|
|
UInt_t obt1; |
71 |
|
|
UInt_t pkt1; |
72 |
|
|
UInt_t obt2; |
73 |
|
|
UInt_t pkt2; |
74 |
|
|
UInt_t valid; |
75 |
|
|
// |
76 |
|
|
// |
77 |
|
|
Bool_t NOBOOT; |
78 |
|
|
Bool_t debug; |
79 |
|
|
// |
80 |
|
|
typedef std::list<const char*> pcksList; |
81 |
|
|
static void getPacketsNames(pcksList &pcksNames){ |
82 |
|
|
pcksNames.push_back("PhysEndRun"); |
83 |
|
|
pcksNames.push_back("CalibCalPulse1"); |
84 |
|
|
pcksNames.push_back("CalibCalPulse2"); |
85 |
|
|
pcksNames.push_back("Physics"); |
86 |
|
|
pcksNames.push_back("CalibTrkBoth"); |
87 |
|
|
pcksNames.push_back("CalibTrk1"); |
88 |
|
|
pcksNames.push_back("CalibTrk2"); |
89 |
|
|
pcksNames.push_back("CalibTof"); |
90 |
|
|
pcksNames.push_back("CalibS4"); |
91 |
|
|
pcksNames.push_back("CalibCalPed"); |
92 |
|
|
pcksNames.push_back("Calib1_Ac1"); |
93 |
|
|
pcksNames.push_back("Calib2_Ac1"); |
94 |
|
|
pcksNames.push_back("Calib1_Ac2"); |
95 |
|
|
pcksNames.push_back("Calib2_Ac2"); |
96 |
|
|
pcksNames.push_back("CalibCal"); |
97 |
|
|
pcksNames.push_back("RunHeader"); |
98 |
|
|
pcksNames.push_back("RunTrailer"); |
99 |
|
|
pcksNames.push_back("CalibHeader"); |
100 |
|
|
pcksNames.push_back("CalibTrailer"); |
101 |
|
|
pcksNames.push_back("InitHeader"); |
102 |
|
|
pcksNames.push_back("InitTrailer"); |
103 |
|
|
pcksNames.push_back("EventTrk"); |
104 |
|
|
pcksNames.push_back("Log"); |
105 |
|
|
pcksNames.push_back("VarDump"); |
106 |
|
|
pcksNames.push_back("ArrDump"); |
107 |
|
|
pcksNames.push_back("TabDump"); |
108 |
|
|
pcksNames.push_back("Tmtc"); |
109 |
|
|
pcksNames.push_back("Mcmd"); |
110 |
|
|
pcksNames.push_back("ForcedFECmd"); |
111 |
|
|
pcksNames.push_back("Ac1Init"); |
112 |
|
|
pcksNames.push_back("CalInit"); |
113 |
|
|
pcksNames.push_back("TrkInit"); |
114 |
|
|
pcksNames.push_back("TofInit"); |
115 |
|
|
pcksNames.push_back("TrgInit"); |
116 |
|
|
pcksNames.push_back("NdInit"); |
117 |
|
|
pcksNames.push_back("S4Init"); |
118 |
|
|
pcksNames.push_back("Ac2Init"); |
119 |
|
|
pcksNames.push_back("CalAlarm"); |
120 |
|
|
pcksNames.push_back("Ac1Alarm"); |
121 |
|
|
pcksNames.push_back("TrkAlarm"); |
122 |
|
|
pcksNames.push_back("TrgAlarm"); |
123 |
|
|
pcksNames.push_back("TofAlarm"); |
124 |
|
|
pcksNames.push_back("S4Alarm"); |
125 |
|
|
pcksNames.push_back("Ac2Alarm"); |
126 |
|
|
pcksNames.push_back("TsbT"); |
127 |
|
|
pcksNames.push_back("TsbB"); |
128 |
|
|
}; |
129 |
|
|
// |
130 |
|
|
// Functions |
131 |
|
|
// |
132 |
|
|
void HandleRun(); |
133 |
|
|
void HandleRunFragments(Bool_t mishead, Bool_t mistrail, UInt_t firstev, UInt_t lastev); |
134 |
|
|
void HandleMissingHoT(Bool_t mishead, Bool_t mistrail, UInt_t firstev, UInt_t lastev); |
135 |
|
|
void HandleSuspiciousRun(); |
136 |
|
|
void FillClass(); |
137 |
|
|
void FillClass(Bool_t mishead, Bool_t mistrail, UInt_t firstev, UInt_t lastev); |
138 |
|
|
void HandleTRK_CALIB(Bool_t pk1, Bool_t pk2); |
139 |
|
|
// |
140 |
|
|
Bool_t IsDebug(){return(debug);}; |
141 |
|
|
Bool_t IsRunAlreadyInserted(); |
142 |
|
|
Bool_t IsRunConsistent(Bool_t mishead, Bool_t mistrail, UInt_t &firstev, UInt_t &lastev); |
143 |
|
|
// |
144 |
|
|
UInt_t PKT(UInt_t pkt_num); |
145 |
|
|
// |
146 |
|
|
ULong64_t OBT(UInt_t obt); |
147 |
|
|
// |
148 |
|
|
TArrayD S4_paramfit(pamela::CalibS4Event *S4CalibEvent); |
149 |
|
|
// |
150 |
|
|
|
151 |
|
|
public: |
152 |
|
|
// |
153 |
|
|
PamelaDBOperations(TString host, TString user, TString password, TString filerawname, TString filerootname, UInt_t boot, UInt_t tsync, UInt_t obt0, Bool_t debug); // constructor |
154 |
|
|
// |
155 |
|
|
void Close(); // destructor |
156 |
|
|
// |
157 |
|
|
// |
158 |
|
|
// Setters |
159 |
|
|
// |
160 |
|
|
void SetConnection(TString host, TString user, TString password); |
161 |
|
|
void SetBOOTnumber(UInt_t boot); |
162 |
|
|
void SetRawName(TString str); |
163 |
|
|
void SetRootName(TString str); |
164 |
|
|
void SetDebugFlag(Bool_t debug); |
165 |
|
|
void SetID_RAW(UInt_t idr); |
166 |
|
|
void SetID_ROOT(UInt_t idr); |
167 |
|
|
void SetTsync(UInt_t ts); |
168 |
|
|
void SetObt0(UInt_t ts); |
169 |
|
|
void SetCommonGLRUN(UInt_t absth, UInt_t abstt); |
170 |
|
|
void SetNOBOOT(Bool_t noboot); |
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 |
|
|
// |
207 |
|
|
void OpenFile(); |
208 |
|
|
void CheckFile(); |
209 |
|
|
// |
210 |
|
|
}; |
211 |
|
|
#endif /* PAMELA_DB_OPERATIONS_H */ |