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