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.
 
void setBFieldZ (const double bfieldZ=1.5)
 Set the B-Field value used for pT calculations.
 

Static Public Member Functions

static 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.
 

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 m_outerDifferenceVector(oHit - cHit), m_innerDifferenceVector(cHit - iHit)
38 {
39 };

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

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

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

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

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

◆ getAngleRZ()

double getAngleRZ ( )
inline

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

Definition at line 85 of file ThreeHitVariables.h.

86 {
87 B2Vector3D rzVecAB(m_outerDifferenceVector.Perp(), m_outerDifferenceVector.Z(), 0.);
88 B2Vector3D rzVecBC(m_innerDifferenceVector.Perp(), m_innerDifferenceVector.Z(), 0.);
89 TwoHitVariables twoHitVariables(rzVecAB, rzVecBC);
90
91 double result = acos(twoHitVariables.getCosXY()); // 0-pi
92 return (std::isnan(result) || std::isinf(result)) ? double(0) : result;
93 } // return unit: rad (0 - pi)
B2Vector3< double > B2Vector3D
typedef for common usage with double
Definition B2Vector3.h:522

◆ getAngleXY()

double getAngleXY ( )
inline

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

Definition at line 108 of file ThreeHitVariables.h.

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

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

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

◆ getCircleDistanceIP()

double getCircleDistanceIP ( )
inline

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

Definition at line 147 of file ThreeHitVariables.h.

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

◆ getCircleRadius()

double getCircleRadius ( )
inline

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

Definition at line 162 of file ThreeHitVariables.h.

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

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

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

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

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

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

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

◆ getCurvatureSign() [2/2]

static int getCurvatureSign ( const B2Vector3D & oHit,
const B2Vector3D & cHit,
const B2Vector3D & iHit )
inlinestatic

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

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

◆ getDeltaSlopeRZ()

double getDeltaSlopeRZ ( )
inline

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

Definition at line 185 of file ThreeHitVariables.h.

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

◆ getDeltaSlopeZoverS()

double getDeltaSlopeZoverS ( )
inline

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

Definition at line 197 of file ThreeHitVariables.h.

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

◆ getDeltaSoverZ()

double getDeltaSoverZ ( )
inline

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

Definition at line 224 of file ThreeHitVariables.h.

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

◆ getSimplePTEstimate()

double getSimplePTEstimate ( )
inline

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

Definition at line 269 of file ThreeHitVariables.h.

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

◆ performHelixParamterFit()

double performHelixParamterFit ( )
inline

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

Definition at line 245 of file ThreeHitVariables.h.

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

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

305{ 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 45 of file ThreeHitVariables.h.

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

Member Data Documentation

◆ m_BFieldZ

double m_BFieldZ = 1.5
private

BField along z to estimate pT.

Definition at line 320 of file ThreeHitVariables.h.

◆ m_cHit

B2Vector3D m_cHit
private

center hit position

Definition at line 311 of file ThreeHitVariables.h.

◆ m_iHit

B2Vector3D m_iHit
private

innermost hit position

Definition at line 313 of file ThreeHitVariables.h.

◆ m_innerDifferenceVector

B2Vector3D m_innerDifferenceVector
private

vector containing the difference m_cHit - m_iHit

Definition at line 318 of file ThreeHitVariables.h.

◆ m_oHit

B2Vector3D m_oHit
private

outermost hit position

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


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