CbmRoot
Loading...
Searching...
No Matches
cbm::algo::ca::Grid Class Reference

Class for storing 2d objects in a grid. More...

#include <CaGrid.h>

Collaboration diagram for cbm::algo::ca::Grid:
[legend]

Public Member Functions

 Grid ()=default
 Default constructor.
 
 ~Grid ()=default
 Destructor.
 
void BuildBins (fscal xMin, fscal xMax, fscal yMin, fscal yMax, fscal binWidthX, fscal binWidthY)
 Build the grid.
 
void StoreHits (const ca::Vector< ca::Hit > &hits, ca::HitIndex_t hitStartIndex, ca::HitIndex_t nHits, const ca::Vector< unsigned char > &hitKeyFlags)
 Store objects in the grid.
 
void RemoveUsedHits (const ca::Vector< ca::Hit > &hits, const ca::Vector< unsigned char > &hitKeyFlags)
 Remove grid entries that correspond to the used hits.
 
int GetBin (fscal X, fscal Y) const
 Get bin index for (X,Y) point with boundary check.
 
int GetBinX (fscal X) const
 Get bin X index with boundary check.
 
int GetBinY (fscal Y) const
 Get bin Y index with boundary check.
 
std::tuple< fscal, fscalGetBinBoundsX (int iBin) const
 Get bin bounds along X.
 
std::tuple< fscal, fscalGetBinBoundsY (int iBin) const
 Get bin bounds along Y.
 
int GetNofBins () const
 Get number of bins.
 
int GetNofBinsX () const
 Get number of bins along X.
 
int GetNofBinsY () const
 Get number of bins along Y.
 
ca::HitIndex_t GetFirstBinEntryIndex (int bin) const
 Get index of the first bin entry in fHitsInBin array.
 
const ca::Vector< ca::GridEntry > & GetEntries () const
 Get number of entries in the bin.
 
fscal GetMinX () const
 Get minimal X value.
 
fscal GetMinY () const
 Get minimal Y value.
 
fscal GetBinWidthX () const
 Get bin width in X.
 
fscal GetBinWidthY () const
 Get bin width in Y.
 
fscal GetMaxRangeX () const
 Get maximal entry range in X.
 
fscal GetMaxRangeY () const
 Get maximal entry range in Y.
 
fscal GetMaxRangeT () const
 Get maximal entry range in T.
 

Private Attributes

int fN {0}
 — Data members —
 
int fNx {0}
 N bins in X.
 
int fNy {0}
 N bins in Y.
 
fscal fMinX {0.}
 minimal X value
 
fscal fMinY {0.}
 minimal Y value
 
fscal fBinWidthX {0.}
 bin width in X
 
fscal fBinWidthY {0.}
 bin width in Y
 
fscal fBinWidthXinv {0.}
 inverse bin width in X
 
fscal fBinWidthYinv {0.}
 inverse bin width in Y
 
fscal fMaxRangeX {0.}
 maximal entry range in X
 
fscal fMaxRangeY {0.}
 maximal entry range in Y
 
fscal fMaxRangeT {0.}
 maximal entry range in T
 
ca::Vector< ca::HitIndex_tfFirstBinEntryIndex
 index of the first entry in the bin
 
ca::Vector< ca::HitIndex_tfNofBinEntries {"Grid::fNofBinEntries", 1, 0}
 number of hits in the bin
 
ca::Vector< ca::GridEntryfEntries
 grid entries with references to the hit index in fWindowHits
 

Detailed Description

Class for storing 2d objects in a grid.

It creates 2-dimensional backet-sorted grid of pointers to 2-dimensional objects.

The class provides an access to the objects in selected 2D bin without touching the rest of the data. To loop over the objects in arbitrary XY-area one can use the ca::GridArea class.

The class is used by CaTracker to speed-up the hit search operations The grid axis are named X and Y

Definition at line 32 of file CaGrid.h.

Constructor & Destructor Documentation

◆ Grid()

cbm::algo::ca::Grid::Grid ( )
default

Default constructor.

◆ ~Grid()

cbm::algo::ca::Grid::~Grid ( )
default

Destructor.

Member Function Documentation

◆ BuildBins()

void cbm::algo::ca::Grid::BuildBins ( fscal xMin,
fscal xMax,
fscal yMin,
fscal yMax,
fscal binWidthX,
fscal binWidthY )

Build the grid.

Parameters
xMin- minimal X value
xMax- maximal X value
yMin- minimal Y value
yMax- maximal Y value
binWidthX- bin width in X
binWidthY- bin width in Y

Definition at line 19 of file CaGrid.cxx.

References fBinWidthX, fBinWidthXinv, fBinWidthY, fBinWidthYinv, fEntries, fFirstBinEntryIndex, fMinX, fMinY, fN, fNofBinEntries, fNx, fNy, and cbm::algo::ca::Vector< T >::reset().

Referenced by cbm::algo::ca::TrackFinderWindow::PrepareGrid().

◆ GetBin()

int cbm::algo::ca::Grid::GetBin ( fscal X,
fscal Y ) const
inline

Get bin index for (X,Y) point with boundary check.

— Inline methods —

Parameters
X- point x coordinate
Y- point y coordinate
Returns
bin index in the range [0, fN-1]

Definition at line 158 of file CaGrid.h.

References fNx, GetBinX(), and GetBinY().

Referenced by StoreHits().

◆ GetBinBoundsX()

std::tuple< fscal, fscal > cbm::algo::ca::Grid::GetBinBoundsX ( int iBin) const
inline

Get bin bounds along X.

Parameters
iBin- bin index
Returns
pair of (Xmin, Xmax) bounds

Definition at line 176 of file CaGrid.h.

References fBinWidthX, fMinX, and fNx.

◆ GetBinBoundsY()

std::tuple< fscal, fscal > cbm::algo::ca::Grid::GetBinBoundsY ( int iBin) const
inline

Get bin bounds along Y.

Parameters
iBin- bin index
Returns
pair of (Ymin, Ymax) bounds

Definition at line 182 of file CaGrid.h.

References fBinWidthY, fMinY, and fNx.

◆ GetBinWidthX()

fscal cbm::algo::ca::Grid::GetBinWidthX ( ) const
inline

Get bin width in X.

Definition at line 115 of file CaGrid.h.

References fBinWidthX.

◆ GetBinWidthY()

fscal cbm::algo::ca::Grid::GetBinWidthY ( ) const
inline

Get bin width in Y.

Definition at line 118 of file CaGrid.h.

References fBinWidthY.

◆ GetBinX()

int cbm::algo::ca::Grid::GetBinX ( fscal X) const
inline

Get bin X index with boundary check.

Parameters
X- x coordinate
Returns
binX index

Definition at line 164 of file CaGrid.h.

References fBinWidthXinv, fMinX, and fNx.

Referenced by GetBin(), and cbm::algo::ca::GridArea::GridArea().

◆ GetBinY()

int cbm::algo::ca::Grid::GetBinY ( fscal Y) const
inline

Get bin Y index with boundary check.

Parameters
Y- y coordinate
Returns
binY index

Definition at line 170 of file CaGrid.h.

References fBinWidthYinv, fMinY, and fNy.

Referenced by GetBin(), and cbm::algo::ca::GridArea::GridArea().

◆ GetEntries()

const ca::Vector< ca::GridEntry > & cbm::algo::ca::Grid::GetEntries ( ) const
inline

Get number of entries in the bin.

Get entries

Definition at line 106 of file CaGrid.h.

References fEntries.

Referenced by cbm::algo::ca::GridArea::DoLoopOverEntireGrid(), and cbm::algo::ca::GridArea::GetNextObjectId().

◆ GetFirstBinEntryIndex()

ca::HitIndex_t cbm::algo::ca::Grid::GetFirstBinEntryIndex ( int bin) const
inline

Get index of the first bin entry in fHitsInBin array.

Definition at line 100 of file CaGrid.h.

References fFirstBinEntryIndex, and fN.

Referenced by cbm::algo::ca::GridArea::GetNextGridEntry(), and cbm::algo::ca::GridArea::GridArea().

◆ GetMaxRangeT()

fscal cbm::algo::ca::Grid::GetMaxRangeT ( ) const
inline

Get maximal entry range in T.

Definition at line 127 of file CaGrid.h.

References fMaxRangeT.

◆ GetMaxRangeX()

fscal cbm::algo::ca::Grid::GetMaxRangeX ( ) const
inline

Get maximal entry range in X.

Definition at line 121 of file CaGrid.h.

References fMaxRangeX.

◆ GetMaxRangeY()

fscal cbm::algo::ca::Grid::GetMaxRangeY ( ) const
inline

Get maximal entry range in Y.

Definition at line 124 of file CaGrid.h.

References fMaxRangeY.

◆ GetMinX()

fscal cbm::algo::ca::Grid::GetMinX ( ) const
inline

Get minimal X value.

Definition at line 109 of file CaGrid.h.

References fMinX.

◆ GetMinY()

fscal cbm::algo::ca::Grid::GetMinY ( ) const
inline

Get minimal Y value.

Definition at line 112 of file CaGrid.h.

References fMinY.

◆ GetNofBins()

int cbm::algo::ca::Grid::GetNofBins ( ) const
inline

Get number of bins.

Definition at line 91 of file CaGrid.h.

References fN.

◆ GetNofBinsX()

int cbm::algo::ca::Grid::GetNofBinsX ( ) const
inline

Get number of bins along X.

Definition at line 94 of file CaGrid.h.

References fNx.

◆ GetNofBinsY()

int cbm::algo::ca::Grid::GetNofBinsY ( ) const
inline

Get number of bins along Y.

Definition at line 97 of file CaGrid.h.

References fNy.

◆ RemoveUsedHits()

void cbm::algo::ca::Grid::RemoveUsedHits ( const ca::Vector< ca::Hit > & hits,
const ca::Vector< unsigned char > & hitKeyFlags )

◆ StoreHits()

void cbm::algo::ca::Grid::StoreHits ( const ca::Vector< ca::Hit > & hits,
ca::HitIndex_t hitStartIndex,
ca::HitIndex_t nHits,
const ca::Vector< unsigned char > & hitKeyFlags )

Store objects in the grid.

void StoreData(...);

Store ca::Hits in the grid

Parameters
hits- vector of hits to store
hitStartIndex- index of the first hit to store
nHits- number of hits to store starting from the hitStartIndex
hitKeyFlags- vector of flags to recognise used hits and skip them

Definition at line 56 of file CaGrid.cxx.

References cbm::algo::ca::Hit::BackKey(), fEntries, fFirstBinEntryIndex, fMaxRangeT, fMaxRangeX, fMaxRangeY, fN, fNofBinEntries, cbm::algo::ca::Hit::FrontKey(), GetBin(), hits, cbm::algo::ca::Hit::RangeT(), cbm::algo::ca::Hit::RangeX(), cbm::algo::ca::Hit::RangeY(), cbm::algo::ca::Vector< T >::reset(), cbm::algo::ca::Hit::X(), and cbm::algo::ca::Hit::Y().

Member Data Documentation

◆ fBinWidthX

fscal cbm::algo::ca::Grid::fBinWidthX {0.}
private

bin width in X

Definition at line 138 of file CaGrid.h.

Referenced by BuildBins(), GetBinBoundsX(), and GetBinWidthX().

◆ fBinWidthXinv

fscal cbm::algo::ca::Grid::fBinWidthXinv {0.}
private

inverse bin width in X

Definition at line 140 of file CaGrid.h.

Referenced by BuildBins(), and GetBinX().

◆ fBinWidthY

fscal cbm::algo::ca::Grid::fBinWidthY {0.}
private

bin width in Y

Definition at line 139 of file CaGrid.h.

Referenced by BuildBins(), GetBinBoundsY(), and GetBinWidthY().

◆ fBinWidthYinv

fscal cbm::algo::ca::Grid::fBinWidthYinv {0.}
private

inverse bin width in Y

Definition at line 141 of file CaGrid.h.

Referenced by BuildBins(), and GetBinY().

◆ fEntries

ca::Vector<ca::GridEntry> cbm::algo::ca::Grid::fEntries
private
Initial value:
{
"Ca::Grid::fEntries"}

grid entries with references to the hit index in fWindowHits

Definition at line 152 of file CaGrid.h.

Referenced by BuildBins(), GetEntries(), RemoveUsedHits(), and StoreHits().

◆ fFirstBinEntryIndex

ca::Vector<ca::HitIndex_t> cbm::algo::ca::Grid::fFirstBinEntryIndex
private
Initial value:
{"Grid::fFirstBinEntryIndex", 1,
0}

index of the first entry in the bin

Definition at line 147 of file CaGrid.h.

Referenced by BuildBins(), GetFirstBinEntryIndex(), RemoveUsedHits(), and StoreHits().

◆ fMaxRangeT

fscal cbm::algo::ca::Grid::fMaxRangeT {0.}
private

maximal entry range in T

Definition at line 145 of file CaGrid.h.

Referenced by GetMaxRangeT(), RemoveUsedHits(), and StoreHits().

◆ fMaxRangeX

fscal cbm::algo::ca::Grid::fMaxRangeX {0.}
private

maximal entry range in X

Definition at line 143 of file CaGrid.h.

Referenced by GetMaxRangeX(), RemoveUsedHits(), and StoreHits().

◆ fMaxRangeY

fscal cbm::algo::ca::Grid::fMaxRangeY {0.}
private

maximal entry range in Y

Definition at line 144 of file CaGrid.h.

Referenced by GetMaxRangeY(), RemoveUsedHits(), and StoreHits().

◆ fMinX

fscal cbm::algo::ca::Grid::fMinX {0.}
private

minimal X value

Definition at line 136 of file CaGrid.h.

Referenced by BuildBins(), GetBinBoundsX(), GetBinX(), and GetMinX().

◆ fMinY

fscal cbm::algo::ca::Grid::fMinY {0.}
private

minimal Y value

Definition at line 137 of file CaGrid.h.

Referenced by BuildBins(), GetBinBoundsY(), GetBinY(), and GetMinY().

◆ fN

int cbm::algo::ca::Grid::fN {0}
private

— Data members —

total N bins

Definition at line 132 of file CaGrid.h.

Referenced by BuildBins(), GetFirstBinEntryIndex(), GetNofBins(), RemoveUsedHits(), and StoreHits().

◆ fNofBinEntries

ca::Vector<ca::HitIndex_t> cbm::algo::ca::Grid::fNofBinEntries {"Grid::fNofBinEntries", 1, 0}
private

number of hits in the bin

Definition at line 150 of file CaGrid.h.

Referenced by BuildBins(), RemoveUsedHits(), and StoreHits().

◆ fNx

int cbm::algo::ca::Grid::fNx {0}
private

N bins in X.

Definition at line 133 of file CaGrid.h.

Referenced by BuildBins(), GetBin(), GetBinBoundsX(), GetBinBoundsY(), GetBinX(), and GetNofBinsX().

◆ fNy

int cbm::algo::ca::Grid::fNy {0}
private

N bins in Y.

Definition at line 134 of file CaGrid.h.

Referenced by BuildBins(), GetBinY(), and GetNofBinsY().


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