From e6b815b157ef44e16176c2dc0d869390657467bd Mon Sep 17 00:00:00 2001 From: Javier Galan Date: Fri, 3 May 2024 15:10:29 +0200 Subject: [PATCH] TRestAxionMagneticField. Major oversight on data not passed by reference --- inc/TRestAxionMagneticField.h | 2 +- src/TRestAxionMagneticField.cxx | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/inc/TRestAxionMagneticField.h b/inc/TRestAxionMagneticField.h index b56720dc..b2dd1e54 100644 --- a/inc/TRestAxionMagneticField.h +++ b/inc/TRestAxionMagneticField.h @@ -95,7 +95,7 @@ class TRestAxionMagneticField : public TRestMetadata { void LoadMagneticFieldData(MagneticFieldVolume& mVol, std::vector> data); - TVector3 GetMagneticVolumeNode(MagneticFieldVolume mVol, TVector3 pos); + TVector3 GetMagneticVolumeNode(size_t id, TVector3 pos); /// \brief This private method returns true if the magnetic field volumes loaded are the same as /// the volumes defined. diff --git a/src/TRestAxionMagneticField.cxx b/src/TRestAxionMagneticField.cxx index 459571e0..4f15d0f4 100644 --- a/src/TRestAxionMagneticField.cxx +++ b/src/TRestAxionMagneticField.cxx @@ -1025,7 +1025,7 @@ TVector3 TRestAxionMagneticField::GetMagneticField(TVector3 pos, Bool_t showWarn return TVector3(0, 0, 0); } else { if (IsFieldConstant(id)) return fConstantField[id]; - TVector3 node = GetMagneticVolumeNode(fMagneticFieldVolumes[id], pos); + TVector3 node = GetMagneticVolumeNode((size_t)id, pos); Int_t nX = node.X(); Int_t nY = node.Y(); Int_t nZ = node.Z(); @@ -1430,10 +1430,10 @@ TVector3 TRestAxionMagneticField::GetFieldAverageTransverseVector(TVector3 from, /// /// This method will be made private, no reason to use it outside this class. /// -TVector3 TRestAxionMagneticField::GetMagneticVolumeNode(MagneticFieldVolume mVol, TVector3 pos) { - Int_t nx = mVol.mesh.GetNodeX(pos.X()); - Int_t ny = mVol.mesh.GetNodeY(pos.Y()); - Int_t nz = mVol.mesh.GetNodeZ(pos.Z()); +TVector3 TRestAxionMagneticField::GetMagneticVolumeNode(size_t id, TVector3 pos) { + Int_t nx = fMagneticFieldVolumes[id].mesh.GetNodeX(pos.X()); + Int_t ny = fMagneticFieldVolumes[id].mesh.GetNodeY(pos.Y()); + Int_t nz = fMagneticFieldVolumes[id].mesh.GetNodeZ(pos.Z()); return TVector3(nx, ny, nz); }