Belle II Software  release-05-01-25
BFieldComponentQuad.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2010-2011 Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Andreas Moll, Hiroyuki Nakayama *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #ifndef BFIELDCOMPONENTQUAD_H
12 #define BFIELDCOMPONENTQUAD_H
13 
14 #include <geometry/bfieldmap/BFieldComponentAbs.h>
15 
16 #include <string>
17 
18 namespace Belle2 {
37  class BFieldComponentQuad : public BFieldComponentAbs {
38 
39  public:
41  struct range_t {
42  double r0;
43  double r1;
44  };
46  typedef std::vector<range_t> ranges_t;
47 
49  struct ApertPoint {
50  double s{0};
51  double r{0};
52  };
53 
56  struct ParamPoint3 {
57  double s{0};
58  double L{0};
59  double mxx{0};
60  double mxy{0};
61  double mx0{0};
62  double myx{0};
63  double myy{0};
64  double my0{0};
73  inline double getBx(double x, double y) const {return x * mxx + y * mxy + mx0;}
82  inline double getBy(double x, double y) const {return x * myx + y * myy + my0;}
83 
91  {
92  mxx += t.mxx;
93  mxy += t.mxy;
94  mx0 += t.mx0;
95  myx += t.myx;
96  myy += t.myy;
97  my0 += t.my0;
98  return *this;
99  }
100  };
101 
103  struct irange_t {
104  short int i0{0};
105  short int i1{0};
106  };
107 
109  BFieldComponentQuad() = default;
110 
112  virtual ~BFieldComponentQuad() = default;
113 
118  virtual void initialize() override;
119 
126  virtual B2Vector3D calculate(const B2Vector3D& point) const override;
127 
133  double getApertureHER(double s) const;
134 
140  double getApertureLER(double s) const;
141 
148  void setMapFilename(const std::string& filenameHER, const std::string& filenameLER, const std::string& filenameHERleak) { m_mapFilenameHER = filenameHER; m_mapFilenameLER = filenameLER; m_mapFilenameHERleak = filenameHERleak; }
149 
155  void setApertFilename(const std::string& filenameHER, const std::string& filenameLER) { m_apertFilenameHER = filenameHER; m_apertFilenameLER = filenameLER; }
156 
163  void setMapSize(int sizeHER, int sizeLER, int sizeHERleak) { m_mapSizeHER = sizeHER; m_mapSizeLER = sizeLER; m_mapSizeHERleak = sizeHERleak;}
164 
170  void setApertSize(int sizeHER, int sizeLER) { m_apertSizeHER = sizeHER; m_apertSizeLER = sizeLER; }
171 
172  private:
179  inline int getRange(double a, const ranges_t& b) const;
180 
187  inline double getAperture(double s, std::vector<ApertPoint>::const_iterator hint) const;
188 
190  std::string m_mapFilenameHER{""};
192  std::string m_mapFilenameLER{""};
194  std::string m_mapFilenameHERleak{""};
196  std::string m_apertFilenameHER{""};
198  std::string m_apertFilenameLER{""};
200  int m_mapSizeHER{0};
202  int m_mapSizeLER{0};
210  double m_maxr2{0};
211 
216  std::vector<ApertPoint> m_ah;
218  std::vector<ApertPoint> m_al;
219 
221  std::vector<ParamPoint3> m_h3;
223  std::vector<ParamPoint3 >m_l3;
224 
226  std::vector<std::vector<ParamPoint3>::const_iterator> m_offset_pp_her;
228  std::vector<std::vector<ParamPoint3>::const_iterator> m_offset_pp_ler;
230  std::vector<std::vector<ApertPoint>::const_iterator> m_offset_ap_her;
232  std::vector<std::vector<ApertPoint>::const_iterator> m_offset_ap_ler;
233  };
234 
236 } //end of namespace Belle2
237 
238 #endif /* BFIELDCOMPONENTQUAD_H */
Belle2::BFieldComponentQuad::initialize
virtual void initialize() override
Initializes the magnetic field component.
Definition: BFieldComponentQuad.cc:45
Belle2::BFieldComponentQuad::ParamPoint3
Quadrupole lense data structure.
Definition: BFieldComponentQuad.h:64
Belle2::BFieldComponentQuad::ParamPoint3::myy
double myy
yy coefficents to calculate By
Definition: BFieldComponentQuad.h:71
Belle2::BFieldComponentQuad::getAperture
double getAperture(double s, std::vector< ApertPoint >::const_iterator hint) const
Returns the beam pipe aperture at given position.
Definition: BFieldComponentQuad.cc:342
Belle2::BFieldComponentQuad::m_ah
std::vector< ApertPoint > m_ah
The the aperture parameters for HER.
Definition: BFieldComponentQuad.h:224
Belle2::BFieldComponentQuad::ranges_t
std::vector< range_t > ranges_t
vector of Range data structure.
Definition: BFieldComponentQuad.h:54
Belle2::BFieldComponentQuad::ParamPoint3::L
double L
element length in [cm]
Definition: BFieldComponentQuad.h:66
Belle2::BFieldComponentQuad::m_h3
std::vector< ParamPoint3 > m_h3
The map for HER.
Definition: BFieldComponentQuad.h:229
Belle2::BFieldComponentQuad::ParamPoint3::mx0
double mx0
x0 coefficents to calculate Bx
Definition: BFieldComponentQuad.h:69
Belle2::BFieldComponentQuad::m_offset_pp_ler
std::vector< std::vector< ParamPoint3 >::const_iterator > m_offset_pp_ler
The vector of pointer to accelerate search in maps for ler.
Definition: BFieldComponentQuad.h:236
Belle2::BFieldComponentQuad::getApertureLER
double getApertureLER(double s) const
Returns the LER beam pipe aperture at given position.
Definition: BFieldComponentQuad.cc:327
Belle2::BFieldComponentQuad::m_apertFilenameHER
std::string m_apertFilenameHER
Filename of the aperture for HER.
Definition: BFieldComponentQuad.h:204
Belle2::BFieldComponentQuad::ParamPoint3::getBy
double getBy(double x, double y) const
Calculates the Y component of the magnetic field vector at the specified space point from a quadrupol...
Definition: BFieldComponentQuad.h:90
Belle2::BFieldComponentQuad::BFieldComponentQuad
BFieldComponentQuad()=default
The BFieldComponentQuad constructor.
Belle2::BFieldComponentQuad::getApertureHER
double getApertureHER(double s) const
Returns the HER beam pipe aperture at given position.
Definition: BFieldComponentQuad.cc:320
Belle2::BFieldComponentQuad::m_apertFilenameLER
std::string m_apertFilenameLER
The filename of the aperture for LER.
Definition: BFieldComponentQuad.h:206
Belle2::BFieldComponentQuad::ParamPoint3::my0
double my0
y0 coefficents to calculate By
Definition: BFieldComponentQuad.h:72
Belle2::BFieldComponentQuad::m_apertSizeHER
int m_apertSizeHER
The size of the aperture for HER.
Definition: BFieldComponentQuad.h:214
Belle2::BFieldComponentQuad::m_maxr2
double m_maxr2
The square of maximal aperture for fast rejection.
Definition: BFieldComponentQuad.h:218
Belle2::BFieldComponentQuad::m_ranges_her
ranges_t m_ranges_her
ranges vector for HER
Definition: BFieldComponentQuad.h:220
Belle2::B2Vector3< double >
Belle2::BFieldComponentQuad::m_mapSizeHER
int m_mapSizeHER
The size of the map for HER.
Definition: BFieldComponentQuad.h:208
Belle2::BFieldComponentQuad::m_apertSizeLER
int m_apertSizeLER
The size of the aperture for LER.
Definition: BFieldComponentQuad.h:216
Belle2::BFieldComponentQuad::ApertPoint::r
double r
aperture in [cm]
Definition: BFieldComponentQuad.h:59
Belle2::BFieldComponentQuad::ParamPoint3::getBx
double getBx(double x, double y) const
Calculates the X component of the magnetic field vector at the specified space point from a quadrupol...
Definition: BFieldComponentQuad.h:81
Belle2::BFieldComponentQuad::range_t::r1
double r1
max of the range
Definition: BFieldComponentQuad.h:51
Belle2::BFieldComponentQuad::range_t::r0
double r0
min of the range
Definition: BFieldComponentQuad.h:50
Belle2::BFieldComponentQuad::ParamPoint3::mxx
double mxx
xx coefficents to calculate Bx
Definition: BFieldComponentQuad.h:67
Belle2::BFieldComponentQuad::irange_t::i0
short int i0
start index
Definition: BFieldComponentQuad.h:112
Belle2::BFieldComponentQuad::m_mapSizeLER
int m_mapSizeLER
The size of the map for LER.
Definition: BFieldComponentQuad.h:210
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::BFieldComponentQuad::calculate
virtual B2Vector3D calculate(const B2Vector3D &point) const override
Calculates the magnetic field vector at the specified space point.
Definition: BFieldComponentQuad.cc:349
Belle2::BFieldComponentQuad::m_l3
std::vector< ParamPoint3 > m_l3
The map for LER.
Definition: BFieldComponentQuad.h:231
Belle2::BFieldComponentQuad::getRange
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.
Definition: BFieldComponentQuad.cc:334
Belle2::BFieldComponentQuad::ParamPoint3::s
double s
s in [cm]
Definition: BFieldComponentQuad.h:65
Belle2::BFieldComponentQuad::m_ranges_ler
ranges_t m_ranges_ler
ranges vector for LER
Definition: BFieldComponentQuad.h:221
Belle2::BFieldComponentQuad::m_al
std::vector< ApertPoint > m_al
The the aperture parameters for LER.
Definition: BFieldComponentQuad.h:226
Belle2::BFieldComponentQuad::ApertPoint::s
double s
length along beamline in [cm]
Definition: BFieldComponentQuad.h:58
Belle2::BFieldComponentQuad::m_offset_ap_her
std::vector< std::vector< ApertPoint >::const_iterator > m_offset_ap_her
The vector of pointer to accelerate search in aperture for her.
Definition: BFieldComponentQuad.h:238
Belle2::BFieldComponentQuad::m_offset_ap_ler
std::vector< std::vector< ApertPoint >::const_iterator > m_offset_ap_ler
The vector of pointer to accelerate search in aperture for ler.
Definition: BFieldComponentQuad.h:240
Belle2::BFieldComponentQuad::ParamPoint3::operator+=
ParamPoint3 & operator+=(const ParamPoint3 &t)
Sum up the matrix components of quadrupole lenses.
Definition: BFieldComponentQuad.h:98
Belle2::BFieldComponentQuad::setApertSize
void setApertSize(int sizeHER, int sizeLER)
Sets the size of the aperture map.
Definition: BFieldComponentQuad.h:178
Belle2::BFieldComponentQuad::setMapFilename
void setMapFilename(const std::string &filenameHER, const std::string &filenameLER, const std::string &filenameHERleak)
Sets the filename of the magnetic field map.
Definition: BFieldComponentQuad.h:156
Belle2::BFieldComponentQuad::m_mapFilenameHER
std::string m_mapFilenameHER
Magnetic field map of HER
Definition: BFieldComponentQuad.h:198
Belle2::BFieldComponentQuad::irange_t::i1
short int i1
stop index
Definition: BFieldComponentQuad.h:113
Belle2::BFieldComponentQuad::~BFieldComponentQuad
virtual ~BFieldComponentQuad()=default
The BFieldComponentQuad destructor.
Belle2::BFieldComponentQuad::m_offset_pp_her
std::vector< std::vector< ParamPoint3 >::const_iterator > m_offset_pp_her
The vector of pointer to accelerate search in maps for her.
Definition: BFieldComponentQuad.h:234
Belle2::BFieldComponentQuad::m_mapFilenameLER
std::string m_mapFilenameLER
Magnetic field map of LER
Definition: BFieldComponentQuad.h:200
Belle2::BFieldComponentQuad::ParamPoint3::mxy
double mxy
xy coefficents to calculate Bx
Definition: BFieldComponentQuad.h:68
Belle2::BFieldComponentQuad::setApertFilename
void setApertFilename(const std::string &filenameHER, const std::string &filenameLER)
Sets the filename of aperture definition file.
Definition: BFieldComponentQuad.h:163
Belle2::BFieldComponentQuad::m_mapFilenameHERleak
std::string m_mapFilenameHERleak
The filename of the magnetic field map.
Definition: BFieldComponentQuad.h:202
Belle2::BFieldComponentQuad::ParamPoint3::myx
double myx
yx coefficents to calculate By
Definition: BFieldComponentQuad.h:70
Belle2::BFieldComponentQuad::m_mapSizeHERleak
int m_mapSizeHERleak
The size of the map.
Definition: BFieldComponentQuad.h:212
Belle2::BFieldComponentQuad::ApertPoint
Aperture data structure.
Definition: BFieldComponentQuad.h:57
Belle2::BFieldComponentQuad::setMapSize
void setMapSize(int sizeHER, int sizeLER, int sizeHERleak)
Sets the size of the magnetic field map.
Definition: BFieldComponentQuad.h:171