Belle II Software  release-08-01-10
BFieldComponent3d.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 #include <vector>
15 
16 namespace Belle2 {
37 
38  public:
39 
41  BFieldComponent3d() = default;
42 
44  virtual ~BFieldComponent3d() = default;
45 
50  virtual void initialize() override;
51 
59  virtual ROOT::Math::XYZVector calculate(const ROOT::Math::XYZVector& point) const override;
60 
65  virtual void terminate() override;
66 
71  void setMapFilename(const std::string& filename) { m_mapFilename = filename; };
72 
79  void setMapSize(int sizeR, int sizePhi, int sizeZ) { m_mapSize[0] = sizeR; m_mapSize[1] = sizePhi; m_mapSize[2] = sizeZ; }
80 
87  void setMapRegionZ(double minZ, double maxZ, double offset) { m_mapRegionZ[0] = minZ; m_mapRegionZ[1] = maxZ; m_mapOffset = offset; }
88 
94  void setMapRegionR(double minR, double maxR) { m_mapRegionR[0] = minR; m_mapRegionR[1] = maxR; }
95 
102  void setGridPitch(double pitchR, double pitchPhi, double pitchZ) { m_gridPitch[0] = pitchR; m_gridPitch[1] = pitchPhi; m_gridPitch[2] = pitchZ; }
103 
109  void setExcludeRegionZ(double minZ, double maxZ) { m_exRegionZ[0] = minZ + m_mapOffset; m_exRegionZ[1] = maxZ + m_mapOffset; }
110 
116  void setExcludeRegionR(double minR, double maxR) { m_exRegionR[0] = minR; m_exRegionR[1] = maxR; }
117 
126  void setErrorRegionR(double minR = -1., double maxR = -1., double errBr = 0.0, double errBphi = 0.0, double errBz = 0.0)
127  { m_errRegionR[0] = minR; m_errRegionR[1] = maxR; m_errB[0] = errBr; m_errB[1] = errBphi; m_errB[2] = errBz; }
128 
132  void mirrorPhi(bool mirrorPhi = 0.) { m_mirrorPhi = mirrorPhi; }
133 
138 
143  void enableCoordinate(const std::string& mapEnable = "rphiz") { m_mapEnable = mapEnable; }
144  protected:
145 
146  private:
147 
151  ROOT::Math::XYZVector interpolate(unsigned int ir, unsigned int iphi, unsigned int iz, double wr, double wphi, double wz) const;
152 
154  std::string m_mapFilename{""};
156  std::vector<ROOT::Math::XYZVector> m_bmap;
158  std::string m_mapEnable{"rphiz"};
160  bool m_interpolate{true};
162  int m_mapSize[3];
164  double m_mapRegionZ[2] {0};
166  double m_mapOffset{0};
168  double m_mapRegionR[2] {0};
170  double m_gridPitch[3] {0};
172  double m_igridPitch[3] {0};
174  double m_exRegionZ[2] {0};
176  double m_exRegionR[2] {0};
178  bool m_exRegion{true};
180  bool m_mirrorPhi{true};
182  double m_errRegionR[2] {0};
184  double m_errB[3] {0};
185  };
186 
188 } //end of namespace Belle2
The BFieldComponent3d class.
double m_exRegionR[2]
The min and max boundaries of the excluded region in r.
void setExcludeRegionZ(double minZ, double maxZ)
Sets the size of the magnetic field map to exclude.
ROOT::Math::XYZVector 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,...
double m_errRegionR[2]
The min and max boundaries of the region in r to apply error.
virtual void initialize() override
Initializes the magnetic field component.
bool m_interpolate
Flag to switch on/off interpolation >
double m_gridPitch[3]
The grid pitch in r,phi,z.
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.
std::string m_mapFilename
The filename of the magnetic field map.
virtual void terminate() override
Terminates the magnetic field component.
double m_mapRegionZ[2]
The min and max boundaries of the map region in z.
double m_mapOffset
Offset required because the accelerator group defines the Belle center as zero.
int m_mapSize[3]
The size of the map in r, phi and z.
virtual ROOT::Math::XYZVector calculate(const ROOT::Math::XYZVector &point) const override
Calculates the magnetic field vector at the specified space point.
double m_igridPitch[3]
The inverted grid pitch in r,phi,z.
void setMapRegionR(double minR, double maxR)
Sets the size of the magnetic field map.
void setMapFilename(const std::string &filename)
Sets the filename of the magnetic field map.
bool m_exRegion
Flag to indicate whether there is a region to exclude.
std::vector< ROOT::Math::XYZVector > m_bmap
The memory buffer for the magnetic field map.
void enableCoordinate(const std::string &mapEnable="rphiz")
Option to reduce 3D to 2D map (in coordinates, NOT Br, Bphi, Bz components)
void setMapSize(int sizeR, int sizePhi, int sizeZ)
Sets the size of the magnetic field map.
double m_mapRegionR[2]
The min and max boundaries of the map region in r.
double m_exRegionZ[2]
The min and max boundaries of the excluded region in z.
void setExcludeRegionR(double minR, double maxR)
Sets the size of the magnetic field map to exclude.
void setGridPitch(double pitchR, double pitchPhi, double pitchZ)
Sets the grid pitch of the magnetic field map.
void setMapRegionZ(double minZ, double maxZ, double offset)
Sets the size of the magnetic field map.
double m_errB[3]
The error Br, Bphi, Bz as a scale factor (B_new = m_errB * B_old).
std::string m_mapEnable
Enable different dimension, "rphiz", "rphi", "phiz" or "rz" >
BFieldComponent3d()=default
The BFieldComponent3d constructor.
virtual ~BFieldComponent3d()=default
The BFieldComponent3d destructor.
bool m_mirrorPhi
Flag to indicate whether there is a region to exclude.
void doInterpolation(bool interpolate=true)
void mirrorPhi(bool mirrorPhi=0.)
The BFieldComponentAbs class.
Abstract base class for different kinds of events.