CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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  return std::array<int, 4>({{etaBinMin, etaBinMax, phiBinMin, phiBinMax}});
42  }
43 
44  int globalBin(int etaBin, int phiBin) const { return phiBin + etaBin * T::nPhiBins; }
45 
46  int globalBin(double eta, double phi) const { return phiBin(phi) + etaBin(eta) * T::nPhiBins; }
47 
48  void clear() {
49  auto nBins = T::nEtaBins * T::nPhiBins;
50  for (int j = 0; j < nBins; ++j)
51  tile_[j].clear();
52  }
53 
54  const std::vector<unsigned int>& operator[](int globalBinId) const { return tile_[globalBinId]; }
55 
56 private:
57  std::array<std::vector<unsigned int>, T::nBins> tile_;
58 };
59 
60 namespace ticl {
62  using Tiles = std::array<TICLLayerTile, TileConstants::nLayers>;
63  using TracksterTiles = std::array<TICLLayerTile, TileConstants::iterations>;
64 
66  using TilesHFNose = std::array<TICLLayerTileHFNose, TileConstantsHFNose::nLayers>;
67  using TracksterTilesHFNose = std::array<TICLLayerTileHFNose, TileConstantsHFNose::iterations>;
68 
69 } // namespace ticl
70 
71 template <typename T>
73 public:
74  // value_type_t is the type of the type of the array used by the incoming <T> type.
76  // This class represents a generic collection of Tiles. The additional index
77  // numbering is not handled internally. It is the user's responsibility to
78  // properly use and consistently access it here.
79  const auto& operator[](int index) const { return tiles_[index]; }
80  void fill(int index, double eta, double phi, unsigned int objectId) { tiles_[index].fill(eta, phi, objectId); }
81 
82 private:
84 };
85 
90 
91 #endif
void fill(double eta, double phi, unsigned int layerClusterId)
Definition: TICLLayerTile.h:15
const auto & operator[](int index) const
Definition: TICLLayerTile.h:79
std::array< TICLLayerTileHFNose, TileConstantsHFNose::iterations > TracksterTilesHFNose
Definition: TICLLayerTile.h:67
constexpr T normalizedPhi(T phi)
Definition: normalizedPhi.h:8
int etaBin(float eta) const
Definition: TICLLayerTile.h:19
tuple etaMin
Definition: Puppi_cff.py:46
double maxEta
int globalBin(int etaBin, int phiBin) const
Definition: TICLLayerTile.h:44
std::array< TICLLayerTile, TileConstants::nLayers > Tiles
Definition: TICLLayerTile.h:62
std::array< int, 4 > searchBoxEtaPhi(float etaMin, float etaMax, float phiMin, float phiMax) const
Definition: TICLLayerTile.h:36
std::array< std::vector< unsigned int >, T::nBins > tile_
Definition: TICLLayerTile.h:57
const std::vector< unsigned int > & operator[](int globalBinId) const
Definition: TICLLayerTile.h:54
std::array< TICLLayerTile, TileConstants::iterations > TracksterTiles
Definition: TICLLayerTile.h:63
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int phiBin(float phi) const
Definition: TICLLayerTile.h:28
typename T::value_type::type constants_type_t
Definition: TICLLayerTile.h:75
#define M_PI
int globalBin(double eta, double phi) const
Definition: TICLLayerTile.h:46
std::array< TICLLayerTileHFNose, TileConstantsHFNose::nLayers > TilesHFNose
Definition: TICLLayerTile.h:66
void fill(int index, double eta, double phi, unsigned int objectId)
Definition: TICLLayerTile.h:80
tuple etaMax
Definition: Puppi_cff.py:47
long double T