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
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
|
// -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: t; tab-width: 8; -*-
#ifndef ECALMATACQDIGI_H
#define ECALMATACQDIGI_H 1
#include <ostream>
#include <vector>
#include <algorithm>
#include "Rtypes.h"
#define ECAL_MATACQ_DIGI_VERS 2
/** \class EcalMatacqDigi
*/
class EcalMatacqDigi {
public:
/** LSB of ADC count in Volt
*/
static const double lsb_;
/** Maximum number of time samples
*/
static const int MAXSAMPLES = 2560;
public:
typedef int key_type; //matacq channel id used as key for edm::SortedCollection
public:
/** Default constructor.
*/
EcalMatacqDigi() : chId_(-1), ts_(0.), tTrigS_(999.), version_(-1) { init(); }
/** Constructor
* @param samples adc time samples
* @param chId Matacq channel ID
* @param ts sampling time in seconds
* @param version Matacq raw data private version
* @param tTrigg time position of the trigger in seconds
*/
EcalMatacqDigi(const std::vector<Short_t>& samples,
const int& chId,
const double& ts,
const short& version = -1,
const double& tTrig = 999.)
: chId_(chId), data_(samples), ts_(ts), tTrigS_(tTrig), version_(version) {
init();
};
/** Gets amplitude in ADC count of time sample i. i between 0 and size()-1.
* Note: Amplitude is pedestal subtracted at acquisition time.
*/
float adcCount(const int& i) const { return data_[i]; }
/** Gets amplitude in Volt of time sample i. i between 0 and size()-1.
* Note: Amplitude is pedestal subtracted at acquisition time.
*/
float amplitudeV(const int& i) const { return data_[i] * lsb_; }
/** Gets Matacq electronics channel id
*/
int chId() const { return chId_; }
/** For edm::SortedCollection.
* @return as key the matacq channel id
*/
int id() const { return chId_; }
// /** Sets Matacq electronics channel id
// */
// void chId(int newChId){ chId_ = newChId;}
/** Number of time samples
*/
int size() const { return data_.size(); }
/** Swaps samples with the passed samples. For package internal use.
* @param samples new time samples in unit used in raw data
* (a priori ADC count).
*/
void swap(std::vector<short>& samples) { std::swap(data_, samples); }
void swap(EcalMatacqDigi& a);
// /** Gets time of sample i. i between 0 and size()-1.
// */
// float t(int i) const { return ts()*i;}
/** Gets sampling time in seconds
*/
float ts() const { return ts_; }
// /** Sets sampling time period
// * @param ts sampling time period in seconds
// */
// void ts(double newTs){
// ts_ = newTs;
// }
/** Gets time of trigger in seconds.
* @return (t_trig-t_0), with t_trig the trigger time and t_0 the first.
* Returns 999 if not available.
* sample time.
*/
float tTrig() const { return tTrigS_; }
// /** Sets trigger time position
// * @param tTrigS (t_trig-t_0) in seconds, with t_trig the time of MATACQ
// * trigger and t_0 the time of the first sample of each MATACQ channel.
// */
// void tTrig(double tTrigS){
// tTrigS_ = tTrigS;
// }
/** version of raw data format, the digis originate from.
* @return raw data format version, -1 if not available.
*/
short version() const { return version_; }
// /** Sets the raw data format, the digi is issued from.
// * @param version internal matacq raw data format version
// */
// void version(short version){
// version_ = version;
// }
#if (ECAL_MATACQ_DIGI_VERS >= 2)
/** Gets the bunch crossing id field contents.
* @return BX id
*/
int bxId() const { return bxId_; }
/** Sets the bunch crossing id field contents.
* @param value new value
*/
void bxId(int value) { bxId_ = value; }
/** Gets level one accept counter of the event
* @return l1a
*/
int l1a() const { return l1a_; }
/** Sets level one accept counter of the event
* @param value new value
*/
void l1a(int value) { l1a_ = value; }
/** Gets type of test trigger
* @return triggerType
*/
int triggerType() const { return triggerType_; }
/** Sets type of test trigger
* @param value new value
*/
void triggerType(int value) { triggerType_ = value; }
/** Gets the matacq data timestamp with fine granularity (89.1us)
* @return acquisition date of the data expressed in number of "elapsed"
* second and microseconds since the EPOCH as defined in POSIX.1.
* See time() standard c function and gettimeofday UNIX function.
*/
timeval timeStamp() const {
timeval value;
value.tv_sec = tv_sec_;
value.tv_usec = tv_usec_;
return value;
}
/** Sets the matcq event timestmap
* @param value new value
*/
void timeStamp(timeval value) {
tv_sec_ = value.tv_sec;
tv_usec_ = value.tv_usec;
}
/** Gets the LHC orbit ID of the event
* Available only for Matacq data format version >=3 and for P5 data.
* @return the LHC orbit ID
*/
UInt_t orbitId() const { return orbitId_; }
/** Sets the LHC orbit ID of the event.
* @param value new value
*/
void orbitId(UInt_t value) { orbitId_ = value; }
/** Gets the Trig Rec value (see Matacq documentation)
* Available only for Matacq data format version >=3.
* @return the Trig Rec value
*/
int trigRec() const { return trigRec_; }
/** Sets the Trig Rec value (see Matacq documentation)
* @param value new value
*/
void trigRec(int value) { trigRec_ = value; }
/** Gets the Posttrig value (see Matacq documentation).
* Available only for Matacq data format version >=3.
*/
int postTrig() const { return postTrig_; }
/** Sets the Posttrig value (see Matacq documentation).
* @param value new value
*/
void postTrig(int value) { postTrig_ = value; }
/** Gets the vernier values (see Matacq documentation)
* @return verniers
*/
std::vector<int> vernier() const { return vernier_; }
/** Sets verniers
* @param value new value
*/
void vernier(const std::vector<int>& value) { vernier_ = value; }
/** Gets "Delay A" setting of laser delay box in ns.delayA
* @return delayA
*/
int delayA() const { return delayA_; }
/** Sets "Delay A" setting of laser delay box in ns.delayA
* @param value new value
*/
void delayA(int value) { delayA_ = value; }
/** Gets the WTE-to-Laser delay of EMTC in LHC clock unit.
* @return emtcDelay
*/
int emtcDelay() const { return emtcDelay_; }
/** Sets the WTE-to-Laser delay of EMTC in LHC clock unit.
* @param value new value
*/
void emtcDelay(int value) { emtcDelay_ = value; }
/** Gets the EMTC laser phase in 1/8th LHC clock unit.
* @return emtcPhase
*/
int emtcPhase() const { return emtcPhase_; }
/** Sets the EMTC laser phase in 1/8th LHC clock unit.
* @param value new value
*/
void emtcPhase(int value) { emtcPhase_ = value; }
/** Gets the laser logarithmic attenuator setting in -10dB unit.
* Between 0 and 5*(-10dB), -1 if unknown.
* @return attenuation_dB
*/
int attenuation_dB() const { return attenuation_dB_; }
/** Sets the laser Logarithmic attenuator setting in -10dB unit.
* Between 0 and 5*(-10dB), -1 if unknown.
* @param value new value
*/
void attenuation_dB(int value) { attenuation_dB_ = value; }
/** Gets the laser power setting in percents
* (set with the linear attenuator),
* @return laserPower
*/
int laserPower() const { return laserPower_; }
/** Sets the laser power setting in percents
* (set with the linear attenuator),
* @param value new value
*/
void laserPower(int value) { laserPower_ = value; }
#endif
void init() {
#if (ECAL_MATACQ_DIGI_VERS >= 2)
bxId_ = -1;
l1a_ = -1;
triggerType_ = -1;
orbitId_ = -1;
trigRec_ = -1;
postTrig_ = -1;
vernier_ = std::vector<Int_t>(4, -1);
delayA_ = -1;
emtcDelay_ = -1;
emtcPhase_ = -1;
attenuation_dB_ = -1;
laserPower_ = -1;
tv_sec_ = 0;
tv_usec_ = 0;
#endif
}
private:
/** Electronic channel id
*/
int chId_;
/** ADC count of time samples
*/
std::vector<Short_t> data_;
/**Sampling period in seconds. In priniciple 1ns or 0.5ns
*/
double ts_;
/** Trigger time in seconds
*/
double tTrigS_;
/** version of raw data format, the digis originate from.
*/
short version_;
#if (ECAL_MATACQ_DIGI_VERS >= 2)
/** Type of test trigger
* @return triggerType
*/
int8_t triggerType_;
/** Logarithmic attenuator setting in -10dB unit. Between 0 and
* 5*(-10dB), -1 if unknown.
*/
int8_t attenuation_dB_;
/** Bunch crossing Id
*/
Short_t bxId_;
/** Event id. Actually LV1 ID.
*/
Int_t l1a_;
/* LHC orbit ID
*/
Int_t orbitId_;
/** Trig Rec value (see Matacq documentation)
*/
Short_t trigRec_;
/** Posttrig value (see Matacq documentation)
*/
Short_t postTrig_;
/** Vernier values (see Matacq documentation)
*/
std::vector<Int_t> vernier_;
/** "Delay A" setting of laser delay box in ns.
*/
Int_t delayA_;
/** WTE-to-Laser delay of EMTC in LHC clock unit.
*/
Int_t emtcDelay_;
/** EMTC laser phase in 1/8th LHC clock unit.
*/
Int_t emtcPhase_;
/** Laser power in percents (set with the linear attenuator).
*/
Int_t laserPower_;
/** Matacq acquisition time stamp
*/
/** We don't use timeval directly, because its typedef is platform dependent.
*/
Long64_t tv_sec_;
Long64_t tv_usec_;
#endif
};
std::ostream& operator<<(std::ostream& s, const EcalMatacqDigi& digi);
#endif
|