IAP GITLAB

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

unit tests

parent 9ec06c98
No related branches found
No related tags found
1 merge request!371Additional outputs ported to new architecture
...@@ -118,7 +118,7 @@ int main() { ...@@ -118,7 +118,7 @@ int main() {
rootCS, {sin(theta) * cos(phi), sin(theta) * sin(phi), -cos(theta)}); rootCS, {sin(theta) * cos(phi), sin(theta) * sin(phi), -cos(theta)});
ShowerAxis const showerAxis{injectionPos, direction * 100_km, env}; ShowerAxis const showerAxis{injectionPos, direction * 100_km, env};
EnergyLossWriter<EnergyLossWriterParquet> dEdX{showerAxis}; EnergyLossWriter dEdX{showerAxis};
output.add("energyloss", dEdX); output.add("energyloss", dEdX);
{ {
......
...@@ -157,10 +157,6 @@ int main(int argc, char** argv) { ...@@ -157,10 +157,6 @@ int main(int argc, char** argv) {
app.add_flag("--force-interaction", force_interaction, app.add_flag("--force-interaction", force_interaction,
"Force the location of the first interaction.") "Force the location of the first interaction.")
->group("Misc."); ->group("Misc.");
app.add_option("-v,--verbosity", "Verbosity level")
->default_str("info")
->check(CLI::IsMember({"warn", "info", "debug", "trace"}))
->group("Misc.");
app.add_option("-v,--verbosity", "Verbosity level: warn, info, debug, trace.") app.add_option("-v,--verbosity", "Verbosity level: warn, info, debug, trace.")
->default_val("info") ->default_val("info")
->check(CLI::IsMember({"warn", "info", "debug", "trace"})) ->check(CLI::IsMember({"warn", "info", "debug", "trace"}))
...@@ -285,7 +281,7 @@ int main(int argc, char** argv) { ...@@ -285,7 +281,7 @@ int main(int argc, char** argv) {
output.add("energyloss", dEdX); output.add("energyloss", dEdX);
// create a track writer and register it with the output manager // create a track writer and register it with the output manager
TrackWriter<TrackWriterParquet> tracks; TrackWriter tracks;
output.add("tracks", tracks); output.add("tracks", tracks);
corsika::sibyll::Interaction sibyll; corsika::sibyll::Interaction sibyll;
...@@ -335,7 +331,7 @@ int main(int argc, char** argv) { ...@@ -335,7 +331,7 @@ int main(int argc, char** argv) {
corsika::urqmd::UrQMD urqmd; corsika::urqmd::UrQMD urqmd;
InteractionCounter urqmdCounted(urqmd); InteractionCounter urqmdCounted(urqmd);
StackInspector<setup::Stack> stackInspect(50000, false, E0); StackInspector<setup::Stack> stackInspect(10000, false, E0);
// assemble all processes into an ordered process list // assemble all processes into an ordered process list
struct EnergySwitch { struct EnergySwitch {
......
...@@ -145,7 +145,7 @@ int main(int argc, char** argv) { ...@@ -145,7 +145,7 @@ int main(int argc, char** argv) {
OutputManager output("em_shower_outputs"); OutputManager output("em_shower_outputs");
EnergyLossWriter<EnergyLossWriterParquet> dEdX{showerAxis, 10_g / square(1_cm), 200}; EnergyLossWriter dEdX{showerAxis, 10_g / square(1_cm), 200};
// register energy losses as output // register energy losses as output
output.add("dEdX", dEdX); output.add("dEdX", dEdX);
...@@ -160,7 +160,7 @@ int main(int argc, char** argv) { ...@@ -160,7 +160,7 @@ int main(int argc, char** argv) {
// NOT possible right now, due to interface differenc in PROPOSAL // NOT possible right now, due to interface differenc in PROPOSAL
// InteractionCounter emCascadeCounted(emCascade); // InteractionCounter emCascadeCounted(emCascade);
TrackWriter<TrackWriterParquet> tracks; TrackWriter tracks;
output.add("tracks", tracks); output.add("tracks", tracks);
// long. profile; columns for photon, e+, e- still need to be added // long. profile; columns for photon, e+, e- still need to be added
......
...@@ -53,7 +53,8 @@ TEST_CASE("ObservationPlane", "interface") { ...@@ -53,7 +53,8 @@ TEST_CASE("ObservationPlane", "interface") {
SECTION("horizontal plane") { SECTION("horizontal plane") {
Plane const obsPlane(Point(cs, {10_m, 0_m, 0_m}), DirectionVector(cs, {1., 0., 0.})); Plane const obsPlane(Point(cs, {10_m, 0_m, 0_m}), DirectionVector(cs, {1., 0., 0.}));
ObservationPlane<setup::Tracking> obs(obsPlane, DirectionVector(cs, {0., 1., 0.})); ObservationPlane<setup::Tracking, WriterOff> obs(obsPlane,
DirectionVector(cs, {0., 1., 0.}));
LengthType const length = obs.getMaxStepLength(particle, no_used_track); LengthType const length = obs.getMaxStepLength(particle, no_used_track);
ProcessReturn const ret = obs.doContinuous(particle, no_used_track, true); ProcessReturn const ret = obs.doContinuous(particle, no_used_track, true);
...@@ -81,8 +82,8 @@ TEST_CASE("ObservationPlane", "interface") { ...@@ -81,8 +82,8 @@ TEST_CASE("ObservationPlane", "interface") {
SECTION("transparent plane") { SECTION("transparent plane") {
Plane const obsPlane(Point(cs, {1_m, 0_m, 0_m}), DirectionVector(cs, {1., 0., 0.})); Plane const obsPlane(Point(cs, {1_m, 0_m, 0_m}), DirectionVector(cs, {1., 0., 0.}));
ObservationPlane<setup::Tracking> obs(obsPlane, DirectionVector(cs, {0., 0., 1.}), ObservationPlane<setup::Tracking, WriterOff> obs(
false); obsPlane, DirectionVector(cs, {0., 0., 1.}), false);
LengthType const length = obs.getMaxStepLength(particle, no_used_track); LengthType const length = obs.getMaxStepLength(particle, no_used_track);
ProcessReturn const ret = obs.doContinuous(particle, no_used_track, false); ProcessReturn const ret = obs.doContinuous(particle, no_used_track, false);
...@@ -102,7 +103,8 @@ TEST_CASE("ObservationPlane", "interface") { ...@@ -102,7 +103,8 @@ TEST_CASE("ObservationPlane", "interface") {
Plane const obsPlane(Point(cs, {10_m, 5_m, 5_m}), Plane const obsPlane(Point(cs, {10_m, 5_m, 5_m}),
DirectionVector(cs, {1, 0.1, -0.05})); DirectionVector(cs, {1, 0.1, -0.05}));
ObservationPlane<setup::Tracking> obs(obsPlane, DirectionVector(cs, {0., 1., 0.})); ObservationPlane<setup::Tracking, WriterOff> obs(obsPlane,
DirectionVector(cs, {0., 1., 0.}));
LengthType const length = obs.getMaxStepLength(particle, no_used_track); LengthType const length = obs.getMaxStepLength(particle, no_used_track);
ProcessReturn const ret = obs.doContinuous(particle, no_used_track, true); ProcessReturn const ret = obs.doContinuous(particle, no_used_track, true);
...@@ -113,8 +115,8 @@ TEST_CASE("ObservationPlane", "interface") { ...@@ -113,8 +115,8 @@ TEST_CASE("ObservationPlane", "interface") {
SECTION("output") { SECTION("output") {
Plane const obsPlane(Point(cs, {1_m, 0_m, 0_m}), DirectionVector(cs, {1., 0., 0.})); Plane const obsPlane(Point(cs, {1_m, 0_m, 0_m}), DirectionVector(cs, {1., 0., 0.}));
ObservationPlane<setup::Tracking> obs(obsPlane, DirectionVector(cs, {0., 0., 1.}), ObservationPlane<setup::Tracking, WriterOff> obs(
false); obsPlane, DirectionVector(cs, {0., 0., 1.}), false);
auto const cfg = obs.getConfig(); auto const cfg = obs.getConfig();
CHECK(cfg["type"]); CHECK(cfg["type"]);
} }
......
...@@ -52,7 +52,7 @@ TEST_CASE("ParticleCut", "process,continuous,secondary") { ...@@ -52,7 +52,7 @@ TEST_CASE("ParticleCut", "process,continuous,secondary") {
SECTION("cut on particle type: inv") { SECTION("cut on particle type: inv") {
// particle cut with 20GeV threshold for all, also cut invisible // particle cut with 20GeV threshold for all, also cut invisible
ParticleCut cut(20_GeV, 20_GeV, 20_GeV, 20_GeV, true, false); ParticleCut cut(20_GeV, 20_GeV, 20_GeV, 20_GeV, true);
CHECK(cut.getHadronKineticECut() == 20_GeV); CHECK(cut.getHadronKineticECut() == 20_GeV);
// add primary particle to stack // add primary particle to stack
...@@ -75,13 +75,11 @@ TEST_CASE("ParticleCut", "process,continuous,secondary") { ...@@ -75,13 +75,11 @@ TEST_CASE("ParticleCut", "process,continuous,secondary") {
cut.doSecondaries(view); cut.doSecondaries(view);
CHECK(view.getEntries() == 9); CHECK(view.getEntries() == 9);
CHECK(cut.getNumberInvParticles() == 2);
CHECK(cut.getInvEnergy() / 1_GeV == Approx(2000.));
} }
SECTION("cut on particle type: em") { SECTION("cut on particle type: em") {
ParticleCut cut(20_GeV, false, true); ParticleCut cut(1_EeV, 1_EeV, 1_GeV, 1_GeV, false);
// add primary particle to stack // add primary particle to stack
auto particle = stack.addParticle(std::make_tuple( auto particle = stack.addParticle(std::make_tuple(
...@@ -100,12 +98,10 @@ TEST_CASE("ParticleCut", "process,continuous,secondary") { ...@@ -100,12 +98,10 @@ TEST_CASE("ParticleCut", "process,continuous,secondary") {
cut.doSecondaries(view); cut.doSecondaries(view);
CHECK(view.getEntries() == 10); CHECK(view.getEntries() == 10);
CHECK(cut.getNumberEmParticles() == 1);
CHECK(cut.getEmEnergy() / 1_GeV == 1000.);
} }
SECTION("cut low energy") { SECTION("cut low energy") {
ParticleCut cut(20_GeV, 20_GeV, 20_GeV, 20_GeV, true, false); ParticleCut cut(20_GeV, 20_GeV, 20_GeV, 20_GeV, true);
// add primary particle to stack // add primary particle to stack
auto particle = stack.addParticle(std::make_tuple( auto particle = stack.addParticle(std::make_tuple(
...@@ -134,7 +130,7 @@ TEST_CASE("ParticleCut", "process,continuous,secondary") { ...@@ -134,7 +130,7 @@ TEST_CASE("ParticleCut", "process,continuous,secondary") {
} }
SECTION("cut low energy: electrons, photons, hadrons and muons") { SECTION("cut low energy: electrons, photons, hadrons and muons") {
ParticleCut cut(5_MeV, 5_MeV, 5_GeV, 5_GeV, true, false); ParticleCut cut(5_MeV, 5_MeV, 5_GeV, 5_GeV, true);
// add primary particle to stack // add primary particle to stack
auto particle = stack.addParticle(std::make_tuple(Code::Proton, Eabove - Proton::mass, auto particle = stack.addParticle(std::make_tuple(Code::Proton, Eabove - Proton::mass,
...@@ -167,7 +163,7 @@ TEST_CASE("ParticleCut", "process,continuous,secondary") { ...@@ -167,7 +163,7 @@ TEST_CASE("ParticleCut", "process,continuous,secondary") {
} }
SECTION("cut low energy: reset thresholds of arbitrary set of particles") { SECTION("cut low energy: reset thresholds of arbitrary set of particles") {
ParticleCut cut({{Code::Electron, 5_MeV}, {Code::Positron, 50_MeV}}, false, true); ParticleCut cut({{Code::Electron, 5_MeV}, {Code::Positron, 50_MeV}}, false);
CHECK(get_kinetic_energy_threshold(Code::Electron) != CHECK(get_kinetic_energy_threshold(Code::Electron) !=
get_kinetic_energy_threshold(Code::Positron)); get_kinetic_energy_threshold(Code::Positron));
CHECK_FALSE(get_kinetic_energy_threshold(Code::Electron) == Electron::mass); CHECK_FALSE(get_kinetic_energy_threshold(Code::Electron) == Electron::mass);
...@@ -176,7 +172,7 @@ TEST_CASE("ParticleCut", "process,continuous,secondary") { ...@@ -176,7 +172,7 @@ TEST_CASE("ParticleCut", "process,continuous,secondary") {
} }
SECTION("cut on time") { SECTION("cut on time") {
ParticleCut cut(20_GeV, 20_GeV, 20_GeV, 20_GeV, false, false); ParticleCut cut(20_GeV, 20_GeV, 20_GeV, 20_GeV, false);
const TimeType too_late = 1_s; const TimeType too_late = 1_s;
// add primary particle to stack // add primary particle to stack
...@@ -196,10 +192,6 @@ TEST_CASE("ParticleCut", "process,continuous,secondary") { ...@@ -196,10 +192,6 @@ TEST_CASE("ParticleCut", "process,continuous,secondary") {
cut.doSecondaries(view); cut.doSecondaries(view);
CHECK(view.getEntries() == 0); CHECK(view.getEntries() == 0);
CHECK(cut.getTimeCutEnergy() == 11 * Eabove);
CHECK(cut.getCutEnergy() == 0_GeV);
cut.reset();
CHECK(cut.getTimeCutEnergy() == 0_GeV);
} }
setup::Trajectory const track = setup::testing::make_track<setup::Trajectory>( setup::Trajectory const track = setup::testing::make_track<setup::Trajectory>(
...@@ -208,7 +200,7 @@ TEST_CASE("ParticleCut", "process,continuous,secondary") { ...@@ -208,7 +200,7 @@ TEST_CASE("ParticleCut", "process,continuous,secondary") {
SECTION("cut on doContinous, just invisibles") { SECTION("cut on doContinous, just invisibles") {
ParticleCut cut(20_GeV, 20_GeV, 20_GeV, 20_GeV, true, false); ParticleCut cut(20_GeV, 20_GeV, 20_GeV, 20_GeV, true);
// add particles, all with energies above the threshold // add particles, all with energies above the threshold
// only cut is by species // only cut is by species
...@@ -223,7 +215,5 @@ TEST_CASE("ParticleCut", "process,continuous,secondary") { ...@@ -223,7 +215,5 @@ TEST_CASE("ParticleCut", "process,continuous,secondary") {
} }
CHECK(stack.getEntries() == 9); CHECK(stack.getEntries() == 9);
CHECK(cut.getNumberInvParticles() == 2);
CHECK(cut.getInvEnergy() / 1_GeV == 2000);
} }
} }
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