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