CMS 3D CMS Logo

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