Belle II Software  release-05-01-25
CDCBFieldUtil.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2014 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Oliver Frost *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 #include <tracking/trackFindingCDC/eventdata/trajectories/CDCBFieldUtil.h>
11 
12 #include <tracking/trackFindingCDC/geometry/Vector3D.h>
13 
14 #include <tracking/trackFindingCDC/numerics/ERotation.h>
15 #include <tracking/trackFindingCDC/numerics/ESign.h>
16 
17 #include <framework/geometry/BFieldManager.h>
18 
19 #include <framework/geometry/B2Vector3.h>
20 
21 #include <TMath.h>
22 #include <cmath>
23 
24 using namespace Belle2;
25 using namespace TrackFindingCDC;
26 
28 {
29  B2Vector3D origin(0, 0, 0);
30  double b = BFieldManager::getField(origin).Mag();
31  double c_EarthMagneticField = 3.2e-5 * Unit::T;
32  return not(b > 5 * c_EarthMagneticField);
33 }
34 
36 {
37  return sign(CDCBFieldUtil::getBFieldZ());
38 }
39 
41 {
42  return getBFieldZ(Vector3D(0, 0, 0));
43 }
44 
45 double CDCBFieldUtil::getBFieldZ(const Vector2D& pos2D)
46 {
47  return getBFieldZ(Vector3D(pos2D, 0));
48 }
49 
50 double CDCBFieldUtil::getBFieldZ(const Vector3D& pos3D)
51 {
52  // The BFieldMap can not handle positions with not a number coordinates
53  // which can occure if fits fail.
54  // Return NAN to the caller and let him decide what to do next.
55  if (pos3D.hasNAN()) return NAN;
56  auto mag3D = BFieldManager::getField(pos3D.x(), pos3D.y(), pos3D.z());
57  return mag3D.Z() / Unit::T;
58 }
59 
60 
61 
62 double CDCBFieldUtil::getAlphaFromBField(double bField)
63 {
64  return 1.0 / (bField * TMath::C()) * 1E11;
65 }
66 
67 double CDCBFieldUtil::getAlphaZ(const Vector2D& pos2D)
68 {
69  return getAlphaFromBField(getBFieldZ(pos2D));
70 }
71 
72 double CDCBFieldUtil::getAlphaZ(const Vector3D& pos3D)
73 {
74  return getAlphaFromBField(getBFieldZ(pos3D));
75 }
76 
78 {
79  return static_cast<ESign>(- ccwInfo * getBFieldZSign());
80 }
81 
83 {
84  return static_cast<ERotation>(- chargeSign * getBFieldZSign());
85 }
86 
88 {
89  return chargeSignToERotation(sign(charge));
90 }
91 
92 double CDCBFieldUtil::absMom2DToBendRadius(double absMom2D,
93  double bZ)
94 {
95  // In case of zero magnetic field return something large
96  return std::fmin(4440, absMom2D / (bZ * 0.00299792458));
97 }
98 
99 double CDCBFieldUtil::absMom2DToBendRadius(double absMom2D,
100  const Vector2D& pos2D)
101 {
102  return absMom2DToBendRadius(absMom2D, getBFieldZ(pos2D));
103 }
104 
105 double CDCBFieldUtil::absMom2DToBendRadius(double absMom2D,
106  const Vector3D& pos3D)
107 {
108  return absMom2DToBendRadius(absMom2D, getBFieldZ(pos3D));
109 }
110 
111 double CDCBFieldUtil::absMom2DToCurvature(double absMom2D,
112  double charge,
113  double bZ)
114 {
115  return - charge * bZ * 0.00299792458 * std::fmax(0, 1 / absMom2D);
116 }
117 
118 double CDCBFieldUtil::absMom2DToCurvature(double absMom2D,
119  double charge,
120  const Vector2D& pos2D)
121 {
122  return absMom2DToCurvature(absMom2D, charge, getBFieldZ(pos2D));
123 }
124 
125 double CDCBFieldUtil::absMom2DToCurvature(double absMom2D,
126  double charge,
127  const Vector3D& pos3D)
128 {
129  return absMom2DToCurvature(absMom2D, charge, getBFieldZ(pos3D));
130 }
131 
132 double CDCBFieldUtil::curvatureToAbsMom2D(double curvature,
133  double bZ)
134 {
135  return std::fmin(20, std::fabs(bZ * 0.00299792458 / curvature));
136 }
137 
138 double CDCBFieldUtil::curvatureToAbsMom2D(double curvature,
139  const Vector2D& pos2D)
140 {
141  return curvatureToAbsMom2D(curvature, getBFieldZ(pos2D));
142 }
143 
144 double CDCBFieldUtil::curvatureToAbsMom2D(double curvature,
145  const Vector3D& pos3D)
146 {
147  return curvatureToAbsMom2D(curvature, getBFieldZ(pos3D));
148 }
Belle2::TrackFindingCDC::CDCBFieldUtil::getAlphaFromBField
static double getAlphaFromBField(double bField)
Translater from magnetic field strength in Tesla to the alpha value.
Definition: CDCBFieldUtil.cc:62
Belle2::TrackFindingCDC::Vector3D::hasNAN
bool hasNAN() const
Checks if one of the coordinates is NAN.
Definition: Vector3D.h:157
Belle2::TrackFindingCDC::CDCBFieldUtil::chargeToERotation
static ERotation chargeToERotation(double charge)
Conversion help for charges to clockwise or counterclockwise travel.
Definition: CDCBFieldUtil.cc:87
Belle2::Vector3D
HepGeom::Vector3D< double > Vector3D
3D Vector
Definition: Cell.h:35
Belle2::BFieldManager::getField
static void getField(const double *pos, double *field)
return the magnetic field at a given position.
Definition: BFieldManager.h:110
Belle2::TrackFindingCDC::Vector2D
A two dimensional vector which is equipped with functions for correct handeling of orientation relat...
Definition: Vector2D.h:37
Belle2::TrackFindingCDC::ESignUtil::ESign
ESign
Enumeration for the distinct sign values of floating point variables.
Definition: ESign.h:37
Belle2::TrackFindingCDC::Vector3D::x
double x() const
Getter for the x coordinate.
Definition: Vector3D.h:464
Belle2::TrackFindingCDC::CDCBFieldUtil::absMom2DToCurvature
static double absMom2DToCurvature(double absMom2D, double charge, double bZ)
Conversion helper for momenta to two dimensional curvature.
Definition: CDCBFieldUtil.cc:111
Belle2::TrackFindingCDC::CDCBFieldUtil::ccwInfoToChargeSign
static ESign ccwInfoToChargeSign(ERotation ccwInfo)
Conversion helper from clockwise or counterclockwise travel to the charge sign.
Definition: CDCBFieldUtil.cc:77
Belle2::TrackFindingCDC::CDCBFieldUtil::isOff
static bool isOff()
Indicator if the magnetic field is off in the current geometry.
Definition: CDCBFieldUtil.cc:27
Belle2::B2Vector3< double >
Belle2::TrackFindingCDC::CDCBFieldUtil::getBFieldZSign
static ESign getBFieldZSign()
Getter for the sign of the magnetic field in z direction.
Definition: CDCBFieldUtil.cc:35
Belle2::TrackFindingCDC::CDCBFieldUtil::curvatureToAbsMom2D
static double curvatureToAbsMom2D(double curvature, double bZ)
Conversion helper for two dimensional curvature to momenta.
Definition: CDCBFieldUtil.cc:132
Belle2::Unit::T
static const double T
[tesla]
Definition: Unit.h:130
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TrackFindingCDC::Vector3D
A three dimensional vector.
Definition: Vector3D.h:34
Belle2::TrackFindingCDC::Vector3D::y
double y() const
Getter for the y coordinate.
Definition: Vector3D.h:476
Belle2::TrackFindingCDC::NRotation::ERotation
ERotation
Enumeration to represent the distinct possibilities of the right left passage information.
Definition: ERotation.h:35
Belle2::TrackFindingCDC::CDCBFieldUtil::getBFieldZ
static double getBFieldZ()
Getter for the signed magnetic field stength in z direction at the origin ( in Tesla )
Definition: CDCBFieldUtil.cc:40
Belle2::TrackFindingCDC::Vector3D::z
double z() const
Getter for the z coordinate.
Definition: Vector3D.h:488
Belle2::TrackFindingCDC::CDCBFieldUtil::getAlphaZ
static double getAlphaZ(const Vector2D &pos2D)
Getter for the signed alpha of the magnetic field in z direction.
Definition: CDCBFieldUtil.cc:67
Belle2::TrackFindingCDC::CDCBFieldUtil::absMom2DToBendRadius
static double absMom2DToBendRadius(double absMom2D, double bZ)
Conversion helper for momenta to two dimensional (absolute) bend radius.
Definition: CDCBFieldUtil.cc:92
Belle2::TrackFindingCDC::CDCBFieldUtil::chargeSignToERotation
static ERotation chargeSignToERotation(ESign chargeSign)
Conversion helper from the charge sign to clockwise or counterclockwise travel.
Definition: CDCBFieldUtil.cc:82