Belle II Software development
TwoHitVariables.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#include <tracking/spacePointCreation/SpacePoint.h>
11#include <framework/geometry/B2Vector3.h>
12
13#include <cmath>
14
15namespace Belle2 {
20 namespace vxdHoughTracking {
21
24 public:
28 TwoHitVariables(const B2Vector3D& oHit, const B2Vector3D& iHit) : m_oHit(oHit), m_iHit(iHit)
29 {};
30
34 void setHits(const B2Vector3D& oHit, const B2Vector3D& iHit)
35 {
36 m_oHit = oHit;
37 m_iHit = iHit;
38 }
39
41 double getCosXY()
42 {
43 return (m_oHit.X() * m_iHit.X() + m_oHit.Y() * m_iHit.Y()) / (m_oHit.Perp() * m_iHit.Perp());
44 }
45
48 {
49 return m_oHit.Z() - m_iHit.Z();
50 }
51
54 {
55 return (m_oHit.Z() - m_iHit.Z()) * (m_oHit.Z() - m_iHit.Z());
56 }
57
60 {
61 return (m_oHit - m_iHit).Perp2();
62 }
63
66 {
67 return (m_oHit - m_iHit).Mag2();
68 }
69
71 double getRZSlope()
72 {
73 double result = atan(
74 sqrt(std::pow(double(m_oHit.X() - m_iHit.X()), 2)
75 + std::pow(double(m_oHit.Y() - m_iHit.Y()), 2)) /
76 double(m_oHit.Z() - m_iHit.Z()));
77 // atan also returns negative angles, so map back to [0,Pi] otherwise one get two peaks at +/-Pi/2 for 90 degree angles
78 if (result < 0.0) result += M_PI;
79
80 // TODO: check if 0 is a good default return value in the case z_i==z_o!
81 return (std::isnan(result) || std::isinf(result)) ? double(0) : result;
82 }
83
87 double getDistanceInTimeU(const SpacePoint& outerSpacePoint, const SpacePoint& innerSpacePoint)
88 {
89 return outerSpacePoint.TimeU() - innerSpacePoint.TimeU();
90 }
91
95 double getDistanceInTimeV(const SpacePoint& outerSpacePoint, const SpacePoint& innerSpacePoint)
96 {
97 return outerSpacePoint.TimeV() - innerSpacePoint.TimeV();
98 }
99
102 void setBFieldZ(const double bfieldZ = 1.5) { m_BFieldZ = bfieldZ; }
103
104 private:
106 double m_BFieldZ = 1.5;
111
112 };
113
114 }
116}
DataType Z() const
access variable Z (= .at(2) without boundary check)
Definition: B2Vector3.h:435
DataType X() const
access variable X (= .at(0) without boundary check)
Definition: B2Vector3.h:431
DataType Y() const
access variable Y (= .at(1) without boundary check)
Definition: B2Vector3.h:433
DataType Perp() const
The transverse component (R in cylindrical coordinate system).
Definition: B2Vector3.h:200
SpacePoint typically is build from 1 PXDCluster or 1-2 SVDClusters.
Definition: SpacePoint.h:42
double TimeV() const
return the time in ns of the cluster on the V side
Definition: SpacePoint.h:135
double TimeU() const
return the time in ns of the cluster on the U side
Definition: SpacePoint.h:132
Class that allows the calculation of simple variables to check whether a combination of two hits shou...
double getCosXY()
calculate the cosine of the angle between two vectors in x-y
double get3DDistanceSquared()
get the square of the difference of two vectors
double get1DZDistance()
get the difference in z between two vectors
double getDistanceInTimeV(const SpacePoint &outerSpacePoint, const SpacePoint &innerSpacePoint)
get the time difference of two space points for the v-side measurement
void setBFieldZ(const double bfieldZ=1.5)
Set the B-Field value used for pT calculations.
TwoHitVariables(const B2Vector3D &oHit, const B2Vector3D &iHit)
Constructor.
double m_BFieldZ
BField along z to estimate pT.
void setHits(const B2Vector3D &oHit, const B2Vector3D &iHit)
Set hits if not given in constructor of if they need to be changed.
double getDistanceInTimeU(const SpacePoint &outerSpacePoint, const SpacePoint &innerSpacePoint)
get the time difference of two space points for the u-side measurement
B2Vector3D m_oHit
outermost hit position
double get1DZDistanceSquared()
get the squared difference in z between two vectors
B2Vector3D m_iHit
innermost hit position
double get2DXYDistanceSquared()
get the squared distance between two vectors in x-y
double getRZSlope()
get an estimate for the slope in R-z, similar to theta
double atan(double a)
atan for double
Definition: beamHelpers.h:34
double sqrt(double a)
sqrt for double
Definition: beamHelpers.h:28
Abstract base class for different kinds of events.