Belle II Software  release-05-01-25
MagneticField.cc
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, Guofu Cao *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #include <simulation/kernel/MagneticField.h>
12 #include <framework/geometry/BFieldManager.h>
13 
14 #include <framework/gearbox/Unit.h>
15 
16 #include <CLHEP/Units/SystemOfUnits.h>
17 
18 #include <globals.hh>
19 
20 namespace Belle2 {
25  namespace Simulation {
26 
27  MagneticField::MagneticField(): G4MagneticField()
28  {
29  }
30 
32  {
33  }
34 
35  void MagneticField::GetFieldValue(const G4double Point[3], G4double* Bfield) const
36  {
37  static const double pos_conversion{Unit::mm / CLHEP::mm};
38  static const double mag_conversion{CLHEP::tesla / Unit::T};
39  //Get the magnetic field vector from the central magnetic field map (Geant4 uses [mm] as a length unit)
40  const B2Vector3D point = B2Vector3D{Point} * pos_conversion;
41  // get the field in Geant4 units
42  B2Vector3D magField = BFieldManager::getField(point) * mag_conversion;
43  // and set it
44  magField.GetXYZ(Bfield);
45  }
46 
47  }
49 }
Belle2::BFieldManager::getField
static void getField(const double *pos, double *field)
return the magnetic field at a given position.
Definition: BFieldManager.h:110
Belle2::B2Vector3::GetXYZ
void GetXYZ(Double_t *carray) const
directly copies coordinates to an array of double
Belle2::Simulation::MagneticField::GetFieldValue
void GetFieldValue(const G4double Point[3], G4double *Bfield) const
Sets the magnetic field vector for a specified space point.
Definition: MagneticField.cc:43
Belle2::B2Vector3< double >
Belle2::Unit::T
static const double T
[tesla]
Definition: Unit.h:130
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::Simulation::MagneticField::~MagneticField
~MagneticField()
Destructor.
Definition: MagneticField.cc:39
Belle2::Unit::mm
static const double mm
[millimeters]
Definition: Unit.h:80
Belle2::Simulation::MagneticField::MagneticField
MagneticField()
Constructor.
Definition: MagneticField.cc:35