IAP GITLAB

Skip to content
Snippets Groups Projects
Commit 8105f130 authored by ralfulrich's avatar ralfulrich
Browse files

improve test a bit

parent 92e8492a
No related branches found
No related tags found
No related merge requests found
......@@ -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);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment