Belle II Software  release-08-01-10
Modulo.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 #pragma once
9 
10 namespace Belle2 {
15  namespace TrackFindingCDC {
20  inline int modulo(int numerator, int denominator)
21  {
22  return ((numerator % denominator) + denominator) % denominator;
23  }
24 
32  inline int moduloFast(int numerator, int denominator)
33  {
34  while (numerator < 0) numerator += denominator;
35  while (numerator >= denominator) numerator -= denominator;
36  return numerator;
37  }
38 
44  inline int symmetricModulo(int numerator, int denominator)
45  {
46  return modulo(numerator + denominator / 2, denominator) - denominator / 2;
47  }
48 
57  inline int symmetricModuloFast(int numerator, int denominator)
58  {
59  return moduloFast(numerator + denominator / 2, denominator) - denominator / 2;
60  }
61 
63  template<class AInt>
64  inline bool isEven(const AInt& x)
65  {
66  return (x % 2) == 0;
67  }
68 
70  template<class AInt>
71  inline bool isOdd(const AInt& x)
72  {
73  return (x % 2) != 0;
74  }
75  }
77 }
Abstract base class for different kinds of events.