CMS 3D CMS Logo

CandCombiner.h
Go to the documentation of this file.
1 #ifndef CandUtils_CandCombiner_h
2 #define CandUtils_CandCombiner_h
3 
16 
17 namespace combiner {
18  namespace helpers {
19  struct NormalClone {
21  template <typename Ref>
22  static void addDaughter(reco::CompositeCandidate& cmp, const Ref& c, const std::string name = "") {
23  cmp.addDaughter(*c, name);
24  }
25  };
26 
27  struct ShallowClone {
31  const std::string name = "") {
32  cmp.addDaughter(reco::ShallowCloneCandidate(c), name);
33  }
34  };
35  struct ShallowClonePtr {
39  }
40  };
41  } // namespace helpers
42 } // namespace combiner
43 
44 template <typename Selector,
45  typename PairSelector = AnyPairSelector,
46  typename Cloner = combiner::helpers::NormalClone,
48  typename Setup = AddFourMomenta>
49 class CandCombiner : public CandCombinerBase<OutputCollection, typename Cloner::CandPtr> {
50 public:
51  typedef typename Cloner::CandPtr CandPtr;
56  CandCombiner(int q1, int q2) : base(q1, q2), select_(), selectPair_(), setup_() {}
58  CandCombiner(int q1, int q2, int q3) : base(q1, q2, q3), select_(), selectPair_(), setup_() {}
60  CandCombiner(int q1, int q2, int q3, int q4) : base(q1, q2, q3, q4), select_(), selectPair_(), setup_() {}
64  CandCombiner(const Selector& select, int q1, int q2) : base(q1, q2), select_(select), selectPair_(), setup_() {}
66  CandCombiner(const Selector& select, int q1, int q2, int q3)
67  : base(q1, q2, q3), select_(select), selectPair_(), setup_() {}
69  CandCombiner(const Selector& select, int q1, int q2, int q3, int q4)
70  : base(q1, q2, q3, q4), select_(select), selectPair_(), setup_() {}
75  CandCombiner(const Selector& select, const PairSelector& selectPair, int q1, int q2)
76  : base(q1, q2), select_(select), selectPair_(selectPair), setup_() {}
78  CandCombiner(const Selector& select, const PairSelector& selectPair, int q1, int q2, int q3)
79  : base(q1, q2, q3), select_(select), selectPair_(selectPair), setup_() {}
81  CandCombiner(const Selector& select, const PairSelector& selectPair, int q1, int q2, int q3, int q4)
82  : base(q1, q2, q3, q4), select_(select), selectPair_(selectPair), setup_() {}
86  CandCombiner(const Selector& select, const PairSelector& selectPair, const Setup& setup, int q1, int q2)
89  CandCombiner(const Selector& select, const PairSelector& selectPair, const Setup& setup, int q1, int q2, int q3)
90  : base(q1, q2, q3), select_(select), selectPair_(selectPair), setup_(setup) {}
93  const Selector& select, const PairSelector& selectPair, const Setup& setup, int q1, int q2, int q3, int q4)
94  : base(q1, q2, q3, q4), select_(select), selectPair_(selectPair), setup_(setup) {}
97  const PairSelector& selectPair,
98  const Setup& setup,
99  const std::vector<int>& dauCharge)
100  : base(true, dauCharge), select_(select), selectPair_(selectPair), setup_(setup) {}
102  CandCombiner(const Selector& select, const PairSelector& selectPair, const std::vector<int>& dauCharge)
103  : base(true, dauCharge), select_(select), selectPair_(selectPair), setup_() {}
105  CandCombiner(const std::vector<int>& dauCharge) : base(true, dauCharge), select_(), selectPair_(), setup_() {}
108  const PairSelector& selectPair,
109  const Setup& setup,
110  bool checkCharge,
111  bool checkOverlap,
112  const std::vector<int>& dauCharge)
115  Setup& setup() { return setup_; }
116 
117 private:
119  bool select(const reco::Candidate& c) const override { return select_(c); }
121  bool selectPair(const reco::Candidate& c1, const reco::Candidate& c2) const override { return selectPair_(c1, c2); }
123  void setup(typename OutputCollection::value_type& c) const override { setup_.set(c); }
126  const CandPtr& c,
127  const std::string name = "") const override {
128  Cloner::addDaughter(cmp, c, name);
129  }
136 };
137 
138 #endif
Setup & setup()
return reference to setup object to allow its initialization
Definition: CandCombiner.h:115
CandCombiner(const Selector &select, const PairSelector &selectPair, const Setup &setup, int q1, int q2, int q3, int q4)
constructor from a selector and four charges
Definition: CandCombiner.h:92
std::vector< CompositeCandidate > CompositeCandidateCollection
collection of Candidate objects
CandCombinerBase< OutputCollection, CandPtr > base
Definition: CandCombiner.h:52
static void addDaughter(reco::CompositeCandidate &cmp, const reco::CandidateBaseRef &c, const std::string name="")
Definition: CandCombiner.h:29
CandCombiner(int q1, int q2, int q3)
constructor from a selector and three charges
Definition: CandCombiner.h:58
CandCombiner()
default constructor
Definition: CandCombiner.h:54
CandCombiner(int q1, int q2, int q3, int q4)
constructor from a selector and four charges
Definition: CandCombiner.h:60
bool select(const reco::Candidate &c) const override
select a candidate
Definition: CandCombiner.h:119
void addDaughter(typename OutputCollection::value_type &cmp, const CandPtr &c, const std::string name="") const override
add candidate daughter
Definition: CandCombiner.h:125
CandCombiner(const Selector &select, const PairSelector &selectPair, int q1, int q2, int q3)
constructor from a selector and three charges
Definition: CandCombiner.h:78
CandCombiner(const Selector &select, const PairSelector &selectPair, const Setup &setup, int q1, int q2, int q3)
constructor from a selector and three charges
Definition: CandCombiner.h:89
CandCombiner(const Selector &select, const PairSelector &selectPair, const std::vector< int > &dauCharge)
constructor from a selector, specifying to check for charge
Definition: CandCombiner.h:102
CandCombiner(const Selector &select)
default constructor
Definition: CandCombiner.h:62
Setup setup_
utility to setup composite candidate kinematics from daughters
Definition: CandCombiner.h:135
CandCombiner(const Selector &select, const PairSelector &selectPair, const Setup &setup, int q1, int q2)
constructor from a selector and two charges
Definition: CandCombiner.h:86
CandCombiner(const Selector &select, int q1, int q2, int q3, int q4)
constructor from a selector and four charges
Definition: CandCombiner.h:69
PairSelector selectPair_
candidate pair selector
Definition: CandCombiner.h:133
CandCombiner(const Selector &select, int q1, int q2, int q3)
constructor from a selector and three charges
Definition: CandCombiner.h:66
CandCombiner(const Selector &select, int q1, int q2)
constructor from a selector and two charges
Definition: CandCombiner.h:64
reco::CandidateBaseRef CandPtr
Definition: CandCombiner.h:28
Functor that operates on <T>
Definition: Selector.h:22
CandCombiner(const Selector &select, const PairSelector &selectPair, const Setup &setup)
Definition: CandCombiner.h:83
CandCombiner(const Selector &select, const PairSelector &selectPair, const Setup &setup, const std::vector< int > &dauCharge)
constructor from a selector, specifying to check for charge
Definition: CandCombiner.h:96
reco::CandidateBaseRef CandPtr
Definition: CandCombiner.h:20
CandCombiner(const Selector &select, const PairSelector &selectPair, const Setup &setup, bool checkCharge, bool checkOverlap, const std::vector< int > &dauCharge)
constructor from a selector, specifying optionally to check for charge
Definition: CandCombiner.h:107
Cloner::CandPtr CandPtr
Definition: CandCombiner.h:51
def checkOverlap(process)
CandCombiner(int q1, int q2)
constructor from a selector and two charges
Definition: CandCombiner.h:56
CandCombiner(const Selector &select, const PairSelector &selectPair)
constructor from selector
Definition: CandCombiner.h:72
CandCombiner(const std::vector< int > &dauCharge)
constructor from a selector, specifying to check for charge
Definition: CandCombiner.h:105
CandCombiner(const Selector &select, const PairSelector &selectPair, int q1, int q2, int q3, int q4)
constructor from a selector and four charges
Definition: CandCombiner.h:81
CandCombiner(const Selector &select, const PairSelector &selectPair, int q1, int q2)
constructor from a selector and two charges
Definition: CandCombiner.h:75
bool selectPair(const reco::Candidate &c1, const reco::Candidate &c2) const override
select a candidate
Definition: CandCombiner.h:121
static void addDaughter(reco::CompositeCandidate &cmp, const Ref &c, const std::string name="")
Definition: CandCombiner.h:22
void setup(typename OutputCollection::value_type &c) const override
set kinematics to reconstructed composite
Definition: CandCombiner.h:123
static void addDaughter(reco::CompositeCandidate &cmp, const reco::CandidatePtr &c, const std::string name="")
Definition: CandCombiner.h:37
Selector select_
candidate selector
Definition: CandCombiner.h:131