Newer
Older
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
/**
\class THcTrigRawHit
\ingroup DetSupport
\brief Class representing a single raw hit for the THcTrigDet.
Contains plane, counter and an ADC or a TDC value.
Note: not yet finalized!
*/
#include "THcTrigRawHit.h"
#include <stdexcept>
THcTrigRawHit::THcTrigRawHit(
Int_t plane, Int_t counter
) :
THcRawHit(plane, counter),
fAdcVal(), fTdcVal(), fNumAdcSamples(0), fNumTdcSamples(0),
fAdcReferenceTime(0), fTdcReferenceTime(0),
fHasAdcRef(kFALSE), fHasTdcRef(kFALSE)
{}
THcTrigRawHit& THcTrigRawHit::operator=(const THcTrigRawHit& right) {
// Call base class assignment operator.
THcRawHit::operator=(right);
for (UInt_t i=0; i<fNumAdcSamples; ++i) fAdcVal[i] = right.fAdcVal[i];
for (UInt_t i=0; i<fNumTdcSamples; ++i) fTdcVal[i] = right.fTdcVal[i];
fNumAdcSamples = right.fNumAdcSamples;
fNumTdcSamples = right.fNumTdcSamples;
fAdcReferenceTime = right.fAdcReferenceTime;
fTdcReferenceTime = right.fTdcReferenceTime;
fHasAdcRef = right.fHasAdcRef;
fHasTdcRef = right.fHasTdcRef;
return *this;
}
THcTrigRawHit::~THcTrigRawHit() {}
void THcTrigRawHit::Clear(Option_t* opt) {
fNumAdcSamples = 0;
fNumTdcSamples = 0;
fHasAdcRef = kFALSE;
fHasTdcRef = kFALSE;
}
void THcTrigRawHit::SetData(Int_t signal, Int_t data) {
// TODO: check if signal matches plane.
// Signal 0 is ADC.
if (signal == 0) {
if (fNumAdcSamples >= fMaxAdcSamples) {
throw std::out_of_range(
"`THcTrigRawHit::SetData`: too many samples for ADC signal!"
);
}
fAdcVal[fNumAdcSamples] = data;
++fNumAdcSamples;
}
// Signal 1 is TDC.
else if (signal == 1) {
if (fNumTdcSamples >= fMaxTdcSamples) {
throw std::out_of_range(
"`THcTrigRawHit::SetData`: too many samples for TDC signal!"
);
}
fTdcVal[fNumTdcSamples] = data;
++fNumTdcSamples;
}
else throw std::out_of_range("`THcTrigRawHit::SetData`: only signals `0` and `1` available!");
}
void THcTrigRawHit::SetReference(Int_t signal, Int_t reference) {
if (signal == 0) fAdcReferenceTime = reference;
else if (signal == 1) fTdcReferenceTime = reference;
else throw std::out_of_range("`THcTrigRawHit::SetReference`: only signals `0` and `1` available!");
}
Int_t THcTrigRawHit::GetData(Int_t signal) {
// TODO: expand this. Maybe add new methods.
// For now only returns first value.
if (signal == 0) return fAdcVal[0];
else if (signal == 1) return fTdcVal[0];
else throw std::out_of_range("`THcTrigRawHit::GetData`: only signals `0` and `1` available!");
}
Int_t THcTrigRawHit::GetReference(Int_t signal) {
// Reference time.
if (signal == 0) return fAdcReferenceTime;
else if (signal == 1) return fTdcReferenceTime;
else throw std::out_of_range("`THcTrigRawHit::GetReference`: only signals `0` and `1` available!");
}
Bool_t THcTrigRawHit::HasReference(Int_t signal) {
// Reference time.
if (signal == 0) return fHasAdcRef;
else if (signal == 1) return fHasTdcRef;
else throw std::out_of_range("`THcTrigRawHit::HasReference`: only signals `0` and `1` available!");
}
ClassImp(THcTrigRawHit)