CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | Private Attributes | Friends
L1GctHtMissLut Class Reference

LUT for conversion of Ht components x and y to magnitude and angle. More...

#include <L1GctHtMissLut.h>

Inheritance diagram for L1GctHtMissLut:
L1GctLut< 16, 12 >

Public Types

enum  numberOfBits { kHxOrHyMissComponentNBits = 8, kHtMissMagnitudeNBits = 7, kHtMissAngleNBits = 5 }
 

Public Member Functions

const double componentLsb () const
 
const L1CaloEtScaleetScale () const
 Return the Lut functions and parameters. More...
 
std::vector< unsigned > getThresholdsGct () const
 
std::vector< double > getThresholdsGeV () const
 Get thresholds. More...
 
 L1GctHtMissLut (const L1CaloEtScale *const scale, const double lsb)
 Constructor for use with emulator. More...
 
 L1GctHtMissLut ()
 Default constructor. More...
 
 L1GctHtMissLut (const L1GctHtMissLut &lut)
 Copy constructor. More...
 
L1GctHtMissLut operator= (const L1GctHtMissLut &lut)
 Overload = operator. More...
 
void setEtScale (const L1CaloEtScale *const fn)
 Set the functions. More...
 
void setExEyLsb (const double lsb)
 
 ~L1GctHtMissLut () override
 Destructor. More...
 
- Public Member Functions inherited from L1GctLut< 16, 12 >
uint16_t lutValue (const uint16_t lutAddress) const
 Access the look-up table contents for a given Address. More...
 
int operator!= (const L1GctLut< KAddressBits, KDataBits > &rhsLut) const
 Inequality check between look-up tables. More...
 
int operator== (const L1GctLut< KAddressBits, KDataBits > &rhsLut) const
 Equality check between look-up tables. More...
 
uint16_t operator[] (const uint16_t lutAddress) const
 Access the look-up table contents for a given Address. More...
 
void setTerse ()
 
bool setupOk ()
 
void setVerbose ()
 control output messages More...
 
virtual ~L1GctLut ()
 

Static Public Attributes

static const int NAddress = 2 * L1GctHtMissLut::kHxOrHyMissComponentNBits
 
static const int NData = L1GctHtMissLut::kHtMissMagnitudeNBits + L1GctHtMissLut::kHtMissAngleNBits
 
- Static Public Attributes inherited from L1GctLut< 16, 12 >
static const uint16_t MAX_ADDRESS_BITMASK
 
static const uint16_t MAX_DATA_BITMASK
 

Protected Member Functions

uint16_t value (const uint16_t lutAddress) const override
 
- Protected Member Functions inherited from L1GctLut< 16, 12 >
bool equalityCheck (const L1GctLut< KAddressBits, KDataBits > &c) const
 
 L1GctLut ()
 

Private Attributes

double m_componentLsb
 
const L1CaloEtScalem_etScale
 

Friends

std::ostream & operator<< (std::ostream &os, const L1GctHtMissLut &lut)
 Overload << operator. More...
 

Additional Inherited Members

- Protected Attributes inherited from L1GctLut< 16, 12 >
bool m_setupOk
 
bool m_verbose
 

Detailed Description

LUT for conversion of Ht components x and y to magnitude and angle.

Author
Greg Heath
Date
September 2008

Definition at line 20 of file L1GctHtMissLut.h.

Member Enumeration Documentation

◆ numberOfBits

Enumerator
kHxOrHyMissComponentNBits 
kHtMissMagnitudeNBits 
kHtMissAngleNBits 

Definition at line 24 of file L1GctHtMissLut.h.

Constructor & Destructor Documentation

◆ L1GctHtMissLut() [1/3]

L1GctHtMissLut::L1GctHtMissLut ( const L1CaloEtScale *const  scale,
const double  lsb 
)

Constructor for use with emulator.

Definition at line 11 of file L1GctHtMissLut.cc.

References L1GctLut< 16, 12 >::m_setupOk, and pfClustersFromCombinedCaloHF_cfi::scale.

13  if (scale != nullptr)
14  m_setupOk = true;
15 }
Base class for LookUp Tables.
Definition: L1GctLut.h:19
double m_componentLsb
const L1CaloEtScale * m_etScale

◆ L1GctHtMissLut() [2/3]

L1GctHtMissLut::L1GctHtMissLut ( )

Default constructor.

Definition at line 17 of file L1GctHtMissLut.cc.

Base class for LookUp Tables.
Definition: L1GctLut.h:19
double m_componentLsb
const L1CaloEtScale * m_etScale

◆ L1GctHtMissLut() [3/3]

L1GctHtMissLut::L1GctHtMissLut ( const L1GctHtMissLut lut)

Copy constructor.

Definition at line 19 of file L1GctHtMissLut.cc.

References m_etScale, and L1GctLut< 16, 12 >::m_setupOk.

21  if (m_etScale != nullptr)
22  m_setupOk = true;
23 }
Base class for LookUp Tables.
Definition: L1GctLut.h:19
double m_componentLsb
const L1CaloEtScale * m_etScale
const L1CaloEtScale * etScale() const
Return the Lut functions and parameters.
const double componentLsb() const

◆ ~L1GctHtMissLut()

L1GctHtMissLut::~L1GctHtMissLut ( )
override

Destructor.

Definition at line 25 of file L1GctHtMissLut.cc.

25 {}

Member Function Documentation

◆ componentLsb()

const double L1GctHtMissLut::componentLsb ( ) const
inline

Definition at line 55 of file L1GctHtMissLut.h.

References m_componentLsb.

Referenced by L1GctMet::componentLsb().

55 { return m_componentLsb; }
double m_componentLsb

◆ etScale()

const L1CaloEtScale* L1GctHtMissLut::etScale ( ) const
inline

Return the Lut functions and parameters.

Definition at line 54 of file L1GctHtMissLut.h.

References m_etScale.

Referenced by L1GctMet::etScale().

54 { return m_etScale; }
const L1CaloEtScale * m_etScale

◆ getThresholdsGct()

std::vector< unsigned > L1GctHtMissLut::getThresholdsGct ( ) const

Definition at line 70 of file L1GctHtMissLut.cc.

References L1CaloEtScale::getThresholds(), m_componentLsb, m_etScale, and mps_fire::result.

70  {
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 }
const std::vector< double > & getThresholds() const
get thresholds
Definition: L1CaloEtScale.h:66
double m_componentLsb
const L1CaloEtScale * m_etScale

◆ getThresholdsGeV()

std::vector< double > L1GctHtMissLut::getThresholdsGeV ( ) const

Get thresholds.

Definition at line 68 of file L1GctHtMissLut.cc.

References L1CaloEtScale::getThresholds(), and m_etScale.

68 { return m_etScale->getThresholds(); }
const std::vector< double > & getThresholds() const
get thresholds
Definition: L1CaloEtScale.h:66
const L1CaloEtScale * m_etScale

◆ operator=()

L1GctHtMissLut L1GctHtMissLut::operator= ( const L1GctHtMissLut lut)

Overload = operator.

Definition at line 79 of file L1GctHtMissLut.cc.

References groupFilesInBlocks::temp.

79  {
80  const L1GctHtMissLut& temp(lut);
81  return temp;
82 }
LUT for conversion of Ht components x and y to magnitude and angle.

◆ setEtScale()

void L1GctHtMissLut::setEtScale ( const L1CaloEtScale *const  fn)
inline

Set the functions.

Definition at line 45 of file L1GctHtMissLut.h.

References personalPlayback::fn, m_etScale, and L1GctLut< 16, 12 >::m_setupOk.

Referenced by L1GctMet::setEtScale().

45  {
46  m_etScale = fn;
47  if (fn != nullptr) {
48  m_setupOk = true;
49  }
50  }
const L1CaloEtScale * m_etScale

◆ setExEyLsb()

void L1GctHtMissLut::setExEyLsb ( const double  lsb)
inline

◆ value()

uint16_t L1GctHtMissLut::value ( const uint16_t  lutAddress) const
overrideprotectedvirtual

Implements L1GctLut< 16, 12 >.

Definition at line 27 of file L1GctHtMissLut.cc.

References kHtMissAngleNBits, kHtMissMagnitudeNBits, kHxOrHyMissComponentNBits, m_componentLsb, m_etScale, M_PI, L1CaloEtScale::rank(), mps_fire::result, and mathSSE::sqrt().

Referenced by average.Average::average().

27  {
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 }
T sqrt(T t)
Definition: SSEVec.h:19
double m_componentLsb
#define M_PI
const L1CaloEtScale * m_etScale
uint16_t rank(const uint16_t linear) const
convert from linear Et scale to rank scale

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const L1GctHtMissLut lut 
)
friend

Overload << operator.

Definition at line 84 of file L1GctHtMissLut.cc.

84  {
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 }
const std::vector< double > & getThresholds() const
get thresholds
Definition: L1CaloEtScale.h:66
Base class for LookUp Tables.
Definition: L1GctLut.h:19
unsigned linScaleMax() const
Definition: L1CaloEtScale.h:48
double m_componentLsb
const L1CaloEtScale * m_etScale
unsigned rankScaleMax() const
Definition: L1CaloEtScale.h:51

Member Data Documentation

◆ m_componentLsb

double L1GctHtMissLut::m_componentLsb
private

Definition at line 67 of file L1GctHtMissLut.h.

Referenced by componentLsb(), getThresholdsGct(), operator<<(), setExEyLsb(), and value().

◆ m_etScale

const L1CaloEtScale* L1GctHtMissLut::m_etScale
private

◆ NAddress

const int L1GctHtMissLut::NAddress = 2 * L1GctHtMissLut::kHxOrHyMissComponentNBits
static

Definition at line 27 of file L1GctHtMissLut.h.

◆ NData

Definition at line 27 of file L1GctHtMissLut.h.