1 |
dgele |
1.1 |
#ifndef PhysicsTools_PatAlgos_interface_OverlapTest_h
|
2 |
|
|
#define PhysicsTools_PatAlgos_interface_OverlapTest_h
|
3 |
|
|
|
4 |
|
|
#include "FWCore/Framework/interface/Event.h"
|
5 |
|
|
#include "FWCore/ParameterSet/interface/ParameterSet.h"
|
6 |
|
|
#include "FWCore/ParameterSet/interface/InputTag.h"
|
7 |
|
|
|
8 |
|
|
#include "DataFormats/Candidate/interface/CandidateFwd.h"
|
9 |
|
|
#include "DataFormats/Candidate/interface/Candidate.h"
|
10 |
|
|
#include "DataFormats/RecoCandidate/interface/RecoCandidate.h"
|
11 |
|
|
#include "PhysicsTools/PatUtils/interface/StringParserTools.h"
|
12 |
|
|
#include "PhysicsTools/PatUtils/interface/PATDiObjectProxy.h"
|
13 |
|
|
|
14 |
|
|
namespace pat { namespace helper {
|
15 |
|
|
|
16 |
|
|
// Base class for a test for overlaps
|
17 |
|
|
class OverlapTest {
|
18 |
|
|
public:
|
19 |
|
|
/// constructor: reads 'src' and 'requireNoOvelaps' parameters
|
20 |
|
|
OverlapTest(const std::string &name, const edm::ParameterSet &iConfig) :
|
21 |
|
|
src_(iConfig.getParameter<edm::InputTag>("src")),
|
22 |
|
|
name_(name),
|
23 |
|
|
requireNoOvelaps_(iConfig.getParameter<bool>("requireNoOvelaps")) {}
|
24 |
|
|
/// destructor, does nothing
|
25 |
|
|
virtual ~OverlapTest() {}
|
26 |
|
|
/// initializer for each event. to be implemented in child classes.
|
27 |
|
|
virtual void readInput(const edm::Event & iEvent, const edm::EventSetup &iSetup) = 0;
|
28 |
|
|
/// check for overlaps for a given item. to be implemented in child classes
|
29 |
|
|
/// return true if overlaps have been found, and fills the PtrVector
|
30 |
|
|
virtual bool fillOverlapsForItem(const reco::Candidate &item, reco::CandidatePtrVector &overlapsToFill) const = 0;
|
31 |
|
|
/// end of event method. does nothing
|
32 |
|
|
virtual void done() {}
|
33 |
|
|
// -- basic getters ---
|
34 |
|
|
|
35 |
|
|
const std::string & name() const { return name_; }
|
36 |
|
|
bool requireNoOvelaps() const { return requireNoOvelaps_; }
|
37 |
|
|
protected:
|
38 |
|
|
edm::InputTag src_;
|
39 |
|
|
std::string name_;
|
40 |
|
|
bool requireNoOvelaps_;
|
41 |
|
|
};
|
42 |
|
|
|
43 |
|
|
class BasicOverlapTest : public OverlapTest {
|
44 |
|
|
public:
|
45 |
|
|
BasicOverlapTest(const std::string &name, const edm::ParameterSet &iConfig) :
|
46 |
|
|
OverlapTest(name, iConfig),
|
47 |
|
|
presel_(iConfig.getParameter<std::string>("preselection")),
|
48 |
|
|
deltaR_(iConfig.getParameter<double>("deltaR")),
|
49 |
|
|
checkRecoComponents_(iConfig.getParameter<bool>("checkRecoComponents")),
|
50 |
|
|
pairCut_(iConfig.getParameter<std::string>("pairCut")) {}
|
51 |
|
|
// implementation of mother methods
|
52 |
|
|
/// Read input, apply preselection cut
|
53 |
|
|
virtual void readInput(const edm::Event & iEvent, const edm::EventSetup &iSetup) ;
|
54 |
|
|
/// Check for overlaps
|
55 |
|
|
virtual bool fillOverlapsForItem(const reco::Candidate &item, reco::CandidatePtrVector &overlapsToFill) const ;
|
56 |
|
|
protected:
|
57 |
|
|
// ---- configurables ----
|
58 |
|
|
/// A generic preselection cut that can work on any Candidate, but has access also to methods of PAT specific objects
|
59 |
|
|
PATStringCutObjectSelector presel_;
|
60 |
|
|
/// Delta R for the match
|
61 |
|
|
double deltaR_;
|
62 |
|
|
/// Check the overlapping by RECO components
|
63 |
|
|
bool checkRecoComponents_;
|
64 |
|
|
/// Cut on the pair of objects together
|
65 |
|
|
StringCutObjectSelector<pat::DiObjectProxy> pairCut_;
|
66 |
|
|
// ---- working variables ----
|
67 |
|
|
/// The collection to check overlaps against
|
68 |
|
|
edm::Handle<reco::CandidateView> candidates_;
|
69 |
|
|
/// Flag saying if each element has passed the preselection or not
|
70 |
|
|
std::vector<bool> isPreselected_;
|
71 |
|
|
};
|
72 |
|
|
|
73 |
|
|
class OverlapBySuperClusterSeed : public OverlapTest {
|
74 |
|
|
public:
|
75 |
|
|
// constructor: nothing except initialize the base class
|
76 |
|
|
OverlapBySuperClusterSeed(const std::string &name, const edm::ParameterSet &iConfig) : OverlapTest(name, iConfig) {}
|
77 |
|
|
// every event: nothing except read the input list
|
78 |
|
|
virtual void readInput(const edm::Event & iEvent, const edm::EventSetup &iSetup) {
|
79 |
|
|
iEvent.getByLabel(src_, others_);
|
80 |
|
|
}
|
81 |
|
|
/// Check for overlaps
|
82 |
|
|
virtual bool fillOverlapsForItem(const reco::Candidate &item, reco::CandidatePtrVector &overlapsToFill) const ;
|
83 |
|
|
protected:
|
84 |
|
|
edm::Handle<edm::View<reco::RecoCandidate> > others_;
|
85 |
|
|
};
|
86 |
|
|
|
87 |
|
|
|
88 |
|
|
|
89 |
|
|
} } // namespaces
|
90 |
|
|
|
91 |
|
|
#endif
|