CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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  //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 }
85 
87  const std::vector<l1thgcfirmware::HGCalMulticluster>& multiclusters_in,
88  const std::vector<l1thgcfirmware::HGCalCluster>& rejected_clusters_in,
89  std::vector<l1thgcfirmware::HGCalMulticluster>& multiclusters_out,
90  std::vector<l1thgcfirmware::HGCalCluster>& rejected_clusters_out,
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 }
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
tuple 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
const std::vector< double > & dr_byLayer_coefficientA() const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int iseed
Definition: AMPTWrapper.h:134
const std::vector< double > & dr_byLayer_coefficientB() const