CMS 3D CMS Logo

HGCalLayerTiles.h
Go to the documentation of this file.
1 // Authors: Felice Pantaleo - felice.pantaleo@cern.ch
2 // Date: 03/2019
3 
4 #ifndef RecoLocalCalo_HGCalRecProducers_HGCalLayerTiles_h
5 #define RecoLocalCalo_HGCalRecProducers_HGCalLayerTiles_h
6 
9 
10 #include <vector>
11 #include <array>
12 #include <cmath>
13 #include <algorithm>
14 #include <cassert>
15 
16 template <typename T>
18 public:
19  void fill(const std::vector<float>& x,
20  const std::vector<float>& y,
21  const std::vector<float>& eta,
22  const std::vector<float>& phi,
23  const std::vector<bool>& isSi) {
24  auto cellsSize = x.size();
25  for (unsigned int i = 0; i < cellsSize; ++i) {
26  tiles_[getGlobalBin(x[i], y[i])].push_back(i);
27  if (!isSi[i]) {
28  tiles_[getGlobalBinEtaPhi(eta[i], phi[i])].push_back(i);
29  // Copy cells in phi=[-3.15,-3.] to the last bin
30  if (getPhiBin(phi[i]) == mPiPhiBin) {
31  tiles_[getGlobalBinEtaPhi(eta[i], phi[i] + 2 * M_PI)].push_back(i);
32  }
33  // Copy cells in phi=[3.,3.15] to the first bin
34  if (getPhiBin(phi[i]) == pPiPhiBin) {
35  tiles_[getGlobalBinEtaPhi(eta[i], phi[i] - 2 * M_PI)].push_back(i);
36  }
37  }
38  }
39  }
40 
41  int getXBin(float x) const {
42  constexpr float xRange = T::maxX - T::minX;
43  static_assert(xRange >= 0.);
44  constexpr float r = T::nColumns / xRange;
45  int xBin = (x - T::minX) * r;
46  xBin = std::clamp(xBin, 0, T::nColumns - 1);
47  return xBin;
48  }
49 
50  int getYBin(float y) const {
51  constexpr float yRange = T::maxY - T::minY;
52  static_assert(yRange >= 0.);
53  constexpr float r = T::nRows / yRange;
54  int yBin = (y - T::minY) * r;
55  yBin = std::clamp(yBin, 0, T::nRows - 1);
56  return yBin;
57  }
58 
59  int getEtaBin(float eta) const {
60  constexpr float etaRange = T::maxEta - T::minEta;
61  static_assert(etaRange >= 0.);
62  constexpr float r = T::nColumnsEta / etaRange;
63  int etaBin = (eta - T::minEta) * r;
64  etaBin = std::clamp(etaBin, 0, T::nColumnsEta - 1);
65  return etaBin;
66  }
67 
68  int getPhiBin(float phi) const {
69  constexpr float phiRange = T::maxPhi - T::minPhi;
70  static_assert(phiRange >= 0.);
71  constexpr float r = T::nRowsPhi / phiRange;
72  int phiBin = (phi - T::minPhi) * r;
73  phiBin = std::clamp(phiBin, 0, T::nRowsPhi - 1);
74  return phiBin;
75  }
76 
79 
80  int getGlobalBin(float x, float y) const { return getXBin(x) + getYBin(y) * T::nColumns; }
81 
82  int getGlobalBinByBin(int xBin, int yBin) const { return xBin + yBin * T::nColumns; }
83 
84  int getGlobalBinEtaPhi(float eta, float phi) const {
85  return T::nColumns * T::nRows + getEtaBin(eta) + getPhiBin(phi) * T::nColumnsEta;
86  }
87 
88  int getGlobalBinByBinEtaPhi(int etaBin, int phiBin) const {
89  return T::nColumns * T::nRows + etaBin + phiBin * T::nColumnsEta;
90  }
91 
92  std::array<int, 4> searchBox(float xMin, float xMax, float yMin, float yMax) const {
93  int xBinMin = getXBin(xMin);
94  int xBinMax = getXBin(xMax);
95  int yBinMin = getYBin(yMin);
96  int yBinMax = getYBin(yMax);
97  return std::array<int, 4>({{xBinMin, xBinMax, yBinMin, yBinMax}});
98  }
99 
100  std::array<int, 4> searchBoxEtaPhi(float etaMin, float etaMax, float phiMin, float phiMax) const {
101  int etaBinMin = getEtaBin(etaMin);
102  int etaBinMax = getEtaBin(etaMax);
103  int phiBinMin = getPhiBin(phiMin);
104  int phiBinMax = getPhiBin(phiMax);
105  return std::array<int, 4>({{etaBinMin, etaBinMax, phiBinMin, phiBinMax}});
106  }
107 
108  void clear() {
109  for (auto& t : tiles_)
110  t.clear();
111  }
112 
113  const std::vector<int>& operator[](int globalBinId) const { return tiles_[globalBinId]; }
114 
115 private:
116  std::array<std::vector<int>, T::nTiles> tiles_;
117 };
118 
121 #endif
beampixel_dqm_sourceclient-live_cfg.xRange
xRange
Definition: beampixel_dqm_sourceclient-live_cfg.py:144
HGCalLayerTilesT::getEtaBin
int getEtaBin(float eta) const
Definition: HGCalLayerTiles.h:59
DDAxes::y
HGCalLayerTilesT::tiles_
std::array< std::vector< int >, T::nTiles > tiles_
Definition: HGCalLayerTiles.h:116
ALCARECOTkAlBeamHalo_cff.etaMin
etaMin
GeV.
Definition: ALCARECOTkAlBeamHalo_cff.py:32
mps_fire.i
i
Definition: mps_fire.py:428
photonAnalyzer_cfi.xBin
xBin
Definition: photonAnalyzer_cfi.py:81
generateTowerEtThresholdLUT.etaRange
etaRange
Definition: generateTowerEtThresholdLUT.py:55
etaBin
int etaBin(const l1t::HGCalMulticluster *cl)
Definition: L1EGammaEEProducer.cc:19
BeamMonitor_cff.phiBin
phiBin
Definition: BeamMonitor_cff.py:75
HGCalLayerTilesT::fill
void fill(const std::vector< float > &x, const std::vector< float > &y, const std::vector< float > &eta, const std::vector< float > &phi, const std::vector< bool > &isSi)
Definition: HGCalLayerTiles.h:19
HGCalLayerTilesT::pPiPhiBin
int pPiPhiBin
Definition: HGCalLayerTiles.h:78
HFNoseTilesConstants.h
photonAnalyzer_cfi.yBin
yBin
Definition: photonAnalyzer_cfi.py:85
photonAnalyzer_cfi.yMin
yMin
Definition: photonAnalyzer_cfi.py:86
DDAxes::x
HGCalLayerTilesT::searchBox
std::array< int, 4 > searchBox(float xMin, float xMax, float yMin, float yMax) const
Definition: HGCalLayerTiles.h:92
HGVHistoProducerAlgoBlock_cfi.minX
minX
Definition: HGVHistoProducerAlgoBlock_cfi.py:153
HLT_FULL_cff.maxPhi
maxPhi
Definition: HLT_FULL_cff.py:52976
photonAnalyzer_cfi.xMin
xMin
Definition: photonAnalyzer_cfi.py:82
HGCalLayerTilesT::mPiPhiBin
int mPiPhiBin
Definition: HGCalLayerTiles.h:77
PVValHelper::eta
Definition: PVValidationHelpers.h:69
AlignmentTrackSelector_cfi.phiMin
phiMin
Definition: AlignmentTrackSelector_cfi.py:18
maxEta
double maxEta
Definition: PFJetBenchmarkAnalyzer.cc:76
HGCalLayerTilesT::getGlobalBin
int getGlobalBin(float x, float y) const
Definition: HGCalLayerTiles.h:80
AlignmentTrackSelector_cfi.phiMax
phiMax
Definition: AlignmentTrackSelector_cfi.py:17
multiplicitycorr_cfi.yMax
yMax
Definition: multiplicitycorr_cfi.py:6
HGCalLayerTilesT
Definition: HGCalLayerTiles.h:17
beampixel_dqm_sourceclient-live_cfg.yRange
yRange
Definition: beampixel_dqm_sourceclient-live_cfg.py:146
HGCalLayerTilesT::searchBoxEtaPhi
std::array< int, 4 > searchBoxEtaPhi(float etaMin, float etaMax, float phiMin, float phiMax) const
Definition: HGCalLayerTiles.h:100
HGCalLayerTilesT::getGlobalBinByBin
int getGlobalBinByBin(int xBin, int yBin) const
Definition: HGCalLayerTiles.h:82
HGVHistoProducerAlgoBlock_cfi.minY
minY
Definition: HGVHistoProducerAlgoBlock_cfi.py:158
HGCalLayerTilesT::getXBin
int getXBin(float x) const
Definition: HGCalLayerTiles.h:41
HGCalLayerTilesT::getGlobalBinEtaPhi
int getGlobalBinEtaPhi(float eta, float phi) const
Definition: HGCalLayerTiles.h:84
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:49
HGCalLayerTilesT::clear
void clear()
Definition: HGCalLayerTiles.h:108
HGCalLayerTilesT::getPhiBin
int getPhiBin(float phi) const
Definition: HGCalLayerTiles.h:68
alignCSCRings.r
r
Definition: alignCSCRings.py:93
HGCalLayerTilesT::operator[]
const std::vector< int > & operator[](int globalBinId) const
Definition: HGCalLayerTiles.h:113
DDAxes::phi
HLT_FULL_cff.minPhi
minPhi
Definition: HLT_FULL_cff.py:52964
HGVHistoProducerAlgoBlock_cfi.maxY
maxY
Definition: HGVHistoProducerAlgoBlock_cfi.py:159
ALCARECOTkAlBeamHalo_cff.etaMax
etaMax
Definition: ALCARECOTkAlBeamHalo_cff.py:33
HGCalLayerTilesT::getYBin
int getYBin(float y) const
Definition: HGCalLayerTiles.h:50
multiplicitycorr_cfi.xMax
xMax
Definition: multiplicitycorr_cfi.py:5
HGCalTilesConstants.h
EgHLTOffEleSelection_cfi.minEta
minEta
Definition: EgHLTOffEleSelection_cfi.py:11
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
HGCalLayerTilesT::getGlobalBinByBinEtaPhi
int getGlobalBinByBinEtaPhi(int etaBin, int phiBin) const
Definition: HGCalLayerTiles.h:88
HGVHistoProducerAlgoBlock_cfi.maxX
maxX
Definition: HGVHistoProducerAlgoBlock_cfi.py:154