30 #include <unordered_map> 45 template <
class T,
class U>
48 for (
auto itr = thefootprint.begin(); itr != thefootprint.end(); ++itr )
50 if( itr->key() == theCandidate.key() )
return true;
58 template <
class T,
class U>
59 bool isInFootprintAlternative(
const T& thefootprint,
const U& theCandidate)
61 for (
auto itr = thefootprint.begin(); itr != thefootprint.end(); ++itr )
63 if( itr->key() == theCandidate->sourceCandidatePtr(0).key() )
return true;
72 citk::IsolationConeDefinitionBase(c),
73 _isolateAgainst(c.getParameter<
std::
string>(
"isolateAgainst")),
74 _miniAODVertexCodes(c.getParameter<
std::vector<unsigned> >(
"miniAODVertexCodes")),
75 _vertexIndex(c.getParameter<
int> (
"vertexIndex")),
76 _particleBasedIsolation(c.getParameter<
edm::InputTag>(
"particleBasedIsolation")){}
91 iEvent.
getByToken(particleBasedIsolationToken_, particleBasedIsolationMap);
106 const std::string _isolateAgainst, _vertexCollection;
116 "PhotonPFIsolationWithMapBasedVeto");
130 bool inFootprint =
false;
135 if ( aspacked.
get() )
137 inFootprint =
isInFootprint(aspat_photonptr ->associatedPackedPFCandidates(),aspacked);
140 if( aspacked->
charge() != 0 )
142 bool is_vertex_allowed =
false;
143 for(
const unsigned vtxtype : _miniAODVertexCodes )
145 if( vtxtype == aspacked->
fromPV(_vertexIndex) ) {
146 is_vertex_allowed =
true;
151 result &= (is_vertex_allowed);
154 result &= deltar2 < _coneSize2 && (!inFootprint);
161 inFootprint = isInFootprintAlternative((*particleBasedIsolationMap)[photon], aspf);
162 result &= deltar2 < _coneSize2 && (!inFootprint);
169 <<
"The supplied candidate to be used as isolation " 170 <<
"was neither a reco::Photon nor a pat::Photon!";
virtual ~PhotonPFIsolationWithMapBasedVeto()
Destructor.
EDGetTokenT< ProductType > mayConsume(edm::InputTag const &tag)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
T const * get() const
Returns C++ pointer to the item.
const std::vector< unsigned > _miniAODVertexCodes
edm::Handle< edm::ValueMap< std::vector< reco::PFCandidateRef > > > particleBasedIsolationMap
edm::Ptr< pat::PackedCandidate > PackedCandidatePtr
bool isInIsolationCone(const reco::CandidatePtr &photon, const reco::CandidatePtr &pfCandidate) const override final
void setConsumes(edm::ConsumesCollector iC) override
const PVAssoc fromPV(size_t ipv=0) const
bool isInFootprint(const T &thefootprint, const U &theCandidate)
edm::EDGetTokenT< edm::ValueMap< std::vector< reco::PFCandidateRef > > > particleBasedIsolationToken_
virtual int charge() const
electric charge
bool isNonnull() const
Checks for non-null.
edm::Ptr< reco::Photon > recoPhotonPtr
const unsigned _vertexIndex
const edm::InputTag _particleBasedIsolation
PhotonPFIsolationWithMapBasedVeto(const edm::ParameterSet &c)
T1 deltaR2(T1 eta1, T2 phi1, T3 eta2, T4 phi2)
edm::Ptr< pat::Photon > patPhotonPtr
virtual void getEventInfo(const edm::Event &iEvent) override
#define DEFINE_EDM_PLUGIN(factory, type, name)