-
Notifications
You must be signed in to change notification settings - Fork 5
/
BaseTypes.h
290 lines (263 loc) · 14.1 KB
/
BaseTypes.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
#ifndef BASETYPES_H
#define BASETYPES_H
// There is no good implementation of std::make_pair in Qt. So I am sticking with the standard C++ container here
#include <vector>
#include <string>
// Qt includes
#include <QtSql/QSqlQuery>
#include <QVariant>
#include <QVector>
// ROOT includes
#include <TObjString.h>
// Debugging output
#include "Debug.h"
/** \Struct Base_Type
*
* abstract base struct for TTree branch handling and filling
*/
struct Base_Type {
virtual ~Base_Type() {
}
virtual void setFromResultset(const QSqlQuery& rs, int field_no) = 0;
};
/** \Struct String
*
* struct to handle TObjString branches
*/
struct String : public Base_Type {
/**
* Default constructor. Initialize to 0
*/
String():
Base_Type(),
value(0)
{
}
/**
* Initialize from std::string
*/
String(std::string v):
Base_Type()
{
value = new TObjString(v.c_str());
}
/**
* Initialize from char*
*/
String(char* v):
Base_Type()
{
value = new TObjString(v);
}
~String() {
}
virtual void setFromResultset(const QSqlQuery& rs, int field_no) {
value = new TObjString(Form("%s",rs.value(field_no).toString().toStdString().c_str() ) );
}
TObjString* value;
};
/** \Struct Double
*
* struct to handle double branches
*/
struct Double : public Base_Type {
Double() {
}
Double(double v):
Base_Type(),
value(v)
{
}
virtual void setFromResultset(const QSqlQuery& rs, int field_no) {
value = rs.value(field_no).toDouble();
}
double value;
};
/** \Struct Integer
*
* struct to handle integer branches
*/
struct Integer : public Base_Type {
Integer() {
}
Integer(int v):
Base_Type(),
value(v)
{
}
virtual void setFromResultset(const QSqlQuery& rs, int field_no) {
value = rs.value(field_no).toInt();
}
unsigned int value;
};
/** \Struct BaseQuery
*
* struct to store the branch structure of a database query for a
* given run type
*/
struct BaseQuery {
QVector<std::pair<std::string, Base_Type* > > query;
BaseQuery() {
query.push_back(std::make_pair("Detector" , new String() ) );
query.push_back(std::make_pair("Side" , new Double() ) );
query.push_back(std::make_pair("Layer" , new Double() ) );
query.push_back(std::make_pair("Cl" , new Double() ) );
query.push_back(std::make_pair("Cr" , new Double() ) );
query.push_back(std::make_pair("Power" , new Double() ) );
query.push_back(std::make_pair("Mod" , new Double() ) );
query.push_back(std::make_pair("Rack" , new String() ) );
query.push_back(std::make_pair("Crate" , new Double() ) );
query.push_back(std::make_pair("Slot" , new Double() ) );
query.push_back(std::make_pair("PP1" , new String() ) );
query.push_back(std::make_pair("Stack" , new Double() ) );
query.push_back(std::make_pair("Place" , new Double() ) );
query.push_back(std::make_pair("Detid" , new Double() ) );
query.push_back(std::make_pair("Dcu" , new Double() ) );
query.push_back(std::make_pair("FecCrate" , new Double() ) );
query.push_back(std::make_pair("Fec" , new Double() ) );
query.push_back(std::make_pair("Ring" , new Double() ) );
query.push_back(std::make_pair("Ccu" , new Double() ) );
query.push_back(std::make_pair("CcuArrangement" , new Double() ) );
query.push_back(std::make_pair("I2CChannel" , new Double() ) );
query.push_back(std::make_pair("FecKey" , new Integer()) );
query.push_back(std::make_pair("I2CAddress" , new Double() ) );
query.push_back(std::make_pair("lasChan" , new Double() ) );
}
void setExtendedQuery(const std::string& runType) {
if(runType == "TIMING") {
query.push_back(std::make_pair("DeviceId" , new Double() ) );
query.push_back(std::make_pair("FedId" , new Double() ) );
query.push_back(std::make_pair("FeUnit" , new Double() ) );
query.push_back(std::make_pair("FeChan" , new Double() ) );
query.push_back(std::make_pair("FeApv" , new Double() ) );
query.push_back(std::make_pair("TickHeight" , new Double() ) );
query.push_back(std::make_pair("Delay" , new Double() ) );
query.push_back(std::make_pair("Base" , new Double() ) );
query.push_back(std::make_pair("Peak" , new Double() ) );
query.push_back(std::make_pair("Kind" , new Double() ) );
query.push_back(std::make_pair("IsValid" , new Double() ) );
}
else if (runType == "GAINSCAN" || runType == "OPTOSCAN") { // use both notations
query.push_back(std::make_pair("DeviceId", new Double() ) );
query.push_back(std::make_pair("FedId", new Double() ) );
query.push_back(std::make_pair("FeUnit", new Double() ) );
query.push_back(std::make_pair("FeChan", new Double() ) );
query.push_back(std::make_pair("FeApv", new Double() ) );
query.push_back(std::make_pair("Gain", new Double() ) );
query.push_back(std::make_pair("Bias0", new Double() ) );
query.push_back(std::make_pair("Bias1", new Double() ) );
query.push_back(std::make_pair("Bias2", new Double() ) );
query.push_back(std::make_pair("Bias3", new Double() ) );
query.push_back(std::make_pair("SelectedBias", new Double() ) );
query.push_back(std::make_pair("Measgain0", new Double() ) );
query.push_back(std::make_pair("Measgain1", new Double() ) );
query.push_back(std::make_pair("Measgain2", new Double() ) );
query.push_back(std::make_pair("Measgain3", new Double() ) );
query.push_back(std::make_pair("SelectedMeasgain", new Double() ) );
query.push_back(std::make_pair("Zerolight0", new Double() ) );
query.push_back(std::make_pair("Zerolight1", new Double() ) );
query.push_back(std::make_pair("Zerolight2", new Double() ) );
query.push_back(std::make_pair("Zerolight3", new Double() ) );
query.push_back(std::make_pair("SelectedZerolight", new Double() ) );
query.push_back(std::make_pair("Linknoise0", new Double() ) );
query.push_back(std::make_pair("Linknoise1", new Double() ) );
query.push_back(std::make_pair("Linknoise2", new Double() ) );
query.push_back(std::make_pair("Linknoise3", new Double() ) );
query.push_back(std::make_pair("SelectedLinknoise", new Double() ) );
query.push_back(std::make_pair("Liftoff0", new Double() ) );
query.push_back(std::make_pair("Liftoff1", new Double() ) );
query.push_back(std::make_pair("Liftoff2", new Double() ) );
query.push_back(std::make_pair("Liftoff3", new Double() ) );
query.push_back(std::make_pair("SelectedLiftoff", new Double() ) );
query.push_back(std::make_pair("Threshold0", new Double() ) );
query.push_back(std::make_pair("Threshold1", new Double() ) );
query.push_back(std::make_pair("Threshold2", new Double() ) );
query.push_back(std::make_pair("Threshold3", new Double() ) );
query.push_back(std::make_pair("SelectedThreshold", new Double() ) );
query.push_back(std::make_pair("Tickheight0", new Double() ) );
query.push_back(std::make_pair("Tickheight1", new Double() ) );
query.push_back(std::make_pair("Tickheight2", new Double() ) );
query.push_back(std::make_pair("Tickheight3", new Double() ) );
query.push_back(std::make_pair("SelectedTickheight", new Double() ) );
query.push_back(std::make_pair("Isvalid", new Double() ) );
query.push_back(std::make_pair("Baselineslop0", new Double() ) );
query.push_back(std::make_pair("Baselineslop1", new Double() ) );
query.push_back(std::make_pair("Baselineslop2", new Double() ) );
query.push_back(std::make_pair("Baselineslop3", new Double() ) );
query.push_back(std::make_pair("SelectedBaselineslop",new Double() ) );
query.push_back(std::make_pair("NormTick0", new Double() ) );
query.push_back(std::make_pair("NormTick1", new Double() ) );
query.push_back(std::make_pair("NormTick2", new Double() ) );
query.push_back(std::make_pair("NormTick3", new Double() ) );
}
else if(runType == "VPSPSCAN") {
query.push_back(std::make_pair("DeviceId", new Double() ) );
query.push_back(std::make_pair("FedId", new Double() ) );
query.push_back(std::make_pair("FeUnit", new Double() ) );
query.push_back(std::make_pair("FeChan", new Double() ) );
query.push_back(std::make_pair("FeApv", new Double() ) );
query.push_back(std::make_pair("Vpsp", new Double() ) );
query.push_back(std::make_pair("Adclevel", new Double() ) );
query.push_back(std::make_pair("Fraction", new Double() ) );
query.push_back(std::make_pair("Topedge", new Double() ) );
query.push_back(std::make_pair("Bottomedge", new Double() ) );
query.push_back(std::make_pair("Toplevel", new Double() ) );
query.push_back(std::make_pair("Bottomlevel", new Double() ) );
query.push_back(std::make_pair("Isvalid", new Double() ) );
}
else if(runType == "VERY_FAST_CONNECTION" || runType == "FASTFEDCABLING") {
query.push_back(std::make_pair("DeviceId" , new Double() ) );
query.push_back(std::make_pair("FedId" , new Double() ) );
query.push_back(std::make_pair("FeUnit" , new Double() ) );
query.push_back(std::make_pair("FeChan" , new Double() ) );
query.push_back(std::make_pair("FeApv" , new Double() ) );
query.push_back(std::make_pair("Highlevel" , new Double() ) );
query.push_back(std::make_pair("Highrms" , new Double() ) );
query.push_back(std::make_pair("Lowlevel" , new Double() ) );
query.push_back(std::make_pair("Lowrms" , new Double() ) );
query.push_back(std::make_pair("Maxll" , new Double() ) );
query.push_back(std::make_pair("Minll" , new Double() ) );
query.push_back(std::make_pair("Dcuid" , new Double() ) );
query.push_back(std::make_pair("Lldch" , new Double() ) );
query.push_back(std::make_pair("Isvalid" , new Double() ) );
query.push_back(std::make_pair("Isdirty" , new Double() ) );
}
else if(runType == "PEDESTALS" || runType == "PEDESTAL" || runType == "SCOPE") {
query.push_back(std::make_pair("DeviceId", new Double() ) );
query.push_back(std::make_pair("FedId", new Double() ) );
query.push_back(std::make_pair("FeUnit", new Double() ) );
query.push_back(std::make_pair("FeChan", new Double() ) );
query.push_back(std::make_pair("FeApv", new Double() ) );
query.push_back(std::make_pair("PedsMean", new Double() ) );
query.push_back(std::make_pair("PedsSpread", new Double() ) );
query.push_back(std::make_pair("NoiseMean", new Double() ) );
query.push_back(std::make_pair("NoiseSpread", new Double() ) );
query.push_back(std::make_pair("RawMean", new Double() ) );
query.push_back(std::make_pair("RawSpread", new Double() ) );
query.push_back(std::make_pair("PedsMax", new Double() ) );
query.push_back(std::make_pair("PedsMin", new Double() ) );
query.push_back(std::make_pair("NoiseMax", new Double() ) );
query.push_back(std::make_pair("NoiseMin", new Double() ) );
query.push_back(std::make_pair("RawMax", new Double() ) );
query.push_back(std::make_pair("RawMin", new Double() ) );
query.push_back(std::make_pair("IsValid", new Double() ) );
}
else if(runType == "ENC_PEDESTAL") {
query.pop_back(); // remove IsValid from the end
query.push_back(std::make_pair("PedsMeanENC", new Double() ) );
query.push_back(std::make_pair("PedsSpreadENC", new Double() ) );
query.push_back(std::make_pair("NoiseMeanENC", new Double() ) );
query.push_back(std::make_pair("NoiseSpreadENC", new Double() ) );
query.push_back(std::make_pair("RawMeanENC", new Double() ) );
query.push_back(std::make_pair("RawSpreadENC", new Double() ) );
query.push_back(std::make_pair("PedsMaxENC", new Double() ) );
query.push_back(std::make_pair("PedsMinENC", new Double() ) );
query.push_back(std::make_pair("NoiseMaxENC", new Double() ) );
query.push_back(std::make_pair("NoiseMinENC", new Double() ) );
query.push_back(std::make_pair("RawMaxENC", new Double() ) );
query.push_back(std::make_pair("RawMinENC", new Double() ) );
query.push_back(std::make_pair("IsValid", new Double() ) );
}
}
};
#endif