5#ifndef TRIGEFMISSINGET_PUFITMULTIGRID_H
6#define TRIGEFMISSINGET_PUFITMULTIGRID_H
46 constexpr uint16_t
intLog2(std::size_t i, uint16_t tmp = 0)
53 return intLog2(i >> 1, tmp + 1);
61 template <std::
size_t N>
64 static_assert(N > 0,
"N must be greater than 0");
67 static_assert(N < 17,
"N must be no greater than 16");
71 constexpr static std::size_t
All = (1 << N) - 1;
156 template <std::size_t
I,
158 typename =
typename std::enable_if<I <= All>::type>
169 template <std::size_t
I,
171 typename =
typename std::enable_if<I <= All>::type>
198 for (std::size_t ii = 0; ii < N; ++ii)
199 (
subTower(ii).*f)(other.subTower(ii));
204 template <
typename T>
207 typename std::decay<T>::type val{};
208 for (std::size_t ii = 0; ii < N; ++ii)
259 typename std::vector<Tower>::iterator
begin();
261 typename std::vector<Tower>::const_iterator
begin()
const;
263 typename std::vector<Tower>::iterator
end();
265 typename std::vector<Tower>::const_iterator
end()
const;
278 template <std::size_t
I,
280 typename =
typename std::enable_if<I <= All>::type>
291 template <std::size_t
I,
293 typename =
typename std::enable_if<I <= All>::type>
314 template <
typename Gr
id>
323 return grids[displacement];
329 return grids[displacement];
333 template <std::
size_t I>
342 template <std::size_t
I,
344 typename =
typename std::enable_if<I <= Grid::All>::type>
Provide a base class for the grids used in some pufit algorithms.
Base class for towers belonging to the grids.
std::size_t index() const
The global index of this tower.
std::size_t nPhiTowers() const
The number of phi bins.
double maxEta() const
The maximum eta range for the grid.
std::size_t nEtaTowers() const
The number of eta bins.
bool displacePhi() const
Whether or not this is displaced in phi.
PeriodicGridBase(const GridParameters ¶meters)
Construct the grid from its parameters.
bool displaceEta() const
Whether or not this is displaced in eta.
const GridParameters & parameters() const
The grid parameters.
Describes a single element of the grid.
Bins energy deposits into a grid.
double ex(std::size_t type=All) const
The x-component of this tower's energy.
friend class PufitMulitGrid
bool m_mask
The mask value.
std::decay< T >::type sumOver(int type, T(PufitGrid::Tower::*f)() const) const
Sum over the results of all sub towers whose indices match the 'type' mask.
const PufitGrid::Tower & subTower(std::size_t ii) const
Get a subtower by index.
PufitMultiGrid *const m_parent
The parent grid.
double ez(std::size_t type=All) const
The z-component of this tower's energy.
double ey(std::size_t type=All) const
The y-component of this tower's energy.
bool masked() const
Whether or not this tower was masked.
PufitGrid::Tower & subTower(std::size_t ii)
Get a subtower by index.
double eta(std::size_t type=All) const
This tower's kinematic eta.
SignedKinematics kinematics(std::size_t type=All) const
Build a kinematics object from this tower.
void mask(bool value=true)
Set the mask on this tower.
const PufitMultiGrid * grid() const override
The parent grid of this tower.
Tower & operator-=(const Tower &other)
Subtract another tower's energies from this one.
Tower & operator+=(const Tower &other)
Add another tower's energies into this one.
const PufitGrid::Tower & get() const
Get one of the underlying towers.
Tower & operator=(const Tower &other)
Copy assignment operator.
Tower(const Tower &)=default
PufitGrid::Tower & get()
Get one of the underlying towers.
double sumE(std::size_t type=All) const
The total sumE in this tower.
Tower(PufitMultiGrid *parent, std::size_t index)
Create a tower with its parent grid.
double sumEt(std::size_t type=All) const
The total sumEt in this tower.
void applyToAll(PufitGrid::Tower &(PufitGrid::Tower::*f)(const PufitGrid::Tower &), const PufitMultiGrid::Tower &other)
Apply a function to all sub towers.
double phi(std::size_t type=All) const
This tower's kinematic phi.
const PufitGrid & get() const
Get one of the underlying grids.
std::vector< Tower > m_towers
std::vector< Tower >::const_iterator begin() const
Access by iterator.
std::vector< Tower >::iterator begin()
Access by iterator.
PufitGrid & get()
Get one of the underlying grids.
PufitMultiGrid(const PufitMultiGrid &other)
Copy constructor.
PufitMultiGrid(double maxEta, std::size_t nEtaTowers, std::size_t nPhiTowers, bool displaceEta=false, bool displacePhi=false)
Create a new tower grid.
Tower & operator[](const std::pair< std::size_t, std::size_t > &indices)
Access stored value by eta/phi index (access is bounds checked)
PufitGrid get(std::size_t type) const
Get one of the underlying grids.
Tower & operator[](std::size_t index)
Access stored value by global index number (access is bounds checked)
static constexpr std::size_t NCategories
The number of separate categories in the grid.
PufitMultiGrid & operator-=(const PufitMultiGrid &other)
Subtract a whole grid from this.
static constexpr std::size_t All
Maximum value representable by N bits.
void reset()
Reset the internal storage.
PufitMultiGrid & operator=(const PufitMultiGrid &other)
Assignment operator.
PufitMultiGrid(const GridParameters ¶meters)
Construct a grid from the provided parameters.
const Tower & operator[](const std::pair< std::size_t, std::size_t > &indices) const
Access stored value by eta/phi index (access is bounds checked)
const Tower & operator[](std::size_t index) const
Access stored value by global index number (access is bounds checked)
std::vector< Tower >::iterator end()
Iterator end point.
PufitMultiGrid & operator+=(const PufitMultiGrid &other)
Add a whole grid into this.
std::vector< Tower >::const_iterator end() const
Iterator end point.
std::array< PufitGrid, N > m_grids
Class to describe the kinematics of an object that can have negative energies.
constexpr uint16_t intLog2(std::size_t i, uint16_t tmp=0)
Compile time calculation of the log base 2 of an integer.
GridDisplacement
Enum to describe the positioning of the grid.
constexpr bool isPow2(std::size_t i)
Compile time check if a number is a power of 2.
It used to be useful piece of code for replacing actual SG with other store of similar functionality ...
Parameters describing a grid.
Helper struct to contain a full set of grids.
Element & operator-=(const SignedKinematics &kin)
Element & operator+=(const SignedKinematics &kin)
PufitMultiGridSet & parent
Element(PufitMultiGridSet &parent)
PufitMultiGridSet(double maxEta, std::size_t nEta, std::size_t nPhi)
const Grid & operator[](GridDisplacement displacement) const
Select a grid (const)
PufitGridSet get(std::size_t type) const
Grid & operator[](GridDisplacement displacement)
Select a grid.
std::array< PUSplitGrid, 4 > grids