From 9ef3d7750aec383ca1cdec1eca3021c4acdc63bc Mon Sep 17 00:00:00 2001 From: ralfulrich <ralf.ulrich@kit.edu> Date: Thu, 7 Jan 2021 12:25:10 +0100 Subject: [PATCH] logging, test, examples --- .../framework/{logging => core}/Logging.inl | 0 .../detail/modules/pythia8/Interaction.inl | 7 +- .../detail/modules/qgsjetII/Interaction.inl | 129 +++++++++++------- corsika/framework/core/Logging.hpp | 10 +- .../geometry/RootCoordinateSystem.hpp | 2 +- corsika/setup/SetupLogger.hpp | 10 +- examples/boundary_example.cpp | 3 +- examples/cascade_example.cpp | 6 +- examples/cascade_proton_example.cpp | 1 + examples/em_shower.cpp | 1 + examples/geometry_example.cpp | 3 + examples/helix_example.cpp | 3 + examples/hybrid_MC.cpp | 1 + examples/particle_list_example.cpp | 3 +- examples/stack_example.cpp | 3 + examples/staticsequence_example.cpp | 3 + examples/stopping_power.cpp | 5 +- examples/vertical_EAS.cpp | 1 + tests/framework/testCOMBoost.cpp | 12 ++ tests/framework/testCascade.cpp | 2 + tests/framework/testClassTimer.cpp | 5 + tests/framework/testCombinedStack.cpp | 10 ++ tests/framework/testCorsikaFenv.cpp | 3 + tests/framework/testFourVector.cpp | 3 + tests/framework/testFunctionTimer.cpp | 5 + tests/framework/testGeometry.cpp | 4 + tests/framework/testHelix.cpp | 3 + tests/framework/testInteractionCounter.cpp | 6 +- tests/framework/testLogging.cpp | 77 ++++++----- tests/framework/testNullModel.cpp | 4 + tests/framework/testParticles.cpp | 4 + tests/framework/testProcessSequence.cpp | 6 + tests/framework/testRandom.cpp | 10 +- tests/framework/testSaveBoostHistogram.cpp | 5 + tests/framework/testSecondaryView.cpp | 3 +- tests/framework/testStackInterface.cpp | 4 + tests/framework/testUnits.cpp | 10 +- tests/media/testEnvironment.cpp | 23 ++++ tests/media/testMagneticField.cpp | 3 + tests/media/testMedium.cpp | 6 + tests/media/testRefractiveIndex.cpp | 3 + tests/media/testShowerAxis.cpp | 4 + tests/modules/testCONEX.cpp | 7 + tests/modules/testExecTime.cpp | 3 + tests/modules/testInteractionCounter.cpp | 6 +- tests/modules/testNullModel.cpp | 3 + tests/modules/testObservationPlane.cpp | 3 + tests/modules/testOnShellCheck.cpp | 4 + tests/modules/testParticleCut.cpp | 4 + tests/modules/testPythia8.cpp | 6 + tests/modules/testQGSJetII.cpp | 11 +- tests/modules/testSibyll.cpp | 6 + tests/modules/testStackInspector.cpp | 3 + tests/modules/testTracking.cpp | 3 + tests/modules/testUrQMD.cpp | 4 + tests/stack/testDummyStack.cpp | 3 + .../stack/testGeometryNodeStackExtension.cpp | 3 + tests/stack/testHistoryStack.cpp | 3 + tests/stack/testHistoryView.cpp | 3 + tests/stack/testNuclearStackExtension.cpp | 3 + tests/stack/testVectorStack.cpp | 5 +- 61 files changed, 382 insertions(+), 107 deletions(-) rename corsika/detail/framework/{logging => core}/Logging.inl (100%) diff --git a/corsika/detail/framework/logging/Logging.inl b/corsika/detail/framework/core/Logging.inl similarity index 100% rename from corsika/detail/framework/logging/Logging.inl rename to corsika/detail/framework/core/Logging.inl diff --git a/corsika/detail/modules/pythia8/Interaction.inl b/corsika/detail/modules/pythia8/Interaction.inl index f92f8f46e..95758a4e5 100644 --- a/corsika/detail/modules/pythia8/Interaction.inl +++ b/corsika/detail/modules/pythia8/Interaction.inl @@ -337,8 +337,11 @@ namespace corsika::pythia8 { // link to pythia stack Pythia8::Event& event = pythia_.event; - // print final state - event.list(); + + if (print_listing_) { + // print final state + event.list(); + } MomentumVector Plab_final(labCS, {0.0_GeV, 0.0_GeV, 0.0_GeV}); HEPEnergyType Elab_final = 0_GeV; diff --git a/corsika/detail/modules/qgsjetII/Interaction.inl b/corsika/detail/modules/qgsjetII/Interaction.inl index be20e4995..2cb34dbf9 100644 --- a/corsika/detail/modules/qgsjetII/Interaction.inl +++ b/corsika/detail/modules/qgsjetII/Interaction.inl @@ -153,10 +153,12 @@ namespace corsika::qgsjetII { event is copied (and boosted) into the shower lab frame. */ - template <typename TParticle> - void Interaction::doInteraction(TParticle& vP) { + template <typename TView> + void Interaction::doInteraction(TView& view) { + + auto const projectile = view.getProjectile(); - const auto corsikaBeamId = vP.getPID(); + const auto corsikaBeamId = projectile.getPID(); std::cout << "ProcessQgsjetII: " << "DoInteraction: " << corsikaBeamId << " interaction? " << corsika::qgsjetII::canInteract(corsikaBeamId) << std::endl; @@ -166,22 +168,24 @@ namespace corsika::qgsjetII { CoordinateSystemPtr const& rootCS = get_root_CoordinateSystem(); // position and time of interaction, not used in QgsjetII - Point pOrig = vP.getPosition(); - TimeType tOrig = vP.getTime(); + Point pOrig = projectile.getPosition(); + TimeType tOrig = projectile.getTime(); // define target // for QgsjetII is always a single nucleon // FOR NOW: target is always at rest - const auto targetEnergyLab = 0_GeV + constants::nucleonMass; - const auto targetMomentumLab = MomentumVector(rootCS, 0_GeV, 0_GeV, 0_GeV); - const FourVector PtargLab(targetEnergyLab, targetMomentumLab); + auto const targetEnergyLab = 0_GeV + constants::nucleonMass; + auto const targetMomentumLab = MomentumVector(rootCS, 0_GeV, 0_GeV, 0_GeV); + FourVector const PtargLab(targetEnergyLab, targetMomentumLab); // define projectile - HEPEnergyType const projectileEnergyLab = vP.getEnergy(); - auto const projectileMomentumLab = vP.getMomentum(); + HEPEnergyType const projectileEnergyLab = projectile.getEnergy(); + auto const projectileMomentumLab = projectile.getMomentum(); int beamA = 0; - if (is_nucleus(corsikaBeamId)) beamA = vP.getNuclearA(); + if (is_nucleus(corsikaBeamId)) beamA = projectile.getNuclearA(); + + HEPEnergyType const projectileEnergyLabPerNucleon = projectileEnergyLab / beamA; std::cout << "Interaction: ebeam lab: " << projectileEnergyLab / 1_GeV << std::endl << "Interaction: pbeam lab: " @@ -195,7 +199,7 @@ namespace corsika::qgsjetII { std::cout << "Interaction: time: " << tOrig << std::endl; // sample target mass number - auto const* currentNode = vP.getNode(); + auto const* currentNode = projectile.getNode(); auto const& mediumComposition = currentNode->getModelProperties().getNuclearComposition(); // get cross sections for target materials @@ -219,19 +223,37 @@ namespace corsika::qgsjetII { mediumComposition.sampleTarget(cross_section_of_components, rng_); std::cout << "Interaction: target selected: " << targetCode << std::endl; - int targetQgsCode = -1; - if (is_nucleus(targetCode)) targetQgsCode = get_nucleus_A(targetCode); - if (targetCode == Code::Proton) targetQgsCode = 1; - std::cout << "Interaction: target qgsjetII code/A: " << targetQgsCode << std::endl; - if (targetQgsCode > maxMassNumber_ || targetQgsCode < 1) - throw std::runtime_error("QgsjetII target outside range."); - - int projQgsCode = 1; - if (is_nucleus(corsikaBeamId)) projQgsCode = vP.getNuclearA(); - std::cout << "Interaction: projectile qgsjetII code/A: " << projQgsCode << " " - << corsikaBeamId << std::endl; - if (projQgsCode > maxMassNumber_ || projQgsCode < 1) - throw std::runtime_error("QgsjetII target outside range."); + int targetMassNumber = 1; // proton + if (is_nucleus(targetCode)) { // nucleus + targetMassNumber = get_nucleus_A(targetCode); + if (targetMassNumber > maxMassNumber_) + throw std::runtime_error("QgsjetII target mass outside range."); + } else { + if (targetCode != Proton::code) + throw std::runtime_error("QgsjetII Taget not possible."); + } + std::cout << "Interaction: target qgsjetII code/A: " << targetMassNumber << std::endl; + + int projectileMassNumber = 1; // "1" means "hadron" + QgsjetIIHadronType qgsjet_hadron_type = + qgsjetII::getQgsjetIIHadronType(corsikaBeamId); + if (qgsjet_hadron_type == QgsjetIIHadronType::NucleusType) { + projectileMassNumber = projectile.getNuclearA(); + if (projectileMassNumber > maxMassNumber_) + throw std::runtime_error("QgsjetII projectile mass outside range."); + std::array<QgsjetIIHadronType, 2> constexpr nucleons = { + QgsjetIIHadronType::ProtonType, QgsjetIIHadronType::NeutronType}; + std::uniform_int_distribution select(0, 1); + qgsjet_hadron_type = nucleons[select(rng_)]; + } else { + // from conex: replace pi0 or rho0 with pi+/pi- in alternating sequence + if (qgsjet_hadron_type == QgsjetIIHadronType::NeutralLightMesonType) { + qgsjet_hadron_type = alternate_; + alternate_ = (alternate_ == QgsjetIIHadronType::PiPlusType + ? QgsjetIIHadronType::PiMinusType + : QgsjetIIHadronType::PiPlusType); + } + } // beam id for qgsjetII int kBeam = 2; // default: proton Shouldn't we randomize neutron/proton for nuclei? @@ -254,9 +276,9 @@ namespace corsika::qgsjetII { std::cout << "Interaction: " << " DoInteraction: E(GeV):" << projectileEnergyLab / 1_GeV << std::endl; count_++; - qgini_(projectileEnergyLab / 1_GeV, kBeam, projQgsCode, targetQgsCode); - // this is from CRMC, is this REALLY needed ??? - qgini_(projectileEnergyLab / 1_GeV, kBeam, projQgsCode, targetQgsCode); + int qgsjet_hadron_type_int = static_cast<QgsjetIICodeIntType>(qgsjet_hadron_type); + qgini_(projectileEnergyLab / 1_GeV, qgsjet_hadron_type_int, projectileMassNumber, + targetMassNumber); qgconf_(); // bookkeeping @@ -278,21 +300,30 @@ namespace corsika::qgsjetII { int Z = 0; switch (A) { case 1: { // proton/neutron - idFragm = Code::Proton; - - auto momentum = - Vector(zAxisFrame, QuantityVector<hepmomentum_d>{ - 0.0_GeV, 0.0_GeV, - sqrt((projectileEnergyLab + Proton::mass) * - (projectileEnergyLab - Proton::mass))}); - - auto const energy = - sqrt(momentum.getSquaredNorm() + square(get_mass(idFragm))); + std::uniform_real_distribution<double> select; + if (select(rng_) > 0.5) { + idFragm = Code::Proton; + Z = 1; + } else { + idFragm = Code::Neutron; + Z = 0; + } + + const HEPMassType nucleonMass = get_mass(idFragm); + + auto momentum = Vector( + zAxisFrame, corsika::QuantityVector<hepmomentum_d>{ + 0.0_GeV, 0.0_GeV, + sqrt((projectileEnergyLabPerNucleon + nucleonMass) * + (projectileEnergyLabPerNucleon - nucleonMass))}); + + auto const energy = sqrt(momentum.getSquaredNorm() + square(nucleonMass)); momentum.rebase(originalCS); // transform back into standard lab frame std::cout << "secondary fragment> id=" << idFragm << " p=" << momentum.getComponents() << std::endl; - auto pnew = - vP.addSecondary(std::make_tuple(idFragm, energy, momentum, pOrig, tOrig)); + auto pnew = view.addSecondary( + std::make_tuple(idFragm, energy, momentum, + pOrig, tOrig)); Plab_final += pnew.getMomentum(); Elab_final += pnew.getEnergy(); } break; @@ -311,21 +342,23 @@ namespace corsika::qgsjetII { } } - if (idFragm == Code::Nucleus) { + if (idFragm == Code::Nucleus) { // thus: not p or n + const HEPMassType nucleusMass = + Proton::mass * Z + Neutron::mass * (A - Z); auto momentum = Vector( zAxisFrame, QuantityVector<hepmomentum_d>{ 0.0_GeV, 0.0_GeV, - sqrt((projectileEnergyLab + constants::nucleonMass * A) * - (projectileEnergyLab - constants::nucleonMass * A))}); + sqrt((projectileEnergyLabPerNucleon * A + nucleusMass) * + (projectileEnergyLabPerNucleon * A - nucleusMass))}); - auto const energy = - sqrt(momentum.getSquaredNorm() + square(constants::nucleonMass * A)); + auto const energy = sqrt(momentum.getSquaredNorm() + square(nucleusMass)); momentum.rebase(originalCS); // transform back into standard lab frame std::cout << "secondary fragment> id=" << idFragm << " p=" << momentum.getComponents() << " A=" << A << " Z=" << Z << std::endl; - auto pnew = vP.addSecondary( - std::make_tuple(idFragm, energy, momentum, pOrig, tOrig, A, Z)); + auto pnew = view.addSecondary( + std::make_tuple( + idFragm, energy, momentum, pOrig, tOrig, A, Z)); Plab_final += pnew.getMomentum(); Elab_final += pnew.getEnergy(); } @@ -342,7 +375,7 @@ namespace corsika::qgsjetII { std::cout << "secondary fragment> id=" << corsika::qgsjetII::convertFromQgsjetII(psec.getPID()) << " p=" << momentum.getComponents() << std::endl; - auto pnew = vP.addSecondary( + auto pnew = view.addSecondary( std::make_tuple(corsika::qgsjetII::convertFromQgsjetII(psec.getPID()), energy, momentum, pOrig, tOrig)); Plab_final += pnew.getMomentum(); diff --git a/corsika/framework/core/Logging.hpp b/corsika/framework/core/Logging.hpp index ade32ff6b..999235555 100644 --- a/corsika/framework/core/Logging.hpp +++ b/corsika/framework/core/Logging.hpp @@ -46,6 +46,11 @@ namespace corsika { + /* + * The default pattern for CORSIKA8 loggers. + */ + const std::string default_pattern{"[%n:%^%-8l%$] %v"}; + /** * Create a new C8-style logger. * @@ -83,7 +88,8 @@ namespace corsika { /** * The default "corsika" logger. */ - inline std::shared_ptr<spdlog::logger> corsika_logger = get_logger("corsika", true); + static inline std::shared_ptr<spdlog::logger> corsika_logger = get_logger("corsika", true); + // corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); // many of these free functions are special to the logging // infrastructure so we hide them in the corsika::logging namespace. @@ -140,4 +146,4 @@ namespace corsika { } // namespace corsika -#include <corsika/detail/framework/logging/Logging.inl> +#include <corsika/detail/framework/core/Logging.inl> diff --git a/corsika/framework/geometry/RootCoordinateSystem.hpp b/corsika/framework/geometry/RootCoordinateSystem.hpp index 08244fb54..41d2654d5 100644 --- a/corsika/framework/geometry/RootCoordinateSystem.hpp +++ b/corsika/framework/geometry/RootCoordinateSystem.hpp @@ -27,7 +27,7 @@ namespace corsika { * RootCoordinateSystem */ - static CoordinateSystemPtr& get_root_CoordinateSystem() { + static inline CoordinateSystemPtr& get_root_CoordinateSystem() { static CoordinateSystemPtr rootCS(new CoordinateSystem); // THIS IS IT return rootCS; } diff --git a/corsika/setup/SetupLogger.hpp b/corsika/setup/SetupLogger.hpp index 4d90f4c38..6d46e9836 100644 --- a/corsika/setup/SetupLogger.hpp +++ b/corsika/setup/SetupLogger.hpp @@ -8,4 +8,12 @@ #pragma once -namespace corsika {} +namespace corsika::setup { + + /** + * The default "corsika" logger. + */ + static std::shared_ptr<spdlog::logger> corsika_logger = get_logger("corsika", true); + // corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); + +} diff --git a/examples/boundary_example.cpp b/examples/boundary_example.cpp index da4d76d3e..bca45481a 100644 --- a/examples/boundary_example.cpp +++ b/examples/boundary_example.cpp @@ -79,7 +79,8 @@ private: // int main() { - // logging::SetLevel(logging::level::info); + logging::set_level(logging::level::info); + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); CORSIKA_LOG_INFO("boundary_example"); diff --git a/examples/cascade_example.cpp b/examples/cascade_example.cpp index 65366853f..246b5538a 100644 --- a/examples/cascade_example.cpp +++ b/examples/cascade_example.cpp @@ -35,7 +35,7 @@ /* NOTE, WARNING, ATTENTION - The .../Random.hpppp implement the hooks of external modules to the C8 random + The .../Random.hpp implement the hooks of external modules to the C8 random number generator. It has to occur excatly ONCE per linked executable. If you include the header below multiple times and link this togehter, it will fail. @@ -54,7 +54,9 @@ using namespace std; // int main() { - logging::set_level(logging::level::info); + //logging::set_level(logging::level::info); + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); + logging::set_level(logging::level::trace); std::cout << "cascade_example" << std::endl; diff --git a/examples/cascade_proton_example.cpp b/examples/cascade_proton_example.cpp index d7ed42c34..003dc8558 100644 --- a/examples/cascade_proton_example.cpp +++ b/examples/cascade_proton_example.cpp @@ -58,6 +58,7 @@ using namespace std; int main() { logging::set_level(logging::level::info); + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); std::cout << "cascade_proton_example" << std::endl; diff --git a/examples/em_shower.cpp b/examples/em_shower.cpp index 4bd457b8d..855fc5a38 100644 --- a/examples/em_shower.cpp +++ b/examples/em_shower.cpp @@ -65,6 +65,7 @@ using MyExtraEnv = MediumPropertyModel<UniformMagneticField<T>>; int main(int argc, char** argv) { logging::set_level(logging::level::info); + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); if (argc != 2) { std::cerr << "usage: em_shower <energy/GeV>" << std::endl; diff --git a/examples/geometry_example.cpp b/examples/geometry_example.cpp index b752d52ca..7a25708a8 100644 --- a/examples/geometry_example.cpp +++ b/examples/geometry_example.cpp @@ -20,6 +20,9 @@ using namespace corsika; int main() { + logging::set_level(logging::level::info); + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); + CORSIKA_LOG_INFO("geometry_example"); // define the root coordinate system diff --git a/examples/helix_example.cpp b/examples/helix_example.cpp index 452c0177b..cf58531b4 100644 --- a/examples/helix_example.cpp +++ b/examples/helix_example.cpp @@ -20,6 +20,9 @@ using namespace corsika; int main() { + logging::set_level(logging::level::info); + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); + CORSIKA_LOG_INFO("helix_example"); CoordinateSystemPtr const& root = get_root_CoordinateSystem(); diff --git a/examples/hybrid_MC.cpp b/examples/hybrid_MC.cpp index 410c5bf1c..b4eab698c 100644 --- a/examples/hybrid_MC.cpp +++ b/examples/hybrid_MC.cpp @@ -85,6 +85,7 @@ using MyExtraEnv = MediumPropertyModel<UniformMagneticField<T>>; int main(int argc, char** argv) { logging::set_level(logging::level::info); + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); CORSIKA_LOG_INFO("hybrid_MC"); diff --git a/examples/particle_list_example.cpp b/examples/particle_list_example.cpp index 4a341b29c..4b8d1d757 100644 --- a/examples/particle_list_example.cpp +++ b/examples/particle_list_example.cpp @@ -34,7 +34,8 @@ using namespace std; // int main() { - logging::set_level(spdlog::level::info); + logging::set_level(logging::level::info); + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); logging::info( "------------------------------------------\n" diff --git a/examples/stack_example.cpp b/examples/stack_example.cpp index 277b68760..30187c520 100644 --- a/examples/stack_example.cpp +++ b/examples/stack_example.cpp @@ -43,6 +43,9 @@ void read(VectorStack& s) { int main() { + logging::set_level(logging::level::info); + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); + std::cout << "stack_example" << std::endl; VectorStack s; fill(s); diff --git a/examples/staticsequence_example.cpp b/examples/staticsequence_example.cpp index a9d7a6284..d7b9e06b5 100644 --- a/examples/staticsequence_example.cpp +++ b/examples/staticsequence_example.cpp @@ -104,6 +104,9 @@ void modular() { int main() { + logging::set_level(logging::level::info); + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); + std::cout << "staticsequence_example" << std::endl; modular(); diff --git a/examples/stopping_power.cpp b/examples/stopping_power.cpp index b27494414..ef8252501 100644 --- a/examples/stopping_power.cpp +++ b/examples/stopping_power.cpp @@ -29,7 +29,10 @@ using namespace std; // int main() { - std::cout << "stopping_power" << std::endl; + logging::set_level(logging::level::info); + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); + + CORSIKA_LOG_INFO("stopping_power"); feenableexcept(FE_INVALID); diff --git a/examples/vertical_EAS.cpp b/examples/vertical_EAS.cpp index 9dfbfb11d..7d0a97d06 100644 --- a/examples/vertical_EAS.cpp +++ b/examples/vertical_EAS.cpp @@ -90,6 +90,7 @@ using MyExtraEnv = MediumPropertyModel<UniformMagneticField<T>>; int main(int argc, char** argv) { + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); logging::set_level(logging::level::info); CORSIKA_LOG_INFO("vertical_EAS"); diff --git a/tests/framework/testCOMBoost.cpp b/tests/framework/testCOMBoost.cpp index 7cc37dd49..4b60566e4 100644 --- a/tests/framework/testCOMBoost.cpp +++ b/tests/framework/testCOMBoost.cpp @@ -38,6 +38,10 @@ auto const s = [](HEPEnergyType E, QuantityVector<hepmomentum_d> const& p) { }; TEST_CASE("rotation") { + + logging::set_level(logging::level::info); + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); + // define projectile kinematics in lab frame HEPMassType const projectileMass = 1_GeV; HEPMassType const targetMass = 1.0e300_eV; @@ -166,6 +170,10 @@ TEST_CASE("rotation") { } TEST_CASE("boosts") { + + logging::set_level(logging::level::info); + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); + // define target kinematics in lab frame HEPMassType const targetMass = 1_GeV; MomentumVector pTargetLab{rootCS, {0_eV, 0_eV, 0_eV}}; @@ -319,6 +327,10 @@ TEST_CASE("boosts") { } TEST_CASE("rest frame") { + + logging::set_level(logging::level::info); + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); + HEPMassType const projectileMass = 1_GeV; HEPMomentumType const P0 = 1_TeV; MomentumVector pProjectileLab{rootCS, {0_GeV, P0, 0_GeV}}; diff --git a/tests/framework/testCascade.cpp b/tests/framework/testCascade.cpp index 27880dfb8..8a7978b84 100644 --- a/tests/framework/testCascade.cpp +++ b/tests/framework/testCascade.cpp @@ -15,6 +15,7 @@ #include <corsika/modules/StackInspector.hpp> #include <corsika/framework/core/ParticleProperties.hpp> +#include <corsika/framework/core/Logging.hpp> #include <corsika/framework/geometry/Point.hpp> #include <corsika/framework/geometry/RootCoordinateSystem.hpp> @@ -136,6 +137,7 @@ public: TEST_CASE("Cascade", "[Cascade]") { + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); logging::set_level(logging::level::trace); HEPEnergyType E0 = 100_GeV; diff --git a/tests/framework/testClassTimer.cpp b/tests/framework/testClassTimer.cpp index 3d35fcc03..008b581e8 100644 --- a/tests/framework/testClassTimer.cpp +++ b/tests/framework/testClassTimer.cpp @@ -7,6 +7,7 @@ */ #include <corsika/framework/analytics/ClassTimer.hpp> +#include <corsika/framework/core/Logging.hpp> #include <catch2/catch.hpp> @@ -103,6 +104,10 @@ public: }; TEST_CASE("ClassTimer", "[Timer]") { + + logging::set_level(logging::level::info); + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); + SECTION("Measure runtime of a function without arguments") { auto test = foo(); diff --git a/tests/framework/testCombinedStack.cpp b/tests/framework/testCombinedStack.cpp index f90f738d1..7d01f3fcd 100644 --- a/tests/framework/testCombinedStack.cpp +++ b/tests/framework/testCombinedStack.cpp @@ -11,6 +11,7 @@ #include <corsika/framework/stack/CombinedStack.hpp> #include <corsika/framework/stack/SecondaryView.hpp> #include <corsika/framework/stack/Stack.hpp> +#include <corsika/framework/core/Logging.hpp> #include <testTestStack.hpp> // for testing: simple stack. This is a // test-build, and inluce file is obtained from CMAKE_CURRENT_SOURCE_DIR @@ -87,6 +88,9 @@ using StackTest = CombinedStack<TestStackData, TestStackData2, CombinedTestInter TEST_CASE("Combined Stack", "[stack]") { + logging::set_level(logging::level::info); + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); + // helper function for sum over stack data auto sum = [](const StackTest& stack) { double v = 0; @@ -283,6 +287,9 @@ using StackTest2 = CombinedStack<typename StackTest::stack_implementation_type, TEST_CASE("Combined Stack - multi", "[stack]") { + logging::set_level(logging::level::info); + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); + SECTION("create secondaries") { StackTest2 s; @@ -378,6 +385,9 @@ using Particle2 = typename StackTest2::particle_type; TEST_CASE("Combined Stack - secondary view") { + logging::set_level(logging::level::info); + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); + SECTION("create secondaries via secondaryview") { StackTest2 stack; diff --git a/tests/framework/testCorsikaFenv.cpp b/tests/framework/testCorsikaFenv.cpp index 3e4e98e99..2b6cdb580 100644 --- a/tests/framework/testCorsikaFenv.cpp +++ b/tests/framework/testCorsikaFenv.cpp @@ -21,6 +21,9 @@ static void handle_fpe(int /*signo*/) { gRESULT = 0; } TEST_CASE("CorsikaFenv", "[fenv]") { + logging::set_level(logging::level::info); + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); + SECTION("Enable all exceptions") { feenableexcept(FE_ALL_EXCEPT); } signal(SIGFPE, handle_fpe); diff --git a/tests/framework/testFourVector.cpp b/tests/framework/testFourVector.cpp index a5982da82..09b458295 100644 --- a/tests/framework/testFourVector.cpp +++ b/tests/framework/testFourVector.cpp @@ -20,6 +20,9 @@ using namespace corsika; TEST_CASE("four vectors") { + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); + logging::set_level(logging::level::info); + // this is just needed as a baseline CoordinateSystemPtr rootCS = get_root_CoordinateSystem(); diff --git a/tests/framework/testFunctionTimer.cpp b/tests/framework/testFunctionTimer.cpp index c825f3efb..6596bcb70 100644 --- a/tests/framework/testFunctionTimer.cpp +++ b/tests/framework/testFunctionTimer.cpp @@ -7,6 +7,7 @@ */ #include <corsika/framework/analytics/FunctionTimer.hpp> +#include <corsika/framework/core/Logging.hpp> #include <catch2/catch.hpp> @@ -30,6 +31,10 @@ public: }; TEST_CASE("FunctionTimer", "[Timer]") { + + logging::set_level(logging::level::info); + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); + SECTION("Measure runtime of a free function") { auto test = corsika::FunctionTimer(testFunc); diff --git a/tests/framework/testGeometry.cpp b/tests/framework/testGeometry.cpp index 3472cf2dd..f0cd253f7 100644 --- a/tests/framework/testGeometry.cpp +++ b/tests/framework/testGeometry.cpp @@ -27,6 +27,10 @@ using namespace corsika::testing; double constexpr absMargin = 1.0e-8; TEST_CASE("transformations between CoordinateSystems") { + + logging::set_level(logging::level::info); + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); + CoordinateSystemPtr rootCS = get_root_CoordinateSystem(); QuantityVector<length_d> const coordinates{0_m, 0_m, 0_m}; diff --git a/tests/framework/testHelix.cpp b/tests/framework/testHelix.cpp index 5acb065ab..cbe997d20 100644 --- a/tests/framework/testHelix.cpp +++ b/tests/framework/testHelix.cpp @@ -21,6 +21,9 @@ double constexpr absMargin = 1.0e-8; TEST_CASE("Helix class") { + logging::set_level(logging::level::info); + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); + const CoordinateSystemPtr rootCS = get_root_CoordinateSystem(); Point r0(rootCS, {0_m, 0_m, 0_m}); diff --git a/tests/framework/testInteractionCounter.cpp b/tests/framework/testInteractionCounter.cpp index 88d110665..b9cb8b013 100644 --- a/tests/framework/testInteractionCounter.cpp +++ b/tests/framework/testInteractionCounter.cpp @@ -38,7 +38,8 @@ struct DummyProcess { TEST_CASE("InteractionCounter", "[process]") { - logging::set_level(logging::level::debug); + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); + logging::set_level(logging::level::info); DummyProcess d; InteractionCounter countedProcess(d); @@ -100,6 +101,9 @@ TEST_CASE("InteractionCounter", "[process]") { TEST_CASE("InteractionCounterOutput", "[output validation]") { + logging::set_level(logging::level::info); + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); + auto file = GENERATE(as<std::string>{}, "testInteractionCounter_file1", "testInteractionCounter_file2"); diff --git a/tests/framework/testLogging.cpp b/tests/framework/testLogging.cpp index 9c06a18fa..0c6de5282 100644 --- a/tests/framework/testLogging.cpp +++ b/tests/framework/testLogging.cpp @@ -13,12 +13,15 @@ using namespace corsika; TEST_CASE("Logging", "[Logging]") { + + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); + SECTION("top level functions using default corsika logger") { - logging::info("This is an info message!"); - logging::warn("This is a warning message!"); - logging::debug("This is a debug message!"); - logging::error("This is an error message!"); - logging::critical("This is a critical error message!"); + logging::info("(1) This is an info message!"); + logging::warn("(1) This is a warning message!"); + logging::debug("(1) This is a debug message!"); + logging::error("(1) This is an error message!"); + logging::critical("(1) This is a critical error message!"); } SECTION("create a specific logger") { @@ -30,21 +33,21 @@ TEST_CASE("Logging", "[Logging]") { logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); // and make sure we can log with this created object - logger->info("This is an info message!"); - logger->warn("This is a warning message!"); - logger->debug("This is a debug message!"); - logger->error("This is an error message!"); - logger->critical("This is a critical error message!"); + logger->info("(2) This is an info message!"); + logger->warn("(2) This is a warning message!"); + logger->debug("(2) This is a debug message!"); + logger->error("(2) This is an error message!"); + logger->critical("(2) This is a critical error message!"); // get a reference to the logger using Get auto other = get_logger("loggerA"); // and make sure we can use this other reference to log - other->info("This is an info message!"); - other->warn("This is a warning message!"); - other->debug("This is a debug message!"); - other->error("This is an error message!"); - other->critical("This is a critical error message!"); + other->info("(3) This is an info message!"); + other->warn("(3) This is a warning message!"); + other->debug("(3) This is a debug message!"); + other->error("(3) This is an error message!"); + other->critical("(3) This is a critical error message!"); } SECTION("get a new logger") { @@ -53,11 +56,11 @@ TEST_CASE("Logging", "[Logging]") { auto logger = get_logger("loggerB"); // and make sure we can log with this created object - logger->info("This is an info message!"); - logger->warn("This is a warning message!"); - logger->debug("This is a debug message!"); - logger->error("This is an error message!"); - logger->critical("This is a critical error message!"); + logger->info("(4) This is an info message!"); + logger->warn("(4) This is a warning message!"); + logger->debug("(4) This is a debug message!"); + logger->error("(4) This is an error message!"); + logger->critical("(4) This is a critical error message!"); } SECTION("test log level") { @@ -66,11 +69,11 @@ TEST_CASE("Logging", "[Logging]") { logging::set_default_level(logging::level::critical); // and make sure we can log with this created object - logging::info("This should NOT be printed!"); - logging::warn("This should NOT be printed!"); - logging::debug("This should NOT be printed!"); - logging::error("This should NOT be printed!"); - logging::critical("This SHOULD BE printed!!"); + logging::info("(5) This should NOT be printed!"); + logging::warn("(5) This should NOT be printed!"); + logging::debug("(5) This should NOT be printed!"); + logging::error("(5) This should NOT be printed!"); + logging::critical("(5) This SHOULD BE printed!!"); // get a reference to an unknown logger auto logger = get_logger("loggerD"); @@ -79,11 +82,11 @@ TEST_CASE("Logging", "[Logging]") { logger->set_level(logging::level::critical); // now try the various logging functions - logger->info("This should NOT be printed!"); - logger->warn("This should NOT be printed!"); - logger->debug("This should NOT be printed!"); - logger->error("This should NOT be printed!"); - logger->critical("This SHOULD BE printed!!"); + logger->info("(6) This should NOT be printed!"); + logger->warn("(6) This should NOT be printed!"); + logger->debug("(6) This should NOT be printed!"); + logger->error("(6) This should NOT be printed!"); + logger->critical("(6) This SHOULD BE printed!!"); // and reset it for the next tests logging::set_default_level(logging::level::debug); @@ -93,10 +96,10 @@ TEST_CASE("Logging", "[Logging]") { SECTION("test macro style logging") { // these print with the "corsika" logger - CORSIKA_LOG_INFO("test macro style logging"); - CORSIKA_LOG_DEBUG("test macro style logging"); - CORSIKA_LOG_ERROR("test macro style logging"); - CORSIKA_LOG_CRITICAL("test macro style logging"); + CORSIKA_LOG_INFO("(7) test macro style logging"); + CORSIKA_LOG_DEBUG("(7) test macro style logging"); + CORSIKA_LOG_ERROR("(7) test macro style logging"); + CORSIKA_LOG_CRITICAL("(7) test macro style logging"); // get a reference to an unknown logger auto logger = get_logger("loggerE"); @@ -105,13 +108,13 @@ TEST_CASE("Logging", "[Logging]") { logging::add_source_info(logger); // these print with the "loggerE" logger - CORSIKA_LOGGER_INFO(logger, "test macro style logging"); - CORSIKA_LOGGER_WARN(logger, "test macro style logging"); + CORSIKA_LOGGER_INFO(logger, "(8) test macro style logging"); + CORSIKA_LOGGER_WARN(logger, "(8) test macro style logging"); // reset the logging pattern logging::reset_pattern(logger); // these trace macros should not print file, function, and line - CORSIKA_LOGGER_TRACE(logger, "test macro style logging:"); + CORSIKA_LOGGER_TRACE(logger, "(9) test macro style logging:"); } } diff --git a/tests/framework/testNullModel.cpp b/tests/framework/testNullModel.cpp index 2db109099..0589b1782 100644 --- a/tests/framework/testNullModel.cpp +++ b/tests/framework/testNullModel.cpp @@ -7,6 +7,7 @@ */ #include <corsika/framework/process/NullModel.hpp> +#include <corsika/framework/core/Logging.hpp> #include <catch2/catch.hpp> @@ -19,5 +20,8 @@ using namespace corsika; TEST_CASE("NullModel", "[processes]") { + logging::set_level(logging::level::info); + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); + SECTION("interface") { [[maybe_unused]] NullModel model; } } diff --git a/tests/framework/testParticles.cpp b/tests/framework/testParticles.cpp index ae4b42856..dd999ecf8 100644 --- a/tests/framework/testParticles.cpp +++ b/tests/framework/testParticles.cpp @@ -8,6 +8,7 @@ #include <corsika/framework/core/ParticleProperties.hpp> #include <corsika/framework/core/PhysicalUnits.hpp> +#include <corsika/framework/core/Logging.hpp> #include <catch2/catch.hpp> @@ -15,6 +16,9 @@ using namespace corsika; TEST_CASE("ParticleProperties", "[Particles]") { + logging::set_level(logging::level::info); + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); + SECTION("Types") { CHECK(Electron::code == Code::Electron); CHECK(Positron::code == Code::Positron); diff --git a/tests/framework/testProcessSequence.cpp b/tests/framework/testProcessSequence.cpp index af4cfd94b..ac80847ca 100644 --- a/tests/framework/testProcessSequence.cpp +++ b/tests/framework/testProcessSequence.cpp @@ -249,6 +249,9 @@ struct DummyView { TEST_CASE("Process Sequence", "[Process Sequence]") { + logging::set_level(logging::level::info); + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); + SECTION("Check construction") { globalCount = 0; Process1 m1(0); @@ -372,6 +375,9 @@ TEST_CASE("Process Sequence", "[Process Sequence]") { TEST_CASE("Switch Process Sequence", "[Process Sequence]") { + logging::set_level(logging::level::info); + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); + SECTION("Check construction") { struct TestSelect { diff --git a/tests/framework/testRandom.cpp b/tests/framework/testRandom.cpp index 17c9c7c7a..5774575e6 100644 --- a/tests/framework/testRandom.cpp +++ b/tests/framework/testRandom.cpp @@ -53,7 +53,10 @@ SCENARIO("random-number streams can be registered and retrieved") { } TEST_CASE("UniformRealDistribution") { - using namespace corsika::units::si; + + logging::set_level(logging::level::info); + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); + std::mt19937 rng; corsika::UniformRealDistribution<LengthType> dist(1_m, 2_m); @@ -96,7 +99,10 @@ TEST_CASE("UniformRealDistribution") { } TEST_CASE("ExponentialDistribution") { - using namespace corsika::units::si; + + logging::set_level(logging::level::info); + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); + std::mt19937 rng; auto const beta = 15_m; diff --git a/tests/framework/testSaveBoostHistogram.cpp b/tests/framework/testSaveBoostHistogram.cpp index 7058811b0..91bac8b82 100644 --- a/tests/framework/testSaveBoostHistogram.cpp +++ b/tests/framework/testSaveBoostHistogram.cpp @@ -8,12 +8,17 @@ #include <catch2/catch.hpp> #include <corsika/framework/utility/SaveBoostHistogram.hpp> +#include <corsika/framework/core/Logging.hpp> #include <random> namespace bh = boost::histogram; TEST_CASE("SaveHistogram") { + + corsika::corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); + corsika::logging::set_level(corsika::logging::level::info); + std::mt19937 rng; std::normal_distribution n1{2., 6.}; std::exponential_distribution e{1.}; diff --git a/tests/framework/testSecondaryView.cpp b/tests/framework/testSecondaryView.cpp index db14cdd8a..87cfd91c0 100644 --- a/tests/framework/testSecondaryView.cpp +++ b/tests/framework/testSecondaryView.cpp @@ -43,7 +43,8 @@ using Particle = typename StackTest::particle_type; TEST_CASE("SecondaryStack", "[stack]") { - logging::set_level(logging::level::debug); + logging::set_level(logging::level::info); + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); // helper function for sum over stack data auto sum = [](const StackTest& stack) { diff --git a/tests/framework/testStackInterface.cpp b/tests/framework/testStackInterface.cpp index 0e5b49a1a..b37dc495d 100644 --- a/tests/framework/testStackInterface.cpp +++ b/tests/framework/testStackInterface.cpp @@ -9,6 +9,7 @@ #define protected public // to also test the internal state of objects #include <corsika/framework/stack/Stack.hpp> +#include <corsika/framework/core/Logging.hpp> #include <testTestStack.hpp> // from tests/common @@ -25,6 +26,9 @@ typedef Stack<TestStackData, TestParticleInterface> StackTest; TEST_CASE("Stack", "[Stack]") { + logging::set_level(logging::level::info); + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); + // helper function for sum over stack data auto sum = [](const StackTest& stack) { double v = 0; diff --git a/tests/framework/testUnits.cpp b/tests/framework/testUnits.cpp index 2cdd947b1..67db321d8 100644 --- a/tests/framework/testUnits.cpp +++ b/tests/framework/testUnits.cpp @@ -6,18 +6,21 @@ * the license. */ -#include <catch2/catch.hpp> - #include <corsika/framework/core/PhysicalUnits.hpp> +#include <corsika/framework/core/Logging.hpp> #include <array> #include <sstream> +#include <catch2/catch.hpp> + using namespace corsika; -using namespace corsika::units::si; TEST_CASE("PhysicalUnits", "[Units]") { + logging::set_level(logging::level::info); + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); + SECTION("Consistency") { CHECK(1_m / 1_m == Approx(1)); // CHECK_FALSE( 1_m/1_s == 1 ); // static assert @@ -114,7 +117,6 @@ TEST_CASE("PhysicalUnits", "[Units]") { } SECTION("static_pow") { - using namespace corsika::units; double x = 235.7913; CHECK(1 == static_pow<0, double>(x)); CHECK(x == static_pow<1, double>(x)); diff --git a/tests/media/testEnvironment.cpp b/tests/media/testEnvironment.cpp index d5177adf5..799ff2423 100644 --- a/tests/media/testEnvironment.cpp +++ b/tests/media/testEnvironment.cpp @@ -39,12 +39,20 @@ CoordinateSystemPtr const& gCS = get_root_CoordinateSystem(); Point const gOrigin(gCS, {0_m, 0_m, 0_m}); TEST_CASE("HomogeneousMedium") { + + logging::set_level(logging::level::info); + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); + NuclearComposition const protonComposition(std::vector<Code>{Code::Proton}, std::vector<float>{1.f}); HomogeneousMedium<IMediumModel> const medium(19.2_g / cube(1_cm), protonComposition); } TEST_CASE("FlatExponential") { + + logging::set_level(logging::level::info); + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); + NuclearComposition const protonComposition(std::vector<Code>{Code::Proton}, std::vector<float>{1.f}); @@ -104,6 +112,10 @@ TEST_CASE("FlatExponential") { } TEST_CASE("SlidingPlanarExponential") { + + logging::set_level(logging::level::info); + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); + NuclearComposition const protonComposition(std::vector<Code>{Code::Proton}, std::vector<float>{1.f}); @@ -161,6 +173,10 @@ struct Exponential { }; TEST_CASE("InhomogeneousMedium") { + + logging::set_level(logging::level::info); + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); + Vector direction(gCS, QuantityVector<dimensionless_d>(1, 0, 0)); Line line(gOrigin, Vector<SpeedType::dimension_type>( @@ -205,6 +221,9 @@ TEST_CASE("InhomogeneousMedium") { TEST_CASE("LayeredSphericalAtmosphereBuilder") { + logging::set_level(logging::level::info); + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); + LayeredSphericalAtmosphereBuilder builder = make_layered_spherical_atmosphere_builder<>::create(gOrigin, constants::EarthRadius::Mean); @@ -239,6 +258,10 @@ TEST_CASE("LayeredSphericalAtmosphereBuilder") { } TEST_CASE("LayeredSphericalAtmosphereBuilder w/ magnetic field") { + + logging::set_level(logging::level::info); + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); + // setup our interface types using ModelInterface = IMagneticFieldModel<IMediumModel>; diff --git a/tests/media/testMagneticField.cpp b/tests/media/testMagneticField.cpp index 71e521c76..73827dd92 100644 --- a/tests/media/testMagneticField.cpp +++ b/tests/media/testMagneticField.cpp @@ -23,6 +23,9 @@ using namespace corsika; TEST_CASE("UniformMagneticField w/ Homogeneous Medium") { + logging::set_level(logging::level::info); + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); + CoordinateSystemPtr const& gCS = get_root_CoordinateSystem(); Point const gOrigin(gCS, {0_m, 0_m, 0_m}); diff --git a/tests/media/testMedium.cpp b/tests/media/testMedium.cpp index 8e6ac8d08..670c25d92 100644 --- a/tests/media/testMedium.cpp +++ b/tests/media/testMedium.cpp @@ -26,6 +26,9 @@ using namespace corsika; TEST_CASE("MediumProperties") { + logging::set_level(logging::level::info); + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); + // test access of medium properties via enum and class types const Medium type = Medium::AirDry1Atm; @@ -41,6 +44,9 @@ TEST_CASE("MediumProperties") { TEST_CASE("MediumPropertyModel w/ Homogeneous") { + logging::set_level(logging::level::info); + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); + CoordinateSystemPtr gCS = get_root_CoordinateSystem(); Point const gOrigin(gCS, {0_m, 0_m, 0_m}); diff --git a/tests/media/testRefractiveIndex.cpp b/tests/media/testRefractiveIndex.cpp index 0e53e7642..fb1e71fec 100644 --- a/tests/media/testRefractiveIndex.cpp +++ b/tests/media/testRefractiveIndex.cpp @@ -25,6 +25,9 @@ using namespace corsika; TEST_CASE("UniformRefractiveIndex w/ Homogeneous") { + logging::set_level(logging::level::info); + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); + CoordinateSystemPtr const& gCS = get_root_CoordinateSystem(); Point const gOrigin(gCS, {0_m, 0_m, 0_m}); diff --git a/tests/media/testShowerAxis.cpp b/tests/media/testShowerAxis.cpp index e5511ba16..2293b616f 100644 --- a/tests/media/testShowerAxis.cpp +++ b/tests/media/testShowerAxis.cpp @@ -46,6 +46,10 @@ auto setupEnvironment(Code vTargetCode) { } TEST_CASE("Homogeneous Density") { + + logging::set_level(logging::level::info); + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); + auto [env, csPtr, nodePtr] = setupEnvironment(Code::Nitrogen); auto const& cs = *csPtr; [[maybe_unused]] auto const& env_dummy = env; diff --git a/tests/modules/testCONEX.cpp b/tests/modules/testCONEX.cpp index 635fee1b5..48ddaa4c7 100644 --- a/tests/modules/testCONEX.cpp +++ b/tests/modules/testCONEX.cpp @@ -37,6 +37,10 @@ template <typename T> using MExtraEnvirnoment = MediumPropertyModel<UniformMagneticField<T>>; TEST_CASE("CONEXSourceCut") { + + logging::set_level(logging::level::info); + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); + RNGManager::getInstance().registerRandomStream("cascade"); RNGManager::getInstance().registerRandomStream("sibyll"); @@ -116,6 +120,9 @@ TEST_CASE("CONEXSourceCut") { TEST_CASE("ConexOutput", "[output validation]") { + logging::set_level(logging::level::info); + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); + auto file = GENERATE(as<std::string>{}, "conex_fit", "conex_output"); SECTION(std::string("check saved data, ") + file + ".txt") { diff --git a/tests/modules/testExecTime.cpp b/tests/modules/testExecTime.cpp index a95eaaa8c..2079da842 100644 --- a/tests/modules/testExecTime.cpp +++ b/tests/modules/testExecTime.cpp @@ -26,6 +26,9 @@ using namespace corsika::process::example_processors; TEST_CASE("Timing process", "[proccesses][analytic_processors ExecTime]") { + logging::set_level(logging::level::info); + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); + int tmp = 0; SECTION("BoundaryCrossing") { diff --git a/tests/modules/testInteractionCounter.cpp b/tests/modules/testInteractionCounter.cpp index 6a147372f..096903c54 100644 --- a/tests/modules/testInteractionCounter.cpp +++ b/tests/modules/testInteractionCounter.cpp @@ -40,7 +40,8 @@ struct DummyProcess { TEST_CASE("InteractionCounter", "[process]") { - logging::SetLevel(logging::level::debug); + logging::set_level(logging::level::info); + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); DummyProcess d; InteractionCounter countedProcess(d); @@ -103,6 +104,9 @@ TEST_CASE("InteractionCounter", "[process]") { TEST_CASE("InteractionCounterOutput", "[output validation]") { + logging::set_level(logging::level::info); + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); + auto file = GENERATE(as<std::string>{}, "testInteractionCounter_file1", "testInteractionCounter_file2"); diff --git a/tests/modules/testNullModel.cpp b/tests/modules/testNullModel.cpp index cfbeeee26..a24433b08 100644 --- a/tests/modules/testNullModel.cpp +++ b/tests/modules/testNullModel.cpp @@ -14,6 +14,9 @@ using namespace corsika; TEST_CASE("NullModel", "[processes]") { + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); + logging::set_level(logging::level::trace); + SECTION("interface") { [[maybe_unused]] NullModel model; // nothing to test... } diff --git a/tests/modules/testObservationPlane.cpp b/tests/modules/testObservationPlane.cpp index 26cb731c2..9b9be4656 100644 --- a/tests/modules/testObservationPlane.cpp +++ b/tests/modules/testObservationPlane.cpp @@ -25,6 +25,9 @@ using namespace corsika; TEST_CASE("ContinuousProcess interface", "[proccesses][observation_plane]") { + logging::set_level(logging::level::info); + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); + auto [env, csPtr, nodePtr] = setup::testing::setup_environment(Code::Oxygen); auto const& cs = *csPtr; [[maybe_unused]] auto const& env_dummy = env; diff --git a/tests/modules/testOnShellCheck.cpp b/tests/modules/testOnShellCheck.cpp index ab713f7b5..f7577569c 100644 --- a/tests/modules/testOnShellCheck.cpp +++ b/tests/modules/testOnShellCheck.cpp @@ -23,6 +23,10 @@ using namespace corsika; TEST_CASE("OnShellCheck", "[processes]") { + + logging::set_level(logging::level::info); + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); + feenableexcept(FE_INVALID); using EnvType = setup::Environment; EnvType env; diff --git a/tests/modules/testParticleCut.cpp b/tests/modules/testParticleCut.cpp index 52907dd21..27164cada 100644 --- a/tests/modules/testParticleCut.cpp +++ b/tests/modules/testParticleCut.cpp @@ -23,6 +23,10 @@ using namespace corsika; TEST_CASE("ParticleCut", "[processes]") { + + logging::set_level(logging::level::info); + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); + feenableexcept(FE_INVALID); using EnvType = setup::Environment; diff --git a/tests/modules/testPythia8.cpp b/tests/modules/testPythia8.cpp index f0ba758f4..4f93280f5 100644 --- a/tests/modules/testPythia8.cpp +++ b/tests/modules/testPythia8.cpp @@ -22,6 +22,9 @@ using namespace corsika; TEST_CASE("Pythia", "[processes]") { + logging::set_level(logging::level::info); + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); + SECTION("linking pythia") { using namespace Pythia8; using std::cout; @@ -93,6 +96,9 @@ auto sumMomentum(TStackView const& view, CoordinateSystemPtr const& vCS) { TEST_CASE("pythia process") { + logging::set_level(logging::level::info); + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); + auto [env, csPtr, nodePtr] = setup::testing::setup_environment(Code::Proton); auto const& cs = *csPtr; [[maybe_unused]] auto const& env_dummy = env; diff --git a/tests/modules/testQGSJetII.cpp b/tests/modules/testQGSJetII.cpp index eeb6d95a7..3ddbb254c 100644 --- a/tests/modules/testQGSJetII.cpp +++ b/tests/modules/testQGSJetII.cpp @@ -39,6 +39,9 @@ auto sumMomentum(TStackView const& view, CoordinateSystemPtr const& vCS) { TEST_CASE("CORSIKA_DATA", "[processes]") { + logging::set_level(logging::level::info); + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); + SECTION("check CORSIKA_DATA") { const char* data = std::getenv("CORSIKA_DATA"); @@ -55,6 +58,9 @@ TEST_CASE("CORSIKA_DATA", "[processes]") { TEST_CASE("QgsjetII", "[processes]") { + logging::set_level(logging::level::info); + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); + SECTION("Corsika -> QgsjetII") { CHECK(corsika::qgsjetII::convertToQgsjetII(PiMinus::code) == corsika::qgsjetII::QgsjetIICode::PiMinus); @@ -115,6 +121,9 @@ TEST_CASE("QgsjetII", "[processes]") { TEST_CASE("QgsjetIIInterface", "[processes]") { + logging::set_level(logging::level::info); + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); + auto [env, csPtr, nodePtr] = setup::testing::setup_environment(Code::Oxygen); [[maybe_unused]] auto const& env_dummy = env; [[maybe_unused]] auto const& node_dummy = nodePtr; @@ -132,7 +141,7 @@ TEST_CASE("QgsjetIIInterface", "[processes]") { auto const projectileMomentum = projectile.getMomentum(); corsika::qgsjetII::Interaction model; - model.doInteraction(projectile); + model.doInteraction(view); [[maybe_unused]] const GrammageType length = model.getInteractionLength(particle); CHECK(length / (1_g / square(1_cm)) == Approx(93.04).margin(0.1)); diff --git a/tests/modules/testSibyll.cpp b/tests/modules/testSibyll.cpp index 2a3585a3d..6e35c6a1d 100644 --- a/tests/modules/testSibyll.cpp +++ b/tests/modules/testSibyll.cpp @@ -32,6 +32,9 @@ using namespace corsika::sibyll; TEST_CASE("Sibyll", "[processes]") { + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); + logging::set_level(logging::level::trace); + SECTION("Sibyll -> Corsika") { CHECK(Code::Electron == corsika::sibyll::convertFromSibyll(corsika::sibyll::SibyllCode::Electron)); @@ -96,6 +99,9 @@ auto sumMomentum(TStackView const& view, CoordinateSystemPtr const& vCS) { TEST_CASE("SibyllInterface", "[processes]") { + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); + logging::set_level(logging::level::trace); + auto [env, csPtr, nodePtr] = setup::testing::setup_environment(Code::Oxygen); auto const& cs = *csPtr; [[maybe_unused]] auto const& env_dummy = env; diff --git a/tests/modules/testStackInspector.cpp b/tests/modules/testStackInspector.cpp index 31f3765ae..00187ed9a 100644 --- a/tests/modules/testStackInspector.cpp +++ b/tests/modules/testStackInspector.cpp @@ -23,6 +23,9 @@ using namespace corsika; TEST_CASE("StackInspector", "[processes]") { + logging::set_level(logging::level::info); + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); + auto const& rootCS = get_root_CoordinateSystem(); Point const origin(rootCS, {0_m, 0_m, 0_m}); VelocityVector v(rootCS, 0_m / second, 0_m / second, 1_m / second); diff --git a/tests/modules/testTracking.cpp b/tests/modules/testTracking.cpp index 70d2583c1..87cd51e93 100644 --- a/tests/modules/testTracking.cpp +++ b/tests/modules/testTracking.cpp @@ -42,6 +42,9 @@ TEMPLATE_TEST_CASE("TrackingLeapfrog_Curved", "tracking", tracking_leapfrog_curved::Tracking, tracking_leapfrog_straight::Tracking, tracking_line::Tracking) { + logging::set_level(logging::level::info); + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); + logging::set_level(logging::level::trace); const HEPEnergyType P0 = 10_GeV; diff --git a/tests/modules/testUrQMD.cpp b/tests/modules/testUrQMD.cpp index 9157df2d5..03ea27d8c 100644 --- a/tests/modules/testUrQMD.cpp +++ b/tests/modules/testUrQMD.cpp @@ -57,6 +57,10 @@ auto sumMomentum(TStackView const& view, CoordinateSystemPtr const& vCS) { } TEST_CASE("UrQMD") { + + logging::set_level(logging::level::info); + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); + SECTION("conversion") { CHECK_THROWS(corsika::urqmd::convertFromUrQMD(106, 0)); CHECK(corsika::urqmd::convertFromUrQMD(101, 0) == Code::Pi0); diff --git a/tests/stack/testDummyStack.cpp b/tests/stack/testDummyStack.cpp index 2c3110eba..d68b0c093 100644 --- a/tests/stack/testDummyStack.cpp +++ b/tests/stack/testDummyStack.cpp @@ -16,6 +16,9 @@ using namespace corsika; TEST_CASE("DummyStack", "[stack]") { + logging::set_level(logging::level::info); + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); + using TestStack = dummy_stack::DummyStack; dummy_stack::NoData noData; diff --git a/tests/stack/testGeometryNodeStackExtension.cpp b/tests/stack/testGeometryNodeStackExtension.cpp index 35f5c20bd..8256927d9 100644 --- a/tests/stack/testGeometryNodeStackExtension.cpp +++ b/tests/stack/testGeometryNodeStackExtension.cpp @@ -40,6 +40,9 @@ using TestStack = TEST_CASE("GeometryNodeStackExtension", "[stack]") { + logging::set_level(logging::level::info); + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); + dummy_stack::NoData noData; SECTION("write node") { diff --git a/tests/stack/testHistoryStack.cpp b/tests/stack/testHistoryStack.cpp index e63620830..b393291bf 100644 --- a/tests/stack/testHistoryStack.cpp +++ b/tests/stack/testHistoryStack.cpp @@ -48,6 +48,9 @@ using EvtPtr = std::shared_ptr<DummyEvent>; TEST_CASE("HistoryStackExtension", "[stack]") { + logging::set_level(logging::level::info); + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); + [[maybe_unused]] CoordinateSystemPtr const& dummyCS = get_root_CoordinateSystem(); const dummy_stack::NoData noData; diff --git a/tests/stack/testHistoryView.cpp b/tests/stack/testHistoryView.cpp index ce09e81e3..6ee9300c3 100644 --- a/tests/stack/testHistoryView.cpp +++ b/tests/stack/testHistoryView.cpp @@ -69,6 +69,9 @@ int count_generations(Event const* event) { TEST_CASE("HistoryStackExtensionView", "[stack]") { + logging::set_level(logging::level::info); + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); + CoordinateSystemPtr const& dummyCS = get_root_CoordinateSystem(); // in this test we only use one singel stack ! diff --git a/tests/stack/testNuclearStackExtension.cpp b/tests/stack/testNuclearStackExtension.cpp index c00fb2fe6..1e33f6c05 100644 --- a/tests/stack/testNuclearStackExtension.cpp +++ b/tests/stack/testNuclearStackExtension.cpp @@ -19,6 +19,9 @@ using namespace std; TEST_CASE("NuclearStackExtension", "[stack]") { + logging::set_level(logging::level::info); + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); + CoordinateSystemPtr const& dummyCS = get_root_CoordinateSystem(); SECTION("write non nucleus") { diff --git a/tests/stack/testVectorStack.cpp b/tests/stack/testVectorStack.cpp index 420a0232a..9767b6c84 100644 --- a/tests/stack/testVectorStack.cpp +++ b/tests/stack/testVectorStack.cpp @@ -19,7 +19,10 @@ using namespace std; TEST_CASE("VectorStack", "[stack]") { - const CoordinateSystemPtr& dummyCS = get_root_CoordinateSystem(); + logging::set_level(logging::level::info); + corsika_logger->set_pattern("[%n:%^%-8l%$] custom pattern: %v"); + + CoordinateSystemPtr const& dummyCS = get_root_CoordinateSystem(); SECTION("read+write") { -- GitLab