CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Public Attributes | Private Attributes
HGCalLayerTilesT< T, WRAPPER > Class Template Reference

#include <HGCalLayerTiles.h>

Public Types

typedef T type
 

Public Member Functions

void clear ()
 
float distance2 (float dim1Cell1, float dim2Cell1, float dim1Cell2, float dim2Cell2) const
 
void fill (const std::vector< float > &dim1, const std::vector< float > &dim2)
 fill the tile More...
 
int getDim1Bin (float dim) const
 compute bin for dim1 (x or eta) More...
 
int getDim2Bin (float dim2) const
 compute bin for dim2 (y or phi) More...
 
int getGlobalBin (float dim1, float dim2) const
 
int getGlobalBinByBin (int dim1Bin, int dim2Bin) const
 
const std::vector< int > & operator[] (int globalBinId) const
 
std::array< int, 4 > searchBox (float dim1Min, float dim1Max, float dim2Min, float dim2Max) const
 

Public Attributes

int mPiPhiBin = getDim2Bin(-M_PI)
 
int pPiPhiBin = getDim2Bin(M_PI)
 

Private Attributes

std::array< std::vector< int >, T::nTiles > tiles_
 

Detailed Description

template<typename T, typename WRAPPER>
class HGCalLayerTilesT< T, WRAPPER >

Definition at line 19 of file HGCalLayerTiles.h.

Member Typedef Documentation

◆ type

template<typename T , typename WRAPPER >
typedef T HGCalLayerTilesT< T, WRAPPER >::type

Definition at line 21 of file HGCalLayerTiles.h.

Member Function Documentation

◆ clear()

template<typename T , typename WRAPPER >
void HGCalLayerTilesT< T, WRAPPER >::clear ( void  )
inline

Definition at line 111 of file HGCalLayerTiles.h.

References submitPVValidationJobs::t, and HGCalLayerTilesT< T, WRAPPER >::tiles_.

111  {
112  for (auto& t : tiles_)
113  t.clear();
114  }
std::array< std::vector< int >, T::nTiles > tiles_

◆ distance2()

template<typename T , typename WRAPPER >
float HGCalLayerTilesT< T, WRAPPER >::distance2 ( float  dim1Cell1,
float  dim2Cell1,
float  dim1Cell2,
float  dim2Cell2 
) const
inline

Definition at line 76 of file HGCalLayerTiles.h.

References ALPAKA_ACCELERATOR_NAMESPACE::brokenline::constexpr(), d1, and reco::deltaPhi().

76  { // distance squared
77  float d1 = dim1Cell1 - dim1Cell2;
78  float d2 = dim2Cell1 - dim2Cell2;
79  if constexpr (std::is_same_v<WRAPPER, PhiWrapper>) {
80  d2 = reco::deltaPhi(dim2Cell1, dim2Cell2);
81  }
82  return std::fmaf(d1, d1, d2 * d2);
83  }
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:26
static constexpr float d1

◆ fill()

template<typename T , typename WRAPPER >
void HGCalLayerTilesT< T, WRAPPER >::fill ( const std::vector< float > &  dim1,
const std::vector< float > &  dim2 
)
inline

fill the tile

Parameters
[in]dim1represents x or eta
[in]dim2represents y or phils

Definition at line 29 of file HGCalLayerTiles.h.

References HGCalLayerTilesT< T, WRAPPER >::getGlobalBin(), mps_fire::i, heavyIonCSV_trainingSettings::idx, and HGCalLayerTilesT< T, WRAPPER >::tiles_.

29  {
30  auto cellsSize = dim1.size();
31  for (unsigned int i = 0; i < cellsSize; ++i) {
32  auto idx = getGlobalBin(dim1[i], dim2[i]);
33  tiles_[idx].push_back(i);
34  }
35  }
int getGlobalBin(float dim1, float dim2) const
std::array< std::vector< int >, T::nTiles > tiles_

◆ getDim1Bin()

template<typename T , typename WRAPPER >
int HGCalLayerTilesT< T, WRAPPER >::getDim1Bin ( float  dim) const
inline

compute bin for dim1 (x or eta)

Parameters
[in]dimfor bining
Returns
computed bin

Definition at line 42 of file HGCalLayerTiles.h.

References ALPAKA_ACCELERATOR_NAMESPACE::brokenline::constexpr(), and alignCSCRings::r.

Referenced by HGCalLayerTilesT< T, WRAPPER >::getGlobalBin(), and HGCalLayerTilesT< T, WRAPPER >::searchBox().

42  {
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);
48  return dimBin;
49  }

◆ getDim2Bin()

template<typename T , typename WRAPPER >
int HGCalLayerTilesT< T, WRAPPER >::getDim2Bin ( float  dim2) const
inline

compute bin for dim2 (y or phi)

Parameters
[in]dimfor bining
Returns
computed bin

Definition at line 57 of file HGCalLayerTiles.h.

References ALPAKA_ACCELERATOR_NAMESPACE::brokenline::constexpr(), M_PI, normalizedPhi(), BeamMonitor_cff::phiBin, and alignCSCRings::r.

Referenced by HGCalLayerTilesT< T, WRAPPER >::getGlobalBin(), and HGCalLayerTilesT< T, WRAPPER >::searchBox().

57  {
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);
64  return dimBin;
65  } else {
66  auto normPhi = normalizedPhi(dim2);
67  constexpr float r = T::nRows * M_1_PI * 0.5f;
68  int phiBin = (normPhi + M_PI) * r;
69  return phiBin;
70  }
71  }
constexpr T normalizedPhi(T phi)
Definition: normalizedPhi.h:8
#define M_PI

◆ getGlobalBin()

template<typename T , typename WRAPPER >
int HGCalLayerTilesT< T, WRAPPER >::getGlobalBin ( float  dim1,
float  dim2 
) const
inline

Definition at line 84 of file HGCalLayerTiles.h.

References HGCalLayerTilesT< T, WRAPPER >::getDim1Bin(), and HGCalLayerTilesT< T, WRAPPER >::getDim2Bin().

Referenced by HGCalLayerTilesT< T, WRAPPER >::fill().

84 { return getDim1Bin(dim1) + getDim2Bin(dim2) * T::nColumns; }
int getDim2Bin(float dim2) const
compute bin for dim2 (y or phi)
int getDim1Bin(float dim) const
compute bin for dim1 (x or eta)

◆ getGlobalBinByBin()

template<typename T , typename WRAPPER >
int HGCalLayerTilesT< T, WRAPPER >::getGlobalBinByBin ( int  dim1Bin,
int  dim2Bin 
) const
inline

Definition at line 86 of file HGCalLayerTiles.h.

86 { return dim1Bin + dim2Bin * T::nColumns; }

◆ operator[]()

template<typename T , typename WRAPPER >
const std::vector<int>& HGCalLayerTilesT< T, WRAPPER >::operator[] ( int  globalBinId) const
inline

Definition at line 116 of file HGCalLayerTiles.h.

References HGCalLayerTilesT< T, WRAPPER >::tiles_.

116 { return tiles_[globalBinId]; }
std::array< std::vector< int >, T::nTiles > tiles_

◆ searchBox()

template<typename T , typename WRAPPER >
std::array<int, 4> HGCalLayerTilesT< T, WRAPPER >::searchBox ( float  dim1Min,
float  dim1Max,
float  dim2Min,
float  dim2Max 
) const
inline

Definition at line 88 of file HGCalLayerTiles.h.

References ALPAKA_ACCELERATOR_NAMESPACE::brokenline::constexpr(), HGCalLayerTilesT< T, WRAPPER >::getDim1Bin(), and HGCalLayerTilesT< T, WRAPPER >::getDim2Bin().

88  {
89  if constexpr (std::is_same_v<WRAPPER, PhiWrapper>) {
90  if (dim1Max - dim1Min < 0) {
91  return std::array<int, 4>({{0, 0, 0, 0}});
92  }
93  }
94  int dim1BinMin = getDim1Bin(dim1Min);
95  int dim1BinMax = getDim1Bin(dim1Max);
96  int dim2BinMin = getDim2Bin(dim2Min);
97  int dim2BinMax = getDim2Bin(dim2Max);
98  if constexpr (std::is_same_v<WRAPPER, PhiWrapper>) {
99  // If the search window cross the phi-bin boundary, add T::nPhiBins to the
100  // MAx value. This guarantees that the caller can perform a valid doule
101  // loop on eta and phi. It is the caller responsibility to perform a module
102  // operation on the phiBin values returned by this function, to explore the
103  // correct bins.
104  if (dim2BinMax < dim2BinMin) {
105  dim2BinMax += T::nRows;
106  }
107  }
108  return std::array<int, 4>({{dim1BinMin, dim1BinMax, dim2BinMin, dim2BinMax}});
109  }
int getDim2Bin(float dim2) const
compute bin for dim2 (y or phi)
int getDim1Bin(float dim) const
compute bin for dim1 (x or eta)

Member Data Documentation

◆ mPiPhiBin

template<typename T , typename WRAPPER >
int HGCalLayerTilesT< T, WRAPPER >::mPiPhiBin = getDim2Bin(-M_PI)

Definition at line 73 of file HGCalLayerTiles.h.

◆ pPiPhiBin

template<typename T , typename WRAPPER >
int HGCalLayerTilesT< T, WRAPPER >::pPiPhiBin = getDim2Bin(M_PI)

Definition at line 74 of file HGCalLayerTiles.h.

◆ tiles_

template<typename T , typename WRAPPER >
std::array<std::vector<int>, T::nTiles> HGCalLayerTilesT< T, WRAPPER >::tiles_
private