Belle II Software  release-05-02-19
Shortcuts.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2013 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Eugenio Paoloni *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #pragma once
12 
13 #include <tracking/trackFindingVXD/filterMap/filterFramework/SelectionVariable.h>
14 #include <tracking/trackFindingVXD/filterMap/filterFramework/Range.h>
15 #include <tracking/trackFindingVXD/filterMap/filterFramework/LowerBoundedSet.h>
16 #include <tracking/trackFindingVXD/filterMap/filterFramework/UpperBoundedSet.h>
17 #include <tracking/trackFindingVXD/filterMap/filterFramework/SingleElementSet.h>
18 
19 #include <tracking/trackFindingVXD/filterMap/filterFramework/ClosedLowerBoundedSet.h>
20 #include <tracking/trackFindingVXD/filterMap/filterFramework/ClosedUpperBoundedSet.h>
21 #include <tracking/trackFindingVXD/filterMap/filterFramework/ClosedRange.h>
22 
23 #include <tracking/trackFindingVXD/filterMap/filterFramework/VoidObserver.h>
24 #include <tracking/trackFindingVXD/filterMap/filterFramework/Filter.h>
25 
26 #include <type_traits>
27 
28 
29 namespace Belle2 {
42  template <class Var, class Arithmetic, typename ... types>
43  // the following typename expands to Filter<Var, UpperBoundedSet<Arithmetic>, VoidObserver>
44  // if Var derives from SelectionVariable and Arithmetic is an integer or a floating point type
45  // otherwise SFINAE ( Substitution Failure Is Not An Error )
46  typename
47  std::enable_if <
48  std::is_base_of<SelectionVariable<typename Var::argumentType, Var::c_Nargs, typename Var::variableType>, Var>::value&&
49  std::is_arithmetic<Arithmetic>::value,
50  Filter<Var, UpperBoundedSet<Arithmetic>, VoidObserver >>::type
51  operator < (const Var&, Arithmetic upperBound)
52  {
53  return Filter<Var, UpperBoundedSet<Arithmetic>, VoidObserver>(UpperBoundedSet<Arithmetic> (upperBound));
54  }
55 
56 
65  template <class Var, class Arithmetic, typename ... types>
66  // the following typename expands to Filter<Var, UpperBoundedSet<Arithmetic>, VoidObserver>
67  // if Var derives from SelectionVariable and Arithmetic is an integer or a floating point type
68  // otherwise SFINAE ( Substitution Failure Is Not An Error )
69  typename
70  std::enable_if <
71  std::is_base_of< SelectionVariable<typename Var::argumentType, Var::c_Nargs, typename Var::variableType>, Var>::value&&
72  std::is_arithmetic<Arithmetic>::value,
73  Filter<Var, ClosedUpperBoundedSet<Arithmetic>, VoidObserver> >::type
74  operator <= (const Var&, Arithmetic upperBound)
75  {
76  return Filter<Var, ClosedUpperBoundedSet<Arithmetic>, VoidObserver>(ClosedUpperBoundedSet<Arithmetic> (upperBound));
77  }
78 
79 
87  template <class Var, class Arithmetic>
88  // the following typename expands to Filter<Var, LowerBoundedSet<Arithmetic>, VoidObserver>
89  // if Var derives from SelectionVariable and Arithmetic is an integer or a floating point type
90  typename std::enable_if <
91  std::is_base_of<SelectionVariable<typename Var::argumentType, Var::c_Nargs, typename Var::variableType>, Var>::value
92  && std::is_arithmetic<Arithmetic>::value,
93  Filter<Var, LowerBoundedSet<Arithmetic>, VoidObserver> >::type
94  operator > (const Var&, Arithmetic lowerBound)
95  {
96  return Filter<Var, LowerBoundedSet<Arithmetic>, VoidObserver >(LowerBoundedSet<Arithmetic> (lowerBound));
97  }
98 
99 
107  template <class Var, class Arithmetic>
108  // the following typename expands to Filter<Var, LowerBoundedSet<Arithmetic>, VoidObserver>
109  // if Var derives from SelectionVariable and Arithmetic is an integer or a floating point type
110  typename std::enable_if <
111  std::is_base_of<SelectionVariable<typename Var::argumentType, Var::c_Nargs, typename Var::variableType>, Var>::value
112  && std::is_arithmetic<Arithmetic>::value,
113  Filter<Var, ClosedLowerBoundedSet<Arithmetic>, VoidObserver> >::type
114  operator >= (const Var&, Arithmetic lowerBound)
115  {
116  return Filter<Var, ClosedLowerBoundedSet<Arithmetic>, VoidObserver >(ClosedLowerBoundedSet<Arithmetic> (lowerBound));
117  }
118 
119 
127  template <class Var, class Arithmetic>
128  // the following typename expands to Filter<Var, UpperBoundedSet<Arithmetic>, VoidObserver>
129  // if Var derives from SelectionVariable and Arithmetic is an integer or a floating point type
130  typename std::enable_if <
131  std::is_base_of<SelectionVariable<typename Var::argumentType, Var::c_Nargs, typename Var::variableType>, Var>::value
132  && std::is_arithmetic<Arithmetic>::value,
133  Filter<Var, UpperBoundedSet<Arithmetic>, VoidObserver> >::type
134  operator > (Arithmetic upperBound, const Var&)
135  {
136  return Filter<Var, UpperBoundedSet<Arithmetic>, VoidObserver>(UpperBoundedSet<Arithmetic> (upperBound));
137  }
138 
139 
147  template <class Var, class Arithmetic>
148  // the following typename expands to Filter<Var, UpperBoundedSet<Arithmetic>, VoidObserver>
149  // if Var derives from SelectionVariable and Arithmetic is an integer or a floating point type
150  typename std::enable_if <
151  std::is_base_of<SelectionVariable<typename Var::argumentType, Var::c_Nargs, typename Var::variableType>, Var>::value
152  && std::is_arithmetic<Arithmetic>::value,
153  Filter<Var, ClosedUpperBoundedSet<Arithmetic>, VoidObserver> >::type
154  operator >= (Arithmetic upperBound, const Var&)
155  {
156  return Filter<Var, ClosedUpperBoundedSet<Arithmetic>, VoidObserver>(ClosedUpperBoundedSet<Arithmetic> (upperBound));
157  }
158 
159 
167  template <class Var, class Arithmetic>
168  // the following typename expands to Filter<Var, LowerBoundedSet<Arithmetic>, Observer>
169  // if Var derives from SelectionVariable and Arithmetic is an integer or a floating point type
170  typename std::enable_if <
171  std::is_base_of<SelectionVariable<typename Var::argumentType, Var::c_Nargs, typename Var::variableType>, Var>::value
172  && std::is_arithmetic<Arithmetic>::value,
173  Filter<Var, LowerBoundedSet<Arithmetic>, VoidObserver> >::type
174  operator < (Arithmetic lowerBound, const Var&)
175  {
176  return Filter<Var, LowerBoundedSet<Arithmetic>, VoidObserver>(LowerBoundedSet<Arithmetic> (lowerBound));
177  }
178 
179 
187  template <class Var, class Arithmetic>
188  // the following typename expands to Filter<Var, LowerBoundedSet<Arithmetic>, Observer>
189  // if Var derives from SelectionVariable and Arithmetic is an integer or a floating point type
190  typename std::enable_if <
191  std::is_base_of<SelectionVariable<typename Var::argumentType, Var::c_Nargs, typename Var::variableType>, Var>::value
192  && std::is_arithmetic<Arithmetic>::value,
193  Filter<Var, ClosedLowerBoundedSet<Arithmetic>, VoidObserver >>::type
194  operator <= (Arithmetic lowerBound, const Var&)
195  {
196  return Filter<Var, ClosedLowerBoundedSet<Arithmetic>, VoidObserver>(ClosedLowerBoundedSet<Arithmetic> (lowerBound));
197  }
198 
199 
207  template <class Var, class Val>
208  // the following typename expands to Filter<Var, SingleElementSet<Val>, VoidObserver>
209  // if Var derives from SelectionVariable
210  typename std::enable_if
211  <std::is_base_of<SelectionVariable<typename Var::argumentType, Var::c_Nargs, typename Var::variableType>, Var>::value,
212  Filter<Var, SingleElementSet<Val>, VoidObserver> >::type
213  operator == (const Var&, Val v)
214  {
215  return Filter<Var, SingleElementSet<Val>, VoidObserver>(SingleElementSet<Val> (v));
216  }
217 
218 
227  template <class Var, class Val>
228  // the following typename expands to Filter<Var, SingleElementSet<Val>, VoidObserver>
229  // if Var derives from SelectionVariable
230  typename std::enable_if
231  <std::is_base_of<SelectionVariable<typename Var::argumentType, Var::c_Nargs, typename Var::variableType>, Var>::value,
232  Filter<Var, SingleElementSet<Val>, VoidObserver> >::type
233  operator == (Val val, const Var& var)
234  {
235  return var == val;
236  }
237 
238 
250  template <class Var, class ArithmeticLower, class ArithmeticUpper, class Observer>
251  // the following typename expands to Filter<Var, Range<ArithmeticLower, ArithmeticUpper>, Observer>
252  // if Var derives from SelectionVariable and Arithmetics are integer or floating point types
253  typename std::enable_if <
254  std::is_base_of<SelectionVariable<typename Var::argumentType, Var::c_Nargs, typename Var::variableType>, Var>::value
255  && std::is_arithmetic<ArithmeticLower>::value
256  && std::is_arithmetic<ArithmeticUpper>::value ,
257  Filter<Var, Range<ArithmeticLower, ArithmeticUpper>, Observer >>::type
258  operator < (const Filter<Var, LowerBoundedSet<ArithmeticLower>, Observer>& filter, ArithmeticUpper upperBound)
259  {
260  return Filter<Var, Range<ArithmeticLower, ArithmeticUpper>, Observer>
261  (Range<ArithmeticLower, ArithmeticUpper> (filter.getRange().getInf(), upperBound));
262  }
263 
264 
276  template <class Var, class ArithmeticLower, class ArithmeticUpper, class Observer>
277  // the following typename expands to Filter<Var, Range<ArithmeticLower, ArithmeticUpper>, Observer>
278  // if Var derives from SelectionVariable and Arithmetics are integer or floating point types
279  typename std::enable_if <
280  std::is_base_of<SelectionVariable<typename Var::argumentType, Var::c_Nargs, typename Var::variableType>, Var>::value
281  && std::is_arithmetic<ArithmeticLower>::value
282  && std::is_arithmetic<ArithmeticUpper>::value ,
283  Filter<Var, Range<ArithmeticLower, ArithmeticUpper>, Observer >>::type
284  operator > (const Filter<Var, UpperBoundedSet<ArithmeticUpper>, Observer>& filter, ArithmeticLower lowerBound)
285  {
286  return Filter<Var, Range<ArithmeticLower, ArithmeticUpper>, Observer>
287  (Range<ArithmeticLower, ArithmeticUpper> (lowerBound , filter.getRange().getSup()));
288  }
289 
290 
302  template <class Var, class ArithmeticLower, class ArithmeticUpper, class Observer>
303  // the following typename expands to Filter<Var, ClosedRange<ArithmeticLower, ArithmeticUpper>, Observer>
304  // if Var derives from SelectionVariable and Arithmetics are integer or floating point types
305  typename std::enable_if <
306  std::is_base_of<SelectionVariable<typename Var::argumentType, Var::c_Nargs, typename Var::variableType>, Var>::value
307  && std::is_arithmetic<ArithmeticLower>::value
308  && std::is_arithmetic<ArithmeticUpper>::value ,
309  Filter<Var, ClosedRange<ArithmeticLower, ArithmeticUpper>, Observer >>::type
310  operator <= (const Filter<Var, ClosedLowerBoundedSet<ArithmeticLower>, Observer>& filter, ArithmeticUpper upperBound)
311  {
312  return Filter<Var, ClosedRange<ArithmeticLower, ArithmeticUpper>, Observer>
313  (ClosedRange<ArithmeticLower, ArithmeticUpper> (filter.getRange().getInf(), upperBound));
314  }
315 
316 
328  template <class Var, class ArithmeticLower, class ArithmeticUpper, class Observer>
329  // the following typename expands to Filter<Var, ClosedRange<ArithmeticLower, ArithmeticUpper>, Observer>
330  // if Var derives from SelectionVariable and Arithmetics are integer or floating point types
331  typename std::enable_if <
332  std::is_base_of<SelectionVariable<typename Var::argumentType, Var::c_Nargs, typename Var::variableType>, Var>::value
333  && std::is_arithmetic<ArithmeticLower>::value
334  && std::is_arithmetic<ArithmeticUpper>::value ,
335  Filter<Var, ClosedRange<ArithmeticLower, ArithmeticUpper>, Observer >>::type
336  operator >= (const Filter<Var, ClosedUpperBoundedSet<ArithmeticUpper> , Observer>& filter, ArithmeticLower lowerBound)
337  {
338  return Filter<Var, ClosedRange<ArithmeticLower, ArithmeticUpper>, Observer>
339  (ClosedRange<ArithmeticLower, ArithmeticUpper> (lowerBound , filter.getRange().getSup()));
340  }
342 }
Belle2::operator>
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:102
Belle2::operator==
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:50
Belle2::operator>=
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:122
Belle2::filter
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:43
Belle2::operator<
bool operator<(ExpRun a, ExpRun b)
less than for ExpRun
Definition: Splitter.h:78
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::operator<=
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:82