CMS 3D CMS Logo

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 //BPHMultiSelectBase has the implementation needed for accept
46 // but does not itself override accept
47 template <class T>
48 class BPHMultiSelectBase : public T {
49 public:
53  switch (op) {
55  breakValue = true;
56  finalValue = false;
57  break;
59  breakValue = false;
60  finalValue = true;
61  break;
62  }
63  }
64 
67  ~BPHMultiSelectBase() override {}
68 
71  void include(T& s, bool m = true) {
73  SelectElement e;
74  e.selector = &s;
75  e.mode = m;
76  selectList.push_back(e);
77  return;
78  }
79 
80 protected:
81  template <class Obj>
82  bool select(const Obj& cand) const {
83  int i;
84  int n = selectList.size();
85  for (i = 0; i < n; ++i) {
86  const SelectElement& e = selectList[i];
87  if ((e.selector->accept(cand) == e.mode) == breakValue)
88  return breakValue;
89  }
90  return finalValue;
91  }
92  template <class Obj>
93  bool select(const Obj& cand, const BPHRecoBuilder* build) const {
94  int i;
95  int n = selectList.size();
96  for (i = 0; i < n; ++i) {
97  const SelectElement& e = selectList[i];
98  if ((e.selector->accept(cand, build) == e.mode) == breakValue)
99  return breakValue;
100  }
101  return finalValue;
102  }
103 
104 private:
105  // private copy and assigment constructors
106  BPHMultiSelectBase<T>(const BPHMultiSelectBase<T>& x) = delete;
107  BPHMultiSelectBase<T>& operator=(const BPHMultiSelectBase<T>& x) = delete;
108 
109  struct SelectElement {
111  bool mode;
112  };
113 
116  std::vector<SelectElement> selectList;
117 };
118 
119 template <class T>
121 public:
123 
127 
130  ~BPHMultiSelect() override {}
131 
133  bool accept(const typename T::AcceptArg& cand) const override;
134 
135 private:
136  // private copy and assigment constructors
137  BPHMultiSelect(const BPHMultiSelect<T>& x) = delete;
138  BPHMultiSelect& operator=(const BPHMultiSelect<T>& x) = delete;
139 };
140 
141 template <>
142 class BPHMultiSelect<BPHRecoSelect> : public BPHMultiSelectBase<BPHRecoSelect> {
143 public:
145 
149 
152  ~BPHMultiSelect() override {}
153 
155  bool accept(const typename BPHRecoSelect::AcceptArg& cand) const override;
156  bool accept(const reco::Candidate& cand, //NOLINT
157  const BPHRecoBuilder* build) const override; //NOLINT
158 
159 private:
160  // private copy and assigment constructors
162  BPHMultiSelect& operator=(const BPHMultiSelect<BPHRecoSelect>& x) = delete;
163 };
164 
165 template <>
167 template <>
169 template <>
171 
172 #endif
BPHMultiSelect(BPHSelectOperation::mode op)
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:30
bool accept(const typename T::AcceptArg &cand) const override
accept function
BPHMultiSelectBase(BPHSelectOperation::mode op)
bool select(const Obj &cand) const
~BPHMultiSelect() override
fixed size matrix
BPHMultiSelect(BPHSelectOperation::mode op)
bool include(const CollT &coll, const ItemT &item)
std::vector< SelectElement > selectList
long double T
bool select(const Obj &cand, const BPHRecoBuilder *build) const
~BPHMultiSelectBase() override