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