CMS 3D CMS Logo

HGCalHistoClusteringImpl_SA.cc
Go to the documentation of this file.
2 
3 #include <map>
4 #include <cmath>
5 
6 std::vector<l1thgcfirmware::HGCalMulticluster> HGCalHistoClusteringImplSA::clusterSeedMulticluster_SA(
7  const std::vector<l1thgcfirmware::HGCalCluster>& clusters,
8  const std::vector<l1thgcfirmware::HGCalSeed>& seeds,
9  std::vector<l1thgcfirmware::HGCalCluster>& rejected_clusters,
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  for (const auto& energy : targetSeedsEnergy) {
64  double seedWeight = 1;
65  if (mapSeedMulticluster[energy.first].size() == 0) {
66  mapSeedMulticluster[energy.first] = l1thgcfirmware::HGCalMulticluster(clu, 1);
67  } else {
68  mapSeedMulticluster[energy.first].addConstituent(clu, true, seedWeight);
69  }
70  }
71  }
72 
73  multiclustersOut.reserve(mapSeedMulticluster.size());
74  for (const auto& mclu : mapSeedMulticluster)
75  multiclustersOut.emplace_back(mclu.second);
76 
77  return multiclustersOut;
78 }
79 
81  const std::vector<l1thgcfirmware::HGCalMulticluster>& multiclusters_in,
82  const std::vector<l1thgcfirmware::HGCalCluster>& rejected_clusters_in,
83  std::vector<l1thgcfirmware::HGCalMulticluster>& multiclusters_out,
84  std::vector<l1thgcfirmware::HGCalCluster>& rejected_clusters_out,
86  for (const auto& tc : rejected_clusters_in) {
87  rejected_clusters_out.push_back(tc);
88  }
89 
90  for (const auto& multicluster : multiclusters_in) {
91  if (multicluster.sumPt() > configuration.ptC3dThreshold()) {
92  multiclusters_out.push_back(multicluster);
93  } else {
94  for (const auto& tc : multicluster.constituents()) {
95  rejected_clusters_out.push_back(tc);
96  }
97  }
98  }
99 }
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
dictionary configuration
Definition: JetHT_cfg.py:38
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
d
Definition: ztail.py:151
std::vector< l1thgcfirmware::HGCalMulticluster > 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
int iseed
Definition: AMPTWrapper.h:134