00001 #include "TrkExtAlg/ExtBesMagneticField.h"
00002
00003 #include "GaudiKernel/AlgFactory.h"
00004 #include "GaudiKernel/MsgStream.h"
00005 #include "GaudiKernel/SvcFactory.h"
00006 #include "GaudiKernel/ISvcLocator.h"
00007 #include "GaudiKernel/SmartDataPtr.h"
00008 #include "GaudiKernel/Bootstrap.h"
00009
00010 #include "G4FieldManager.hh"
00011 #include "G4MagneticField.hh"
00012 #include "globals.hh"
00013
00014 #include "CLHEP/Geometry/Vector3D.h"
00015 #include "CLHEP/Geometry/Point3D.h"
00016 #include "CLHEP/Units/PhysicalConstants.h"
00017
00018 #ifndef ENABLE_BACKWARDS_COMPATIBILITY
00019 typedef HepGeom::Point3D<double> HepPoint3D;
00020 #endif
00021 #ifndef ENABLE_BACKWARDS_COMPATIBILITY
00022 typedef HepGeom::Vector3D<double> HepVector3D;
00023 #endif
00024
00025
00026 using namespace CLHEP;
00027
00028 ExtBesMagneticField::ExtBesMagneticField()
00029 {
00030 GetFieldManager()->SetDetectorField(this);
00031 GetFieldManager()->CreateChordFinder(this);
00032
00033
00034 ISvcLocator* svcLocator = Gaudi::svcLocator();
00035 StatusCode sc = svcLocator->service("MagneticFieldSvc",m_pIMF);
00036 if(sc!=StatusCode::SUCCESS) {
00037 G4cout<< "Unable to open Magnetic field service"<<G4endl;
00038 }
00039 }
00040
00041
00042 ExtBesMagneticField::~ExtBesMagneticField(){}
00043
00044
00045 void ExtBesMagneticField::GetFieldValue(const double Point[3],double *Bfield) const
00046 {
00047 double x=Point[0];
00048 double y=Point[1];
00049 double z=Point[2];
00050
00051 HepPoint3D r(x,y,z);
00052 HepVector3D b;
00053
00054 if(m_pIMF->ifRealField() == true)
00055 m_pIMF->fieldVector(r,b);
00056 else
00057 m_pIMF->uniFieldVector(r,b);
00058
00059 Bfield[0]=b.x();
00060 Bfield[1]=b.y();
00061 Bfield[2]=b.z();
00062 }
00063
00064 #include "G4TransportationManager.hh"
00065
00066 G4FieldManager* ExtBesMagneticField::GetFieldManager()
00067 {
00068 return G4TransportationManager::GetTransportationManager()->GetFieldManager();
00069 }
00070