CMS 3D CMS Logo

List of all members | Public Member Functions
HGCalHistoClusteringImplSA Class Reference

#include <HGCalHistoClusteringImpl_SA.h>

Public Member Functions

std::vector< l1thgcfirmware::HGCalMulticlusterclusterSeedMulticluster_SA (const std::vector< l1thgcfirmware::HGCalCluster > &clusters, const std::vector< l1thgcfirmware::HGCalSeed > &seeds, std::vector< l1thgcfirmware::HGCalCluster > &rejected_clusters, const l1thgcfirmware::ClusterAlgoConfig &configuration) const
 
void finalizeClusters_SA (const std::vector< l1thgcfirmware::HGCalMulticluster > &, const std::vector< l1thgcfirmware::HGCalCluster > &, std::vector< l1thgcfirmware::HGCalMulticluster > &, std::vector< l1thgcfirmware::HGCalCluster > &, const l1thgcfirmware::ClusterAlgoConfig &configuration) const
 
 HGCalHistoClusteringImplSA ()=default
 
void runAlgorithm () const
 
 ~HGCalHistoClusteringImplSA ()=default
 

Detailed Description

Definition at line 13 of file HGCalHistoClusteringImpl_SA.h.

Constructor & Destructor Documentation

◆ HGCalHistoClusteringImplSA()

HGCalHistoClusteringImplSA::HGCalHistoClusteringImplSA ( )
default

◆ ~HGCalHistoClusteringImplSA()

HGCalHistoClusteringImplSA::~HGCalHistoClusteringImplSA ( )
default

Member Function Documentation

◆ clusterSeedMulticluster_SA()

std::vector< l1thgcfirmware::HGCalMulticluster > HGCalHistoClusteringImplSA::clusterSeedMulticluster_SA ( const std::vector< l1thgcfirmware::HGCalCluster > &  clusters,
const std::vector< l1thgcfirmware::HGCalSeed > &  seeds,
std::vector< l1thgcfirmware::HGCalCluster > &  rejected_clusters,
const l1thgcfirmware::ClusterAlgoConfig configuration 
) const

Definition at line 6 of file HGCalHistoClusteringImpl_SA.cc.

References funct::abs(), bsc_activity_cfg::clusters, JetHT_cfg::configuration, ztail::d, HCALHighEnergyHPDFilter_cfi::energy, iseed, fileCollector::seed, and DetachedQuadStep_cff::seeds.

Referenced by HGCalHistoClusteringWrapper::clusterizeHisto().

10  {
11  std::map<int, l1thgcfirmware::HGCalMulticluster> mapSeedMulticluster;
12  std::vector<l1thgcfirmware::HGCalMulticluster> multiclustersOut;
13 
14  for (const auto& clu : clusters) {
15  int z_side = clu.zside();
16 
17  double radiusCoefficientA = configuration.dr_byLayer_coefficientA().empty()
18  ? configuration.dr()
19  : configuration.dr_byLayer_coefficientA()[clu.layer()];
20  double radiusCoefficientB =
21  configuration.dr_byLayer_coefficientB().empty() ? 0 : configuration.dr_byLayer_coefficientB()[clu.layer()];
22 
23  double minDistSqrd = radiusCoefficientA + radiusCoefficientB * (configuration.midRadius() - std::abs(clu.eta()));
24  minDistSqrd *= minDistSqrd;
25 
26  std::vector<std::pair<int, double>> targetSeedsEnergy;
27 
28  unsigned int iseed = 0;
29  for (const auto& seed : seeds) {
30  if (z_side * seed.z() < 0) {
31  ++iseed;
32  continue;
33  }
34 
35  double seedEnergy = seed.energy();
36 
37  double d = (clu.x() - seed.x()) * (clu.x() - seed.x()) + (clu.y() - seed.y()) * (clu.y() - seed.y());
38 
39  if (d < minDistSqrd) {
40  // NearestNeighbour
41  minDistSqrd = d;
42 
43  if (targetSeedsEnergy.empty()) {
44  targetSeedsEnergy.emplace_back(iseed, seedEnergy);
45  } else {
46  targetSeedsEnergy.at(0).first = iseed;
47  targetSeedsEnergy.at(0).second = seedEnergy;
48  }
49  }
50  ++iseed;
51  }
52 
53  if (targetSeedsEnergy.empty()) {
54  rejected_clusters.emplace_back(clu);
55  continue;
56  }
57 
58  // N.B. as I have only implemented NearestNeighbour option
59  // then targetSeedsEnergy has at most 1 seed for this cluster
60  // Leaving in some redundant functionality in case we need
61  // EnergySplit option
62 
63  //Loop over target seeds and divide up the clusters energy
64  double totalTargetSeedEnergy = 0;
65  for (const auto& energy : targetSeedsEnergy) {
66  totalTargetSeedEnergy += energy.second;
67  }
68 
69  for (const auto& energy : targetSeedsEnergy) {
70  double seedWeight = 1;
71  if (mapSeedMulticluster[energy.first].size() == 0) {
72  mapSeedMulticluster[energy.first] = l1thgcfirmware::HGCalMulticluster(clu, 1);
73  } else {
74  mapSeedMulticluster[energy.first].addConstituent(clu, true, seedWeight);
75  }
76  }
77  }
78 
79  multiclustersOut.reserve(mapSeedMulticluster.size());
80  for (const auto& mclu : mapSeedMulticluster)
81  multiclustersOut.emplace_back(mclu.second);
82 
83  return multiclustersOut;
84 }
dictionary configuration
Definition: JetHT_cfg.py:37
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
d
Definition: ztail.py:151
int iseed
Definition: AMPTWrapper.h:134

◆ finalizeClusters_SA()

void HGCalHistoClusteringImplSA::finalizeClusters_SA ( const std::vector< l1thgcfirmware::HGCalMulticluster > &  multiclusters_in,
const std::vector< l1thgcfirmware::HGCalCluster > &  rejected_clusters_in,
std::vector< l1thgcfirmware::HGCalMulticluster > &  multiclusters_out,
std::vector< l1thgcfirmware::HGCalCluster > &  rejected_clusters_out,
const l1thgcfirmware::ClusterAlgoConfig configuration 
) const

Definition at line 86 of file HGCalHistoClusteringImpl_SA.cc.

References JetHT_cfg::configuration.

Referenced by HGCalHistoClusteringWrapper::clusterizeHisto().

91  {
92  for (const auto& tc : rejected_clusters_in) {
93  rejected_clusters_out.push_back(tc);
94  }
95 
96  for (const auto& multicluster : multiclusters_in) {
97  if (multicluster.sumPt() > configuration.ptC3dThreshold()) {
98  multiclusters_out.push_back(multicluster);
99  } else {
100  for (const auto& tc : multicluster.constituents()) {
101  rejected_clusters_out.push_back(tc);
102  }
103  }
104  }
105 }
dictionary configuration
Definition: JetHT_cfg.py:37

◆ runAlgorithm()

void HGCalHistoClusteringImplSA::runAlgorithm ( ) const