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