CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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)
 
virtual ~L1GctHtMissLut ()
 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

virtual uint16_t value (const uint16_t lutAddress) const
 
- 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 21 of file L1GctHtMissLut.h.

Member Enumeration Documentation

Enumerator
kHxOrHyMissComponentNBits 
kHtMissMagnitudeNBits 
kHtMissAngleNBits 

Definition at line 26 of file L1GctHtMissLut.h.

Constructor & Destructor Documentation

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.

11  :
13  m_etScale(scale),
14  m_componentLsb(lsb)
15 {
16  if (scale != 0) m_setupOk = true;
17 }
Base class for LookUp Tables.
Definition: L1GctLut.h:21
double m_componentLsb
const L1CaloEtScale * m_etScale
L1GctHtMissLut::L1GctHtMissLut ( )

Default constructor.

Definition at line 19 of file L1GctHtMissLut.cc.

19  :
21  m_etScale(0),
22  m_componentLsb(1.0)
23 {
24 }
Base class for LookUp Tables.
Definition: L1GctLut.h:21
double m_componentLsb
const L1CaloEtScale * m_etScale
L1GctHtMissLut::L1GctHtMissLut ( const L1GctHtMissLut lut)

Copy constructor.

Definition at line 26 of file L1GctHtMissLut.cc.

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

26  :
28  m_etScale(lut.etScale()),
30 {
31  if (m_etScale != 0) m_setupOk = true;
32 }
Base class for LookUp Tables.
Definition: L1GctLut.h:21
double m_componentLsb
const double componentLsb() const
const L1CaloEtScale * m_etScale
const L1CaloEtScale * etScale() const
Return the Lut functions and parameters.
L1GctHtMissLut::~L1GctHtMissLut ( )
virtual

Destructor.

Definition at line 34 of file L1GctHtMissLut.cc.

35 {
36 }

Member Function Documentation

const double L1GctHtMissLut::componentLsb ( ) const
inline

Definition at line 54 of file L1GctHtMissLut.h.

References m_componentLsb.

Referenced by L1GctMet::componentLsb().

54 { return m_componentLsb; }
double m_componentLsb
const L1CaloEtScale* L1GctHtMissLut::etScale ( ) const
inline

Return the Lut functions and parameters.

Definition at line 53 of file L1GctHtMissLut.h.

References m_etScale.

Referenced by L1GctMet::etScale().

53 { return m_etScale; }
const L1CaloEtScale * m_etScale
std::vector< unsigned > L1GctHtMissLut::getThresholdsGct ( ) const

Definition at line 85 of file L1GctHtMissLut.cc.

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

86 {
87  std::vector<unsigned> result;
88  std::vector<double> thresholdsGeV = m_etScale->getThresholds();
89  for (std::vector<double>::const_iterator thr=thresholdsGeV.begin();
90  thr != thresholdsGeV.end(); thr++) {
91  result.push_back(static_cast<unsigned>((*thr)/(m_componentLsb)));
92  }
93  return result;
94 }
const std::vector< double > & getThresholds() const
get thresholds
Definition: L1CaloEtScale.h:63
tuple result
Definition: query.py:137
double m_componentLsb
const L1CaloEtScale * m_etScale
std::vector< double > L1GctHtMissLut::getThresholdsGeV ( ) const

Get thresholds.

Definition at line 80 of file L1GctHtMissLut.cc.

References L1CaloEtScale::getThresholds(), and m_etScale.

81 {
82  return m_etScale->getThresholds();
83 }
const std::vector< double > & getThresholds() const
get thresholds
Definition: L1CaloEtScale.h:63
const L1CaloEtScale * m_etScale
L1GctHtMissLut L1GctHtMissLut::operator= ( const L1GctHtMissLut lut)

Overload = operator.

Definition at line 96 of file L1GctHtMissLut.cc.

References groupFilesInBlocks::temp.

97 {
98  L1GctHtMissLut temp(lut);
99  return temp;
100 }
LUT for conversion of Ht components x and y to magnitude and angle.
void L1GctHtMissLut::setEtScale ( const L1CaloEtScale *const  fn)
inline

Set the functions.

Definition at line 49 of file L1GctHtMissLut.h.

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

Referenced by L1GctMet::setEtScale().

49 { m_etScale = fn; if (fn != 0) { m_setupOk = true; } }
const L1CaloEtScale * m_etScale
void L1GctHtMissLut::setExEyLsb ( const double  lsb)
inline

Definition at line 50 of file L1GctHtMissLut.h.

References m_componentLsb.

Referenced by L1GctMet::setEtComponentLsb().

50 { m_componentLsb = lsb; }
double m_componentLsb
uint16_t L1GctHtMissLut::value ( const uint16_t  lutAddress) const
protectedvirtual

Implements L1GctLut< 16, 12 >.

Definition at line 39 of file L1GctHtMissLut.cc.

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

40 {
41  uint16_t result=0;
42 
43  if (lutAddress!=0) {
44  static const int maxComponent = 1<<kHxOrHyMissComponentNBits;
45  static const int componentMask = maxComponent-1;
46 
47  static const int magnitudeMask = (1<<kHtMissMagnitudeNBits) - 1;
48  static const int angleMask = (1<<kHtMissAngleNBits) - 1;
49 
50  // Extract the bits corresponding to hx and hy components
51  int hxCompGct = static_cast<int>(lutAddress>>kHxOrHyMissComponentNBits) & componentMask;
52  int hyCompGct = static_cast<int>(lutAddress) & componentMask;
53 
54  // These are twos-complement integers - if the MSB is set, the value is negative
55  if (hxCompGct >= maxComponent/2) hxCompGct -= maxComponent;
56  if (hyCompGct >= maxComponent/2) hyCompGct -= maxComponent;
57 
58  // Convert to GeV. Add 0.5 to each component to compensate for truncation errors.
59  double hxCompGeV = m_componentLsb * (static_cast<double>(hxCompGct) + 0.5);
60  double hyCompGeV = m_componentLsb * (static_cast<double>(hyCompGct) + 0.5);
61 
62  // Convert to magnitude and angle
63  double htMissMag = sqrt(hxCompGeV * hxCompGeV + hyCompGeV * hyCompGeV);
64  double htMissAng = atan2(hyCompGeV, hxCompGeV);
65  if (htMissAng < 0.0) htMissAng += 2.0*M_PI;
66 
67  // Convert back to integer
68  int htMissMagBits = static_cast<int>(m_etScale->rank(htMissMag)) & magnitudeMask;
69  int htMissAngBits = static_cast<int>(htMissAng*9.0/M_PI) & angleMask;
70 
71  // Form the lut output
72  result = (htMissMagBits << kHtMissAngleNBits) | htMissAngBits ;
73  }
74 
75  return result;
76 
77 }
uint16_t rank(const uint16_t linear) const
convert from linear Et scale to rank scale
T sqrt(T t)
Definition: SSEVec.h:46
tuple result
Definition: query.py:137
double m_componentLsb
const L1CaloEtScale * m_etScale
#define M_PI
Definition: BFit3D.cc:3

Friends And Related Function Documentation

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

Overload << operator.

Definition at line 102 of file L1GctHtMissLut.cc.

103 {
104  os << "===L1GctHtMissLut===" << std::endl;
105  std::vector<double> thresholds = lut.m_etScale->getThresholds();
106  std::vector<double>::const_iterator thr = thresholds.begin();
107  os << "Thresholds are: " << *(thr++);
108  for ( ; thr != thresholds.end(); thr++) {
109  os << ", " << *thr;
110  }
111  os << std::endl;
112  os << "Max values for input to et scale " << lut.m_etScale->linScaleMax()
113  << " and for output " << lut.m_etScale->rankScaleMax() << std::endl;
114  os << "LSB used for conversion is " << lut.m_componentLsb << " GeV" << std::endl;
115  os << "\n===Lookup table contents===\n" << std::endl;
117  os << *temp;
118  return os;
119 }
Base class for LookUp Tables.
Definition: L1GctLut.h:21
const std::vector< double > & getThresholds() const
get thresholds
Definition: L1CaloEtScale.h:63
double m_componentLsb
tuple lut
Definition: lumiPlot.py:244
const L1CaloEtScale * m_etScale
unsigned linScaleMax() const
Definition: L1CaloEtScale.h:45
unsigned rankScaleMax() const
Definition: L1CaloEtScale.h:48

Member Data Documentation

double L1GctHtMissLut::m_componentLsb
private

Definition at line 69 of file L1GctHtMissLut.h.

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

const L1CaloEtScale* L1GctHtMissLut::m_etScale
private
const int L1GctHtMissLut::NAddress =2*L1GctHtMissLut::kHxOrHyMissComponentNBits
static

Definition at line 31 of file L1GctHtMissLut.h.

Definition at line 31 of file L1GctHtMissLut.h.