Belle II Software  release-08-01-10
Shortcuts.h
1 /**************************************************************************
2  * basf2 (Belle II Analysis Software Framework) *
3  * Author: The Belle II Collaboration *
4  * *
5  * See git log for contributors and copyright holders. *
6  * This file is licensed under LGPL-3.0, see LICENSE.md. *
7  **************************************************************************/
8 
9 #pragma once
10 
11 #include <tracking/trackFindingVXD/filterMap/filterFramework/SelectionVariable.h>
12 #include <tracking/trackFindingVXD/filterMap/filterFramework/Range.h>
13 #include <tracking/trackFindingVXD/filterMap/filterFramework/LowerBoundedSet.h>
14 #include <tracking/trackFindingVXD/filterMap/filterFramework/UpperBoundedSet.h>
15 #include <tracking/trackFindingVXD/filterMap/filterFramework/SingleElementSet.h>
16 
17 #include <tracking/trackFindingVXD/filterMap/filterFramework/ClosedLowerBoundedSet.h>
18 #include <tracking/trackFindingVXD/filterMap/filterFramework/ClosedUpperBoundedSet.h>
19 #include <tracking/trackFindingVXD/filterMap/filterFramework/ClosedRange.h>
20 
21 #include <tracking/trackFindingVXD/filterMap/filterFramework/VoidObserver.h>
22 #include <tracking/trackFindingVXD/filterMap/filterFramework/Filter.h>
23 
24 #include <type_traits>
25 
26 
27 namespace Belle2 {
40  template <class Var, class Arithmetic, typename ... types>
41  // the following typename expands to Filter<Var, UpperBoundedSet<Arithmetic>, VoidObserver>
42  // if Var derives from SelectionVariable and Arithmetic is an integer or a floating point type
43  // otherwise SFINAE ( Substitution Failure Is Not An Error )
44  typename
45  std::enable_if <
46  std::is_base_of<SelectionVariable<typename Var::argumentType, Var::c_Nargs, typename Var::variableType>, Var>::value&&
47  std::is_arithmetic<Arithmetic>::value,
49  operator < (const Var&, Arithmetic upperBound)
50  {
52  }
53 
54 
63  template <class Var, class Arithmetic, typename ... types>
64  // the following typename expands to Filter<Var, UpperBoundedSet<Arithmetic>, VoidObserver>
65  // if Var derives from SelectionVariable and Arithmetic is an integer or a floating point type
66  // otherwise SFINAE ( Substitution Failure Is Not An Error )
67  typename
68  std::enable_if <
69  std::is_base_of< SelectionVariable<typename Var::argumentType, Var::c_Nargs, typename Var::variableType>, Var>::value&&
70  std::is_arithmetic<Arithmetic>::value,
72  operator <= (const Var&, Arithmetic upperBound)
73  {
75  }
76 
77 
85  template <class Var, class Arithmetic>
86  // the following typename expands to Filter<Var, LowerBoundedSet<Arithmetic>, VoidObserver>
87  // if Var derives from SelectionVariable and Arithmetic is an integer or a floating point type
88  typename std::enable_if <
89  std::is_base_of<SelectionVariable<typename Var::argumentType, Var::c_Nargs, typename Var::variableType>, Var>::value
90  && std::is_arithmetic<Arithmetic>::value,
91  Filter<Var, LowerBoundedSet<Arithmetic>, VoidObserver> >::type
92  operator > (const Var&, Arithmetic lowerBound)
93  {
95  }
96 
97 
105  template <class Var, class Arithmetic>
106  // the following typename expands to Filter<Var, LowerBoundedSet<Arithmetic>, VoidObserver>
107  // if Var derives from SelectionVariable and Arithmetic is an integer or a floating point type
108  typename std::enable_if <
109  std::is_base_of<SelectionVariable<typename Var::argumentType, Var::c_Nargs, typename Var::variableType>, Var>::value
110  && std::is_arithmetic<Arithmetic>::value,
111  Filter<Var, ClosedLowerBoundedSet<Arithmetic>, VoidObserver> >::type
112  operator >= (const Var&, Arithmetic lowerBound)
113  {
115  }
116 
117 
125  template <class Var, class Arithmetic>
126  // the following typename expands to Filter<Var, UpperBoundedSet<Arithmetic>, VoidObserver>
127  // if Var derives from SelectionVariable and Arithmetic is an integer or a floating point type
128  typename std::enable_if <
129  std::is_base_of<SelectionVariable<typename Var::argumentType, Var::c_Nargs, typename Var::variableType>, Var>::value
130  && std::is_arithmetic<Arithmetic>::value,
131  Filter<Var, UpperBoundedSet<Arithmetic>, VoidObserver> >::type
132  operator > (Arithmetic upperBound, const Var&)
133  {
135  }
136 
137 
145  template <class Var, class Arithmetic>
146  // the following typename expands to Filter<Var, UpperBoundedSet<Arithmetic>, VoidObserver>
147  // if Var derives from SelectionVariable and Arithmetic is an integer or a floating point type
148  typename std::enable_if <
149  std::is_base_of<SelectionVariable<typename Var::argumentType, Var::c_Nargs, typename Var::variableType>, Var>::value
150  && std::is_arithmetic<Arithmetic>::value,
151  Filter<Var, ClosedUpperBoundedSet<Arithmetic>, VoidObserver> >::type
152  operator >= (Arithmetic upperBound, const Var&)
153  {
155  }
156 
157 
165  template <class Var, class Arithmetic>
166  // the following typename expands to Filter<Var, LowerBoundedSet<Arithmetic>, Observer>
167  // if Var derives from SelectionVariable and Arithmetic is an integer or a floating point type
168  typename std::enable_if <
169  std::is_base_of<SelectionVariable<typename Var::argumentType, Var::c_Nargs, typename Var::variableType>, Var>::value
170  && std::is_arithmetic<Arithmetic>::value,
172  operator < (Arithmetic lowerBound, const Var&)
173  {
175  }
176 
177 
185  template <class Var, class Arithmetic>
186  // the following typename expands to Filter<Var, LowerBoundedSet<Arithmetic>, Observer>
187  // if Var derives from SelectionVariable and Arithmetic is an integer or a floating point type
188  typename std::enable_if <
189  std::is_base_of<SelectionVariable<typename Var::argumentType, Var::c_Nargs, typename Var::variableType>, Var>::value
190  && std::is_arithmetic<Arithmetic>::value,
192  operator <= (Arithmetic lowerBound, const Var&)
193  {
195  }
196 
197 
205  template <class Var, class Val>
206  // the following typename expands to Filter<Var, SingleElementSet<Val>, VoidObserver>
207  // if Var derives from SelectionVariable
208  typename std::enable_if
209  <std::is_base_of<SelectionVariable<typename Var::argumentType, Var::c_Nargs, typename Var::variableType>, Var>::value,
210  Filter<Var, SingleElementSet<Val>, VoidObserver> >::type
211  operator == (const Var&, Val v)
212  {
214  }
215 
216 
225  template <class Var, class Val>
226  // the following typename expands to Filter<Var, SingleElementSet<Val>, VoidObserver>
227  // if Var derives from SelectionVariable
228  typename std::enable_if
229  <std::is_base_of<SelectionVariable<typename Var::argumentType, Var::c_Nargs, typename Var::variableType>, Var>::value,
230  Filter<Var, SingleElementSet<Val>, VoidObserver> >::type
231  operator == (Val val, const Var& var)
232  {
233  return var == val;
234  }
235 
236 
248  template <class Var, class ArithmeticLower, class ArithmeticUpper, class Observer>
249  // the following typename expands to Filter<Var, Range<ArithmeticLower, ArithmeticUpper>, Observer>
250  // if Var derives from SelectionVariable and Arithmetics are integer or floating point types
251  typename std::enable_if <
252  std::is_base_of<SelectionVariable<typename Var::argumentType, Var::c_Nargs, typename Var::variableType>, Var>::value
253  && std::is_arithmetic<ArithmeticLower>::value
254  && std::is_arithmetic<ArithmeticUpper>::value,
256  operator < (const Filter<Var, LowerBoundedSet<ArithmeticLower>, Observer>& filter, ArithmeticUpper upperBound)
257  {
259  (Range<ArithmeticLower, ArithmeticUpper> (filter.getRange().getInf(), upperBound));
260  }
261 
262 
274  template <class Var, class ArithmeticLower, class ArithmeticUpper, class Observer>
275  // the following typename expands to Filter<Var, Range<ArithmeticLower, ArithmeticUpper>, Observer>
276  // if Var derives from SelectionVariable and Arithmetics are integer or floating point types
277  typename std::enable_if <
278  std::is_base_of<SelectionVariable<typename Var::argumentType, Var::c_Nargs, typename Var::variableType>, Var>::value
279  && std::is_arithmetic<ArithmeticLower>::value
280  && std::is_arithmetic<ArithmeticUpper>::value,
281  Filter<Var, Range<ArithmeticLower, ArithmeticUpper>, Observer >>::type
282  operator > (const Filter<Var, UpperBoundedSet<ArithmeticUpper>, Observer>& filter, ArithmeticLower lowerBound)
283  {
285  (Range<ArithmeticLower, ArithmeticUpper> (lowerBound, filter.getRange().getSup()));
286  }
287 
288 
300  template <class Var, class ArithmeticLower, class ArithmeticUpper, class Observer>
301  // the following typename expands to Filter<Var, ClosedRange<ArithmeticLower, ArithmeticUpper>, Observer>
302  // if Var derives from SelectionVariable and Arithmetics are integer or floating point types
303  typename std::enable_if <
304  std::is_base_of<SelectionVariable<typename Var::argumentType, Var::c_Nargs, typename Var::variableType>, Var>::value
305  && std::is_arithmetic<ArithmeticLower>::value
306  && std::is_arithmetic<ArithmeticUpper>::value,
308  operator <= (const Filter<Var, ClosedLowerBoundedSet<ArithmeticLower>, Observer>& filter, ArithmeticUpper upperBound)
309  {
311  (ClosedRange<ArithmeticLower, ArithmeticUpper> (filter.getRange().getInf(), upperBound));
312  }
313 
314 
326  template <class Var, class ArithmeticLower, class ArithmeticUpper, class Observer>
327  // the following typename expands to Filter<Var, ClosedRange<ArithmeticLower, ArithmeticUpper>, Observer>
328  // if Var derives from SelectionVariable and Arithmetics are integer or floating point types
329  typename std::enable_if <
330  std::is_base_of<SelectionVariable<typename Var::argumentType, Var::c_Nargs, typename Var::variableType>, Var>::value
331  && std::is_arithmetic<ArithmeticLower>::value
332  && std::is_arithmetic<ArithmeticUpper>::value,
333  Filter<Var, ClosedRange<ArithmeticLower, ArithmeticUpper>, Observer >>::type
334  operator >= (const Filter<Var, ClosedUpperBoundedSet<ArithmeticUpper>, Observer>& filter, ArithmeticLower lowerBound)
335  {
337  (ClosedRange<ArithmeticLower, ArithmeticUpper> (lowerBound, filter.getRange().getSup()));
338  }
340 }
Represents a closed lower bounded set of arithmetic types.
Represents a closed set of arithmetic types.
Definition: ClosedRange.h:32
Represents an upper bounded set of arithmetic types.
This class is used to select pairs, triplets...
Definition: Filter.h:34
Represents a lower bounded set of arithmetic types.
Observer base class which can be used to evaluate the VXDTF2's Filters.
Definition: Observer.h:19
Represents a range of arithmetic types.
Definition: Range.h:29
Represents a set containing a single element;.
Represents an upper bounded set of arithmetic types.
The most CPU efficient Observer for the VXDTF filter tools (even if useless).
Definition: VoidObserver.h:30
bool operator==(const DecayNode &node1, const DecayNode &node2)
Compare two Decay Nodes: They are equal if All daughter decay nodes are equal or one of the daughter ...
Definition: DecayNode.cc:48
std::enable_if< std::is_base_of< SelectionVariable< typename Var::argumentType, Var::c_Nargs, typename Var::variableType >, Var >::value &&std::is_arithmetic< Arithmetic >::value, Filter< Var, ClosedLowerBoundedSet< Arithmetic >, VoidObserver > >::type operator>=(const Var &, Arithmetic lowerBound)
Creates a Filters with a closed lower bound >= on the provided variable Var >= lowerBound.
Definition: Shortcuts.h:112
std::map< ExpRun, std::pair< double, double > > filter(const std::map< ExpRun, std::pair< double, double >> &runs, double cut, std::map< ExpRun, std::pair< double, double >> &runsRemoved)
filter events to remove runs shorter than cut, it stores removed runs in runsRemoved
Definition: Splitter.cc:38
std::enable_if< std::is_base_of< SelectionVariable< typename Var::argumentType, Var::c_Nargs, typename Var::variableType >, Var >::value &&std::is_arithmetic< Arithmetic >::value, Filter< Var, LowerBoundedSet< Arithmetic >, VoidObserver > >::type operator>(const Var &, Arithmetic lowerBound)
Creates a Filters with an lower bound > on the provided variable Var > lowerBound.
Definition: Shortcuts.h:92
bool operator<(ExpRun a, ExpRun b)
less than for ExpRun
Definition: Splitter.h:74
std::enable_if< std::is_base_of< SelectionVariable< typename Var::argumentType, Var::c_Nargs, typename Var::variableType >, Var >::value &&std::is_arithmetic< Arithmetic >::value, Filter< Var, ClosedUpperBoundedSet< Arithmetic >, VoidObserver > >::type operator<=(const Var &, Arithmetic upperBound)
Creates a Filters with a closed upper bound <= on the provided variable Var <= lowerBound.
Definition: Shortcuts.h:72
Abstract base class for different kinds of events.