CMS 3D CMS Logo

NamedCandCombiner.h
Go to the documentation of this file.
1 #ifndef CandUtils_NamedCandCombiner_h
2 #define CandUtils_NamedCandCombiner_h
3 
14 #include <string>
15 
16 namespace combiner {
17  namespace helpers {
18  struct NormalClone {
19  template<typename Ptr, typename CMP>
20  static void addDaughter(CMP & cmp, const Ptr & c, std::string name) {
21  cmp.addDaughter(*c, name);
22  }
23  };
24 
25  struct ShallowClone {
26  template<typename CMP>
27  static void addDaughter(CMP & cmp, const reco::CandidatePtr & c, std::string name) {
28  if(c->numberOfDaughters()==0)
29  cmp.addDaughter(reco::ShallowClonePtrCandidate(c), name);
30  else
31  cmp.addDaughter(*c, name);
32  }
33  };
34  }
35 }
36 
37 template<typename Selector,
38  typename PairSelector = AnyPairSelector,
39  typename Cloner = combiner::helpers::NormalClone,
40  typename Setup = AddFourMomenta>
42 public:
45  NamedCandCombinerBase(name),
46  select_(), selectPair_(), setup_(), name_(name) { }
49  NamedCandCombinerBase(name, q1, q2),
50  select_(), selectPair_(), setup_(), name_(name) { }
52  NamedCandCombiner(std::string name, int q1, int q2, int q3 ) :
53  NamedCandCombinerBase(name, q1, q2, q3),
54  select_(), selectPair_(), setup_(), name_(name) { }
56  NamedCandCombiner(std::string name, int q1, int q2, int q3, int q4) :
57  NamedCandCombinerBase(name, q1, q2, q3, q4),
58  select_(), selectPair_(), setup_(), name_(name) { }
61  NamedCandCombinerBase(name),
62  select_(select), selectPair_(), setup_(), name_(name) { }
65  NamedCandCombinerBase(name, q1, q2),
66  select_(select), selectPair_(), setup_(), name_(name) { }
68  NamedCandCombiner(std::string name, const Selector & select, int q1, int q2, int q3 ) :
69  NamedCandCombinerBase(name, q1, q2, q3),
70  select_(select), selectPair_(), setup_(), name_(name) { }
72  NamedCandCombiner(std::string name, const Selector & select, int q1, int q2, int q3, int q4 ) :
73  NamedCandCombinerBase(name, q1, q2, q3, q4),
74  select_(select), selectPair_(), setup_(), name_(name) { }
76  NamedCandCombiner(std::string name, const Selector & select, const PairSelector & selectPair) :
77  NamedCandCombinerBase(name),
78  select_(select), selectPair_(selectPair), setup_(), name_(name) { }
80  NamedCandCombiner(std::string name, const Selector & select, const PairSelector & selectPair, int q1, int q2) :
81  NamedCandCombinerBase(name, q1, q2),
82  select_(select), selectPair_(selectPair), setup_(), name_(name) { }
84  NamedCandCombiner(std::string name, const Selector & select, const PairSelector & selectPair, int q1, int q2, int q3) :
85  NamedCandCombinerBase(name, q1, q2, q3),
86  select_(select), selectPair_(selectPair), setup_(), name_(name) { }
88  NamedCandCombiner(std::string name, const Selector & select, const PairSelector & selectPair, int q1, int q2, int q3, int q4) :
89  NamedCandCombinerBase(name, q1, q2, q3, q4),
90  select_(select), selectPair_(selectPair), setup_(), name_(name) { }
91  NamedCandCombiner(std::string name, const Selector & select, const PairSelector & selectPair, const Setup & setup) :
92  NamedCandCombinerBase(name),
93  select_(select), selectPair_(selectPair), setup_(setup), name_(name) { }
95  NamedCandCombiner(std::string name, const Selector & select, const PairSelector & selectPair, const Setup & setup, int q1, int q2) :
96  NamedCandCombinerBase(name, q1, q2),
97  select_(select), selectPair_(selectPair), setup_(setup), name_(name) { }
99  NamedCandCombiner(std::string name, const Selector & select, const PairSelector & selectPair, const Setup & setup, int q1, int q2, int q3) :
100  NamedCandCombinerBase(name, q1, q2, q3),
101  select_(select), selectPair_(selectPair), setup_(setup), name_(name) { }
103  NamedCandCombiner(std::string name, const Selector & select, const PairSelector & selectPair, const Setup & setup, int q1, int q2, int q3, int q4) :
104  NamedCandCombinerBase(name, q1, q2, q3, q4),
105  select_(select), selectPair_(selectPair), setup_(setup), name_(name) { }
107  NamedCandCombiner(std::string name, const Selector & select, const PairSelector & selectPair, const Setup & setup,const std::vector <int> & dauCharge) :
108  NamedCandCombinerBase(name, true, dauCharge), select_(select), selectPair_(selectPair), setup_(setup), name_(name) { }
110  NamedCandCombiner( std::string name, const Selector & select, const PairSelector & selectPair, const std::vector <int> & dauCharge ) :
111  NamedCandCombinerBase(name, true, dauCharge), select_(select), selectPair_(selectPair), setup_(), name_(name) { }
113  NamedCandCombiner(std::string name, const std::vector <int> & dauCharge) :
114  NamedCandCombinerBase(name, true, dauCharge), select_(), selectPair_(), setup_(), name_(name) { }
116  NamedCandCombiner(std::string name, const Selector & select, const PairSelector & selectPair, const Setup & setup,
117  bool checkCharge, bool checkOverlap, const std::vector <int> & dauCharge) :
118  NamedCandCombinerBase(name, checkCharge, checkOverlap, dauCharge),
119  select_(select), selectPair_(selectPair), setup_(setup), name_(name) { }
121  Setup & setup() { return setup_; }
122 
123 private:
125  virtual bool select(const reco::Candidate & c) const {
126  return select_(c);
127  }
129  virtual bool selectPair(const reco::Candidate & c1, const reco::Candidate & c2) const {
130  return selectPair_(c1, c2);
131  }
133  virtual void setup(reco::NamedCompositeCandidate & c) const {
134  setup_.set(c);
135  }
138  Cloner::addDaughter(cmp, c, n);
139  }
143  PairSelector selectPair_;
145  Setup setup_;
148 };
149 
150 #endif
NamedCandCombiner(std::string name, const Selector &select, int q1, int q2, int q3)
constructor from a selector and three charges
NamedCandCombiner(std::string name, const Selector &select, const PairSelector &selectPair, int q1, int q2, int q3, int q4)
constructor from a selector and four charges
static void addDaughter(CMP &cmp, const Ptr &c, std::string name)
static void addDaughter(CMP &cmp, const reco::CandidatePtr &c, std::string name)
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:2
NamedCandCombiner(std::string name, 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
NamedCandCombiner(std::string name, const Selector &select, const PairSelector &selectPair, const Setup &setup)
NamedCandCombiner(std::string name, const std::vector< int > &dauCharge)
constructor from a selector, specifying to check for charge
PairSelector selectPair_
candidate pair selector
std::string name_
name
NamedCandCombiner(std::string name, int q1, int q2, int q3)
constructor from a selector and three charges
virtual bool select(const reco::Candidate &c) const
select a candidate
double q2[4]
Definition: TauolaWrapper.h:88
NamedCandCombiner(std::string name, const Selector &select, const PairSelector &selectPair, const Setup &setup, int q1, int q2, int q3)
constructor from a selector and three charges
NamedCandCombiner(std::string name)
default constructor
virtual bool selectPair(const reco::Candidate &c1, const reco::Candidate &c2) const
select a candidate
NamedCandCombiner(std::string name, int q1, int q2, int q3, int q4)
constructor from a selector and four charges
Functor that operates on <T>
Definition: Selector.h:23
NamedCandCombiner(std::string name, const Selector &select, const PairSelector &selectPair, const Setup &setup, const std::vector< int > &dauCharge)
constructor from a selector, specifying to check for charge
NamedCandCombiner(std::string name, const Selector &select, const PairSelector &selectPair, int q1, int q2)
constructor from a selector and two charges
NamedCandCombiner(std::string name, const Selector &select, int q1, int q2, int q3, int q4)
constructor from a selector and four charges
NamedCandCombiner(std::string name, const Selector &select, int q1, int q2)
constructor from a selector and two charges
NamedCandCombiner(std::string name, int q1, int q2)
constructor from a selector and two charges
NamedCandCombiner(std::string name, const Selector &select, const PairSelector &selectPair, int q1, int q2, int q3)
constructor from a selector and three charges
NamedCandCombiner(std::string name, const Selector &select, const PairSelector &selectPair, const Setup &setup, int q1, int q2, int q3, int q4)
constructor from a selector and four charges
double q1[4]
Definition: TauolaWrapper.h:87
virtual void setup(reco::NamedCompositeCandidate &c) const
set kinematics to reconstructed composite
NamedCandCombiner(std::string name, const Selector &select, const PairSelector &selectPair, const std::vector< int > &dauCharge)
constructor from a selector, specifying to check for charge
def checkOverlap(process)
NamedCandCombiner(std::string name, const Selector &select, const PairSelector &selectPair)
constructor from selector
NamedCandCombiner(std::string name, const Selector &select, const PairSelector &selectPair, const Setup &setup, int q1, int q2)
constructor from a selector and two charges
Setup setup_
utility to setup composite candidate kinematics from daughters
virtual void addDaughter(reco::NamedCompositeCandidate &cmp, const reco::CandidatePtr &c, std::string n) const
add candidate daughter
Setup & setup()
return reference to setup object to allow its initialization
NamedCandCombiner(std::string name, const Selector &select)
default constructor
Selector select_
candidate selector