From 138fefe935cc8e5cc717f20f8df5e3a7565e66a6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A9=20Schmidt?= <upwli@student.kit.edu>
Date: Tue, 14 Jul 2020 11:39:29 +0200
Subject: [PATCH] magMaxLength is not a decay

---
 Framework/Cascade/Cascade.h | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/Framework/Cascade/Cascade.h b/Framework/Cascade/Cascade.h
index 3a6df6da4..ac1169c69 100644
--- a/Framework/Cascade/Cascade.h
+++ b/Framework/Cascade/Cascade.h
@@ -230,8 +230,7 @@ namespace corsika::cascade {
         auto magneticfield = corsika::geometry::Vector(fEnvironment.GetCoordinateSystem(),
                                                        0_uT, 50_uT, 0_uT);
         geometry::Vector<SpeedType::dimension_type> const velocityVerticalMag =
-            velocity - magneticfield * velocity.dot(magneticfield) /
-                           (magneticfield.GetSquaredNorm());
+            velocity - velocity.parallelProjectionOnto(magneticfield);
         LengthType const gyroradius =
             vParticle.GetEnergy() * velocityVerticalMag.GetNorm() * 1_V /
             (corsika::units::constants::cSquared * abs(chargeNumber) *
@@ -308,7 +307,7 @@ namespace corsika::cascade {
 
         TStackView secondaries(vParticle);
 
-        if (min_distance != distance_max) {
+        if (min_distance != distance_max && min_distance != magMaxLength) {
           /*
             Create SecondaryView object on Stack. The data container
             remains untouched and identical, and 'projectil' is identical
-- 
GitLab