Newer
Older
/**
\class THcRawTdcHit
\ingroup DetSupport
\brief Class representing a single raw TDC hit.
*/
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
/**
\fn THcRawTdcHit::THcRawTdcHit()
\brief Constructor.
*/
/**
\fn THcRawTdcHit& THcRawTdcHit::operator=(const THcRawTdcHit& right)
\brief Assignment operator.
\param[in] right Raw TDC hit to be assigned.
*/
/**
\fn THcRawTdcHit::~THcRawTdcHit()
\brief Destructor.
*/
/**
\fn void THcRawTdcHit::Clear(Option_t* opt="")
\brief Clears variables before next event.
\param[in] opt Maybe used in base clas... Not sure.
*/
/**
\fn void THcRawTdcHit::SetTime(Int_t time)
\brief Sets raw TDC time from the modules. In channels.
\param[in] time Raw TDC time from the modules. In channels.
\throw std::out_of_range Tried to set too many hits.
*/
/**
\fn void THcRawTdcHit::SetRefTime(Int_t refTime)
\brief Sets reference time. In channels.
\param[in] refTime Reference time. In channels.
*/
/**
\fn Int_t THcRawTdcHit::GetTimeRaw(UInt_t iHit=0) const
\brief Gets raw TDC time. In channels.
\param[in] iHit Sequential number of requested hit.
\throw std::out_of_range Tried to access nonexisting hit.
Returns 0 if tried to access first hit but no hits are set.
*/
/**
\fn Int_T THcRawTdcHit::GetTime(UInt_t iHit=0) const
\brief Gets TDC time. In channels.
\param[in] iHit Sequential number of requested hit.
Returned time is corrected for reference time, if available.
*/
/**
\fn Int_t THcRawTdcHit::GetRefTime() const
\brief Gets reference time. In channels.
\throw std::runtime_error No reference time was set.
*/
/**
\fn Bool_t THcRawTdcHit::HasRefTime() const
\brief Queries whether reference time has been set.
*/
/**
\fn UInt_t THcRawTdcHit::GetNHits() const
\brief Gets the number of set hits.
*/
#include "THcRawTdcHit.h"
#include <stdexcept>
#include <TString.h>
THcRawTdcHit::THcRawTdcHit() :
TObject(),
fChannelToTimeFactor(0.1),
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
fTime(), fRefTime(0), fHasRefTime(kFALSE), fNHits(0)
{}
THcRawTdcHit& THcRawTdcHit::operator=(const THcRawTdcHit& right) {
TObject::operator=(right);
if (this != &right) {
for (UInt_t iHit=0; iHit<fMaxNHits; ++iHit) {
fTime[iHit] = right.fTime[iHit];
}
fRefTime = right.fRefTime;
fHasRefTime = right.fHasRefTime;
fNHits = right.fNHits;
}
return *this;
}
THcRawTdcHit::~THcRawTdcHit() {}
void THcRawTdcHit::Clear(Option_t* opt) {
TObject::Clear(opt);
for (UInt_t iHit=0; iHit<fNHits; ++iHit) {
fTime[iHit] = 0;
}
fRefTime = 0;
fHasRefTime = kFALSE;
fNHits = 0;
}
void THcRawTdcHit::SetTime(Int_t time) {
if (fNHits < fMaxNHits) {
fTime[fNHits] = time;
++fNHits;
}
else {
TString msg = TString::Format(
"`THcRawTdcHit::SetTime`: Trying to set too many hits! Only %d slots available.",
fMaxNHits
);
throw std::out_of_range(msg.Data());
}
}
void THcRawTdcHit::SetRefTime(Int_t refTime) {
fRefTime = refTime;
fHasRefTime = kTRUE;
}
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
Int_t THcRawTdcHit::GetTimeRaw(UInt_t iHit) const {
if (iHit < fNHits) {
return fTime[iHit];
}
else if (iHit == 0) {
return 0;
}
else {
TString msg = TString::Format(
"`THcRawTdcHit::GetTimeRaw`: Trying to get hit %d where only %d hits available!",
iHit, fNHits
);
throw std::out_of_range(msg.Data());
}
}
Int_t THcRawTdcHit::GetTime(UInt_t iHit) const {
Int_t time = GetTimeRaw(iHit);
if (fHasRefTime) {
time -= fRefTime;
}
return time;
}
Int_t THcRawTdcHit::GetRefTime() const {
if (fHasRefTime) {
return fRefTime;
}
else {
TString msg = TString::Format(
"`THcRawTdcHit::GetRefTime`: Reference time not available!"
);
throw std::runtime_error(msg.Data());
}
}
Bool_t THcRawTdcHit::HasRefTime() const {
UInt_t THcRawTdcHit::GetNHits() const {
return fNHits;
}