CMS 3D CMS Logo

L1GctHtMissLut.cc
Go to the documentation of this file.
2 
4 
5 #include <cmath>
6 
7 //DEFINE STATICS
10 
12  : L1GctLut<NAddress, NData>(), m_etScale(scale), m_componentLsb(lsb) {
13  if (scale != nullptr)
14  m_setupOk = true;
15 }
16 
17 L1GctHtMissLut::L1GctHtMissLut() : L1GctLut<NAddress, NData>(), m_etScale(nullptr), m_componentLsb(1.0) {}
18 
20  : L1GctLut<NAddress, NData>(), m_etScale(lut.etScale()), m_componentLsb(lut.componentLsb()) {
21  if (m_etScale != nullptr)
22  m_setupOk = true;
23 }
24 
26 
27 uint16_t L1GctHtMissLut::value(const uint16_t lutAddress) const {
28  uint16_t result = 0;
29 
30  if (lutAddress != 0) {
31  static const int maxComponent = 1 << kHxOrHyMissComponentNBits;
32  static const int componentMask = maxComponent - 1;
33 
34  static const int magnitudeMask = (1 << kHtMissMagnitudeNBits) - 1;
35  static const int angleMask = (1 << kHtMissAngleNBits) - 1;
36 
37  // Extract the bits corresponding to hx and hy components
38  int hxCompGct = static_cast<int>(lutAddress >> kHxOrHyMissComponentNBits) & componentMask;
39  int hyCompGct = static_cast<int>(lutAddress) & componentMask;
40 
41  // These are twos-complement integers - if the MSB is set, the value is negative
42  if (hxCompGct >= maxComponent / 2)
43  hxCompGct -= maxComponent;
44  if (hyCompGct >= maxComponent / 2)
45  hyCompGct -= maxComponent;
46 
47  // Convert to GeV. Add 0.5 to each component to compensate for truncation errors.
48  double hxCompGeV = m_componentLsb * (static_cast<double>(hxCompGct) + 0.5);
49  double hyCompGeV = m_componentLsb * (static_cast<double>(hyCompGct) + 0.5);
50 
51  // Convert to magnitude and angle
52  double htMissMag = sqrt(hxCompGeV * hxCompGeV + hyCompGeV * hyCompGeV);
53  double htMissAng = atan2(hyCompGeV, hxCompGeV);
54  if (htMissAng < 0.0)
55  htMissAng += 2.0 * M_PI;
56 
57  // Convert back to integer
58  int htMissMagBits = static_cast<int>(m_etScale->rank(htMissMag)) & magnitudeMask;
59  int htMissAngBits = static_cast<int>(htMissAng * 9.0 / M_PI) & angleMask;
60 
61  // Form the lut output
62  result = (htMissMagBits << kHtMissAngleNBits) | htMissAngBits;
63  }
64 
65  return result;
66 }
67 
68 std::vector<double> L1GctHtMissLut::getThresholdsGeV() const { return m_etScale->getThresholds(); }
69 
70 std::vector<unsigned> L1GctHtMissLut::getThresholdsGct() const {
71  std::vector<unsigned> result;
72  std::vector<double> thresholdsGeV = m_etScale->getThresholds();
73  for (std::vector<double>::const_iterator thr = thresholdsGeV.begin(); thr != thresholdsGeV.end(); thr++) {
74  result.push_back(static_cast<unsigned>((*thr) / (m_componentLsb)));
75  }
76  return result;
77 }
78 
80  const L1GctHtMissLut& temp(lut);
81  return temp;
82 }
83 
84 std::ostream& operator<<(std::ostream& os, const L1GctHtMissLut& lut) {
85  os << "===L1GctHtMissLut===" << std::endl;
86  std::vector<double> thresholds = lut.m_etScale->getThresholds();
87  std::vector<double>::const_iterator thr = thresholds.begin();
88  os << "Thresholds are: " << *(thr++);
89  for (; thr != thresholds.end(); thr++) {
90  os << ", " << *thr;
91  }
92  os << std::endl;
93  os << "Max values for input to et scale " << lut.m_etScale->linScaleMax() << " and for output "
94  << lut.m_etScale->rankScaleMax() << std::endl;
95  os << "LSB used for conversion is " << lut.m_componentLsb << " GeV" << std::endl;
96  os << "\n===Lookup table contents===\n" << std::endl;
98  os << *temp;
99  return os;
100 }
101 
L1GctHtMissLut::operator=
L1GctHtMissLut operator=(const L1GctHtMissLut &lut)
Overload = operator.
Definition: L1GctHtMissLut.cc:79
L1GctHtMissLut::m_etScale
const L1CaloEtScale * m_etScale
Definition: L1GctHtMissLut.h:65
particleFlowZeroSuppressionECAL_cff.thresholds
thresholds
Definition: particleFlowZeroSuppressionECAL_cff.py:31
HLT_FULL_cff.scale
scale
Definition: HLT_FULL_cff.py:6634
L1GctHtMissLut::getThresholdsGct
std::vector< unsigned > getThresholdsGct() const
Definition: L1GctHtMissLut.cc:70
L1GctHtMissLut.h
L1GctHtMissLut::getThresholdsGeV
std::vector< double > getThresholdsGeV() const
Get thresholds.
Definition: L1GctHtMissLut.cc:68
hgcalVFEProducer_cfi.lsb
lsb
Definition: hgcalVFEProducer_cfi.py:80
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
L1CaloEtScale::rankScaleMax
unsigned rankScaleMax() const
Definition: L1CaloEtScale.h:51
operator<<
std::ostream & operator<<(std::ostream &os, const L1GctHtMissLut &lut)
Definition: L1GctHtMissLut.cc:84
L1GctHtMissLut::~L1GctHtMissLut
~L1GctHtMissLut() override
Destructor.
Definition: L1GctHtMissLut.cc:25
L1GctLut< 16, 12 >::m_setupOk
bool m_setupOk
Definition: L1GctLut.h:77
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
L1GctHtMissLut::kHtMissAngleNBits
Definition: L1GctHtMissLut.h:24
L1CaloEtScale::linScaleMax
unsigned linScaleMax() const
Definition: L1CaloEtScale.h:48
hgcalConcentratorProducer_cfi.NData
NData
Definition: hgcalConcentratorProducer_cfi.py:81
L1GctHtMissLut::value
uint16_t value(const uint16_t lutAddress) const override
Definition: L1GctHtMissLut.cc:27
L1CaloEtScale
Definition: L1CaloEtScale.h:29
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:49
L1GctHtMissLut::L1GctHtMissLut
L1GctHtMissLut()
Default constructor.
Definition: L1GctHtMissLut.cc:17
L1GctHtMissLut::kHxOrHyMissComponentNBits
Definition: L1GctHtMissLut.h:24
L1CaloEtScale::rank
uint16_t rank(const uint16_t linear) const
convert from linear Et scale to rank scale
Definition: L1CaloEtScale.cc:52
L1CaloEtScale.h
L1CaloEtScale::getThresholds
const std::vector< double > & getThresholds() const
get thresholds
Definition: L1CaloEtScale.h:66
L1GctLut
Base class for LookUp Tables.
Definition: L1GctLut.h:19
L1GctHtMissLut
LUT for conversion of Ht components x and y to magnitude and angle.
Definition: L1GctHtMissLut.h:20
L1GctHtMissLut::m_componentLsb
double m_componentLsb
Definition: L1GctHtMissLut.h:67
L1GctHtMissLut::kHtMissMagnitudeNBits
Definition: L1GctHtMissLut.h:24
mps_fire.result
result
Definition: mps_fire.py:311
L1GctHtMissLut::NAddress
static const int NAddress
Definition: L1GctHtMissLut.h:27
L1GctHtMissLut::NData
static const int NData
Definition: L1GctHtMissLut.h:27
photonValidator_cfi.etScale
etScale
Definition: photonValidator_cfi.py:47