Belle II Software development
ThreeHitVariables Class Reference

Class that allows the calculation of simple variables to estimate the quality of a triplet of hits. More...

#include <ThreeHitVariables.h>

Public Member Functions

 ThreeHitVariables ()
 basic constructor
 
 ThreeHitVariables (const B2Vector3D &oHit, const B2Vector3D &cHit, const B2Vector3D &iHit)
 actual useful constructor
 
void setHits (const B2Vector3D &oHit, const B2Vector3D &cHit, const B2Vector3D &iHit)
 Set hits if not given in constructor of if they need to be changed.
 
double calcAvgDistanceXY (const B2Vector3D &circleCenter)
 helper function which calculates the average distance in XY from the given center
 
double getAngle3D ()
 calculates the angle between the hits/vectors (3D), returning unit: angle in radian
 
double getAngle3DSimple ()
 calculates the angle between the hits/vectors (3D), returning unit: none (calculation for degrees is incomplete, if you want readable numbers, use Angle3DFull instead)
 
double getAngleRZ ()
 calculates the angle between the hits/vectors (RZ), returning unit: angle in radian
 
double getCosAngleRZSimple ()
 calculates the cosine of the angle between the hits/vectors (RZ), returning unit: none (calculation for degrees is incomplete, if you want readable numbers, use AngleRZFull instead)
 
double getAngleXY ()
 Calculates the angle in x-y between two vectors return unit: rad (0 - pi)
 
B2Vector3D getCircleCenterXY ()
 calculates an estimation of circleCenter position, result is returned as the x and y value of the B2Vector3.
 
double getCircleDistanceIP ()
 calculates the distance of the point of closest approach of circle to the IP, returning unit: cm
 
double getCircleRadius ()
 calculates the estimation of the circle radius of the 3-hit-tracklet, returning unit: cm.
 
double getCosAngleXY ()
 calculates the angle between the hits/vectors (XY), returning unit: none (calculation for degrees is incomplete, if you want readable numbers, use AngleXYFull instead)
 
double getDeltaSlopeRZ ()
 calculates deviations in the slope of the inner segment and the outer segment, returning unit: none
 
double getDeltaSlopeZoverS ()
 compares the "slopes" z over arc length. calcDeltaSlopeZOverS is invariant under rotations in the r-z plane.
 
double getDeltaSoverZ ()
 calculates the helixparameter describing the deviation in arc length per unit in z. returning unit: radians*cm
 
double performHelixParamterFit ()
 calculates the helixparameter describing the deviation in z per unit angle, returning unit: none
 
double getSimplePTEstimate ()
 calculates the estimation of the transverse momentum of the 3-hit-tracklet, returning unit: GeV/c
 
int getCurvatureSign ()
 calculates calculates the sign of the curvature of given 3-hit-tracklet.
 
int getCurvatureSign (const B2Vector3D &oHit, const B2Vector3D &cHit, const B2Vector3D &iHit)
 calculates calculates the sign of the curvature of 3-hit-tracklet given as arguments.
 
void setBFieldZ (const double bfieldZ=1.5)
 Set the B-Field value used for pT calculations.
 

Private Attributes

double m_BFieldZ = 1.5
 BField along z to estimate pT.
 
B2Vector3D m_oHit
 outermost hit position
 
B2Vector3D m_cHit
 center hit position
 
B2Vector3D m_iHit
 innermost hit position
 
B2Vector3D m_outerDifferenceVector
 The following two differences are used very often, so calculate once on construction vector containing the difference m_oHit - m_cHit.
 
B2Vector3D m_innerDifferenceVector
 vector containing the difference m_cHit - m_iHit
 

Detailed Description

Class that allows the calculation of simple variables to estimate the quality of a triplet of hits.

Definition at line 25 of file ThreeHitVariables.h.

Constructor & Destructor Documentation

◆ ThreeHitVariables() [1/2]

ThreeHitVariables ( )
inline

basic constructor

Definition at line 28 of file ThreeHitVariables.h.

28 : m_oHit(0., 0., 0.), m_cHit(0., 0., 0.), m_iHit(0., 0., 0.),
30 {};
B2Vector3D m_outerDifferenceVector
The following two differences are used very often, so calculate once on construction vector containin...
B2Vector3D m_oHit
outermost hit position
B2Vector3D m_iHit
innermost hit position
B2Vector3D m_innerDifferenceVector
vector containing the difference m_cHit - m_iHit

◆ ThreeHitVariables() [2/2]

ThreeHitVariables ( const B2Vector3D oHit,
const B2Vector3D cHit,
const B2Vector3D iHit 
)
inline

actual useful constructor

Parameters
oHitB2Vector3D of the outer hit used for calculating the single variables
cHitB2Vector3D of the center hit used for calculating the single variables
iHitB2Vector3D of the inner hit used for calculating the single variables

Definition at line 36 of file ThreeHitVariables.h.

36 :
37 m_oHit(oHit), m_cHit(cHit), m_iHit(iHit)
38 {
39 m_outerDifferenceVector = oHit - cHit;
40 m_innerDifferenceVector = cHit - iHit;
41 };

Member Function Documentation

◆ calcAvgDistanceXY()

double calcAvgDistanceXY ( const B2Vector3D circleCenter)
inline

helper function which calculates the average distance in XY from the given center

Parameters
circleCentercenter of the cirlce for which the average distance is calculated returns the average distance in cm of the hits to the circle center position

Definition at line 59 of file ThreeHitVariables.h.

60 {
61 return (sqrt(std::pow(circleCenter.X() - m_oHit.X(), 2) + std::pow(circleCenter.Y() - m_oHit.Y(), 2)) +
62 sqrt(std::pow(circleCenter.X() - m_cHit.X(), 2) + std::pow(circleCenter.Y() - m_cHit.Y(), 2)) +
63 sqrt(std::pow(circleCenter.X() - m_iHit.X(), 2) + std::pow(circleCenter.Y() - m_iHit.Y(), 2))) / 3.;
64 }
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
double sqrt(double a)
sqrt for double
Definition: beamHelpers.h:28

◆ getAngle3D()

double getAngle3D ( )
inline

calculates the angle between the hits/vectors (3D), returning unit: angle in radian

Definition at line 68 of file ThreeHitVariables.h.

69 {
72 return (std::isnan(result) || std::isinf(result)) ? double(0) : result;
73 }
DataType Mag() const
The magnitude (rho in spherical coordinate system).
Definition: B2Vector3.h:159
DataType Dot(const B2Vector3< DataType > &p) const
Scalar product.
Definition: B2Vector3.h:290

◆ getAngle3DSimple()

double getAngle3DSimple ( )
inline

calculates the angle between the hits/vectors (3D), returning unit: none (calculation for degrees is incomplete, if you want readable numbers, use Angle3DFull instead)

Definition at line 77 of file ThreeHitVariables.h.

78 {
79 // fullCalc would be acos(m_vecAB.Dot(m_vecBC) / m_vecAB.Mag()*m_vecBC.Mag()), but here time-consuming parts have been neglected
82 return (std::isnan(result) || std::isinf(result)) ? double(0) : result;
83 }
DataType Mag2() const
The magnitude squared (rho^2 in spherical coordinate system).
Definition: B2Vector3.h:157

◆ getAngleRZ()

double getAngleRZ ( )
inline

calculates the angle between the hits/vectors (RZ), returning unit: angle in radian

Definition at line 87 of file ThreeHitVariables.h.

88 {
91 TwoHitVariables twoHitVariables(rzVecAB, rzVecBC);
92
93 double result = acos(twoHitVariables.getCosXY()); // 0-pi
94 return (std::isnan(result) || std::isinf(result)) ? double(0) : result;
95 } // return unit: rad (0 - pi)
DataType Z() const
access variable Z (= .at(2) without boundary check)
Definition: B2Vector3.h:435
DataType Perp() const
The transverse component (R in cylindrical coordinate system).
Definition: B2Vector3.h:200
B2Vector3< double > B2Vector3D
typedef for common usage with double
Definition: B2Vector3.h:516

◆ getAngleXY()

double getAngleXY ( )
inline

Calculates the angle in x-y between two vectors return unit: rad (0 - pi)

Definition at line 110 of file ThreeHitVariables.h.

111 {
112 TwoHitVariables twoHitVariables(m_outerDifferenceVector, m_innerDifferenceVector);
113 double result = acos(twoHitVariables.getCosXY()); // 0-pi
114 return (std::isnan(result) || std::isinf(result)) ? double(0) : result;
115 }

◆ getCircleCenterXY()

B2Vector3D getCircleCenterXY ( )
inline

calculates an estimation of circleCenter position, result is returned as the x and y value of the B2Vector3.

Definition at line 119 of file ThreeHitVariables.h.

120 {
121 // calculates the intersection point using Cramer's rule.
122 // x_1+s*n_1==x_2+t*n_2 --> n_1 *s - n_2 *t == x_2 - x_1 --> http://en.wikipedia.org/wiki/Cramer%27s_rule
123 double inX = m_cHit.X() - m_iHit.X(); // x value of the normal vector of the inner segment (m_cHit-m_iHit)
124 double inY = m_cHit.Y() - m_iHit.Y(); // y value of the normal vector of the inner segment (m_cHit-m_iHit)
125 double outX = m_oHit.X() - m_cHit.X(); // x value of the normal vector of the outer segment (m_oHit-m_cHit)
126 double outY = m_oHit.Y() - m_cHit.Y(); // y value of the normal vector of the outer segment (m_oHit-m_cHit)
127
128 // searching solution for Ax = b, aij are the matrix elements of A, bi are elements of b
129 double a11 = inY;
130 double a12 = -inX;
131 double a21 = -outY;
132 double a22 = outX;
133 double b1 = m_cHit.X() + outX * 0.5 - (m_iHit.X() + inX * 0.5);
134 double b2 = m_cHit.Y() + outY * 0.5 - (m_iHit.Y() + inY * 0.5);
135
136 // protect against the determinant being zero
137 if (a11 * a22 == a12 * a21) {
138 return B2Vector3D(1e30, 1e30, 1e30);
139 }
140
141 // the determinant is zero if the three hits are on a line in (x,y), which is checked above.
142 double s = (b1 * a22 - b2 * a21) / (a11 * a22 - a12 * a21);
143
144 return B2Vector3D(m_iHit.X() + inX * 0.5 + s * inY, m_iHit.Y() + inY * 0.5 - s * inX, 0.);
145 }

◆ getCircleDistanceIP()

double getCircleDistanceIP ( )
inline

calculates the distance of the point of closest approach of circle to the IP, returning unit: cm

Definition at line 149 of file ThreeHitVariables.h.

150 {
151 B2Vector3D circleCenter = getCircleCenterXY();
152 if (circleCenter.Perp2() > 1e30) {
153 return NAN;
154 }
155 double circleRadius = calcAvgDistanceXY(circleCenter);
156
157 // distance of closest approach of circle to the IP :
158 // WARNING only valid for IP=0,0,X
159 return (fabs(circleCenter.Perp() - circleRadius));
160 }
B2Vector3D getCircleCenterXY()
calculates an estimation of circleCenter position, result is returned as the x and y value of the B2V...
double calcAvgDistanceXY(const B2Vector3D &circleCenter)
helper function which calculates the average distance in XY from the given center

◆ getCircleRadius()

double getCircleRadius ( )
inline

calculates the estimation of the circle radius of the 3-hit-tracklet, returning unit: cm.

Definition at line 164 of file ThreeHitVariables.h.

165 {
166 B2Vector3D circleCenter = getCircleCenterXY();
167 if (circleCenter.Perp2() > 1e30) {
168 return NAN;
169 }
170 return calcAvgDistanceXY(circleCenter);
171 }

◆ getCosAngleRZSimple()

double getCosAngleRZSimple ( )
inline

calculates the cosine of the angle between the hits/vectors (RZ), returning unit: none (calculation for degrees is incomplete, if you want readable numbers, use AngleRZFull instead)

Definition at line 99 of file ThreeHitVariables.h.

100 {
103 TwoHitVariables twoHitVariables(rzVecAB, rzVecBC);
104
105 return twoHitVariables.getCosXY();
106 }

◆ getCosAngleXY()

double getCosAngleXY ( )
inline

calculates the angle between the hits/vectors (XY), returning unit: none (calculation for degrees is incomplete, if you want readable numbers, use AngleXYFull instead)

Definition at line 176 of file ThreeHitVariables.h.

177 {
178 double result = (m_outerDifferenceVector.X() * m_innerDifferenceVector.X() +
181
182 return (std::isnan(result) || std::isinf(result)) ? double(0) : result;
183 }

◆ getCurvatureSign() [1/2]

int getCurvatureSign ( )
inline

calculates calculates the sign of the curvature of given 3-hit-tracklet.

A positive value represents a left-oriented curvature, a negative value means having a right-oriented curvature. 0 means that it is exactly straight or that two hits are identical.

Definition at line 286 of file ThreeHitVariables.h.

287 {
288 using boost::math::sign;
289 B2Vector3D ba(m_oHit.X() - m_cHit.X(), m_oHit.Y() - m_cHit.Y(), 0.0);
290 B2Vector3D bc(m_cHit.X() - m_iHit.X(), m_cHit.Y() - m_iHit.Y(), 0.0);
291 return sign(bc.Orthogonal() * ba); //normal vector of m_vecBC times segment of ba
292 }

◆ getCurvatureSign() [2/2]

int getCurvatureSign ( const B2Vector3D oHit,
const B2Vector3D cHit,
const B2Vector3D iHit 
)
inline

calculates calculates the sign of the curvature of 3-hit-tracklet given as arguments.

A positive value represents a left-oriented curvature, a negative value means having a right-oriented curvature. 0 means that it is exactly straight or that two hits are identical.

Definition at line 297 of file ThreeHitVariables.h.

298 {
299 using boost::math::sign;
300 B2Vector3D ba(oHit.X() - cHit.X(), oHit.Y() - cHit.Y(), 0.0);
301 B2Vector3D bc(cHit.X() - iHit.X(), cHit.Y() - iHit.Y(), 0.0);
302 return sign(bc.Orthogonal() * ba); //normal vector of m_vecBC times segment of ba
303 }

◆ getDeltaSlopeRZ()

double getDeltaSlopeRZ ( )
inline

calculates deviations in the slope of the inner segment and the outer segment, returning unit: none

Definition at line 187 of file ThreeHitVariables.h.

188 {
189 TwoHitVariables outerTwoHitVariables(m_oHit, m_cHit);
190 TwoHitVariables innerTwoHitVariables(m_cHit, m_iHit);
191 double slopeOC = outerTwoHitVariables.getRZSlope();
192 double slopeCI = innerTwoHitVariables.getRZSlope();
193
194 return slopeCI - slopeOC;
195 }

◆ getDeltaSlopeZoverS()

double getDeltaSlopeZoverS ( )
inline

compares the "slopes" z over arc length. calcDeltaSlopeZOverS is invariant under rotations in the r-z plane.

Definition at line 199 of file ThreeHitVariables.h.

200 {
201 B2Vector3D circleCenter = getCircleCenterXY();
202 if (circleCenter.Perp2() > 1e30) {
203 return NAN;
204 }
205 double circleRadius = calcAvgDistanceXY(circleCenter);
206 B2Vector3D vecOuter2cC = m_oHit - circleCenter;
207 B2Vector3D vecCenter2cC = m_cHit - circleCenter;
208 B2Vector3D vecInner2cC = m_iHit - circleCenter;
209
210 TwoHitVariables outerTwoHitVariables(vecOuter2cC, vecCenter2cC);
211 TwoHitVariables innerTwoHitVariables(vecCenter2cC, vecInner2cC);
212
213 // WARNING: this is only approximately S (valid in the limit of small angles) but might be OK for this use!!!
214 // want to replace id with 2*sin ( alfa ) * circleRadius
215 double alfaOCr = acos(outerTwoHitVariables.getCosXY()) * circleRadius ;
216 double alfaCIr = acos(innerTwoHitVariables.getCosXY()) * circleRadius ;
217
218 // Beware of z>r!:
219 double result = (asin(double(m_oHit.Z() - m_cHit.Z()) / alfaOCr)) - asin(double(m_cHit.Z() - m_iHit.Z()) / alfaCIr);
220
221 return (std::isnan(result) || std::isinf(result)) ? double(0) : result;
222 }

◆ getDeltaSoverZ()

double getDeltaSoverZ ( )
inline

calculates the helixparameter describing the deviation in arc length per unit in z. returning unit: radians*cm

Definition at line 226 of file ThreeHitVariables.h.

227 {
228 B2Vector3D circleCenter = getCircleCenterXY();
229 if (circleCenter.Perp2() > 1e30) {
230 return NAN;
231 }
232 B2Vector3D vecOuter2cC = m_oHit - circleCenter;
233 B2Vector3D vecCenter2cC = m_cHit - circleCenter;
234 B2Vector3D vecInner2cC = m_iHit - circleCenter;
235
236 TwoHitVariables outerTwoHitVariables(vecOuter2cC, vecCenter2cC);
237 TwoHitVariables innerTwoHitVariables(vecCenter2cC, vecInner2cC);
238 double alfaOC = acos(outerTwoHitVariables.getCosXY());
239 double alfaCI = acos(innerTwoHitVariables.getCosXY());
240
241 // equals to alfaAB/dZAB and alfaBC/dZBC, but this solution here can not produce a division by zero:
242 return (alfaOC * double(m_cHit.Z() - m_iHit.Z())) - (alfaCI * double(m_oHit.Z() - m_cHit.Z()));
243 }

◆ getSimplePTEstimate()

double getSimplePTEstimate ( )
inline

calculates the estimation of the transverse momentum of the 3-hit-tracklet, returning unit: GeV/c

Definition at line 271 of file ThreeHitVariables.h.

272 {
273 B2Vector3D circleCenter = getCircleCenterXY();
274 if (circleCenter.Perp2() > 1e30) {
275 return NAN;
276 }
277 double circleRadius = calcAvgDistanceXY(circleCenter);
278
279 return 0.00299792458 * m_BFieldZ * circleRadius;
280 }
double m_BFieldZ
BField along z to estimate pT.

◆ performHelixParamterFit()

double performHelixParamterFit ( )
inline

calculates the helixparameter describing the deviation in z per unit angle, returning unit: none

Definition at line 247 of file ThreeHitVariables.h.

248 {
249 B2Vector3D circleCenter = getCircleCenterXY();
250 if (circleCenter.Perp2() > 1e30) {
251 return NAN;
252 }
253
254 B2Vector3D vecOuter2cC = m_oHit - circleCenter;
255 B2Vector3D vecCenter2cC = m_cHit - circleCenter;
256 B2Vector3D vecInner2cC = m_iHit - circleCenter;
257 TwoHitVariables outerTwoHitVariables(vecOuter2cC, vecCenter2cC);
258 TwoHitVariables innerTwoHitVariables(vecCenter2cC, vecInner2cC);
259
260 double alfaAB = outerTwoHitVariables.getCosXY();
261 double alfaBC = innerTwoHitVariables.getCosXY();
262
263 // real calculation: ratio is (m_vecij[2] = deltaZ): alfaAB/deltaZab : alfaBC/deltaZbc, the following equation saves two times '/'
264 double result = (alfaAB * double(m_cHit.Z() - m_iHit.Z())) / (alfaBC * double(m_oHit.Z() - m_cHit.Z()));
265
266 return (std::isnan(result) || std::isinf(result)) ? double(0) : result;
267 }

◆ setBFieldZ()

void setBFieldZ ( const double  bfieldZ = 1.5)
inline

Set the B-Field value used for pT calculations.

Parameters
bfieldZB-Field value to be used

Definition at line 307 of file ThreeHitVariables.h.

307{ m_BFieldZ = bfieldZ; }

◆ setHits()

void setHits ( const B2Vector3D oHit,
const B2Vector3D cHit,
const B2Vector3D iHit 
)
inline

Set hits if not given in constructor of if they need to be changed.

Parameters
oHitB2Vector3D of the outer hit used for calculating the single variables
cHitB2Vector3D of the center hit used for calculating the single variables
iHitB2Vector3D of the inner hit used for calculating the single variables

Definition at line 47 of file ThreeHitVariables.h.

48 {
49 m_oHit = oHit;
50 m_oHit = oHit;
51 m_iHit = iHit;
52 m_outerDifferenceVector = oHit - cHit;
53 m_innerDifferenceVector = cHit - iHit;
54 }

Member Data Documentation

◆ m_BFieldZ

double m_BFieldZ = 1.5
private

BField along z to estimate pT.

Definition at line 311 of file ThreeHitVariables.h.

◆ m_cHit

B2Vector3D m_cHit
private

center hit position

Definition at line 315 of file ThreeHitVariables.h.

◆ m_iHit

B2Vector3D m_iHit
private

innermost hit position

Definition at line 317 of file ThreeHitVariables.h.

◆ m_innerDifferenceVector

B2Vector3D m_innerDifferenceVector
private

vector containing the difference m_cHit - m_iHit

Definition at line 322 of file ThreeHitVariables.h.

◆ m_oHit

B2Vector3D m_oHit
private

outermost hit position

Definition at line 313 of file ThreeHitVariables.h.

◆ m_outerDifferenceVector

B2Vector3D m_outerDifferenceVector
private

The following two differences are used very often, so calculate once on construction vector containing the difference m_oHit - m_cHit.

Definition at line 320 of file ThreeHitVariables.h.


The documentation for this class was generated from the following file: