CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
BPHMultiSelect.h
Go to the documentation of this file.
1 #ifndef HeavyFlavorAnalysis_RecoDecay_BPHMultiSelect_h
2 #define HeavyFlavorAnalysis_RecoDecay_BPHMultiSelect_h
3 
12 //----------------------
13 // Base Class Headers --
14 //----------------------
15 
16 //------------------------------------
17 // Collaborating Class Declarations --
18 //------------------------------------
23 class BPHRecoBuilder;
24 class BPHDecayMomentum;
25 class BPHDecayVertex;
26 
27 namespace reco {
28  class Candidate;
29 }
30 
31 //---------------
32 // C++ Headers --
33 //---------------
34 #include <vector>
35 
36 // ---------------------
37 // -- Class Interface --
38 // ---------------------
39 
41 public:
42  enum mode { or_mode, and_mode };
43 };
44 
45 template <class T>
46 class BPHMultiSelectBase : public T {
47 public:
51  switch (op) {
53  breakValue = true;
54  finalValue = false;
55  break;
57  breakValue = false;
58  finalValue = true;
59  break;
60  }
61  }
62 
63  // deleted copy constructor and assignment operator
66 
69  ~BPHMultiSelectBase() override {}
70 
73  void include(T& s, bool m = true) {
75  SelectElement e;
76  e.selector = &s;
77  e.mode = m;
78  selectList.push_back(e);
79  return;
80  }
81 
83  unsigned int count() { return selectList.size(); }
84 
85 protected:
86  using Obj = typename T::AcceptArg;
87  bool select(const Obj& cand) const {
88  int i;
89  int n = selectList.size();
90  for (i = 0; i < n; ++i) {
91  const SelectElement& e = selectList[i];
92  if ((e.selector->accept(cand) == e.mode) == breakValue)
93  return breakValue;
94  }
95  return finalValue;
96  }
97  bool select(const Obj& cand, const BPHRecoBuilder* build) const {
98  int i;
99  int n = selectList.size();
100  for (i = 0; i < n; ++i) {
101  const SelectElement& e = selectList[i];
102  if ((e.selector->accept(cand, build) == e.mode) == breakValue)
103  return breakValue;
104  }
105  return finalValue;
106  }
107 
108 private:
109  struct SelectElement {
111  bool mode;
112  };
113 
116  std::vector<SelectElement> selectList;
117 };
118 
119 template <class T>
121 public:
123 
127 
128  // deleted copy constructor and assignment operator
129  BPHSlimSelect(const BPHSlimSelect<T>& x) = delete;
130  BPHSlimSelect& operator=(const BPHSlimSelect<T>& x) = delete;
131 
134  ~BPHSlimSelect() override {}
135 
138  bool accept(const typename T::AcceptArg& cand) const override { return Base::select(cand); }
140 };
141 
142 template <class T>
143 class BPHFullSelect : public BPHSlimSelect<T> {
144 public:
146 
150 
151  // deleted copy constructor and assignment operator
154 
157  ~BPHFullSelect() override {}
158 
161  bool accept(const typename T::AcceptArg& cand, const BPHRecoBuilder* build) const override {
163  return Base::select(cand, build);
164  }
165 };
166 
167 template <class T = BPHFullSelect<BPHRecoSelect>>
168 class BPHMultiSelect : public T {
169 public:
173 
174  // deleted copy constructor and assignment operator
175  BPHMultiSelect(const BPHMultiSelect<T>& x) = delete;
176  BPHMultiSelect& operator=(const BPHMultiSelect<T>& x) = delete;
177 
180  ~BPHMultiSelect() override {}
181 
184 };
186 
187 #endif
BPHMultiSelect(BPHSelectOperation::mode op)
BPHSlimSelect & operator=(const BPHSlimSelect< T > &x)=delete
BPHSlimSelect(BPHSelectOperation::mode op)
void include(T &s, bool m=true)
include selection
~BPHFullSelect() override
bool select(const Obj &cand, const BPHRecoBuilder *build) const
BPHMultiSelectBase & operator=(const BPHMultiSelectBase< T > &x)=delete
bool select(const Obj &cand) const
BPHMultiSelectBase(BPHSelectOperation::mode op)
~BPHSlimSelect() override
BPHFullSelect(BPHSelectOperation::mode op)
~BPHMultiSelect() override
BPHFullSelect & operator=(const BPHFullSelect< T > &x)
bool accept(const typename T::AcceptArg &cand, const BPHRecoBuilder *build) const override
accept function
BPHMultiSelect & operator=(const BPHMultiSelect< T > &x)=delete
std::vector< SelectElement > selectList
typename T::AcceptArg Obj
unsigned int count()
component count
long double T
bool accept(const typename T::AcceptArg &cand) const override
accept function
~BPHMultiSelectBase() override