CMS 3D CMS Logo

PFClusterFromHGCalMultiCluster.cc
Go to the documentation of this file.
3 
5 
7 
9  ev.getByToken(clusterToken_, clusterH_);
10  ev.getByToken(tracksterToken_, trackstersH_);
11 }
12 
14  const std::vector<bool>& rechitMask,
15  const std::vector<bool>& seedable,
17  const auto& hgcalMultiClusters = *clusterH_;
18  auto const& hits = *input;
19 
20  const auto& tracksters = *trackstersH_;
21 
22  // for quick indexing back to hit energy
23  std::unordered_map<uint32_t, size_t> detIdToIndex(hits.size());
24  for (uint32_t i = 0; i < hits.size(); ++i) {
25  detIdToIndex[hits[i].detId()] = i;
26  }
27 
28  int iMultiClus = -1;
29  for (const auto& mcl : hgcalMultiClusters) {
30  iMultiClus++;
31  // Skip empty multiclusters
32  if (mcl.hitsAndFractions().empty()) {
33  continue;
34  }
35  // Filter using trackster PID
37  float probTotal = 0.0f;
38  for (int cat : filter_on_categories_) {
39  probTotal += tracksters[iMultiClus].id_probabilities(cat);
40  }
41  if (probTotal < pid_threshold_) {
42  continue;
43  }
44  }
45 
46  DetId seed;
47  double energy = 0.0, highest_energy = 0.0;
48  output.emplace_back();
49  reco::PFCluster& back = output.back();
50  const auto& hitsAndFractions_mcl = mcl.hitsAndFractions();
51 
52  std::vector<std::pair<DetId, float> > hitsAndFractions;
53  hitsAndFractions.insert(hitsAndFractions.end(), hitsAndFractions_mcl.begin(), hitsAndFractions_mcl.end());
54 
55  // Use the H&F of the clusters inside the multicluster if the latter's H&F are not stored
56  if (hitsAndFractions.empty()) {
57  for (const auto& cl : mcl) {
58  const auto& hAndF_temp = cl->hitsAndFractions();
59  hitsAndFractions.insert(hitsAndFractions.end(), hAndF_temp.begin(), hAndF_temp.end());
60  }
61  }
62 
63  for (const auto& hAndF : hitsAndFractions) {
64  auto itr = detIdToIndex.find(hAndF.first);
65  if (itr == detIdToIndex.end()) {
66  continue; // hit wasn't saved in reco
67  }
68  auto ref = makeRefhit(input, itr->second);
69  assert(ref->detId() == hAndF.first.rawId());
70  const double hit_energy = hAndF.second * ref->energy();
71  energy += hit_energy;
72  back.addRecHitFraction(reco::PFRecHitFraction(ref, hAndF.second));
73  // TODO: the following logic to identify the seed of a cluster
74  // could be appropriate for the Run2 Ecal Calorimetric
75  // detector, but could be wrong for the HGCal one. This has to
76  // be reviewd.
77  if (hit_energy > highest_energy || highest_energy == 0.0) {
78  highest_energy = hit_energy;
79  seed = ref->detId();
80  }
81  } // end of hitsAndFractions
82 
83  if (!back.hitsAndFractions().empty()) {
84  back.setSeed(seed);
85  back.setEnergy(energy);
87  } else {
88  back.setSeed(0);
89  back.setEnergy(0.f);
90  }
91  } // end of loop over hgcalMulticlusters (3D)
92 }
PFClusterFromHGCalMultiCluster::updateEvent
void updateEvent(const edm::Event &) final
Definition: PFClusterFromHGCalMultiCluster.cc:8
reco::PFClusterCollection
std::vector< PFCluster > PFClusterCollection
collection of PFCluster objects
Definition: PFClusterFwd.h:9
reco::CaloCluster::setSeed
void setSeed(const DetId &id)
Definition: CaloCluster.h:146
mps_fire.i
i
Definition: mps_fire.py:428
input
static const std::string input
Definition: EdmProvDump.cc:48
MessageLogger.h
hfClusterShapes_cfi.hits
hits
Definition: hfClusterShapes_cfi.py:5
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
reco::PFRecHitFraction
Fraction of a PFRecHit (rechits can be shared between several PFCluster's)
Definition: PFRecHitFraction.h:18
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:72
reco::CaloCluster::setCorrectedEnergy
void setCorrectedEnergy(double cenergy)
Definition: CaloCluster.h:137
eostools.cat
def cat(path)
Definition: eostools.py:401
PFClusterFromHGCalMultiCluster::pid_threshold_
float pid_threshold_
Definition: PFClusterFromHGCalMultiCluster.h:35
PFClusterFromHGCalMultiCluster.h
cms::cuda::assert
assert(be >=bs)
edm::Handle< reco::PFRecHitCollection >
InitialClusteringStepBase::makeRefhit
reco::PFRecHitRef makeRefhit(const edm::Handle< reco::PFRecHitCollection > &h, const unsigned i) const
Definition: InitialClusteringStepBase.h:103
fileCollector.seed
seed
Definition: fileCollector.py:127
GetRecoTauVFromDQM_MC_cff.cl
cl
Definition: GetRecoTauVFromDQM_MC_cff.py:38
DetId
Definition: DetId.h:17
HCALHighEnergyHPDFilter_cfi.energy
energy
Definition: HCALHighEnergyHPDFilter_cfi.py:5
Event.h
reco::CaloCluster::hitsAndFractions
const std::vector< std::pair< DetId, float > > & hitsAndFractions() const
Definition: CaloCluster.h:210
PFClusterFromHGCalMultiCluster::trackstersH_
edm::Handle< std::vector< ticl::Trackster > > trackstersH_
Definition: PFClusterFromHGCalMultiCluster.h:42
PFClusterFromHGCalMultiCluster::filter_on_categories_
std::vector< int > filter_on_categories_
Definition: PFClusterFromHGCalMultiCluster.h:36
PFClusterFromHGCalMultiCluster::buildClusters
void buildClusters(const edm::Handle< reco::PFRecHitCollection > &, const std::vector< bool > &, const std::vector< bool > &, reco::PFClusterCollection &) override
Definition: PFClusterFromHGCalMultiCluster.cc:13
PFClusterFromHGCalMultiCluster::clusterToken_
edm::EDGetTokenT< std::vector< reco::HGCalMultiCluster > > clusterToken_
Definition: PFClusterFromHGCalMultiCluster.h:38
reco::PFCluster::addRecHitFraction
void addRecHitFraction(const reco::PFRecHitFraction &frac)
add a given fraction of the rechit
Definition: PFCluster.cc:33
reco::CaloCluster::setEnergy
void setEnergy(double energy)
Definition: CaloCluster.h:136
HGCalDetId.h
ev
bool ev
Definition: Hydjet2Hadronizer.cc:95
reco::PFCluster
Particle flow cluster, see clustering algorithm in PFClusterAlgo.
Definition: PFCluster.h:42
PFClusterFromHGCalMultiCluster::clusterH_
edm::Handle< std::vector< reco::HGCalMultiCluster > > clusterH_
Definition: PFClusterFromHGCalMultiCluster.h:39
PFClusterFromHGCalMultiCluster::tracksterToken_
edm::EDGetTokenT< std::vector< ticl::Trackster > > tracksterToken_
Definition: PFClusterFromHGCalMultiCluster.h:41
edm::Event
Definition: Event.h:73
PFClusterFromHGCalMultiCluster::filterByTracksterPID_
bool filterByTracksterPID_
Definition: PFClusterFromHGCalMultiCluster.h:34