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 //------------------------------------
18 // Collaborating Class Declarations --
19 //------------------------------------
24 class BPHRecoBuilder;
25 class BPHDecayMomentum;
26 class BPHDecayVertex;
27 
28 namespace reco {
29  class Candidate;
30 }
31 
32 //---------------
33 // C++ Headers --
34 //---------------
35 #include <vector>
36 
37 // ---------------------
38 // -- Class Interface --
39 // ---------------------
40 
42  public:
43  enum mode { or_mode, and_mode };
44 };
45 
46 
47 //BPHMultiSelectBase has the implementation needed for accept
48 // but does not itself override accept
49 template<class T>
50 class BPHMultiSelectBase : public T {
51 
52  public:
56  switch ( op ) {
58  breakValue = true;
59  finalValue = false;
60  break;
62  breakValue = false;
63  finalValue = true;
64  break;
65  }
66  }
67 
70  ~BPHMultiSelectBase() override {}
71 
74  void include( T& s, bool m = true ) {
76  SelectElement e;
77  e.selector = &s;
78  e.mode = m;
79  selectList.push_back( e );
80  return;
81  }
82 
83  protected:
84  template<class Obj> bool select( const Obj& cand ) const {
85  int i;
86  int n = selectList.size();
87  for ( i = 0; i < n; ++i ) {
88  const SelectElement& e = selectList[i];
89  if ( ( e.selector->accept( cand ) == e.mode ) == breakValue )
90  return breakValue;
91  }
92  return finalValue;
93  }
94  template<class Obj> bool select( const Obj& cand,
95  const BPHRecoBuilder* build ) const {
96  int i;
97  int n = selectList.size();
98  for ( i = 0; i < n; ++i ) {
99  const SelectElement& e = selectList[i];
100  if ( ( e.selector->accept( cand, build ) == e.mode ) == breakValue )
101  return breakValue;
102  }
103  return finalValue;
104  }
105 
106  private:
107 
108  // private copy and assigment constructors
109  BPHMultiSelectBase<T> ( const BPHMultiSelectBase<T>& x ) = delete;
110  BPHMultiSelectBase<T>& operator=( const BPHMultiSelectBase<T>& x ) = delete;
111 
112  struct SelectElement {
114  bool mode;
115  };
116 
119  std::vector<SelectElement> selectList;
120 
121 };
122 
123 template<class T>
125 
126  public:
128 
132  Base(op) {}
133 
136  ~BPHMultiSelect() override {}
137 
139  bool accept( const typename T::AcceptArg & cand ) const override;
140 
141  private:
142 
143  // private copy and assigment constructors
144  BPHMultiSelect ( const BPHMultiSelect<T>& x ) = delete;
145  BPHMultiSelect& operator=( const BPHMultiSelect<T>& x ) = delete;
146 };
147 
148 template<>
149 class BPHMultiSelect<BPHRecoSelect>: public BPHMultiSelectBase<BPHRecoSelect> {
150 
151  public:
153 
157  Base(op) {}
158 
161  ~BPHMultiSelect() override {}
162 
164  bool accept( const typename BPHRecoSelect::AcceptArg & cand ) const override;
165  bool accept( const reco::Candidate & cand, //NOLINT
166  const BPHRecoBuilder* build ) const override; //NOLINT
167 
168  private:
169 
170  // private copy and assigment constructors
171  BPHMultiSelect ( const BPHMultiSelect<BPHRecoSelect>& x ) = delete;
172  BPHMultiSelect& operator=( const BPHMultiSelect<BPHRecoSelect>& x ) = delete;
173 };
174 
175 template<>
177  const BPHDecayMomentum& cand ) const;
178 template<>
180  const BPHDecayVertex & cand ) const;
181 template<>
183  const BPHKinematicFit & cand ) const;
184 
185 #endif
186 
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