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  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 
83  constexpr void setChannelInfo(const HcalDetId& detId,
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_; }
140  constexpr bool hasEffectivePedestals() const { return hasEffectivePedestals_; }
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_
HBHEChannelInfo::tsDFcPerADC
constexpr float tsDFcPerADC(const unsigned ts) const
Definition: HBHEChannelInfo.h:173
HBHEChannelInfo::riseTime
constexpr float const * riseTime() const
Definition: HBHEChannelInfo.h:157
HBHEChannelInfo::id_
HcalDetId id_
Definition: HBHEChannelInfo.h:242
HBHEChannelInfo::chargeInWindow
constexpr double chargeInWindow(const unsigned begin, const unsigned end) const
Definition: HBHEChannelInfo.h:184
mps_fire.i
i
Definition: mps_fire.py:428
HBHEChannelInfo::hasTimeInfo
constexpr bool hasTimeInfo() const
Definition: HBHEChannelInfo.h:139
HBHEChannelInfo::rawCharge_
double rawCharge_[MAXSAMPLES]
Definition: HBHEChannelInfo.h:245
HBHEChannelInfo::tsRiseTime
constexpr float tsRiseTime(const unsigned ts) const
Definition: HBHEChannelInfo.h:174
HBHEChannelInfo::nSamples
constexpr unsigned nSamples() const
Definition: HBHEChannelInfo.h:136
HBHEChannelInfo::fcByPE_
double fcByPE_
Definition: HBHEChannelInfo.h:261
HBHEChannelInfo::gain
constexpr double const * gain() const
Definition: HBHEChannelInfo.h:153
HBHEChannelInfo::peakChargeTS
constexpr unsigned peakChargeTS(const unsigned begin, const unsigned end) const
Definition: HBHEChannelInfo.h:202
HBHEChannelInfo::dropped_
bool dropped_
Definition: HBHEChannelInfo.h:295
HBHEChannelInfo::darkCurrent_
double darkCurrent_
Definition: HBHEChannelInfo.h:260
HcalSpecialTimes.h
HBHEChannelInfo::tsPedestalWidth
constexpr double tsPedestalWidth(const unsigned ts) const
Definition: HBHEChannelInfo.h:167
HBHEChannelInfo::noisecorr_
double noisecorr_
Definition: HBHEChannelInfo.h:263
HBHEChannelInfo::tsGain
constexpr double tsGain(const unsigned ts) const
Definition: HBHEChannelInfo.h:168
HBHEChannelInfo::peakAdcValue
constexpr uint8_t peakAdcValue(const unsigned begin, const unsigned end) const
Definition: HBHEChannelInfo.h:232
HBHEChannelInfo::darkCurrent
constexpr double darkCurrent() const
Definition: HBHEChannelInfo.h:141
HBHEChannelInfo::lambda
constexpr double lambda() const
Definition: HBHEChannelInfo.h:143
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:111
HBHEChannelInfo::hasLinkError_
bool hasLinkError_
Definition: HBHEChannelInfo.h:298
HBHEChannelInfo::capid
constexpr int capid() const
Definition: HBHEChannelInfo.h:138
HBHEChannelInfo::pedestalWidth
constexpr double const * pedestalWidth() const
Definition: HBHEChannelInfo.h:152
HBHEChannelInfo::adc
constexpr uint8_t const * adc() const
Definition: HBHEChannelInfo.h:155
HBHEChannelInfo::pedestal
constexpr double const * pedestal() const
Definition: HBHEChannelInfo.h:151
HBHEChannelInfo::gainWidth_
double gainWidth_[MAXSAMPLES]
Definition: HBHEChannelInfo.h:257
HBHEChannelInfo::isDropped
constexpr bool isDropped() const
Definition: HBHEChannelInfo.h:145
alignCSCRings.s
s
Definition: alignCSCRings.py:92
HBHEChannelInfo::fcByPE
constexpr double fcByPE() const
Definition: HBHEChannelInfo.h:142
HBHEChannelInfo::rawCharge
constexpr double const * rawCharge() const
Definition: HBHEChannelInfo.h:150
HBHEChannelInfo::key_type
HcalDetId key_type
Definition: HBHEChannelInfo.h:17
HBHEChannelInfo::recoShape
constexpr int recoShape() const
Definition: HBHEChannelInfo.h:134
HcalSpecialTimes::UNKNOWN_T_NOTDC
constexpr float UNKNOWN_T_NOTDC
Definition: HcalSpecialTimes.h:42
mps_fire.end
end
Definition: mps_fire.py:242
HBHEChannelInfo::hasEffectivePedestals_
bool hasEffectivePedestals_
Definition: HBHEChannelInfo.h:291
HBHEChannelInfo::tsAdc
constexpr uint8_t tsAdc(const unsigned ts) const
Definition: HBHEChannelInfo.h:172
HBHEChannelInfo::lambda_
double lambda_
Definition: HBHEChannelInfo.h:262
HBHEChannelInfo::gain_
double gain_[MAXSAMPLES]
Definition: HBHEChannelInfo.h:254
HBHEChannelInfo::tsPedestal
constexpr double tsPedestal(const unsigned ts) const
Definition: HBHEChannelInfo.h:166
HBHEChannelInfo::hasEffectivePedestals
constexpr bool hasEffectivePedestals() const
Definition: HBHEChannelInfo.h:140
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:279
HBHEChannelInfo::gainWidth
constexpr double const * gainWidth() const
Definition: HBHEChannelInfo.h:154
HBHEChannelInfo::HBHEChannelInfo
constexpr HBHEChannelInfo(const bool hasTimeFromTDC, const bool hasEffectivePed)
Definition: HBHEChannelInfo.h:45
HcalDetId.h
HBHEChannelInfo::capid_
int32_t capid_
Definition: HBHEChannelInfo.h:285
HBHEChannelInfo::soiRiseTime
constexpr float soiRiseTime() const
Definition: HBHEChannelInfo.h:179
HcalDetId
Definition: HcalDetId.h:12
HBHEChannelInfo::tsCharge
constexpr double tsCharge(const unsigned ts) const
Definition: HBHEChannelInfo.h:170
submitPVResolutionJobs.q
q
Definition: submitPVResolutionJobs.py:84
HBHEChannelInfo::hasLinkError
constexpr bool hasLinkError() const
Definition: HBHEChannelInfo.h:146
HBHEChannelInfo::riseTime_
float riseTime_[MAXSAMPLES]
Definition: HBHEChannelInfo.h:266
HBHEChannelInfo::adc_
uint8_t adc_[MAXSAMPLES]
Definition: HBHEChannelInfo.h:269
HBHEChannelInfo::energyInWindow
constexpr double energyInWindow(const unsigned begin, const unsigned end) const
Definition: HBHEChannelInfo.h:192
HBHEChannelInfo::dFcPerADC_
float dFcPerADC_[MAXSAMPLES]
Definition: HBHEChannelInfo.h:273
HBHEChannelInfo::id
constexpr HcalDetId id() const
Definition: HBHEChannelInfo.h:131
HBHEChannelInfo::pedestal_
double pedestal_[MAXSAMPLES]
Definition: HBHEChannelInfo.h:248
HBHEChannelInfo::dFcPerADC
constexpr float const * dFcPerADC() const
Definition: HBHEChannelInfo.h:156
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:251
HBHEChannelInfo::clear
constexpr void clear()
Definition: HBHEChannelInfo.h:69
HBHEChannelInfo::recoShape_
int32_t recoShape_
Definition: HBHEChannelInfo.h:276
operator<<
std::ostream & operator<<(std::ostream &s, const HBHEChannelInfo &inf)
Definition: HBHEChannelInfo.cc:21
HBHEChannelInfo::soi_
uint32_t soi_
Definition: HBHEChannelInfo.h:282
HBHEChannelInfo::hasCapidError
constexpr bool hasCapidError() const
Definition: HBHEChannelInfo.h:147
HBHEChannelInfo::tsRawCharge
constexpr double tsRawCharge(const unsigned ts) const
Definition: HBHEChannelInfo.h:165
HBHEChannelInfo::hasTimeInfo_
bool hasTimeInfo_
Definition: HBHEChannelInfo.h:288
HBHEChannelInfo::hasCapidError_
bool hasCapidError_
Definition: HBHEChannelInfo.h:299
HBHEChannelInfo::soi
constexpr unsigned soi() const
Definition: HBHEChannelInfo.h:137
HBHEChannelInfo::tagAsDropped
constexpr void tagAsDropped()
Definition: HBHEChannelInfo.h:108
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 double noisecorr, const bool linkError, const bool capidError, const bool dropThisChannel)
Definition: HBHEChannelInfo.h:83
HBHEChannelInfo::tsEnergy
constexpr double tsEnergy(const unsigned ts) const
Definition: HBHEChannelInfo.h:171
HBHEChannelInfo::peakEnergyTS
constexpr unsigned peakEnergyTS(const unsigned begin, const unsigned end) const
Definition: HBHEChannelInfo.h:216
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
HBHEChannelInfo::noisecorr
constexpr double noisecorr() const
Definition: HBHEChannelInfo.h:144
HBHEChannelInfo::tsGainWidth
constexpr double tsGainWidth(const unsigned ts) const
Definition: HBHEChannelInfo.h:169
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