4 #ifndef RecoLocalCalo_HGCalRecProducers_HGCalLayerTiles_h 5 #define RecoLocalCalo_HGCalRecProducers_HGCalLayerTiles_h 18 template <
typename T,
typename WRAPPER>
29 void fill(
const std::vector<float>& dim1,
const std::vector<float>& dim2) {
30 auto cellsSize = dim1.size();
31 for (
unsigned int i = 0;
i < cellsSize; ++
i) {
43 constexpr
float dimRange = T::maxDim1 - T::minDim1;
44 static_assert(dimRange >= 0.);
45 constexpr
float r = T::nColumns / dimRange;
46 int dimBin = (dim - T::minDim1) *
r;
47 dimBin = std::clamp(dimBin, 0, T::nColumns - 1);
58 if constexpr (std::is_same_v<WRAPPER, NoPhiWrapper>) {
59 constexpr
float dimRange = T::maxDim2 - T::minDim2;
60 static_assert(dimRange >= 0.);
61 constexpr
float r = T::nRows / dimRange;
62 int dimBin = (dim2 - T::minDim2) *
r;
63 dimBin = std::clamp(dimBin, 0, T::nRows - 1);
67 constexpr
float r = T::nRows * M_1_PI * 0.5f;
76 inline float distance2(
float dim1Cell1,
float dim2Cell1,
float dim1Cell2,
float dim2Cell2)
const {
77 float d1 = dim1Cell1 - dim1Cell2;
78 float d2 = dim2Cell1 - dim2Cell2;
79 if constexpr (std::is_same_v<WRAPPER, PhiWrapper>) {
82 return (
d1 *
d1 + d2 * d2);
86 int getGlobalBinByBin(
int dim1Bin,
int dim2Bin)
const {
return dim1Bin + dim2Bin * T::nColumns; }
88 std::array<int, 4>
searchBox(
float dim1Min,
float dim1Max,
float dim2Min,
float dim2Max)
const {
89 if constexpr (std::is_same_v<WRAPPER, PhiWrapper>) {
90 if (dim1Max - dim1Min < 0) {
91 return std::array<int, 4>({{0, 0, 0, 0}});
98 if constexpr (std::is_same_v<WRAPPER, PhiWrapper>) {
104 if (dim2BinMax < dim2BinMin) {
105 dim2BinMax += T::nRows;
108 return std::array<int, 4>({{dim1BinMin, dim1BinMax, dim2BinMin, dim2BinMax}});
119 std::array<std::vector<int>, T::nTiles>
tiles_;
constexpr double deltaPhi(double phi1, double phi2)
int getGlobalBin(float dim1, float dim2) const
std::array< int, 4 > searchBox(float dim1Min, float dim1Max, float dim2Min, float dim2Max) const
int getDim2Bin(float dim2) const
compute bin for dim2 (y or phi)
void fill(const std::vector< float > &dim1, const std::vector< float > &dim2)
fill the tile
constexpr T normalizedPhi(T phi)
int getDim1Bin(float dim) const
compute bin for dim1 (x or eta)
int getGlobalBinByBin(int dim1Bin, int dim2Bin) const
float distance2(float dim1Cell1, float dim2Cell1, float dim1Cell2, float dim2Cell2) const
const std::vector< int > & operator[](int globalBinId) const
std::array< std::vector< int >, T::nTiles > tiles_
static constexpr float d1