ATLAS Offline Software
Loading...
Searching...
No Matches
HLT::MET::PufitMultiGrid< N > Class Template Reference

Multiple grids combined into one. More...

#include <PufitMultiGrid.h>

Inheritance diagram for HLT::MET::PufitMultiGrid< N >:
Collaboration diagram for HLT::MET::PufitMultiGrid< N >:

Classes

class  Tower
 Tower in the multi-grid. More...

Public Member Functions

 PufitMultiGrid (double maxEta, std::size_t nEtaTowers, std::size_t nPhiTowers, bool displaceEta=false, bool displacePhi=false)
 Create a new tower grid.
 PufitMultiGrid (const GridParameters &parameters)
 Construct a grid from the provided parameters.
 PufitMultiGrid (const PufitMultiGrid &other)
 Copy constructor.
PufitMultiGridoperator= (const PufitMultiGrid &other)
 Assignment operator.
void reset ()
 Reset the internal storage.
Toweroperator[] (const std::pair< std::size_t, std::size_t > &indices)
 Access stored value by eta/phi index (access is bounds checked)
const Toweroperator[] (const std::pair< std::size_t, std::size_t > &indices) const
 Access stored value by eta/phi index (access is bounds checked)
Toweroperator[] (std::size_t index)
 Access stored value by global index number (access is bounds checked)
const Toweroperator[] (std::size_t index) const
 Access stored value by global index number (access is bounds checked)
std::vector< Tower >::iterator begin ()
 Access by iterator.
std::vector< Tower >::const_iterator begin () const
 Access by iterator.
std::vector< Tower >::iterator end ()
 Iterator end point.
std::vector< Tower >::const_iterator end () const
 Iterator end point.
PufitMultiGridoperator+= (const PufitMultiGrid &other)
 Add a whole grid into this.
PufitMultiGridoperator-= (const PufitMultiGrid &other)
 Subtract a whole grid from this.
template<std::size_t I, typename = typename std::enable_if<isPow2(I)>::type>
PufitGridget ()
 Get one of the underlying grids.
template<std::size_t I, typename = typename std::enable_if<isPow2(I)>::type>
const PufitGridget () const
 Get one of the underlying grids.
PufitGrid get (std::size_t type) const
 Get one of the underlying grids.
std::size_t getIndex (double eta, double phi, bool &outOfRange) const
 Get the index for the given eta, phi values.
std::size_t getEtaIndex (double eta, bool &outOfRange) const
 Get the eta index for the given value.
std::size_t getPhiIndex (double phi) const
 Get the phi index for the given value.
std::size_t globalIndex (std::size_t iEta, std::size_t iPhi) const
 Convert eta and phi to a global index.
std::pair< std::size_t, std::size_t > etaPhiIndex (std::size_t index) const
 Convert a global index to an eta/phi index pair.
double centralEta (std::size_t iEta) const
 Central eta coordinate of the given eta index.
double centralPhi (std::size_t iPhi) const
 Central phi coordinate of the given phi.
const GridParametersparameters () const
 The grid parameters.
double maxEta () const
 The maximum eta range for the grid.
std::size_t nEtaTowers () const
 The number of eta bins.
std::size_t nPhiTowers () const
 The number of phi bins.
std::size_t nTowers () const
 The number of bins.
bool displaceEta () const
 Whether or not this is displaced in eta.
bool displacePhi () const
 Whether or not this is displaced in phi.
GridDisplacement displacement () const
 The grid displacement.
double etaWidth () const
 The bin width in eta.
double phiWidth () const
 The bin width in phi.

Static Public Attributes

static constexpr std::size_t All = (1 << N) - 1
 Maximum value representable by N bits.
static constexpr std::size_t NCategories = N
 The number of separate categories in the grid.

Private Attributes

std::array< PufitGrid, N > m_grids
std::vector< Towerm_towers
const GridParameters m_params
 The grid's parameters.

Detailed Description

template<std::size_t N>
class HLT::MET::PufitMultiGrid< N >

Multiple grids combined into one.

This class allows representing N different categories in a single grid.

Definition at line 62 of file PufitMultiGrid.h.

Constructor & Destructor Documentation

◆ PufitMultiGrid() [1/3]

template<std::size_t N>
HLT::MET::PufitMultiGrid< N >::PufitMultiGrid ( double maxEta,
std::size_t nEtaTowers,
std::size_t nPhiTowers,
bool displaceEta = false,
bool displacePhi = false )

Create a new tower grid.

Parameters
maxEtaThe maximum eta range for the grid
nEtaTowersThe number of eta towers
nPhiTowersThe number of phi towers
displaceEtaWhether to displace eta
displacePhiWhether to displace phi

◆ PufitMultiGrid() [2/3]

template<std::size_t N>
HLT::MET::PufitMultiGrid< N >::PufitMultiGrid ( const GridParameters & parameters)

Construct a grid from the provided parameters.

◆ PufitMultiGrid() [3/3]

template<std::size_t N>
HLT::MET::PufitMultiGrid< N >::PufitMultiGrid ( const PufitMultiGrid< N > & other)

Copy constructor.

Member Function Documentation

◆ begin() [1/2]

template<std::size_t N>
std::vector< Tower >::iterator HLT::MET::PufitMultiGrid< N >::begin ( )

Access by iterator.

◆ begin() [2/2]

template<std::size_t N>
std::vector< Tower >::const_iterator HLT::MET::PufitMultiGrid< N >::begin ( ) const

Access by iterator.

◆ centralEta()

double HLT::MET::PeriodicGridBase::centralEta ( std::size_t iEta) const
inherited

Central eta coordinate of the given eta index.

Definition at line 129 of file PeriodicGridBase.cxx.

130 {
131 return -maxEta() + etaWidth() * (iEta + 0.5) + (displaceEta() ? etaWidth() / 2 : 0);
132 }
double maxEta() const
The maximum eta range for the grid.
bool displaceEta() const
Whether or not this is displaced in eta.
double etaWidth() const
The bin width in eta.
setScale setgFexType iEta

◆ centralPhi()

double HLT::MET::PeriodicGridBase::centralPhi ( std::size_t iPhi) const
inherited

Central phi coordinate of the given phi.

Definition at line 133 of file PeriodicGridBase.cxx.

134 {
135 return phiWidth() * (iPhi + 0.5) + (displacePhi() ? phiWidth() / 2 : 0);
136 }
bool displacePhi() const
Whether or not this is displaced in phi.
double phiWidth() const
The bin width in phi.
@ iPhi
Definition ParamDefs.h:47

◆ displaceEta()

bool HLT::MET::PeriodicGridBase::displaceEta ( ) const
inherited

Whether or not this is displaced in eta.

Definition at line 143 of file PeriodicGridBase.cxx.

143{ return parameters().displaceEta; }
const GridParameters & parameters() const
The grid parameters.
bool displaceEta
Whether the grid is displaced in eta.

◆ displacement()

GridDisplacement HLT::MET::PeriodicGridBase::displacement ( ) const
inherited

The grid displacement.

Definition at line 145 of file PeriodicGridBase.cxx.

146 {
147 return parameters().displacement();
148 }
GridDisplacement displacement() const
The.

◆ displacePhi()

bool HLT::MET::PeriodicGridBase::displacePhi ( ) const
inherited

Whether or not this is displaced in phi.

Definition at line 144 of file PeriodicGridBase.cxx.

144{ return parameters().displacePhi; }
bool displacePhi
Whether the grid is displaced in phi.

◆ end() [1/2]

template<std::size_t N>
std::vector< Tower >::iterator HLT::MET::PufitMultiGrid< N >::end ( )

Iterator end point.

◆ end() [2/2]

template<std::size_t N>
std::vector< Tower >::const_iterator HLT::MET::PufitMultiGrid< N >::end ( ) const

Iterator end point.

◆ etaPhiIndex()

std::pair< std::size_t, std::size_t > HLT::MET::PeriodicGridBase::etaPhiIndex ( std::size_t index) const
inherited

Convert a global index to an eta/phi index pair.

Definition at line 124 of file PeriodicGridBase.cxx.

125 {
126 return std::make_pair(index / nPhiTowers(), index % nPhiTowers());
127 }
std::size_t nPhiTowers() const
The number of phi bins.

◆ etaWidth()

double HLT::MET::PeriodicGridBase::etaWidth ( ) const
inherited

The bin width in eta.

Definition at line 149 of file PeriodicGridBase.cxx.

149{ return 2 * maxEta() / nEtaTowers(); }
std::size_t nEtaTowers() const
The number of eta bins.

◆ get() [1/3]

template<std::size_t N>
template<std::size_t I, typename = typename std::enable_if<isPow2(I)>::type>
PufitGrid & HLT::MET::PufitMultiGrid< N >::get ( )
inline

Get one of the underlying grids.

This is only defined where I is a power of 2

Definition at line 281 of file PufitMultiGrid.h.

282 {
283 return m_grids[intLog2(I)];
284 }
Multiple grids combined into one.
std::array< PufitGrid, N > m_grids
constexpr uint16_t intLog2(std::size_t i, uint16_t tmp=0)
Compile time calculation of the log base 2 of an integer.

◆ get() [2/3]

template<std::size_t N>
template<std::size_t I, typename = typename std::enable_if<isPow2(I)>::type>
const PufitGrid & HLT::MET::PufitMultiGrid< N >::get ( ) const
inline

Get one of the underlying grids.

This is only defined where I is a power of 2

Definition at line 294 of file PufitMultiGrid.h.

295 {
296 return m_grids[intLog2(I)];
297 }

◆ get() [3/3]

template<std::size_t N>
PufitGrid HLT::MET::PufitMultiGrid< N >::get ( std::size_t type) const

Get one of the underlying grids.

This version is allowed to return a grid where idx is not a power of 2, in which case the grid will be constructed on the fly from the sum of its bitmask

◆ getEtaIndex()

std::size_t HLT::MET::PeriodicGridBase::getEtaIndex ( double eta,
bool & outOfRange ) const
inherited

Get the eta index for the given value.

Parameters
etaThe eta value
[out]outOfRangeSet to true if outside of the eta range

If it's out of range the returned index will be nEta

Definition at line 87 of file PeriodicGridBase.cxx.

88 {
89 if (std::abs(eta) >= maxEta())
90 {
91 outOfRange = true;
92 return nEtaTowers();
93 }
94 outOfRange = false;
95 if (displaceEta())
96 {
97 // Apply the displacement by adding the displacement to the input
98 // coordinate. This shifts the grid in the negative direction
99 eta += etaWidth() / 2;
100 // If necessary apply eta periodicity here
101 if (eta >= maxEta())
102 eta -= 2 * maxEta();
103 }
104 return (eta + maxEta()) / etaWidth();
105 }
Scalar eta() const
pseudorapidity method

◆ getIndex()

std::size_t HLT::MET::PeriodicGridBase::getIndex ( double eta,
double phi,
bool & outOfRange ) const
inherited

Get the index for the given eta, phi values.

Parameters
etaThe eta value
phiThe phi value
[out]outOfRangeSet to true if outside of the eta range

If it's out of range the returned index will be nTowers

Definition at line 79 of file PeriodicGridBase.cxx.

80 {
81 std::size_t etaIndex = getEtaIndex(eta, outOfRange);
82 if (outOfRange)
83 return nTowers();
84 return globalIndex(etaIndex, getPhiIndex(phi));
85 }
Scalar phi() const
phi method
std::size_t nTowers() const
The number of bins.
std::size_t getPhiIndex(double phi) const
Get the phi index for the given value.
std::size_t globalIndex(std::size_t iEta, std::size_t iPhi) const
Convert eta and phi to a global index.
std::size_t getEtaIndex(double eta, bool &outOfRange) const
Get the eta index for the given value.

◆ getPhiIndex()

std::size_t HLT::MET::PeriodicGridBase::getPhiIndex ( double phi) const
inherited

Get the phi index for the given value.

Definition at line 107 of file PeriodicGridBase.cxx.

108 {
109 if (displacePhi())
110 // Apply the displacement by adding the displacement to the input
111 // coordinate. This shifts the grid in the negative direction
112 phi += phiWidth() / 2;
113 // Apply periodicity
114 phi = std::fmod(phi, 2 * M_PI);
115 if (phi < 0)
116 phi += 2 * M_PI;
117 return phi / phiWidth();
118 }
#define M_PI

◆ globalIndex()

std::size_t HLT::MET::PeriodicGridBase::globalIndex ( std::size_t iEta,
std::size_t iPhi ) const
inherited

Convert eta and phi to a global index.

Definition at line 120 of file PeriodicGridBase.cxx.

121 {
122 return iEta * nPhiTowers() + iPhi;
123 }

◆ maxEta()

double HLT::MET::PeriodicGridBase::maxEta ( ) const
inherited

The maximum eta range for the grid.

Definition at line 139 of file PeriodicGridBase.cxx.

139{ return parameters().maxEta; }
double maxEta
The maximum |eta| value.

◆ nEtaTowers()

std::size_t HLT::MET::PeriodicGridBase::nEtaTowers ( ) const
inherited

The number of eta bins.

Definition at line 140 of file PeriodicGridBase.cxx.

140{ return parameters().nEtaTowers; }
std::size_t nEtaTowers
The number of divisions along the eta axis.

◆ nPhiTowers()

std::size_t HLT::MET::PeriodicGridBase::nPhiTowers ( ) const
inherited

The number of phi bins.

Definition at line 141 of file PeriodicGridBase.cxx.

141{ return parameters().nPhiTowers; }
std::size_t nPhiTowers
The number of divisions along the phi axis.

◆ nTowers()

std::size_t HLT::MET::PeriodicGridBase::nTowers ( ) const
inherited

The number of bins.

Definition at line 142 of file PeriodicGridBase.cxx.

142{ return nEtaTowers() * nPhiTowers(); }

◆ operator+=()

template<std::size_t N>
PufitMultiGrid & HLT::MET::PufitMultiGrid< N >::operator+= ( const PufitMultiGrid< N > & other)

Add a whole grid into this.

◆ operator-=()

template<std::size_t N>
PufitMultiGrid & HLT::MET::PufitMultiGrid< N >::operator-= ( const PufitMultiGrid< N > & other)

Subtract a whole grid from this.

◆ operator=()

template<std::size_t N>
PufitMultiGrid & HLT::MET::PufitMultiGrid< N >::operator= ( const PufitMultiGrid< N > & other)

Assignment operator.

Parameters
otherThe grid whose towers to take

Take the tower energies/masking from the other grid.

◆ operator[]() [1/4]

template<std::size_t N>
Tower & HLT::MET::PufitMultiGrid< N >::operator[] ( const std::pair< std::size_t, std::size_t > & indices)

Access stored value by eta/phi index (access is bounds checked)

◆ operator[]() [2/4]

template<std::size_t N>
const Tower & HLT::MET::PufitMultiGrid< N >::operator[] ( const std::pair< std::size_t, std::size_t > & indices) const

Access stored value by eta/phi index (access is bounds checked)

◆ operator[]() [3/4]

template<std::size_t N>
Tower & HLT::MET::PufitMultiGrid< N >::operator[] ( std::size_t index)

Access stored value by global index number (access is bounds checked)

◆ operator[]() [4/4]

template<std::size_t N>
const Tower & HLT::MET::PufitMultiGrid< N >::operator[] ( std::size_t index) const

Access stored value by global index number (access is bounds checked)

◆ parameters()

const GridParameters & HLT::MET::PeriodicGridBase::parameters ( ) const
inherited

The grid parameters.

Definition at line 138 of file PeriodicGridBase.cxx.

138{ return m_params; }
const GridParameters m_params
The grid's parameters.

◆ phiWidth()

double HLT::MET::PeriodicGridBase::phiWidth ( ) const
inherited

The bin width in phi.

Definition at line 150 of file PeriodicGridBase.cxx.

150{ return 2 * M_PI / nPhiTowers(); }

◆ reset()

template<std::size_t N>
void HLT::MET::PufitMultiGrid< N >::reset ( )

Reset the internal storage.

Member Data Documentation

◆ All

template<std::size_t N>
std::size_t HLT::MET::PufitMultiGrid< N >::All = (1 << N) - 1
staticconstexpr

Maximum value representable by N bits.

Definition at line 71 of file PufitMultiGrid.h.

◆ m_grids

template<std::size_t N>
std::array<PufitGrid, N> HLT::MET::PufitMultiGrid< N >::m_grids
private

Definition at line 309 of file PufitMultiGrid.h.

◆ m_params

const GridParameters HLT::MET::PeriodicGridBase::m_params
privateinherited

The grid's parameters.

Definition at line 191 of file PeriodicGridBase.h.

◆ m_towers

template<std::size_t N>
std::vector<Tower> HLT::MET::PufitMultiGrid< N >::m_towers
private

Definition at line 310 of file PufitMultiGrid.h.

◆ NCategories

template<std::size_t N>
std::size_t HLT::MET::PufitMultiGrid< N >::NCategories = N
staticconstexpr

The number of separate categories in the grid.

Definition at line 73 of file PufitMultiGrid.h.


The documentation for this class was generated from the following file: