From 8105f130acada86e280688a38d88e8972e6aab06 Mon Sep 17 00:00:00 2001
From: ralfulrich <ralf.ulrich@kit.edu>
Date: Fri, 23 Oct 2020 10:55:11 +0200
Subject: [PATCH] improve test a bit

---
 Processes/ParticleCut/testParticleCut.cc | 92 ++++++++++++++++--------
 1 file changed, 63 insertions(+), 29 deletions(-)

diff --git a/Processes/ParticleCut/testParticleCut.cc b/Processes/ParticleCut/testParticleCut.cc
index 2092636fa..921eecc3e 100644
--- a/Processes/ParticleCut/testParticleCut.cc
+++ b/Processes/ParticleCut/testParticleCut.cc
@@ -37,15 +37,16 @@ TEST_CASE("ParticleCut", "[processes]") {
   const HEPEnergyType Eabove = 1_TeV;
   const HEPEnergyType Ebelow = 10_GeV;
   // list of arbitrary particles
-  std::vector<particles::Code> particleList = {
+  const std::vector<particles::Code> particleList = {
       particles::Code::PiPlus,   particles::Code::PiMinus, particles::Code::KPlus,
       particles::Code::KMinus,   particles::Code::K0Long,  particles::Code::K0Short,
       particles::Code::Electron, particles::Code::MuPlus,  particles::Code::NuE,
-      particles::Code::Neutron};
+      particles::Code::Neutron,  particles::Code::NuMu};
 
   SECTION("cut on particle type: inv") {
 
     ParticleCut cut(20_GeV, false, true);
+    CHECK(cut.GetECut() == 20_GeV);
 
     // add primary particle to stack
     auto particle = stack.AddParticle(
@@ -62,15 +63,15 @@ TEST_CASE("ParticleCut", "[processes]") {
     // add secondaries, all with energies above the threshold
     // only cut is by species
     for (auto proType : particleList)
-      projectile.AddSecondary(std::tuple<particles::Code, units::si::HEPEnergyType,
-                                         corsika::stack::MomentumVector, geometry::Point,
-                                         units::si::TimeType>{
+      projectile.AddSecondary(std::make_tuple(
           proType, Eabove, corsika::stack::MomentumVector(rootCS, {0_GeV, 0_GeV, 0_GeV}),
-          geometry::Point(rootCS, 0_m, 0_m, 0_m), 0_ns});
+          geometry::Point(rootCS, 0_m, 0_m, 0_m), 0_ns));
 
     cut.DoSecondaries(view);
 
     CHECK(view.getEntries() == 9);
+    CHECK(cut.GetNumberInvParticles() == 2);
+    CHECK(cut.GetInvEnergy() / 1_GeV == 2000);
   }
 
   SECTION("cut on particle type: em") {
@@ -79,11 +80,9 @@ TEST_CASE("ParticleCut", "[processes]") {
 
     // add primary particle to stack
     auto particle = stack.AddParticle(
-        std::tuple<particles::Code, units::si::HEPEnergyType,
-                   corsika::stack::MomentumVector, geometry::Point, units::si::TimeType>{
-            particles::Code::Proton, Eabove,
-            corsika::stack::MomentumVector(rootCS, {0_GeV, 0_GeV, 0_GeV}),
-            geometry::Point(rootCS, 0_m, 0_m, 0_m), 0_ns});
+        std::make_tuple(particles::Code::Proton, Eabove,
+                        corsika::stack::MomentumVector(rootCS, {0_GeV, 0_GeV, 0_GeV}),
+                        geometry::Point(rootCS, 0_m, 0_m, 0_m), 0_ns));
     // view on secondary particles
     corsika::setup::StackView view(particle);
     // ref. to primary particle through the secondary view.
@@ -91,16 +90,16 @@ TEST_CASE("ParticleCut", "[processes]") {
     auto projectile = view.GetProjectile();
     // add secondaries, all with energies above the threshold
     // only cut is by species
-    for (auto proType : particleList)
-      projectile.AddSecondary(std::tuple<particles::Code, units::si::HEPEnergyType,
-                                         corsika::stack::MomentumVector, geometry::Point,
-                                         units::si::TimeType>{
+    for (auto proType : particleList) {
+      projectile.AddSecondary(std::make_tuple(
           proType, Eabove, corsika::stack::MomentumVector(rootCS, {0_GeV, 0_GeV, 0_GeV}),
-          geometry::Point(rootCS, 0_m, 0_m, 0_m), 0_ns});
-
+          geometry::Point(rootCS, 0_m, 0_m, 0_m), 0_ns));
+    }
     cut.DoSecondaries(view);
 
-    CHECK(view.getEntries() == 9);
+    CHECK(view.getEntries() == 10);
+    CHECK(cut.GetNumberEmParticles() == 1);
+    CHECK(cut.GetEmEnergy() / 1_GeV == 1000);
   }
 
   SECTION("cut low energy") {
@@ -108,11 +107,9 @@ TEST_CASE("ParticleCut", "[processes]") {
 
     // add primary particle to stack
     auto particle = stack.AddParticle(
-        std::tuple<particles::Code, units::si::HEPEnergyType,
-                   corsika::stack::MomentumVector, geometry::Point, units::si::TimeType>{
-            particles::Code::Proton, Eabove,
-            corsika::stack::MomentumVector(rootCS, {0_GeV, 0_GeV, 0_GeV}),
-            geometry::Point(rootCS, 0_m, 0_m, 0_m), 0_ns});
+        std::make_tuple(particles::Code::Proton, Eabove,
+                        corsika::stack::MomentumVector(rootCS, {0_GeV, 0_GeV, 0_GeV}),
+                        geometry::Point(rootCS, 0_m, 0_m, 0_m), 0_ns));
     // view on secondary particles
     setup::StackView view{particle};
     // ref. to primary particle through the secondary view.
@@ -121,15 +118,52 @@ TEST_CASE("ParticleCut", "[processes]") {
     // add secondaries, all with energies below the threshold
     // only cut is by species
     for (auto proType : particleList)
-      projectile.AddSecondary(std::tuple<particles::Code, units::si::HEPEnergyType,
-                                         corsika::stack::MomentumVector, geometry::Point,
-                                         units::si::TimeType>{
+      projectile.AddSecondary(std::make_tuple(
           proType, Ebelow, corsika::stack::MomentumVector(rootCS, {0_GeV, 0_GeV, 0_GeV}),
-          geometry::Point(rootCS, 0_m, 0_m, 0_m), 0_ns});
+          geometry::Point(rootCS, 0_m, 0_m, 0_m), 0_ns));
+    unsigned short A = 18;
+    unsigned short Z = 8;
+    projectile.AddSecondary(
+        std::make_tuple(particles::Code::Nucleus, Eabove * A,
+                        corsika::stack::MomentumVector(rootCS, {0_GeV, 0_GeV, 0_GeV}),
+                        geometry::Point(rootCS, 0_m, 0_m, 0_m), 0_ns, A, Z));
+    projectile.AddSecondary(
+        std::make_tuple(particles::Code::Nucleus, Ebelow * A,
+                        corsika::stack::MomentumVector(rootCS, {0_GeV, 0_GeV, 0_GeV}),
+                        geometry::Point(rootCS, 0_m, 0_m, 0_m), 0_ns, A, Z));
+
+    cut.DoSecondaries(view);
+
+    CHECK(view.getEntries() == 1);
+    CHECK(view.getSize() == 13);
+  }
+
+  SECTION("cut on time") {
+    ParticleCut cut(20_GeV, false, false);
+    const TimeType too_late = 1_s;
 
+    // add primary particle to stack
+    auto particle = stack.AddParticle(
+        std::make_tuple(particles::Code::Proton, Eabove,
+                        corsika::stack::MomentumVector(rootCS, {0_GeV, 0_GeV, 0_GeV}),
+                        geometry::Point(rootCS, 0_m, 0_m, 0_m), 1_ns));
+    // view on secondary particles
+    corsika::setup::StackView view(particle);
+    // ref. to primary particle through the secondary view.
+    // only this way the secondary view is populated
+    auto projectile = view.GetProjectile();
+    // add secondaries, all with energies above the threshold
+    // only cut is by species
+    for (auto proType : particleList) {
+      projectile.AddSecondary(std::make_tuple(
+          proType, Eabove, corsika::stack::MomentumVector(rootCS, {0_GeV, 0_GeV, 0_GeV}),
+          geometry::Point(rootCS, 0_m, 0_m, 0_m), too_late));
+    }
     cut.DoSecondaries(view);
 
-    REQUIRE(view.getEntries() == 0);
-    REQUIRE(view.getSize() == 10);
+    CHECK(view.getEntries() == 0);
+    CHECK(cut.GetCutEnergy() / 1_GeV == 11000);
+    cut.Reset();
+    CHECK(cut.GetCutEnergy() == 0_GeV);
   }
 }
-- 
GitLab