CbmRoot
Loading...
Searching...
No Matches
CaGrid.h
Go to the documentation of this file.
1/* Copyright (C) 2010-2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Igor Kulakov [committer], Sergey Gorbunov */
4
10
11#pragma once // include this header only once per compilation unit
12
13#include "CaGridEntry.h"
14#include "CaHit.h"
15#include "CaSimd.h"
16#include "CaVector.h"
17
18namespace cbm::algo::ca
19{
20
23
32 class Grid {
33 public:
35 Grid() = default;
36
38 ~Grid() = default;
39
47 void BuildBins(fscal xMin, fscal xMax, fscal yMin, fscal yMax, fscal binWidthX, fscal binWidthY);
48
50 // TODO: write the method with a template input
52
58 void StoreHits(const ca::Vector<ca::Hit>& hits, ca::HitIndex_t hitStartIndex, ca::HitIndex_t nHits,
59 const ca::Vector<unsigned char>& hitKeyFlags);
60
63
68 int GetBin(fscal X, fscal Y) const;
69
73 int GetBinX(fscal X) const;
74
78 int GetBinY(fscal Y) const;
79
83 std::tuple<fscal, fscal> GetBinBoundsX(int iBin) const;
84
88 std::tuple<fscal, fscal> GetBinBoundsY(int iBin) const;
89
91 int GetNofBins() const { return fN; }
92
94 int GetNofBinsX() const { return fNx; }
95
97 int GetNofBinsY() const { return fNy; }
98
100 ca::HitIndex_t GetFirstBinEntryIndex(int bin) const { return fFirstBinEntryIndex[(bin < fN) ? bin : fN]; }
101
103 //ca::HitIndex_t GetNofBinEntries(int bin) const { return fNofBinEntries[bin < fN ? bin : fN]; }
104
107
109 fscal GetMinX() const { return fMinX; }
110
112 fscal GetMinY() const { return fMinY; }
113
115 fscal GetBinWidthX() const { return fBinWidthX; }
116
118 fscal GetBinWidthY() const { return fBinWidthY; }
119
121 fscal GetMaxRangeX() const { return fMaxRangeX; }
122
124 fscal GetMaxRangeY() const { return fMaxRangeY; }
125
127 fscal GetMaxRangeT() const { return fMaxRangeT; }
128
129 private:
131
132 int fN{0};
133 int fNx{0};
134 int fNy{0};
135
142
146
147 ca::Vector<ca::HitIndex_t> fFirstBinEntryIndex{"Grid::fFirstBinEntryIndex", 1,
148 0};
149
150 ca::Vector<ca::HitIndex_t> fNofBinEntries{"Grid::fNofBinEntries", 1, 0};
151
153 "Ca::Grid::fEntries"};
154 };
155
157
158 inline int Grid::GetBin(fscal X, fscal Y) const
159 {
160 //
161 return GetBinY(Y) * fNx + GetBinX(X);
162 }
163
164 inline int Grid::GetBinX(fscal X) const
165 {
166 int binX = static_cast<int>((X - fMinX) * fBinWidthXinv);
167 return std::max(0, std::min(fNx - 1, binX));
168 }
169
170 inline int Grid::GetBinY(fscal Y) const
171 {
172 int binY = static_cast<int>((Y - fMinY) * fBinWidthYinv);
173 return std::max(0, std::min(fNy - 1, binY));
174 }
175
176 inline std::tuple<fscal, fscal> Grid::GetBinBoundsX(int iBin) const
177 {
178 fscal Xmin = fMinX + (iBin % fNx) * fBinWidthX;
179 return std::make_tuple(Xmin, Xmin + fBinWidthX);
180 }
181
182 inline std::tuple<fscal, fscal> Grid::GetBinBoundsY(int iBin) const
183 {
184 fscal Ymin = fMinY + (iBin / fNx) * fBinWidthY;
185 return std::make_tuple(Ymin, Ymin + fBinWidthY);
186 }
187
188} // namespace cbm::algo::ca
A generic hit for the CA tracker (header)
static vector< vector< QAHit > > hits
Class for storing 2d objects in a grid.
Definition CaGrid.h:32
std::tuple< fscal, fscal > GetBinBoundsX(int iBin) const
Get bin bounds along X.
Definition CaGrid.h:176
fscal GetMinY() const
Get minimal Y value.
Definition CaGrid.h:112
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.
Definition CaGrid.cxx:56
fscal fMinY
minimal Y value
Definition CaGrid.h:137
int fNx
N bins in X.
Definition CaGrid.h:133
ca::Vector< ca::GridEntry > fEntries
grid entries with references to the hit index in fWindowHits
Definition CaGrid.h:152
void RemoveUsedHits(const ca::Vector< ca::Hit > &hits, const ca::Vector< unsigned char > &hitKeyFlags)
Remove grid entries that correspond to the used hits.
Definition CaGrid.cxx:96
fscal GetMinX() const
Get minimal X value.
Definition CaGrid.h:109
std::tuple< fscal, fscal > GetBinBoundsY(int iBin) const
Get bin bounds along Y.
Definition CaGrid.h:182
int GetBin(fscal X, fscal Y) const
Get bin index for (X,Y) point with boundary check.
Definition CaGrid.h:158
fscal GetBinWidthX() const
Get bin width in X.
Definition CaGrid.h:115
fscal GetMaxRangeY() const
Get maximal entry range in Y.
Definition CaGrid.h:124
fscal GetBinWidthY() const
Get bin width in Y.
Definition CaGrid.h:118
Grid()=default
Default constructor.
const ca::Vector< ca::GridEntry > & GetEntries() const
Get number of entries in the bin.
Definition CaGrid.h:106
fscal fMaxRangeT
maximal entry range in T
Definition CaGrid.h:145
fscal fBinWidthX
bin width in X
Definition CaGrid.h:138
int fNy
N bins in Y.
Definition CaGrid.h:134
int GetNofBinsX() const
Get number of bins along X.
Definition CaGrid.h:94
fscal GetMaxRangeX() const
Get maximal entry range in X.
Definition CaGrid.h:121
void BuildBins(fscal xMin, fscal xMax, fscal yMin, fscal yMax, fscal binWidthX, fscal binWidthY)
Build the grid.
Definition CaGrid.cxx:19
fscal fMaxRangeX
maximal entry range in X
Definition CaGrid.h:143
int fN
— Data members —
Definition CaGrid.h:132
ca::HitIndex_t GetFirstBinEntryIndex(int bin) const
Get index of the first bin entry in fHitsInBin array.
Definition CaGrid.h:100
int GetNofBinsY() const
Get number of bins along Y.
Definition CaGrid.h:97
fscal fBinWidthYinv
inverse bin width in Y
Definition CaGrid.h:141
int GetNofBins() const
Get number of bins.
Definition CaGrid.h:91
~Grid()=default
Destructor.
int GetBinY(fscal Y) const
Get bin Y index with boundary check.
Definition CaGrid.h:170
fscal fMaxRangeY
maximal entry range in Y
Definition CaGrid.h:144
fscal GetMaxRangeT() const
Get maximal entry range in T.
Definition CaGrid.h:127
fscal fBinWidthY
bin width in Y
Definition CaGrid.h:139
ca::Vector< ca::HitIndex_t > fNofBinEntries
number of hits in the bin
Definition CaGrid.h:150
ca::Vector< ca::HitIndex_t > fFirstBinEntryIndex
index of the first entry in the bin
Definition CaGrid.h:147
fscal fMinX
minimal X value
Definition CaGrid.h:136
int GetBinX(fscal X) const
Get bin X index with boundary check.
Definition CaGrid.h:164
fscal fBinWidthXinv
inverse bin width in X
Definition CaGrid.h:140
TODO: SZh 8.11.2022: add selection of parameterisation.
Definition CaBranch.h:14
kf::fscal fscal
Definition CaSimd.h:14
unsigned int HitIndex_t
Index of ca::Hit.
Definition CaHit.h:27