CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
MuPFIsoHelper.cc
Go to the documentation of this file.
2 
3 MuPFIsoHelper::MuPFIsoHelper(const std::map<std::string, edm::ParameterSet>& labelMap, edm::ConsumesCollector&& iC)
4  : labelMap_(labelMap) {
6  for (std::map<std::string, edm::ParameterSet>::const_iterator i = labelMap_.begin(); i != labelMap_.end(); ++i) {
7  chargedParticle_.push_back(nullHandle);
8  chargedHadron_.push_back(nullHandle);
9  neutralHadron_.push_back(nullHandle);
10  neutralHadronHighThreshold_.push_back(nullHandle);
11  photon_.push_back(nullHandle);
12  photonHighThreshold_.push_back(nullHandle);
13  pu_.push_back(nullHandle);
14 
15  chargedParticleToken_.push_back(
16  iC.consumes<CandDoubleMap>(i->second.getParameter<edm::InputTag>("chargedParticle")));
17  chargedHadronToken_.push_back(iC.consumes<CandDoubleMap>(i->second.getParameter<edm::InputTag>("chargedHadron")));
18  neutralHadronToken_.push_back(iC.consumes<CandDoubleMap>(i->second.getParameter<edm::InputTag>("neutralHadron")));
20  iC.consumes<CandDoubleMap>(i->second.getParameter<edm::InputTag>("neutralHadronHighThreshold")));
21  photonToken_.push_back(iC.consumes<CandDoubleMap>(i->second.getParameter<edm::InputTag>("photon")));
22  photonHighThresholdToken_.push_back(
23  iC.consumes<CandDoubleMap>(i->second.getParameter<edm::InputTag>("photonHighThreshold")));
24  puToken_.push_back(iC.consumes<CandDoubleMap>(i->second.getParameter<edm::InputTag>("pu")));
25  }
26 }
27 
29 
31  const edm::Handle<CandDoubleMap>& chargedParticle,
32  const edm::Handle<CandDoubleMap>& chargedHadron,
33  const edm::Handle<CandDoubleMap>& neutralHadron,
34  const edm::Handle<CandDoubleMap>& neutralHadronHighThreshold,
35  const edm::Handle<CandDoubleMap>& photon,
36  const edm::Handle<CandDoubleMap>& photonHighThreshold,
37  const edm::Handle<CandDoubleMap>& pu) {
39  if (chargedParticle.isValid())
40  iso.sumChargedParticlePt = (*chargedParticle)[muonRef];
41 
42  if (chargedHadron.isValid())
43  iso.sumChargedHadronPt = (*chargedHadron)[muonRef];
44 
45  if (neutralHadron.isValid())
46  iso.sumNeutralHadronEt = (*neutralHadron)[muonRef];
47 
48  if (neutralHadronHighThreshold.isValid())
49  iso.sumNeutralHadronEtHighThreshold = (*neutralHadronHighThreshold)[muonRef];
50 
51  if (photon.isValid())
52  iso.sumPhotonEt = (*photon)[muonRef];
53 
54  if (photonHighThreshold.isValid())
55  iso.sumPhotonEtHighThreshold = (*photonHighThreshold)[muonRef];
56 
57  if (pu.isValid())
58  iso.sumPUPt = (*pu)[muonRef];
59 
60  return iso;
61 }
62 
64  unsigned int count = 0;
65  for (std::map<std::string, edm::ParameterSet>::const_iterator i = labelMap_.begin(); i != labelMap_.end(); ++i) {
67  chargedParticle_[count],
68  chargedHadron_[count],
69  neutralHadron_[count],
71  photon_[count],
72  photonHighThreshold_[count],
73  pu_[count]);
74 
75  muon.setPFIsolation(i->first, iso);
76  count++;
77  }
78 
79  return 0;
80 }
81 
83  unsigned int count = 0;
84  for (std::map<std::string, edm::ParameterSet>::const_iterator i = labelMap_.begin(); i != labelMap_.end(); ++i) {
85  iEvent.getByToken(chargedParticleToken_[count], chargedParticle_[count]);
86  iEvent.getByToken(chargedHadronToken_[count], chargedHadron_[count]);
87  iEvent.getByToken(neutralHadronToken_[count], neutralHadron_[count]);
89  iEvent.getByToken(photonToken_[count], photon_[count]);
91  iEvent.getByToken(puToken_[count], pu_[count]);
92  count++;
93  }
94 }
std::vector< edm::EDGetTokenT< CandDoubleMap > > neutralHadronHighThresholdToken_
Definition: MuPFIsoHelper.h:59
std::vector< edm::EDGetTokenT< CandDoubleMap > > chargedHadronToken_
Definition: MuPFIsoHelper.h:57
std::vector< edm::Handle< CandDoubleMap > > chargedHadron_
Definition: MuPFIsoHelper.h:49
float sumNeutralHadronEtHighThreshold
sum pt of neutral hadrons with a higher threshold
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
std::vector< edm::EDGetTokenT< CandDoubleMap > > photonHighThresholdToken_
Definition: MuPFIsoHelper.h:61
float sumPhotonEt
sum pt of PF photons
reco::MuonPFIsolation makeIsoDeposit(reco::MuonRef &, const edm::Handle< CandDoubleMap > &, const edm::Handle< CandDoubleMap > &, const edm::Handle< CandDoubleMap > &, const edm::Handle< CandDoubleMap > &, const edm::Handle< CandDoubleMap > &, const edm::Handle< CandDoubleMap > &, const edm::Handle< CandDoubleMap > &)
std::vector< edm::Handle< CandDoubleMap > > pu_
Definition: MuPFIsoHelper.h:54
std::vector< edm::EDGetTokenT< CandDoubleMap > > neutralHadronToken_
Definition: MuPFIsoHelper.h:58
float sumNeutralHadronEt
sum pt of neutral hadrons
float sumChargedParticlePt
sum-pt of charged Particles(inludes e/mu)
std::vector< edm::Handle< CandDoubleMap > > neutralHadronHighThreshold_
Definition: MuPFIsoHelper.h:51
float sumPUPt
sum pt of charged Particles not from PV (for Pu corrections)
int iEvent
Definition: GenABIO.cc:224
std::map< std::string, edm::ParameterSet > labelMap_
Definition: MuPFIsoHelper.h:46
void setPFIsolation(const std::string &label, const reco::MuonPFIsolation &deposit)
std::vector< edm::EDGetTokenT< CandDoubleMap > > chargedParticleToken_
Definition: MuPFIsoHelper.h:56
bool isValid() const
Definition: HandleBase.h:70
std::vector< edm::Handle< CandDoubleMap > > chargedParticle_
Definition: MuPFIsoHelper.h:48
std::vector< edm::Handle< CandDoubleMap > > photon_
Definition: MuPFIsoHelper.h:52
std::vector< edm::Handle< CandDoubleMap > > neutralHadron_
Definition: MuPFIsoHelper.h:50
int embedPFIsolation(reco::Muon &, reco::MuonRef &)
std::vector< edm::EDGetTokenT< CandDoubleMap > > puToken_
Definition: MuPFIsoHelper.h:62
std::vector< edm::Handle< CandDoubleMap > > photonHighThreshold_
Definition: MuPFIsoHelper.h:53
void beginEvent(const edm::Event &iEvent)
float sumPhotonEtHighThreshold
sum pt of PF photons with a higher threshold
std::vector< edm::EDGetTokenT< CandDoubleMap > > photonToken_
Definition: MuPFIsoHelper.h:60
MuPFIsoHelper(const std::map< std::string, edm::ParameterSet > &, edm::ConsumesCollector &&)
Definition: MuPFIsoHelper.cc:3
float sumChargedHadronPt
sum-pt of charged Hadron