From 9ad852cad6ad100d6d2d5de5f5f2a8ddc527d389 Mon Sep 17 00:00:00 2001 From: Jonas Rembser Date: Thu, 2 Sep 2021 11:37:18 +0200 Subject: [PATCH 1/3] Merge .cc and .h for CommonTools/ParticleFlow and PileupAlgos plugins --- .../ParticleFlow/plugins/DeltaBetaWeights.cc | 39 ++- .../ParticleFlow/plugins/DeltaBetaWeights.h | 41 --- .../plugins/PFCandIsolatorFromDeposit.cc | 71 ++++- .../plugins/PFCandIsolatorFromDeposit.h | 68 ----- ...cer.h => PFCandidateFromFwdPtrProducer.cc} | 6 + ...h => PFCandidateFwdPtrCollectionFilter.cc} | 4 + ...wdPtrProducer.h => PFJetFwdPtrProducer.cc} | 3 + CommonTools/ParticleFlow/plugins/PFMET.cc | 42 ++- CommonTools/ParticleFlow/plugins/PFMET.h | 45 ---- ...wdPtrProducer.h => PFTauFwdPtrProducer.cc} | 3 + .../ParticleFlow/plugins/SealModule.cc | 21 -- .../ParticleFlow/plugins/TopProjector.cc | 253 +++++++++++++++++- .../ParticleFlow/plugins/TopProjector.h | 252 ----------------- .../PileupAlgos/plugins/PuppiPhoton.cc | 76 ++++-- CommonTools/PileupAlgos/plugins/PuppiPhoton.h | 53 ---- .../PileupAlgos/plugins/PuppiProducer.cc | 102 +++++-- .../PileupAlgos/plugins/PuppiProducer.h | 87 ------ 17 files changed, 527 insertions(+), 639 deletions(-) delete mode 100644 CommonTools/ParticleFlow/plugins/DeltaBetaWeights.h delete mode 100644 CommonTools/ParticleFlow/plugins/PFCandIsolatorFromDeposit.h rename CommonTools/ParticleFlow/plugins/{PFCandidateFromFwdPtrProducer.h => PFCandidateFromFwdPtrProducer.cc} (60%) rename CommonTools/ParticleFlow/plugins/{PFCandidateFwdPtrCollectionFilter.h => PFCandidateFwdPtrCollectionFilter.cc} (83%) rename CommonTools/ParticleFlow/plugins/{PFJetFwdPtrProducer.h => PFJetFwdPtrProducer.cc} (71%) delete mode 100644 CommonTools/ParticleFlow/plugins/PFMET.h rename CommonTools/ParticleFlow/plugins/{PFTauFwdPtrProducer.h => PFTauFwdPtrProducer.cc} (70%) delete mode 100644 CommonTools/ParticleFlow/plugins/SealModule.cc delete mode 100644 CommonTools/ParticleFlow/plugins/TopProjector.h delete mode 100644 CommonTools/PileupAlgos/plugins/PuppiPhoton.h delete mode 100644 CommonTools/PileupAlgos/plugins/PuppiProducer.h diff --git a/CommonTools/ParticleFlow/plugins/DeltaBetaWeights.cc b/CommonTools/ParticleFlow/plugins/DeltaBetaWeights.cc index b6f8165d64213..f95b194d050c1 100644 --- a/CommonTools/ParticleFlow/plugins/DeltaBetaWeights.cc +++ b/CommonTools/ParticleFlow/plugins/DeltaBetaWeights.cc @@ -1,5 +1,37 @@ -#include "CommonTools/ParticleFlow/plugins/DeltaBetaWeights.h" +// Weight for neutral particles based on distance with charged +// +// Original Author: Michail Bachtis,40 1-B08,+41227678176, +// Created: Mon Dec 9 13:18:05 CET 2013 +// +// edited by Pavel Jez +// + +#include "DataFormats/Math/interface/deltaR.h" +#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" +#include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h" +#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/Event.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +#include + +class DeltaBetaWeights : public edm::EDProducer { +public: + explicit DeltaBetaWeights(const edm::ParameterSet&); + ~DeltaBetaWeights() override; + +private: + void produce(edm::Event&, const edm::EventSetup&) override; + // ----------member data --------------------------- + edm::InputTag src_; + edm::InputTag pfCharged_; + edm::InputTag pfPU_; + + edm::EDGetTokenT > pfCharged_token; + edm::EDGetTokenT > pfPU_token; + edm::EDGetTokenT > src_token; +}; DeltaBetaWeights::DeltaBetaWeights(const edm::ParameterSet& iConfig) : src_(iConfig.getParameter("src")), @@ -21,9 +53,8 @@ DeltaBetaWeights::~DeltaBetaWeights() { // (e.g. close files, deallocate resources etc.) } -// -// member functions -// +#include "FWCore/Framework/interface/MakerMacros.h" +DEFINE_FWK_MODULE(DeltaBetaWeights); // ------------ method called to produce the data ------------ void DeltaBetaWeights::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { diff --git a/CommonTools/ParticleFlow/plugins/DeltaBetaWeights.h b/CommonTools/ParticleFlow/plugins/DeltaBetaWeights.h deleted file mode 100644 index 0c92f4b9cfe9d..0000000000000 --- a/CommonTools/ParticleFlow/plugins/DeltaBetaWeights.h +++ /dev/null @@ -1,41 +0,0 @@ - -// Weight for neutral particles based on distance with charged -// -// Original Author: Michail Bachtis,40 1-B08,+41227678176, -// Created: Mon Dec 9 13:18:05 CET 2013 -// -// edited by Pavel Jez -// - -// system include files -#include - -// user include files -#include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDProducer.h" -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "DataFormats/Math/interface/deltaR.h" -#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" -#include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h" - -// -// class declaration -// - -class DeltaBetaWeights : public edm::EDProducer { -public: - explicit DeltaBetaWeights(const edm::ParameterSet&); - ~DeltaBetaWeights() override; - -private: - void produce(edm::Event&, const edm::EventSetup&) override; - // ----------member data --------------------------- - edm::InputTag src_; - edm::InputTag pfCharged_; - edm::InputTag pfPU_; - - edm::EDGetTokenT > pfCharged_token; - edm::EDGetTokenT > pfPU_token; - edm::EDGetTokenT > src_token; -}; diff --git a/CommonTools/ParticleFlow/plugins/PFCandIsolatorFromDeposit.cc b/CommonTools/ParticleFlow/plugins/PFCandIsolatorFromDeposit.cc index 4de7cd12c73c5..9851b3ff68c14 100644 --- a/CommonTools/ParticleFlow/plugins/PFCandIsolatorFromDeposit.cc +++ b/CommonTools/ParticleFlow/plugins/PFCandIsolatorFromDeposit.cc @@ -1,17 +1,11 @@ -#include "CommonTools/ParticleFlow/plugins/PFCandIsolatorFromDeposit.h" - -// Framework -#include "FWCore/Framework/interface/EDProducer.h" -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/EventSetup.h" -#include "DataFormats/Common/interface/Handle.h" -#include "FWCore/Framework/interface/MakerMacros.h" - -#include "FWCore/Framework/interface/ESHandle.h" - +#include "CommonTools/Utils/interface/StringObjectFunction.h" #include "DataFormats/Candidate/interface/CandAssociation.h" +#include "DataFormats/Candidate/interface/Candidate.h" +#include "DataFormats/Common/interface/Handle.h" +#include "DataFormats/Common/interface/OwnVector.h" #include "DataFormats/EcalDetId/interface/EcalSubdetector.h" #include "DataFormats/MuonReco/interface/Muon.h" +#include "DataFormats/MuonReco/interface/MuonFwd.h" #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" #include "DataFormats/RecoCandidate/interface/IsoDeposit.h" #include "DataFormats/RecoCandidate/interface/IsoDepositDirection.h" @@ -19,13 +13,64 @@ #include "DataFormats/RecoCandidate/interface/IsoDepositVetos.h" #include "DataFormats/RecoCandidate/interface/RecoCandidate.h" #include "DataFormats/TrackReco/interface/Track.h" +#include "DataFormats/TrackReco/interface/TrackFwd.h" +#include "FWCore/Framework/interface/ConsumesCollector.h" +#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" -#include +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "PhysicsTools/IsolationAlgos/interface/EventDependentAbsVeto.h" +#include "PhysicsTools/IsolationAlgos/interface/IsoDepositVetoFactory.h" +#include #include #include -#include "PhysicsTools/IsolationAlgos/interface/IsoDepositVetoFactory.h" +class PFCandIsolatorFromDeposits : public edm::stream::EDProducer<> { +public: + typedef edm::ValueMap CandDoubleMap; + + enum Mode { Sum, SumRelative, Sum2, Sum2Relative, Max, MaxRelative, Count, NearestDR }; + PFCandIsolatorFromDeposits(const edm::ParameterSet &); + + ~PFCandIsolatorFromDeposits() override; + + void produce(edm::Event &, const edm::EventSetup &) override; + +private: + class SingleDeposit { + public: + SingleDeposit(const edm::ParameterSet &, edm::ConsumesCollector &&iC); + void cleanup(); + void open(const edm::Event &iEvent, const edm::EventSetup &iSetup); + double compute(const reco::CandidateBaseRef &cand); + const reco::IsoDepositMap &map() { return *hDeps_; } + + private: + Mode mode_; + edm::EDGetTokenT srcToken_; + double deltaR_; + bool usesFunction_; + double weight_; + + StringObjectFunction weightExpr_; + reco::isodeposit::AbsVetos barrelVetos_; + reco::isodeposit::AbsVetos endcapVetos_; + reco::isodeposit::EventDependentAbsVetos evdepVetos_; // note: these are a subset of the above. Don't delete twice! + bool skipDefaultVeto_; + bool usePivotForBarrelEndcaps_; + edm::Handle hDeps_; // transient + + bool isNumber(const std::string &str) const; + double toNumber(const std::string &str) const; + }; + // datamembers + std::vector sources_; +}; using namespace edm; using namespace reco; diff --git a/CommonTools/ParticleFlow/plugins/PFCandIsolatorFromDeposit.h b/CommonTools/ParticleFlow/plugins/PFCandIsolatorFromDeposit.h deleted file mode 100644 index 77bbc20bde3de..0000000000000 --- a/CommonTools/ParticleFlow/plugins/PFCandIsolatorFromDeposit.h +++ /dev/null @@ -1,68 +0,0 @@ -#ifndef PFCandIsolatorFromDeposits_H -#define PFCandIsolatorFromDeposits_H - -#include "FWCore/Framework/interface/stream/EDProducer.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "FWCore/Framework/interface/ConsumesCollector.h" - -#include "DataFormats/TrackReco/interface/TrackFwd.h" -#include "DataFormats/MuonReco/interface/MuonFwd.h" -#include "DataFormats/RecoCandidate/interface/IsoDepositFwd.h" -#include "DataFormats/RecoCandidate/interface/IsoDeposit.h" -#include "PhysicsTools/IsolationAlgos/interface/EventDependentAbsVeto.h" - -#include "DataFormats/Candidate/interface/Candidate.h" -#include "CommonTools/Utils/interface/StringObjectFunction.h" -#include "DataFormats/Common/interface/OwnVector.h" - -#include - -namespace edm { - class Event; -} -namespace edm { - class EventSetup; -} - -class PFCandIsolatorFromDeposits : public edm::stream::EDProducer<> { -public: - typedef edm::ValueMap CandDoubleMap; - - enum Mode { Sum, SumRelative, Sum2, Sum2Relative, Max, MaxRelative, Count, NearestDR }; - PFCandIsolatorFromDeposits(const edm::ParameterSet &); - - ~PFCandIsolatorFromDeposits() override; - - void produce(edm::Event &, const edm::EventSetup &) override; - -private: - class SingleDeposit { - public: - SingleDeposit(const edm::ParameterSet &, edm::ConsumesCollector &&iC); - void cleanup(); - void open(const edm::Event &iEvent, const edm::EventSetup &iSetup); - double compute(const reco::CandidateBaseRef &cand); - const reco::IsoDepositMap &map() { return *hDeps_; } - - private: - Mode mode_; - edm::EDGetTokenT srcToken_; - double deltaR_; - bool usesFunction_; - double weight_; - - StringObjectFunction weightExpr_; - reco::isodeposit::AbsVetos barrelVetos_; - reco::isodeposit::AbsVetos endcapVetos_; - reco::isodeposit::EventDependentAbsVetos evdepVetos_; // note: these are a subset of the above. Don't delete twice! - bool skipDefaultVeto_; - bool usePivotForBarrelEndcaps_; - edm::Handle hDeps_; // transient - - bool isNumber(const std::string &str) const; - double toNumber(const std::string &str) const; - }; - // datamembers - std::vector sources_; -}; -#endif diff --git a/CommonTools/ParticleFlow/plugins/PFCandidateFromFwdPtrProducer.h b/CommonTools/ParticleFlow/plugins/PFCandidateFromFwdPtrProducer.cc similarity index 60% rename from CommonTools/ParticleFlow/plugins/PFCandidateFromFwdPtrProducer.h rename to CommonTools/ParticleFlow/plugins/PFCandidateFromFwdPtrProducer.cc index bf00abfe5c274..2dd5cbb653f16 100644 --- a/CommonTools/ParticleFlow/plugins/PFCandidateFromFwdPtrProducer.h +++ b/CommonTools/ParticleFlow/plugins/PFCandidateFromFwdPtrProducer.cc @@ -1,7 +1,13 @@ #include "CommonTools/UtilAlgos/interface/ProductFromFwdPtrProducer.h" +#include "DataFormats/JetReco/interface/PFJet.h" #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" #include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h" #include "CommonTools/ParticleFlow/interface/PFCandidateWithSrcPtrFactory.h" typedef edm::ProductFromFwdPtrProducer PFCandidateFromFwdPtrProducer; +typedef edm::ProductFromFwdPtrProducer PFJetFromFwdPtrProducer; + +#include "FWCore/Framework/interface/MakerMacros.h" +DEFINE_FWK_MODULE(PFCandidateFromFwdPtrProducer); +DEFINE_FWK_MODULE(PFJetFromFwdPtrProducer); diff --git a/CommonTools/ParticleFlow/plugins/PFCandidateFwdPtrCollectionFilter.h b/CommonTools/ParticleFlow/plugins/PFCandidateFwdPtrCollectionFilter.cc similarity index 83% rename from CommonTools/ParticleFlow/plugins/PFCandidateFwdPtrCollectionFilter.h rename to CommonTools/ParticleFlow/plugins/PFCandidateFwdPtrCollectionFilter.cc index 59180562e777f..23d388f1eb890 100644 --- a/CommonTools/ParticleFlow/plugins/PFCandidateFwdPtrCollectionFilter.h +++ b/CommonTools/ParticleFlow/plugins/PFCandidateFwdPtrCollectionFilter.cc @@ -11,3 +11,7 @@ typedef edm::FwdPtrCollectionFilter PFCandidateFwdPtrCollectionPdgIdFilter; + +#include "FWCore/Framework/interface/MakerMacros.h" +DEFINE_FWK_MODULE(PFCandidateFwdPtrCollectionStringFilter); +DEFINE_FWK_MODULE(PFCandidateFwdPtrCollectionPdgIdFilter); diff --git a/CommonTools/ParticleFlow/plugins/PFJetFwdPtrProducer.h b/CommonTools/ParticleFlow/plugins/PFJetFwdPtrProducer.cc similarity index 71% rename from CommonTools/ParticleFlow/plugins/PFJetFwdPtrProducer.h rename to CommonTools/ParticleFlow/plugins/PFJetFwdPtrProducer.cc index baa72c343b8ef..9aa6ea159b46d 100644 --- a/CommonTools/ParticleFlow/plugins/PFJetFwdPtrProducer.h +++ b/CommonTools/ParticleFlow/plugins/PFJetFwdPtrProducer.cc @@ -3,3 +3,6 @@ #include "DataFormats/JetReco/interface/PFJetCollection.h" typedef edm::FwdPtrProducer PFJetFwdPtrProducer; + +#include "FWCore/Framework/interface/MakerMacros.h" +DEFINE_FWK_MODULE(PFJetFwdPtrProducer); diff --git a/CommonTools/ParticleFlow/plugins/PFMET.cc b/CommonTools/ParticleFlow/plugins/PFMET.cc index cc17a52f91b19..7810cc771598f 100644 --- a/CommonTools/ParticleFlow/plugins/PFMET.cc +++ b/CommonTools/ParticleFlow/plugins/PFMET.cc @@ -1,16 +1,45 @@ -#include "CommonTools/ParticleFlow/plugins/PFMET.h" +/**\class PFMET +\brief Computes the MET from a collection of PFCandidates. HF missing! -#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" +\todo Add HF energy to the MET calculation (access HF towers) + +\author Colin Bernet +\date february 2008 +*/ +#include "CommonTools/ParticleFlow/interface/PFMETAlgo.h" #include "DataFormats/METReco/interface/MET.h" #include "DataFormats/METReco/interface/METFwd.h" #include "DataFormats/Math/interface/LorentzVector.h" - +#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" +#include "FWCore/Framework/interface/EDProducer.h" #include "FWCore/Framework/interface/ESHandle.h" - +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Utilities/interface/Exception.h" -#include "FWCore/Framework/interface/EventSetup.h" + +#include +#include + +class PFMET : public edm::EDProducer { +public: + explicit PFMET(const edm::ParameterSet&); + + ~PFMET() override; + + void produce(edm::Event&, const edm::EventSetup&) override; + + void beginJob() override; + +private: + /// Input PFCandidates + edm::InputTag inputTagPFCandidates_; + edm::EDGetTokenT tokenPFCandidates_; + + pf2pat::PFMETAlgo pfMETAlgo_; +}; using namespace std; using namespace edm; @@ -26,6 +55,9 @@ PFMET::PFMET(const edm::ParameterSet& iConfig) : pfMETAlgo_(iConfig) { LogDebug("PFMET") << " input collection : " << inputTagPFCandidates_; } +#include "FWCore/Framework/interface/MakerMacros.h" +DEFINE_FWK_MODULE(PFMET); + PFMET::~PFMET() {} void PFMET::beginJob() {} diff --git a/CommonTools/ParticleFlow/plugins/PFMET.h b/CommonTools/ParticleFlow/plugins/PFMET.h deleted file mode 100644 index 5b7f253a61826..0000000000000 --- a/CommonTools/ParticleFlow/plugins/PFMET.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef PhysicsTools_PFCandProducer_PFMET_ -#define PhysicsTools_PFCandProducer_PFMET_ - -// system include files -#include -#include - -// user include files -#include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDProducer.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" - -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/MakerMacros.h" - -#include "CommonTools/ParticleFlow/interface/PFMETAlgo.h" - -/**\class PFMET -\brief Computes the MET from a collection of PFCandidates. HF missing! - -\todo Add HF energy to the MET calculation (access HF towers) - -\author Colin Bernet -\date february 2008 -*/ - -class PFMET : public edm::EDProducer { -public: - explicit PFMET(const edm::ParameterSet&); - - ~PFMET() override; - - void produce(edm::Event&, const edm::EventSetup&) override; - - void beginJob() override; - -private: - /// Input PFCandidates - edm::InputTag inputTagPFCandidates_; - edm::EDGetTokenT tokenPFCandidates_; - - pf2pat::PFMETAlgo pfMETAlgo_; -}; - -#endif diff --git a/CommonTools/ParticleFlow/plugins/PFTauFwdPtrProducer.h b/CommonTools/ParticleFlow/plugins/PFTauFwdPtrProducer.cc similarity index 70% rename from CommonTools/ParticleFlow/plugins/PFTauFwdPtrProducer.h rename to CommonTools/ParticleFlow/plugins/PFTauFwdPtrProducer.cc index b6bf2053c90b4..920402228451a 100644 --- a/CommonTools/ParticleFlow/plugins/PFTauFwdPtrProducer.h +++ b/CommonTools/ParticleFlow/plugins/PFTauFwdPtrProducer.cc @@ -3,3 +3,6 @@ #include "DataFormats/TauReco/interface/PFTauFwd.h" typedef edm::FwdPtrProducer PFTauFwdPtrProducer; + +#include "FWCore/Framework/interface/MakerMacros.h" +DEFINE_FWK_MODULE(PFTauFwdPtrProducer); diff --git a/CommonTools/ParticleFlow/plugins/SealModule.cc b/CommonTools/ParticleFlow/plugins/SealModule.cc deleted file mode 100644 index 134fee6951bf8..0000000000000 --- a/CommonTools/ParticleFlow/plugins/SealModule.cc +++ /dev/null @@ -1,21 +0,0 @@ -#include "FWCore/Framework/interface/MakerMacros.h" - -#include "CommonTools/ParticleFlow/plugins/PFMET.h" -#include "CommonTools/ParticleFlow/plugins/PFCandidateFwdPtrCollectionFilter.h" -#include "CommonTools/ParticleFlow/plugins/PFJetFwdPtrProducer.h" -#include "CommonTools/ParticleFlow/plugins/PFTauFwdPtrProducer.h" -#include "CommonTools/ParticleFlow/plugins/PFCandidateFromFwdPtrProducer.h" -#include "CommonTools/ParticleFlow/plugins/DeltaBetaWeights.h" - -DEFINE_FWK_MODULE(PFMET); - -DEFINE_FWK_MODULE(PFCandidateFwdPtrCollectionStringFilter); -DEFINE_FWK_MODULE(PFCandidateFwdPtrCollectionPdgIdFilter); -DEFINE_FWK_MODULE(PFJetFwdPtrProducer); -DEFINE_FWK_MODULE(PFTauFwdPtrProducer); -DEFINE_FWK_MODULE(PFCandidateFromFwdPtrProducer); - -typedef edm::ProductFromFwdPtrProducer PFJetFromFwdPtrProducer; -DEFINE_FWK_MODULE(PFJetFromFwdPtrProducer); - -DEFINE_FWK_MODULE(DeltaBetaWeights); diff --git a/CommonTools/ParticleFlow/plugins/TopProjector.cc b/CommonTools/ParticleFlow/plugins/TopProjector.cc index 40cba4ecfb171..6b30fd6e4dc1b 100644 --- a/CommonTools/ParticleFlow/plugins/TopProjector.cc +++ b/CommonTools/ParticleFlow/plugins/TopProjector.cc @@ -1,26 +1,250 @@ -#include "CommonTools/ParticleFlow/plugins/TopProjector.h" +/**\class TopProjector +\brief -#include "DataFormats/ParticleFlowCandidate/interface/PileUpPFCandidate.h" -#include "DataFormats/ParticleFlowCandidate/interface/PileUpPFCandidateFwd.h" -#include "DataFormats/ParticleFlowCandidate/interface/IsolatedPFCandidate.h" -#include "DataFormats/ParticleFlowCandidate/interface/IsolatedPFCandidateFwd.h" +\author Colin Bernet +\date february 2008 +*/ + +#include "DataFormats/Candidate/interface/CandidateFwd.h" +#include "DataFormats/Candidate/interface/OverlapChecker.h" #include "DataFormats/JetReco/interface/PFJet.h" #include "DataFormats/JetReco/interface/PFJetCollection.h" +#include "DataFormats/Math/interface/deltaR.h" +#include "DataFormats/ParticleFlowCandidate/interface/IsolatedPFCandidate.h" +#include "DataFormats/ParticleFlowCandidate/interface/IsolatedPFCandidateFwd.h" +#include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h" +#include "DataFormats/ParticleFlowCandidate/interface/PileUpPFCandidate.h" +#include "DataFormats/ParticleFlowCandidate/interface/PileUpPFCandidateFwd.h" +#include "DataFormats/Provenance/interface/ProductID.h" #include "DataFormats/TauReco/interface/PFTau.h" #include "DataFormats/TauReco/interface/PFTauFwd.h" - -//TODO just for testing, remove this #include "DataFormats/TrackReco/interface/Track.h" - #include "FWCore/Framework/interface/ESHandle.h" - -// #include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "FWCore/Utilities/interface/Exception.h" +#include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" +#include "FWCore/Utilities/interface/Exception.h" -#include "DataFormats/Math/interface/deltaR.h" +#include +#include +#include -#include "FWCore/Framework/interface/MakerMacros.h" +/// This checks a slew of possible overlaps for FwdPtr and derivatives. +template +class TopProjectorFwdPtrOverlap { +public: + typedef edm::FwdPtr TopFwdPtr; + typedef edm::FwdPtr BottomFwdPtr; + + explicit TopProjectorFwdPtrOverlap() { bottom_ = 0; } + + explicit TopProjectorFwdPtrOverlap(edm::ParameterSet const& iConfig) + : bottom_(nullptr), matchByPtrDirect_(iConfig.getParameter("matchByPtrDirect")) {} + + inline void setBottom(BottomFwdPtr const& bottom) { bottom_ = ⊥ } + + bool operator()(TopFwdPtr const& top) const { + if (std::is_same::value && matchByPtrDirect_) + return top.ptr().refCore() == bottom_->ptr().refCore() && top.ptr().key() == bottom_->ptr().key(); + bool topFwdGood = top.ptr().isNonnull() && top.ptr().isAvailable(); + bool topBckGood = top.backPtr().isNonnull() && top.backPtr().isAvailable(); + bool bottomFwdGood = bottom_->ptr().isNonnull() && bottom_->ptr().isAvailable(); + bool bottomBckGood = bottom_->backPtr().isNonnull() && bottom_->backPtr().isAvailable(); + + bool matched = (topFwdGood && bottomFwdGood && top.ptr().refCore() == bottom_->ptr().refCore() && + top.ptr().key() == bottom_->ptr().key()) || + (topFwdGood && bottomBckGood && top.ptr().refCore() == bottom_->backPtr().refCore() && + top.ptr().key() == bottom_->backPtr().key()) || + (topBckGood && bottomFwdGood && top.backPtr().refCore() == bottom_->ptr().refCore() && + top.backPtr().key() == bottom_->ptr().key()) || + (topBckGood && bottomBckGood && top.backPtr().refCore() == bottom_->backPtr().refCore() && + top.backPtr().key() == bottom_->backPtr().key()); + if (!matched) { + for (unsigned isource = 0; isource < top->numberOfSourceCandidatePtrs(); ++isource) { + reco::CandidatePtr const& topSrcPtr = top->sourceCandidatePtr(isource); + bool topSrcGood = topSrcPtr.isNonnull() && topSrcPtr.isAvailable(); + if ((topSrcGood && bottomFwdGood && topSrcPtr.refCore() == bottom_->ptr().refCore() && + topSrcPtr.key() == bottom_->ptr().key()) || + (topSrcGood && bottomBckGood && topSrcPtr.refCore() == bottom_->backPtr().refCore() && + topSrcPtr.key() == bottom_->backPtr().key())) { + matched = true; + break; + } + } + } + if (!matched) { + for (unsigned isource = 0; isource < (*bottom_)->numberOfSourceCandidatePtrs(); ++isource) { + reco::CandidatePtr const& bottomSrcPtr = (*bottom_)->sourceCandidatePtr(isource); + bool bottomSrcGood = bottomSrcPtr.isNonnull() && bottomSrcPtr.isAvailable(); + if ((topFwdGood && bottomSrcGood && bottomSrcPtr.refCore() == top.ptr().refCore() && + bottomSrcPtr.key() == top.ptr().key()) || + (topBckGood && bottomSrcGood && bottomSrcPtr.refCore() == top.backPtr().refCore() && + bottomSrcPtr.key() == top.backPtr().key())) { + matched = true; + break; + } + } + } + + return matched; + } + +protected: + BottomFwdPtr const* bottom_; + const bool matchByPtrDirect_ = false; +}; + +/// This checks matching based on delta R +template +class TopProjectorDeltaROverlap { +public: + typedef edm::FwdPtr TopFwdPtr; + typedef edm::FwdPtr BottomFwdPtr; + + explicit TopProjectorDeltaROverlap() { bottom_ = 0; } + explicit TopProjectorDeltaROverlap(edm::ParameterSet const& config) + : deltaR2_(config.getParameter("deltaR")), + bottom_(nullptr), + bottomCPtr_(nullptr), + botEta_(-999.f), + botPhi_(0.f) { + deltaR2_ *= deltaR2_; + } + + inline void setBottom(BottomFwdPtr const& bottom) { + bottom_ = ⊥ + bottomCPtr_ = &**bottom_; + botEta_ = bottomCPtr_->eta(); + botPhi_ = bottomCPtr_->phi(); + } + + bool operator()(TopFwdPtr const& top) const { + const Top& oTop = *top; + float topEta = oTop.eta(); + float topPhi = oTop.phi(); + bool matched = reco::deltaR2(topEta, topPhi, botEta_, botPhi_) < deltaR2_; + return matched; + } + +protected: + double deltaR2_; + BottomFwdPtr const* bottom_; + const Bottom* bottomCPtr_; + float botEta_, botPhi_; +}; + +template > +class TopProjector : public edm::stream::EDProducer<> { +public: + typedef std::vector TopCollection; + typedef edm::FwdPtr TopFwdPtr; + typedef std::vector TopFwdPtrCollection; + + typedef std::vector BottomCollection; + typedef edm::FwdPtr BottomFwdPtr; + typedef std::vector BottomFwdPtrCollection; + + TopProjector(const edm::ParameterSet&); + + ~TopProjector() override = default; + + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + + void produce(edm::Event&, const edm::EventSetup&) override; + +private: + /// Matching method. + Matcher match_; + + /// enable? if not, all candidates in the bottom collection are copied to the output collection + const bool enable_; + + /// name of the top projection + const std::string name_; + + /// input tag for the top (masking) collection + const edm::EDGetTokenT tokenTop_; + + /// input tag for the masked collection. + const edm::EDGetTokenT tokenBottom_; +}; + +template +TopProjector::TopProjector(const edm::ParameterSet& iConfig) + : match_(iConfig), + enable_(iConfig.getParameter("enable")), + name_(iConfig.getUntrackedParameter("name", "No Name")), + tokenTop_(consumes(iConfig.getParameter("topCollection"))), + tokenBottom_(consumes(iConfig.getParameter("bottomCollection"))) { + // will produce a collection of the unmasked candidates in the + // bottom collection + produces(); +} + +template +void TopProjector::fillDescriptions(edm::ConfigurationDescriptions& desc) { + edm::ParameterSetDescription psD; + psD.add("enable"); + if (std::is_same>::value) + psD.add("deltaR"); + psD.addUntracked("name", "No Name"); + psD.add("topCollection"); + psD.add("bottomCollection"); + if (std::is_same>::value) + psD.add("matchByPtrDirect", false)->setComment("fast check by ptr() only"); + desc.addWithDefaultLabel(psD); +} + +template +void TopProjector::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { + // get the various collections + + // Access the masking collection + auto const& tops = iEvent.get(tokenTop_); + std::list topsList; + + for (auto const& top : tops) { + topsList.push_back(top); + } + + // Access the collection to + // be masked by the other ones + auto const& bottoms = iEvent.get(tokenBottom_); + + // output collection of FwdPtrs to objects, + // selected from the Bottom collection + std::unique_ptr pBottomFwdPtrOutput(new BottomFwdPtrCollection); + + LogDebug("TopProjection") << " Remaining candidates in the bottom collection ------ "; + + int iB = -1; + for (auto const& bottom : bottoms) { + iB++; + match_.setBottom(bottom); + auto found = topsList.end(); + if (enable_) { + found = std::find_if(topsList.begin(), topsList.end(), match_); + } + + // If this is masked in the top projection, we remove it. + if (found != topsList.end()) { + LogDebug("TopProjection") << "X " << iB << *bottom; + topsList.erase(found); + continue; + } + // otherwise, we keep it. + else { + LogDebug("TopProjection") << "O " << iB << *bottom; + pBottomFwdPtrOutput->push_back(bottom); + } + } + + iEvent.put(std::move(pBottomFwdPtrOutput)); +} using namespace std; using namespace edm; @@ -33,8 +257,9 @@ typedef TopProjector TPIsolatedPFCandidatesOnP typedef TopProjector TPPFCandidatesOnPileUpPFCandidates; typedef TopProjector TPPFTausOnPFJets; -typedef TopProjector > TPPFTausOnPFJetsDeltaR; +typedef TopProjector> TPPFTausOnPFJetsDeltaR; +#include "FWCore/Framework/interface/MakerMacros.h" DEFINE_FWK_MODULE(TPPFJetsOnPFCandidates); DEFINE_FWK_MODULE(TPPFCandidatesOnPFCandidates); DEFINE_FWK_MODULE(TPPileUpPFCandidatesOnPFCandidates); diff --git a/CommonTools/ParticleFlow/plugins/TopProjector.h b/CommonTools/ParticleFlow/plugins/TopProjector.h deleted file mode 100644 index 7b4015c2b97cc..0000000000000 --- a/CommonTools/ParticleFlow/plugins/TopProjector.h +++ /dev/null @@ -1,252 +0,0 @@ -#ifndef CommonTools_ParticleFlow_TopProjector_ -#define CommonTools_ParticleFlow_TopProjector_ - -// system include files -#include -#include -#include - -// user include files -#include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/stream/EDProducer.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" - -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/MakerMacros.h" - -#include "DataFormats/Provenance/interface/ProductID.h" - -#include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h" -#include "DataFormats/TauReco/interface/PFTau.h" -#include "DataFormats/JetReco/interface/PFJet.h" - -#include "DataFormats/Candidate/interface/CandidateFwd.h" -#include "DataFormats/Candidate/interface/OverlapChecker.h" - -#include "DataFormats/Math/interface/deltaR.h" - -#include "FWCore/MessageLogger/interface/MessageLogger.h" - -/**\class TopProjector -\brief - -\author Colin Bernet -\date february 2008 -*/ - -#include - -/// This checks a slew of possible overlaps for FwdPtr and derivatives. -template -class TopProjectorFwdPtrOverlap { -public: - typedef edm::FwdPtr TopFwdPtr; - typedef edm::FwdPtr BottomFwdPtr; - - explicit TopProjectorFwdPtrOverlap() { bottom_ = 0; } - - explicit TopProjectorFwdPtrOverlap(edm::ParameterSet const& iConfig) - : bottom_(nullptr), matchByPtrDirect_(iConfig.getParameter("matchByPtrDirect")) {} - - inline void setBottom(BottomFwdPtr const& bottom) { bottom_ = ⊥ } - - bool operator()(TopFwdPtr const& top) const { - if (std::is_same::value && matchByPtrDirect_) - return top.ptr().refCore() == bottom_->ptr().refCore() && top.ptr().key() == bottom_->ptr().key(); - bool topFwdGood = top.ptr().isNonnull() && top.ptr().isAvailable(); - bool topBckGood = top.backPtr().isNonnull() && top.backPtr().isAvailable(); - bool bottomFwdGood = bottom_->ptr().isNonnull() && bottom_->ptr().isAvailable(); - bool bottomBckGood = bottom_->backPtr().isNonnull() && bottom_->backPtr().isAvailable(); - - bool matched = (topFwdGood && bottomFwdGood && top.ptr().refCore() == bottom_->ptr().refCore() && - top.ptr().key() == bottom_->ptr().key()) || - (topFwdGood && bottomBckGood && top.ptr().refCore() == bottom_->backPtr().refCore() && - top.ptr().key() == bottom_->backPtr().key()) || - (topBckGood && bottomFwdGood && top.backPtr().refCore() == bottom_->ptr().refCore() && - top.backPtr().key() == bottom_->ptr().key()) || - (topBckGood && bottomBckGood && top.backPtr().refCore() == bottom_->backPtr().refCore() && - top.backPtr().key() == bottom_->backPtr().key()); - if (!matched) { - for (unsigned isource = 0; isource < top->numberOfSourceCandidatePtrs(); ++isource) { - reco::CandidatePtr const& topSrcPtr = top->sourceCandidatePtr(isource); - bool topSrcGood = topSrcPtr.isNonnull() && topSrcPtr.isAvailable(); - if ((topSrcGood && bottomFwdGood && topSrcPtr.refCore() == bottom_->ptr().refCore() && - topSrcPtr.key() == bottom_->ptr().key()) || - (topSrcGood && bottomBckGood && topSrcPtr.refCore() == bottom_->backPtr().refCore() && - topSrcPtr.key() == bottom_->backPtr().key())) { - matched = true; - break; - } - } - } - if (!matched) { - for (unsigned isource = 0; isource < (*bottom_)->numberOfSourceCandidatePtrs(); ++isource) { - reco::CandidatePtr const& bottomSrcPtr = (*bottom_)->sourceCandidatePtr(isource); - bool bottomSrcGood = bottomSrcPtr.isNonnull() && bottomSrcPtr.isAvailable(); - if ((topFwdGood && bottomSrcGood && bottomSrcPtr.refCore() == top.ptr().refCore() && - bottomSrcPtr.key() == top.ptr().key()) || - (topBckGood && bottomSrcGood && bottomSrcPtr.refCore() == top.backPtr().refCore() && - bottomSrcPtr.key() == top.backPtr().key())) { - matched = true; - break; - } - } - } - - return matched; - } - -protected: - BottomFwdPtr const* bottom_; - const bool matchByPtrDirect_ = false; -}; - -/// This checks matching based on delta R -template -class TopProjectorDeltaROverlap { -public: - typedef edm::FwdPtr TopFwdPtr; - typedef edm::FwdPtr BottomFwdPtr; - - explicit TopProjectorDeltaROverlap() { bottom_ = 0; } - explicit TopProjectorDeltaROverlap(edm::ParameterSet const& config) - : deltaR2_(config.getParameter("deltaR")), - bottom_(nullptr), - bottomCPtr_(nullptr), - botEta_(-999.f), - botPhi_(0.f) { - deltaR2_ *= deltaR2_; - } - - inline void setBottom(BottomFwdPtr const& bottom) { - bottom_ = ⊥ - bottomCPtr_ = &**bottom_; - botEta_ = bottomCPtr_->eta(); - botPhi_ = bottomCPtr_->phi(); - } - - bool operator()(TopFwdPtr const& top) const { - const Top& oTop = *top; - float topEta = oTop.eta(); - float topPhi = oTop.phi(); - bool matched = reco::deltaR2(topEta, topPhi, botEta_, botPhi_) < deltaR2_; - return matched; - } - -protected: - double deltaR2_; - BottomFwdPtr const* bottom_; - const Bottom* bottomCPtr_; - float botEta_, botPhi_; -}; - -template > -class TopProjector : public edm::stream::EDProducer<> { -public: - typedef std::vector TopCollection; - typedef edm::FwdPtr TopFwdPtr; - typedef std::vector TopFwdPtrCollection; - - typedef std::vector BottomCollection; - typedef edm::FwdPtr BottomFwdPtr; - typedef std::vector BottomFwdPtrCollection; - - TopProjector(const edm::ParameterSet&); - - ~TopProjector() override = default; - - static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); - - void produce(edm::Event&, const edm::EventSetup&) override; - -private: - /// Matching method. - Matcher match_; - - /// enable? if not, all candidates in the bottom collection are copied to the output collection - const bool enable_; - - /// name of the top projection - const std::string name_; - - /// input tag for the top (masking) collection - const edm::EDGetTokenT tokenTop_; - - /// input tag for the masked collection. - const edm::EDGetTokenT tokenBottom_; -}; - -template -TopProjector::TopProjector(const edm::ParameterSet& iConfig) - : match_(iConfig), - enable_(iConfig.getParameter("enable")), - name_(iConfig.getUntrackedParameter("name", "No Name")), - tokenTop_(consumes(iConfig.getParameter("topCollection"))), - tokenBottom_(consumes(iConfig.getParameter("bottomCollection"))) { - // will produce a collection of the unmasked candidates in the - // bottom collection - produces(); -} - -template -void TopProjector::fillDescriptions(edm::ConfigurationDescriptions& desc) { - edm::ParameterSetDescription psD; - psD.add("enable"); - if (std::is_same>::value) - psD.add("deltaR"); - psD.addUntracked("name", "No Name"); - psD.add("topCollection"); - psD.add("bottomCollection"); - if (std::is_same>::value) - psD.add("matchByPtrDirect", false)->setComment("fast check by ptr() only"); - desc.addWithDefaultLabel(psD); -} - -template -void TopProjector::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { - // get the various collections - - // Access the masking collection - auto const& tops = iEvent.get(tokenTop_); - std::list topsList; - - for (auto const& top : tops) { - topsList.push_back(top); - } - - // Access the collection to - // be masked by the other ones - auto const& bottoms = iEvent.get(tokenBottom_); - - // output collection of FwdPtrs to objects, - // selected from the Bottom collection - std::unique_ptr pBottomFwdPtrOutput(new BottomFwdPtrCollection); - - LogDebug("TopProjection") << " Remaining candidates in the bottom collection ------ "; - - int iB = -1; - for (auto const& bottom : bottoms) { - iB++; - match_.setBottom(bottom); - auto found = topsList.end(); - if (enable_) { - found = std::find_if(topsList.begin(), topsList.end(), match_); - } - - // If this is masked in the top projection, we remove it. - if (found != topsList.end()) { - LogDebug("TopProjection") << "X " << iB << *bottom; - topsList.erase(found); - continue; - } - // otherwise, we keep it. - else { - LogDebug("TopProjection") << "O " << iB << *bottom; - pBottomFwdPtrOutput->push_back(bottom); - } - } - - iEvent.put(std::move(pBottomFwdPtrOutput)); -} - -#endif diff --git a/CommonTools/PileupAlgos/plugins/PuppiPhoton.cc b/CommonTools/PileupAlgos/plugins/PuppiPhoton.cc index 5b9ed019b1b64..d69f0d722d681 100644 --- a/CommonTools/PileupAlgos/plugins/PuppiPhoton.cc +++ b/CommonTools/PileupAlgos/plugins/PuppiPhoton.cc @@ -1,27 +1,63 @@ -// system include files -#include - -// user include files -#include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDProducer.h" -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/MakerMacros.h" -#include "FWCore/Framework/interface/ESHandle.h" -#include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "DataFormats/Common/interface/View.h" +#include "DataFormats/Candidate/interface/Candidate.h" #include "DataFormats/Candidate/interface/CandidateFwd.h" -#include "DataFormats/PatCandidates/interface/PackedCandidate.h" -#include "DataFormats/PatCandidates/interface/Photon.h" -#include "DataFormats/PatCandidates/interface/Electron.h" -#include "DataFormats/VertexReco/interface/VertexFwd.h" -#include "DataFormats/VertexReco/interface/Vertex.h" +#include "DataFormats/Common/interface/Association.h" +#include "DataFormats/Common/interface/ValueMap.h" +#include "DataFormats/Common/interface/View.h" #include "DataFormats/GsfTrackReco/interface/GsfTrack.h" #include "DataFormats/GsfTrackReco/interface/GsfTrackFwd.h" -#include "DataFormats/Common/interface/Association.h" +#include "DataFormats/Math/interface/PtEtaPhiMass.h" #include "DataFormats/Math/interface/deltaR.h" -//Main File -#include "CommonTools/PileupAlgos/plugins/PuppiPhoton.h" +#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" +#include "DataFormats/PatCandidates/interface/Electron.h" +#include "DataFormats/PatCandidates/interface/PackedCandidate.h" +#include "DataFormats/PatCandidates/interface/Photon.h" +#include "DataFormats/VertexReco/interface/Vertex.h" +#include "DataFormats/VertexReco/interface/VertexFwd.h" +#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +#include + +// ------------------------------------------------------------------------------------------ +class PuppiPhoton : public edm::stream::EDProducer<> { +public: + explicit PuppiPhoton(const edm::ParameterSet &); + ~PuppiPhoton() override; + + static void fillDescriptions(edm::ConfigurationDescriptions &descriptions); + typedef math::XYZTLorentzVector LorentzVector; + typedef std::vector LorentzVectorCollection; + typedef edm::View CandidateView; + typedef std::vector PFOutputCollection; + typedef edm::View PFView; + +private: + void produce(edm::Event &, const edm::EventSetup &) override; + bool matchPFCandidate(const reco::Candidate *iPF, const reco::Candidate *iPho); + edm::EDGetTokenT tokenPFCandidates_; + edm::EDGetTokenT tokenPuppiCandidates_; + edm::EDGetTokenT tokenPhotonCandidates_; + edm::EDGetTokenT>> reco2pf_; + edm::EDGetTokenT> tokenWeights_; + edm::EDGetTokenT> tokenPhotonId_; + double pt_; + double eta_; + bool usePFRef_; + bool usePFphotons_; + bool runOnMiniAOD_; + bool usePhotonId_; + std::vector dRMatch_; + std::vector pdgIds_; + std::unique_ptr corrCandidates_; + double weight_; + bool useValueMap_; +}; // ------------------------------------------------------------------------------------------ PuppiPhoton::PuppiPhoton(const edm::ParameterSet &iConfig) { diff --git a/CommonTools/PileupAlgos/plugins/PuppiPhoton.h b/CommonTools/PileupAlgos/plugins/PuppiPhoton.h deleted file mode 100644 index 194cc3001fe05..0000000000000 --- a/CommonTools/PileupAlgos/plugins/PuppiPhoton.h +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef CommonTools_Puppi_PuppiPhoton_h_ -#define CommonTools_Puppi_PuppiPhoton_h_ -// system include files -#include - -// user include files -#include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/stream/EDProducer.h" -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/MakerMacros.h" -#include "FWCore/Framework/interface/ESHandle.h" -#include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "DataFormats/Math/interface/PtEtaPhiMass.h" -#include "DataFormats/Candidate/interface/Candidate.h" -#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" -#include "DataFormats/Common/interface/ValueMap.h" - -// ------------------------------------------------------------------------------------------ -class PuppiPhoton : public edm::stream::EDProducer<> { -public: - explicit PuppiPhoton(const edm::ParameterSet &); - ~PuppiPhoton() override; - - static void fillDescriptions(edm::ConfigurationDescriptions &descriptions); - typedef math::XYZTLorentzVector LorentzVector; - typedef std::vector LorentzVectorCollection; - typedef edm::View CandidateView; - typedef std::vector PFOutputCollection; - typedef edm::View PFView; - -private: - void produce(edm::Event &, const edm::EventSetup &) override; - bool matchPFCandidate(const reco::Candidate *iPF, const reco::Candidate *iPho); - edm::EDGetTokenT tokenPFCandidates_; - edm::EDGetTokenT tokenPuppiCandidates_; - edm::EDGetTokenT tokenPhotonCandidates_; - edm::EDGetTokenT > > reco2pf_; - edm::EDGetTokenT > tokenWeights_; - edm::EDGetTokenT > tokenPhotonId_; - double pt_; - double eta_; - bool usePFRef_; - bool usePFphotons_; - bool runOnMiniAOD_; - bool usePhotonId_; - std::vector dRMatch_; - std::vector pdgIds_; - std::unique_ptr corrCandidates_; - double weight_; - bool useValueMap_; -}; -#endif diff --git a/CommonTools/PileupAlgos/plugins/PuppiProducer.cc b/CommonTools/PileupAlgos/plugins/PuppiProducer.cc index a04967339319e..0d6c3bdfda83b 100644 --- a/CommonTools/PileupAlgos/plugins/PuppiProducer.cc +++ b/CommonTools/PileupAlgos/plugins/PuppiProducer.cc @@ -1,23 +1,93 @@ -// system include files -#include - -// user include files -#include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDProducer.h" -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/MakerMacros.h" -#include "DataFormats/Common/interface/ValueMap.h" -#include "FWCore/Framework/interface/ESHandle.h" -#include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "DataFormats/Common/interface/View.h" +#include "CommonTools/PileupAlgos/interface/PuppiAlgo.h" +#include "CommonTools/PileupAlgos/interface/PuppiContainer.h" #include "DataFormats/Candidate/interface/Candidate.h" #include "DataFormats/Candidate/interface/CandidateFwd.h" +#include "DataFormats/Common/interface/Association.h" +#include "DataFormats/Common/interface/ValueMap.h" +#include "DataFormats/Common/interface/View.h" #include "DataFormats/GsfTrackReco/interface/GsfTrack.h" #include "DataFormats/GsfTrackReco/interface/GsfTrackFwd.h" -#include "DataFormats/Common/interface/Association.h" -//Main File -#include "CommonTools/PileupAlgos/plugins/PuppiProducer.h" +#include "DataFormats/Math/interface/LorentzVector.h" +#include "DataFormats/Math/interface/PtEtaPhiMass.h" +#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" +#include "DataFormats/PatCandidates/interface/PackedCandidate.h" +#include "DataFormats/VertexReco/interface/VertexFwd.h" +#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +#include + +// ------------------------------------------------------------------------------------------ +class PuppiProducer : public edm::stream::EDProducer<> { +public: + explicit PuppiProducer(const edm::ParameterSet&); + ~PuppiProducer() override; + + static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); + typedef math::XYZTLorentzVector LorentzVector; + typedef std::vector LorentzVectorCollection; + typedef reco::VertexCollection VertexCollection; + typedef edm::View CandidateView; + typedef std::vector PFInputCollection; + typedef std::vector PFOutputCollection; + typedef std::vector PackedOutputCollection; + typedef edm::View PFView; + typedef edm::Association CandToVertex; + +private: + virtual void beginJob(); + void produce(edm::Event&, const edm::EventSetup&) override; + virtual void endJob(); + + edm::EDGetTokenT tokenPFCandidates_; + edm::EDGetTokenT tokenVertices_; + edm::EDGetTokenT tokenVertexAssociation_; + edm::EDGetTokenT> tokenVertexAssociationQuality_; + edm::EDGetTokenT tokenPuppiContainer_; + edm::EDGetTokenT tokenPuppiCandidates_; + edm::EDGetTokenT tokenPackedPuppiCandidates_; + edm::EDGetTokenT puProxyValueToken_; + edm::EDPutTokenT> ptokenPupOut_; + edm::EDPutTokenT> ptokenP4PupOut_; + edm::EDPutTokenT> ptokenValues_; + edm::EDPutTokenT ptokenPackedPuppiCandidates_; + edm::EDPutTokenT ptokenPuppiCandidates_; + edm::EDPutTokenT ptokenNalgos_; + edm::EDPutTokenT> ptokenRawAlphas_; + edm::EDPutTokenT> ptokenAlphas_; + edm::EDPutTokenT> ptokenAlphasMed_; + edm::EDPutTokenT> ptokenAlphasRms_; + std::string fPuppiName; + std::string fPFName; + std::string fPVName; + bool fUseVertexAssociation; + int vertexAssociationQuality_; + bool fPuppiDiagnostics; + bool fPuppiNoLep; + bool fUseFromPVLooseTight; + bool fUseDZ; + double fDZCut; + double fEtaMinUseDZ; + double fPtMaxCharged; + double fEtaMaxCharged; + double fPtMaxPhotons; + double fEtaMaxPhotons; + uint fNumOfPUVtxsForCharged; + double fDZCutForChargedFromPUVtxs; + bool fUseExistingWeights; + bool fClonePackedCands; + int fVtxNdofCut; + double fVtxZCut; + bool fUsePUProxyValue; + std::unique_ptr fPuppiContainer; + std::vector fRecoObjCollection; +}; // ------------------------------------------------------------------------------------------ PuppiProducer::PuppiProducer(const edm::ParameterSet& iConfig) { diff --git a/CommonTools/PileupAlgos/plugins/PuppiProducer.h b/CommonTools/PileupAlgos/plugins/PuppiProducer.h deleted file mode 100644 index bef5c7d797646..0000000000000 --- a/CommonTools/PileupAlgos/plugins/PuppiProducer.h +++ /dev/null @@ -1,87 +0,0 @@ -#ifndef CommonTools_Puppi_PuppiProducer_h_ -#define CommonTools_Puppi_PuppiProducer_h_ -// system include files -#include - -// user include files -#include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/stream/EDProducer.h" -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/MakerMacros.h" -#include "FWCore/Framework/interface/ESHandle.h" -#include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" -#include "DataFormats/Math/interface/PtEtaPhiMass.h" -#include "DataFormats/Math/interface/LorentzVector.h" -#include "DataFormats/VertexReco/interface/VertexFwd.h" -#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" -#include "DataFormats/PatCandidates/interface/PackedCandidate.h" -#include "CommonTools/PileupAlgos/interface/PuppiContainer.h" -#include "CommonTools/PileupAlgos/interface/PuppiAlgo.h" - -// ------------------------------------------------------------------------------------------ -class PuppiProducer : public edm::stream::EDProducer<> { -public: - explicit PuppiProducer(const edm::ParameterSet&); - ~PuppiProducer() override; - - static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); - typedef math::XYZTLorentzVector LorentzVector; - typedef std::vector LorentzVectorCollection; - typedef reco::VertexCollection VertexCollection; - typedef edm::View CandidateView; - typedef std::vector PFInputCollection; - typedef std::vector PFOutputCollection; - typedef std::vector PackedOutputCollection; - typedef edm::View PFView; - typedef edm::Association CandToVertex; - -private: - virtual void beginJob(); - void produce(edm::Event&, const edm::EventSetup&) override; - virtual void endJob(); - - edm::EDGetTokenT tokenPFCandidates_; - edm::EDGetTokenT tokenVertices_; - edm::EDGetTokenT tokenVertexAssociation_; - edm::EDGetTokenT> tokenVertexAssociationQuality_; - edm::EDGetTokenT tokenPuppiContainer_; - edm::EDGetTokenT tokenPuppiCandidates_; - edm::EDGetTokenT tokenPackedPuppiCandidates_; - edm::EDGetTokenT puProxyValueToken_; - edm::EDPutTokenT> ptokenPupOut_; - edm::EDPutTokenT> ptokenP4PupOut_; - edm::EDPutTokenT> ptokenValues_; - edm::EDPutTokenT ptokenPackedPuppiCandidates_; - edm::EDPutTokenT ptokenPuppiCandidates_; - edm::EDPutTokenT ptokenNalgos_; - edm::EDPutTokenT> ptokenRawAlphas_; - edm::EDPutTokenT> ptokenAlphas_; - edm::EDPutTokenT> ptokenAlphasMed_; - edm::EDPutTokenT> ptokenAlphasRms_; - std::string fPuppiName; - std::string fPFName; - std::string fPVName; - bool fUseVertexAssociation; - int vertexAssociationQuality_; - bool fPuppiDiagnostics; - bool fPuppiNoLep; - bool fUseFromPVLooseTight; - bool fUseDZ; - double fDZCut; - double fEtaMinUseDZ; - double fPtMaxCharged; - double fEtaMaxCharged; - double fPtMaxPhotons; - double fEtaMaxPhotons; - uint fNumOfPUVtxsForCharged; - double fDZCutForChargedFromPUVtxs; - bool fUseExistingWeights; - bool fClonePackedCands; - int fVtxNdofCut; - double fVtxZCut; - bool fUsePUProxyValue; - std::unique_ptr fPuppiContainer; - std::vector fRecoObjCollection; -}; -#endif From d62d750cdfc3980d6e76e3ed651e6d11aa400a84 Mon Sep 17 00:00:00 2001 From: Jonas Rembser Date: Fri, 3 Sep 2021 15:56:47 +0200 Subject: [PATCH 2/3] Move ShallowCloneProducer to RecoAlgos and define typenames in one file --- .../plugins/CaloJetShallowCloneProducer.cc | 8 ----- .../plugins/CaloMETShallowCloneProducer.cc | 10 ------ .../plugins/ElectronShallowCloneProducer.cc | 9 ----- .../plugins/GenJetShallowCloneProducer.cc | 8 ----- .../plugins/GenMETShallowCloneProducer.cc | 9 ----- .../GsfElectronShallowCloneProducer.cc | 9 ----- .../plugins/MuonShallowCloneProducer.cc | 9 ----- .../plugins/ShallowCloneProducer.cc} | 36 ++++++++++++++++--- 8 files changed, 32 insertions(+), 66 deletions(-) delete mode 100644 CommonTools/RecoAlgos/plugins/CaloJetShallowCloneProducer.cc delete mode 100644 CommonTools/RecoAlgos/plugins/CaloMETShallowCloneProducer.cc delete mode 100644 CommonTools/RecoAlgos/plugins/ElectronShallowCloneProducer.cc delete mode 100644 CommonTools/RecoAlgos/plugins/GenJetShallowCloneProducer.cc delete mode 100644 CommonTools/RecoAlgos/plugins/GenMETShallowCloneProducer.cc delete mode 100644 CommonTools/RecoAlgos/plugins/GsfElectronShallowCloneProducer.cc delete mode 100644 CommonTools/RecoAlgos/plugins/MuonShallowCloneProducer.cc rename CommonTools/{CandAlgos/interface/ShallowCloneProducer.h => RecoAlgos/plugins/ShallowCloneProducer.cc} (51%) diff --git a/CommonTools/RecoAlgos/plugins/CaloJetShallowCloneProducer.cc b/CommonTools/RecoAlgos/plugins/CaloJetShallowCloneProducer.cc deleted file mode 100644 index a6fa0206970cc..0000000000000 --- a/CommonTools/RecoAlgos/plugins/CaloJetShallowCloneProducer.cc +++ /dev/null @@ -1,8 +0,0 @@ -#include "DataFormats/JetReco/interface/CaloJet.h" -#include "CommonTools/CandAlgos/interface/ShallowCloneProducer.h" - -typedef ShallowCloneProducer CaloJetShallowCloneProducer; - -#include "FWCore/Framework/interface/MakerMacros.h" - -DEFINE_FWK_MODULE(CaloJetShallowCloneProducer); diff --git a/CommonTools/RecoAlgos/plugins/CaloMETShallowCloneProducer.cc b/CommonTools/RecoAlgos/plugins/CaloMETShallowCloneProducer.cc deleted file mode 100644 index 2be9da4048dff..0000000000000 --- a/CommonTools/RecoAlgos/plugins/CaloMETShallowCloneProducer.cc +++ /dev/null @@ -1,10 +0,0 @@ -#include "DataFormats/EgammaCandidates/interface/ElectronFwd.h" -#include "DataFormats/METReco/interface/CaloMET.h" -#include "DataFormats/METReco/interface/CaloMETCollection.h" -#include "CommonTools/CandAlgos/interface/ShallowCloneProducer.h" - -typedef ShallowCloneProducer CaloMETShallowCloneProducer; - -#include "FWCore/Framework/interface/MakerMacros.h" - -DEFINE_FWK_MODULE(CaloMETShallowCloneProducer); diff --git a/CommonTools/RecoAlgos/plugins/ElectronShallowCloneProducer.cc b/CommonTools/RecoAlgos/plugins/ElectronShallowCloneProducer.cc deleted file mode 100644 index 8a37e780985f3..0000000000000 --- a/CommonTools/RecoAlgos/plugins/ElectronShallowCloneProducer.cc +++ /dev/null @@ -1,9 +0,0 @@ -#include "DataFormats/EgammaCandidates/interface/Electron.h" -#include "DataFormats/EgammaCandidates/interface/ElectronFwd.h" -#include "CommonTools/CandAlgos/interface/ShallowCloneProducer.h" - -typedef ShallowCloneProducer ElectronShallowCloneProducer; - -#include "FWCore/Framework/interface/MakerMacros.h" - -DEFINE_FWK_MODULE(ElectronShallowCloneProducer); diff --git a/CommonTools/RecoAlgos/plugins/GenJetShallowCloneProducer.cc b/CommonTools/RecoAlgos/plugins/GenJetShallowCloneProducer.cc deleted file mode 100644 index 94e50ddc9b3c2..0000000000000 --- a/CommonTools/RecoAlgos/plugins/GenJetShallowCloneProducer.cc +++ /dev/null @@ -1,8 +0,0 @@ -#include "DataFormats/JetReco/interface/GenJet.h" -#include "CommonTools/CandAlgos/interface/ShallowCloneProducer.h" - -typedef ShallowCloneProducer GenJetShallowCloneProducer; - -#include "FWCore/Framework/interface/MakerMacros.h" - -DEFINE_FWK_MODULE(GenJetShallowCloneProducer); diff --git a/CommonTools/RecoAlgos/plugins/GenMETShallowCloneProducer.cc b/CommonTools/RecoAlgos/plugins/GenMETShallowCloneProducer.cc deleted file mode 100644 index 1186417dc670b..0000000000000 --- a/CommonTools/RecoAlgos/plugins/GenMETShallowCloneProducer.cc +++ /dev/null @@ -1,9 +0,0 @@ -#include "DataFormats/METReco/interface/GenMET.h" -#include "DataFormats/METReco/interface/GenMETCollection.h" -#include "CommonTools/CandAlgos/interface/ShallowCloneProducer.h" - -typedef ShallowCloneProducer GenMETShallowCloneProducer; - -#include "FWCore/Framework/interface/MakerMacros.h" - -DEFINE_FWK_MODULE(GenMETShallowCloneProducer); diff --git a/CommonTools/RecoAlgos/plugins/GsfElectronShallowCloneProducer.cc b/CommonTools/RecoAlgos/plugins/GsfElectronShallowCloneProducer.cc deleted file mode 100644 index e1dcc23e0c8e0..0000000000000 --- a/CommonTools/RecoAlgos/plugins/GsfElectronShallowCloneProducer.cc +++ /dev/null @@ -1,9 +0,0 @@ -#include "DataFormats/EgammaCandidates/interface/GsfElectron.h" -#include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h" -#include "CommonTools/CandAlgos/interface/ShallowCloneProducer.h" - -typedef ShallowCloneProducer PixelMatchGsfElectronShallowCloneProducer; - -#include "FWCore/Framework/interface/MakerMacros.h" - -DEFINE_FWK_MODULE(PixelMatchGsfElectronShallowCloneProducer); diff --git a/CommonTools/RecoAlgos/plugins/MuonShallowCloneProducer.cc b/CommonTools/RecoAlgos/plugins/MuonShallowCloneProducer.cc deleted file mode 100644 index 0f4c2456415c9..0000000000000 --- a/CommonTools/RecoAlgos/plugins/MuonShallowCloneProducer.cc +++ /dev/null @@ -1,9 +0,0 @@ -#include "DataFormats/MuonReco/interface/Muon.h" -#include "DataFormats/MuonReco/interface/MuonFwd.h" -#include "CommonTools/CandAlgos/interface/ShallowCloneProducer.h" - -typedef ShallowCloneProducer MuonShallowCloneProducer; - -#include "FWCore/Framework/interface/MakerMacros.h" - -DEFINE_FWK_MODULE(MuonShallowCloneProducer); diff --git a/CommonTools/CandAlgos/interface/ShallowCloneProducer.h b/CommonTools/RecoAlgos/plugins/ShallowCloneProducer.cc similarity index 51% rename from CommonTools/CandAlgos/interface/ShallowCloneProducer.h rename to CommonTools/RecoAlgos/plugins/ShallowCloneProducer.cc index 7deaaf9e38365..900e143d56843 100644 --- a/CommonTools/CandAlgos/interface/ShallowCloneProducer.h +++ b/CommonTools/RecoAlgos/plugins/ShallowCloneProducer.cc @@ -1,5 +1,3 @@ -#ifndef CandAlgos_ShallowCloneProducer_h -#define CandAlgos_ShallowCloneProducer_h /** \class ShallowCloneProducer * * Clones a concrete Candidate collection @@ -13,11 +11,12 @@ * - C : Concrete candidate collection type * */ + +#include "DataFormats/Candidate/interface/ShallowCloneCandidate.h" #include "FWCore/Framework/interface/EDProducer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Utilities/interface/InputTag.h" -#include "DataFormats/Candidate/interface/ShallowCloneCandidate.h" template class ShallowCloneProducer : public edm::EDProducer { @@ -55,4 +54,33 @@ void ShallowCloneProducer::produce(edm::Event& evt, const edm::EventSetup&) { evt.put(std::move(coll)); } -#endif +#include "DataFormats/EgammaCandidates/interface/Electron.h" +#include "DataFormats/EgammaCandidates/interface/ElectronFwd.h" +#include "DataFormats/EgammaCandidates/interface/GsfElectron.h" +#include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h" +#include "DataFormats/JetReco/interface/CaloJet.h" +#include "DataFormats/JetReco/interface/GenJet.h" +#include "DataFormats/METReco/interface/CaloMET.h" +#include "DataFormats/METReco/interface/CaloMETCollection.h" +#include "DataFormats/METReco/interface/GenMET.h" +#include "DataFormats/METReco/interface/GenMETCollection.h" +#include "DataFormats/MuonReco/interface/Muon.h" +#include "DataFormats/MuonReco/interface/MuonFwd.h" + +typedef ShallowCloneProducer GenMETShallowCloneProducer; +typedef ShallowCloneProducer PixelMatchGsfElectronShallowCloneProducer; +typedef ShallowCloneProducer MuonShallowCloneProducer; +typedef ShallowCloneProducer CaloMETShallowCloneProducer; +typedef ShallowCloneProducer ElectronShallowCloneProducer; +typedef ShallowCloneProducer GenJetShallowCloneProducer; +typedef ShallowCloneProducer CaloJetShallowCloneProducer; + +#include "FWCore/Framework/interface/MakerMacros.h" + +DEFINE_FWK_MODULE(GenMETShallowCloneProducer); +DEFINE_FWK_MODULE(PixelMatchGsfElectronShallowCloneProducer); +DEFINE_FWK_MODULE(MuonShallowCloneProducer); +DEFINE_FWK_MODULE(CaloMETShallowCloneProducer); +DEFINE_FWK_MODULE(ElectronShallowCloneProducer); +DEFINE_FWK_MODULE(GenJetShallowCloneProducer); +DEFINE_FWK_MODULE(CaloJetShallowCloneProducer); From f0766902981ccdaf256127bda6283f9bfc5ac6ec Mon Sep 17 00:00:00 2001 From: Jonas Rembser Date: Sat, 11 Sep 2021 10:38:04 +0200 Subject: [PATCH 3/3] Make CandMatcher and NewCandMatcher aliases and not derived classes --- CommonTools/CandAlgos/interface/CandMatcher.h | 17 ++++------------- .../CandAlgos/interface/NewCandMatcher.h | 15 ++++----------- 2 files changed, 8 insertions(+), 24 deletions(-) diff --git a/CommonTools/CandAlgos/interface/CandMatcher.h b/CommonTools/CandAlgos/interface/CandMatcher.h index 9b1186c3ce691..26e5ca56a9e12 100644 --- a/CommonTools/CandAlgos/interface/CandMatcher.h +++ b/CommonTools/CandAlgos/interface/CandMatcher.h @@ -9,17 +9,8 @@ #include "DataFormats/Candidate/interface/Candidate.h" #include "CommonTools/CandUtils/interface/CandMapTrait.h" -namespace reco { - namespace modules { - template > - class CandMatcher - : public Matcher::type> { - public: - CandMatcher(const edm::ParameterSet& cfg) - : Matcher::type>(cfg) {} - ~CandMatcher() override {} - }; - - } // namespace modules -} // namespace reco +namespace reco::modules { + template > + using CandMatcher = Matcher::type>; +} // namespace reco::modules #endif diff --git a/CommonTools/CandAlgos/interface/NewCandMatcher.h b/CommonTools/CandAlgos/interface/NewCandMatcher.h index c087de01c1add..d709d1458dc28 100644 --- a/CommonTools/CandAlgos/interface/NewCandMatcher.h +++ b/CommonTools/CandAlgos/interface/NewCandMatcher.h @@ -8,15 +8,8 @@ #include "CommonTools/UtilAlgos/interface/NewMatcher.h" #include "DataFormats/Candidate/interface/Candidate.h" -namespace reco { - namespace modulesNew { - template > - class CandMatcher : public Matcher { - public: - CandMatcher(const edm::ParameterSet& cfg) : Matcher(cfg) {} - ~CandMatcher() override {} - }; - - } // namespace modulesNew -} // namespace reco +namespace reco::modulesNew { + template > + using CandMatcher = Matcher; +} // namespace reco::modulesNew #endif