LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
GlobalMagneticField.cxx
Go to the documentation of this file.
1 //
2 // G4 interface for full magnetic field.
3 //
4 //
5 // Original author Eldwan Brianne
6 //
7 
8 // C++ includes
9 #include <iostream>
10 
12 
13 // nug4 includes.
16 
18 
19 // CLHEP includes
20 #include "CLHEP/Units/SystemOfUnits.h"
21 #include "CLHEP/Vector/ThreeVector.h"
22 
23 using CLHEP::Hep3Vector;
24 using namespace std;
25 
26 namespace mag {
27 
28  GlobalMagneticField::GlobalMagneticField()
29  {
31  _bFieldHandle = &*bField;
32  }
33 
34  // This is the entry point called by G4.
35  void GlobalMagneticField::GetFieldValue(const G4double Point[4], G4double *Bfield) const {
36 
37  //Check provider units (geant4 uses mm, your framework can use another unit...)
38  const auto *pProvider = _bFieldHandle->provider();
39 
40  G4ThreeVector point(Point[0], Point[1], Point[2]);//should be in mm
41  const G4ThreeVector field = pProvider->FieldAtPoint(point);//should return tesla
42 
43  Bfield[0] = field.x();
44  Bfield[1] = field.y();
45  Bfield[2] = field.z();
46 
47  // std::cout << "Returned field " << Bfield[0] << ", " << Bfield[1] << ", " << Bfield[2] << std::endl;
48 
49  return;
50  }
51 
52 } // end namespace mag
STL namespace.
virtual const mag::MagneticField * provider() const =0
std::tuple< double, double, const reco::ClusterHit3D * > Point
Definitions used by the VoronoiDiagram algorithm.
Definition: DCEL.h:42