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 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
BPHMultiSelectBase::Obj
typename T::AcceptArg Obj
Definition: BPHMultiSelect.h:86
BPHMultiSelectBase::select
bool select(const Obj &cand) const
Definition: BPHMultiSelect.h:87
BPHMultiSelect::BPHMultiSelect
BPHMultiSelect(BPHSelectOperation::mode op)
Definition: BPHMultiSelect.h:172
BPHFitSelect.h
mps_fire.i
i
Definition: mps_fire.py:428
BPHSelectOperation
Definition: BPHMultiSelect.h:40
BPHFullSelect::accept
bool accept(const typename T::AcceptArg &cand, const BPHRecoBuilder *build) const override
accept function
Definition: BPHMultiSelect.h:162
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
configurableAnalysis::Candidate
char Candidate[]
Definition: modules.cc:20
BPHSlimSelect::accept
bool accept(const typename T::AcceptArg &cand) const override
accept function
Definition: BPHMultiSelect.h:139
BPHRecoSelect.h
DDAxes::x
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:46
newFWLiteAna.build
build
Definition: newFWLiteAna.py:126
BPHMultiSelect::~BPHMultiSelect
~BPHMultiSelect() override
Definition: BPHMultiSelect.h:180
BPHMultiSelectBase::BPHMultiSelectBase
BPHMultiSelectBase(BPHSelectOperation::mode op)
Definition: BPHMultiSelect.h:50
BPHMultiSelectBase::SelectElement
Definition: BPHMultiSelect.h:109
BPHFullSelect::~BPHFullSelect
~BPHFullSelect() override
Definition: BPHMultiSelect.h:157
BPHMultiSelectBase::SelectElement::selector
T * selector
Definition: BPHMultiSelect.h:110
alignCSCRings.s
s
Definition: alignCSCRings.py:92
BPHRecoBuilder
Definition: BPHRecoBuilder.h:50
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:79
BPHFullSelect::operator=
BPHFullSelect & operator=(const BPHFullSelect< T > &x)
BPHMultiSelectBase::SelectElement::mode
bool mode
Definition: BPHMultiSelect.h:111
BPHDecayMomentum
Definition: BPHDecayMomentum.h:35
BPHDecayVertex
Definition: BPHDecayVertex.h:43
BPHMultiSelectBase::include
void include(T &s, bool m=true)
include selection
Definition: BPHMultiSelect.h:74
BPHSelectOperation::and_mode
Definition: BPHMultiSelect.h:42
BPHSelectOperation::mode
mode
Definition: BPHMultiSelect.h:42
BPHSlimSelect::operator=
BPHSlimSelect & operator=(const BPHSlimSelect< T > &x)=delete
BPHMomentumSelect.h
BPHMultiSelect::operator=
BPHMultiSelect & operator=(const BPHMultiSelect< T > &x)=delete
BPHMultiSelectBase::operator=
BPHMultiSelectBase & operator=(const BPHMultiSelectBase< T > &x)=delete
cand
Definition: decayParser.h:32
BPHFullSelect::BPHFullSelect
BPHFullSelect(BPHSelectOperation::mode op)
Definition: BPHMultiSelect.h:149
BPHSlimSelect
Definition: BPHMultiSelect.h:120
BPHMultiSelectBase::select
bool select(const Obj &cand, const BPHRecoBuilder *build) const
Definition: BPHMultiSelect.h:97
BPHMultiSelect
Definition: BPHMultiSelect.h:168
BPHSlimSelect::BPHSlimSelect
BPHSlimSelect(BPHSelectOperation::mode op)
Definition: BPHMultiSelect.h:126
BPHMultiSelectBase::selectList
std::vector< SelectElement > selectList
Definition: BPHMultiSelect.h:116
BPHSlimSelect::~BPHSlimSelect
~BPHSlimSelect() override
Definition: BPHMultiSelect.h:134
BPHVertexSelect.h
BPHMultiSelectBase::count
unsigned int count()
component count
Definition: BPHMultiSelect.h:83
BPHMultiSelectBase::~BPHMultiSelectBase
~BPHMultiSelectBase() override
Definition: BPHMultiSelect.h:69
T
long double T
Definition: Basic3DVectorLD.h:48
BPHSelectOperation::or_mode
Definition: BPHMultiSelect.h:42
BPHMultiSelectBase
Definition: BPHMultiSelect.h:46
BPHMultiSelectBase::finalValue
bool finalValue
Definition: BPHMultiSelect.h:115
BPHFullSelect
Definition: BPHMultiSelect.h:143
BPHMultiSelectBase::breakValue
bool breakValue
Definition: BPHMultiSelect.h:114
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37