Belle II Software  release-06-00-14
BFieldComponentQuad.h
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 
9 #pragma once
10 
11 #include <geometry/bfieldmap/BFieldComponentAbs.h>
12 
13 #include <string>
14 
15 namespace Belle2 {
35 
36  public:
38  struct range_t {
39  double r0;
40  double r1;
41  };
43  typedef std::vector<range_t> ranges_t;
44 
46  struct ApertPoint {
47  double s{0};
48  double r{0};
49  };
50 
53  struct ParamPoint3 {
54  double s{0};
55  double L{0};
56  double mxx{0};
57  double mxy{0};
58  double mx0{0};
59  double myx{0};
60  double myy{0};
61  double my0{0};
70  inline double getBx(double x, double y) const {return x * mxx + y * mxy + mx0;}
79  inline double getBy(double x, double y) const {return x * myx + y * myy + my0;}
80 
88  {
89  mxx += t.mxx;
90  mxy += t.mxy;
91  mx0 += t.mx0;
92  myx += t.myx;
93  myy += t.myy;
94  my0 += t.my0;
95  return *this;
96  }
97  };
98 
100  struct irange_t {
101  short int i0{0};
102  short int i1{0};
103  };
104 
106  BFieldComponentQuad() = default;
107 
109  virtual ~BFieldComponentQuad() = default;
110 
115  virtual void initialize() override;
116 
123  virtual B2Vector3D calculate(const B2Vector3D& point) const override;
124 
130  double getApertureHER(double s) const;
131 
137  double getApertureLER(double s) const;
138 
145  void setMapFilename(const std::string& filenameHER, const std::string& filenameLER, const std::string& filenameHERleak) { m_mapFilenameHER = filenameHER; m_mapFilenameLER = filenameLER; m_mapFilenameHERleak = filenameHERleak; }
146 
152  void setApertFilename(const std::string& filenameHER, const std::string& filenameLER) { m_apertFilenameHER = filenameHER; m_apertFilenameLER = filenameLER; }
153 
160  void setMapSize(int sizeHER, int sizeLER, int sizeHERleak) { m_mapSizeHER = sizeHER; m_mapSizeLER = sizeLER; m_mapSizeHERleak = sizeHERleak;}
161 
167  void setApertSize(int sizeHER, int sizeLER) { m_apertSizeHER = sizeHER; m_apertSizeLER = sizeLER; }
168 
169  private:
176  inline int getRange(double a, const ranges_t& b) const;
177 
184  inline double getAperture(double s, std::vector<ApertPoint>::const_iterator hint) const;
185 
187  std::string m_mapFilenameHER{""};
189  std::string m_mapFilenameLER{""};
191  std::string m_mapFilenameHERleak{""};
193  std::string m_apertFilenameHER{""};
195  std::string m_apertFilenameLER{""};
197  int m_mapSizeHER{0};
199  int m_mapSizeLER{0};
207  double m_maxr2{0};
208 
213  std::vector<ApertPoint> m_ah;
215  std::vector<ApertPoint> m_al;
216 
218  std::vector<ParamPoint3> m_h3;
220  std::vector<ParamPoint3 >m_l3;
221 
223  std::vector<std::vector<ParamPoint3>::const_iterator> m_offset_pp_her;
225  std::vector<std::vector<ParamPoint3>::const_iterator> m_offset_pp_ler;
227  std::vector<std::vector<ApertPoint>::const_iterator> m_offset_ap_her;
229  std::vector<std::vector<ApertPoint>::const_iterator> m_offset_ap_ler;
230  };
231 
233 } //end of namespace Belle2
The BFieldComponentAbs class.
The BFieldComponentQuad class.
void setApertFilename(const std::string &filenameHER, const std::string &filenameLER)
Sets the filename of aperture definition file.
int getRange(double a, const ranges_t &b) const
Search for range occuped by optics since now only for ranges are present use linear search.
int m_mapSizeHER
The size of the map for HER.
double getApertureLER(double s) const
Returns the LER beam pipe aperture at given position.
int m_mapSizeHERleak
The size of the map.
double m_maxr2
The square of maximal aperture for fast rejection.
virtual void initialize() override
Initializes the magnetic field component.
std::vector< ApertPoint > m_al
The the aperture parameters for LER.
std::vector< ApertPoint > m_ah
The the aperture parameters for HER.
void setMapFilename(const std::string &filenameHER, const std::string &filenameLER, const std::string &filenameHERleak)
Sets the filename of the magnetic field map.
int m_mapSizeLER
The size of the map for LER.
std::vector< std::vector< ApertPoint >::const_iterator > m_offset_ap_ler
The vector of pointer to accelerate search in aperture for ler.
std::string m_mapFilenameLER
Magnetic field map of LER
void setApertSize(int sizeHER, int sizeLER)
Sets the size of the aperture map.
std::string m_mapFilenameHERleak
The filename of the magnetic field map.
void setMapSize(int sizeHER, int sizeLER, int sizeHERleak)
Sets the size of the magnetic field map.
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
virtual ~BFieldComponentQuad()=default
The BFieldComponentQuad destructor.
std::vector< ParamPoint3 > m_h3
The map 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.
virtual B2Vector3D calculate(const B2Vector3D &point) const override
Calculates the magnetic field vector at the specified space point.
std::vector< ParamPoint3 > m_l3
The map for LER.
std::string m_mapFilenameHER
Magnetic field map of HER
double getApertureHER(double s) const
Returns the HER beam pipe aperture at given position.
std::vector< std::vector< ParamPoint3 >::const_iterator > m_offset_pp_ler
The vector of pointer to accelerate search in maps for ler.
int m_apertSizeHER
The size of the aperture for HER.
std::vector< range_t > ranges_t
vector of Range data structure.
ranges_t m_ranges_ler
ranges vector for LER
BFieldComponentQuad()=default
The BFieldComponentQuad constructor.
std::string m_apertFilenameHER
Filename of the aperture for HER.
int m_apertSizeLER
The size of the aperture for LER.
std::string m_apertFilenameLER
The filename of the aperture for LER.
Abstract base class for different kinds of events.
double s
length along beamline in [cm]
Quadrupole lense data structure.
double myx
yx coefficents to calculate By
double mxx
xx coefficents to calculate Bx
double getBx(double x, double y) const
Calculates the X component of the magnetic field vector at the specified space point from a quadrupol...
double mx0
x0 coefficents to calculate Bx
double getBy(double x, double y) const
Calculates the Y component of the magnetic field vector at the specified space point from a quadrupol...
double mxy
xy coefficents to calculate Bx
double my0
y0 coefficents to calculate By
ParamPoint3 & operator+=(const ParamPoint3 &t)
Sum up the matrix components of quadrupole lenses.
double myy
yy coefficents to calculate By
start and stop indicies to narrow search in array