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

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
 
double m_BFieldZ = 1.5
 BField along z to estimate pT.
 

Detailed Description

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

Definition at line 24 of file ThreeHitVariables.h.

Constructor & Destructor Documentation

◆ ThreeHitVariables() [1/2]

ThreeHitVariables ( )
inline

basic constructor

Definition at line 27 of file ThreeHitVariables.h.

27 : m_oHit(0., 0., 0.), m_cHit(0., 0., 0.), m_iHit(0., 0., 0.),
28 m_outerDifferenceVector(0., 0., 0.), m_innerDifferenceVector(0., 0., 0.)
29 {};

◆ 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 35 of file ThreeHitVariables.h.

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

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 circle for which the average distance is calculated returns the average distance in cm of the hits to the circle center position

Definition at line 58 of file ThreeHitVariables.h.

59 {
60 return (sqrt(std::pow(circleCenter.X() - m_oHit.X(), 2) + std::pow(circleCenter.Y() - m_oHit.Y(), 2)) +
61 sqrt(std::pow(circleCenter.X() - m_cHit.X(), 2) + std::pow(circleCenter.Y() - m_cHit.Y(), 2)) +
62 sqrt(std::pow(circleCenter.X() - m_iHit.X(), 2) + std::pow(circleCenter.Y() - m_iHit.Y(), 2))) / 3.;
63 }
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 67 of file ThreeHitVariables.h.

68 {
69 double result = acos(m_outerDifferenceVector.Dot(m_innerDifferenceVector) /
70 (m_outerDifferenceVector.Mag() * m_innerDifferenceVector.Mag())); // 0-pi
71 return (std::isnan(result) || std::isinf(result)) ? double(0) : result;
72 }

◆ 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 76 of file ThreeHitVariables.h.

77 {
78 // fullCalc would be acos(m_vecAB.Dot(m_vecBC) / m_vecAB.Mag()*m_vecBC.Mag()), but here time-consuming parts have been neglected
79 double result = m_outerDifferenceVector.Dot(m_innerDifferenceVector) /
80 (m_outerDifferenceVector.Mag2() * m_innerDifferenceVector.Mag2());
81 return (std::isnan(result) || std::isinf(result)) ? double(0) : result;
82 }

◆ getAngleRZ()

double getAngleRZ ( )
inline

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

Definition at line 86 of file ThreeHitVariables.h.

87 {
88 B2Vector3D rzVecAB(m_outerDifferenceVector.Perp(), m_outerDifferenceVector.Z(), 0.);
89 B2Vector3D rzVecBC(m_innerDifferenceVector.Perp(), m_innerDifferenceVector.Z(), 0.);
90 TwoHitVariables twoHitVariables(rzVecAB, rzVecBC);
91
92 double result = acos(twoHitVariables.getCosXY()); // 0-pi
93 return (std::isnan(result) || std::isinf(result)) ? double(0) : result;
94 } // return unit: rad (0 - pi)
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 109 of file ThreeHitVariables.h.

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

◆ 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 118 of file ThreeHitVariables.h.

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

◆ getCircleDistanceIP()

double getCircleDistanceIP ( )
inline

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

Definition at line 148 of file ThreeHitVariables.h.

149 {
150 B2Vector3D circleCenter = getCircleCenterXY();
151 if (circleCenter.Perp2() > 1e30) {
152 return NAN;
153 }
154 double circleRadius = calcAvgDistanceXY(circleCenter);
155
156 // distance of closest approach of circle to the IP :
157 // WARNING only valid for IP=0,0,X
158 return (fabs(circleCenter.Perp() - circleRadius));
159 }

◆ getCircleRadius()

double getCircleRadius ( )
inline

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

Definition at line 163 of file ThreeHitVariables.h.

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

◆ 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 98 of file ThreeHitVariables.h.

99 {
100 B2Vector3D rzVecAB(m_outerDifferenceVector.Perp(), m_outerDifferenceVector.Z(), 0.);
101 B2Vector3D rzVecBC(m_innerDifferenceVector.Perp(), m_innerDifferenceVector.Z(), 0.);
102 TwoHitVariables twoHitVariables(rzVecAB, rzVecBC);
103
104 return twoHitVariables.getCosXY();
105 }

◆ 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 175 of file ThreeHitVariables.h.

176 {
177 double result = (m_outerDifferenceVector.X() * m_innerDifferenceVector.X() +
178 m_outerDifferenceVector.Y() * m_innerDifferenceVector.Y()) /
179 (m_outerDifferenceVector.Perp() * m_innerDifferenceVector.Perp());
180
181 return (std::isnan(result) || std::isinf(result)) ? double(0) : result;
182 }

◆ 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 285 of file ThreeHitVariables.h.

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

◆ 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 296 of file ThreeHitVariables.h.

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

◆ getDeltaSlopeRZ()

double getDeltaSlopeRZ ( )
inline

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

Definition at line 186 of file ThreeHitVariables.h.

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

◆ getDeltaSlopeZoverS()

double getDeltaSlopeZoverS ( )
inline

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

Definition at line 198 of file ThreeHitVariables.h.

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

◆ getDeltaSoverZ()

double getDeltaSoverZ ( )
inline

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

Definition at line 225 of file ThreeHitVariables.h.

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

◆ getSimplePTEstimate()

double getSimplePTEstimate ( )
inline

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

Definition at line 270 of file ThreeHitVariables.h.

271 {
272 B2Vector3D circleCenter = getCircleCenterXY();
273 if (circleCenter.Perp2() > 1e30) {
274 return NAN;
275 }
276 double circleRadius = calcAvgDistanceXY(circleCenter);
277
278 return 0.00299792458 * m_BFieldZ * circleRadius;
279 }

◆ performHelixParamterFit()

double performHelixParamterFit ( )
inline

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

Definition at line 246 of file ThreeHitVariables.h.

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

◆ 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 306 of file ThreeHitVariables.h.

306{ 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 46 of file ThreeHitVariables.h.

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

Member Data Documentation

◆ m_BFieldZ

double m_BFieldZ = 1.5
private

BField along z to estimate pT.

Definition at line 321 of file ThreeHitVariables.h.

◆ m_cHit

B2Vector3D m_cHit
private

center hit position

Definition at line 312 of file ThreeHitVariables.h.

◆ m_iHit

B2Vector3D m_iHit
private

innermost hit position

Definition at line 314 of file ThreeHitVariables.h.

◆ m_innerDifferenceVector

B2Vector3D m_innerDifferenceVector
private

vector containing the difference m_cHit - m_iHit

Definition at line 319 of file ThreeHitVariables.h.

◆ m_oHit

B2Vector3D m_oHit
private

outermost hit position

Definition at line 310 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 317 of file ThreeHitVariables.h.


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