Belle II Software  release-08-01-10
BFieldComponentQuad Class Reference

The BFieldComponentQuad class. More...

#include <BFieldComponentQuad.h>

Inheritance diagram for BFieldComponentQuad:
Collaboration diagram for BFieldComponentQuad:

Classes

struct  ApertPoint
 Aperture data structure. More...
 
struct  irange_t
 start and stop indicies to narrow search in array More...
 
struct  ParamPoint3
 Quadrupole lense data structure. More...
 
struct  range_t
 Range data structure. More...
 

Public Types

typedef std::vector< range_tranges_t
 vector of Range data structure.
 

Public Member Functions

 BFieldComponentQuad ()=default
 The BFieldComponentQuad constructor.
 
virtual ~BFieldComponentQuad ()=default
 The BFieldComponentQuad destructor.
 
virtual void initialize () override
 Initializes the magnetic field component. More...
 
virtual ROOT::Math::XYZVector calculate (const ROOT::Math::XYZVector &point) const override
 Calculates the magnetic field vector at the specified space point. More...
 
double getApertureHER (double s) const
 Returns the HER beam pipe aperture at given position. More...
 
double getApertureLER (double s) const
 Returns the LER beam pipe aperture at given position. More...
 
void setMapFilename (const std::string &filenameHER, const std::string &filenameLER, const std::string &filenameHERleak)
 Sets the filename of the magnetic field map. More...
 
void setApertFilename (const std::string &filenameHER, const std::string &filenameLER)
 Sets the filename of aperture definition file. More...
 
void setMapSize (int sizeHER, int sizeLER, int sizeHERleak)
 Sets the size of the magnetic field map. More...
 
void setApertSize (int sizeHER, int sizeLER)
 Sets the size of the aperture map. More...
 
virtual void terminate ()
 Terminates the magnetic field component. More...
 

Private Member Functions

int getRange (double a, const ranges_t &b) const
 Search for range occupied by optics since now only for ranges are present use linear search. More...
 
double getAperture (double s, std::vector< ApertPoint >::const_iterator hint) const
 Returns the beam pipe aperture at given position. More...
 

Private Attributes

std::string m_mapFilenameHER {""}
 Magnetic field map of HER

 
std::string m_mapFilenameLER {""}
 Magnetic field map of LER

 
std::string m_mapFilenameHERleak {""}
 The filename of the magnetic field map.
 
std::string m_apertFilenameHER {""}
 Filename of the aperture for HER.
 
std::string m_apertFilenameLER {""}
 The filename of the aperture for LER.
 
int m_mapSizeHER {0}
 The size of the map for HER.
 
int m_mapSizeLER {0}
 The size of the map for LER.
 
int m_mapSizeHERleak {0}
 The size of the map.
 
int m_apertSizeHER {0}
 The size of the aperture for HER.
 
int m_apertSizeLER {0}
 The size of the aperture for LER.
 
double m_maxr2 {0}
 The square of maximal aperture for fast rejection.
 
ranges_t m_ranges_her
 ranges vector for HER
 
ranges_t m_ranges_ler
 ranges vector for LER
 
std::vector< ApertPointm_ah
 The the aperture parameters for HER.
 
std::vector< ApertPointm_al
 The the aperture parameters for LER.
 
std::vector< ParamPoint3m_h3
 The map for HER.
 
std::vector< ParamPoint3m_l3
 The map for LER.
 
std::vector< std::vector< ParamPoint3 >::const_iterator > m_offset_pp_her
 The vector of pointer to accelerate search in maps for her.
 
std::vector< std::vector< ParamPoint3 >::const_iterator > m_offset_pp_ler
 The vector of pointer to accelerate search in maps for ler.
 
std::vector< std::vector< ApertPoint >::const_iterator > m_offset_ap_her
 The vector of pointer to accelerate search in aperture for her.
 
std::vector< std::vector< ApertPoint >::const_iterator > m_offset_ap_ler
 The vector of pointer to accelerate search in aperture for ler.
 

Detailed Description

The BFieldComponentQuad class.

This class represents a magnetic field map from quadrupole magnets QC[1/2]*. Only the field from QC[1/2]* inside beam pipes is described. Leak field inside the beam pipe from the quadruple magnet on the other beam line is also included, however, leak field outside both beam pipe are not described. Therefore, we should turn on this field component only when we use TouschekTURTLEReader and Synchrotron radiation study, which needs accurate propagation of beam particles. Field strength are calculated from the magnet parameters (K0,K1,SK0,SK1) used in accelerator simulation. These parameters are provided for each 4cm slice in the beam direction.

Definition at line 35 of file BFieldComponentQuad.h.

Member Function Documentation

◆ calculate()

ROOT::Math::XYZVector calculate ( const ROOT::Math::XYZVector &  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 XYZVector(0,0,0) if the space point lies outside the region described by the component.

Implements BFieldComponentAbs.

Definition at line 347 of file BFieldComponentQuad.cc.

348 {
349  const double sa = sin(0.0415), ca = cos(0.0415);
350  //assume point is given in [cm]
351  ROOT::Math::XYZVector B(0, 0, 0);
352 
353  const ROOT::Math::XYZVector& v{point};
354  double xc = v.X() * ca, zs = v.Z() * sa, zc = v.Z() * ca, xs = v.X() * sa;
355  ROOT::Math::XYZVector vh{(xc - zs), -v.Y(), -(zc + xs)}; // to the HER beamline frame
356  ROOT::Math::XYZVector vl{(xc + zs), -v.Y(), -(zc - xs)}; // to the LER beamline frame
357 
358  double r2h = vh.Perp2(), r2l = vl.Perp2();
359 
360  if (r2h < r2l) { /* the point is closer to HER*/
361  if (r2h < m_maxr2) { /* within max radius */
362  double s = vh.Z();
363  int i = getRange(s, m_ranges_her);
364  if (i < 0) return B;
365  double r = getAperture(s, m_offset_ap_her[i]);
366  if (r2h < r * r) {
367  auto kt = m_offset_pp_her[i] + static_cast<unsigned int>(s - m_ranges_her[i + 1].r0);
368  double Bx = kt->getBx(vh.X(), vh.Y());
369  double By = kt->getBy(vh.X(), vh.Y());
370  B.SetXYZ(Bx * ca, -By, -Bx * sa); // to the detector frame
371  }
372  }
373  } else { /* the point is closer to LER*/
374  if (r2l < m_maxr2) { /* within max radius */
375  double s = vl.Z();
376  int i = getRange(s, m_ranges_ler);
377  if (i < 0) return B;
378  double r = getAperture(s, m_offset_ap_ler[i]);
379  if (r2l < r * r) {
380  auto kt = m_offset_pp_ler[i] + static_cast<unsigned int>(s - m_ranges_ler[i + 1].r0);
381  double Bx = kt->getBx(vl.X(), vl.Y());
382  double By = kt->getBy(vl.X(), vl.Y());
383  B.SetXYZ(Bx * ca, -By, Bx * sa); // to the detector frame
384  }
385  }
386  }
387  return B;
388 }
int getRange(double a, const ranges_t &b) const
Search for range occupied by optics since now only for ranges are present use linear search.
double m_maxr2
The square of maximal aperture for fast rejection.
std::vector< std::vector< ApertPoint >::const_iterator > m_offset_ap_ler
The vector of pointer to accelerate search in aperture for ler.
std::vector< std::vector< ParamPoint3 >::const_iterator > m_offset_pp_her
The vector of pointer to accelerate search in maps for her.
ranges_t m_ranges_her
ranges vector for HER
double getAperture(double s, std::vector< ApertPoint >::const_iterator hint) const
Returns the beam pipe aperture at given position.
std::vector< std::vector< ApertPoint >::const_iterator > m_offset_ap_her
The vector of pointer to accelerate search in aperture for her.
std::vector< std::vector< ParamPoint3 >::const_iterator > m_offset_pp_ler
The vector of pointer to accelerate search in maps for ler.
ranges_t m_ranges_ler
ranges vector for LER

◆ getAperture()

double getAperture ( double  s,
std::vector< ApertPoint >::const_iterator  hint 
) const
inlineprivate

Returns the beam pipe aperture at given position.

Small number of points again linear search.

Parameters
sThe position in beam-axis coordinate.
hintStart search from this position
Returns
The beam pipe aperture at given position.

Definition at line 340 of file BFieldComponentQuad.cc.

◆ getApertureHER()

double getApertureHER ( double  s) const

Returns the HER beam pipe aperture at given position.

Parameters
sThe position in HER beam-axis coordinate.
Returns
The beam pipe aperture at given position.

Definition at line 318 of file BFieldComponentQuad.cc.

◆ getApertureLER()

double getApertureLER ( double  s) const

Returns the LER beam pipe aperture at given position.

Parameters
sThe position in LER beam-axis coordinate.
Returns
The beam pipe aperture at given position.

Definition at line 325 of file BFieldComponentQuad.cc.

◆ getRange()

int getRange ( double  a,
const ranges_t b 
) const
inlineprivate

Search for range occupied by optics since now only for ranges are present use linear search.

Parameters
acoordinate along beamline
bvector with ranges with sentinel at the beginning and the end
Returns
the range number if out of ranges return -1

Definition at line 332 of file BFieldComponentQuad.cc.

◆ initialize()

void initialize ( void  )
overridevirtual

Initializes the magnetic field component.

This method opens the magnetic field map file.

Magnetic field data structure.

< s in [m]

< element length in [m]

< dipole component in [dimensionless]

< quadrupole component in [1/m]

< skew dipole component in [dimensionless]

< skew quadrupole component in [1/m]

< rotation in [radian]

< horizontal displacement in [m]

< vertical displacement in [m]

fold rotation to/from lense frame to a single matrix multiplicaton and vector addition

Parameters
inmap with angle inside
p0normalization constant
Returns
structure where rotations are in the matrix form

In case several maps in the same position we can simply sum up all matricies since magnetic field has superposition properties as well as keep only one vector of parameters for each beamline

Parameters
vfirst map
amap to add to the first map
Returns
merged field map

calculate ranges where quadrupole lenses continously fill the beamline

Parameters
vlense vector
Returns
vector of ranges

associate ranges with the vector of aperture points

Parameters
apthe vector of aperture points
vthe vector of ranges
Returns
the vector of iterators for more effective search

associate ranges with the vector of lenses

Parameters
apthe vector of lenses
vthe vector of ranges
Returns
the vector of iterators which points to the begining of the continous area of lenses

Reimplemented from BFieldComponentAbs.

Definition at line 43 of file BFieldComponentQuad.cc.

◆ setApertFilename()

void setApertFilename ( const std::string &  filenameHER,
const std::string &  filenameLER 
)
inline

Sets the filename of aperture definition file.

Parameters
filenameHERThe filename of the aperture definition for HER.
filenameLERThe filename of the aperture definition for LER.

Definition at line 153 of file BFieldComponentQuad.h.

153 { m_apertFilenameHER = filenameHER; m_apertFilenameLER = filenameLER; }
std::string m_apertFilenameHER
Filename of the aperture for HER.
std::string m_apertFilenameLER
The filename of the aperture for LER.

◆ setApertSize()

void setApertSize ( int  sizeHER,
int  sizeLER 
)
inline

Sets the size of the aperture map.

Parameters
sizeHERThe number of points in the HER aperture file.
sizeLERThe number of points in the LER aperture file.

Definition at line 168 of file BFieldComponentQuad.h.

◆ setMapFilename()

void setMapFilename ( const std::string &  filenameHER,
const std::string &  filenameLER,
const std::string &  filenameHERleak 
)
inline

Sets the filename of the magnetic field map.

Parameters
filenameHERThe filename of the magnetic field map for HER.
filenameLERThe filename of the magnetic field map for LER.
filenameHERleakThe filename of the magnetic field map for HER (leak field from LER).

Definition at line 146 of file BFieldComponentQuad.h.

◆ setMapSize()

void setMapSize ( int  sizeHER,
int  sizeLER,
int  sizeHERleak 
)
inline

Sets the size of the magnetic field map.

Parameters
sizeHERThe number of points in the HER field parameters.
sizeLERThe number of points in the LER field parameters.
sizeHERleakThe number of points in the HER field parameters (leak field from LER).

Definition at line 161 of file BFieldComponentQuad.h.

◆ terminate()

virtual void terminate ( void  )
inlinevirtualinherited

Terminates the magnetic field component.

This method should be used to close files that have been opened in the initialize() method.

Reimplemented in BFieldComponentRadial, BFieldComponentKlm1, BFieldComponentBeamline, and BFieldComponent3d.

Definition at line 66 of file BFieldComponentAbs.h.


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