From e7327f0cc1b2d82d619167d4d0e559557b17005d Mon Sep 17 00:00:00 2001
From: Maximilian Reininghaus <maximilian.reininghaus@kit.edu>
Date: Wed, 15 Mar 2023 19:34:54 +0100
Subject: [PATCH] call code conversion after isValid when it's guaranteed to
 not throw

---
 corsika/detail/modules/fluka/InteractionModel.inl | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/corsika/detail/modules/fluka/InteractionModel.inl b/corsika/detail/modules/fluka/InteractionModel.inl
index 801d8ff4b..eb3f2473b 100644
--- a/corsika/detail/modules/fluka/InteractionModel.inl
+++ b/corsika/detail/modules/fluka/InteractionModel.inl
@@ -50,7 +50,6 @@ namespace corsika::fluka {
                                         HEPEnergyType /*sqrtS*/) const {
     if (!fluka::canInteract(projectileID)) {
       // invalid projectile
-      //~ std::cout << "invalid projecile (cannot interact)";
       return false;
     }
 
@@ -81,8 +80,6 @@ namespace corsika::fluka {
   inline CrossSectionType InteractionModel::getCrossSection(
       Code const projectileId, Code const targetId, FourMomentum const& projectileP4,
       FourMomentum const& targetP4) const {
-    auto const flukaCodeProj =
-        static_cast<FLUKACodeIntType>(convertToFluka(projectileId));
     auto const flukaMaterial = getMaterialIndex(targetId);
 
     HEPEnergyType const sqrtS = (projectileP4 + targetP4).getNorm();
@@ -98,6 +95,8 @@ namespace corsika::fluka {
     auto const plab = projectileLab4mom.getSpaceLikeComponents();
 
     CORSIKA_LOGGER_DEBUG(logger_, fmt::format("Elab = {} GeV", Elab * invGeV));
+    auto const flukaCodeProj =
+        static_cast<FLUKACodeIntType>(convertToFluka(projectileId));
 
     double const dummyEkin = 0;
     CrossSectionType const xs = ::fluka::sgmxyz_(&flukaCodeProj, &flukaMaterial,
-- 
GitLab