Belle II Software  release-05-02-19
BFieldComponentRadial Class Reference

The BFieldComponentRadial class. More...

#include <BFieldComponentRadial.h>

Inheritance diagram for BFieldComponentRadial:
Collaboration diagram for BFieldComponentRadial:

Classes

struct  BFieldPoint
 Magnetic field data structure. More...
 

Public Member Functions

 BFieldComponentRadial ()=default
 The BFieldComponentRadial constructor.
 
virtual ~BFieldComponentRadial ()=default
 The BFieldComponentRadial 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. More...
 
void setMapFilename (const std::string &filename)
 Sets the filename of the magnetic field map. More...
 
void setMapSize (int sizeR, int sizeZ)
 Sets the size of the magnetic field map. More...
 
void setMapRegionZ (double minZ, double maxZ, double offset)
 Sets the size of the magnetic field map. More...
 
void setMapRegionR (double minR, double maxR)
 Sets the size of the magnetic field map. More...
 
void setGridPitch (double pitchR, double pitchZ)
 Sets the grid pitch of the magnetic field map. More...
 
void setKlmParameters (double srmin, double zyoke, double gaph, double iront)
 Sets prameter for EKLM. More...
 

Private Attributes

std::string m_mapFilename {""}
 The filename of the magnetic field map.
 
std::vector< BFieldPointm_mapBuffer
 The memory buffer for the magnetic field map.
 
int m_mapSize [2] {0}
 The size of the map in r and z.
 
double m_mapRegionZ [2] {0}
 The min and max boundaries of the map region in z.
 
double m_mapOffset {0}
 Offset required because the accelerator group defines the Belle center as zero.
 
double m_mapRegionR [2] {0}
 The min and max boundaries of the map region in r.
 
double m_gridPitchR {0}
 The grid pitch in r.
 
double m_gridPitchZ {0}
 The grid pitch in z.
 
double m_igridPitchR {0}
 The reciprocal of grid pitch in r.
 
double m_igridPitchZ {0}
 The reciprocal of grid pitch in z.
 
double m_slotRMin {0}
 minimum radius for the gap in endyoke
 
double m_endyokeZMin {0}
 minimum Z of endyoke
 
double m_gapHeight {0}
 height of the gap in endyoke
 
double m_ironPlateThickness {0}
 thickness of iron plate in endyoke
 
double m_Layer {0}
 height of the layer (gap + iron plate) in endyoke
 
double m_iLayer {0}
 reciprocal of height of the layer (gap + iron plate) in endyoke
 

Detailed Description

The BFieldComponentRadial class.

This class represents a radial magnetic field map. The magnetic field map is stored as a grid in cylindrical coordinates. It is defined by a minimum radius and a maximum radius, a minimum z and a maximum z value, a pitch size in both, r and z, and the number of grid points. 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. The filename points to the zip file containing the magnetic field map.

Definition at line 44 of file BFieldComponentRadial.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 88 of file BFieldComponentRadial.cc.

89 {
90  B2Vector3D B;
91  // If both 'Radial' and 'Beamline' components are defined in xml file,
92  // '3d' component returns zero field where 'Beamline' component is defined.
93  // If no 'Beamline' component is defined in xml file, the following function will never be called.
94  if (BFieldComponentBeamline::Instance().isInRange(point)) return B;
95 
96  //Get the z component
97  double z = point.Z();
98  //Check if the point lies inside the magnetic field boundaries
99  if ((z < m_mapRegionZ[0]) || (z > m_mapRegionZ[1])) return B;
100 
101  //Get the r component
102  double r2 = point.Perp2();
103  //Check if the point lies inside the magnetic field boundaries
104  if ((r2 < m_mapRegionR[0]*m_mapRegionR[0]) || (r2 > m_mapRegionR[1]*m_mapRegionR[1])) return B;
105 
106  double r = sqrt(r2);
107  //Calculate the distance to the lower grid point
108  double wr = (r - m_mapRegionR[0]) * m_igridPitchR;
109  double wz = (z - m_mapRegionZ[0]) * m_igridPitchZ;
110  //Calculate the lower index of the point in the grid
111  int ir = static_cast<int>(wr);
112  int iz = static_cast<int>(wz);
113 
114  double za = z - m_mapOffset;
115  double dz_eklm = abs(za) - (m_endyokeZMin - m_gapHeight);
116  if (dz_eklm > 0 && r > m_slotRMin) {
117  double wl = dz_eklm * m_iLayer;
118  int il = static_cast<int>(wl);
119  if (il <= 16) {
120  double L = m_Layer * il;
121  double l = dz_eklm - L;
122  int ingap = l < m_gapHeight;
123  ir += ingap & (r < m_slotRMin + m_gridPitchR);
124 
125  double zlg = L + m_endyokeZMin, zl0 = zlg - m_gapHeight, zl1 = zlg + m_ironPlateThickness;
126  if (za < 0) {
127  zl0 = -zl0;
128  zlg = -zlg;
129  zl1 = -zl1;
130  }
131  double zoff = m_mapOffset - m_mapRegionZ[0];
132  int izl0 = static_cast<int>((zl0 + zoff) * m_igridPitchZ);
133  int izlg = static_cast<int>((zlg + zoff) * m_igridPitchZ);
134  int izl1 = static_cast<int>((zl1 + zoff) * m_igridPitchZ);
135  int ig = izlg == iz;
136  int idz = (izl0 == iz) - (izl1 == iz) + (ingap ? -ig : ig);
137  iz += (za > 0) ? idz : -idz;
138  }
139  }
140 
141  //Bring the index values within the range
142  ir = min(m_mapSize[0] - 2, ir);
143  iz = min(m_mapSize[1] - 2, iz);
144 
145  wr -= ir;
146  wz -= iz;
147 
148  double wz0 = 1 - wz, wr0 = 1 - wr;
149  //Calculate the linear approx. of the magnetic field vector
150  const unsigned int strideZ = m_mapSize[1];
151  const unsigned int i00 = ir * strideZ + iz, i01 = i00 + 1, i10 = i00 + strideZ, i11 = i01 + strideZ;
152  const BFieldPoint* H = m_mapBuffer.data();
153  double w00 = wz0 * wr0, w01 = wz * wr0, w10 = wz0 * wr, w11 = wz * wr;
154  BFieldPoint Brz = H[i00] * w00 + H[i01] * w01 + H[i10] * w10 + H[i11] * w11;
155 
156  if (r > 0.0) {
157  double norm = Brz.r / r;
158  B.SetXYZ(point.X()*norm, point.Y()*norm, Brz.z);
159  } else {
160  B.SetZ(Brz.z);
161  }
162 
163  return B;
164 }

◆ initialize()

void initialize ( )
overridevirtual

Initializes the magnetic field component.

This method opens the magnetic field map file.

Reimplemented from BFieldComponentAbs.

Definition at line 27 of file BFieldComponentRadial.cc.

◆ setGridPitch()

void setGridPitch ( double  pitchR,
double  pitchZ 
)
inline

Sets the grid pitch of the magnetic field map.

Parameters
pitchRThe pitch of the grid in r [cm].
pitchZThe pitch of the grid in z [cm].

Definition at line 113 of file BFieldComponentRadial.h.

116 {

◆ setKlmParameters()

void setKlmParameters ( double  srmin,
double  zyoke,
double  gaph,
double  iront 
)
inline

Sets prameter for EKLM.

Parameters
srminminimum radius for the gap in endyoke [cm].
zyokeminimum Z of endyoke [cm].
gaphheight of the gap in endyoke [cm]. param iront thickness of iron plate in endyoke [cm].

Definition at line 123 of file BFieldComponentRadial.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 84 of file BFieldComponentRadial.h.

◆ setMapRegionR()

void setMapRegionR ( double  minR,
double  maxR 
)
inline

Sets the size of the magnetic field map.

Parameters
minRThe left (min) border of the magnetic field map region in r [cm].
maxRThe right (max) border of the magnetic field map region in r [cm].

Definition at line 106 of file BFieldComponentRadial.h.

◆ setMapRegionZ()

void setMapRegionZ ( double  minZ,
double  maxZ,
double  offset 
)
inline

Sets the size of the magnetic field map.

Parameters
minZThe left (min) border of the magnetic field map region in z [cm].
maxZThe right (max) border of the magnetic field map region in z [cm].
offsetThe offset in z [cm] which is required because the accelerator group defines the Belle center as zero.

Definition at line 99 of file BFieldComponentRadial.h.

◆ setMapSize()

void setMapSize ( int  sizeR,
int  sizeZ 
)
inline

Sets the size of the magnetic field map.

Parameters
sizeRThe number of points in the r direction.
sizeZThe number of points in the z direction.

Definition at line 91 of file BFieldComponentRadial.h.

◆ terminate()

void terminate ( )
overridevirtual

Terminates the magnetic field component.

This method closes the magnetic field map file.

Reimplemented from BFieldComponentAbs.

Definition at line 166 of file BFieldComponentRadial.cc.


The documentation for this class was generated from the following files:
Belle2::BFieldComponentRadial::m_Layer
double m_Layer
height of the layer (gap + iron plate) in endyoke
Definition: BFieldComponentRadial.h:147
Belle2::BFieldComponentRadial::m_igridPitchR
double m_igridPitchR
The reciprocal of grid pitch in r.
Definition: BFieldComponentRadial.h:140
Belle2::BFieldComponentRadial::m_gridPitchR
double m_gridPitchR
The grid pitch in r.
Definition: BFieldComponentRadial.h:138
Belle2::BFieldComponentRadial::m_mapSize
int m_mapSize[2]
The size of the map in r and z.
Definition: BFieldComponentRadial.h:134
Belle2::BFieldComponentRadial::m_mapOffset
double m_mapOffset
Offset required because the accelerator group defines the Belle center as zero.
Definition: BFieldComponentRadial.h:136
Belle2::B2Vector3::Z
DataType Z() const
access variable Z (= .at(2) without boundary check)
Definition: B2Vector3.h:434
Belle2::B2Vector3< double >
Belle2::BFieldComponentRadial::m_iLayer
double m_iLayer
reciprocal of height of the layer (gap + iron plate) in endyoke
Definition: BFieldComponentRadial.h:148
Belle2::BFieldComponentBeamline::Instance
static BFieldComponentBeamline & Instance()
BFieldComponentBeamline instance.
Definition: BFieldComponentBeamline.cc:699
Belle2::BFieldComponentRadial::m_mapRegionZ
double m_mapRegionZ[2]
The min and max boundaries of the map region in z.
Definition: BFieldComponentRadial.h:135
Belle2::BFieldComponentRadial::m_slotRMin
double m_slotRMin
minimum radius for the gap in endyoke
Definition: BFieldComponentRadial.h:143
Belle2::BFieldComponentRadial::m_gapHeight
double m_gapHeight
height of the gap in endyoke
Definition: BFieldComponentRadial.h:145
Belle2::BFieldComponentRadial::m_ironPlateThickness
double m_ironPlateThickness
thickness of iron plate in endyoke
Definition: BFieldComponentRadial.h:146
Belle2::B2Vector3::Perp2
DataType Perp2() const
The transverse component squared (R^2 in cylindrical coordinate system).
Definition: B2Vector3.h:195
Belle2::B2Vector3::X
DataType X() const
access variable X (= .at(0) without boundary check)
Definition: B2Vector3.h:430
Belle2::BFieldComponentRadial::m_mapRegionR
double m_mapRegionR[2]
The min and max boundaries of the map region in r.
Definition: BFieldComponentRadial.h:137
Belle2::BFieldComponentRadial::m_mapBuffer
std::vector< BFieldPoint > m_mapBuffer
The memory buffer for the magnetic field map.
Definition: BFieldComponentRadial.h:133
Belle2::B2Vector3::Y
DataType Y() const
access variable Y (= .at(1) without boundary check)
Definition: B2Vector3.h:432
Belle2::BFieldComponentRadial::m_endyokeZMin
double m_endyokeZMin
minimum Z of endyoke
Definition: BFieldComponentRadial.h:144
Belle2::BFieldComponentRadial::m_igridPitchZ
double m_igridPitchZ
The reciprocal of grid pitch in z.
Definition: BFieldComponentRadial.h:141