Belle II Software  release-05-01-25
BFieldComponent3d.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2010-2011 Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * *
7  * This software is provided "as is" without any warranty. *
8  **************************************************************************/
9 
10 #ifndef BFIELDCOMPONENT3D_H
11 #define BFIELDCOMPONENT3D_H
12 
13 #include <geometry/bfieldmap/BFieldComponentAbs.h>
14 
15 #include <string>
16 
17 namespace Belle2 {
37  class BFieldComponent3d : public BFieldComponentAbs {
38 
39  public:
40 
42  BFieldComponent3d() = default;
43 
45  virtual ~BFieldComponent3d() = default;
46 
51  virtual void initialize() override;
52 
60  virtual B2Vector3D calculate(const B2Vector3D& point) const override;
61 
66  virtual void terminate() override;
67 
72  void setMapFilename(const std::string& filename) { m_mapFilename = filename; };
73 
80  void setMapSize(int sizeR, int sizePhi, int sizeZ) { m_mapSize[0] = sizeR; m_mapSize[1] = sizePhi; m_mapSize[2] = sizeZ; }
81 
88  void setMapRegionZ(double minZ, double maxZ, double offset) { m_mapRegionZ[0] = minZ; m_mapRegionZ[1] = maxZ; m_mapOffset = offset; }
89 
95  void setMapRegionR(double minR, double maxR) { m_mapRegionR[0] = minR; m_mapRegionR[1] = maxR; }
96 
103  void setGridPitch(double pitchR, double pitchPhi, double pitchZ) { m_gridPitch[0] = pitchR; m_gridPitch[1] = pitchPhi; m_gridPitch[2] = pitchZ; }
104 
110  void setExcludeRegionZ(double minZ, double maxZ) { m_exRegionZ[0] = minZ + m_mapOffset; m_exRegionZ[1] = maxZ + m_mapOffset; }
111 
117  void setExcludeRegionR(double minR, double maxR) { m_exRegionR[0] = minR; m_exRegionR[1] = maxR; }
118 
127  void setErrorRegionR(double minR = -1., double maxR = -1., double errBr = 0.0, double errBphi = 0.0, double errBz = 0.0)
128  { m_errRegionR[0] = minR; m_errRegionR[1] = maxR; m_errB[0] = errBr; m_errB[1] = errBphi; m_errB[2] = errBz; }
129 
133  void mirrorPhi(bool mirrorPhi = 0.) { m_mirrorPhi = mirrorPhi; }
134 
138  void doInterpolation(bool interpolate = true) { m_interpolate = interpolate; }
139 
144  void enableCoordinate(const std::string& mapEnable = "rphiz") { m_mapEnable = mapEnable; }
145  protected:
146 
147  private:
148 
152  B2Vector3D interpolate(unsigned int ir, unsigned int iphi, unsigned int iz, double wr, double wphi, double wz) const;
153 
155  std::string m_mapFilename{""};
157  std::vector<B2Vector3F> m_bmap;
159  std::string m_mapEnable{"rphiz"};
161  bool m_interpolate{true};
163  int m_mapSize[3];
165  double m_mapRegionZ[2] {0};
167  double m_mapOffset{0};
169  double m_mapRegionR[2] {0};
171  double m_gridPitch[3] {0};
173  double m_igridPitch[3] {0};
175  double m_exRegionZ[2] {0};
177  double m_exRegionR[2] {0};
179  bool m_exRegion{true};
181  bool m_mirrorPhi{true};
183  double m_errRegionR[2] {0};
185  double m_errB[3] {0};
186  };
187 
189 } //end of namespace Belle2
190 
191 #endif /* BFIELDCOMPONENT3D_H */
Belle2::BFieldComponent3d::m_bmap
std::vector< B2Vector3F > m_bmap
The memory buffer for the magnetic field map.
Definition: BFieldComponent3d.h:164
Belle2::BFieldComponent3d::m_mapRegionR
double m_mapRegionR[2]
The min and max boundaries of the map region in r.
Definition: BFieldComponent3d.h:176
Belle2::BFieldComponent3d::m_exRegion
bool m_exRegion
Flag to indicate whether there is a region to exclude.
Definition: BFieldComponent3d.h:186
Belle2::BFieldComponent3d::m_exRegionR
double m_exRegionR[2]
The min and max boundaries of the excluded region in r.
Definition: BFieldComponent3d.h:184
Belle2::BFieldComponent3d::m_igridPitch
double m_igridPitch[3]
The inverted grid pitch in r,phi,z.
Definition: BFieldComponent3d.h:180
Belle2::BFieldComponent3d::BFieldComponent3d
BFieldComponent3d()=default
The BFieldComponent3d constructor.
Belle2::BFieldComponent3d::calculate
virtual B2Vector3D calculate(const B2Vector3D &point) const override
Calculates the magnetic field vector at the specified space point.
Definition: BFieldComponent3d.cc:186
Belle2::BFieldComponent3d::terminate
virtual void terminate() override
Terminates the magnetic field component.
Definition: BFieldComponent3d.cc:254
Belle2::BFieldComponent3d::m_mapEnable
std::string m_mapEnable
Enable different dimension, "rphiz", "rphi", "phiz" or "rz" >
Definition: BFieldComponent3d.h:166
Belle2::BFieldComponent3d::setMapSize
void setMapSize(int sizeR, int sizePhi, int sizeZ)
Sets the size of the magnetic field map.
Definition: BFieldComponent3d.h:87
Belle2::BFieldComponent3d::m_mapRegionZ
double m_mapRegionZ[2]
The min and max boundaries of the map region in z.
Definition: BFieldComponent3d.h:172
Belle2::BFieldComponent3d::m_exRegionZ
double m_exRegionZ[2]
The min and max boundaries of the excluded region in z.
Definition: BFieldComponent3d.h:182
Belle2::B2Vector3< double >
Belle2::BFieldComponent3d::m_mapSize
int m_mapSize[3]
The size of the map in r, phi and z.
Definition: BFieldComponent3d.h:170
Belle2::BFieldComponent3d::setGridPitch
void setGridPitch(double pitchR, double pitchPhi, double pitchZ)
Sets the grid pitch of the magnetic field map.
Definition: BFieldComponent3d.h:110
Belle2::BFieldComponent3d::m_mirrorPhi
bool m_mirrorPhi
Flag to indicate whether there is a region to exclude.
Definition: BFieldComponent3d.h:188
Belle2::B2Vector3D
B2Vector3< double > B2Vector3D
typedef for common usage with double
Definition: B2Vector3.h:507
Belle2::BFieldComponent3d::mirrorPhi
void mirrorPhi(bool mirrorPhi=0.)
Definition: BFieldComponent3d.h:140
Belle2::BFieldComponent3d::setErrorRegionR
void setErrorRegionR(double minR=-1., double maxR=-1., double errBr=0.0, double errBphi=0.0, double errBz=0.0)
Sets the size of the magnetic field map to apply error on B.
Definition: BFieldComponent3d.h:134
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::BFieldComponent3d::setMapRegionZ
void setMapRegionZ(double minZ, double maxZ, double offset)
Sets the size of the magnetic field map.
Definition: BFieldComponent3d.h:95
Belle2::BFieldComponent3d::m_interpolate
bool m_interpolate
Flag to switch on/off interpolation >
Definition: BFieldComponent3d.h:168
Belle2::BFieldComponent3d::enableCoordinate
void enableCoordinate(const std::string &mapEnable="rphiz")
Optino to reduce 3D to 2D map (in coordinates, NOT Br, Bphi, Bz components)
Definition: BFieldComponent3d.h:151
Belle2::BFieldComponent3d::setMapRegionR
void setMapRegionR(double minR, double maxR)
Sets the size of the magnetic field map.
Definition: BFieldComponent3d.h:102
Belle2::BFieldComponent3d::initialize
virtual void initialize() override
Initializes the magnetic field component.
Definition: BFieldComponent3d.cc:26
alignment.constraints_generator.filename
filename
File name.
Definition: constraints_generator.py:224
Belle2::BFieldComponent3d::setExcludeRegionZ
void setExcludeRegionZ(double minZ, double maxZ)
Sets the size of the magnetic field map to exclude.
Definition: BFieldComponent3d.h:117
Belle2::BFieldComponent3d::m_errB
double m_errB[3]
The error Br, Bphi, Bz as a scale factor (B_new = m_errB * B_old).
Definition: BFieldComponent3d.h:192
Belle2::BFieldComponent3d::m_mapFilename
std::string m_mapFilename
The filename of the magnetic field map.
Definition: BFieldComponent3d.h:162
Belle2::BFieldComponent3d::setMapFilename
void setMapFilename(const std::string &filename)
Sets the filename of the magnetic field map.
Definition: BFieldComponent3d.h:79
Belle2::BFieldComponent3d::m_gridPitch
double m_gridPitch[3]
The grid pitch in r,phi,z.
Definition: BFieldComponent3d.h:178
Belle2::BFieldComponent3d::~BFieldComponent3d
virtual ~BFieldComponent3d()=default
The BFieldComponent3d destructor.
Belle2::BFieldComponent3d::setExcludeRegionR
void setExcludeRegionR(double minR, double maxR)
Sets the size of the magnetic field map to exclude.
Definition: BFieldComponent3d.h:124
Belle2::BFieldComponent3d::interpolate
B2Vector3D interpolate(unsigned int ir, unsigned int iphi, unsigned int iz, double wr, double wphi, double wz) const
Interpolate the value of B-field between (ir, iphi, iz) and (ir+1, iphi+1, iz+1) using weights (wr,...
Definition: BFieldComponent3d.cc:258
Belle2::BFieldComponent3d::m_errRegionR
double m_errRegionR[2]
The min and max boundaries of the region in r to apply error.
Definition: BFieldComponent3d.h:190
Belle2::BFieldComponent3d::m_mapOffset
double m_mapOffset
Offset required because the accelerator group defines the Belle center as zero.
Definition: BFieldComponent3d.h:174
Belle2::BFieldComponent3d::doInterpolation
void doInterpolation(bool interpolate=true)
Definition: BFieldComponent3d.h:145