CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes
HGCalHistoClusteringImpl Class Reference

#include <HGCalHistoClusteringImpl.h>

Public Member Functions

void clusterizeHisto (const std::vector< edm::Ptr< l1t::HGCalCluster >> &clustersPtr, const std::vector< std::pair< GlobalPoint, double >> &seedPositionsEnergy, const HGCalTriggerGeometryBase &triggerGeometry, l1t::HGCalMulticlusterBxCollection &multiclusters) const
 
float dR (const l1t::HGCalCluster &clu, const GlobalPoint &seed) const
 
void eventSetup (const edm::EventSetup &es)
 
 HGCalHistoClusteringImpl (const edm::ParameterSet &conf)
 

Private Types

enum  ClusterAssociationStrategy { NearestNeighbour, EnergySplit }
 

Private Member Functions

std::vector< l1t::HGCalMulticlusterclusterSeedMulticluster (const std::vector< edm::Ptr< l1t::HGCalCluster >> &clustersPtrs, const std::vector< std::pair< GlobalPoint, double >> &seeds) const
 
void finalizeClusters (std::vector< l1t::HGCalMulticluster > &, l1t::HGCalMulticlusterBxCollection &, const HGCalTriggerGeometryBase &) const
 

Private Attributes

std::string cluster_association_input_
 
ClusterAssociationStrategy cluster_association_strategy_
 
double dr_
 
std::vector< double > dr_byLayer_coefficientA_
 
std::vector< double > dr_byLayer_coefficientB_
 
std::unique_ptr< HGCalTriggerClusterIdentificationBaseid_
 
double ptC3dThreshold_
 
HGCalShowerShape shape_
 
HGCalTriggerTools triggerTools_
 

Static Private Attributes

static double kMidRadius_ = 2.3
 

Detailed Description

Definition at line 14 of file HGCalHistoClusteringImpl.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

HGCalHistoClusteringImpl::HGCalHistoClusteringImpl ( const edm::ParameterSet conf)

Definition at line 6 of file HGCalHistoClusteringImpl.cc.

References cluster_association_input_, cluster_association_strategy_, dr_, EnergySplit, Exception, reco::get(), edm::ParameterSet::getParameter(), id_, NearestNeighbour, and ptC3dThreshold_.

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  if (cluster_association_input_ == "NearestNeighbour") {
18  } else if (cluster_association_input_ == "EnergySplit") {
20  } else {
21  throw cms::Exception("HGCTriggerParameterError")
22  << "Unknown cluster association strategy'" << cluster_association_strategy_;
23  }
24 
25  edm::LogInfo("HGCalMulticlusterParameters")
26  << "Multicluster dR: " << dr_ << "\nMulticluster minimum transverse-momentum: " << ptC3dThreshold_;
27 
28  id_ = std::unique_ptr<HGCalTriggerClusterIdentificationBase>{
29  HGCalTriggerClusterIdentificationFactory::get()->create("HGCalTriggerClusterIdentificationBDT")};
30  id_->initialize(conf.getParameter<edm::ParameterSet>("EGIdentification"));
31 }
T getParameter(std::string const &) const
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:161
std::unique_ptr< HGCalTriggerClusterIdentificationBase > id_
std::vector< double > dr_byLayer_coefficientB_
ClusterAssociationStrategy cluster_association_strategy_
T get(const Candidate &c)
Definition: component.h:55
std::vector< double > dr_byLayer_coefficientA_

Member Function Documentation

void HGCalHistoClusteringImpl::clusterizeHisto ( const std::vector< edm::Ptr< l1t::HGCalCluster >> &  clustersPtr,
const std::vector< std::pair< GlobalPoint, double >> &  seedPositionsEnergy,
const HGCalTriggerGeometryBase triggerGeometry,
l1t::HGCalMulticlusterBxCollection multiclusters 
) const

Definition at line 107 of file HGCalHistoClusteringImpl.cc.

References clusterSeedMulticluster(), and finalizeClusters().

Referenced by eventSetup().

110  {
111  /* clusterize clusters around seeds */
112  std::vector<l1t::HGCalMulticluster> multiclustersTmp = clusterSeedMulticluster(clustersPtrs, seedPositionsEnergy);
113  /* making the collection of multiclusters */
114  finalizeClusters(multiclustersTmp, multiclusters, triggerGeometry);
115 }
void finalizeClusters(std::vector< l1t::HGCalMulticluster > &, l1t::HGCalMulticlusterBxCollection &, const HGCalTriggerGeometryBase &) const
std::vector< l1t::HGCalMulticluster > clusterSeedMulticluster(const std::vector< edm::Ptr< l1t::HGCalCluster >> &clustersPtrs, const std::vector< std::pair< GlobalPoint, double >> &seeds) const
std::vector< l1t::HGCalMulticluster > HGCalHistoClusteringImpl::clusterSeedMulticluster ( const std::vector< edm::Ptr< l1t::HGCalCluster >> &  clustersPtrs,
const std::vector< std::pair< GlobalPoint, double >> &  seeds 
) const
private

Definition at line 39 of file HGCalHistoClusteringImpl.cc.

References funct::abs(), cluster_association_strategy_, edmIntegrityCheck::d, dR(), dr_, dr_byLayer_coefficientA_, dr_byLayer_coefficientB_, EnergySplit, plotBeamSpotDB::first, iseed, kMidRadius_, HGCalTriggerTools::layerWithOffset(), NearestNeighbour, triggerTools_, PV3DBase< T, PVType, FrameType >::z(), and HGCalTriggerTools::zside().

Referenced by clusterizeHisto().

41  {
42  std::map<int, l1t::HGCalMulticluster> mapSeedMulticluster;
43  std::vector<l1t::HGCalMulticluster> multiclustersTmp;
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  continue;
83  //Loop over target seeds and divide up the clusters energy
84  double totalTargetSeedEnergy = 0;
85  for (const auto& energy : targetSeedsEnergy) {
86  totalTargetSeedEnergy += energy.second;
87  }
88 
89  for (const auto& energy : targetSeedsEnergy) {
90  double seedWeight = 1;
92  seedWeight = energy.second / totalTargetSeedEnergy;
93  if (mapSeedMulticluster[energy.first].size() == 0) {
94  mapSeedMulticluster[energy.first] = l1t::HGCalMulticluster(clu, seedWeight);
95  } else {
96  mapSeedMulticluster[energy.first].addConstituent(clu, true, seedWeight);
97  }
98  }
99  }
100 
101  for (const auto& mclu : mapSeedMulticluster)
102  multiclustersTmp.emplace_back(mclu.second);
103 
104  return multiclustersTmp;
105 }
unsigned layerWithOffset(const DetId &) const
int zside(const DetId &) const
T z() const
Definition: PV3DBase.h:64
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< double > dr_byLayer_coefficientB_
float dR(const l1t::HGCalCluster &clu, const GlobalPoint &seed) const
ClusterAssociationStrategy cluster_association_strategy_
int iseed
Definition: AMPTWrapper.h:124
std::vector< double > dr_byLayer_coefficientA_
float HGCalHistoClusteringImpl::dR ( const l1t::HGCalCluster clu,
const GlobalPoint seed 
) const

Definition at line 33 of file HGCalHistoClusteringImpl.cc.

References l1t::HGCalClusterT< C >::centreProj(), mag(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by clusterSeedMulticluster(), and eventSetup().

33  {
34  Basic3DVector<float> seed_3dv(seed);
35  GlobalPoint seed_proj(seed_3dv / seed.z());
36  return (seed_proj - clu.centreProj()).mag();
37 }
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
const GlobalPoint & centreProj() const
T z() const
Definition: PV3DBase.h:64
void HGCalHistoClusteringImpl::eventSetup ( const edm::EventSetup es)
inline

Definition at line 18 of file HGCalHistoClusteringImpl.h.

References clusterizeHisto(), dR(), dr_byLayer_coefficientA_, dr_byLayer_coefficientB_, HGCalShowerShape::eventSetup(), HGCalTriggerTools::eventSetup(), Exception, HGCalTriggerTools::lastLayerBH(), SurveyInfoScenario_cff::seed, shape_, and triggerTools_.

18  {
20  shape_.eventSetup(es);
23  throw cms::Exception("Configuration")
24  << "The per-layer dR values go up to " << (dr_byLayer_coefficientA_.size() - 1) << "(A) and "
25  << (dr_byLayer_coefficientB_.size() - 1) << "(B), while layers go up to " << triggerTools_.lastLayerBH()
26  << "\n";
27  }
28  }
void eventSetup(const edm::EventSetup &es)
void eventSetup(const edm::EventSetup &)
std::vector< double > dr_byLayer_coefficientB_
unsigned lastLayerBH() const
std::vector< double > dr_byLayer_coefficientA_
void HGCalHistoClusteringImpl::finalizeClusters ( std::vector< l1t::HGCalMulticluster > &  multiclusters_in,
l1t::HGCalMulticlusterBxCollection multiclusters_out,
const HGCalTriggerGeometryBase triggerGeometry 
) const
private

Definition at line 117 of file HGCalHistoClusteringImpl.cc.

References HGCalShowerShape::fillShapes(), id_, ptC3dThreshold_, BXVector< T >::push_back(), shape_, and TtFullHadEvtBuilder_cfi::sumPt.

Referenced by clusterizeHisto().

119  {
120  for (auto& multicluster : multiclusters_in) {
121  // compute the eta, phi from its barycenter
122  // + pT as scalar sum of pT of constituents
123  double sumPt = multicluster.sumPt();
124 
125  math::PtEtaPhiMLorentzVector multiclusterP4(sumPt, multicluster.centre().eta(), multicluster.centre().phi(), 0.);
126  multicluster.setP4(multiclusterP4);
127 
128  if (multicluster.pt() > ptC3dThreshold_) {
129  //compute shower shapes
130  shape_.fillShapes(multicluster, triggerGeometry);
131  // fill quality flag
132  multicluster.setHwQual(id_->decision(multicluster));
133  // fill H/E
134  multicluster.saveHOverE();
135 
136  multiclusters_out.push_back(0, multicluster);
137  }
138  }
139 }
std::unique_ptr< HGCalTriggerClusterIdentificationBase > id_
PtEtaPhiMLorentzVectorD PtEtaPhiMLorentzVector
Lorentz vector with cartesian internal representation.
Definition: LorentzVector.h:25
void fillShapes(l1t::HGCalMulticluster &, const HGCalTriggerGeometryBase &) const
void push_back(int bx, T object)

Member Data Documentation

std::string HGCalHistoClusteringImpl::cluster_association_input_
private

Definition at line 53 of file HGCalHistoClusteringImpl.h.

Referenced by HGCalHistoClusteringImpl().

ClusterAssociationStrategy HGCalHistoClusteringImpl::cluster_association_strategy_
private

Definition at line 54 of file HGCalHistoClusteringImpl.h.

Referenced by clusterSeedMulticluster(), and HGCalHistoClusteringImpl().

double HGCalHistoClusteringImpl::dr_
private

Definition at line 48 of file HGCalHistoClusteringImpl.h.

Referenced by clusterSeedMulticluster(), and HGCalHistoClusteringImpl().

std::vector<double> HGCalHistoClusteringImpl::dr_byLayer_coefficientA_
private

Definition at line 49 of file HGCalHistoClusteringImpl.h.

Referenced by clusterSeedMulticluster(), and eventSetup().

std::vector<double> HGCalHistoClusteringImpl::dr_byLayer_coefficientB_
private

Definition at line 50 of file HGCalHistoClusteringImpl.h.

Referenced by clusterSeedMulticluster(), and eventSetup().

std::unique_ptr<HGCalTriggerClusterIdentificationBase> HGCalHistoClusteringImpl::id_
private

Definition at line 58 of file HGCalHistoClusteringImpl.h.

Referenced by finalizeClusters(), and HGCalHistoClusteringImpl().

double HGCalHistoClusteringImpl::kMidRadius_ = 2.3
staticprivate

Definition at line 60 of file HGCalHistoClusteringImpl.h.

Referenced by clusterSeedMulticluster().

double HGCalHistoClusteringImpl::ptC3dThreshold_
private

Definition at line 51 of file HGCalHistoClusteringImpl.h.

Referenced by finalizeClusters(), and HGCalHistoClusteringImpl().

HGCalShowerShape HGCalHistoClusteringImpl::shape_
private

Definition at line 56 of file HGCalHistoClusteringImpl.h.

Referenced by eventSetup(), and finalizeClusters().

HGCalTriggerTools HGCalHistoClusteringImpl::triggerTools_
private

Definition at line 57 of file HGCalHistoClusteringImpl.h.

Referenced by clusterSeedMulticluster(), and eventSetup().