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 override final
 
void getEventContent (const edm::EventBase &) override final
 
result_type operator() (const reco::PhotonPtr &) const override final
 
 PhoAnyPFIsoWithEACut (const edm::ParameterSet &c)
 
void setConsumes (edm::ConsumesCollector &) override final
 
double value (const reco::CandidatePtr &cand) const override final
 
- Public Member Functions inherited from CutApplicatorWithEventContentBase
 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 ()
 
 CutApplicatorBase (const edm::ParameterSet &c)
 
 CutApplicatorBase (const CutApplicatorBase &)=delete
 
virtual 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
 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::InputTagcontentTags_
 
std::unordered_map< std::string, edm::EDGetTokencontentTokens_
 

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(), rhoString_, and HiL1Corrector_cff::rhoTag.

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 
63  contentTags_.emplace(rhoString_,rhoTag);
64 
65 }
T getParameter(std::string const &) const
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(), operator()(), and rhoString_.

76  {
79 }
std::unordered_map< std::string, edm::InputTag > contentTags_
bool getByLabel(InputTag const &, Handle< T > &) const
Definition: EventBase.h:89
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(), hpstanc_transforms::max, reco::LeafCandidate::pt(), rho, AlCaHLTBitMon_QueryRunRegistry::string, reco::Photon::superCluster(), pat::PATObject< ObjectType >::userFloat(), and value().

Referenced by getEventContent().

83  {
84 
85  // in case we are by-value
86  const std::string& inst_name = contentTags_.find(anyPFIsoWithEA_)->second.instance();
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  const 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  const double eA = _effectiveAreas.getEffectiveArea( absEta );
115  const double rho = _rhoHandle.isValid() ? *_rhoHandle : 0;
116  const float anyPFIsoWithEA = std::max(0.0, anyPFIso - rho * eA);
117 
118  // Apply the cut and return the result
119  // Scale by pT if the relative isolation is requested but avoid division by 0
120  return anyPFIsoWithEA < anyPFIsoWithEACutValue*(_useRelativeIso ? cand->pt() : 1.);
121 }
virtual double pt() const final
transverse momentum
reco::SuperClusterRef superCluster() const
Ref to SuperCluster.
key_type key() const
Definition: Ptr.h:186
const float getEffectiveArea(float eta) const
std::unordered_map< std::string, edm::InputTag > contentTags_
Definition: HeavyIon.h:7
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:74
size_t idSize() const
Definition: ValueMap.h:158
const_iterator begin() const
Definition: ValueMap.h:207
ProductID id() const
Accessor for product ID.
Definition: Ptr.h:181
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_
std::unordered_map< std::string, edm::InputTag > contentTags_
double PhoAnyPFIsoWithEACut::value ( const reco::CandidatePtr cand) const
finaloverridevirtual

Implements candidate_functions::CandidateCut.

Definition at line 124 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(), hpstanc_transforms::max, reco::LeafCandidate::pt(), rho, AlCaHLTBitMon_QueryRunRegistry::string, reco::Photon::superCluster(), and pat::PATObject< ObjectType >::userFloat().

Referenced by operator()().

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