Hall A ROOT/C++ Analyzer (podd)
Loading...
Searching...
No Matches
DetectorData.h
Go to the documentation of this file.
1
2//
3// Podd::DetectorData
4//
5// Generic detector data (ADCs and TDCs)
6//
8
9#ifndef PODD_DETECTORDATA_H
10#define PODD_DETECTORDATA_H
11
12#include "TNamed.h"
13#include "DataType.h" // for Data_t
14#include "THaAnalysisObject.h" // for enums (EMode etc.)
15#include "VarDef.h" // for RVarDef
16#include "THaDetMap.h"
17#include <string>
18
19// Silence rootcling warnings from ClassDef macros
20#ifdef __clang__
21#pragma clang diagnostic ignored "-Winconsistent-missing-override"
22#endif
23
24namespace Podd {
25
26//_____________________________________________________________________________
27class DetectorData : public TNamed {
28public:
29 DetectorData() = delete;
30
31 virtual Int_t StoreHit( const DigitizerHitInfo_t& hitinfo, UInt_t data ) = 0;
32 virtual Int_t GetLogicalChannel( const DigitizerHitInfo_t& hitinfo ) const;
33 virtual UInt_t GetSize() const = 0;
34
35 void Clear( Option_t* ="" ) override;
36 virtual void Reset( Option_t* ="" ) {};
39 const char* key_prefix = "",
40 const char* comment_subst = "" );
41
42 Bool_t HitDone() const { return fHitDone; }
43 Bool_t IsSetup() const { return fVarOK; }
44 void ClearHitDone() { fHitDone = false; }
45
46protected:
47 // Only derived classes may construct
48 DetectorData( const char* name, const char* desc );
49 // For exception message formatting
50 static std::string msg( const DigitizerHitInfo_t& hitinfo, const char* txt );
51 // Actual DefineVariables implementation, called from DefineVariables
54 const char* key_prefix = "",
55 const char* comment_subst = "" );
56 // Standard DefineVariables implementation
57 Int_t StdDefineVariables( const RVarDef* vars, THaAnalysisObject::EMode mode,
58 const char* key_prefix, const char* here,
59 const char* comment_subst );
60
61 Bool_t fVarOK; // Global variables are set up
62 Bool_t fHitDone; // StoreHit called for current hit
63
64 ClassDef(DetectorData, 1) // Base class for detector raw data
65};
66
67//_____________________________________________________________________________
68// ADC info
69struct ADCCalib_t {
70 ADCCalib_t() : ped(0), gain(1), mip(1e10), twalk(0) {}
71 void adc_calib_reset() { ped = 0; gain = 1; mip = 1e10; twalk = 0; }
72 Data_t ped; // ADC pedestal (channels)
73 Data_t gain; // ADC gain (a.u.)
74 Data_t mip; // ADC MIP for twalk correction (channels)
75 Data_t twalk; // Timewalk correction coefficient
76};
77
78struct ADCData_t {
81 void adc_clear() { adc = kMinInt; adc_p = adc_c = kBig; nadc = 0; }
82 UInt_t adc; // Raw ADC amplitude (channels)
83 Data_t adc_p; // Pedestal-subtracted ADC amplitude
84 Data_t adc_c; // Gain-corrected ADC amplitude
85 UInt_t nadc; // Number of hits on this ADC
86};
87
88// TDC info
89struct TDCCalib_t {
90 TDCCalib_t() : tdc2t(5e-10), off(0) {}
91 void tdc_calib_reset() { tdc2t = 5e-10; off = 0; }
92 Data_t tdc2t; // Conversion coefficient from raw TDC to time (s/ch)
93 Data_t off; // TDC offset (channels)
94};
95
96struct TDCData_t {
98 void tdc_clear() { tdc = kMinInt; tdc_c = kBig; ntdc = 0; }
99 UInt_t tdc; // Raw TDC time (channels)
100 Data_t tdc_c; // Converted TDC time, corrected for offset (s)
101 UInt_t ntdc; // Number of hits on this TDC
102};
103
104// ADC and TDC combined
109
110struct PMTData_t : public ADCData_t, public TDCData_t {
112 void clear() { adc_clear(); tdc_clear(); }
113};
114
116 HitCount_t() : tdc(0), adc(0) {}
117 void clear() { tdc = adc = 0; }
118 // These counters indicate for how many TDC/ADC channels, respectively,
119 // any data was found in the raw data stream, even if uninteresting
120 // (below pedestal etc.)
121 UInt_t tdc; // Count of TDCs with one or more hits
122 UInt_t adc; // Count of ADCs with one or more hits
123};
124
125//_____________________________________________________________________________
126class ADCData : public DetectorData {
127public:
128 ADCData( const char* name, const char* desc, UInt_t nelem );
129
130 Int_t StoreHit( const DigitizerHitInfo_t& hitinfo,
131 UInt_t data ) override;
132
133 void Clear( Option_t* ="" ) override;
134 void Reset( Option_t* ="" ) override;
135
136 UInt_t GetHitCount() const { return fNHits; }
137 UInt_t GetSize() const override { return fCalib.size(); }
138#ifdef NDEBUG
139 ADCCalib_t& GetCalib( size_t i ) { return fCalib[i]; }
140 ADCData_t& GetADC( size_t i ) { return fADCs[i]; }
141#else
142 ADCCalib_t& GetCalib( size_t i ) { return fCalib.at(i); }
143 ADCData_t& GetADC( size_t i ) { return fADCs.at(i); }
144#endif
146 { return GetCalib(GetLogicalChannel(hitinfo)); }
148 { return GetADC(GetLogicalChannel(hitinfo)); }
149
150protected:
151 // Calibration
152 std::vector<ADCCalib_t> fCalib; // Calibration constants
153
154 // Per-event data
155 std::vector<ADCData_t> fADCs; // ADC data
156 UInt_t fNHits; // Number of ADCs with signal
157
160 const char* key_prefix = "",
161 const char* comment_subst = "" ) override;
162
163 ClassDef(ADCData, 1) // ADC raw data
164};
165
166//_____________________________________________________________________________
167class PMTData : public DetectorData {
168public:
169 PMTData( const char* name, const char* desc, UInt_t nelem );
170
171 Int_t StoreHit( const DigitizerHitInfo_t& hitinfo,
172 UInt_t data ) override;
173
174 void Clear( Option_t* ="" ) override;
175 void Reset( Option_t* ="" ) override;
176
178 UInt_t GetSize() const override { return fCalib.size(); }
179#ifdef NDEBUG
180 PMTCalib_t& GetCalib( size_t i ) { return fCalib[i]; }
181 PMTData_t& GetPMT( size_t i ) { return fPMTs[i]; }
182#else
183 PMTCalib_t& GetCalib( size_t i ) { return fCalib.at(i); }
184 PMTData_t& GetPMT( size_t i ) { return fPMTs.at(i); }
185#endif
187 { return GetCalib(GetLogicalChannel(hitinfo)); }
189 { return GetPMT(GetLogicalChannel(hitinfo)); }
190
191protected:
192 // Calibration
193 std::vector<PMTCalib_t> fCalib; // Calibration constants
194
195 // Per-event data
196 std::vector<PMTData_t> fPMTs; // PMT data (ADCs & TDCs)
197 HitCount_t fNHits; // Number of ADCs/TDCs with signal
198
201 const char* key_prefix = "",
202 const char* comment_subst = "" ) override;
203
204 ClassDef(PMTData, 1) // Photomultiplier tube raw data (ADC & TDC)
205};
206
207} // namespace Podd
208
209#endif //PODD_DETECTORDATA_H
int Int_t
unsigned int UInt_t
Double_t Data_t
Definition DataType.h:13
const Data_t kBig
Definition DataType.h:15
#define e(i)
bool Bool_t
const Int_t kMinInt
const UInt_t kMaxUInt
const char Option_t
#define ClassDef(name, id)
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
char name[80]
static const char *const here
Definition THaVar.cxx:64
ADCData_t & GetADC(size_t i)
std::vector< ADCData_t > fADCs
UInt_t GetSize() const override
UInt_t GetHitCount() const
std::vector< ADCCalib_t > fCalib
void Reset(Option_t *="") override
Int_t StoreHit(const DigitizerHitInfo_t &hitinfo, UInt_t data) override
void Clear(Option_t *="") override
ADCCalib_t & GetCalib(const DigitizerHitInfo_t &hitinfo)
ADCCalib_t & GetCalib(size_t i)
Int_t DefineVariablesImpl(THaAnalysisObject::EMode mode=THaAnalysisObject::kDefine, const char *key_prefix="", const char *comment_subst="") override
ADCData_t & GetADC(const DigitizerHitInfo_t &hitinfo)
virtual Int_t DefineVariablesImpl(THaAnalysisObject::EMode mode=THaAnalysisObject::kDefine, const char *key_prefix="", const char *comment_subst="")
virtual Int_t GetLogicalChannel(const DigitizerHitInfo_t &hitinfo) const
Bool_t HitDone() const
virtual Int_t StoreHit(const DigitizerHitInfo_t &hitinfo, UInt_t data)=0
static std::string msg(const DigitizerHitInfo_t &hitinfo, const char *txt)
virtual void Reset(Option_t *="")
Int_t DefineVariables(THaAnalysisObject::EMode mode=THaAnalysisObject::kDefine, const char *key_prefix="", const char *comment_subst="")
virtual UInt_t GetSize() const =0
Int_t StdDefineVariables(const RVarDef *vars, THaAnalysisObject::EMode mode, const char *key_prefix, const char *here, const char *comment_subst)
void Clear(Option_t *="") override
Bool_t IsSetup() const
std::vector< PMTData_t > fPMTs
HitCount_t & GetHitCount()
PMTCalib_t & GetCalib(const DigitizerHitInfo_t &hitinfo)
Int_t DefineVariablesImpl(THaAnalysisObject::EMode mode=THaAnalysisObject::kDefine, const char *key_prefix="", const char *comment_subst="") override
PMTData_t & GetPMT(size_t i)
UInt_t GetSize() const override
std::vector< PMTCalib_t > fCalib
Int_t StoreHit(const DigitizerHitInfo_t &hitinfo, UInt_t data) override
void Clear(Option_t *="") override
HitCount_t fNHits
PMTCalib_t & GetCalib(size_t i)
void Reset(Option_t *="") override
PMTData_t & GetPMT(const DigitizerHitInfo_t &hitinfo)