Belle II Software  release-05-01-25
MagneticFieldComponent3D.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2017 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Martin Ritter *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #pragma once
12 
13 #include <framework/dbobjects/MagneticFieldComponent.h>
14 
15 namespace Belle2 {
21  class MagneticFieldComponent3D final: public MagneticFieldComponent {
22  public:
26  MagneticFieldComponent3D(double minR, double maxR, double minZ, double maxZ,
27  int nR, int nPhi, int nZ,
28  std::vector<B2Vector3F>&& fieldmap):
29  MagneticFieldComponent(true), m_minR(minR), m_maxR(maxR), m_minZ(minZ), m_maxZ(maxZ), m_mapSize{nR, nPhi, nZ},
30  m_gridPitch{static_cast<float>((maxR - minR) / (nR - 1)), static_cast<float>(M_PI / (nPhi - 1)), static_cast<float>((maxZ - minZ) / (nZ - 1))},
31  m_invgridPitch{static_cast<float>(1. / m_gridPitch[0]), static_cast<float>(1. / m_gridPitch[1]), static_cast<float>(1. / m_gridPitch[2])},
32  m_bmap(fieldmap)
33  {}
34 
36  bool inside(const B2Vector3D& pos) const override
37  {
38  const float z = pos.Z();
39  if (z < m_minZ || z > m_maxZ) return false;
40  const float r = pos.Perp();
41  return (r >= m_minR && r <= m_maxR);
42  }
44  B2Vector3D getField(const B2Vector3D& pos) const override;
45  private:
54  B2Vector3D interpolate(unsigned int ir, unsigned int iphi, unsigned int iz, double wr, double wphi, double wz) const;
56  float m_minR{0};
58  float m_maxR{0};
60  float m_minZ{0};
62  float m_maxZ{0};
64  int m_mapSize[3] {0};
66  float m_gridPitch[3] {0};
68  float m_invgridPitch[3] {0};
70  std::vector<B2Vector3F> m_bmap;
73  };
75 }; // Belle2 namespace
Belle2::MagneticFieldComponent3D::m_maxR
float m_maxR
maximal R=sqrt(x^2+y^2) for which this field is present
Definition: MagneticFieldComponent3D.h:66
Belle2::MagneticFieldComponent3D::m_gridPitch
float m_gridPitch[3]
grid pitch in r, phi and z
Definition: MagneticFieldComponent3D.h:74
Belle2::MagneticFieldComponent3D::ClassDefOverride
ClassDefOverride(MagneticFieldComponent3D, 1)
ROOT dictionary.
Belle2::MagneticFieldComponent3D::interpolate
B2Vector3D interpolate(unsigned int ir, unsigned int iphi, unsigned int iz, double wr, double wphi, double wz) const
Linear interpolate the magnetic field inside a bin.
Definition: MagneticFieldComponent3D.cc:145
Belle2::MagneticFieldComponent3D::MagneticFieldComponent3D
MagneticFieldComponent3D()
empty constructor for ROOT
Definition: MagneticFieldComponent3D.h:32
Belle2::MagneticFieldComponent3D::m_maxZ
float m_maxZ
maximal Z for which this field is present
Definition: MagneticFieldComponent3D.h:70
Belle2::MagneticFieldComponent3D::getField
B2Vector3D getField(const B2Vector3D &pos) const override
return the field assuming we are inside the active region as returned by inside()
Definition: MagneticFieldComponent3D.cc:91
Belle2::MagneticFieldComponent3D::m_invgridPitch
float m_invgridPitch[3]
inverted grid pitch in r, phi and z
Definition: MagneticFieldComponent3D.h:76
Belle2::MagneticFieldComponent3D::m_bmap
std::vector< B2Vector3F > m_bmap
magnetic field strength
Definition: MagneticFieldComponent3D.h:78
Belle2::MagneticFieldComponent3D::m_minZ
float m_minZ
minimal Z for which this field is present
Definition: MagneticFieldComponent3D.h:68
Belle2::B2Vector3< double >
Belle2::MagneticFieldComponent3D::m_minR
float m_minR
minimal R=sqrt(x^2+y^2) for which this field is present
Definition: MagneticFieldComponent3D.h:64
Belle2::MagneticFieldComponent3D::inside
bool inside(const B2Vector3D &pos) const override
return whether we are inside the active region for this component
Definition: MagneticFieldComponent3D.h:44
Belle2::MagneticFieldComponent3D::m_mapSize
int m_mapSize[3]
number of bins in r, phi and z
Definition: MagneticFieldComponent3D.h:72
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::MagneticFieldComponent3D
Describe one component of the Geometry.
Definition: MagneticFieldComponent3D.h:29
Belle2::MagneticFieldComponent
Abstract base class for BField components.
Definition: MagneticFieldComponent.h:38
Belle2::MagneticFieldComponent::MagneticFieldComponent
MagneticFieldComponent(bool exclusive)
Constructor.
Definition: MagneticFieldComponent.h:44