CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 {
29  static void addDaughter(reco::CompositeCandidate & cmp, const reco::CandidateBaseRef & c, const std::string name = "") {
30  if(c->numberOfDaughters()==0)
32  else
33  cmp.addDaughter(*c, name);
34  }
35  };
36  struct ShallowClonePtr {
38  static void addDaughter(reco::CompositeCandidate & cmp, const reco::CandidatePtr & c, const std::string name = "") {
39  if(c->numberOfDaughters()==0)
41  else
42  cmp.addDaughter(*c, name);
43  }
44  };
45  }
46 }
47 
48 template<typename Selector,
49  typename PairSelector = AnyPairSelector,
50  typename Cloner = combiner::helpers::NormalClone,
52  typename Setup = AddFourMomenta>
53 class CandCombiner : public CandCombinerBase<OutputCollection, typename Cloner::CandPtr> {
54 public:
55  typedef typename Cloner::CandPtr CandPtr;
59  base(),
60  select_(), selectPair_(), setup_() { }
62  CandCombiner(int q1, int q2) :
63  base(q1, q2),
64  select_(), selectPair_(), setup_() { }
66  CandCombiner( int q1, int q2, int q3 ) :
67  base(q1, q2, q3),
68  select_(), selectPair_(), setup_() { }
70  CandCombiner(int q1, int q2, int q3, int q4) :
71  base(q1, q2, q3, q4),
72  select_(), selectPair_(), setup_() { }
75  base( ),
76  select_(select), selectPair_(), setup_() { }
78  CandCombiner( const Selector & select, int q1, int q2 ) :
79  base(q1, q2),
80  select_(select), selectPair_(), setup_() { }
82  CandCombiner( const Selector & select, int q1, int q2, int q3 ) :
83  base(q1, q2, q3),
84  select_(select), selectPair_(), setup_() { }
86  CandCombiner( const Selector & select, int q1, int q2, int q3, int q4 ) :
87  base(q1, q2, q3, q4),
88  select_(select), selectPair_(), setup_() { }
90  CandCombiner(const Selector & select, const PairSelector & selectPair) :
91  base( ),
92  select_(select), selectPair_(selectPair), setup_() { }
94  CandCombiner(const Selector & select, const PairSelector & selectPair, int q1, int q2) :
95  base(q1, q2),
96  select_(select), selectPair_(selectPair), setup_() { }
98  CandCombiner(const Selector & select, const PairSelector & selectPair, int q1, int q2, int q3) :
99  base(q1, q2, q3),
100  select_(select), selectPair_(selectPair), setup_() { }
102  CandCombiner(const Selector & select, const PairSelector & selectPair, int q1, int q2, int q3, int q4) :
103  base(q1, q2, q3, q4),
104  select_(select), selectPair_(selectPair), setup_() { }
105  CandCombiner(const Selector & select, const PairSelector & selectPair, const Setup & setup) :
106  base(),
107  select_(select), selectPair_(selectPair), setup_(setup) { }
109  CandCombiner(const Selector & select, const PairSelector & selectPair, const Setup & setup, int q1, int q2) :
110  base(q1, q2),
111  select_(select), selectPair_(selectPair), setup_(setup) { }
113  CandCombiner(const Selector & select, const PairSelector & selectPair, const Setup & setup, int q1, int q2, int q3) :
114  base(q1, q2, q3),
115  select_(select), selectPair_(selectPair), setup_(setup) { }
117  CandCombiner(const Selector & select, const PairSelector & selectPair, const Setup & setup, int q1, int q2, int q3, int q4) :
118  base(q1, q2, q3, q4),
119  select_(select), selectPair_(selectPair), setup_(setup) { }
121  CandCombiner(const Selector & select, const PairSelector & selectPair, const Setup & setup,const std::vector <int> & dauCharge) :
122  base(true, dauCharge), select_(select), selectPair_(selectPair), setup_(setup) { }
124  CandCombiner( const Selector & select, const PairSelector & selectPair, const std::vector <int> & dauCharge ) :
125  base(true, dauCharge), select_(select), selectPair_(selectPair), setup_() { }
127  CandCombiner(const std::vector <int> & dauCharge) :
128  base(true, dauCharge), select_(), selectPair_(), setup_() { }
130  CandCombiner(const Selector & select, const PairSelector & selectPair, const Setup & setup,
131  bool checkCharge, const std::vector <int> & dauCharge) :
132  base(checkCharge, dauCharge),
133  select_(select), selectPair_(selectPair), setup_(setup) { }
135  Setup & setup() { return setup_; }
136 
137 private:
139  virtual bool select(const reco::Candidate & c) const {
140  return select_(c);
141  }
143  virtual bool selectPair(const reco::Candidate & c1, const reco::Candidate & c2) const {
144  return selectPair_(c1, c2);
145  }
147  virtual void setup(typename OutputCollection::value_type & c) const {
148  setup_.set(c);
149  }
151  virtual void addDaughter(typename OutputCollection::value_type & cmp, const CandPtr & c, const std::string name = "") const {
152  Cloner::addDaughter(cmp, c, name);
153  }
155  Selector select_;
157  PairSelector selectPair_;
159  Setup setup_;
160 };
161 
162 #endif
virtual void setup(typename OutputCollection::value_type &c) const
set kinematics to reconstructed composite
Definition: CandCombiner.h:147
std::vector< ProtoJet > OutputCollection
Definition: JetRecoTypes.h:63
Setup & setup()
return reference to setup object to allow its initialization
Definition: CandCombiner.h:129
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:117
std::vector< CompositeCandidate > CompositeCandidateCollection
collection of Candidate objects
CandCombinerBase< OutputCollection, CandPtr > base
Definition: CandCombiner.h:56
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:66
CandCombiner()
default constructor
Definition: CandCombiner.h:58
CandCombiner(int q1, int q2, int q3, int q4)
constructor from a selector and four charges
Definition: CandCombiner.h:70
double q2[4]
Definition: TauolaWrapper.h:88
CandCombiner(const Selector &select, const PairSelector &selectPair, int q1, int q2, int q3)
constructor from a selector and three charges
Definition: CandCombiner.h:98
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:113
virtual bool selectPair(const reco::Candidate &c1, const reco::Candidate &c2) const
select a candidate
Definition: CandCombiner.h:137
CandCombiner(const Selector &select, const PairSelector &selectPair, const std::vector< int > &dauCharge)
constructor from a selector, specifying to check for charge
Definition: CandCombiner.h:124
CandCombiner(const Selector &select)
default constructor
Definition: CandCombiner.h:74
Setup setup_
utility to setup composite candidate kinematics from daughters
Definition: CandCombiner.h:153
CandCombiner(const Selector &select, const PairSelector &selectPair, const Setup &setup, int q1, int q2)
constructor from a selector and two charges
Definition: CandCombiner.h:109
CandCombiner(const Selector &select, int q1, int q2, int q3, int q4)
constructor from a selector and four charges
Definition: CandCombiner.h:86
virtual void addDaughter(typename OutputCollection::value_type &cmp, const CandPtr &c, const std::string name="") const
add candidate daughter
Definition: CandCombiner.h:151
virtual bool select(const reco::Candidate &c) const
select a candidate
Definition: CandCombiner.h:133
PairSelector selectPair_
candidate pair selector
Definition: CandCombiner.h:151
CandCombiner(const Selector &select, int q1, int q2, int q3)
constructor from a selector and three charges
Definition: CandCombiner.h:82
CandCombiner(const Selector &select, int q1, int q2)
constructor from a selector and two charges
Definition: CandCombiner.h:78
reco::CandidateBaseRef CandPtr
Definition: CandCombiner.h:28
Container::value_type value_type
Functor that operates on &lt;T&gt;
Definition: Selector.h:25
void addDaughter(const Candidate &, const std::string &s="")
add a clone of the passed candidate as daughter
CandCombiner(const Selector &select, const PairSelector &selectPair, const Setup &setup)
Definition: CandCombiner.h:105
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:121
reco::CandidateBaseRef CandPtr
Definition: CandCombiner.h:20
double q1[4]
Definition: TauolaWrapper.h:87
CandCombiner(const Selector &select, const PairSelector &selectPair, const Setup &setup, bool checkCharge, const std::vector< int > &dauCharge)
constructor from a selector, specifying optionally to check for charge
Definition: CandCombiner.h:130
Cloner::CandPtr CandPtr
Definition: CandCombiner.h:55
CandCombiner(int q1, int q2)
constructor from a selector and two charges
Definition: CandCombiner.h:62
CandCombiner(const Selector &select, const PairSelector &selectPair)
constructor from selector
Definition: CandCombiner.h:90
CandCombiner(const std::vector< int > &dauCharge)
constructor from a selector, specifying to check for charge
Definition: CandCombiner.h:127
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:102
CandCombiner(const Selector &select, const PairSelector &selectPair, int q1, int q2)
constructor from a selector and two charges
Definition: CandCombiner.h:94
static void addDaughter(reco::CompositeCandidate &cmp, const Ref &c, const std::string name="")
Definition: CandCombiner.h:22
static void addDaughter(reco::CompositeCandidate &cmp, const reco::CandidatePtr &c, const std::string name="")
Definition: CandCombiner.h:38
Selector select_
candidate selector
Definition: CandCombiner.h:149