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
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
/**
\class THcTrigRawHit
\ingroup DetSupport
\brief Class representing a single raw ADC hit.
It supports rich data from flash 250 ADC modules.
*/
#include "THcRawAdcHit.h"
#include <stdexcept>
#include "TString.h"
THcRawAdcHit::THcRawAdcHit() :
TObject(),
fAdc(), fAdcTime(), fAdcPedestal(), fAdcPeak(), fAdcSample(),
fHasMulti(kFALSE), fNPulses(0), fNSamples(0)
{}
THcRawAdcHit& THcRawAdcHit::operator=(const THcRawAdcHit& right) {
TObject::operator=(right);
if (this != &right) {
for (UInt_t i=0; i<fMaxNPulses; ++i) {
fAdc[i] = right.fAdc[i];
fAdcTime[i] = right.fAdcTime[i];
fAdcPedestal[i] = right.fAdcPedestal[i];
fAdcPeak[i] = right.fAdcPeak[i];
}
for (UInt_t i=0; i<fMaxNSamples; ++i) {
fAdcSample[i] = right.fAdcSample[i];
}
fHasMulti = right.fHasMulti;
fNPulses = right.fNPulses;
fNSamples = right.fNSamples;
}
return *this;
}
THcRawAdcHit::~THcRawAdcHit() {}
void THcRawAdcHit::Clear(Option_t* opt) {
TObject::Clear(opt);
//for (UInt_t i=0; i<fMaxNPulses; ++i) {
// fAdc[i] = 0;
// fAdcTime[i] = 0;
// fAdcPedestal[i] = 0;
// fAdcPeak[i] = 0;
//}
//for (UInt_t i=0; i<fMaxNSamples; ++i) {
// fAdcSample[i] = 0 ;
//}
fHasMulti = kFALSE;
fNPulses = 0;
fNSamples = 0;
}
void THcRawAdcHit::SetData(Int_t data) {
if (fNPulses >= fMaxNPulses) {
throw std::out_of_range(
"`THcRawAdcHit::SetData`: too many pulses!"
);
}
fAdc[fNPulses] = data;
++fNPulses;
}
void THcRawAdcHit::SetSample(Int_t data) {
if (fNSamples >= fMaxNSamples) {
throw std::out_of_range(
"`THcRawAdcHit::SetSample`: too many samples!"
);
}
fAdcSample[fNSamples] = data;
++fNSamples;
}
void THcRawAdcHit::SetDataTimePedestalPeak(
Int_t data, Int_t time, Int_t pedestal, Int_t peak
) {
if (fNPulses >= fMaxNPulses) {
throw std::out_of_range(
"`THcRawAdcHit::SetData`: too many pulses!"
);
}
fAdc[fNPulses] = data;
fAdcTime[fNPulses] = data;
fAdcPedestal[fNPulses] = data;
fAdcPeak[fNPulses] = data;
fHasMulti = kTRUE;
++fNPulses;
}
Int_t THcRawAdcHit::GetRawData(UInt_t iPulse) {
if (iPulse >= fNPulses && iPulse != 0) {
TString msg = TString::Format(
"`THcRawAdcHit::GetRawData`: requested pulse %d where only %d pulses available!",
iPulse, fNPulses
);
throw std::out_of_range(msg.Data());
}
else if (iPulse >= fNPulses && iPulse == 0) {
return 0;
}
else {
return fAdc[iPulse];
}
}
Int_t THcRawAdcHit::GetAdcTime(UInt_t iPulse) {
if (iPulse >= fNPulses && iPulse != 0) {
TString msg = TString::Format(
"`THcRawAdcHit::GetAdcTime`: requested pulse %d where only %d pulses available!",
iPulse, fNPulses
);
throw std::out_of_range(msg.Data());
}
else if (fHasMulti) {
return fAdcTime[iPulse];
}
else {
return 0;
}
}
Int_t THcRawAdcHit::GetAdcPedestal(UInt_t iPulse) {
if (iPulse >= fNPulses && iPulse != 0) {
TString msg = TString::Format(
"`THcRawAdcHit::GetAdcPedestal`: requested pulse %d where only %d pulses available!",
iPulse, fNPulses
);
throw std::out_of_range(msg.Data());
}
else if (fHasMulti) {
return fAdcPedestal[iPulse];
}
else {
return 0;
}
}
Int_t THcRawAdcHit::GetAdcPeak(UInt_t iPulse) {
if (iPulse >= fNPulses && iPulse != 0) {
TString msg = TString::Format(
"`THcRawAdcHit::GetAdcPeak`: requested pulse %d where only %d pulses available!",
iPulse, fNPulses
);
throw std::out_of_range(msg.Data());
}
else if (fHasMulti) {
return fAdcPeak[iPulse];
}
else {
return 0;
}
}
Int_t THcRawAdcHit::GetSample(UInt_t iSample) {
if (iSample >= fNSamples && iSample != 0) {
TString msg = TString::Format(
"`THcRawAdcHit::GetSample`: requested sample %d where only %d sample available!",
iSample, fNSamples
);
throw std::out_of_range(msg.Data());
}
else if (iSample >= fNSamples && iSample == 0) {
return 0;
}
else {
return fAdcSample[iSample];
}
}
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
Double_t THcRawAdcHit::GetAverage(UInt_t iSampleLow, UInt_t iSampleHigh) {
if (iSampleHigh >= fNSamples || iSampleLow >= fNSamples) {
TString msg = TString::Format(
"`THcRawAdcHit::GetAverage`: not this many samples available!"
);
throw std::out_of_range(msg.Data());
}
else {
Double_t average = 0.0;
for (UInt_t i=iSampleLow; i<=iSampleHigh; ++i) {
average += fAdcSample[i];
}
return average / (iSampleHigh - iSampleLow + 1);
}
}
Int_t THcRawAdcHit::GetIntegral(UInt_t iSampleLow, UInt_t iSampleHigh) {
if (iSampleHigh >= fNSamples || iSampleLow >= fNSamples) {
TString msg = TString::Format(
"`THcRawAdcHit::GetAverage`: not this many samples available!"
);
throw std::out_of_range(msg.Data());
}
else {
Int_t integral = 0;
for (UInt_t i=iSampleLow; i<=iSampleHigh; ++i) {
integral += fAdcSample[i];
}
return integral;
}
}
Double_t THcRawAdcHit::GetData(
UInt_t iPedLow, UInt_t iPedHigh, UInt_t iIntLow, UInt_t iIntHigh
) {
return
GetIntegral(iIntLow, iIntHigh)
- GetAverage(iPedHigh, iPedLow) * (iIntHigh - iIntLow + 1);
}
UInt_t THcRawAdcHit::GetNPulses() {
return fNPulses;
}
UInt_t THcRawAdcHit::GetNSamples() {
return fNSamples;
}
Bool_t THcRawAdcHit::HasMulti() {
return fHasMulti;
}
ClassImp(THcRawAdcHit)