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 {
20  constexpr float etaRange = T::maxEta - T::minEta;
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  int etaBinMin = etaBin(etaMin);
38  int etaBinMax = etaBin(etaMax);
39  int phiBinMin = phiBin(phiMin);
40  int phiBinMax = phiBin(phiMax);
41  // If the search window cross the phi-bin boundary, add T::nPhiBins to the
42  // MAx value. This guarantees that the caller can perform a valid doule
43  // loop on eta and phi. It is the caller responsibility to perform a module
44  // operation on the phiBin values returned by this function, to explore the
45  // correct bins.
46  if (phiBinMax < phiBinMin) {
47  phiBinMax += T::nPhiBins;
48  }
49  return std::array<int, 4>({{etaBinMin, etaBinMax, phiBinMin, phiBinMax}});
50  }
51 
52  int globalBin(int etaBin, int phiBin) const { return phiBin + etaBin * T::nPhiBins; }
53 
54  int globalBin(double eta, double phi) const { return phiBin(phi) + etaBin(eta) * T::nPhiBins; }
55 
56  void clear() {
57  auto nBins = T::nEtaBins * T::nPhiBins;
58  for (int j = 0; j < nBins; ++j)
59  tile_[j].clear();
60  }
61 
62  const std::vector<unsigned int>& operator[](int globalBinId) const { return tile_[globalBinId]; }
63 
64 private:
65  std::array<std::vector<unsigned int>, T::nBins> tile_;
66 };
67 
68 namespace ticl {
70  using Tiles = std::array<TICLLayerTile, TileConstants::nLayers>;
71  using TracksterTiles = std::array<TICLLayerTile, TileConstants::iterations>;
72 
74  using TilesHFNose = std::array<TICLLayerTileHFNose, TileConstantsHFNose::nLayers>;
75  using TracksterTilesHFNose = std::array<TICLLayerTileHFNose, TileConstantsHFNose::iterations>;
76 
77 } // namespace ticl
78 
79 template <typename T>
81 public:
82  // value_type_t is the type of the type of the array used by the incoming <T> type.
84  // This class represents a generic collection of Tiles. The additional index
85  // numbering is not handled internally. It is the user's responsibility to
86  // properly use and consistently access it here.
87  const auto& operator[](int index) const { return tiles_[index]; }
88  void fill(int index, double eta, double phi, unsigned int objectId) { tiles_[index].fill(eta, phi, objectId); }
89 
90 private:
92 };
93 
98 
99 #endif
void fill(double eta, double phi, unsigned int layerClusterId)
Definition: TICLLayerTile.h:15
std::array< TICLLayerTileHFNose, TileConstantsHFNose::iterations > TracksterTilesHFNose
Definition: TICLLayerTile.h:75
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:54
const auto & operator[](int index) const
Definition: TICLLayerTile.h:87
std::array< TICLLayerTile, TileConstants::nLayers > Tiles
Definition: TICLLayerTile.h:70
std::array< std::vector< unsigned int >, T::nBins > tile_
Definition: TICLLayerTile.h:65
std::array< TICLLayerTile, TileConstants::iterations > TracksterTiles
Definition: TICLLayerTile.h:71
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:62
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:83
#define M_PI
std::array< TICLLayerTileHFNose, TileConstantsHFNose::nLayers > TilesHFNose
Definition: TICLLayerTile.h:74
Definition: Common.h:8
void fill(int index, double eta, double phi, unsigned int objectId)
Definition: TICLLayerTile.h:88
int globalBin(int etaBin, int phiBin) const
Definition: TICLLayerTile.h:52
long double T