Belle II Software development
CDCBFieldUtil.cc
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#include <tracking/trackFindingCDC/eventdata/trajectories/CDCBFieldUtil.h>
9
10#include <tracking/trackFindingCDC/geometry/Vector3D.h>
11
12#include <tracking/trackFindingCDC/numerics/ERotation.h>
13#include <tracking/trackFindingCDC/numerics/ESign.h>
14
15#include <framework/geometry/BFieldManager.h>
16
17#include <framework/geometry/B2Vector3.h>
18
19#include <TMath.h>
20#include <cmath>
21
22using namespace Belle2;
23using namespace TrackFindingCDC;
24
26{
27 double b = BFieldManager::getField(0, 0, 0).R();
28 double c_EarthMagneticField = 3.2e-5 * Unit::T;
29 return not(b > 5 * c_EarthMagneticField);
30}
31
33{
34 return sign(CDCBFieldUtil::getBFieldZ());
35}
36
38{
39 return getBFieldZ(Vector3D(0, 0, 0));
40}
41
43{
44 return getBFieldZ(Vector3D(pos2D, 0));
45}
46
48{
49 // The BFieldMap can not handle positions with not a number coordinates
50 // which can occur if fits fail.
51 // Return NAN to the caller and let him decide what to do next.
52 if (pos3D.hasNAN()) return NAN;
53 auto mag3D = BFieldManager::getField(pos3D.x(), pos3D.y(), pos3D.z());
54 return mag3D.Z() / Unit::T;
55}
56
57
58
60{
61 return 1.0 / (bField * TMath::C()) * 1E11;
62}
63
65{
66 return getAlphaFromBField(getBFieldZ(pos2D));
67}
68
70{
71 return getAlphaFromBField(getBFieldZ(pos3D));
72}
73
75{
76 return static_cast<ESign>(- ccwInfo * getBFieldZSign());
77}
78
80{
81 return static_cast<ERotation>(- chargeSign * getBFieldZSign());
82}
83
85{
86 return chargeSignToERotation(sign(charge));
87}
88
90 double bZ)
91{
92 // In case of zero magnetic field return something large
93 return std::fmin(4440, absMom2D / (bZ * 0.00299792458));
94}
95
97 const Vector2D& pos2D)
98{
99 return absMom2DToBendRadius(absMom2D, getBFieldZ(pos2D));
100}
101
103 const Vector3D& pos3D)
104{
105 return absMom2DToBendRadius(absMom2D, getBFieldZ(pos3D));
106}
107
109 double charge,
110 double bZ)
111{
112 return - charge * bZ * 0.00299792458 * std::fmax(0, 1 / absMom2D);
113}
114
116 double charge,
117 const Vector2D& pos2D)
118{
119 return absMom2DToCurvature(absMom2D, charge, getBFieldZ(pos2D));
120}
121
123 double charge,
124 const Vector3D& pos3D)
125{
126 return absMom2DToCurvature(absMom2D, charge, getBFieldZ(pos3D));
127}
128
130 double bZ)
131{
132 return std::fmin(20, std::fabs(bZ * 0.00299792458 / curvature));
133}
134
136 const Vector2D& pos2D)
137{
138 return curvatureToAbsMom2D(curvature, getBFieldZ(pos2D));
139}
140
142 const Vector3D& pos3D)
143{
144 return curvatureToAbsMom2D(curvature, getBFieldZ(pos3D));
145}
static double curvatureToAbsMom2D(double curvature, double bZ)
Conversion helper for two dimensional curvature to momenta.
static bool isOff()
Indicator if the magnetic field is off in the current geometry.
static ESign getBFieldZSign()
Getter for the sign of the magnetic field in z direction.
static ESign ccwInfoToChargeSign(ERotation ccwInfo)
Conversion helper from clockwise or counterclockwise travel to the charge sign.
static double getBFieldZ()
Getter for the signed magnetic field strength in z direction at the origin ( in Tesla )
static ERotation chargeSignToERotation(ESign chargeSign)
Conversion helper from the charge sign to clockwise or counterclockwise travel.
static ERotation chargeToERotation(double charge)
Conversion help for charges to clockwise or counterclockwise travel.
static double absMom2DToCurvature(double absMom2D, double charge, double bZ)
Conversion helper for momenta to two dimensional curvature.
static double getAlphaZ(const Vector2D &pos2D)
Getter for the signed alpha of the magnetic field in z direction.
static double getAlphaFromBField(double bField)
Translator from magnetic field strength in Tesla to the alpha value.
static double absMom2DToBendRadius(double absMom2D, double bZ)
Conversion helper for momenta to two dimensional (absolute) bend radius.
A two dimensional vector which is equipped with functions for correct handling of orientation relate...
Definition: Vector2D.h:32
A three dimensional vector.
Definition: Vector3D.h:33
double x() const
Getter for the x coordinate.
Definition: Vector3D.h:472
bool hasNAN() const
Checks if one of the coordinates is NAN.
Definition: Vector3D.h:165
double y() const
Getter for the y coordinate.
Definition: Vector3D.h:484
double z() const
Getter for the z coordinate.
Definition: Vector3D.h:496
static const double T
[tesla]
Definition: Unit.h:120
static void getField(const double *pos, double *field)
return the magnetic field at a given position.
Definition: BFieldManager.h:91
ESign
Enumeration for the distinct sign values of floating point variables.
Definition: ESign.h:27
ERotation
Enumeration to represent the distinct possibilities of the right left passage information.
Definition: ERotation.h:25
Abstract base class for different kinds of events.