30 #include <unordered_map> 45 template <
class T,
class U>
46 bool isInFootprint(
const T& thefootprint,
const U& theCandidate)
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!";
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
int charge() const override
electric charge
void getEventInfo(const edm::Event &iEvent) override
void setConsumes(edm::ConsumesCollector iC) override
const PVAssoc fromPV(size_t ipv=0) const
edm::EDGetTokenT< edm::ValueMap< std::vector< reco::PFCandidateRef > > > particleBasedIsolationToken_
bool isInIsolationCone(const reco::CandidatePtr &photon, const reco::CandidatePtr &pfCandidate) const final
bool isNonnull() const
Checks for non-null.
edm::Ptr< reco::Photon > recoPhotonPtr
const unsigned _vertexIndex
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
const edm::InputTag _particleBasedIsolation
PhotonPFIsolationWithMapBasedVeto(const edm::ParameterSet &c)
edm::Ptr< pat::Photon > patPhotonPtr
#define DEFINE_EDM_PLUGIN(factory, type, name)
~PhotonPFIsolationWithMapBasedVeto() override
Destructor.