CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes | Private Attributes
PhotonPFIsolationWithMapBasedVeto Class Reference
Inheritance diagram for PhotonPFIsolationWithMapBasedVeto:
citk::IsolationConeDefinitionBase

Public Member Functions

void getEventInfo (const edm::Event &iEvent) override
 
bool isInIsolationCone (const reco::CandidatePtr &photon, const reco::CandidatePtr &pfCandidate) const final
 
PhotonPFIsolationWithMapBasedVetooperator= (const PhotonPFIsolationWithMapBasedVeto &)=delete
 
 PhotonPFIsolationWithMapBasedVeto (const edm::ParameterSet &c)
 
 PhotonPFIsolationWithMapBasedVeto (const PhotonPFIsolationWithMapBasedVeto &)=delete
 
void setConsumes (edm::ConsumesCollector iC) override
 
 ~PhotonPFIsolationWithMapBasedVeto () override
 Destructor. More...
 
- Public Member Functions inherited from citk::IsolationConeDefinitionBase
const std::string & additionalCode () const
 
virtual void getEventSetupInfo (const edm::EventSetup &)
 
 IsolationConeDefinitionBase (const edm::ParameterSet &c)
 
 IsolationConeDefinitionBase (const IsolationConeDefinitionBase &)=delete
 
const std::string & name () const
 
IsolationConeDefinitionBaseoperator= (const IsolationConeDefinitionBase &)=delete
 
virtual ~IsolationConeDefinitionBase ()
 Destructor. More...
 

Public Attributes

edm::Handle< edm::ValueMap< std::vector< reco::PFCandidateRef > > > particleBasedIsolationMap
 
edm::EDGetTokenT< edm::ValueMap< std::vector< reco::PFCandidateRef > > > particleBasedIsolationToken_
 

Private Attributes

const std::string _isolateAgainst
 
const std::vector< unsigned > _miniAODVertexCodes
 
const edm::InputTag _particleBasedIsolation
 
const std::string _vertexCollection
 
const unsigned _vertexIndex
 

Additional Inherited Members

- Protected Attributes inherited from citk::IsolationConeDefinitionBase
std::string _additionalCode
 
const float _coneSize2
 

Detailed Description

Definition at line 69 of file PhotonPFIsolationWithMapBasedVeto.cc.

Constructor & Destructor Documentation

PhotonPFIsolationWithMapBasedVeto::PhotonPFIsolationWithMapBasedVeto ( const edm::ParameterSet c)
inline

Definition at line 71 of file PhotonPFIsolationWithMapBasedVeto.cc.

References muons2muons_cfi::photon.

71  :
73  _isolateAgainst(c.getParameter<std::string>("isolateAgainst")), //isolate against either h+, h0 or gamma
74  _miniAODVertexCodes(c.getParameter<std::vector<unsigned> >("miniAODVertexCodes")), //quality flags to be used for association with the vertex configurable, the vertex can be chosen
75  _vertexIndex(c.getParameter<int> ("vertexIndex")),//vertex of interest
76  _particleBasedIsolation(c.getParameter<edm::InputTag>("particleBasedIsolation")){}
T getParameter(std::string const &) const
PhotonPFIsolationWithMapBasedVeto::PhotonPFIsolationWithMapBasedVeto ( const PhotonPFIsolationWithMapBasedVeto )
delete
PhotonPFIsolationWithMapBasedVeto::~PhotonPFIsolationWithMapBasedVeto ( )
inlineoverride

Destructor.

Definition at line 102 of file PhotonPFIsolationWithMapBasedVeto.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

102 {};

Member Function Documentation

void PhotonPFIsolationWithMapBasedVeto::getEventInfo ( const edm::Event iEvent)
inlineoverridevirtual

Reimplemented from citk::IsolationConeDefinitionBase.

Definition at line 89 of file PhotonPFIsolationWithMapBasedVeto.cc.

References edm::Event::getByToken().

90  {
92  };
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:508
edm::Handle< edm::ValueMap< std::vector< reco::PFCandidateRef > > > particleBasedIsolationMap
edm::EDGetTokenT< edm::ValueMap< std::vector< reco::PFCandidateRef > > > particleBasedIsolationToken_
bool PhotonPFIsolationWithMapBasedVeto::isInIsolationCone ( const reco::CandidatePtr photon,
const reco::CandidatePtr pfCandidate 
) const
finalvirtual

Implements citk::IsolationConeDefinitionBase.

Definition at line 121 of file PhotonPFIsolationWithMapBasedVeto.cc.

References pat::PackedCandidate::charge(), reco::deltaR2(), Exception, pat::PackedCandidate::fromPV(), edm::Ptr< T >::get(), isInFootprint(), edm::Ptr< T >::isNonnull(), and mps_fire::result.

121  {
122 
123  //convert the photon and candidate objects to the corresponding pat or reco objects. What is used depends on what is user running on: miniAOD or AOD
124  pat::patPhotonPtr aspat_photonptr(photon);
125 
126  pat::PackedCandidatePtr aspacked(pfCandidate);
127  reco::PFCandidatePtr aspf(pfCandidate);
128 
129 
130  bool inFootprint = false;
131  bool result = true;
132  const float deltar2 = reco::deltaR2(*photon,*pfCandidate); //calculate deltaR2 distance between PFCandidate and photon
133 
134  // dealing here with patObjects: miniAOD case
135  if ( aspacked.get() )
136  {
137  inFootprint = isInFootprint(aspat_photonptr ->associatedPackedPFCandidates(),aspacked);
138 
139  //checking if the charged candidates come from the appropriate vertex
140  if( aspacked->charge() != 0 )
141  {
142  bool is_vertex_allowed = false;
143  for( const unsigned vtxtype : _miniAODVertexCodes )
144  {
145  if( vtxtype == aspacked->fromPV(_vertexIndex) ) {
146  is_vertex_allowed = true;
147  break;
148  }
149  }
150 
151  result &= (is_vertex_allowed);
152  }
153  //return true if the candidate is inside the cone and not in the footprint
154  result &= deltar2 < _coneSize2 && (!inFootprint);
155 
156  }
157 
158  // dealing here with recoObjects: AOD case
159  else if ( aspf.get() && aspf.isNonnull())
160  {
161  inFootprint = isInFootprintAlternative((*particleBasedIsolationMap)[photon], aspf);
162  result &= deltar2 < _coneSize2 && (!inFootprint);
163 
164  }
165 
166  // throw exception if it is not a patObject or recoObject
167  else {
168  throw cms::Exception("InvalidIsolationInput")
169  << "The supplied candidate to be used as isolation "
170  << "was neither a reco::Photon nor a pat::Photon!";
171  }
172 
173  return result;
174 }
edm::Handle< edm::ValueMap< std::vector< reco::PFCandidateRef > > > particleBasedIsolationMap
bool isInFootprint(const T &thefootprint, const U &theCandidate)
T1 deltaR2(T1 eta1, T2 phi1, T3 eta2, T4 phi2)
Definition: deltaR.h:36
PhotonPFIsolationWithMapBasedVeto& PhotonPFIsolationWithMapBasedVeto::operator= ( const PhotonPFIsolationWithMapBasedVeto )
delete
void PhotonPFIsolationWithMapBasedVeto::setConsumes ( edm::ConsumesCollector  iC)
inlineoverridevirtual

Implements citk::IsolationConeDefinitionBase.

Definition at line 96 of file PhotonPFIsolationWithMapBasedVeto.cc.

References edm::ConsumesCollector::mayConsume().

97  {
99  }
EDGetTokenT< ProductType > mayConsume(edm::InputTag const &tag)
edm::EDGetTokenT< edm::ValueMap< std::vector< reco::PFCandidateRef > > > particleBasedIsolationToken_

Member Data Documentation

const std::string PhotonPFIsolationWithMapBasedVeto::_isolateAgainst
private

Definition at line 102 of file PhotonPFIsolationWithMapBasedVeto.cc.

const std::vector<unsigned> PhotonPFIsolationWithMapBasedVeto::_miniAODVertexCodes
private

Definition at line 107 of file PhotonPFIsolationWithMapBasedVeto.cc.

const edm::InputTag PhotonPFIsolationWithMapBasedVeto::_particleBasedIsolation
private

Definition at line 109 of file PhotonPFIsolationWithMapBasedVeto.cc.

const std::string PhotonPFIsolationWithMapBasedVeto::_vertexCollection
private

Definition at line 102 of file PhotonPFIsolationWithMapBasedVeto.cc.

const unsigned PhotonPFIsolationWithMapBasedVeto::_vertexIndex
private

Definition at line 108 of file PhotonPFIsolationWithMapBasedVeto.cc.

edm::Handle< edm::ValueMap<std::vector<reco::PFCandidateRef > > > PhotonPFIsolationWithMapBasedVeto::particleBasedIsolationMap

Definition at line 86 of file PhotonPFIsolationWithMapBasedVeto.cc.

edm::EDGetTokenT<edm::ValueMap<std::vector<reco::PFCandidateRef > > > PhotonPFIsolationWithMapBasedVeto::particleBasedIsolationToken_

Definition at line 87 of file PhotonPFIsolationWithMapBasedVeto.cc.