CMS 3D CMS Logo

PFClusterFromHGCalMultiCluster.cc
Go to the documentation of this file.
3 
5 
7 
10 }
11 
14  const std::vector<bool>& rechitMask, const std::vector<bool>& seedable,
16 
17  const auto& hgcalMultiClusters = *clusterH_;
18  auto const& hits = *input;
19 
20  // for quick indexing back to hit energy
21  std::unordered_map<uint32_t, size_t> detIdToIndex(hits.size());
22  for (uint32_t i = 0; i < hits.size(); ++i) {
23  detIdToIndex[hits[i].detId()] = i;
24  }
25 
26  for (const auto& mcl : hgcalMultiClusters) {
27  DetId seed;
28  double energy = 0.0, highest_energy = 0.0;
29  output.emplace_back();
30  reco::PFCluster& back = output.back();
31  for (const auto& cl : mcl) {
32  const auto& hitsAndFractions = cl->hitsAndFractions();
33  for (const auto& hAndF : hitsAndFractions) {
34  auto itr = detIdToIndex.find(hAndF.first);
35  if (itr == detIdToIndex.end()) {
36  continue; // hit wasn't saved in reco
37  }
38  auto ref = makeRefhit(input, itr->second);
39  assert(ref->detId() == hAndF.first.rawId());
40  const double hit_energy = hAndF.second * ref->energy();
41  energy += hit_energy;
42  back.addRecHitFraction(reco::PFRecHitFraction(ref, hAndF.second));
43  // TODO: the following logic to identify the seed of a cluster
44  // could be appropriate for the Run2 Ecal Calorimetric
45  // detector, but could be wrong for the HGCal one. This has to
46  // be reviewd.
47  if (hit_energy > highest_energy || highest_energy == 0.0) {
48  highest_energy = hit_energy;
49  seed = ref->detId();
50  }
51  } // end of hitsAndFractions
52  } // end of loop over clusters (2D/layer)
53  if (energy <= 1) {
54  output.pop_back();
55  continue;
56  }
57  if (!back.hitsAndFractions().empty()) {
58  back.setSeed(seed);
59  back.setEnergy(energy);
60  back.setCorrectedEnergy(energy);
61  } else {
62  back.setSeed(0);
63  back.setEnergy(0.f);
64  }
65  } // end of loop over hgcalMulticlusters (3D)
66 }
void buildClusters(const edm::Handle< reco::PFRecHitCollection > &, const std::vector< bool > &, const std::vector< bool > &, reco::PFClusterCollection &) override
Particle flow cluster, see clustering algorithm in PFClusterAlgo.
Definition: PFCluster.h:47
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
Fraction of a PFRecHit (rechits can be shared between several PFCluster&#39;s)
void setEnergy(double energy)
Definition: CaloCluster.h:113
const std::vector< std::pair< DetId, float > > & hitsAndFractions() const
Definition: CaloCluster.h:197
bool ev
static std::string const input
Definition: EdmProvDump.cc:44
void setSeed(const DetId &id)
Definition: CaloCluster.h:123
reco::PFRecHitRef makeRefhit(const edm::Handle< reco::PFRecHitCollection > &h, const unsigned i) const
void setCorrectedEnergy(double cenergy)
Definition: CaloCluster.h:114
double f[11][100]
Definition: DetId.h:18
edm::Handle< std::vector< reco::HGCalMultiCluster > > clusterH_
void addRecHitFraction(const reco::PFRecHitFraction &frac)
add a given fraction of the rechit
Definition: PFCluster.cc:99
edm::EDGetTokenT< std::vector< reco::HGCalMultiCluster > > clusterToken_
std::vector< PFCluster > PFClusterCollection
collection of PFCluster objects
Definition: PFClusterFwd.h:9
void updateEvent(const edm::Event &) final