Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-09-28 07:03:49

0001 // SPDX-License-Identifier: LGPL-3.0-or-later
0002 // Copyright (C) 2022 Whitney Armstrong, Wouter Deconinck
0003 
0004 #include "JugTrack/DD4hepBField.h"
0005 
0006 #include <cmath>
0007 #include "Acts/Definitions/Units.hpp"
0008 #include "Acts/Definitions/Algebra.hpp"
0009 #include "DD4hep/DD4hepUnits.h"
0010 #include "DD4hep/Objects.h"
0011 
0012 namespace Jug::BField {
0013 
0014   Acts::Result<Acts::Vector3> DD4hepBField::getField(const Acts::Vector3& position,
0015                                                      Acts::MagneticFieldProvider::Cache& /*cache*/) const
0016   {
0017     dd4hep::Position pos(position[0]/10.0,position[1]/10.0,position[2]/10.0);
0018     auto field = m_det->field().magneticField(pos) * (Acts::UnitConstants::T / dd4hep::tesla); 
0019     return Acts::Result<Acts::Vector3>::success({field.x(), field.y(),field.z()});
0020   }
0021 
0022   Acts::Result<Acts::Vector3> DD4hepBField::getFieldGradient(const Acts::Vector3& position,
0023                                                              Acts::ActsMatrix<3, 3>& /*derivative*/,
0024                                                              Acts::MagneticFieldProvider::Cache& cache) const
0025   {
0026     return this->getField(position, cache);
0027   }
0028 } // namespace Jug::BField