CMS 3D CMS Logo

HGCalHistoClusteringWrapper.cc
Go to the documentation of this file.
2 
5 
8 
12 
14 
17 
19 public:
22 
23  void configure(
24  const std::pair<const HGCalTriggerGeometryBase* const, const edm::ParameterSet&>& configuration) override;
25 
26  void process(const std::pair<const std::vector<edm::Ptr<l1t::HGCalCluster>>,
27  const std::vector<std::pair<GlobalPoint, double>>>& inputClustersAndSeeds,
28  std::pair<l1t::HGCalMulticlusterBxCollection&, l1t::HGCalClusterBxCollection&>&
29  outputMulticlustersAndRejectedClusters) const override;
30 
31 private:
34  const std::vector<std::pair<GlobalPoint, double>>& seeds,
37  const l1thgcfirmware::HGCalClusterSACollection& rejected_clusters_out,
38  const std::vector<edm::Ptr<l1t::HGCalCluster>>& clustersPtrs,
40  l1t::HGCalClusterBxCollection& rejected_clusters) const;
41 
43  const l1thgcfirmware::HGCalSeedSACollection& inputSeeds,
45  l1thgcfirmware::HGCalClusterSACollection& outputRejectedClusters) const;
46 
48 
50 
52 
54 
55  static constexpr double kMidRadius_ = 2.3;
56 };
57 
60  theAlgo_(),
61  theConfiguration_(kMidRadius_,
62  conf.getParameter<double>("dR_multicluster"),
63  conf.existsAs<std::vector<double>>("dR_multicluster_byLayer_coefficientA")
64  ? conf.getParameter<std::vector<double>>("dR_multicluster_byLayer_coefficientA")
65  : std::vector<double>(),
66  conf.existsAs<std::vector<double>>("dR_multicluster_byLayer_coefficientB")
67  ? conf.getParameter<std::vector<double>>("dR_multicluster_byLayer_coefficientB")
68  : std::vector<double>(),
69  conf.getParameter<double>("minPt_multicluster")) {}
70 
72  std::vector<l1thgcfirmware::HGCalCluster>& clusters_SA,
73  const std::vector<std::pair<GlobalPoint, double>>& seeds,
74  std::vector<l1thgcfirmware::HGCalSeed>& seeds_SA) const {
75  clusters_SA.clear();
76  clusters_SA.reserve(clustersPtrs.size());
77  unsigned int clusterIndex = 0;
78  for (const auto& cluster : clustersPtrs) {
79  clusters_SA.emplace_back(cluster->centreProj().x(),
80  cluster->centreProj().y(),
81  cluster->centre().z(),
82  triggerTools_.zside(cluster->detId()),
83  triggerTools_.layerWithOffset(cluster->detId()),
84  cluster->eta(),
85  cluster->phi(),
86  cluster->pt(),
87  cluster->mipPt(),
88  clusterIndex);
89  ++clusterIndex;
90  }
91 
92  seeds_SA.clear();
93  seeds_SA.reserve(seeds.size());
94  for (const auto& seed : seeds) {
95  seeds_SA.emplace_back(seed.first.x(), seed.first.y(), seed.first.z(), seed.second);
96  }
97 }
98 
100  const std::vector<l1thgcfirmware::HGCalMulticluster>& multiclusters_out,
101  const std::vector<l1thgcfirmware::HGCalCluster>& rejected_clusters_out,
102  const std::vector<edm::Ptr<l1t::HGCalCluster>>& clustersPtrs,
103  l1t::HGCalMulticlusterBxCollection& multiclustersBXCollection,
104  l1t::HGCalClusterBxCollection& rejected_clusters) const {
105  // Not doing completely the correct thing here
106  // Taking the multiclusters from the stand alone emulation
107  // Getting their consistuent clusters (stand alone objects)
108  // Linking back to the original CMSSW-type cluster
109  // And creating a CMSSW-type multicluster based from these clusters
110  // So the output multiclusters will not be storing bit accurate quantities (or whatever was derived by the stand along emulation)
111  // As these inherit from L1Candidate, could set their HW quantities to the bit accurate ones
112  for (const auto& rejected_cluster : rejected_clusters_out) {
113  rejected_clusters.push_back(0, *clustersPtrs.at(rejected_cluster.index_cmssw()));
114  }
115 
116  std::vector<l1t::HGCalMulticluster> multiclusters;
117  multiclusters.reserve(multiclusters_out.size());
118  for (unsigned int imulticluster = 0; imulticluster < multiclusters_out.size(); ++imulticluster) {
119  bool firstConstituent = true;
120  for (const auto& constituent : multiclusters_out[imulticluster].constituents()) {
121  if (firstConstituent) {
122  multiclusters.emplace_back(clustersPtrs.at(constituent.index_cmssw()), 1.);
123  } else {
124  multiclusters.at(imulticluster).addConstituent(clustersPtrs.at(constituent.index_cmssw()), 1.);
125  }
126  firstConstituent = false;
127  }
128  }
129 
130  for (const auto& multicluster : multiclusters) {
131  multiclustersBXCollection.push_back(0, multicluster);
132  }
133 }
134 
136  const std::pair<const std::vector<edm::Ptr<l1t::HGCalCluster>>, const std::vector<std::pair<GlobalPoint, double>>>&
137  inputClustersAndSeeds,
138  std::pair<l1t::HGCalMulticlusterBxCollection&, l1t::HGCalClusterBxCollection&>&
139  outputMulticlustersAndRejectedClusters) const {
142  convertCMSSWInputs(inputClustersAndSeeds.first, clusters_SA, inputClustersAndSeeds.second, seeds_SA);
143 
144  l1thgcfirmware::HGCalClusterSACollection rejected_clusters_finalized_SA;
145  l1thgcfirmware::HGCalMulticlusterSACollection multiclusters_finalized_SA;
146  clusterizeHisto(clusters_SA, seeds_SA, multiclusters_finalized_SA, rejected_clusters_finalized_SA);
147 
148  convertAlgorithmOutputs(multiclusters_finalized_SA,
149  rejected_clusters_finalized_SA,
150  inputClustersAndSeeds.first,
151  outputMulticlustersAndRejectedClusters.first,
152  outputMulticlustersAndRejectedClusters.second);
153 }
154 
157  const l1thgcfirmware::HGCalSeedSACollection& inputSeeds,
159  l1thgcfirmware::HGCalClusterSACollection& outputRejectedClusters) const {
160  // Call SA clustering
161  std::vector<l1thgcfirmware::HGCalCluster> rejected_clusters_vec_SA;
162  std::vector<l1thgcfirmware::HGCalMulticluster> multiclusters_vec_SA =
163  theAlgo_.clusterSeedMulticluster_SA(inputClusters, inputSeeds, rejected_clusters_vec_SA, theConfiguration_);
164 
166  multiclusters_vec_SA, rejected_clusters_vec_SA, outputMulticlusters, outputRejectedClusters, theConfiguration_);
167 }
168 
170  const std::pair<const HGCalTriggerGeometryBase* const, const edm::ParameterSet&>& configuration) {
171  setGeometry(configuration.first);
172 
173  // theConfiguration_.setParameters( ... );
174 
175  if ((!theConfiguration_.dr_byLayer_coefficientA().empty() &&
179  throw cms::Exception("Configuration")
180  << "The per-layer dR values go up to " << (theConfiguration_.dr_byLayer_coefficientA().size() - 1) << "(A) and "
181  << (theConfiguration_.dr_byLayer_coefficientB().size() - 1) << "(B), while layers go up to "
182  << triggerTools_.lastLayerBH() << "\n";
183  }
184 };
185 
std::vector< HGCalCluster > HGCalClusterSACollection
HGCalHistoClusteringImplSA theAlgo_
void convertAlgorithmOutputs(const l1thgcfirmware::HGCalMulticlusterSACollection &multiclusters_out, const l1thgcfirmware::HGCalClusterSACollection &rejected_clusters_out, const std::vector< edm::Ptr< l1t::HGCalCluster >> &clustersPtrs, l1t::HGCalMulticlusterBxCollection &multiclusters, l1t::HGCalClusterBxCollection &rejected_clusters) const
void setGeometry(const HGCalTriggerGeometryBase *const geom)
void process(const std::pair< const std::vector< edm::Ptr< l1t::HGCalCluster >>, const std::vector< std::pair< GlobalPoint, double >>> &inputClustersAndSeeds, std::pair< l1t::HGCalMulticlusterBxCollection &, l1t::HGCalClusterBxCollection &> &outputMulticlustersAndRejectedClusters) const override
void convertCMSSWInputs(const std::vector< edm::Ptr< l1t::HGCalCluster >> &clustersPtrs, l1thgcfirmware::HGCalClusterSACollection &clusters_SA, const std::vector< std::pair< GlobalPoint, double >> &seeds, l1thgcfirmware::HGCalSeedSACollection &seeds_SA) const
const std::vector< double > & dr_byLayer_coefficientA() const
std::vector< HGCalSeed > HGCalSeedSACollection
Definition: HGCalSeed_SA.h:24
void setGeometry(const HGCalTriggerGeometryBase *const)
int zside(const DetId &) 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
const std::vector< double > & dr_byLayer_coefficientB() const
dictionary configuration
Definition: JetHT_cfg.py:37
void configure(const std::pair< const HGCalTriggerGeometryBase *const, const edm::ParameterSet &> &configuration) override
unsigned lastLayerBH() const
unsigned layerWithOffset(const DetId &) const
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
l1thgcfirmware::ClusterAlgoConfig theConfiguration_
#define DEFINE_EDM_PLUGIN(factory, type, name)
HGCalHistoClusteringWrapper(const edm::ParameterSet &conf)
void clusterizeHisto(const l1thgcfirmware::HGCalClusterSACollection &inputClusters, const l1thgcfirmware::HGCalSeedSACollection &inputSeeds, l1thgcfirmware::HGCalMulticlusterSACollection &outputMulticlusters, l1thgcfirmware::HGCalClusterSACollection &outputRejectedClusters) const
std::vector< HGCalMulticluster > HGCalMulticlusterSACollection
void push_back(int bx, T object)