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 
30  for (const auto& mcl : hgcalMultiClusters) {
31  iMultiClus++;
32 
33  // Skip empty multiclusters
34  if (mcl.hitsAndFractions().empty()) {
35  continue;
36  }
37 
38  // Filter using trackster PID
40  float probTotal = 0.0f;
41 
42  for (int cat : filter_on_categories_) {
43  probTotal += tracksters[iMultiClus].id_probabilities(cat);
44  }
45 
46  if (probTotal < pid_threshold_) {
47  continue;
48  }
49  }
50 
51  DetId seed;
52  double energy = 0.0, highest_energy = 0.0;
53  output.emplace_back();
54  reco::PFCluster& back = output.back();
55  const auto& hitsAndFractions_mcl = mcl.hitsAndFractions();
56 
57  std::vector<std::pair<DetId, float> > hitsAndFractions;
58  hitsAndFractions.insert(hitsAndFractions.end(), hitsAndFractions_mcl.begin(), hitsAndFractions_mcl.end());
59 
60  // Use the H&F of the clusters inside the multicluster if the latter's H&F are not stored
61  if (hitsAndFractions.empty()) {
62  for (const auto& cl : mcl) {
63  const auto& hAndF_temp = cl->hitsAndFractions();
64  hitsAndFractions.insert(hitsAndFractions.end(), hAndF_temp.begin(), hAndF_temp.end());
65  }
66  }
67 
68  for (const auto& hAndF : hitsAndFractions) {
69  auto itr = detIdToIndex.find(hAndF.first);
70  if (itr == detIdToIndex.end()) {
71  continue; // hit wasn't saved in reco
72  }
73  auto ref = makeRefhit(input, itr->second);
74  assert(ref->detId() == hAndF.first.rawId());
75  const double hit_energy = hAndF.second * ref->energy();
76  energy += hit_energy;
77  back.addRecHitFraction(reco::PFRecHitFraction(ref, hAndF.second));
78  // TODO: the following logic to identify the seed of a cluster
79  // could be appropriate for the Run2 Ecal Calorimetric
80  // detector, but could be wrong for the HGCal one. This has to
81  // be reviewd.
82  if (hit_energy > highest_energy || highest_energy == 0.0) {
83  highest_energy = hit_energy;
84  seed = ref->detId();
85  }
86  } // end of hitsAndFractions
87 
88  if (!back.hitsAndFractions().empty()) {
89  back.setSeed(seed);
90  back.setEnergy(energy);
92  } else {
93  back.setSeed(0);
94  back.setEnergy(0.f);
95  }
96  } // end of loop over hgcalMulticlusters (3D)
97 }
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:355
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:32
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
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
itr
std::vector< std::pair< float, float > >::iterator itr
Definition: HGCDigitizer.cc:28
reco::PFCluster::addRecHitFraction
void addRecHitFraction(const reco::PFRecHitFraction &frac)
add a given fraction of the rechit
Definition: PFCluster.cc:77
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:46
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
SurveyInfoScenario_cff.seed
seed
Definition: SurveyInfoScenario_cff.py:295