CMS 3D CMS Logo

HcalQIECoder.cc
Go to the documentation of this file.
1 
10 #include <iostream>
11 
14 
15 namespace {
16  // pack range/capId in the plain index
17  inline unsigned index(unsigned fRange, unsigned fCapId) { return fCapId * 4 + fRange; }
18 } // namespace
19 
20 float HcalQIECoder::charge(const HcalQIEShape& fShape, unsigned fAdc, unsigned fCapId) const {
21  unsigned range = fShape.range(fAdc);
22  return (fShape.center(fAdc) - offset(fCapId, range)) / slope(fCapId, range);
23 }
24 
25 unsigned HcalQIECoder::adc(const HcalQIEShape& fShape, float fCharge, unsigned fCapId) const {
26  // search for the range
27  for (unsigned range = 0; range < 4; range++) {
28  float qieCharge = fCharge * slope(fCapId, range) + offset(fCapId, range);
29  unsigned nbin = fShape.nbins(); // it's just 64 = 2*32 ! (for QIE10)
30  unsigned minBin = nbin * range;
31  unsigned maxBin = minBin + nbin - 1;
32  float qieChargeMax = fShape.highEdge(maxBin);
33  if (qieCharge <= qieChargeMax) {
34  for (unsigned bin = minBin; bin <= maxBin; bin++) {
35  if (qieCharge < fShape.highEdge(bin)) {
36  return bin;
37  }
38  }
39  return minBin; // underflow
40  } else if (range == 3) {
41  return (4 * nbin - 1); // overflow
42  }
43  }
44  return 0; //should never get here
45 }
46 
47 float HcalQIECoder::offset(unsigned fCapId, unsigned fRange) const { return *((&mOffset00) + index(fRange, fCapId)); }
48 
49 float HcalQIECoder::slope(unsigned fCapId, unsigned fRange) const { return *((&mSlope00) + index(fRange, fCapId)); }
50 
51 void HcalQIECoder::setOffset(unsigned fCapId, unsigned fRange, float fValue) {
52  if (fCapId < 4U && fRange < 4U) { // fCapId >= 0 and fRange >= 0, since fCapId and fRange are unsigned
53  *((&mOffset00) + index(fRange, fCapId)) = fValue;
54  } else {
55  std::cerr << "HcalQIECoder::setOffset-> Wrong parameters capid/range: " << fCapId << '/' << fRange << std::endl;
56  }
57 }
58 
59 void HcalQIECoder::setSlope(unsigned fCapId, unsigned fRange, float fValue) {
60  if (fCapId < 4U && fRange < 4U) { // fCapId >= 0 and fRange >= 0, since fCapId and fRange are unsigned
61  *((&mSlope00) + index(fRange, fCapId)) = fValue;
62  } else {
63  std::cerr << "HcalQIECoder::setSlope-> Wrong parameters capid/range: " << fCapId << '/' << fRange << std::endl;
64  }
65 }
cms::cuda::allocator::minBin
constexpr unsigned int minBin
Definition: getCachingDeviceAllocator.h:18
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
HcalQIEShape.h
HcalQIECoder::mOffset00
float mOffset00
Definition: HcalQIECoder.h:40
HcalQIECoder::charge
float charge(const HcalQIEShape &fShape, unsigned fAdc, unsigned fCapId) const
ADC [0..127] + capid [0..3] -> fC conversion.
Definition: HcalQIECoder.cc:20
HcalQIECoder::offset
float offset(unsigned fCapId, unsigned fRange) const
Definition: HcalQIECoder.cc:47
HcalQIECoder.h
HcalQIECoder::setOffset
void setOffset(unsigned fCapId, unsigned fRange, float fValue)
Definition: HcalQIECoder.cc:51
mitigatedMETSequence_cff.U
U
Definition: mitigatedMETSequence_cff.py:36
HcalQIEShape::highEdge
float highEdge(unsigned fAdc) const
Definition: HcalQIEShape.cc:46
HcalQIEShape::center
float center(unsigned fAdc) const
Definition: HcalQIEShape.cc:36
beam_dqm_sourceclient-live_cfg.cerr
cerr
Definition: beam_dqm_sourceclient-live_cfg.py:17
cms::cuda::allocator::maxBin
constexpr unsigned int maxBin
Definition: getCachingDeviceAllocator.h:20
HcalQIEShape::nbins
unsigned nbins() const
Definition: HcalQIEShape.h:33
newFWLiteAna.bin
bin
Definition: newFWLiteAna.py:161
HcalQIECoder::slope
float slope(unsigned fCapId, unsigned fRange) const
Definition: HcalQIECoder.cc:49
HcalQIECoder::setSlope
void setSlope(unsigned fCapId, unsigned fRange, float fValue)
Definition: HcalQIECoder.cc:59
HcalQIEShape::range
unsigned range(unsigned fAdc) const
Definition: HcalQIEShape.h:25
ZMuMuCategoriesSequences_cff.nbin
nbin
Definition: ZMuMuCategoriesSequences_cff.py:25
HcalQIECoder::mSlope00
float mSlope00
Definition: HcalQIECoder.h:56
HcalQIEShape
Definition: HcalQIEShape.h:17
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
HcalQIECoder::adc
unsigned adc(const HcalQIEShape &fShape, float fCharge, unsigned fCapId) const
fC + capid [0..3] -> ADC conversion
Definition: HcalQIECoder.cc:25