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