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 #include <iostream>
6 
9 
16 public:
18 
19  static const unsigned MAXSAMPLES = 10;
20 
22  : id_(),
23  rawCharge_{0.},
24  pedestal_{0.},
25  pedestalWidth_{0.},
26  gain_{0.},
27  gainWidth_{0.},
28  darkCurrent_{0},
29  fcByPE_{0},
30  lambda_{0},
31  noisecorr_{0},
32  riseTime_{0.f},
33  adc_{0},
34  dFcPerADC_{0.f},
35  recoShape_{0},
36  nSamples_{0},
37  soi_{0},
38  capid_{0},
39  hasTimeInfo_{false},
41  dropped_{true},
42  hasLinkError_{false},
43  hasCapidError_{false} {}
44 
45  constexpr explicit HBHEChannelInfo(const bool hasTimeFromTDC, const bool hasEffectivePed)
46  : id_(),
47  rawCharge_{0.},
48  pedestal_{0.},
49  pedestalWidth_{0.},
50  gain_{0.},
51  gainWidth_{0.},
52  darkCurrent_{0},
53  fcByPE_{0},
54  lambda_{0},
55  noisecorr_{0},
56  riseTime_{0.f},
57  adc_{0},
58  dFcPerADC_{0.f},
59  recoShape_{0},
60  nSamples_{0},
61  soi_{0},
62  capid_{0},
63  hasTimeInfo_(hasTimeFromTDC),
64  hasEffectivePedestals_(hasEffectivePed),
65  dropped_{true},
66  hasLinkError_{false},
67  hasCapidError_{false} {}
68 
69  constexpr void clear() {
70  id_ = HcalDetId(0U);
71  recoShape_ = 0;
72  nSamples_ = 0;
73  soi_ = 0;
74  capid_ = 0;
75  darkCurrent_ = 0;
76  fcByPE_ = 0;
77  lambda_ = 0, dropped_ = true;
78  noisecorr_ = 0;
79  hasLinkError_ = false;
80  hasCapidError_ = false;
81  }
82 
84  const int recoShape,
85  const unsigned nSamp,
86  const unsigned iSoi,
87  const int iCapid,
88  const double darkCurrent,
89  const double fcByPE,
90  const double lambda,
91  const double noisecorr,
92  const bool linkError,
93  const bool capidError,
94  const bool dropThisChannel) {
96  id_ = detId;
97  nSamples_ = nSamp < MAXSAMPLES ? nSamp : MAXSAMPLES;
98  soi_ = iSoi;
99  capid_ = iCapid;
101  fcByPE_ = fcByPE;
102  lambda_ = lambda, dropped_ = dropThisChannel;
104  hasLinkError_ = linkError;
105  hasCapidError_ = capidError;
106  }
107 
108  constexpr void tagAsDropped() { dropped_ = true; }
109 
110  // For speed, the "setSample" function does not perform bounds checking
111  constexpr void setSample(const unsigned ts,
112  const uint8_t rawADC,
113  const float differentialChargeGain,
114  const double q,
115  const double ped,
116  const double pedWidth,
117  const double g,
118  const double gainWidth,
119  const float t) {
120  rawCharge_[ts] = q;
121  riseTime_[ts] = t;
122  adc_[ts] = rawADC;
123  dFcPerADC_[ts] = differentialChargeGain;
124  pedestal_[ts] = ped;
125  gain_[ts] = g;
126  pedestalWidth_[ts] = pedWidth;
127  gainWidth_[ts] = gainWidth;
128  }
129 
130  // Inspectors
131  constexpr HcalDetId id() const { return id_; }
132 
133  // access the recoShape
134  constexpr int recoShape() const { return recoShape_; }
135 
136  constexpr unsigned nSamples() const { return nSamples_; }
137  constexpr unsigned soi() const { return soi_; }
138  constexpr int capid() const { return capid_; }
139  constexpr bool hasTimeInfo() const { return hasTimeInfo_; }
141  constexpr double darkCurrent() const { return darkCurrent_; }
142  constexpr double fcByPE() const { return fcByPE_; }
143  constexpr double lambda() const { return lambda_; }
144  constexpr double noisecorr() const { return noisecorr_; }
145  constexpr bool isDropped() const { return dropped_; }
146  constexpr bool hasLinkError() const { return hasLinkError_; }
147  constexpr bool hasCapidError() const { return hasCapidError_; }
148 
149  // Direct read-only access to time slice arrays
150  constexpr double const* rawCharge() const { return rawCharge_; }
151  constexpr double const* pedestal() const { return pedestal_; }
152  constexpr double const* pedestalWidth() const { return pedestalWidth_; }
153  constexpr double const* gain() const { return gain_; }
154  constexpr double const* gainWidth() const { return gainWidth_; }
155  constexpr uint8_t const* adc() const { return adc_; }
156  constexpr float const* dFcPerADC() const { return dFcPerADC_; }
157  constexpr float const* riseTime() const {
158  if (hasTimeInfo_)
159  return riseTime_;
160  else
161  return nullptr;
162  }
163 
164  // Indexed access to time slice quantities. No bounds checking.
165  constexpr double tsRawCharge(const unsigned ts) const { return rawCharge_[ts]; }
166  constexpr double tsPedestal(const unsigned ts) const { return pedestal_[ts]; }
167  constexpr double tsPedestalWidth(const unsigned ts) const { return pedestalWidth_[ts]; }
168  constexpr double tsGain(const unsigned ts) const { return gain_[ts]; }
169  constexpr double tsGainWidth(const unsigned ts) const { return gainWidth_[ts]; }
170  constexpr double tsCharge(const unsigned ts) const { return rawCharge_[ts] - pedestal_[ts]; }
171  constexpr double tsEnergy(const unsigned ts) const { return (rawCharge_[ts] - pedestal_[ts]) * gain_[ts]; }
172  constexpr uint8_t tsAdc(const unsigned ts) const { return adc_[ts]; }
173  constexpr float tsDFcPerADC(const unsigned ts) const { return dFcPerADC_[ts]; }
174  constexpr float tsRiseTime(const unsigned ts) const {
176  }
177 
178  // Signal rise time measurement for the SOI, if available
179  constexpr float soiRiseTime() const {
181  }
182 
183  // The TS with the "end" index is not included in the window
184  constexpr double chargeInWindow(const unsigned begin, const unsigned end) const {
185  double sum = 0.0;
186  const unsigned imax = end < nSamples_ ? end : nSamples_;
187  for (unsigned i = begin; i < imax; ++i)
188  sum += (rawCharge_[i] - pedestal_[i]);
189  return sum;
190  }
191 
192  constexpr double energyInWindow(const unsigned begin, const unsigned end) const {
193  double sum = 0.0;
194  const unsigned imax = end < nSamples_ ? end : nSamples_;
195  for (unsigned i = begin; i < imax; ++i)
196  sum += (rawCharge_[i] - pedestal_[i]) * gain_[i];
197  return sum;
198  }
199 
200  // The two following methods return MAXSAMPLES if the specified
201  // window does not overlap with the samples stored
202  constexpr unsigned peakChargeTS(const unsigned begin, const unsigned end) const {
203  unsigned iPeak = MAXSAMPLES;
204  double dmax = -DBL_MAX;
205  const unsigned imax = end < nSamples_ ? end : nSamples_;
206  for (unsigned i = begin; i < imax; ++i) {
207  const double q = rawCharge_[i] - pedestal_[i];
208  if (q > dmax) {
209  dmax = q;
210  iPeak = i;
211  }
212  }
213  return iPeak;
214  }
215 
216  constexpr unsigned peakEnergyTS(const unsigned begin, const unsigned end) const {
217  unsigned iPeak = MAXSAMPLES;
218  double dmax = -DBL_MAX;
219  const unsigned imax = end < nSamples_ ? end : nSamples_;
220  for (unsigned i = begin; i < imax; ++i) {
221  const double e = (rawCharge_[i] - pedestal_[i]) * gain_[i];
222  if (e > dmax) {
223  dmax = e;
224  iPeak = i;
225  }
226  }
227  return iPeak;
228  }
229 
230  // The following function can be used, for example,
231  // in a check for presence of saturated ADC values
232  constexpr uint8_t peakAdcValue(const unsigned begin, const unsigned end) const {
233  uint8_t peak = 0;
234  const unsigned imax = end < nSamples_ ? end : nSamples_;
235  for (unsigned i = begin; i < imax; ++i)
236  if (adc_[i] > peak)
237  peak = adc_[i];
238  return peak;
239  }
240 
241 private:
243 
244  // Charge in fC for all time slices
246 
247  // Pedestal in fC
249 
250  // Pedestal Width in fC
252 
253  // fC to GeV conversion factor
254  double gain_[MAXSAMPLES];
255 
256  // fC to GeV conversion factor
258 
259  // needed for the dark current
260  double darkCurrent_;
261  double fcByPE_;
262  double lambda_;
263  double noisecorr_;
264 
265  // Signal rise time from TDC in ns (if provided)
267 
268  // Raw QIE ADC values
269  uint8_t adc_[MAXSAMPLES];
270 
271  // Differential fC/ADC gain. Needed for proper determination
272  // of the ADC quantization error.
274 
275  // Reco Shapes
276  int32_t recoShape_;
277 
278  // Number of time slices actually filled
279  uint32_t nSamples_;
280 
281  // "Sample of interest" in the array of time slices
282  uint32_t soi_;
283 
284  // QIE8 or QIE11 CAPID for the sample of interest
285  int32_t capid_;
286 
287  // Flag indicating presence of the time info from TDC (QIE11)
289 
290  // Flag indicating use of effective pedestals
292 
293  // Flag indicating that this channel should be dropped
294  // (typically, tagged bad from DB or zero-suppressed)
295  bool dropped_;
296 
297  // Flags indicating presence of hardware errors
300 };
301 
302 std::ostream& operator<<(std::ostream& s, const HBHEChannelInfo& inf);
303 
304 #endif // DataFormats_HcalRecHit_HBHEChannelInfo_h_
constexpr uint8_t const * adc() const
constexpr double const * pedestal() const
constexpr double tsEnergy(const unsigned ts) const
constexpr double noisecorr() const
constexpr double fcByPE() const
constexpr int recoShape() const
constexpr bool hasCapidError() const
constexpr float tsDFcPerADC(const unsigned ts) const
constexpr float const * riseTime() const
constexpr double tsRawCharge(const unsigned ts) const
constexpr bool hasEffectivePedestals() const
constexpr double chargeInWindow(const unsigned begin, const unsigned end) const
constexpr float tsRiseTime(const unsigned ts) const
double gainWidth_[MAXSAMPLES]
constexpr unsigned peakEnergyTS(const unsigned begin, const unsigned end) const
constexpr double tsGainWidth(const unsigned ts) const
constexpr HBHEChannelInfo(const bool hasTimeFromTDC, const bool hasEffectivePed)
HcalDetId key_type
constexpr double tsPedestalWidth(const unsigned ts) 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
constexpr double const * gainWidth() const
float dFcPerADC_[MAXSAMPLES]
constexpr HcalDetId id() const
static const unsigned MAXSAMPLES
constexpr int capid() const
constexpr double const * pedestalWidth() const
double pedestalWidth_[MAXSAMPLES]
constexpr float soiRiseTime() const
string inf
Definition: EcalCondDB.py:96
constexpr double const * rawCharge() const
constexpr double tsGain(const unsigned ts) const
constexpr uint8_t peakAdcValue(const unsigned begin, const unsigned end) const
constexpr bool hasLinkError() const
uint8_t adc_[MAXSAMPLES]
constexpr double energyInWindow(const unsigned begin, const unsigned end) const
constexpr unsigned soi() const
double gain_[MAXSAMPLES]
constexpr 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 double noisecorr, const bool linkError, const bool capidError, const bool dropThisChannel)
double pedestal_[MAXSAMPLES]
constexpr HBHEChannelInfo()
std::ostream & operator<<(std::ostream &s, const HBHEChannelInfo &inf)
constexpr void clear()
constexpr bool isDropped() const
constexpr bool hasTimeInfo() const
constexpr double tsCharge(const unsigned ts) const
double rawCharge_[MAXSAMPLES]
constexpr unsigned nSamples() const
constexpr uint8_t tsAdc(const unsigned ts) const
constexpr double tsPedestal(const unsigned ts) const
constexpr void tagAsDropped()
constexpr float UNKNOWN_T_NOTDC
constexpr unsigned peakChargeTS(const unsigned begin, const unsigned end) const
constexpr float const * dFcPerADC() const
constexpr double darkCurrent() const
constexpr double const * gain() const
constexpr double lambda() const
constexpr 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)
float riseTime_[MAXSAMPLES]