CMS 3D CMS Logo

HBHEChannelInfo.h
Go to the documentation of this file.
1 #ifndef DataFormats_HcalRecHit_HBHEChannelInfo_h_
2 #define DataFormats_HcalRecHit_HBHEChannelInfo_h_
3 
4 #include <cfloat>
5 
8 
15 {
16 public:
18 
19  static const unsigned MAXSAMPLES = 10;
20 
22  : id_(), rawCharge_{0.}, pedestal_{0.}, pedestalWidth_{0.},
23  gain_{0.}, gainWidth_{0.}, darkCurrent_{0}, fcByPE_{0}, lambda_{0},
24  riseTime_{0.f}, adc_{0},
25  dFcPerADC_{0.f}, recoShape_{0}, nSamples_{0},
26  soi_{0}, capid_{0}, hasTimeInfo_{false}, hasEffectivePedestals_{false},
27  dropped_{true}, hasLinkError_{false}, hasCapidError_{false}
28  {}
29 
30  constexpr explicit HBHEChannelInfo(const bool hasTimeFromTDC, const bool hasEffectivePed)
31  : id_(), rawCharge_{0.}, pedestal_{0.}, pedestalWidth_{0.},
32  gain_{0.}, gainWidth_{0.}, darkCurrent_{0}, fcByPE_{0}, lambda_{0},
33  riseTime_{0.f}, adc_{0},
34  dFcPerADC_{0.f}, recoShape_{0}, nSamples_{0},
35  soi_{0}, capid_{0}, hasTimeInfo_(hasTimeFromTDC),
36  hasEffectivePedestals_(hasEffectivePed),
37  dropped_{true}, hasLinkError_{false}, hasCapidError_{false}
38  {}
39 
41  {
42  id_ = HcalDetId(0U);
43  recoShape_ = 0;
44  nSamples_ = 0;
45  soi_ = 0;
46  capid_ = 0;
47  darkCurrent_ = 0;
48  fcByPE_ = 0;
49  lambda_ = 0,
50  dropped_ = true;
51  hasLinkError_ = false;
52  hasCapidError_ = false;
53  }
54 
55  constexpr void setChannelInfo(const HcalDetId& detId, const int recoShape, const unsigned nSamp,
56  const unsigned iSoi, const int iCapid,
57  const double darkCurrent, const double fcByPE, const double lambda,
58  const bool linkError, const bool capidError,
59  const bool dropThisChannel)
60  {
62  id_ = detId;
63  nSamples_ = nSamp < MAXSAMPLES ? nSamp : MAXSAMPLES;
64  soi_ = iSoi;
65  capid_ = iCapid;
67  fcByPE_ = fcByPE;
68  lambda_ = lambda,
69  dropped_ = dropThisChannel;
70  hasLinkError_ = linkError;
71  hasCapidError_ = capidError;
72  }
73 
75  {dropped_ = true;}
76 
77  // For speed, the "setSample" function does not perform bounds checking
78  constexpr void setSample(const unsigned ts, const uint8_t rawADC,
79  const float differentialChargeGain, const double q,
80  const double ped, const double pedWidth,
81  const double g, const double gainWidth,
82  const float t)
83  {
84  rawCharge_[ts] = q;
85  riseTime_[ts] = t;
86  adc_[ts] = rawADC;
87  dFcPerADC_[ts] = differentialChargeGain;
88  pedestal_[ts] = ped;
89  gain_[ts] = g;
90  pedestalWidth_[ts] = pedWidth;
91  gainWidth_[ts] = gainWidth;
92  }
93 
94  // Inspectors
95  constexpr HcalDetId id() const {return id_;}
96 
97  // access the recoShape
98  constexpr int recoShape() const { return recoShape_;}
99 
100  constexpr unsigned nSamples() const {return nSamples_;}
101  constexpr unsigned soi() const {return soi_;}
102  constexpr int capid() const {return capid_;}
103  constexpr bool hasTimeInfo() const {return hasTimeInfo_;}
105  constexpr double darkCurrent() const {return darkCurrent_;}
106  constexpr double fcByPE() const {return fcByPE_;}
107  constexpr double lambda() const {return lambda_;}
108  constexpr bool isDropped() const {return dropped_;}
109  constexpr bool hasLinkError() const {return hasLinkError_;}
110  constexpr bool hasCapidError() const {return hasCapidError_;}
111 
112  // Direct read-only access to time slice arrays
113  constexpr double const* rawCharge() const {return rawCharge_;}
114  constexpr double const* pedestal() const {return pedestal_;}
115  constexpr double const* pedestalWidth() const {return pedestalWidth_;}
116  constexpr double const* gain() const {return gain_;}
117  constexpr double const* gainWidth() const {return gainWidth_;}
118  constexpr uint8_t const* adc() const {return adc_;}
119  constexpr float const* dFcPerADC() const {return dFcPerADC_;}
120  constexpr float const* riseTime() const
121  {if (hasTimeInfo_) return riseTime_; else return nullptr;}
122 
123  // Indexed access to time slice quantities. No bounds checking.
124  constexpr double tsRawCharge(const unsigned ts) const {return rawCharge_[ts];}
125  constexpr double tsPedestal(const unsigned ts) const {return pedestal_[ts];}
126  constexpr double tsPedestalWidth(const unsigned ts) const {return pedestalWidth_[ts];}
127  constexpr double tsGain(const unsigned ts) const {return gain_[ts];}
128  constexpr double tsGainWidth(const unsigned ts) const {return gainWidth_[ts];}
129  constexpr double tsCharge(const unsigned ts) const
130  {return rawCharge_[ts] - pedestal_[ts];}
131  constexpr double tsEnergy(const unsigned ts) const
132  {return (rawCharge_[ts] - pedestal_[ts])*gain_[ts];}
133  constexpr uint8_t tsAdc(const unsigned ts) const {return adc_[ts];}
134  constexpr float tsDFcPerADC(const unsigned ts) const {return dFcPerADC_[ts];}
135  constexpr float tsRiseTime(const unsigned ts) const
137 
138  // Signal rise time measurement for the SOI, if available
139  constexpr float soiRiseTime() const
140  {
141  return (hasTimeInfo_ && soi_ < nSamples_) ?
143  }
144 
145  // The TS with the "end" index is not included in the window
146  constexpr double chargeInWindow(const unsigned begin, const unsigned end) const
147  {
148  double sum = 0.0;
149  const unsigned imax = end < nSamples_ ? end : nSamples_;
150  for (unsigned i=begin; i<imax; ++i)
151  sum += (rawCharge_[i] - pedestal_[i]);
152  return sum;
153  }
154 
155  constexpr double energyInWindow(const unsigned begin, const unsigned end) const
156  {
157  double sum = 0.0;
158  const unsigned imax = end < nSamples_ ? end : nSamples_;
159  for (unsigned i=begin; i<imax; ++i)
160  sum += (rawCharge_[i] - pedestal_[i])*gain_[i];
161  return sum;
162  }
163 
164  // The two following methods return MAXSAMPLES if the specified
165  // window does not overlap with the samples stored
166  constexpr unsigned peakChargeTS(const unsigned begin, const unsigned end) const
167  {
168  unsigned iPeak = MAXSAMPLES;
169  double dmax = -DBL_MAX;
170  const unsigned imax = end < nSamples_ ? end : nSamples_;
171  for (unsigned i=begin; i<imax; ++i)
172  {
173  const double q = rawCharge_[i] - pedestal_[i];
174  if (q > dmax)
175  {
176  dmax = q;
177  iPeak = i;
178  }
179  }
180  return iPeak;
181  }
182 
183  constexpr unsigned peakEnergyTS(const unsigned begin, const unsigned end) const
184  {
185  unsigned iPeak = MAXSAMPLES;
186  double dmax = -DBL_MAX;
187  const unsigned imax = end < nSamples_ ? end : nSamples_;
188  for (unsigned i=begin; i<imax; ++i)
189  {
190  const double e = (rawCharge_[i] - pedestal_[i])*gain_[i];
191  if (e > dmax)
192  {
193  dmax = e;
194  iPeak = i;
195  }
196  }
197  return iPeak;
198  }
199 
200  // The following function can be used, for example,
201  // in a check for presence of saturated ADC values
202  constexpr uint8_t peakAdcValue(const unsigned begin, const unsigned end) const
203  {
204  uint8_t peak = 0;
205  const unsigned imax = end < nSamples_ ? end : nSamples_;
206  for (unsigned i=begin; i<imax; ++i)
207  if (adc_[i] > peak)
208  peak = adc_[i];
209  return peak;
210  }
211 
212 private:
214 
215  // Charge in fC for all time slices
217 
218  // Pedestal in fC
220 
221  // Pedestal Width in fC
223 
224  // fC to GeV conversion factor
225  double gain_[MAXSAMPLES];
226 
227  // fC to GeV conversion factor
229 
230  // needed for the dark current
231  double darkCurrent_;
232  double fcByPE_;
233  double lambda_;
234 
235  // Signal rise time from TDC in ns (if provided)
237 
238  // Raw QIE ADC values
239  uint8_t adc_[MAXSAMPLES];
240 
241  // Differential fC/ADC gain. Needed for proper determination
242  // of the ADC quantization error.
244 
245  // Reco Shapes
246  int32_t recoShape_;
247 
248  // Number of time slices actually filled
249  uint32_t nSamples_;
250 
251  // "Sample of interest" in the array of time slices
252  uint32_t soi_;
253 
254  // QIE8 or QIE11 CAPID for the sample of interest
255  int32_t capid_;
256 
257  // Flag indicating presence of the time info from TDC (QIE11)
259 
260  // Flag indicating use of effective pedestals
262 
263  // Flag indicating that this channel should be dropped
264  // (typically, tagged bad from DB or zero-suppressed)
265  bool dropped_;
266 
267  // Flags indicating presence of hardware errors
270 };
271 
272 #endif // DataFormats_HcalRecHit_HBHEChannelInfo_h_
uint8_t const * adc() const
double lambda() const
unsigned peakChargeTS(const unsigned begin, const unsigned end) const
double const * gainWidth() const
bool hasTimeInfo() const
double tsGain(const unsigned ts) const
HBHEChannelInfo(const bool hasTimeFromTDC, const bool hasEffectivePed)
double tsGainWidth(const unsigned ts) const
double gainWidth_[MAXSAMPLES]
unsigned soi() const
double const * pedestalWidth() const
double const * gain() const
HcalDetId key_type
bool hasEffectivePedestals() const
void setSample(const unsigned ts, const uint8_t rawADC, const float differentialChargeGain, const double q, const double ped, const double pedWidth, const double g, const double gainWidth, const float t)
HcalDetId id() const
double const * pedestal() const
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
Definition: Activities.doc:4
#define constexpr
double tsPedestal(const unsigned ts) const
float dFcPerADC_[MAXSAMPLES]
double const * rawCharge() const
double tsRawCharge(const unsigned ts) const
static const unsigned MAXSAMPLES
double pedestalWidth_[MAXSAMPLES]
float soiRiseTime() const
double fcByPE() const
double energyInWindow(const unsigned begin, const unsigned end) const
double tsCharge(const unsigned ts) const
double chargeInWindow(const unsigned begin, const unsigned end) const
#define end
Definition: vmac.h:39
uint8_t adc_[MAXSAMPLES]
int recoShape() const
double gain_[MAXSAMPLES]
double pedestal_[MAXSAMPLES]
double darkCurrent() const
float const * dFcPerADC() const
double tsEnergy(const unsigned ts) const
float tsRiseTime(const unsigned ts) const
double tsPedestalWidth(const unsigned ts) const
double rawCharge_[MAXSAMPLES]
constexpr float UNKNOWN_T_NOTDC
#define begin
Definition: vmac.h:32
bool hasLinkError() const
float const * riseTime() const
void setChannelInfo(const HcalDetId &detId, const int recoShape, const unsigned nSamp, const unsigned iSoi, const int iCapid, const double darkCurrent, const double fcByPE, const double lambda, const bool linkError, const bool capidError, const bool dropThisChannel)
bool isDropped() const
unsigned nSamples() const
int capid() const
uint8_t peakAdcValue(const unsigned begin, const unsigned end) const
uint8_t tsAdc(const unsigned ts) const
bool hasCapidError() const
unsigned peakEnergyTS(const unsigned begin, const unsigned end) const
float tsDFcPerADC(const unsigned ts) const
float riseTime_[MAXSAMPLES]