Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix MET Significance, Covariance Matrix and unclustered energy lepton subtraction #29385

Merged
merged 9 commits into from Apr 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion CommonTools/CandAlgos/plugins/CandPtrProjector.cc
Expand Up @@ -50,7 +50,7 @@ void CandPtrProjector::produce(edm::StreamID, edm::Event& iEvent, edm::EventSetu
bool addcand = true;
if (useDeltaRforFootprint_)
for (const auto& it : vetoedPtrs)
if (reco::deltaR2(it->p4(), c->p4()) < 0.00000025) {
if ((it.isNonnull()) && (it.isAvailable()) && (reco::deltaR2(it->p4(), c->p4()) < 0.00000025)) {
addcand = false;
break;
}
Expand Down
82 changes: 82 additions & 0 deletions PhysicsTools/PatUtils/plugins/PFEGammaToCandidate.cc
@@ -0,0 +1,82 @@
/**
Take as input:
- the electron and photon collections
- the electron and photon pf maps (edm::ValueMap<std::vector<reco::PFCandidateRef>>) pointing to old PF candidates
Produce as output:
- the electron and photon collections as VertexCompositePtrCandidates
*/

#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/global/EDProducer.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
#include "DataFormats/Common/interface/ValueMap.h"
#include "DataFormats/Common/interface/PtrVector.h"
#include "DataFormats/PatCandidates/interface/Photon.h"
#include "DataFormats/PatCandidates/interface/Electron.h"
#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
#include "DataFormats/Common/interface/RefToPtr.h"
#include "DataFormats/Candidate/interface/VertexCompositePtrCandidate.h"

class PFEGammaToCandidate : public edm::global::EDProducer<> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new producers should come with a ::fillDescriptions method.
Please define one.

public:
explicit PFEGammaToCandidate(const edm::ParameterSet &iConfig);
~PFEGammaToCandidate() override = default;

void produce(edm::StreamID iID, edm::Event &iEvent, const edm::EventSetup &iSetup) const override;
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions);

private:
const edm::EDGetTokenT<edm::View<pat::Photon>> photons_;
const edm::EDGetTokenT<edm::View<pat::Electron>> electrons_;
const edm::EDGetTokenT<edm::ValueMap<std::vector<reco::PFCandidateRef>>> photon2pf_, electron2pf_;

template <typename T>
void run(edm::Event &iEvent,
const edm::EDGetTokenT<edm::View<T>> &colltoken,
const edm::EDGetTokenT<edm::ValueMap<std::vector<reco::PFCandidateRef>>> &oldmaptoken,
const std::string &name) const {
auto const &coll = iEvent.get(colltoken);

edm::Handle<edm::ValueMap<std::vector<reco::PFCandidateRef>>> oldmap;
iEvent.getByToken(oldmaptoken, oldmap);

auto result = std::make_unique<std::vector<reco::VertexCompositePtrCandidate>>();
for (auto const &obj : coll) {
result->push_back(reco::VertexCompositePtrCandidate(obj));
for (reco::PFCandidateRef pfRef : (*oldmap)[obj.originalObjectRef()])
result->back().addDaughter(refToPtr(pfRef));
}
iEvent.put(std::move(result), name);
}
};

PFEGammaToCandidate::PFEGammaToCandidate(const edm::ParameterSet &iConfig)
: photons_(consumes<edm::View<pat::Photon>>(iConfig.getParameter<edm::InputTag>("photons"))),
electrons_(consumes<edm::View<pat::Electron>>(iConfig.getParameter<edm::InputTag>("electrons"))),
photon2pf_(
consumes<edm::ValueMap<std::vector<reco::PFCandidateRef>>>(iConfig.getParameter<edm::InputTag>("photon2pf"))),
electron2pf_(consumes<edm::ValueMap<std::vector<reco::PFCandidateRef>>>(
iConfig.getParameter<edm::InputTag>("electron2pf"))) {
produces<std::vector<reco::VertexCompositePtrCandidate>>("photons");
produces<std::vector<reco::VertexCompositePtrCandidate>>("electrons");
}

void PFEGammaToCandidate::produce(edm::StreamID iID, edm::Event &iEvent, const edm::EventSetup &iSetup) const {
run<pat::Photon>(iEvent, photons_, photon2pf_, "photons");
run<pat::Electron>(iEvent, electrons_, electron2pf_, "electrons");
}

void PFEGammaToCandidate::fillDescriptions(edm::ConfigurationDescriptions &descriptions) {
edm::ParameterSetDescription desc;
desc.add<edm::InputTag>("photons", edm::InputTag("selectedPatPhotons"));
desc.add<edm::InputTag>("electrons", edm::InputTag("selectedPatElectrons"));
desc.add<edm::InputTag>("photon2pf", edm::InputTag("particleBasedIsolation", "gedPhotons"));
desc.add<edm::InputTag>("electron2pf", edm::InputTag("particleBasedIsolation", "gedGsfElectrons"));
descriptions.addWithDefaultLabel(desc);
}

#include "FWCore/Framework/interface/MakerMacros.h"
DEFINE_FWK_MODULE(PFEGammaToCandidate);