CMS 3D CMS Logo

HGCalHistoSeedingImpl.h
Go to the documentation of this file.
1 #ifndef __L1Trigger_L1THGCal_HGCalHistoSeedingImpl_h__
2 #define __L1Trigger_L1THGCal_HGCalHistoSeedingImpl_h__
3 
8 
13 
15 private:
16  struct Bin {
17  enum Content { Sum, Ecal, Hcal };
18  std::array<float, 3> values = {{0., 0., 0.}};
19  float weighted_x = 0.;
20  float weighted_y = 0.;
21  };
22  template <typename T>
23  class HistogramT {
24  public:
25  using Data = std::vector<T>;
26  using iterator = typename Data::iterator;
27  using const_iterator = typename Data::const_iterator;
28 
29  public:
30  HistogramT() : bins1_(0), bins2_(0), bins_(0) {}
31  HistogramT(unsigned bins1, unsigned bins2)
32  : bins1_(bins1), bins2_(bins2), bins_(bins1 * bins2), histogram_(bins_ * kSides_) {}
33 
34  T& at(int zside, unsigned x1, unsigned x2) { return histogram_[index(zside, x1, x2)]; }
35 
36  const T& at(int zside, unsigned x1, unsigned x2) const { return histogram_[index(zside, x1, x2)]; }
37 
38  iterator begin() { return histogram_.begin(); }
39  const_iterator begin() const { return histogram_.begin(); }
40  iterator end() { return histogram_.end(); }
41  const_iterator end() const { return histogram_.end(); }
42 
43  private:
44  static constexpr unsigned kSides_ = 2;
45  unsigned bins1_ = 0;
46  unsigned bins2_ = 0;
47  unsigned bins_ = 0;
49 
50  unsigned index(int zside, unsigned x1, unsigned x2) const {
51  if (x1 >= bins1_ || x2 >= bins2_) {
52  throw cms::Exception("OutOfBound") << "Trying to access bin (" << x1 << "," << x2
53  << ") in seeding histogram of size (" << bins1_ << "," << bins2_ << ")";
54  }
55  return x2 + bins2_ * x1 + bins_ * (zside > 0 ? 1 : 0);
56  }
57  };
59 
60  class Navigator {
61  public:
62  enum class AxisType { Bounded, Circular };
63 
65 
66  Navigator(int bins1, AxisType type_axis1, int bins2, AxisType type_axis2)
67  : axis_types_({{type_axis1, type_axis2}}), bins_({{bins1, bins2}}), home_({{0, 0}}) {}
68 
69  void setHome(int x1, int x2) {
70  if (x1 < 0 || x2 < 0 || x1 >= std::get<0>(bins_) || x2 >= std::get<1>(bins_)) {
71  throw cms::Exception("OutOfBound") << "Setting invalid navigator home position (" << x1 << "," << x2 << "\n)";
72  }
73  home_[0] = x1;
74  home_[1] = x2;
75  }
76 
77  std::array<int, 2> move(int offset1, int offset2) { return {{offset<0>(offset1), offset<1>(offset2)}}; }
78 
79  template <unsigned N>
80  int offset(int shift) {
81  int shifted = std::get<N>(home_);
82  int max = std::get<N>(bins_);
83  switch (std::get<N>(axis_types_)) {
84  case AxisType::Bounded:
85  shifted += shift;
86  if (shifted < 0 || shifted >= max)
87  shifted = -1;
88  break;
89  case AxisType::Circular:
90  shifted += shift;
91  while (shifted < 0)
92  shifted += max;
93  while (shifted >= max)
94  shifted -= max;
95  break;
96  default:
97  break;
98  }
99  return shifted;
100  }
101 
102  private:
103  std::array<AxisType, 2> axis_types_;
104  std::array<int, 2> bins_;
105  std::array<int, 2> home_;
106  };
107 
108 public:
110 
112 
113  float dR(const l1t::HGCalCluster& clu, const GlobalPoint& seed) const;
114 
115  void findHistoSeeds(const std::vector<edm::Ptr<l1t::HGCalCluster>>& clustersPtr,
116  std::vector<std::pair<GlobalPoint, double>>& seedPositionsEnergy);
117 
118 private:
120  enum SeedingSpace { RPhi, XY };
122 
124 
125  Histogram fillSmoothHistoClusters(const Histogram&, const vector<double>&, Bin::Content);
126  Histogram fillSmoothPhiHistoClusters(const Histogram& histoClusters, const vector<unsigned>& binSums);
127  Histogram fillSmoothRPhiHistoClusters(const Histogram& histoClusters);
128 
129  void setSeedEnergyAndPosition(std::vector<std::pair<GlobalPoint, double>>& seedPositionsEnergy,
130  int z_side,
131  unsigned bin_R,
132  unsigned bin_phi,
133  const Bin& histBin);
134 
135  std::vector<std::pair<GlobalPoint, double>> computeMaxSeeds(const Histogram& histoClusters);
136 
137  std::vector<std::pair<GlobalPoint, double>> computeSecondaryMaxSeeds(const Histogram& histoClusters);
138 
139  std::vector<std::pair<GlobalPoint, double>> computeInterpolatedMaxSeeds(const Histogram& histoClusters);
140 
141  std::vector<std::pair<GlobalPoint, double>> computeThresholdSeeds(const Histogram& histoClusters);
142 
143  std::array<double, 4> boundaries();
144 
149 
150  unsigned nBins1_ = 42;
151  unsigned nBins2_ = 216;
152  std::vector<unsigned> binsSumsHisto_;
153  double histoThreshold_ = 20.;
154  static constexpr double area_per_triggercell_ =
155  4.91E-05; // Hex_Wafer_Area (x/z units)/N_TC (per wafer) = (0.866*((hexWafer_minimal_diameter)*(1./319.))^2 / 48)
156  std::vector<double> neighbour_weights_;
157  std::vector<double> smoothing_ecal_;
158  std::vector<double> smoothing_hcal_;
159 
162 
163  static constexpr unsigned neighbour_weights_size_ = 9;
164  const double kROverZMin_ = 0.076;
165  const double kROverZMax_ = 0.58;
166 
167  static constexpr double kXYMax_ = 0.6;
168 };
169 
170 #endif
HGCalHistoSeedingImpl::HistogramT::bins2_
unsigned bins2_
Definition: HGCalHistoSeedingImpl.h:46
HGCalHistoSeedingImpl::navigator_
Navigator navigator_
Definition: HGCalHistoSeedingImpl.h:161
HGCalTriggerTools.h
l1t::HGCalCluster
Definition: HGCalCluster.h:11
HGCalTriggerTools::eventSetup
void eventSetup(const edm::EventSetup &)
Definition: HGCalTriggerTools.cc:35
HGCalHistoSeedingImpl::computeSecondaryMaxSeeds
std::vector< std::pair< GlobalPoint, double > > computeSecondaryMaxSeeds(const Histogram &histoClusters)
Definition: HGCalHistoSeedingImpl.cc:407
HGCalHistoSeedingImpl::kROverZMax_
const double kROverZMax_
Definition: HGCalHistoSeedingImpl.h:165
HGCalHistoSeedingImpl::Bin::weighted_y
float weighted_y
Definition: HGCalHistoSeedingImpl.h:20
HGCalHistoSeedingImpl::HistogramT::index
unsigned index(int zside, unsigned x1, unsigned x2) const
Definition: HGCalHistoSeedingImpl.h:50
HGCalHistoSeedingImpl::SeedingPosition
SeedingPosition
Definition: HGCalHistoSeedingImpl.h:121
HGCalHistoSeedingImpl
Definition: HGCalHistoSeedingImpl.h:14
MessageLogger.h
HGCalHistoSeedingImpl::area_per_triggercell_
static constexpr double area_per_triggercell_
Definition: HGCalHistoSeedingImpl.h:154
HGCalHistoSeedingImpl::XY
Definition: HGCalHistoSeedingImpl.h:120
HGCalHistoSeedingImpl::nBins2_
unsigned nBins2_
Definition: HGCalHistoSeedingImpl.h:151
hgcalBackEndLayer2Producer_cfi.binSums
binSums
Definition: hgcalBackEndLayer2Producer_cfi.py:12
HGCalHistoSeedingImpl::kROverZMin_
const double kROverZMin_
Definition: HGCalHistoSeedingImpl.h:164
HGCalHistoSeedingImpl::Bin::Ecal
Definition: HGCalHistoSeedingImpl.h:17
ecaldqm::zside
int zside(DetId const &)
Definition: EcalDQMCommonUtils.cc:189
HGCalHistoSeedingImpl::eventSetup
void eventSetup(const edm::EventSetup &es)
Definition: HGCalHistoSeedingImpl.h:111
testProducerWithPsetDescEmpty_cfi.x2
x2
Definition: testProducerWithPsetDescEmpty_cfi.py:28
HGCalHistoSeedingImpl::HistogramT::at
T & at(int zside, unsigned x1, unsigned x2)
Definition: HGCalHistoSeedingImpl.h:34
HGCalTriggerClusterIdentificationBase.h
HGCalHistoSeedingImpl::HistogramT::Data
std::vector< T > Data
Definition: HGCalHistoSeedingImpl.h:25
HGCalHistoSeedingImpl::Navigator::Navigator
Navigator()
Definition: HGCalHistoSeedingImpl.h:64
HGCalHistoSeedingImpl::HistogramT::end
const_iterator end() const
Definition: HGCalHistoSeedingImpl.h:41
HGCalHistoSeedingImpl::RPhi
Definition: HGCalHistoSeedingImpl.h:120
HGCalHistoSeedingImpl::boundaries
std::array< double, 4 > boundaries()
Definition: HGCalHistoSeedingImpl.cc:555
HGCalHistoSeedingImpl::Bin::Sum
Definition: HGCalHistoSeedingImpl.h:17
HGCalHistoSeedingImpl::neighbour_weights_
std::vector< double > neighbour_weights_
Definition: HGCalHistoSeedingImpl.h:156
HGCalHistoSeedingImpl::Navigator::home_
std::array< int, 2 > home_
Definition: HGCalHistoSeedingImpl.h:105
HGCalHistoSeedingImpl::Navigator::AxisType
AxisType
Definition: HGCalHistoSeedingImpl.h:62
HGCalHistoSeedingImpl::triggerTools_
HGCalTriggerTools triggerTools_
Definition: HGCalHistoSeedingImpl.h:160
HGCalHistoSeedingImpl::fillHistoClusters
Histogram fillHistoClusters(const std::vector< edm::Ptr< l1t::HGCalCluster >> &clustersPtrs)
Definition: HGCalHistoSeedingImpl.cc:69
HGCalHistoSeedingImpl::Navigator::setHome
void setHome(int x1, int x2)
Definition: HGCalHistoSeedingImpl.h:69
HGCalShowerShape.h
HGCalHistoSeedingImpl::TCWeighted
Definition: HGCalHistoSeedingImpl.h:121
HGCalHistoSeedingImpl::Navigator::move
std::array< int, 2 > move(int offset1, int offset2)
Definition: HGCalHistoSeedingImpl.h:77
HGCalHistoSeedingImpl::HistogramT::const_iterator
typename Data::const_iterator const_iterator
Definition: HGCalHistoSeedingImpl.h:27
HGCalHistoSeedingImpl::computeInterpolatedMaxSeeds
std::vector< std::pair< GlobalPoint, double > > computeInterpolatedMaxSeeds(const Histogram &histoClusters)
Definition: HGCalHistoSeedingImpl.cc:326
HGCalHistoSeedingImpl::HistoThresholdC3d
Definition: HGCalHistoSeedingImpl.h:119
fileCollector.seed
seed
Definition: fileCollector.py:127
HGCalHistoSeedingImpl::HistogramT::bins1_
unsigned bins1_
Definition: HGCalHistoSeedingImpl.h:45
testProducerWithPsetDescEmpty_cfi.x1
x1
Definition: testProducerWithPsetDescEmpty_cfi.py:33
HGCalMulticluster.h
HGCalHistoSeedingImpl::HistoInterpolatedMaxC3d
Definition: HGCalHistoSeedingImpl.h:119
HGCalHistoSeedingImpl::Navigator::offset
int offset(int shift)
Definition: HGCalHistoSeedingImpl.h:80
HGCalHistoSeedingImpl::fillSmoothRPhiHistoClusters
Histogram fillSmoothRPhiHistoClusters(const Histogram &histoClusters)
Definition: HGCalHistoSeedingImpl.cc:209
HGCalHistoSeedingImpl::HistogramT::HistogramT
HistogramT(unsigned bins1, unsigned bins2)
Definition: HGCalHistoSeedingImpl.h:31
HGCalTriggerGeometryBase.h
HGCalHistoSeedingImpl::HistogramT
Definition: HGCalHistoSeedingImpl.h:23
HGCalHistoSeedingImpl::SeedingSpace
SeedingSpace
Definition: HGCalHistoSeedingImpl.h:120
HGCalHistoSeedingImpl::Bin
Definition: HGCalHistoSeedingImpl.h:16
HGCalHistoSeedingImpl::HistogramT::kSides_
static constexpr unsigned kSides_
Definition: HGCalHistoSeedingImpl.h:44
HGCalHistoSeedingImpl::HistogramT::HistogramT
HistogramT()
Definition: HGCalHistoSeedingImpl.h:30
HGCalHistoSeedingImpl::seedingSpace_
SeedingSpace seedingSpace_
Definition: HGCalHistoSeedingImpl.h:147
HGCalHistoSeedingImpl::HistogramT::begin
iterator begin()
Definition: HGCalHistoSeedingImpl.h:38
HGCalHistoSeedingImpl::HistogramT::bins_
unsigned bins_
Definition: HGCalHistoSeedingImpl.h:47
HGCalHistoSeedingImpl::neighbour_weights_size_
static constexpr unsigned neighbour_weights_size_
Definition: HGCalHistoSeedingImpl.h:163
HGCalHistoSeedingImpl::Bin::Hcal
Definition: HGCalHistoSeedingImpl.h:17
HGCalHistoSeedingImpl::Navigator
Definition: HGCalHistoSeedingImpl.h:60
Point3DBase< float, GlobalTag >
HGCalHistoSeedingImpl::Bin::Content
Content
Definition: HGCalHistoSeedingImpl.h:17
HGCalHistoSeedingImpl::HistogramT::iterator
typename Data::iterator iterator
Definition: HGCalHistoSeedingImpl.h:26
HGCalHistoSeedingImpl::Navigator::bins_
std::array< int, 2 > bins_
Definition: HGCalHistoSeedingImpl.h:104
HGCalHistoSeedingImpl::Bin::values
std::array< float, 3 > values
Definition: HGCalHistoSeedingImpl.h:18
HGCalHistoSeedingImpl::Histogram
HistogramT< Bin > Histogram
Definition: HGCalHistoSeedingImpl.h:58
edm::ParameterSet
Definition: ParameterSet.h:47
HGCalHistoSeedingImpl::Navigator::AxisType::Bounded
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
HGCalHistoSeedingImpl::fillSmoothHistoClusters
Histogram fillSmoothHistoClusters(const Histogram &, const vector< double > &, Bin::Content)
Definition: HGCalHistoSeedingImpl.cc:120
HGCalHistoSeedingImpl::computeThresholdSeeds
std::vector< std::pair< GlobalPoint, double > > computeThresholdSeeds(const Histogram &histoClusters)
Definition: HGCalHistoSeedingImpl.cc:387
HGCalHistoSeedingImpl::kXYMax_
static constexpr double kXYMax_
Definition: HGCalHistoSeedingImpl.h:167
HGCalHistoSeedingImpl::histoThreshold_
double histoThreshold_
Definition: HGCalHistoSeedingImpl.h:153
HGCalHistoSeedingImpl::nBins1_
unsigned nBins1_
Definition: HGCalHistoSeedingImpl.h:150
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
HGCalHistoSeedingImpl::HistogramT::at
const T & at(int zside, unsigned x1, unsigned x2) const
Definition: HGCalHistoSeedingImpl.h:36
edm::EventSetup
Definition: EventSetup.h:58
HGCalHistoSeedingImpl::fillSmoothPhiHistoClusters
Histogram fillSmoothPhiHistoClusters(const Histogram &histoClusters, const vector< unsigned > &binSums)
Definition: HGCalHistoSeedingImpl.cc:162
HGCalCluster.h
HGCalHistoSeedingImpl::HistogramT::begin
const_iterator begin() const
Definition: HGCalHistoSeedingImpl.h:39
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
HGCalHistoSeedingImpl::setSeedEnergyAndPosition
void setSeedEnergyAndPosition(std::vector< std::pair< GlobalPoint, double >> &seedPositionsEnergy, int z_side, unsigned bin_R, unsigned bin_phi, const Bin &histBin)
Definition: HGCalHistoSeedingImpl.cc:234
edm::Ptr
Definition: AssociationVector.h:31
HGCalHistoSeedingImpl::seedingAlgoType_
std::string seedingAlgoType_
Definition: HGCalHistoSeedingImpl.h:145
HGCalHistoSeedingImpl::seedingPosition_
SeedingPosition seedingPosition_
Definition: HGCalHistoSeedingImpl.h:148
HGCalHistoSeedingImpl::SeedingType
SeedingType
Definition: HGCalHistoSeedingImpl.h:119
HGCalHistoSeedingImpl::HGCalHistoSeedingImpl
HGCalHistoSeedingImpl(const edm::ParameterSet &conf)
Definition: HGCalHistoSeedingImpl.cc:7
edm::shift
static unsigned const int shift
Definition: LuminosityBlockID.cc:7
T
long double T
Definition: Basic3DVectorLD.h:48
Exception
Definition: hltDiff.cc:245
HGCalHistoSeedingImpl::smoothing_hcal_
std::vector< double > smoothing_hcal_
Definition: HGCalHistoSeedingImpl.h:158
HGCalHistoSeedingImpl::Navigator::axis_types_
std::array< AxisType, 2 > axis_types_
Definition: HGCalHistoSeedingImpl.h:103
HGCalHistoSeedingImpl::HistogramT::histogram_
Data histogram_
Definition: HGCalHistoSeedingImpl.h:48
HGCalHistoSeedingImpl::Navigator::Navigator
Navigator(int bins1, AxisType type_axis1, int bins2, AxisType type_axis2)
Definition: HGCalHistoSeedingImpl.h:66
HGCalHistoSeedingImpl::binsSumsHisto_
std::vector< unsigned > binsSumsHisto_
Definition: HGCalHistoSeedingImpl.h:152
HGCalHistoSeedingImpl::computeMaxSeeds
std::vector< std::pair< GlobalPoint, double > > computeMaxSeeds(const Histogram &histoClusters)
Definition: HGCalHistoSeedingImpl.cc:267
HGCalTriggerTools
Definition: HGCalTriggerTools.h:32
HGCalHistoSeedingImpl::Bin::weighted_x
float weighted_x
Definition: HGCalHistoSeedingImpl.h:19
HGCalHistoSeedingImpl::HistoMaxC3d
Definition: HGCalHistoSeedingImpl.h:119
ParameterSet.h
HGCalHistoSeedingImpl::seedingType_
SeedingType seedingType_
Definition: HGCalHistoSeedingImpl.h:146
HGCalHistoSeedingImpl::Navigator::AxisType::Circular
HGCalHistoSeedingImpl::findHistoSeeds
void findHistoSeeds(const std::vector< edm::Ptr< l1t::HGCalCluster >> &clustersPtr, std::vector< std::pair< GlobalPoint, double >> &seedPositionsEnergy)
Definition: HGCalHistoSeedingImpl.cc:518
HGCalHistoSeedingImpl::smoothing_ecal_
std::vector< double > smoothing_ecal_
Definition: HGCalHistoSeedingImpl.h:157
HGCalHistoSeedingImpl::dR
float dR(const l1t::HGCalCluster &clu, const GlobalPoint &seed) const
HGCalHistoSeedingImpl::HistogramT::end
iterator end()
Definition: HGCalHistoSeedingImpl.h:40
HGCalHistoSeedingImpl::HistoSecondaryMaxC3d
Definition: HGCalHistoSeedingImpl.h:119
HGCalHistoSeedingImpl::BinCentre
Definition: HGCalHistoSeedingImpl.h:121