32 #include <unordered_map> 46 template <
class T,
class U>
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
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
edm::Ptr< pat::PackedCandidate > PackedCandidatePtr
edm::EDGetTokenT< edm::ValueMap< std::vector< reco::PFCandidateRef > > > particleBasedIsolationToken_
ElectronPFIsolationWithMapBasedVeto(const edm::ParameterSet &c)
bool isInFootprint(const T &thefootprint, const U &theCandidate)
void setConsumes(edm::ConsumesCollector iC) override
virtual void getEventInfo(const edm::Event &iEvent) override
T1 deltaR2(T1 eta1, T2 phi1, T3 eta2, T4 phi2)
bool isInIsolationCone(const reco::CandidatePtr &photon, const reco::CandidatePtr &other) const override final
virtual ~ElectronPFIsolationWithMapBasedVeto()
Destructor.
#define DEFINE_EDM_PLUGIN(factory, type, name)