From 516c6324ae3c85f0e02a1f95e71a82426175c02d Mon Sep 17 00:00:00 2001 From: ralfulrich <ralf.ulrich@kit.edu> Date: Sat, 1 Dec 2018 12:15:00 +0100 Subject: [PATCH] added position/momentum/time to super-stupid-stack --- Stack/SuperStupidStack/CMakeLists.txt | 1 + Stack/SuperStupidStack/SuperStupidStack.h | 66 ++++++++++++++++++----- 2 files changed, 54 insertions(+), 13 deletions(-) diff --git a/Stack/SuperStupidStack/CMakeLists.txt b/Stack/SuperStupidStack/CMakeLists.txt index 6b00c993c..1e789386a 100644 --- a/Stack/SuperStupidStack/CMakeLists.txt +++ b/Stack/SuperStupidStack/CMakeLists.txt @@ -12,6 +12,7 @@ target_link_libraries ( CORSIKAstackinterface CORSIKAunits CORSIKAparticles + CORSIKAgeometry ) target_include_directories ( diff --git a/Stack/SuperStupidStack/SuperStupidStack.h b/Stack/SuperStupidStack/SuperStupidStack.h index 66eed2d78..8caa6cc77 100644 --- a/Stack/SuperStupidStack/SuperStupidStack.h +++ b/Stack/SuperStupidStack/SuperStupidStack.h @@ -16,7 +16,12 @@ #include <corsika/stack/Stack.h> #include <corsika/units/PhysicalUnits.h> +#include <corsika/geometry/CoordinateSystem.h> // remove +#include <corsika/geometry/Point.h> +#include <corsika/geometry/Vector.h> + #include <vector> +#include <algorithm> namespace corsika::stack { @@ -24,8 +29,16 @@ namespace corsika::stack { using corsika::particles::Code; using corsika::units::si::EnergyType; - using corsika::units::si::operator""_GeV; // literals; - + using corsika::units::si::TimeType; + using corsika::units::si::second; + using corsika::units::si::meter; + using corsika::units::si::joule; + using corsika::units::si::energy_d; + using corsika::geometry::Point; + using corsika::geometry::Vector; + + typedef Vector<energy_d> MomentumVector; + /** * Example of a particle object on the stack. */ @@ -39,9 +52,15 @@ namespace corsika::stack { public: void SetPID(const Code id) { GetStackData().SetPID(GetIndex(), id); } void SetEnergy(const EnergyType& e) { GetStackData().SetEnergy(GetIndex(), e); } + void SetMomentum(const MomentumVector& v) { GetStackData().SetMomentum(GetIndex(), v); } + void SetPosition(const Point& v) { GetStackData().SetPosition(GetIndex(), v); } + void SetTime(const TimeType& v) { GetStackData().SetTime(GetIndex(), v); } Code GetPID() const { return GetStackData().GetPID(GetIndex()); } EnergyType GetEnergy() const { return GetStackData().GetEnergy(GetIndex()); } + MomentumVector GetMomentum() const { return GetStackData().GetMomentum(GetIndex()); } + Point GetPosition() const { return GetStackData().GetPosition(GetIndex()); } + TimeType GetTime() const { return GetStackData().GetTime(GetIndex()); } }; /** @@ -61,42 +80,60 @@ namespace corsika::stack { int GetSize() const { return fDataPID.size(); } int GetCapacity() const { return fDataPID.size(); } - + void SetPID(const int i, const Code id) { fDataPID[i] = id; } void SetEnergy(const int i, const EnergyType e) { fDataE[i] = e; } - + void SetMomentum(const int i, const MomentumVector& v) { fMomentum[i] = v; } + void SetPosition(const int i, const Point& v) { fPosition[i] = v; } + void SetTime(const int i, const TimeType& v) { fTime[i] = v; } + Code GetPID(const int i) const { return fDataPID[i]; } EnergyType GetEnergy(const int i) const { return fDataE[i]; } + MomentumVector GetMomentum(const int i) { return fMomentum[i]; } + Point GetPosition(const int i) { return fPosition[i]; } + TimeType GetTime(const int i) { return fTime[i]; } /** * Function to copy particle at location i2 in stack to i1 */ void Copy(const int i1, const int i2) { - fDataE[i2] = fDataE[i1]; fDataPID[i2] = fDataPID[i1]; + fDataE[i2] = fDataE[i1]; + fMomentum[i2] = fMomentum[i1]; + fPosition[i2] = fPosition[i1]; + fTime[i2] = fTime[i1]; } /** * Function to copy particle at location i2 in stack to i1 */ void Swap(const int i1, const int i2) { - EnergyType tE = fDataE[i2]; - Code tC = fDataPID[i2]; - fDataE[i2] = fDataE[i1]; - fDataPID[i2] = fDataPID[i1]; - fDataE[i1] = tE; - fDataPID[i1] = tC; + std::swap(fDataPID[i2], fDataPID[i1]); + std::swap(fDataE[i2], fDataE[i1]); + std::swap(fMomentum[i2], fMomentum[i1]); // should be Momentum !!!! + std::swap(fPosition[i2], fPosition[i1]); + std::swap(fTime[i2], fTime[i1]); } protected: void IncrementSize() { - fDataE.push_back(0_GeV); fDataPID.push_back(Code::Unknown); + fDataE.push_back(0 * joule); +#warning this here makes no sense: see issue #48 + auto const dummyCS = corsika::geometry::CoordinateSystem::CreateRootCS(); + fMomentum.push_back(MomentumVector(dummyCS, + {0 * joule, 0 * joule, 0 * joule})); + fPosition.push_back(Point(dummyCS, + {0 * meter, 0 * meter, 0 * meter})); + fTime.push_back(0 * second); } void DecrementSize() { if (fDataE.size() > 0) { + fDataPID.pop_back(); fDataE.pop_back(); - fDataPID.pop_back(); + fMomentum.pop_back(); + fPosition.pop_back(); + fTime.pop_back(); } } @@ -105,6 +142,9 @@ namespace corsika::stack { std::vector<Code> fDataPID; std::vector<EnergyType> fDataE; + std::vector<Vector<corsika::units::si::energy_d>> fMomentum; // should be Momentum !!!! + std::vector<Point> fPosition; + std::vector<TimeType> fTime; }; // end class SuperStupidStackImpl -- GitLab