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 edm::ParameterSet &c)
 
 CutApplicatorWithEventContentBase (const CutApplicatorWithEventContentBase &)=delete
 
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 edm::ParameterSet &c)
 
 CutApplicatorBase (const CutApplicatorBase &)=delete
 
const std::string & name () const override
 
result_type operator() (const argument_type &) const final
 
virtual result_type operator() (const reco::GsfElectronPtr &) const
 
virtual result_type operator() (const pat::ElectronPtr &) const
 
virtual result_type operator() (const reco::MuonPtr &) const
 
virtual result_type operator() (const pat::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

static constexpr char anyPFIsoWithEA_ [] = "anyPFIsoWithEA"
 
static constexpr 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.

References anyPFIsoWithEA_, c, CutApplicatorWithEventContentBase::contentTags_, rhoString_, and HLT_2022v14_cff::rhoTag.

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 }
std::unordered_map< std::string, edm::InputTag > contentTags_
static constexpr char anyPFIsoWithEA_[]
static constexpr char rhoString_[]
EffectiveAreas _effectiveAreas

Member Function Documentation

◆ candidateType()

CandidateType PhoAnyPFIsoWithEACut::candidateType ( ) const
inlinefinalvirtual

Reimplemented from CutApplicatorBase.

Definition at line 16 of file PhoAnyPFIsoWithEACut.cc.

References CutApplicatorBase::PHOTON.

◆ getEventContent()

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

Implements CutApplicatorWithEventContentBase.

Definition at line 67 of file PhoAnyPFIsoWithEACut.cc.

References _anyPFIsoMap, _rhoHandle, anyPFIsoWithEA_, CutApplicatorWithEventContentBase::contentTags_, makeMEIFBenchmarkPlots::ev, and rhoString_.

67  {
69  ev.getByLabel(contentTags_[rhoString_], _rhoHandle);
70 }
std::unordered_map< std::string, edm::InputTag > contentTags_
static constexpr char anyPFIsoWithEA_[]
static constexpr char rhoString_[]
edm::Handle< double > _rhoHandle
edm::Handle< edm::ValueMap< float > > _anyPFIsoMap

◆ operator()()

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

Reimplemented from CutApplicatorBase.

Definition at line 72 of file PhoAnyPFIsoWithEACut.cc.

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.

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 }
std::unordered_map< std::string, edm::InputTag > contentTags_
size_t idSize() const
Definition: ValueMap.h:157
static constexpr char anyPFIsoWithEA_[]
Definition: HeavyIon.h:7
edm::Handle< double > _rhoHandle
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const float getEffectiveArea(float eta) const
const_iterator begin() const
Definition: ValueMap.h:229
bool isValid() const
Definition: HandleBase.h:70
edm::Handle< edm::ValueMap< float > > _anyPFIsoMap
EffectiveAreas _effectiveAreas
bool contains(ProductID id) const
Definition: ValueMap.h:155

◆ setConsumes()

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

Implements CutApplicatorWithEventContentBase.

Definition at line 59 of file PhoAnyPFIsoWithEACut.cc.

References anyPFIsoWithEA_, edm::ConsumesCollector::consumes(), CutApplicatorWithEventContentBase::contentTags_, CutApplicatorWithEventContentBase::contentTokens_, rho, and rhoString_.

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 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
std::unordered_map< std::string, edm::InputTag > contentTags_
static constexpr char anyPFIsoWithEA_[]
static constexpr char rhoString_[]
std::unordered_map< std::string, edm::EDGetToken > contentTokens_

◆ value()

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

Implements candidate_functions::CandidateCut.

Definition at line 106 of file PhoAnyPFIsoWithEACut.cc.

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.

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 }
std::unordered_map< std::string, edm::InputTag > contentTags_
size_t idSize() const
Definition: ValueMap.h:157
static constexpr char anyPFIsoWithEA_[]
Definition: HeavyIon.h:7
edm::Handle< double > _rhoHandle
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const float getEffectiveArea(float eta) const
const_iterator begin() const
Definition: ValueMap.h:229
bool isValid() const
Definition: HandleBase.h:70
edm::Handle< edm::ValueMap< float > > _anyPFIsoMap
EffectiveAreas _effectiveAreas
bool contains(ProductID id) const
Definition: ValueMap.h:155

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"
staticprivate

◆ rhoString_

constexpr char PhoAnyPFIsoWithEACut::rhoString_ = "rho"
staticprivate

Definition at line 35 of file PhoAnyPFIsoWithEACut.cc.

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