Hall C ROOT/C++ Analyzer (hcana)
Loading...
Searching...
No Matches
THcRawAdcHit.h
Go to the documentation of this file.
1#ifndef ROOT_THcRawAdcHit
2#define ROOT_THcRawAdcHit
3
4#include "TObject.h"
5#include <stdexcept>
6
7class THcRawAdcHit : public TObject {
8public:
10 THcRawAdcHit& operator=( const THcRawAdcHit& right );
11 virtual ~THcRawAdcHit();
12
13 virtual void Clear( Option_t* opt = "" );
14
15 void SetData( Int_t data );
16 void SetSample( Int_t data );
18 void SetRefTime( Int_t refTime );
19 void SetSampThreshold( Double_t thres );
20 void SetSampNSAT( Int_t nsat );
21 void SetRefDiffTime( Int_t refDiffTime );
22 void SetDataTimePedestalPeak( Int_t data, Int_t time, Int_t pedestal,
23 Int_t peak );
24
25 Int_t GetRawData( UInt_t iPulse = 0 ) const;
28 Int_t GetF250_NSA() const { return fNSA; }
29 Int_t GetF250_NSB() const { return fNSB; }
30
31 Double_t GetAverage( UInt_t iSampleLow, UInt_t iSampleHigh ) const;
32 Int_t GetIntegral( UInt_t iSampleLow, UInt_t iSampleHigh ) const;
33 Double_t GetData( UInt_t iPedLow, UInt_t iPedHigh,
34 UInt_t iIntLow, UInt_t iIntHigh ) const;
35
36 UInt_t GetNPulses() const;
37 UInt_t GetNSampPulses() const;
38 UInt_t GetNSamples() const;
39
40 Bool_t HasMulti() const;
41 Bool_t HasRefTime() const;
42
43 Int_t GetPedRaw() const;
44 Int_t GetSampPedRaw() const;
45 Int_t GetPulseIntRaw( UInt_t iPulse = 0 ) const;
46 Int_t GetPulseAmpRaw( UInt_t iPulse = 0 ) const;
47 Int_t GetPulseTimeRaw( UInt_t iPulse = 0 ) const;
48 Int_t GetSampleRaw( UInt_t iSample = 0 ) const;
49 Int_t GetSampPulseIntRaw( UInt_t iPulse = 0 ) const;
50 Int_t GetSampPulseAmpRaw( UInt_t iPulse = 0 ) const;
51 Int_t GetSampPulseTimeRaw( UInt_t iPulse = 0 ) const;
52 Int_t GetRefTime() const;
53 Int_t GetRefDiffTime() const;
54
55 Double_t GetPed() const;
56 Double_t GetSampPed() const;
57 Double_t GetSample( UInt_t iSample = 0 ) const;
58 Double_t GetPulseInt( UInt_t iPulse = 0 ) const;
59 Double_t GetPulseAmp( UInt_t iPulse = 0 ) const;
60 Double_t GetPulseTime( UInt_t iPulse = 0 ) const;
61 Double_t GetSampPulseInt( UInt_t iPulse = 0 ) const;
62 Double_t GetSampPulseAmp( UInt_t iPulse = 0 ) const;
63 Double_t GetSampPulseTime( UInt_t iPulse = 0 ) const;
64
65 Int_t GetSampleIntRaw() const;
66 Double_t GetSampleInt() const;
67 constexpr static Double_t GetAdcTomV();
68 constexpr static Double_t GetAdcTopC();
69 constexpr static Double_t GetAdcTons();
70
71 void SetF250Params( Int_t NSA, Int_t NSB, Int_t NPED );
72
73protected:
74 static constexpr UInt_t fMaxNPulses = 4;
75 static constexpr UInt_t fMaxNSamples = 1024;
76
77 // FADC conversion factors
78 static constexpr Double_t fNAdcChan = 4096.0; // Number of FADC channels in units of ADC channels
79 static constexpr Double_t fAdcRange = 1.0; // Dynamic range of FADCs in units of V, // TO-DO: Get fAdcRange from pre-start event
80 static constexpr Double_t fAdcImpedence = 50.0; // FADC input impedence in units of Ohms
81 static constexpr Double_t fAdcTimeSample = 4000.0; // Length of FADC time sample in units of ps
82 static constexpr Double_t fAdcTimeRes = 0.0625; // FADC time resolution in units of ns
83
84 Int_t fNPedestalSamples; // TODO: Get this from prestart event...
89
93
105
111
112 static void throw_bad_index( const char* loc, UInt_t i, UInt_t N );
113 static void throw_bad_range( const char* loc, UInt_t lo, UInt_t hi, UInt_t N );
114
116};
117
118// FADC conversion factors
119// Convert pedestal and amplitude to mV
121 // 1000 mV / 4096 ADC channels
122 return (fAdcRange * 1000. / fNAdcChan);
123}
124
125// Convert integral to pC
127 // (1 V / 4096 adc channels) * (4000 ps time sample / 50 ohms input resistance) = 0.020 pc/channel
129}
130
131// Convert time sub samples to ns
133 return fAdcTimeRes;
134}
135
136inline
138 return fNPulses;
139}
140
141inline
145
146inline
148 return fNSamples;
149}
150
151inline
153 return fHasMulti;
154}
155
156inline
158 return fPed;
159}
160
161inline
163 return fSampPed;
164}
165
166inline
168 return (static_cast<Double_t>(fPed) / static_cast<Double_t>(fNPedestalSamples)) * GetAdcTomV();
169}
170
171inline
173 return (static_cast<Double_t>(fSampPed) / static_cast<Double_t>(fNPedestalSamples)) * GetAdcTomV();
174}
175
176inline
178 return (static_cast<Double_t>(fPulseInt[iPulse]) - static_cast<Double_t>(fPed) * fPeakPedestalRatio) * GetAdcTopC();
179}
180
181inline
183 return (static_cast<Double_t>(fSampPulseInt[iPulse]) - static_cast<Double_t>(fSampPed) * fPeakPedestalRatio) *
184 GetAdcTopC();
185}
186
187inline
189 return (static_cast<Double_t>(fPulseAmp[iPulse]) -
190 static_cast<Double_t>(fPed) / static_cast<Double_t>(fNPedestalSamples)) * GetAdcTomV();
191}
192
193inline
195 return (static_cast<Double_t>(fSampPulseAmp[iPulse]) -
196 static_cast<Double_t>(fSampPed) / static_cast<Double_t>(fNPedestalSamples)) * GetAdcTomV();
197}
198
199inline
201 Int_t rawtime = fPulseTime[iPulse];
202 if( fHasRefTime ) {
203 rawtime -= fRefTime;
204 }
205 return (static_cast<Double_t>(rawtime) * GetAdcTons());
206}
207
208inline
210 Int_t rawtime = fSampPulseTime[iPulse];
211 if( fHasRefTime ) {
212 rawtime -= fRefTime;
213 }
214 return (static_cast<Double_t>(rawtime) * GetAdcTons());
215}
216
217inline
219 return fSampPulseTime[iPulse];
220}
221
222inline
224 return fSampPulseInt[iPulse];
225}
226
227inline
229 return fSampPulseAmp[iPulse];
230}
231
232
233inline
235 Int_t integral = 0;
236
237 for( UInt_t iSample = 0; iSample < fNSamples; ++iSample ) {
238 integral += fSample[iSample];
239 }
240
241 return integral;
242}
243
244inline
246 return static_cast<Double_t>(GetSampleIntRaw()) - GetPed() * static_cast<Double_t>(fNSamples);
247}
248
249inline
251 if( fNPulses == 0 && iPulse == 0 )
252 return 0;
253 if( iPulse >= fNPulses )
254 throw_bad_index(__FUNCTION__ , iPulse, fNPulses);
255
256 return fPulseInt[iPulse];
257}
258
259inline
260Double_t THcRawAdcHit::GetAverage( UInt_t iSampleLow, UInt_t iSampleHigh ) const {
261 if( iSampleHigh >= fNSamples || iSampleLow > iSampleHigh )
262 throw_bad_range(__FUNCTION__, iSampleLow, iSampleHigh, fNSamples);
263
264 Double_t average = 0.0;
265 for( UInt_t i = iSampleLow; i <= iSampleHigh; ++i ) {
266 average += fSample[i];
267 }
268 return average / (iSampleHigh - iSampleLow + 1);
269}
270
271
272inline
273Int_t THcRawAdcHit::GetIntegral( UInt_t iSampleLow, UInt_t iSampleHigh ) const {
274 if( iSampleHigh >= fNSamples || iSampleLow > iSampleHigh )
275 throw_bad_range(__FUNCTION__, iSampleLow, iSampleHigh, fNSamples);
276
277 Int_t integral = 0;
278 for( UInt_t i = iSampleLow; i <= iSampleHigh; ++i ) {
279 integral += fSample[i];
280 }
281 return integral;
282}
283
284inline
286 UInt_t iPedLow, UInt_t iPedHigh, UInt_t iIntLow, UInt_t iIntHigh) const {
287 return
288 GetIntegral(iIntLow, iIntHigh)
289 - GetAverage(iPedHigh, iPedLow) * (iIntHigh - iIntLow + 1);
290}
291
292inline
294 if( fNPulses == 0 && iPulse == 0 )
295 return 0;
296 if( iPulse >= fNPulses )
297 throw_bad_index(__FUNCTION__ , iPulse, fNPulses);
298
299 return fPulseInt[iPulse];
300}
301
302inline
304 if( fNPulses == 0 && iPulse == 0 )
305 return 0;
306 if( iPulse >= fNPulses )
307 throw_bad_index(__FUNCTION__ , iPulse, fNPulses);
308
309 return fPulseAmp[iPulse];
310}
311
312inline
314 if( fNPulses == 0 && iPulse == 0 )
315 return 0;
316 if( iPulse >= fNPulses )
317 throw_bad_index(__FUNCTION__ , iPulse, fNPulses);
318
319 return fPulseTime[iPulse];
320}
321
322inline
324 if( iSample >= fNSamples )
325 throw_bad_index(__FUNCTION__ , iSample, fNSamples);
326
327 return fSample[iSample];
328}
329
330inline
332 if( iSample >= fNSamples )
333 throw_bad_index(__FUNCTION__ , iSample, fNSamples);
334
335 return fSample[iSample] * GetAdcTomV() - GetSampPed();
336}
337
338inline
340 if( !fHasRefTime )
341 throw std::runtime_error("THcRawAdcHit::GetRefTime: Reference time not available!");
342
343 return fRefTime;
344}
345
346inline
348 if( !fHasRefTime )
349 throw std::runtime_error("THcRawAdcHit::GetRefDiffTime: Reference time not available!");
350
351 return fRefDiffTime;
352}
353
354inline
356 return fHasRefTime;
357}
358
359
360#endif // ROOT_THcRawAdcHit
int Int_t
unsigned int UInt_t
std::vector< uint32_t > integral
bool Bool_t
double Double_t
const char Option_t
#define ClassDef(name, id)
Class representing a single raw ADC hit.
Definition THcRawAdcHit.h:7
Int_t GetSampPulseIntRaw(UInt_t iPulse=0) const
UInt_t GetNSampPulses() const
Double_t GetSampPulseInt(UInt_t iPulse=0) const
Int_t GetPedRaw() const
Gets raw signal pedestal. In channels.
Bool_t fHasRefTime
Int_t GetSampPulseAmpRaw(UInt_t iPulse=0) const
Double_t GetSampPulseTime(UInt_t iPulse=0) const
UInt_t GetNPulses() const
Gets number of set pulses.
void SetData(Int_t data)
Sets raw ADC value.
Int_t GetF250_NSB() const
UInt_t GetNSamples() const
Gets number of set samples.
static void throw_bad_index(const char *loc, UInt_t i, UInt_t N)
static constexpr Double_t fAdcTimeRes
Int_t GetSampPedRaw() const
Int_t fPulseTime[fMaxNPulses]
virtual ~THcRawAdcHit()
Destructor.
Bool_t HasRefTime() const
void SetSampNSAT(Int_t nsat)
void SetRefDiffTime(Int_t refDiffTime)
void SetDataTimePedestalPeak(Int_t data, Int_t time, Int_t pedestal, Int_t peak)
Sets various bits of ADC data.
THcRawAdcHit & operator=(const THcRawAdcHit &right)
Assignment operator.
static constexpr Double_t fAdcTimeSample
static constexpr Double_t GetAdcTopC()
void SetSampThreshold(Double_t thres)
Double_t GetPulseAmp(UInt_t iPulse=0) const
Gets pedestal subtracted pulse amplitude. In channels.
Int_t GetRefTime() const
Double_t GetSample(UInt_t iSample=0) const
Bool_t HasMulti() const
Queries whether data is from flash 250 module.
static constexpr UInt_t fMaxNSamples
void SetSampIntTimePedestalPeak()
Int_t fSampPulseInt[fMaxNPulses]
Int_t fSample[fMaxNSamples]
Int_t GetPulseAmpRaw(UInt_t iPulse=0) const
Gets raw pulse amplitude. In channels.
Double_t fPeakPedestalRatio
static void throw_bad_range(const char *loc, UInt_t lo, UInt_t hi, UInt_t N)
Double_t GetPed() const
Gets sample pedestal. In channels.
Double_t GetF250_PeakPedestalRatio() const
Int_t GetPulseTimeRaw(UInt_t iPulse=0) const
Gets raw pulse time. In subsamples.
Double_t GetSampPulseAmp(UInt_t iPulse=0) const
static constexpr Double_t fNAdcChan
Double_t GetPulseTime(UInt_t iPulse=0) const
Int_t GetRawData(UInt_t iPulse=0) const
Gets raw pulse integral. In channels.
Double_t GetSampleInt() const
Gets pedestal subtracted integral of samples. In channels.
Int_t fSampPulseAmp[fMaxNPulses]
static constexpr UInt_t fMaxNPulses
Int_t GetF250_NPedestalSamples() const
Int_t GetSampleRaw(UInt_t iSample=0) const
Gets raw sample. In channels.
Int_t GetPulseIntRaw(UInt_t iPulse=0) const
Gets raw pulse integral. In channels.
Int_t fPulseInt[fMaxNPulses]
static constexpr Double_t fAdcImpedence
Double_t fSampThreshold
Int_t GetSampPulseTimeRaw(UInt_t iPulse=0) const
Int_t fPulseAmp[fMaxNPulses]
void SetSample(Int_t data)
Sets raw signal sample.
Double_t GetAverage(UInt_t iSampleLow, UInt_t iSampleHigh) const
Gets average of raw samples. In channels.
Double_t GetSampPed() const
Int_t GetRefDiffTime() const
static constexpr Double_t fAdcRange
Int_t GetF250_NSA() const
virtual void Clear(Option_t *opt="")
Clears variables before next event.
Int_t fNPeakSamples
Int_t GetIntegral(UInt_t iSampleLow, UInt_t iSampleHigh) const
Gets integral of raw samples. In channels.
THcRawAdcHit()
Constructor.
static constexpr Double_t GetAdcTomV()
Double_t fSubsampleToTimeFactor
UInt_t fNSampPulses
void SetF250Params(Int_t NSA, Int_t NSB, Int_t NPED)
Sets F250 parameters used for pedestal subtraction.
Int_t fNPedestalSamples
Int_t GetSampleIntRaw() const
Gets raw integral of sTimeFacamples. In channels.
static constexpr Double_t GetAdcTons()
Double_t GetData(UInt_t iPedLow, UInt_t iPedHigh, UInt_t iIntLow, UInt_t iIntHigh) const
Gets pedestal subtracted integral of samples. In channels.
void SetRefTime(Int_t refTime)
Sets reference time. In channels.
Int_t fSampPulseTime[fMaxNPulses]
Double_t GetPulseInt(UInt_t iPulse=0) const
Gets pedestal subtracted pulse integral. In channels.