CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 overridefinal
 
void getEventContent (const edm::EventBase &) overridefinal
 
result_type operator() (const reco::PhotonPtr &) const overridefinal
 
 PhoAnyPFIsoWithEACut (const edm::ParameterSet &c)
 
void setConsumes (edm::ConsumesCollector &) overridefinal
 
double value (const reco::CandidatePtr &cand) const overridefinal
 
- Public Member Functions inherited from CutApplicatorWithEventContentBase
 CutApplicatorWithEventContentBase (const edm::ParameterSet &c)
 
 CutApplicatorWithEventContentBase (const CutApplicatorWithEventContentBase &)=delete
 
CutApplicatorWithEventContentBaseoperator= (const CutApplicatorWithEventContentBase &)=delete
 
virtual ~CutApplicatorWithEventContentBase ()
 Destructor. More...
 
- Public Member Functions inherited from CutApplicatorBase
virtual result_type asCandidate (const argument_type &) const
 
 CutApplicatorBase (const edm::ParameterSet &c)
 
 CutApplicatorBase (const CutApplicatorBase &)=delete
 
const std::string & name () const
 
virtual 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 pat::PhotonPtr &) const
 
virtual result_type operator() (const reco::MuonPtr &) const
 
virtual result_type operator() (const pat::MuonPtr &) const
 
virtual result_type operator() (const reco::PFTauPtr &) const
 
virtual result_type operator() (const pat::TauPtr &) const
 
CutApplicatorBaseoperator= (const CutApplicatorBase &)=delete
 
virtual ~CutApplicatorBase ()
 Destructor. More...
 
- Public Member Functions inherited from candidate_functions::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 char anyPFIsoWithEA_ [] = "anyPFIsoWithEA"
 
static char rhoString_ [] = "rho"
 

Additional Inherited Members

- Public Types inherited from CutApplicatorBase
enum  CandidateType {
  NONE, ELECTRON, MUON, PHOTON,
  TAU, PATELECTRON, PATMUON, PATPHOTON,
  PATTAU
}
 
- Protected Attributes inherited from CutApplicatorWithEventContentBase
std::unordered_map
< std::string, edm::InputTag
contentTags_
 
std::unordered_map
< std::string, edm::EDGetToken
contentTokens_
 

Detailed Description

Definition at line 6 of file PhoAnyPFIsoWithEACut.cc.

Constructor & Destructor Documentation

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

Definition at line 48 of file PhoAnyPFIsoWithEACut.cc.

References anyPFIsoWithEA_, CutApplicatorWithEventContentBase::contentTags_, edm::ParameterSet::getParameter(), and rhoString_.

48  :
50  _C1_EB(c.getParameter<double>("C1_EB")),
51  _C2_EB(c.getParameter<double>("C2_EB")),
52  _C1_EE(c.getParameter<double>("C1_EE")),
53  _C2_EE(c.getParameter<double>("C2_EE")),
54  _barrelCutOff(c.getParameter<double>("barrelCutOff")),
55  _useRelativeIso(c.getParameter<bool>("useRelativeIso")),
56  _effectiveAreas( (c.getParameter<edm::FileInPath>("effAreasConfigFile")).fullPath())
57 {
58 
59  edm::InputTag maptag = c.getParameter<edm::InputTag>("anyPFIsoMap");
60  contentTags_.emplace(anyPFIsoWithEA_,maptag);
61 
62  edm::InputTag rhoTag = c.getParameter<edm::InputTag>("rho");
63  contentTags_.emplace(rhoString_,rhoTag);
64 
65 }
T getParameter(std::string const &) const
CutApplicatorWithEventContentBase(const edm::ParameterSet &c)
std::unordered_map< std::string, edm::InputTag > contentTags_
EffectiveAreas _effectiveAreas

Member Function Documentation

CandidateType PhoAnyPFIsoWithEACut::candidateType ( ) const
inlinefinaloverridevirtual

Reimplemented from CutApplicatorBase.

Definition at line 17 of file PhoAnyPFIsoWithEACut.cc.

References CutApplicatorBase::PHOTON.

17  {
18  return PHOTON;
19  }
void PhoAnyPFIsoWithEACut::getEventContent ( const edm::EventBase ev)
finaloverridevirtual

Implements CutApplicatorWithEventContentBase.

Definition at line 76 of file PhoAnyPFIsoWithEACut.cc.

References _anyPFIsoMap, _rhoHandle, anyPFIsoWithEA_, CutApplicatorWithEventContentBase::contentTags_, edm::EventBase::getByLabel(), and rhoString_.

76  {
79 }
std::unordered_map< std::string, edm::InputTag > contentTags_
bool getByLabel(InputTag const &, Handle< T > &) const
Definition: EventBase.h:92
edm::Handle< edm::ValueMap< float > > _anyPFIsoMap
edm::Handle< double > _rhoHandle
CutApplicatorBase::result_type PhoAnyPFIsoWithEACut::operator() ( const reco::PhotonPtr cand) const
finaloverridevirtual

Reimplemented from CutApplicatorBase.

Definition at line 83 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::Ptr< T >::id(), edm::ValueMap< T >::idSize(), edm::HandleBase::isValid(), edm::Ptr< T >::key(), bookConverter::max, rho, and AlCaHLTBitMon_QueryRunRegistry::string.

83  {
84 
85  // in case we are by-value
86  const std::string& inst_name = contentTags_.find(anyPFIsoWithEA_)->second.instance();
87  edm::Ptr<pat::Photon> pat(cand);
88  float anyisoval = -1.0;
89  if( _anyPFIsoMap.isValid() && _anyPFIsoMap->contains( cand.id() ) ) {
90  anyisoval = (*_anyPFIsoMap)[cand];
91  } else if ( _anyPFIsoMap.isValid() && _anyPFIsoMap->idSize() == 1 &&
92  cand.id() == edm::ProductID() ) {
93  // in case we have spoofed a ptr
94  //note this must be a 1:1 valuemap (only one product input)
95  anyisoval = _anyPFIsoMap->begin()[cand.key()];
96  } else if ( _anyPFIsoMap.isValid() ){ // throw an exception
97  anyisoval = (*_anyPFIsoMap)[cand];
98  }
99 
100  // Figure out the cut value
101  // The value is generally pt-dependent: C1 + pt * C2
102  double absEta = std::abs(cand->superCluster()->eta());
103  const float anyPFIsoWithEACutValue =
104  ( absEta < _barrelCutOff ?
105  _C1_EB + cand->pt() * _C2_EB
106  :
107  _C1_EE + cand->pt() * _C2_EE
108  );
109 
110  // Retrieve the variable value for this particle
111  float anyPFIso = _anyPFIsoMap.isValid() ? anyisoval : pat->userFloat(inst_name);
112 
113  // Apply pile-up correction
114  double eA = _effectiveAreas.getEffectiveArea( absEta );
115  double rho = *_rhoHandle;
116  float anyPFIsoWithEA = std::max(0.0, anyPFIso - rho * eA);
117 
118  // Divide by pT if the relative isolation is requested
119  if( _useRelativeIso )
120  anyPFIsoWithEA /= cand->pt();
121 
122  // Apply the cut and return the result
123  return anyPFIsoWithEA < anyPFIsoWithEACutValue;
124 }
key_type key() const
Definition: Ptr.h:169
Definition: DDAxes.h:10
const float getEffectiveArea(float eta) const
std::unordered_map< std::string, edm::InputTag > contentTags_
bool contains(ProductID id) const
Definition: ValueMap.h:154
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
bool isValid() const
Definition: HandleBase.h:75
size_t idSize() const
Definition: ValueMap.h:158
const_iterator begin() const
Definition: ValueMap.h:209
ProductID id() const
Accessor for product ID.
Definition: Ptr.h:164
edm::Handle< edm::ValueMap< float > > _anyPFIsoMap
edm::Handle< double > _rhoHandle
EffectiveAreas _effectiveAreas
void PhoAnyPFIsoWithEACut::setConsumes ( edm::ConsumesCollector cc)
finaloverridevirtual

Implements CutApplicatorWithEventContentBase.

Definition at line 67 of file PhoAnyPFIsoWithEACut.cc.

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

67  {
68  auto anyPFIsoWithEA =
70  contentTokens_.emplace(anyPFIsoWithEA_,anyPFIsoWithEA);
71 
72  auto rho = cc.consumes<double>(contentTags_[rhoString_]);
73  contentTokens_.emplace(rhoString_, rho);
74 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
std::unordered_map< std::string, edm::EDGetToken > contentTokens_
Definition: DDAxes.h:10
std::unordered_map< std::string, edm::InputTag > contentTags_
double PhoAnyPFIsoWithEACut::value ( const reco::CandidatePtr cand) const
finaloverridevirtual

Implements candidate_functions::CandidateCut.

Definition at line 127 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::Ptr< T >::id(), edm::ValueMap< T >::idSize(), edm::HandleBase::isValid(), edm::Ptr< T >::key(), bookConverter::max, rho, and AlCaHLTBitMon_QueryRunRegistry::string.

127  {
128  reco::PhotonPtr pho(cand);
129 
130  // in case we are by-value
131  const std::string& inst_name = contentTags_.find(anyPFIsoWithEA_)->second.instance();
132  edm::Ptr<pat::Photon> pat(cand);
133  float anyisoval = -1.0;
134  if( _anyPFIsoMap.isValid() && _anyPFIsoMap->contains( cand.id() ) ) {
135  anyisoval = (*_anyPFIsoMap)[cand];
136  } else if ( _anyPFIsoMap.isValid() && _anyPFIsoMap->idSize() == 1 &&
137  cand.id() == edm::ProductID() ) {
138  // in case we have spoofed a ptr
139  //note this must be a 1:1 valuemap (only one product input)
140  anyisoval = _anyPFIsoMap->begin()[cand.key()];
141  } else if ( _anyPFIsoMap.isValid() ){ // throw an exception
142  anyisoval = (*_anyPFIsoMap)[cand];
143  }
144 
145  // Figure out the cut value
146  // The value is generally pt-dependent: C1 + pt * C2
147  double absEta = std::abs(pho->superCluster()->eta());
148 
149  // Retrieve the variable value for this particle
150  float anyPFIso = _anyPFIsoMap.isValid() ? anyisoval : pat->userFloat(inst_name);
151 
152  // Apply pile-up correction
153  double eA = _effectiveAreas.getEffectiveArea( absEta );
154  double rho = *_rhoHandle;
155  float anyPFIsoWithEA = std::max(0.0, anyPFIso - rho * eA);
156 
157  // Divide by pT if the relative isolation is requested
158  if( _useRelativeIso )
159  anyPFIsoWithEA /= pho->pt();
160 
161  // Apply the cut and return the result
162  return anyPFIsoWithEA;
163 }
key_type key() const
Definition: Ptr.h:169
Definition: DDAxes.h:10
const float getEffectiveArea(float eta) const
std::unordered_map< std::string, edm::InputTag > contentTags_
bool contains(ProductID id) const
Definition: ValueMap.h:154
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
bool isValid() const
Definition: HandleBase.h:75
size_t idSize() const
Definition: ValueMap.h:158
const_iterator begin() const
Definition: ValueMap.h:209
ProductID id() const
Accessor for product ID.
Definition: Ptr.h:164
edm::Handle< edm::ValueMap< float > > _anyPFIsoMap
edm::Handle< double > _rhoHandle
EffectiveAreas _effectiveAreas

Member Data Documentation

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

Definition at line 33 of file PhoAnyPFIsoWithEACut.cc.

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

float PhoAnyPFIsoWithEACut::_barrelCutOff
private

Definition at line 28 of file PhoAnyPFIsoWithEACut.cc.

Referenced by operator()().

float PhoAnyPFIsoWithEACut::_C1_EB
private

Definition at line 23 of file PhoAnyPFIsoWithEACut.cc.

Referenced by operator()().

float PhoAnyPFIsoWithEACut::_C1_EE
private

Definition at line 25 of file PhoAnyPFIsoWithEACut.cc.

Referenced by operator()().

float PhoAnyPFIsoWithEACut::_C2_EB
private

Definition at line 24 of file PhoAnyPFIsoWithEACut.cc.

Referenced by operator()().

float PhoAnyPFIsoWithEACut::_C2_EE
private

Definition at line 26 of file PhoAnyPFIsoWithEACut.cc.

Referenced by operator()().

EffectiveAreas PhoAnyPFIsoWithEACut::_effectiveAreas
private

Definition at line 31 of file PhoAnyPFIsoWithEACut.cc.

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

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

Definition at line 35 of file PhoAnyPFIsoWithEACut.cc.

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

bool PhoAnyPFIsoWithEACut::_useRelativeIso
private

Definition at line 29 of file PhoAnyPFIsoWithEACut.cc.

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

char PhoAnyPFIsoWithEACut::anyPFIsoWithEA_ = "anyPFIsoWithEA"
staticprivate
char PhoAnyPFIsoWithEACut::rhoString_ = "rho"
staticprivate

Definition at line 38 of file PhoAnyPFIsoWithEACut.cc.

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