IAP GITLAB

Skip to content
Snippets Groups Projects
Commit af24950c authored by Hans Dembinski's avatar Hans Dembinski
Browse files

demonstrating a tested example

parent cae2f86f
No related branches found
No related tags found
No related merge requests found
......@@ -11,8 +11,9 @@ target_link_libraries (logger_example CORSIKAunits CORSIKAlogging)
install (TARGETS logger_example DESTINATION share/examples)
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_link_libraries (cascade_example SuperStupidStack CORSIKAunits CORSIKAlogging
......@@ -34,4 +35,3 @@ target_link_libraries (staticsequence_example
CORSIKAgeometry
CORSIKAlogging)
install (TARGETS staticsequence_example DESTINATION share/examples)
......@@ -13,6 +13,7 @@
#include <corsika/stack/super_stupid/SuperStupidStack.h>
#include <iomanip>
#include <iostream>
#include <cassert>
using namespace std;
// using namespace corsika::literals;
......@@ -30,14 +31,18 @@ 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() == i++ * 1_GeV);
}
cout << "Etot=" << Etot << " = " << Etot / 1_GeV << " GeV" << endl;
assert(total_energy == 16.5_GeV);
}
int main() {
......
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