CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes | Static Private Attributes
PhoAnyPFIsoWithEACut Class Reference
Inheritance diagram for PhoAnyPFIsoWithEACut:
CutApplicatorWithEventContentBase CutApplicatorBase candidate_functions::CandidateCut

Public Member Functions

CandidateType candidateType () const final
 
void getEventContent (const edm::EventBase &) final
 
result_type operator() (const reco::PhotonPtr &) const final
 
 PhoAnyPFIsoWithEACut (const edm::ParameterSet &c)
 
void setConsumes (edm::ConsumesCollector &) final
 
double value (const reco::CandidatePtr &cand) const final
 
- Public Member Functions inherited from CutApplicatorWithEventContentBase
 CutApplicatorWithEventContentBase ()
 
 CutApplicatorWithEventContentBase (const CutApplicatorWithEventContentBase &)=delete
 
 CutApplicatorWithEventContentBase (const edm::ParameterSet &c)
 
CutApplicatorWithEventContentBaseoperator= (const CutApplicatorWithEventContentBase &)=delete
 
 ~CutApplicatorWithEventContentBase () override
 Destructor. More...
 
- Public Member Functions inherited from CutApplicatorBase
virtual result_type asCandidate (const argument_type &) const
 
 CutApplicatorBase ()
 
 CutApplicatorBase (const CutApplicatorBase &)=delete
 
 CutApplicatorBase (const edm::ParameterSet &c)
 
const std::string & name () const override
 
result_type operator() (const argument_type &) const final
 
virtual result_type operator() (const pat::ElectronPtr &) const
 
virtual result_type operator() (const pat::MuonPtr &) const
 
virtual result_type operator() (const reco::GsfElectronPtr &) const
 
virtual result_type operator() (const reco::MuonPtr &) const
 
CutApplicatorBaseoperator= (const CutApplicatorBase &)=delete
 
 ~CutApplicatorBase () override
 Destructor. More...
 
- Public Member Functions inherited from candidate_functions::CandidateCut
 CandidateCut ()
 
virtual ~CandidateCut ()
 

Private Attributes

edm::Handle< edm::ValueMap< float > > _anyPFIsoMap
 
float _barrelCutOff
 
float _C1_EB
 
float _C1_EE
 
float _C2_EB
 
float _C2_EE
 
EffectiveAreas _effectiveAreas
 
edm::Handle< double > _rhoHandle
 
bool _useRelativeIso
 

Static Private Attributes

constexpr static char anyPFIsoWithEA_ [] = "anyPFIsoWithEA"
 
constexpr static char rhoString_ [] = "rho"
 

Additional Inherited Members

- Public Types inherited from CutApplicatorBase
enum  CandidateType {
  NONE, ELECTRON, MUON, PHOTON,
  TAU, PATELECTRON, PATMUON, PATPHOTON,
  PATTAU
}
 
- Public Types inherited from candidate_functions::CandidateCut
using argument_type = reco::CandidatePtr
 
using result_type = bool
 
- Protected Attributes inherited from CutApplicatorWithEventContentBase
std::unordered_map< std::string, edm::InputTagcontentTags_
 
std::unordered_map< std::string, edm::EDGetTokencontentTokens_
 

Detailed Description

Definition at line 5 of file PhoAnyPFIsoWithEACut.cc.

Constructor & Destructor Documentation

◆ PhoAnyPFIsoWithEACut()

PhoAnyPFIsoWithEACut::PhoAnyPFIsoWithEACut ( const edm::ParameterSet c)

Definition at line 43 of file PhoAnyPFIsoWithEACut.cc.

45  _C1_EB(c.getParameter<double>("C1_EB")),
46  _C2_EB(c.getParameter<double>("C2_EB")),
47  _C1_EE(c.getParameter<double>("C1_EE")),
48  _C2_EE(c.getParameter<double>("C2_EE")),
49  _barrelCutOff(c.getParameter<double>("barrelCutOff")),
50  _useRelativeIso(c.getParameter<bool>("useRelativeIso")),
51  _effectiveAreas((c.getParameter<edm::FileInPath>("effAreasConfigFile")).fullPath()) {
52  edm::InputTag maptag = c.getParameter<edm::InputTag>("anyPFIsoMap");
53  contentTags_.emplace(anyPFIsoWithEA_, maptag);
54 
55  edm::InputTag rhoTag = c.getParameter<edm::InputTag>("rho");
56  contentTags_.emplace(rhoString_, rhoTag);
57 }

References anyPFIsoWithEA_, HltBtagPostValidation_cff::c, CutApplicatorWithEventContentBase::contentTags_, rhoString_, and HLT_2018_cff::rhoTag.

Member Function Documentation

◆ candidateType()

CandidateType PhoAnyPFIsoWithEACut::candidateType ( ) const
inlinefinalvirtual

Reimplemented from CutApplicatorBase.

Definition at line 16 of file PhoAnyPFIsoWithEACut.cc.

16 { return PHOTON; }

References CutApplicatorBase::PHOTON.

◆ getEventContent()

void PhoAnyPFIsoWithEACut::getEventContent ( const edm::EventBase ev)
finalvirtual

◆ operator()()

CutApplicatorBase::result_type PhoAnyPFIsoWithEACut::operator() ( const reco::PhotonPtr cand) const
finalvirtual

Reimplemented from CutApplicatorBase.

Definition at line 72 of file PhoAnyPFIsoWithEACut.cc.

72  {
73  // in case we are by-value
74  const std::string& inst_name = contentTags_.find(anyPFIsoWithEA_)->second.instance();
76  float anyisoval = -1.0;
77  if (_anyPFIsoMap.isValid() && _anyPFIsoMap->contains(cand.id())) {
78  anyisoval = (*_anyPFIsoMap)[cand];
79  } else if (_anyPFIsoMap.isValid() && _anyPFIsoMap->idSize() == 1 && cand.id() == edm::ProductID()) {
80  // in case we have spoofed a ptr
81  //note this must be a 1:1 valuemap (only one product input)
82  anyisoval = _anyPFIsoMap->begin()[cand.key()];
83  } else if (_anyPFIsoMap.isValid()) { // throw an exception
84  anyisoval = (*_anyPFIsoMap)[cand];
85  }
86 
87  // Figure out the cut value
88  // The value is generally pt-dependent: C1 + pt * C2
89  const double absEta = std::abs(cand->superCluster()->eta());
90  const float anyPFIsoWithEACutValue =
91  (absEta < _barrelCutOff ? _C1_EB + cand->pt() * _C2_EB : _C1_EE + cand->pt() * _C2_EE);
92 
93  // Retrieve the variable value for this particle
94  float anyPFIso = _anyPFIsoMap.isValid() ? anyisoval : pat->userFloat(inst_name);
95 
96  // Apply pile-up correction
97  const double eA = _effectiveAreas.getEffectiveArea(absEta);
98  const double rho = _rhoHandle.isValid() ? *_rhoHandle : 0;
99  const float anyPFIsoWithEA = std::max(0.0, anyPFIso - rho * eA);
100 
101  // Apply the cut and return the result
102  // Scale by pT if the relative isolation is requested but avoid division by 0
103  return anyPFIsoWithEA < anyPFIsoWithEACutValue * (_useRelativeIso ? cand->pt() : 1.);
104 }

References _anyPFIsoMap, _barrelCutOff, _C1_EB, _C1_EE, _C2_EB, _C2_EE, _effectiveAreas, _rhoHandle, _useRelativeIso, funct::abs(), anyPFIsoWithEA_, edm::ValueMap< T >::begin(), edm::ValueMap< T >::contains(), CutApplicatorWithEventContentBase::contentTags_, EffectiveAreas::getEffectiveArea(), edm::ValueMap< T >::idSize(), edm::HandleBase::isValid(), SiStripPI::max, rho, and AlCaHLTBitMon_QueryRunRegistry::string.

◆ setConsumes()

void PhoAnyPFIsoWithEACut::setConsumes ( edm::ConsumesCollector cc)
finalvirtual

Implements CutApplicatorWithEventContentBase.

Definition at line 59 of file PhoAnyPFIsoWithEACut.cc.

59  {
60  auto anyPFIsoWithEA = cc.consumes<edm::ValueMap<float> >(contentTags_[anyPFIsoWithEA_]);
61  contentTokens_.emplace(anyPFIsoWithEA_, anyPFIsoWithEA);
62 
63  auto rho = cc.consumes<double>(contentTags_[rhoString_]);
64  contentTokens_.emplace(rhoString_, rho);
65 }

References anyPFIsoWithEA_, CutApplicatorWithEventContentBase::contentTags_, CutApplicatorWithEventContentBase::contentTokens_, rho, and rhoString_.

◆ value()

double PhoAnyPFIsoWithEACut::value ( const reco::CandidatePtr cand) const
finalvirtual

Implements candidate_functions::CandidateCut.

Definition at line 106 of file PhoAnyPFIsoWithEACut.cc.

106  {
107  reco::PhotonPtr pho(cand);
108 
109  // in case we are by-value
110  const std::string& inst_name = contentTags_.find(anyPFIsoWithEA_)->second.instance();
112  float anyisoval = -1.0;
113  if (_anyPFIsoMap.isValid() && _anyPFIsoMap->contains(cand.id())) {
114  anyisoval = (*_anyPFIsoMap)[cand];
115  } else if (_anyPFIsoMap.isValid() && _anyPFIsoMap->idSize() == 1 && cand.id() == edm::ProductID()) {
116  // in case we have spoofed a ptr
117  //note this must be a 1:1 valuemap (only one product input)
118  anyisoval = _anyPFIsoMap->begin()[cand.key()];
119  } else if (_anyPFIsoMap.isValid()) { // throw an exception
120  anyisoval = (*_anyPFIsoMap)[cand];
121  }
122 
123  // Figure out the cut value
124  // The value is generally pt-dependent: C1 + pt * C2
125  double absEta = std::abs(pho->superCluster()->eta());
126 
127  // Retrieve the variable value for this particle
128  float anyPFIso = _anyPFIsoMap.isValid() ? anyisoval : pat->userFloat(inst_name);
129 
130  // Apply pile-up correction
131  double eA = _effectiveAreas.getEffectiveArea(absEta);
132  double rho = *_rhoHandle;
133  float anyPFIsoWithEA = std::max(0.0, anyPFIso - rho * eA);
134 
135  // Divide by pT if the relative isolation is requested
136  if (_useRelativeIso)
137  anyPFIsoWithEA /= pho->pt();
138 
139  // Apply the cut and return the result
140  return anyPFIsoWithEA;
141 }

References _anyPFIsoMap, _effectiveAreas, _rhoHandle, _useRelativeIso, funct::abs(), anyPFIsoWithEA_, edm::ValueMap< T >::begin(), edm::ValueMap< T >::contains(), CutApplicatorWithEventContentBase::contentTags_, EffectiveAreas::getEffectiveArea(), edm::ValueMap< T >::idSize(), edm::HandleBase::isValid(), SiStripPI::max, rho, and AlCaHLTBitMon_QueryRunRegistry::string.

Member Data Documentation

◆ _anyPFIsoMap

edm::Handle<edm::ValueMap<float> > PhoAnyPFIsoWithEACut::_anyPFIsoMap
private

Definition at line 30 of file PhoAnyPFIsoWithEACut.cc.

Referenced by getEventContent(), operator()(), and value().

◆ _barrelCutOff

float PhoAnyPFIsoWithEACut::_barrelCutOff
private

Definition at line 25 of file PhoAnyPFIsoWithEACut.cc.

Referenced by operator()().

◆ _C1_EB

float PhoAnyPFIsoWithEACut::_C1_EB
private

Definition at line 20 of file PhoAnyPFIsoWithEACut.cc.

Referenced by operator()().

◆ _C1_EE

float PhoAnyPFIsoWithEACut::_C1_EE
private

Definition at line 22 of file PhoAnyPFIsoWithEACut.cc.

Referenced by operator()().

◆ _C2_EB

float PhoAnyPFIsoWithEACut::_C2_EB
private

Definition at line 21 of file PhoAnyPFIsoWithEACut.cc.

Referenced by operator()().

◆ _C2_EE

float PhoAnyPFIsoWithEACut::_C2_EE
private

Definition at line 23 of file PhoAnyPFIsoWithEACut.cc.

Referenced by operator()().

◆ _effectiveAreas

EffectiveAreas PhoAnyPFIsoWithEACut::_effectiveAreas
private

Definition at line 28 of file PhoAnyPFIsoWithEACut.cc.

Referenced by operator()(), and value().

◆ _rhoHandle

edm::Handle<double> PhoAnyPFIsoWithEACut::_rhoHandle
private

Definition at line 32 of file PhoAnyPFIsoWithEACut.cc.

Referenced by getEventContent(), operator()(), and value().

◆ _useRelativeIso

bool PhoAnyPFIsoWithEACut::_useRelativeIso
private

Definition at line 26 of file PhoAnyPFIsoWithEACut.cc.

Referenced by operator()(), and value().

◆ anyPFIsoWithEA_

constexpr char PhoAnyPFIsoWithEACut::anyPFIsoWithEA_ = "anyPFIsoWithEA"
staticconstexprprivate

◆ rhoString_

constexpr char PhoAnyPFIsoWithEACut::rhoString_ = "rho"
staticconstexprprivate

Definition at line 35 of file PhoAnyPFIsoWithEACut.cc.

Referenced by getEventContent(), PhoAnyPFIsoWithEACut(), and setConsumes().

PhoAnyPFIsoWithEACut::_C1_EE
float _C1_EE
Definition: PhoAnyPFIsoWithEACut.cc:22
PhoAnyPFIsoWithEACut::_anyPFIsoMap
edm::Handle< edm::ValueMap< float > > _anyPFIsoMap
Definition: PhoAnyPFIsoWithEACut.cc:30
PhoAnyPFIsoWithEACut::_C2_EE
float _C2_EE
Definition: PhoAnyPFIsoWithEACut.cc:23
CutApplicatorBase::PHOTON
Definition: CutApplicatorBase.h:47
HLT_2018_cff.rhoTag
rhoTag
Definition: HLT_2018_cff.py:13606
PhoAnyPFIsoWithEACut::_C2_EB
float _C2_EB
Definition: PhoAnyPFIsoWithEACut.cc:21
CutApplicatorWithEventContentBase::contentTags_
std::unordered_map< std::string, edm::InputTag > contentTags_
Definition: CutApplicatorWithEventContentBase.h:35
edm::FileInPath
Definition: FileInPath.h:64
PhoAnyPFIsoWithEACut::anyPFIsoWithEA_
constexpr static char anyPFIsoWithEA_[]
Definition: PhoAnyPFIsoWithEACut.cc:34
DDAxes::rho
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
CutApplicatorWithEventContentBase::CutApplicatorWithEventContentBase
CutApplicatorWithEventContentBase()
Definition: CutApplicatorWithEventContentBase.h:21
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
edm::ValueMap::begin
const_iterator begin() const
Definition: ValueMap.h:229
cand
Definition: decayParser.h:34
PhoAnyPFIsoWithEACut::_rhoHandle
edm::Handle< double > _rhoHandle
Definition: PhoAnyPFIsoWithEACut.cc:32
pat
Definition: HeavyIon.h:7
PhoAnyPFIsoWithEACut::rhoString_
constexpr static char rhoString_[]
Definition: PhoAnyPFIsoWithEACut.cc:35
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
cc
edm::Ptr
Definition: AssociationVector.h:31
edm::ValueMap::idSize
size_t idSize() const
Definition: ValueMap.h:157
edm::ValueMap< float >
ev
bool ev
Definition: Hydjet2Hadronizer.cc:95
CutApplicatorWithEventContentBase::contentTokens_
std::unordered_map< std::string, edm::EDGetToken > contentTokens_
Definition: CutApplicatorWithEventContentBase.h:40
PhoAnyPFIsoWithEACut::_effectiveAreas
EffectiveAreas _effectiveAreas
Definition: PhoAnyPFIsoWithEACut.cc:28
EffectiveAreas::getEffectiveArea
const float getEffectiveArea(float eta) const
Definition: EffectiveAreas.cc:44
PhoAnyPFIsoWithEACut::_C1_EB
float _C1_EB
Definition: PhoAnyPFIsoWithEACut.cc:20
PhoAnyPFIsoWithEACut::_useRelativeIso
bool _useRelativeIso
Definition: PhoAnyPFIsoWithEACut.cc:26
edm::ValueMap::contains
bool contains(ProductID id) const
Definition: ValueMap.h:155
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
edm::InputTag
Definition: InputTag.h:15
edm::ProductID
Definition: ProductID.h:27
PhoAnyPFIsoWithEACut::_barrelCutOff
float _barrelCutOff
Definition: PhoAnyPFIsoWithEACut.cc:25