diff options
Diffstat (limited to 'src/main/Quadrupole.cc')
-rw-r--r-- | src/main/Quadrupole.cc | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/main/Quadrupole.cc b/src/main/Quadrupole.cc index 9b1c3e9..911ae18 100644 --- a/src/main/Quadrupole.cc +++ b/src/main/Quadrupole.cc @@ -23,7 +23,10 @@ Vector3D Quadrupole::magneticFieldAt(const Vector3D& position) const { Vector3D d = getDiagonal().unit(); Vector3D y = x - x.dot(d) * d; Vector3D u = Vector3D::k.cross(d); - return focalizingCoefficient * (y.dot(u) * Vector3D::k + position.getZ() * u); + if ((x.dot(d) >= 0) && ((position - getExitPosition()).dot(-d) >= 0)) + return focalizingCoefficient * (y.dot(u) * Vector3D::k + position.getZ() * u); + else + return Vector3D::Null; } double Quadrupole::getFocalizingCoefficient() const { |