32 #include <unordered_map> 46 template <
class T,
class U>
47 bool isInFootprint(
const T& thefootprint,
const U& theCandidate)
49 for (
auto itr = thefootprint.begin(); itr != thefootprint.end(); ++itr )
51 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 _particleBasedIsolation(c.getParameter<
edm::InputTag>(
"particleBasedIsolation")){}
90 iEvent.
getByToken(particleBasedIsolationToken_, particleBasedIsolationMap);
105 const std::string _isolateAgainst, _vertexCollection;
114 "ElectronPFIsolationWithMapBasedVeto");
128 bool inFootprint =
false;
133 if ( aspacked.
get() )
135 inFootprint = isInFootprint(aspat_electronptr ->associatedPackedPFCandidates(),aspacked);
138 if( aspacked->charge() != 0 )
140 bool is_vertex_allowed =
false;
141 for(
const unsigned vtxtype : _miniAODVertexCodes )
143 if( vtxtype == aspacked->fromPV() ) {
144 is_vertex_allowed =
true;
149 result &= (is_vertex_allowed);
152 result &= deltar2 < _coneSize2 && (!inFootprint);
156 else if ( aspf.
get())
158 inFootprint = isInFootprintAlternative((*particleBasedIsolationMap)[electron], pfCandidate);
160 result &= deltar2 < _coneSize2 && (!inFootprint);
166 <<
"The supplied candidate to be used as isolation " 167 <<
"was neither a reco::Photon nor a pat::Photon!";
EDGetTokenT< ProductType > mayConsume(edm::InputTag const &tag)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
edm::Ptr< pat::PackedCandidate > PackedCandidatePtr
const std::vector< unsigned > _miniAODVertexCodes
T const * get() const
Returns C++ pointer to the item.
const edm::InputTag _particleBasedIsolation
edm::Handle< edm::ValueMap< std::vector< reco::PFCandidateRef > > > particleBasedIsolationMap
edm::Ptr< reco::GsfElectron > GsfElectronPtr
edm::Ptr< pat::Electron > patElectronPtr
~ElectronPFIsolationWithMapBasedVeto() override
Destructor.
edm::EDGetTokenT< edm::ValueMap< std::vector< reco::PFCandidateRef > > > particleBasedIsolationToken_
ElectronPFIsolationWithMapBasedVeto(const edm::ParameterSet &c)
void setConsumes(edm::ConsumesCollector iC) override
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
void getEventInfo(const edm::Event &iEvent) override
#define DEFINE_EDM_PLUGIN(factory, type, name)
bool isInIsolationCone(const reco::CandidatePtr &photon, const reco::CandidatePtr &other) const final