CMS 3D CMS Logo

TICLLayerTile.h
Go to the documentation of this file.
1 // Authors: Marco Rovere, Felice Pantaleo - marco.rovere@cern.ch, felice.pantaleo@cern.ch
2 // Date: 05/2019
3 
4 #ifndef DataFormats_HGCalReco_TICLLayerTile_h
5 #define DataFormats_HGCalReco_TICLLayerTile_h
6 
9 
10 template <typename T>
12 public:
13  typedef T type;
14 
15  void fill(float eta, float phi, unsigned int layerClusterId) { tile_[globalBin(eta, phi)].push_back(layerClusterId); }
16 
17  int etaBin(float eta) const {
19  static_assert(etaRange >= 0.f);
20  float r = T::nEtaBins / etaRange;
21  int etaBin = (std::abs(eta) - T::minEta) * r;
22  etaBin = std::clamp(etaBin, 0, T::nEtaBins - 1);
23  return etaBin;
24  }
25 
26  int phiBin(float phi) const {
27  auto normPhi = normalizedPhi(phi);
28  float r = T::nPhiBins * M_1_PI * 0.5f;
29  int phiBin = (normPhi + M_PI) * r;
30 
31  return phiBin;
32  }
33 
34  std::array<int, 4> searchBoxEtaPhi(float etaMin, float etaMax, float phiMin, float phiMax) const {
35  // The tile only handles one endcap at a time and does not hold mixed eta
36  // values.
37  if (etaMin * etaMax < 0) {
38  return std::array<int, 4>({{0, 0, 0, 0}});
39  }
40  if (etaMax - etaMin < 0) {
41  return std::array<int, 4>({{0, 0, 0, 0}});
42  }
43  int etaBinMin = etaBin(etaMin);
44  int etaBinMax = etaBin(etaMax);
45  int phiBinMin = phiBin(phiMin);
46  int phiBinMax = phiBin(phiMax);
47  if (etaMin < 0) {
48  std::swap(etaBinMin, etaBinMax);
49  }
50  // If the search window cross the phi-bin boundary, add T::nPhiBins to the
51  // MAx value. This guarantees that the caller can perform a valid doule
52  // loop on eta and phi. It is the caller responsibility to perform a module
53  // operation on the phiBin values returned by this function, to explore the
54  // correct bins.
55  if (phiBinMax < phiBinMin) {
56  phiBinMax += T::nPhiBins;
57  }
58  return std::array<int, 4>({{etaBinMin, etaBinMax, phiBinMin, phiBinMax}});
59  }
60 
61  int globalBin(int etaBin, int phiBin) const { return phiBin + etaBin * T::nPhiBins; }
62 
63  int globalBin(float eta, float phi) const { return phiBin(phi) + etaBin(eta) * T::nPhiBins; }
64 
65  void clear() {
66  auto nBins = T::nEtaBins * T::nPhiBins;
67  for (int j = 0; j < nBins; ++j)
68  tile_[j].clear();
69  }
70 
71  const std::vector<unsigned int>& operator[](int globalBinId) const { return tile_[globalBinId]; }
72 
73 private:
74  std::array<std::vector<unsigned int>, T::nBins> tile_;
75 };
76 
77 namespace ticl {
79  using Tiles = std::array<TICLLayerTile, TileConstants::nLayers>;
80  using TracksterTiles = std::array<TICLLayerTile, TileConstants::iterations>;
81 
83  using TilesHFNose = std::array<TICLLayerTileHFNose, TileConstantsHFNose::nLayers>;
84  using TracksterTilesHFNose = std::array<TICLLayerTileHFNose, TileConstantsHFNose::iterations>;
85 
86 } // namespace ticl
87 
88 template <typename T>
90 public:
91  // value_type_t is the type of the type of the array used by the incoming <T> type.
93  // This class represents a generic collection of Tiles. The additional index
94  // numbering is not handled internally. It is the user's responsibility to
95  // properly use and consistently access it here.
96  const auto& operator[](int index) const { return tiles_[index]; }
97  void fill(int index, float eta, float phi, unsigned int objectId) { tiles_[index].fill(eta, phi, objectId); }
98 
99 private:
101 };
102 
107 
108 #endif
std::array< TICLLayerTileHFNose, TileConstantsHFNose::iterations > TracksterTilesHFNose
Definition: TICLLayerTile.h:84
int etaBin(float eta) const
Definition: TICLLayerTile.h:17
constexpr T normalizedPhi(T phi)
Definition: normalizedPhi.h:8
const auto & operator[](int index) const
Definition: TICLLayerTile.h:96
std::array< TICLLayerTile, TileConstants::nLayers > Tiles
Definition: TICLLayerTile.h:79
int globalBin(float eta, float phi) const
Definition: TICLLayerTile.h:63
std::array< std::vector< unsigned int >, T::nBins > tile_
Definition: TICLLayerTile.h:74
void swap(Association< C > &lhs, Association< C > &rhs)
Definition: Association.h:112
std::array< TICLLayerTile, TileConstants::iterations > TracksterTiles
Definition: TICLLayerTile.h:80
std::array< int, 4 > searchBoxEtaPhi(float etaMin, float etaMax, float phiMin, float phiMax) const
Definition: TICLLayerTile.h:34
const std::vector< unsigned int > & operator[](int globalBinId) const
Definition: TICLLayerTile.h:71
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
void fill(int index, float eta, float phi, unsigned int objectId)
Definition: TICLLayerTile.h:97
double f[11][100]
int phiBin(float phi) const
Definition: TICLLayerTile.h:26
typename T::value_type::type constants_type_t
Definition: TICLLayerTile.h:92
#define M_PI
std::array< TICLLayerTileHFNose, TileConstantsHFNose::nLayers > TilesHFNose
Definition: TICLLayerTile.h:83
void fill(float eta, float phi, unsigned int layerClusterId)
Definition: TICLLayerTile.h:15
static constexpr int nPhiBins
Definition: Common.h:10
int globalBin(int etaBin, int phiBin) const
Definition: TICLLayerTile.h:61
long double T