Belle II Software  release-08-01-10
TwoHitFilters.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 <framework/geometry/B2Vector3.h>
12 #include <math.h>
13 
14 
15 
16 namespace Belle2 {
22  class TwoHitFilters {
23  public:
24 
27  m_x2(0.),
28  m_y2(0.),
29  m_z2(0.),
30  m_dz(0.)
31  {
32  m_hitA.SetXYZ(0., 0., 0.);
33  m_hitB.SetXYZ(0., 0., 0.);
34  }
35 
37  TwoHitFilters(const B2Vector3D& outerHit, const B2Vector3D& innerHit):
38  m_hitA(outerHit),
39  m_hitB(innerHit) { initializeMe(outerHit, innerHit); }
40 
41 
44 
46  void resetValues(const B2Vector3D& outerHit, const B2Vector3D& innerHit)
47  {
48  m_hitA = outerHit;
49  m_hitB = innerHit;
50 
51  initializeMe(outerHit, innerHit);
52  }
53 
55  double calcDist3D() const { return (m_x2 + m_y2 + m_z2); } // return unit: cm^2
56 
58  double fullDist3D() const { return sqrt(calcDist3D()); } // return unit: cm
59 
61  double calcDistXY() const { return (m_x2 + m_y2); } // return unit: cm^2
62 
64  double fullDistXY() const { return sqrt(calcDistXY()); } // return unit: cm
65 
67  double calcDistZ() const { return m_dz; } // return unit: cm
68 
70  double calcSlopeRZ() const
71  {
72  //double slope = atan (calcDistXY() / m_dz) ;
73  double slope = atan(fullDistXY() / m_dz) ; //since calcDistXY() returns cm ^2
74  return filterNan(slope);
75  } // return unit: radians
76 
78  double fullSlopeRZ() const { return calcSlopeRZ(); }
79 
81  double calcNormedDist3D() const
82  {
83  double normedVal = calcDistXY() / calcDist3D();
84  return filterNan(normedVal);
85  } // return unit: none
86 
88  double filterNan(double value) const;
89 
90  protected:
91 
93  void initializeMe(const B2Vector3D& outerHit, const B2Vector3D& innerHit)
94  {
95  m_x2 = outerHit[0] - innerHit[0]; // not x2 yet, reusing member
96  m_y2 = outerHit[1] - innerHit[1];
97  m_dz = outerHit[2] - innerHit[2];
98 
99  m_x2 *= m_x2; // now it's x2...
100  m_y2 *= m_y2;
101  m_z2 = m_dz * m_dz;
102  }
103 
104  B2Vector3D
106  B2Vector3D
108  double m_x2;
109  double m_y2;
110  double m_z2;
111  double m_dz;
113  }; //end class TwoHitFilters
115 } //end namespace Belle2
void SetXYZ(DataType x, DataType y, DataType z)
set all coordinates using data type
Definition: B2Vector3.h:464
The class 'TwoHitFilters' bundles filter methods using 2 hits which are stored in B2Vector3Ds.
Definition: TwoHitFilters.h:22
double calcNormedDist3D() const
calculates the normed distance between the hits (3D), return unit: none
Definition: TwoHitFilters.h:81
void initializeMe(const B2Vector3D &outerHit, const B2Vector3D &innerHit)
initializer function, sets values
Definition: TwoHitFilters.h:93
double calcDist3D() const
calculates the distance between the hits (3D), returning unit: cm^2 for speed optimization
Definition: TwoHitFilters.h:55
double m_x2
internal intermediate value storing x^2, no enduser-relevance
double calcDistXY() const
calculates the distance between the hits (XY), returning unit: cm^2 for speed optimization
Definition: TwoHitFilters.h:61
double fullDistXY() const
calculates the real distance between the hits (XY), returning unit: cm
Definition: TwoHitFilters.h:64
double m_dz
internal intermediate value storing distance in z, no enduser-relevance
TwoHitFilters()
Empty constructor.
Definition: TwoHitFilters.h:26
B2Vector3D m_hitB
inner hit (position relevant for useful filter calculation, e.g.
double filterNan(double value) const
nice little nanChecker returns 0 if value was nan or inf, else returns value itself
double calcSlopeRZ() const
calculates the angle of the slope of the hits in RZ, returnValue = theta = atan(r/z)
Definition: TwoHitFilters.h:70
double m_y2
internal intermediate value storing y^2, no enduser-relevance
TwoHitFilters(const B2Vector3D &outerHit, const B2Vector3D &innerHit)
Constructor.
Definition: TwoHitFilters.h:37
~TwoHitFilters()
Destructor.
Definition: TwoHitFilters.h:43
double fullDist3D() const
calculates the real distance between the hits (3D), returning unit: cm
Definition: TwoHitFilters.h:58
double fullSlopeRZ() const
calculates the angle of the slope of the hits in RZ, returnValue = theta = atan(r/z)
Definition: TwoHitFilters.h:78
double m_z2
internal intermediate value storing z^2, no enduser-relevance
double calcDistZ() const
calculates the distance between the hits (Z only), returning unit: cm
Definition: TwoHitFilters.h:67
void resetValues(const B2Vector3D &outerHit, const B2Vector3D &innerHit)
Overrides Constructor-Setup.
Definition: TwoHitFilters.h:46
B2Vector3D m_hitA
outer hit (position relevant for useful filter calculation, e.g.
double sqrt(double a)
sqrt for double
Definition: beamHelpers.h:28
double atan(double a)
atan for double
Definition: beamHelpers.h:34
Abstract base class for different kinds of events.