diff --git a/Documentation/Examples/CMakeLists.txt b/Documentation/Examples/CMakeLists.txt index 2a66a3470584d14733e8a4651238e13b95756879..148df3493a54be8a98442a2f065a6c7a11858591 100644 --- a/Documentation/Examples/CMakeLists.txt +++ b/Documentation/Examples/CMakeLists.txt @@ -1,20 +1,28 @@ add_executable (helix_example helix_example.cc) +target_compile_options(helix_example PRIVATE -g) # do not skip asserts target_link_libraries(helix_example CORSIKAgeometry CORSIKAunits) install (TARGETS helix_example DESTINATION share/examples) +add_test(helix_example helix_example) add_executable (geometry_example geometry_example.cc) +target_compile_options(geometry_example PRIVATE -g) # do not skip asserts target_link_libraries (geometry_example CORSIKAgeometry CORSIKAunits) -install (TARGETS geometry_example DESTINATION share/examples) +#install (TARGETS geometry_example DESTINATION share/examples) +add_test(geometry_example geometry_example) add_executable (logger_example logger_example.cc) +target_compile_options(logger_example PRIVATE -g) # do not skip asserts target_link_libraries (logger_example CORSIKAunits CORSIKAlogging) -install (TARGETS logger_example DESTINATION share/examples) +#install (TARGETS logger_example DESTINATION share/examples) +add_test(logger_example logger_example) add_executable (stack_example stack_example.cc) +target_compile_options(stack_example PRIVATE -g) # do not skip asserts target_link_libraries (stack_example SuperStupidStack CORSIKAunits CORSIKAlogging) -install (TARGETS stack_example DESTINATION share/examples) +add_test(stack_example stack_example) add_executable (cascade_example cascade_example.cc) +target_compile_options(cascade_example PRIVATE -g) # do not skip asserts target_link_libraries (cascade_example SuperStupidStack CORSIKAunits CORSIKAlogging CORSIKArandom CORSIKAsibyll @@ -25,13 +33,15 @@ target_link_libraries (cascade_example SuperStupidStack CORSIKAunits CORSIKAlogg CORSIKAgeometry CORSIKAprocesssequence ) -install (TARGETS cascade_example DESTINATION share/examples) +#install (TARGETS cascade_example DESTINATION share/examples) +add_test(cascade_example cascade_example) add_executable (staticsequence_example staticsequence_example.cc) +target_compile_options(staticsequence_example PRIVATE -g) # do not skip asserts target_link_libraries (staticsequence_example CORSIKAprocesssequence CORSIKAunits CORSIKAgeometry CORSIKAlogging) -install (TARGETS staticsequence_example DESTINATION share/examples) - +#install (TARGETS staticsequence_example DESTINATION share/examples) +add_test(staticsequence_example staticsequence_example) diff --git a/Documentation/Examples/geometry_example.cc b/Documentation/Examples/geometry_example.cc index 5bacd1489ab9bff7add254ad8edc70ccada9ea43..abba9d9fc0350752fe211bd092490b17e9da923e 100644 --- a/Documentation/Examples/geometry_example.cc +++ b/Documentation/Examples/geometry_example.cc @@ -50,12 +50,15 @@ int main() { std::cout << "p2-p1 components in cs3: " << diff.GetComponents(cs3) << std::endl; // but not under rotations std::cout << "p2-p1 norm^2: " << norm << std::endl; - + assert(norm == 1 * meter*meter); + Sphere s(p1, 10_m); // define a sphere around a point with a radius std::cout << "p1 inside s: " << s.Contains(p2) << std::endl; - + assert(s.Contains(p2) == 1); + Sphere s2(p1, 3_um); // another sphere std::cout << "p1 inside s2: " << s2.Contains(p2) << std::endl; + assert(s2.Contains(p2) == 0); // let's try parallel projections: auto const v1 = Vector<length_d>(root, {1_m, 1_m, 0_m}); diff --git a/Documentation/Examples/helix_example.cc b/Documentation/Examples/helix_example.cc index c51afce291181a4629b4fceaf776b0bfa9fc40cd..02ccc7c2454da62ea2fec686f9980f923ba34ceb 100644 --- a/Documentation/Examples/helix_example.cc +++ b/Documentation/Examples/helix_example.cc @@ -35,7 +35,7 @@ int main() { auto constexpr t0 = 0_s; auto constexpr t1 = 1_s; - auto constexpr dt = 1_us; + auto constexpr dt = 1_ms; auto constexpr n = long((t1 - t0) / dt) + 1; auto arr = std::make_unique<std::array<std::array<double, 4>, n>>(); diff --git a/Documentation/Examples/logger_example.cc b/Documentation/Examples/logger_example.cc index 1bd72012ec936e33d9caf791f240d1f7b24dde0b..9d9b743c13caff6010b13a37e5a20aed02c58ed2 100644 --- a/Documentation/Examples/logger_example.cc +++ b/Documentation/Examples/logger_example.cc @@ -35,7 +35,7 @@ int main() { std::any */ - for (int i = 0; i < 100000; ++i) { + for (int i = 0; i < 10000; ++i) { LOG(info, "irgendwas", " ", string("and more"), " ", boost::format("error: %i message: %s. done."), i, "stupido"); LOG(err, "Fehler"); @@ -46,7 +46,7 @@ int main() { sink::NoSink off; Logger<MessageOff> info("", "", off); - for (int i = 0; i < 100000; ++i) { + for (int i = 0; i < 10000; ++i) { LOG(info, "irgendwas", string("and more"), boost::format("error: %i message: %s. done."), i, "stupido", "a-number:", 8.99, "ENDE"); diff --git a/Documentation/Examples/stack_example.cc b/Documentation/Examples/stack_example.cc index f0a04f79be09dff2c58a74bc4822c443c12061f0..4e2aae20b9fcd34ee0d1d7acc75c157558d4e027 100644 --- a/Documentation/Examples/stack_example.cc +++ b/Documentation/Examples/stack_example.cc @@ -13,13 +13,11 @@ #include <corsika/stack/super_stupid/SuperStupidStack.h> #include <iomanip> #include <iostream> - -using namespace std; -// using namespace corsika::literals; -// using namespace corsika::io; +#include <cassert> using namespace corsika::units::si; using namespace corsika::stack; +using namespace std; void fill(corsika::stack::super_stupid::SuperStupidStack& s) { for (int i = 0; i < 11; ++i) { @@ -30,14 +28,17 @@ void fill(corsika::stack::super_stupid::SuperStupidStack& s) { } void read(corsika::stack::super_stupid::SuperStupidStack& s) { - cout << "found Stack with " << s.GetSize() << " particles. " << endl; - EnergyType Etot; + assert(s.GetSize() == 11); // stack has 11 particles + + EnergyType total_energy; + int i = 0; for (auto& p : s) { - Etot += p.GetEnergy(); - cout << "particle: " << p.GetPID() << " with " << p.GetEnergy() / 1_GeV << " GeV" - << endl; + total_energy += p.GetEnergy(); + // particles are electrons with 1.5 GeV energy times i + assert(p.GetPID() == corsika::particles::Code::Electron); + assert(p.GetEnergy() == 1.5_GeV * (i++)); } - cout << "Etot=" << Etot << " = " << Etot / 1_GeV << " GeV" << endl; + //assert(total_energy == 82.5_GeV); } int main() { diff --git a/Documentation/Examples/staticsequence_example.cc b/Documentation/Examples/staticsequence_example.cc index 07cc7561e0a8222e26d9e5b7eeba8ced68f6f63b..53ebc73e44704f5d38ef01cd33ca67a9c1fac3d7 100644 --- a/Documentation/Examples/staticsequence_example.cc +++ b/Documentation/Examples/staticsequence_example.cc @@ -38,8 +38,8 @@ public: Process2() {} template <typename D, typename T, typename S> - inline EProcessReturn DoContinuous(D&, T&, S&) const { - // for (int i=0; i<10; ++i) d.p[i] *= 2; + inline EProcessReturn DoContinuous(D& d, T&, S&) const { + for (int i=0; i<10; ++i) d.p[i] -= 0.1*i; return EProcessReturn::eOk; } }; @@ -74,7 +74,7 @@ private: }; struct DummyData { - double p[10]; + double p[10] = {0,0,0,0,0,0,0,0,0,0}; }; struct DummyStack {}; @@ -86,14 +86,19 @@ void modular() { Process4 m4; const auto sequence = m1 + m2 + m3 + m4; - + DummyData p; DummyStack s; Trajectory t; - const int n = 100000000; + const int n = 1000; for (int i = 0; i < n; ++i) { sequence.DoContinuous(p, t, s); } - + + for(int i=0; i<10; ++i) { + //cout << p.p[i] << endl; + //assert(p.p[i] == n-i*100); + } + cout << " done (nothing...) " << endl; }