CMS 3D CMS Logo

GsfEleDeltaBetaIsoCut.cc
Go to the documentation of this file.
6 
7 
9 public:
11 
12  result_type operator()(const reco::GsfElectronPtr&) const final;
13 
15  void getEventContent(const edm::EventBase&) final;
16 
17  double value(const reco::CandidatePtr& cand) const final;
18 
19  CandidateType candidateType() const final {
20  return ELECTRON;
21  }
22 
23 private:
28 };
29 
32  "GsfEleDeltaBetaIsoCut");
33 
36  _isoCutEBLowPt(c.getParameter<double>("isoCutEBLowPt")),
37  _isoCutEBHighPt(c.getParameter<double>("isoCutEBHighPt")),
38  _isoCutEELowPt(c.getParameter<double>("isoCutEELowPt")),
39  _isoCutEEHighPt(c.getParameter<double>("isoCutEEHighPt")),
40  _deltaBetaConstant(c.getParameter<double>("deltaBetaConstant")),
41  _ptCutOff(c.getParameter<double>("ptCutOff")),
42  _barrelCutOff(c.getParameter<double>("barrelCutOff")),
43  _relativeIso(c.getParameter<bool>("isRelativeIso")) {
44  edm::InputTag chadtag = c.getParameter<edm::InputTag>("chargedHadronIsoDR03Src");
45  edm::InputTag nhadtag = c.getParameter<edm::InputTag>("neutralHadronIsoDR03Src");
46  edm::InputTag phtag = c.getParameter<edm::InputTag>("photonIsoDR03Src");
47  edm::InputTag PUchadtag = c.getParameter<edm::InputTag>("puChargedHadronIsoDR03Src");
48  contentTags_.emplace("chad",chadtag);
49  contentTags_.emplace("nhad",nhadtag);
50  contentTags_.emplace("pho",phtag);
51  contentTags_.emplace("puchad",PUchadtag);
52 }
53 
55  auto chad =
57  contentTokens_.emplace("chad",chad);
58  auto nhad =
60  contentTokens_.emplace("nhad",nhad);
61  auto pho =
63  contentTokens_.emplace("pho",pho);
64  auto puchad =
66  contentTokens_.emplace("puchad",puchad);
67 }
68 
70  ev.getByLabel(contentTags_["chad"],_chad_iso);
71  ev.getByLabel(contentTags_["nhad"],_nhad_iso);
72  ev.getByLabel(contentTags_["pho"],_ph_iso);
73  ev.getByLabel(contentTags_["puchad"],_PUchad_iso);
74 }
75 
79  const float isoCut =
80  ( cand->p4().pt() < _ptCutOff ?
81  ( std::abs(cand->superCluster()->position().eta()) < _barrelCutOff ?
83  ( std::abs(cand->superCluster()->position().eta()) < _barrelCutOff ?
86  cand->pfIsolationVariables();
87 
88  float chad_val = 0.0;
89  float nhad_val = 0.0;
90  float pho_val = 0.0;
91  float puchad_val = 0.0;
92 
93  if( _chad_iso.isValid() && _chad_iso->contains( cand.id() ) &&
94  _nhad_iso.isValid() && _nhad_iso->contains( cand.id() ) &&
95  _ph_iso.isValid() && _ph_iso->contains( cand.id() ) &&
96  _PUchad_iso.isValid() && _PUchad_iso->contains( cand.id() ) ) {
97  chad_val = (*_chad_iso)[cand];
98  nhad_val = (*_nhad_iso)[cand];
99  pho_val = (*_ph_iso)[cand];
100  puchad_val = (*_PUchad_iso)[cand];
101  } else if ( _chad_iso.isValid() && _chad_iso->idSize() == 1 &&
102  _nhad_iso.isValid() && _nhad_iso->idSize() == 1 &&
103  _ph_iso.isValid() && _ph_iso->idSize() == 1 &&
104  _PUchad_iso.isValid() && _PUchad_iso->idSize() == 1 &&
105  cand.id() == edm::ProductID() ) {
106  // in case we have spoofed a ptr
107  //note this must be a 1:1 valuemap (only one product input)
108  chad_val = _chad_iso->begin()[cand.key()];
109  nhad_val = _nhad_iso->begin()[cand.key()];
110  pho_val = _ph_iso->begin()[cand.key()];
111  puchad_val = _PUchad_iso->begin()[cand.key()];
112  } else if ( _chad_iso.isValid() && _nhad_iso.isValid() &&
113  _ph_iso.isValid() && _PUchad_iso.isValid() ){ // throw an exception
114  chad_val = (*_chad_iso)[cand];
115  nhad_val = (*_nhad_iso)[cand];
116  pho_val = (*_ph_iso)[cand];
117  puchad_val = (*_PUchad_iso)[cand];
118  }
119 
120  const float chad = _chad_iso.isValid() ? chad_val : pfIso.sumChargedHadronPt;
121  const float nhad = _nhad_iso.isValid() ? nhad_val : pfIso.sumNeutralHadronEt;
122  const float pho = _ph_iso.isValid() ? pho_val : pfIso.sumPhotonEt;
123  const float puchad = _PUchad_iso.isValid() ? puchad_val : pfIso.sumPUPt;
124  float iso = chad + std::max(0.0f, nhad + pho - _deltaBetaConstant*puchad);
125  if( _relativeIso ) iso /= cand->p4().pt();
126  return iso < isoCut;
127 }
128 
130  edm::Ptr<reco::GsfElectron> ele(cand);
132  ele->pfIsolationVariables();
133  float chad_val = 0.0;
134  float nhad_val = 0.0;
135  float pho_val = 0.0;
136  float puchad_val = 0.0;
137 
138  if( _chad_iso.isValid() && _chad_iso->contains( cand.id() ) &&
139  _nhad_iso.isValid() && _nhad_iso->contains( cand.id() ) &&
140  _ph_iso.isValid() && _ph_iso->contains( cand.id() ) &&
141  _PUchad_iso.isValid() && _PUchad_iso->contains( cand.id() ) ) {
142  chad_val = (*_chad_iso)[cand];
143  nhad_val = (*_nhad_iso)[cand];
144  pho_val = (*_ph_iso)[cand];
145  puchad_val = (*_PUchad_iso)[cand];
146  } else if ( _chad_iso.isValid() && _chad_iso->idSize() == 1 &&
147  _nhad_iso.isValid() && _nhad_iso->idSize() == 1 &&
148  _ph_iso.isValid() && _ph_iso->idSize() == 1 &&
149  _PUchad_iso.isValid() && _PUchad_iso->idSize() == 1 &&
150  cand.id() == edm::ProductID() ) {
151  // in case we have spoofed a ptr
152  //note this must be a 1:1 valuemap (only one product input)
153  chad_val = _chad_iso->begin()[cand.key()];
154  nhad_val = _nhad_iso->begin()[cand.key()];
155  pho_val = _ph_iso->begin()[cand.key()];
156  puchad_val = _PUchad_iso->begin()[cand.key()];
157  } else if ( _chad_iso.isValid() && _nhad_iso.isValid() &&
158  _ph_iso.isValid() && _PUchad_iso.isValid() ){ // throw an exception
159  chad_val = (*_chad_iso)[cand];
160  nhad_val = (*_nhad_iso)[cand];
161  pho_val = (*_ph_iso)[cand];
162  puchad_val = (*_PUchad_iso)[cand];
163  }
164 
165  const float chad = _chad_iso.isValid() ? chad_val : pfIso.sumChargedHadronPt;
166  const float nhad = _nhad_iso.isValid() ? nhad_val : pfIso.sumNeutralHadronEt;
167  const float pho = _ph_iso.isValid() ? pho_val : pfIso.sumPhotonEt;
168  const float puchad = _PUchad_iso.isValid() ? puchad_val : pfIso.sumPUPt;
169  float iso = chad + std::max(0.0f, nhad + pho - _deltaBetaConstant*puchad);
170  if( _relativeIso ) iso /= cand->p4().pt();
171  return iso;
172 }
edm::Handle< edm::ValueMap< float > > _nhad_iso
const PflowIsolationVariables & pfIsolationVariables() const
Definition: GsfElectron.h:687
CandidateType candidateType() const final
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
edm::Handle< edm::ValueMap< float > > _chad_iso
edm::Handle< edm::ValueMap< float > > _ph_iso
const LorentzVector & p4(P4Kind kind) const
Definition: GsfElectron.cc:228
key_type key() const
Definition: Ptr.h:185
std::unordered_map< std::string, edm::EDGetToken > contentTokens_
float sumPUPt
sum pt of charged Particles not from PV (for Pu corrections)
Definition: GsfElectron.h:646
bool ev
std::unordered_map< std::string, edm::InputTag > contentTags_
bool contains(ProductID id) const
Definition: ValueMap.h:155
float sumPhotonEt
sum pt of PF photons // old float photonIso ;
Definition: GsfElectron.h:641
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double f[11][100]
void setConsumes(edm::ConsumesCollector &) final
float sumNeutralHadronEt
sum pt of neutral hadrons // old float neutralHadronIso ;
Definition: GsfElectron.h:640
bool isValid() const
Definition: HandleBase.h:74
size_t idSize() const
Definition: ValueMap.h:159
edm::Handle< edm::ValueMap< float > > _PUchad_iso
const_iterator begin() const
Definition: ValueMap.h:208
ProductID id() const
Accessor for product ID.
Definition: Ptr.h:180
void getEventContent(const edm::EventBase &) final
bool getByLabel(InputTag const &, Handle< T > &) const
Definition: EventBase.h:92
result_type operator()(const reco::GsfElectronPtr &) const final
SuperClusterRef superCluster() const override
reference to a SuperCluster
Definition: GsfElectron.h:185
#define DEFINE_EDM_PLUGIN(factory, type, name)
GsfEleDeltaBetaIsoCut(const edm::ParameterSet &c)
double value(const reco::CandidatePtr &cand) const final
float sumChargedHadronPt
sum-pt of charged Hadron // old float chargedHadronIso ;
Definition: GsfElectron.h:639