CMS 3D CMS Logo

HGCalHistoClusteringImpl.cc
Go to the documentation of this file.
5 
7  : dr_(conf.getParameter<double>("dR_multicluster")),
8  dr_byLayer_coefficientA_(conf.existsAs<std::vector<double>>("dR_multicluster_byLayer_coefficientA")
9  ? conf.getParameter<std::vector<double>>("dR_multicluster_byLayer_coefficientA")
10  : std::vector<double>()),
11  dr_byLayer_coefficientB_(conf.existsAs<std::vector<double>>("dR_multicluster_byLayer_coefficientB")
12  ? conf.getParameter<std::vector<double>>("dR_multicluster_byLayer_coefficientB")
13  : std::vector<double>()),
14  ptC3dThreshold_(conf.getParameter<double>("minPt_multicluster")),
15  cluster_association_input_(conf.getParameter<string>("cluster_association")),
16  shape_(conf) {
17  if (cluster_association_input_ == "NearestNeighbour") {
19  } else if (cluster_association_input_ == "EnergySplit") {
21  } else {
22  throw cms::Exception("HGCTriggerParameterError")
23  << "Unknown cluster association strategy'" << cluster_association_strategy_;
24  }
25 
26  edm::LogInfo("HGCalMulticlusterParameters")
27  << "Multicluster dR: " << dr_ << "\nMulticluster minimum transverse-momentum: " << ptC3dThreshold_;
28 
29  id_ = std::unique_ptr<HGCalTriggerClusterIdentificationBase>{
30  HGCalTriggerClusterIdentificationFactory::get()->create("HGCalTriggerClusterIdentificationBDT")};
31  id_->initialize(conf.getParameter<edm::ParameterSet>("EGIdentification"));
32 }
33 
35  return (seed - clu.centreProj()).mag();
36 }
37 
38 std::vector<l1t::HGCalMulticluster> HGCalHistoClusteringImpl::clusterSeedMulticluster(
39  const std::vector<edm::Ptr<l1t::HGCalCluster>>& clustersPtrs,
40  const std::vector<std::pair<GlobalPoint, double>>& seeds,
41  std::vector<l1t::HGCalCluster>& rejected_clusters) const {
42  std::map<int, l1t::HGCalMulticluster> mapSeedMulticluster;
43  std::vector<l1t::HGCalMulticluster> multiclustersOut;
44 
45  for (const auto& clu : clustersPtrs) {
46  int z_side = triggerTools_.zside(clu->detId());
47 
48  double radiusCoefficientA =
50  double radiusCoefficientB =
52 
53  double minDist = radiusCoefficientA + radiusCoefficientB * (kMidRadius_ - std::abs(clu->eta()));
54 
55  std::vector<pair<int, double>> targetSeedsEnergy;
56 
57  for (unsigned int iseed = 0; iseed < seeds.size(); iseed++) {
58  GlobalPoint seedPosition = seeds[iseed].first;
59  double seedEnergy = seeds[iseed].second;
60 
61  if (z_side * seedPosition.z() < 0)
62  continue;
63  double d = this->dR(*clu, seeds[iseed].first);
64 
65  if (d < minDist) {
67  targetSeedsEnergy.emplace_back(iseed, seedEnergy);
69  minDist = d;
70 
71  if (targetSeedsEnergy.empty()) {
72  targetSeedsEnergy.emplace_back(iseed, seedEnergy);
73  } else {
74  targetSeedsEnergy.at(0).first = iseed;
75  targetSeedsEnergy.at(0).second = seedEnergy;
76  }
77  }
78  }
79  }
80 
81  if (targetSeedsEnergy.empty()) {
82  rejected_clusters.emplace_back(*clu);
83  continue;
84  }
85  //Loop over target seeds and divide up the clusters energy
86  double totalTargetSeedEnergy = 0;
87  for (const auto& energy : targetSeedsEnergy) {
88  totalTargetSeedEnergy += energy.second;
89  }
90 
91  for (const auto& energy : targetSeedsEnergy) {
92  double seedWeight = 1;
94  seedWeight = energy.second / totalTargetSeedEnergy;
95  if (mapSeedMulticluster[energy.first].size() == 0) {
96  mapSeedMulticluster[energy.first] = l1t::HGCalMulticluster(clu, seedWeight);
97  } else {
98  mapSeedMulticluster[energy.first].addConstituent(clu, true, seedWeight);
99  }
100  }
101  }
102 
103  multiclustersOut.reserve(mapSeedMulticluster.size());
104  for (const auto& mclu : mapSeedMulticluster)
105  multiclustersOut.emplace_back(mclu.second);
106 
107  return multiclustersOut;
108 }
109 
111  const std::vector<std::pair<GlobalPoint, double>>& seedPositionsEnergy,
112  const HGCalTriggerGeometryBase& triggerGeometry,
113  l1t::HGCalMulticlusterBxCollection& multiclusters,
114  l1t::HGCalClusterBxCollection& rejected_clusters) const {
115  /* clusterize clusters around seeds */
116  std::vector<l1t::HGCalCluster> rejected_clusters_vec;
117  std::vector<l1t::HGCalMulticluster> multiclusters_vec =
118  clusterSeedMulticluster(clustersPtrs, seedPositionsEnergy, rejected_clusters_vec);
119  /* making the collection of multiclusters */
120  finalizeClusters(multiclusters_vec, rejected_clusters_vec, multiclusters, rejected_clusters, triggerGeometry);
121 }
122 
123 void HGCalHistoClusteringImpl::finalizeClusters(std::vector<l1t::HGCalMulticluster>& multiclusters_in,
124  const std::vector<l1t::HGCalCluster>& rejected_clusters_in,
125  l1t::HGCalMulticlusterBxCollection& multiclusters_out,
126  l1t::HGCalClusterBxCollection& rejected_clusters_out,
127  const HGCalTriggerGeometryBase& triggerGeometry) const {
128  for (const auto& tc : rejected_clusters_in) {
129  rejected_clusters_out.push_back(0, tc);
130  }
131 
132  for (auto& multicluster : multiclusters_in) {
133  // compute the eta, phi from its barycenter
134  // + pT as scalar sum of pT of constituents
135  double sumPt = multicluster.sumPt();
136 
137  math::PtEtaPhiMLorentzVector multiclusterP4(sumPt, multicluster.centre().eta(), multicluster.centre().phi(), 0.);
138  multicluster.setP4(multiclusterP4);
139 
140  if (multicluster.pt() > ptC3dThreshold_) {
141  //compute shower shapes
142  shape_.fillShapes(multicluster, triggerGeometry);
143  // fill quality flag
144  multicluster.setHwQual(id_->decision(multicluster));
145  // fill H/E
146  multicluster.saveHOverE();
147 
148  multiclusters_out.push_back(0, multicluster);
149  } else {
150  for (const auto& tc : multicluster.constituents()) {
151  rejected_clusters_out.push_back(0, *(tc.second));
152  }
153  }
154  }
155 }
HGCalTriggerGeometryBase
Definition: HGCalTriggerGeometryBase.h:19
HGCalShowerShape::fillShapes
void fillShapes(l1t::HGCalMulticluster &, const HGCalTriggerGeometryBase &) const
Definition: HGCalShowerShape.cc:515
l1t::HGCalCluster
Definition: HGCalCluster.h:11
HGCalHistoClusteringImpl::kMidRadius_
static constexpr double kMidRadius_
Definition: HGCalHistoClusteringImpl.h:64
HGCalHistoClusteringImpl::dR
float dR(const l1t::HGCalCluster &clu, const GlobalPoint &seed) const
Definition: HGCalHistoClusteringImpl.cc:34
HGCalHistoClusteringImpl.h
HGCalHistoClusteringImpl::cluster_association_input_
std::string cluster_association_input_
Definition: HGCalHistoClusteringImpl.h:57
HGCalHistoClusteringImpl::HGCalHistoClusteringImpl
HGCalHistoClusteringImpl(const edm::ParameterSet &conf)
Definition: HGCalHistoClusteringImpl.cc:6
deltaPhi.h
HGCalHistoClusteringImpl::finalizeClusters
void finalizeClusters(std::vector< l1t::HGCalMulticluster > &, const std::vector< l1t::HGCalCluster > &, l1t::HGCalMulticlusterBxCollection &, l1t::HGCalClusterBxCollection &, const HGCalTriggerGeometryBase &) const
Definition: HGCalHistoClusteringImpl.cc:123
HGCalHistoClusteringImpl::clusterSeedMulticluster
std::vector< l1t::HGCalMulticluster > clusterSeedMulticluster(const std::vector< edm::Ptr< l1t::HGCalCluster >> &clustersPtrs, const std::vector< std::pair< GlobalPoint, double >> &seeds, std::vector< l1t::HGCalCluster > &rejected_clusters) const
Definition: HGCalHistoClusteringImpl.cc:38
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
dqmdumpme.first
first
Definition: dqmdumpme.py:55
HGCalShowerShape.h
TtFullHadEvtBuilder_cfi.sumPt
sumPt
Definition: TtFullHadEvtBuilder_cfi.py:38
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
HGCalHistoClusteringImpl::triggerTools_
HGCalTriggerTools triggerTools_
Definition: HGCalHistoClusteringImpl.h:61
fileCollector.seed
seed
Definition: fileCollector.py:127
BXVector
Definition: BXVector.h:15
l1t::HGCalMulticluster
Definition: HGCalMulticluster.h:13
HGCalHistoClusteringImpl::dr_byLayer_coefficientA_
std::vector< double > dr_byLayer_coefficientA_
Definition: HGCalHistoClusteringImpl.h:53
HGCalHistoClusteringImpl::ptC3dThreshold_
double ptC3dThreshold_
Definition: HGCalHistoClusteringImpl.h:55
HGCalHistoClusteringImpl::dr_
double dr_
Definition: HGCalHistoClusteringImpl.h:52
HCALHighEnergyHPDFilter_cfi.energy
energy
Definition: HCALHighEnergyHPDFilter_cfi.py:5
HGCalTriggerTools::layerWithOffset
unsigned layerWithOffset(const DetId &) const
Definition: HGCalTriggerTools.cc:134
HGCalTriggerTools::zside
int zside(const DetId &) const
Definition: HGCalTriggerTools.cc:210
Point3DBase< float, GlobalTag >
HGCalHistoClusteringImpl::EnergySplit
Definition: HGCalHistoClusteringImpl.h:39
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
InitialStep_cff.seeds
seeds
Definition: InitialStep_cff.py:230
edm::ParameterSet
Definition: ParameterSet.h:47
iseed
int iseed
Definition: AMPTWrapper.h:134
deltaR.h
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
HGCalHistoClusteringImpl::id_
std::unique_ptr< HGCalTriggerClusterIdentificationBase > id_
Definition: HGCalHistoClusteringImpl.h:62
get
#define get
HGCalHistoClusteringImpl::clusterizeHisto
void clusterizeHisto(const std::vector< edm::Ptr< l1t::HGCalCluster >> &clustersPtr, const std::vector< std::pair< GlobalPoint, double >> &seedPositionsEnergy, const HGCalTriggerGeometryBase &triggerGeometry, l1t::HGCalMulticlusterBxCollection &multiclusters, l1t::HGCalClusterBxCollection &rejected_clusters) const
Definition: HGCalHistoClusteringImpl.cc:110
edm::Ptr
Definition: AssociationVector.h:31
HGCalHistoClusteringImpl::dr_byLayer_coefficientB_
std::vector< double > dr_byLayer_coefficientB_
Definition: HGCalHistoClusteringImpl.h:54
HGCalHistoClusteringImpl::cluster_association_strategy_
ClusterAssociationStrategy cluster_association_strategy_
Definition: HGCalHistoClusteringImpl.h:58
mag
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
Definition: Basic3DVectorLD.h:127
std
Definition: JetResolutionObject.h:76
Exception
Definition: hltDiff.cc:246
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
HGCalHistoClusteringImpl::shape_
HGCalShowerShape shape_
Definition: HGCalHistoClusteringImpl.h:60
l1t::HGCalClusterT::centreProj
const GlobalPoint & centreProj() const
Definition: HGCalClusterT.h:102
ztail.d
d
Definition: ztail.py:151
math::PtEtaPhiMLorentzVector
PtEtaPhiMLorentzVectorD PtEtaPhiMLorentzVector
Lorentz vector with cartesian internal representation.
Definition: LorentzVector.h:25
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
HGCalHistoClusteringImpl::NearestNeighbour
Definition: HGCalHistoClusteringImpl.h:39
BXVector::push_back
void push_back(int bx, T object)