From 61cd7c65333db4bfcb030719c2d40a4fcd8eadae Mon Sep 17 00:00:00 2001
From: ralfulrich <ralf.ulrich@kit.edu>
Date: Thu, 18 Feb 2021 22:07:29 +0100
Subject: [PATCH] final small fixed and style

---
 corsika/detail/modules/LongitudinalProfile.inl    |  8 +++++---
 .../detail/modules/proposal/ContinuousProcess.inl | 15 ++++++++-------
 .../modules/tracking/TrackingLeapFrogCurved.inl   |  4 ++--
 corsika/framework/core/ParticleProperties.hpp     | 14 ++++++++------
 corsika/setup/SetupTrajectory.hpp                 |  4 ++--
 examples/vertical_EAS.cpp                         | 14 +++++++-------
 tests/modules/testParticleCut.cpp                 |  7 +++++--
 7 files changed, 37 insertions(+), 29 deletions(-)

diff --git a/corsika/detail/modules/LongitudinalProfile.inl b/corsika/detail/modules/LongitudinalProfile.inl
index 2a9327cea..0a2ec2e77 100644
--- a/corsika/detail/modules/LongitudinalProfile.inl
+++ b/corsika/detail/modules/LongitudinalProfile.inl
@@ -35,9 +35,11 @@ namespace corsika {
     GrammageType const grammageStart = shower_axis_.getProjectedX(vTrack.getPosition(0));
     GrammageType const grammageEnd = shower_axis_.getProjectedX(vTrack.getPosition(1));
 
-    CORSIKA_LOG_INFO(
-        "pos1={} m, pos2={}, X1={} g/cm2, X2={} g/cm2", vTrack.getPosition(0).getCoordinates() / 1_m,
-        vTrack.getPosition(1).getCoordinates() / 1_m, grammageStart / 1_g * square(1_cm), grammageEnd / 1_g * square(1_cm));
+    CORSIKA_LOG_INFO("pos1={} m, pos2={}, X1={} g/cm2, X2={} g/cm2",
+                     vTrack.getPosition(0).getCoordinates() / 1_m,
+                     vTrack.getPosition(1).getCoordinates() / 1_m,
+                     grammageStart / 1_g * square(1_cm),
+                     grammageEnd / 1_g * square(1_cm));
 
     // Note: particle may go also "upward", thus, grammageEnd<grammageStart
     const int binStart = std::ceil(grammageStart / dX_);
diff --git a/corsika/detail/modules/proposal/ContinuousProcess.inl b/corsika/detail/modules/proposal/ContinuousProcess.inl
index f43265fd1..0e230a762 100644
--- a/corsika/detail/modules/proposal/ContinuousProcess.inl
+++ b/corsika/detail/modules/proposal/ContinuousProcess.inl
@@ -125,13 +125,14 @@ namespace corsika::proposal {
     // hyper parameter which must be adjusted.
     //
     auto const energy = vP.getEnergy();
-    auto const energy_lim =
-        std::max(energy * 0.9, // either 10% relative loss max., or
-                 get_energy_threshold(
-                     code) // energy thresholds globally defined for individual particles
-		 * 0.99 // need to go 1% below global e-cut to assure removal in ParticleCut. The
-		        // 1% does not matter since at cut-time the entire energy is removed.
-        );
+    auto const energy_lim = std::max(
+        energy * 0.9, // either 10% relative loss max., or
+        get_energy_threshold(
+            code) // energy thresholds globally defined for individual particles
+            *
+            0.99 // need to go 1% below global e-cut to assure removal in ParticleCut. The
+                 // 1% does not matter since at cut-time the entire energy is removed.
+    );
 
     // solving the track integral for giving energy lim
     auto c = getCalculator(vP, calc);
diff --git a/corsika/detail/modules/tracking/TrackingLeapFrogCurved.inl b/corsika/detail/modules/tracking/TrackingLeapFrogCurved.inl
index 415c1ada3..ee18af1fb 100644
--- a/corsika/detail/modules/tracking/TrackingLeapFrogCurved.inl
+++ b/corsika/detail/modules/tracking/TrackingLeapFrogCurved.inl
@@ -176,7 +176,7 @@ namespace corsika {
           CORSIKA_LOG_TRACE("Solution (real) for current Volume: {} ", dist);
           if (numericallyInside) {
             // there must be an entry (negative) and exit (positive) solution
-            if (dist < 0.0001_m) { // security margin to assure transfer to next
+            if (dist < -0.0001_m) { // security margin to assure transfer to next
                                    // logical volume
               if (first_entry == 0) {
                 d_enter = dist;
@@ -200,7 +200,7 @@ namespace corsika {
 
             // both physical solutions (entry, exit) must be positive, and as small as
             // possible
-            if (dist < 0.0001_m) { // need small numerical margin, to assure transport
+            if (dist < -0.0001_m) { // need small numerical margin, to assure transport
               // into next logical volume
               continue;
             }
diff --git a/corsika/framework/core/ParticleProperties.hpp b/corsika/framework/core/ParticleProperties.hpp
index 549884b39..e133d6867 100644
--- a/corsika/framework/core/ParticleProperties.hpp
+++ b/corsika/framework/core/ParticleProperties.hpp
@@ -73,12 +73,14 @@ namespace corsika {
 
   //! true iff the particle is a hard-coded nucleus or Code::Nucleus
   bool constexpr is_nucleus(Code const);
-  bool constexpr is_hadron(Code const);    //!< true iff particle is hadron
-  bool constexpr is_em(Code const);        //!< true iff particle is electron, positron or gamma
-  bool constexpr is_muon(Code const);      //!< true iff particle is mu+ or mu-
-  bool constexpr is_neutrino(Code const);  //!< true iff particle is (anti-) neutrino
-  int constexpr get_nucleus_A(Code const); //!< returns A for hard-coded nucleus, otherwise 0
-  int constexpr get_nucleus_Z(Code const); //!< returns Z for hard-coded nucleus, otherwise 0
+  bool constexpr is_hadron(Code const); //!< true iff particle is hadron
+  bool constexpr is_em(Code const); //!< true iff particle is electron, positron or gamma
+  bool constexpr is_muon(Code const);     //!< true iff particle is mu+ or mu-
+  bool constexpr is_neutrino(Code const); //!< true iff particle is (anti-) neutrino
+  int constexpr get_nucleus_A(
+      Code const); //!< returns A for hard-coded nucleus, otherwise 0
+  int constexpr get_nucleus_Z(
+      Code const); //!< returns Z for hard-coded nucleus, otherwise 0
 
   //! returns mass of (A,Z) nucleus, disregarding binding energy
   HEPMassType get_nucleus_mass(unsigned int const, unsigned int const);
diff --git a/corsika/setup/SetupTrajectory.hpp b/corsika/setup/SetupTrajectory.hpp
index 24a51f79c..c40351d26 100644
--- a/corsika/setup/SetupTrajectory.hpp
+++ b/corsika/setup/SetupTrajectory.hpp
@@ -38,7 +38,7 @@ namespace corsika::setup {
      The default tracking algorithm.
    */
 
-  //typedef corsika::tracking_leapfrog_curved::Tracking Tracking;
+  // typedef corsika::tracking_leapfrog_curved::Tracking Tracking;
   // typedef corsika::tracking_leapfrog_straight::Tracking Tracking;
   typedef corsika::tracking_line::Tracking Tracking;
 
@@ -47,6 +47,6 @@ namespace corsika::setup {
   */
   /// definition of Trajectory base class, to be used in tracking and cascades
   typedef StraightTrajectory Trajectory;
-  //typedef corsika::LeapFrogTrajectory Trajectory;
+  // typedef corsika::LeapFrogTrajectory Trajectory;
 
 } // namespace corsika::setup
diff --git a/examples/vertical_EAS.cpp b/examples/vertical_EAS.cpp
index 14edc194a..56bf78c3d 100644
--- a/examples/vertical_EAS.cpp
+++ b/examples/vertical_EAS.cpp
@@ -131,7 +131,7 @@ int main(int argc, char** argv) {
   builder.addExponentialLayer(1144.9069_g / (1_cm * 1_cm), 878153.55_cm, 10_km);
   builder.addExponentialLayer(1305.5948_g / (1_cm * 1_cm), 636143.04_cm, 40_km);
   builder.addExponentialLayer(540.1778_g / (1_cm * 1_cm), 772170.16_cm, 100_km);
-  builder.addLinearLayer(1e9_cm, 112.8_km+constants::EarthRadius::Mean);
+  builder.addLinearLayer(1e9_cm, 112.8_km + constants::EarthRadius::Mean);
   builder.assemble(env);
 
   CORSIKA_LOG_DEBUG(
@@ -157,7 +157,7 @@ int main(int argc, char** argv) {
   Code beamCode;
   HEPEnergyType mass;
   unsigned short Z = 0;
-  if (A>0) {
+  if (A > 0) {
     beamCode = Code::Nucleus;
     Z = std::stoi(std::string(argv[2]));
     mass = get_nucleus_mass(A, Z);
@@ -200,14 +200,14 @@ int main(int argc, char** argv) {
     stack.addParticle(std::make_tuple(beamCode, E0, plab, injectionPos, 0_ns, A, Z));
 
   } else {
-    if (A==1) {
+    if (A == 1) {
       if (Z == 1) {
-	stack.addParticle(std::make_tuple(Code::Proton, E0, plab, injectionPos, 0_ns));
+        stack.addParticle(std::make_tuple(Code::Proton, E0, plab, injectionPos, 0_ns));
       } else if (Z == 0) {
-	stack.addParticle(std::make_tuple(Code::Neutron, E0, plab, injectionPos, 0_ns));
+        stack.addParticle(std::make_tuple(Code::Neutron, E0, plab, injectionPos, 0_ns));
       } else {
-	std::cerr << "illegal parameters" << std::endl;
-	return EXIT_FAILURE;
+        std::cerr << "illegal parameters" << std::endl;
+        return EXIT_FAILURE;
       }
     } else {
       stack.addParticle(std::make_tuple(beamCode, E0, plab, injectionPos, 0_ns));
diff --git a/tests/modules/testParticleCut.cpp b/tests/modules/testParticleCut.cpp
index ef12f58e8..1bc67084b 100644
--- a/tests/modules/testParticleCut.cpp
+++ b/tests/modules/testParticleCut.cpp
@@ -23,7 +23,7 @@
 
 using namespace corsika;
 
-TEST_CASE("ParticleCut", "[processes]") {
+TEST_CASE("ParticleCut", "processes") {
 
   logging::set_level(logging::level::info);
   corsika_logger->set_pattern("[%n:%^%-8l%$] %v");
@@ -222,7 +222,10 @@ TEST_CASE("ParticleCut", "[processes]") {
     for (auto proType : particleList) {
       auto particle = stack.addParticle(std::make_tuple(
           proType, Eabove, MomentumVector(rootCS, {0_GeV, 0_GeV, 0_GeV}), point0, 0_ns));
-      cut.doContinuous(particle, track);
+
+      if (cut.doContinuous(particle, track) == ProcessReturn::ParticleAbsorbed) {
+        particle.erase();
+      }
     }
 
     CHECK(stack.getEntries() == 9);
-- 
GitLab