Belle II Software  release-05-01-25
BFieldComponentKlm1 Class Reference

The Bfieldcomponentklm1 class. More...

#include <BFieldComponentKlm1.h>

Inheritance diagram for BFieldComponentKlm1:
Collaboration diagram for BFieldComponentKlm1:

Classes

struct  BFieldPoint
 Trivial struct representing rz coordinate. More...
 

Public Member Functions

 BFieldComponentKlm1 ()=default
 The BFieldComponentklm1 constructor.
 
virtual ~BFieldComponentKlm1 ()=default
 The BFieldComponentklm1 destructor.
 
virtual void initialize () override
 Initializes the magnetic field Component. More...
 
virtual B2Vector3D calculate (const B2Vector3D &point) const override
 Calculates the magnetic field vector at the specified space point. More...
 
virtual void terminate () override
 Terminates the magnetic field Component.
 
void setMapFilename (const std::string &filename)
 Sets the filename of the magnetic field map. More...
 
void setNLayers (int b, int e)
 Sets the number of barrel and endcap layers. More...
 
void setBarrelRegion (double minR, double maxZ, double offset)
 Sets the dimensions of the barrel region. More...
 
void setEndcapRegion (double minR, double minZ)
 Set the dimensions of the endcap region. More...
 
void setLayerParam (double bgapl0, double bironth, double egap, double dl)
 Set the layer parameters @bgapl0 barrel gap height for layer 0 @bironth barrel iron thickness @egap endcap gap height @dl distance between two layers.
 

Private Attributes

double m_cospi8 {cos(M_PI / 8)}
 cos(pi/8)
 
double m_cos3pi8 {cos(3 * M_PI / 8)}
 cos(3pi/8)
 
double m_cospi4 {cos(M_PI / 4)}
 cos(pi/4)
 
std::string m_mapFilename {""}
 The filename of the magnetic field map.
 
double m_mapOffset {0}
 Offset required because the accelerator group defines the Belle center as zero.
 
double m_barrelRMin {0}
 The minimum boundaries of BKLM region in r.
 
double m_barrelZMax {0}
 The maximum boundaries of BKLM region in r.
 
double m_endcapRMin {0}
 The minimum boundaries of EKLM region in r.
 
double m_endcapZMin {0}
 The minimum boundaries of EKLM region in z.
 
int m_nBarrelLayers {0}
 The number of layers per 1 sector for BKLM.
 
int m_nEndcapLayers {0}
 The number of layers per 1 sector for EKLM.
 
double m_barrelGapHeightLayer0 {0}
 Gap height of BKLM layer0.
 
double m_endcapGapHeight {0}
 Gap height of BKLM layer1-14.
 
double m_dLayer {0}
 deppth of BKLM module?
 
double m_barrelIronThickness {0}
 Thickness of Barrel iron plate.
 
double m_barrelZBreakpoint [15] {0}
 z position of breakpoints between the two linear approximations of Bz in the barrel. More...
 
double m_barrelRBreakpoint [15] {0}
 z position of breakpoints between the two linear approximations of Br in the barrel. More...
 
double m_barrelFieldZSlope1 [15] {0}
 Slope of Bz before the breakpoint in the barrel. More...
 
double m_barrelFieldZIntercept1 [15] {0}
 Intercept of Bz before the beackpoint in the barrel. More...
 
double m_barrelFieldZSlope2 [15] {0}
 Slope of Bz after the breakpoint in the barrel. More...
 
double m_barrelFieldZIntercept2 [15] {0}
 Intercept of Bz after the beackpoint in the barrel. More...
 
double m_barrelFieldRSlope1 [15] {0}
 Slope of Br before the breakpoint in the barrel. More...
 
double m_barrelFieldRIntercept1 [15] {0}
 Intercept of Br before the beackpoint in the barrel. More...
 
double m_barrelFieldRSlope2 [15] {0}
 Slope of Br after the breakpoint in the barrel. More...
 
double m_barrelFieldRIntercept2 [15] {0}
 Intercept of Br after the beackpoint in the barrel. More...
 
double m_endcapZBreakpoint [2][15][5] {{{0}}}
 z position of breakpoints between linear functions in the endcap. More...
 
double m_endcapRBreakpoint [2][15][5] {{{0}}}
 r position of breakpoints between linear functions in the endcap First index indicates whether or not where in a gap (0) or in iron (1), second index is the layer and third index is the number of breaks we have in the linear approximation and their positions
 
double m_endcapFieldZSlope [2][15][5] {{{0}}}
 Slopes of the linear approximation of Bz in the endcap. More...
 
double m_endcapFieldZIntercept [2][15][5] {{{0}}}
 Intercepts of the linear approximation of Bz in the endcap. More...
 
double m_endcapFieldRSlope [2][15][5] {{{0}}}
 Slopes of the linear approximation of Br in the endcap. More...
 
double m_endcapFieldRIntercept [2][15][5] {{{0}}}
 Intercepts of the linear approximation of Br in the endcap. More...
 

Detailed Description

The Bfieldcomponentklm1 class.

This class represents a magnetic field map in KLM region and outside of solenoid. This magnetic field is for Belle. This is porting class from g4superb to basf2. The magnetic field map is stored as linear functions in cylindrical coordinates. It is defined by a maximum radius, a minimum z, r and z, the number of layers for Barrel KLM and Endcap KLM. The ZOffset is used to account for the fact that the acceleration group defines 0 to be in the center of the detector, while the detector group defines the IP to be the center.

Definition at line 44 of file BFieldComponentKlm1.h.

Member Function Documentation

◆ calculate()

B2Vector3D calculate ( const B2Vector3D point) const
overridevirtual

Calculates the magnetic field vector at the specified space point.

Parameters
pointThe space point in Cartesian coordinates (x,y,z) in [cm] at which the magnetic field vector should be calculated.
Returns
The magnetic field vector at the given space point in [T]. Returns a zero vector TVector(0,0,0) if the space point lies outside the region described by the Component.

Implements BFieldComponentAbs.

Definition at line 89 of file BFieldComponentKlm1.cc.

90 {
91  //Get the r and z Component
92  double r = point.Perp();
93  double x = point.X();
94  double y = point.Y();
95  double z = point.Z() - m_mapOffset;
96  double absZ = std::abs(z);
97 
98  B2Vector3D bField(0., 0., 0.);
99 
100  // Barrel
101  if (absZ < m_barrelZMax) {
102 
103  // This code assumes that we are in the barrel KLM. Use the field map
104  // inside an iron plate; use zero in the gap between the iron plates.
105 
106  double cosphi = std::abs(x) / r;
107  double d = ((cosphi < m_cospi8) ? ((cosphi < m_cos3pi8) ? std::abs(y)
108  : (std::abs(x) + std::abs(y)) * m_cospi4)
109  : std::abs(x)) - m_barrelRMin - m_barrelGapHeightLayer0;
110 
111  if (d >= 0.0) {
112  int layer = static_cast<int>(floor(d / m_dLayer));
113 
114  // make sure layer is in a valid range
115  if (layer < 0 || layer > m_nBarrelLayers) return bField;
116  if (layer == m_nBarrelLayers) {
117  layer = m_nBarrelLayers - 1;
118  d = layer * m_dLayer; // for extra-thick outermost iron plate
119  }
120  if ((d - layer * m_dLayer) < m_barrelIronThickness) {
121  double br = ((absZ > m_barrelRBreakpoint[layer]) ?
122  m_barrelFieldRIntercept2[layer] + m_barrelFieldRSlope2[layer] * absZ :
123  m_barrelFieldRIntercept1[layer] + m_barrelFieldRSlope1[layer] * absZ);
124  if (z < 0.0) { br = -br; }
125  bField.SetXYZ(br * x / r, br * y / r,
126  ((absZ > m_barrelZBreakpoint[layer]) ?
127  m_barrelFieldZIntercept2[layer] + m_barrelFieldZSlope2[layer] * absZ :
128  m_barrelFieldZIntercept1[layer] + m_barrelFieldZSlope1[layer] * absZ));
129  }
130  }
131  } else if (absZ > m_endcapZMin) {
132  //Endcap
133  if (r <= m_endcapRMin) return bField;
134 
135  // This code assumes that we are in the endcap KLM.
136  // The field in an inter-plate gap in the endcap is not zero.
137 
138  double dz = absZ - (m_endcapZMin - m_endcapGapHeight);
139  int layer = static_cast<int>(floor(dz / m_dLayer));
140  // make sure layer is in a valid range
141  if (layer < 0 || layer >= m_nEndcapLayers) return bField;
142 
143  int GapIron = 0; // in gap
144  if ((dz - m_dLayer * layer) > m_endcapGapHeight) GapIron = 1; // in Iron plate?
145  for (int j = 0; j < 5; j++) {
146  if (r < m_endcapRBreakpoint[GapIron][layer][j]) {
147  double br = m_endcapFieldRIntercept[GapIron][layer][j] + m_endcapFieldRSlope[GapIron][layer][j] * r;
148  if (z < 0.0) { br = -br; }
149  bField.SetX(br * x / r);
150  bField.SetY(br * y / r);
151  break;
152  }
153  }
154  for (int j = 0; j < 5; j++) {
155  if (r < m_endcapZBreakpoint[GapIron][layer][j]) {
156  bField.SetZ(m_endcapFieldZIntercept[GapIron][layer][j] + m_endcapFieldZSlope[GapIron][layer][j] * r);
157  break;
158  }
159  }
160  }
161 
162  return bField;
163 }

◆ initialize()

void initialize ( )
overridevirtual

Initializes the magnetic field Component.

This method opens the magnetic field map file.

Reimplemented from BFieldComponentAbs.

Definition at line 25 of file BFieldComponentKlm1.cc.

◆ setBarrelRegion()

void setBarrelRegion ( double  minR,
double  maxZ,
double  offset 
)
inline

Sets the dimensions of the barrel region.

Parameters
minRminimal radius
maxZmax extension in z in both directions
offsetmap offset in z

Definition at line 98 of file BFieldComponentKlm1.h.

105 {

◆ setEndcapRegion()

void setEndcapRegion ( double  minR,
double  minZ 
)
inline

Set the dimensions of the endcap region.

Parameters
minRminimal radius
minZstarting z coordinate in both directions

Definition at line 104 of file BFieldComponentKlm1.h.

◆ setMapFilename()

void setMapFilename ( const std::string &  filename)
inline

Sets the filename of the magnetic field map.

Parameters
filenameThe filname of the magnetic field map.

Definition at line 85 of file BFieldComponentKlm1.h.

◆ setNLayers()

void setNLayers ( int  b,
int  e 
)
inline

Sets the number of barrel and endcap layers.

Parameters
bbarrel layers
eendcap layers

Definition at line 91 of file BFieldComponentKlm1.h.

Member Data Documentation

◆ m_barrelFieldRIntercept1

double m_barrelFieldRIntercept1[15] {0}
private

Intercept of Br before the beackpoint in the barrel.

Index indicates the current layer

Definition at line 177 of file BFieldComponentKlm1.h.

◆ m_barrelFieldRIntercept2

double m_barrelFieldRIntercept2[15] {0}
private

Intercept of Br after the beackpoint in the barrel.

Index indicates the current layer

Definition at line 183 of file BFieldComponentKlm1.h.

◆ m_barrelFieldRSlope1

double m_barrelFieldRSlope1[15] {0}
private

Slope of Br before the breakpoint in the barrel.

Index indicates the current layer

Definition at line 174 of file BFieldComponentKlm1.h.

◆ m_barrelFieldRSlope2

double m_barrelFieldRSlope2[15] {0}
private

Slope of Br after the breakpoint in the barrel.

Index indicates the current layer

Definition at line 180 of file BFieldComponentKlm1.h.

◆ m_barrelFieldZIntercept1

double m_barrelFieldZIntercept1[15] {0}
private

Intercept of Bz before the beackpoint in the barrel.

Index indicates the current layer

Definition at line 165 of file BFieldComponentKlm1.h.

◆ m_barrelFieldZIntercept2

double m_barrelFieldZIntercept2[15] {0}
private

Intercept of Bz after the beackpoint in the barrel.

Index indicates the current layer

Definition at line 171 of file BFieldComponentKlm1.h.

◆ m_barrelFieldZSlope1

double m_barrelFieldZSlope1[15] {0}
private

Slope of Bz before the breakpoint in the barrel.

Index indicates the current layer

Definition at line 162 of file BFieldComponentKlm1.h.

◆ m_barrelFieldZSlope2

double m_barrelFieldZSlope2[15] {0}
private

Slope of Bz after the breakpoint in the barrel.

Index indicates the current layer

Definition at line 168 of file BFieldComponentKlm1.h.

◆ m_barrelRBreakpoint

double m_barrelRBreakpoint[15] {0}
private

z position of breakpoints between the two linear approximations of Br in the barrel.

Index indicates the current layer

Definition at line 159 of file BFieldComponentKlm1.h.

◆ m_barrelZBreakpoint

double m_barrelZBreakpoint[15] {0}
private

z position of breakpoints between the two linear approximations of Bz in the barrel.

Index indicates the current layer

Definition at line 156 of file BFieldComponentKlm1.h.

◆ m_endcapFieldRIntercept

double m_endcapFieldRIntercept[2][15][5] {{{0}}}
private

Intercepts of the linear approximation of Br in the endcap.

First index indicates whether or not where in a gap (0) or in iron (1), second index is the layer and third index is the number of breaks we have in the linear approximation and their positions

Definition at line 215 of file BFieldComponentKlm1.h.

◆ m_endcapFieldRSlope

double m_endcapFieldRSlope[2][15][5] {{{0}}}
private

Slopes of the linear approximation of Br in the endcap.

First index indicates whether or not where in a gap (0) or in iron (1), second index is the layer and third index is the number of breaks we have in the linear approximation and their positions

Definition at line 210 of file BFieldComponentKlm1.h.

◆ m_endcapFieldZIntercept

double m_endcapFieldZIntercept[2][15][5] {{{0}}}
private

Intercepts of the linear approximation of Bz in the endcap.

First index indicates whether or not where in a gap (0) or in iron (1), second index is the layer and third index is the number of breaks we have in the linear approximation and their positions

Definition at line 205 of file BFieldComponentKlm1.h.

◆ m_endcapFieldZSlope

double m_endcapFieldZSlope[2][15][5] {{{0}}}
private

Slopes of the linear approximation of Bz in the endcap.

First index indicates whether or not where in a gap (0) or in iron (1), second index is the layer and third index is the number of breaks we have in the linear approximation and their positions

Definition at line 200 of file BFieldComponentKlm1.h.

◆ m_endcapZBreakpoint

double m_endcapZBreakpoint[2][15][5] {{{0}}}
private

z position of breakpoints between linear functions in the endcap.

First index indicates whether or not where in a gap (0) or in iron (1), second index is the layer and third index is the number of breaks we have in the linear approximation and their positions

Definition at line 189 of file BFieldComponentKlm1.h.


The documentation for this class was generated from the following files:
Belle2::BFieldComponentKlm1::m_barrelZBreakpoint
double m_barrelZBreakpoint[15]
z position of breakpoints between the two linear approximations of Bz in the barrel.
Definition: BFieldComponentKlm1.h:156
Belle2::BFieldComponentKlm1::m_barrelZMax
double m_barrelZMax
The maximum boundaries of BKLM region in r.
Definition: BFieldComponentKlm1.h:134
Belle2::BFieldComponentKlm1::m_barrelFieldRIntercept2
double m_barrelFieldRIntercept2[15]
Intercept of Br after the beackpoint in the barrel.
Definition: BFieldComponentKlm1.h:183
Belle2::B2Vector3::Perp
DataType Perp() const
The transverse component (R in cylindrical coordinate system).
Definition: B2Vector3.h:199
Belle2::BFieldComponentKlm1::m_endcapFieldRSlope
double m_endcapFieldRSlope[2][15][5]
Slopes of the linear approximation of Br in the endcap.
Definition: BFieldComponentKlm1.h:210
Belle2::BFieldComponentKlm1::m_cos3pi8
double m_cos3pi8
cos(3pi/8)
Definition: BFieldComponentKlm1.h:122
Belle2::BFieldComponentKlm1::m_mapOffset
double m_mapOffset
Offset required because the accelerator group defines the Belle center as zero.
Definition: BFieldComponentKlm1.h:129
Belle2::BFieldComponentKlm1::m_barrelIronThickness
double m_barrelIronThickness
Thickness of Barrel iron plate.
Definition: BFieldComponentKlm1.h:152
Belle2::BFieldComponentKlm1::m_barrelFieldRSlope2
double m_barrelFieldRSlope2[15]
Slope of Br after the breakpoint in the barrel.
Definition: BFieldComponentKlm1.h:180
Belle2::BFieldComponentKlm1::m_endcapZMin
double m_endcapZMin
The minimum boundaries of EKLM region in z.
Definition: BFieldComponentKlm1.h:138
Belle2::BFieldComponentKlm1::m_endcapZBreakpoint
double m_endcapZBreakpoint[2][15][5]
z position of breakpoints between linear functions in the endcap.
Definition: BFieldComponentKlm1.h:189
Belle2::BFieldComponentKlm1::m_barrelGapHeightLayer0
double m_barrelGapHeightLayer0
Gap height of BKLM layer0.
Definition: BFieldComponentKlm1.h:146
Belle2::B2Vector3::Z
DataType Z() const
access variable Z (= .at(2) without boundary check)
Definition: B2Vector3.h:434
Belle2::BFieldComponentKlm1::m_barrelRMin
double m_barrelRMin
The minimum boundaries of BKLM region in r.
Definition: BFieldComponentKlm1.h:132
Belle2::BFieldComponentKlm1::m_barrelFieldZIntercept1
double m_barrelFieldZIntercept1[15]
Intercept of Bz before the beackpoint in the barrel.
Definition: BFieldComponentKlm1.h:165
Belle2::BFieldComponentKlm1::m_barrelFieldZSlope2
double m_barrelFieldZSlope2[15]
Slope of Bz after the breakpoint in the barrel.
Definition: BFieldComponentKlm1.h:168
Belle2::B2Vector3< double >
Belle2::BFieldComponentKlm1::m_endcapGapHeight
double m_endcapGapHeight
Gap height of BKLM layer1-14.
Definition: BFieldComponentKlm1.h:148
Belle2::BFieldComponentKlm1::m_endcapFieldRIntercept
double m_endcapFieldRIntercept[2][15][5]
Intercepts of the linear approximation of Br in the endcap.
Definition: BFieldComponentKlm1.h:215
Belle2::BFieldComponentKlm1::m_endcapRMin
double m_endcapRMin
The minimum boundaries of EKLM region in r.
Definition: BFieldComponentKlm1.h:136
Belle2::BFieldComponentKlm1::m_barrelFieldZSlope1
double m_barrelFieldZSlope1[15]
Slope of Bz before the breakpoint in the barrel.
Definition: BFieldComponentKlm1.h:162
Belle2::BFieldComponentKlm1::m_endcapFieldZSlope
double m_endcapFieldZSlope[2][15][5]
Slopes of the linear approximation of Bz in the endcap.
Definition: BFieldComponentKlm1.h:200
Belle2::BFieldComponentKlm1::m_endcapRBreakpoint
double m_endcapRBreakpoint[2][15][5]
r position of breakpoints between linear functions in the endcap First index indicates whether or not...
Definition: BFieldComponentKlm1.h:194
Belle2::BFieldComponentKlm1::m_cospi4
double m_cospi4
cos(pi/4)
Definition: BFieldComponentKlm1.h:124
Belle2::BFieldComponentKlm1::m_nBarrelLayers
int m_nBarrelLayers
The number of layers per 1 sector for BKLM.
Definition: BFieldComponentKlm1.h:141
Belle2::BFieldComponentKlm1::m_cospi8
double m_cospi8
cos(pi/8)
Definition: BFieldComponentKlm1.h:120
Belle2::BFieldComponentKlm1::m_barrelFieldRSlope1
double m_barrelFieldRSlope1[15]
Slope of Br before the breakpoint in the barrel.
Definition: BFieldComponentKlm1.h:174
Belle2::BFieldComponentKlm1::m_dLayer
double m_dLayer
deppth of BKLM module?
Definition: BFieldComponentKlm1.h:150
Belle2::B2Vector3::X
DataType X() const
access variable X (= .at(0) without boundary check)
Definition: B2Vector3.h:430
Belle2::BFieldComponentKlm1::m_barrelFieldZIntercept2
double m_barrelFieldZIntercept2[15]
Intercept of Bz after the beackpoint in the barrel.
Definition: BFieldComponentKlm1.h:171
Belle2::BFieldComponentKlm1::m_barrelRBreakpoint
double m_barrelRBreakpoint[15]
z position of breakpoints between the two linear approximations of Br in the barrel.
Definition: BFieldComponentKlm1.h:159
Belle2::BFieldComponentKlm1::m_nEndcapLayers
int m_nEndcapLayers
The number of layers per 1 sector for EKLM.
Definition: BFieldComponentKlm1.h:143
Belle2::BFieldComponentKlm1::m_barrelFieldRIntercept1
double m_barrelFieldRIntercept1[15]
Intercept of Br before the beackpoint in the barrel.
Definition: BFieldComponentKlm1.h:177
Belle2::BFieldComponentKlm1::m_endcapFieldZIntercept
double m_endcapFieldZIntercept[2][15][5]
Intercepts of the linear approximation of Bz in the endcap.
Definition: BFieldComponentKlm1.h:205
Belle2::B2Vector3::Y
DataType Y() const
access variable Y (= .at(1) without boundary check)
Definition: B2Vector3.h:432