File indexing completed on 2024-04-06 12:23:46
0001 #ifndef PhysicsTools_PatAlgos_interface_OverlapTest_h
0002 #define PhysicsTools_PatAlgos_interface_OverlapTest_h
0003
0004 #include "FWCore/Framework/interface/Event.h"
0005 #include "FWCore/Framework/interface/ConsumesCollector.h"
0006 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0007 #include "FWCore/Utilities/interface/InputTag.h"
0008
0009 #include "DataFormats/Candidate/interface/CandidateFwd.h"
0010 #include "DataFormats/Candidate/interface/Candidate.h"
0011 #include "DataFormats/RecoCandidate/interface/RecoCandidate.h"
0012 #include "PhysicsTools/PatUtils/interface/StringParserTools.h"
0013 #include "PhysicsTools/PatUtils/interface/PATDiObjectProxy.h"
0014
0015 namespace pat {
0016 namespace helper {
0017
0018
0019 class OverlapTest {
0020 public:
0021
0022 OverlapTest(const std::string &name, const edm::ParameterSet &iConfig, edm::ConsumesCollector &iC)
0023 : srcToken_(iC.consumes<reco::CandidateView>(iConfig.getParameter<edm::InputTag>("src"))),
0024 name_(name),
0025 requireNoOverlaps_(iConfig.getParameter<bool>("requireNoOverlaps")) {}
0026
0027 virtual ~OverlapTest() {}
0028
0029 virtual void readInput(const edm::Event &iEvent, const edm::EventSetup &iSetup) = 0;
0030
0031
0032 virtual bool fillOverlapsForItem(const reco::Candidate &item, reco::CandidatePtrVector &overlapsToFill) const = 0;
0033
0034 virtual void done() {}
0035
0036
0037 const std::string &name() const { return name_; }
0038 bool requireNoOverlaps() const { return requireNoOverlaps_; }
0039
0040 protected:
0041 edm::EDGetTokenT<reco::CandidateView> srcToken_;
0042 std::string name_;
0043 bool requireNoOverlaps_;
0044 };
0045
0046 class BasicOverlapTest : public OverlapTest {
0047 public:
0048 BasicOverlapTest(const std::string &name, const edm::ParameterSet &iConfig, edm::ConsumesCollector &&iC)
0049 : OverlapTest(name, iConfig, iC),
0050 presel_(iConfig.getParameter<std::string>("preselection")),
0051 deltaR_(iConfig.getParameter<double>("deltaR")),
0052 checkRecoComponents_(iConfig.getParameter<bool>("checkRecoComponents")),
0053 pairCut_(iConfig.getParameter<std::string>("pairCut")) {}
0054
0055
0056 void readInput(const edm::Event &iEvent, const edm::EventSetup &iSetup) override;
0057
0058 bool fillOverlapsForItem(const reco::Candidate &item, reco::CandidatePtrVector &overlapsToFill) const override;
0059
0060 protected:
0061
0062
0063 PATStringCutObjectSelector presel_;
0064
0065 double deltaR_;
0066
0067 bool checkRecoComponents_;
0068
0069 StringCutObjectSelector<pat::DiObjectProxy> pairCut_;
0070
0071
0072 edm::Handle<reco::CandidateView> candidates_;
0073
0074 std::vector<bool> isPreselected_;
0075 };
0076
0077 class OverlapBySuperClusterSeed : public OverlapTest {
0078 public:
0079
0080 OverlapBySuperClusterSeed(const std::string &name, const edm::ParameterSet &iConfig, edm::ConsumesCollector &&iC)
0081 : OverlapTest(name, iConfig, iC) {}
0082
0083 void readInput(const edm::Event &iEvent, const edm::EventSetup &iSetup) override {
0084 iEvent.getByToken(srcToken_, others_);
0085 }
0086
0087 bool fillOverlapsForItem(const reco::Candidate &item, reco::CandidatePtrVector &overlapsToFill) const override;
0088
0089 protected:
0090
0091 edm::Handle<reco::CandidateView> others_;
0092 };
0093
0094 }
0095 }
0096
0097 #endif