Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /juggler/JugTrack/src/components/DD4hepBField.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

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 #if Acts_VERSION_MAJOR < 39
0023   Acts::Result<Acts::Vector3> DD4hepBField::getFieldGradient(const Acts::Vector3& position,
0024                                                              Acts::ActsMatrix<3, 3>& /*derivative*/,
0025                                                              Acts::MagneticFieldProvider::Cache& cache) const
0026   {
0027     return this->getField(position, cache);
0028   }
0029 #endif
0030 
0031 } // namespace Jug::BField