31 #include <unordered_map> 45 template <
class T,
class U>
46 bool isInFootprint(
const T& thefootprint,
const U& theCandidate) {
47 for (
auto itr = thefootprint.begin(); itr != thefootprint.end(); ++itr) {
48 if (itr->key() == theCandidate.key())
56 template <
class T,
class U>
57 bool isInFootprintAlternative(
const T& thefootprint,
const U& theCandidate) {
58 for (
auto itr = thefootprint.begin(); itr != thefootprint.end(); ++itr) {
59 if (itr->key() == theCandidate->sourceCandidatePtr(0).key())
69 :
citk::IsolationConeDefinitionBase(c),
70 _isolateAgainst(c.getParameter<
std::
string>(
"isolateAgainst")),
71 _miniAODVertexCodes(c.getParameter<
std::vector<unsigned> >(
72 "miniAODVertexCodes")),
73 _particleBasedIsolation(c.getParameter<
edm::
InputTag>(
"particleBasedIsolation")) {
86 iEvent.
getByToken(particleBasedIsolationToken_, particleBasedIsolationMap);
91 particleBasedIsolationToken_ =
99 const std::string _isolateAgainst, _vertexCollection;
106 "ElectronPFIsolationWithMapBasedVeto");
118 bool inFootprint =
false;
120 const float deltar2 =
124 if (aspacked.
get()) {
128 if (aspacked->charge() != 0) {
129 bool is_vertex_allowed =
false;
130 for (
const unsigned vtxtype : _miniAODVertexCodes) {
131 if (vtxtype == aspacked->fromPV()) {
132 is_vertex_allowed =
true;
137 result &= (is_vertex_allowed);
140 result &= deltar2 < _coneSize2 && (!inFootprint);
144 else if (aspf.
get()) {
145 inFootprint = isInFootprintAlternative((*particleBasedIsolationMap)[electron], pfCandidate);
147 result &= deltar2 < _coneSize2 && (!inFootprint);
152 throw cms::Exception(
"InvalidIsolationInput") <<
"The supplied candidate to be used as isolation " 153 <<
"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.
edm::Handle< edm::ValueMap< std::vector< reco::PFCandidateRef > > > particleBasedIsolationMap
const edm::InputTag _particleBasedIsolation
edm::Ptr< reco::GsfElectron > GsfElectronPtr
edm::Ptr< pat::Electron > patElectronPtr
edm::Ptr< pat::PackedCandidate > PackedCandidatePtr
~ElectronPFIsolationWithMapBasedVeto() override
Destructor.
ElectronPFIsolationWithMapBasedVeto(const edm::ParameterSet &c)
void setConsumes(edm::ConsumesCollector iC) override
edm::EDGetTokenT< edm::ValueMap< std::vector< reco::PFCandidateRef > > > particleBasedIsolationToken_
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
edm::RefVector< pat::PackedCandidateCollection > associatedPackedPFCandidates() const
References to PFCandidates linked to this object (e.g. for isolation vetos or masking before jet recl...