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 template<class T>
47 class BPHMultiSelect: public T {
48 
49  public:
50 
54  switch ( op ) {
56  breakValue = true;
57  finalValue = false;
58  break;
60  breakValue = false;
61  finalValue = true;
62  break;
63  }
64  }
65 
68  ~BPHMultiSelect() override {}
69 
72  void include( T& s, bool m = true ) {
75  e.selector = &s;
76  e.mode = m;
77  selectList.push_back( e );
78  return;
79  }
80 
82  bool accept( const reco::Candidate & cand, //NOLINT
83  const BPHRecoBuilder* build ) const { return false; } //NOLINT
84  bool accept( const reco::Candidate & cand ) const { return false; } //NOLINT
85  bool accept( const BPHDecayMomentum& cand ) const { return false; } //NOLINT
86  bool accept( const BPHDecayVertex & cand ) const { return false; } //NOLINT
87  bool accept( const BPHKinematicFit & cand ) const { return false; } //NOLINT
88 
89  private:
90 
91  // private copy and assigment constructors
92  BPHMultiSelect ( const BPHMultiSelect<T>& x ) = delete;
93  BPHMultiSelect& operator=( const BPHMultiSelect<T>& x ) = delete;
94 
95  struct SelectElement {
97  bool mode;
98  };
99 
102  std::vector<SelectElement> selectList;
103 
104  template<class Obj> bool select( const Obj& cand ) const {
105  int i;
106  int n = selectList.size();
107  for ( i = 0; i < n; ++i ) {
108  const SelectElement& e = selectList[i];
109  if ( ( e.selector->accept( cand ) == e.mode ) == breakValue )
110  return breakValue;
111  }
112  return finalValue;
113  }
114  template<class Obj> bool select( const Obj& cand,
115  const BPHRecoBuilder* build ) const {
116  int i;
117  int n = selectList.size();
118  for ( i = 0; i < n; ++i ) {
119  const SelectElement& e = selectList[i];
120  if ( ( e.selector->accept( cand, build ) == e.mode ) == breakValue )
121  return breakValue;
122  }
123  return finalValue;
124  }
125 
126 };
127 
128 template<>
130  const reco::Candidate & cand,
131  const BPHRecoBuilder* build ) const;
132 template<>
134  const reco::Candidate & cand ) const;
135 template<>
137  const BPHDecayMomentum& cand ) const;
138 template<>
140  const BPHDecayVertex & cand ) const;
141 template<>
143  const BPHKinematicFit & cand ) const;
144 
145 #endif
146 
BPHMultiSelect(BPHSelectOperation::mode op)
bool select(const Obj &cand, const BPHRecoBuilder *build) const
bool accept(const BPHKinematicFit &cand) const
bool select(const Obj &cand) const
std::vector< SelectElement > selectList
bool accept(const BPHDecayMomentum &cand) const
bool accept(const BPHDecayVertex &cand) const
~BPHMultiSelect() override
fixed size matrix
bool include(const CollT &coll, const ItemT &item)
bool accept(const reco::Candidate &cand, const BPHRecoBuilder *build) const
accept function
bool accept(const reco::Candidate &cand) const
long double T