From cd6275412aaf3cddc5a5372249111d561bffc77e Mon Sep 17 00:00:00 2001 From: ralfulrich <ralf.ulrich@kit.edu> Date: Wed, 8 Aug 2018 14:30:43 +0200 Subject: [PATCH] all my started development --- CMakeLists.txt | 1 + Documentation/Examples/geometry_example.cc | 4 +++- Framework/Cascade/Cascade.cc | 1 + Framework/ParticleStack/StackOne.h | 18 +++++++++++------- Framework/ProcessSequence/ProcessSequence.h | 2 +- Framework/StackInterface/StackIterator.h | 16 ++++++---------- Framework/Units/PhysicalUnits.h | 20 ++++++++++++-------- 7 files changed, 35 insertions(+), 27 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 625db7c4e..b1bf83234 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,6 +11,7 @@ project (corsika VERSION 8.0.0 DESCRIPTION "CORSIKA C++ project") find_package (Boost 1.40 COMPONENTS program_options REQUIRED) find_package (Eigen3 3.3 REQUIRED) +find_package (HDF5) add_subdirectory (Documentation) add_subdirectory (Framework) diff --git a/Documentation/Examples/geometry_example.cc b/Documentation/Examples/geometry_example.cc index d045decba..418073fba 100644 --- a/Documentation/Examples/geometry_example.cc +++ b/Documentation/Examples/geometry_example.cc @@ -14,6 +14,8 @@ #include <iostream> #include <cstdlib> +using namespace phys::units; + int main() { using namespace phys::units; @@ -25,7 +27,7 @@ int main() CoordinateSystem cs2 = root.translate({0_m, 0_m, 1_m}); Point const p2(cs2, {0_m, 0_m, 0_m}); - auto const diff = p2 - p1; + Vector<length_d> const diff = p2 - p1; auto const norm = diff.squaredNorm(); std::cout << "p2-p1 components: " << diff.getComponents() << std::endl; diff --git a/Framework/Cascade/Cascade.cc b/Framework/Cascade/Cascade.cc index 68cde099e..6754155dc 100644 --- a/Framework/Cascade/Cascade.cc +++ b/Framework/Cascade/Cascade.cc @@ -15,6 +15,7 @@ Cascade::Process() } +template<typename Trajectory> void Cascade::Step(auto& sequence, Particle& particle) { diff --git a/Framework/ParticleStack/StackOne.h b/Framework/ParticleStack/StackOne.h index cff3779bd..0d8ab0068 100644 --- a/Framework/ParticleStack/StackOne.h +++ b/Framework/ParticleStack/StackOne.h @@ -17,21 +17,24 @@ namespace stack { template<typename _Stack> class ParticleReadOne : public StackIteratorInfo<_Stack, ParticleReadOne<_Stack> > { - using StackIteratorInfo<_Stack, ParticleReadOne>::Index; - using StackIteratorInfo<_Stack, ParticleReadOne>::Stack; + using StackIteratorInfo<_Stack, ParticleReadOne>::GetIndex; + using StackIteratorInfo<_Stack, ParticleReadOne>::GetStack; public: - void SetId(const int id) { Stack().SetId(Index(), id); } - void SetEnergy(const double e) { Stack().SetEnergy(Index(), e); } + void SetId(const int id) { GetStack().SetId(GetIndex(), id); } + void SetEnergy(const double e) { GetStack().SetEnergy(GetIndex(), e); } - int GetId() const { Stack().GetId(Index()); } - double GetEnergy() const { Stack().GetEnergy(Index()); } + int GetId() const { GetStack().GetId(GetIndex()); } + double GetEnergy() const { GetStack().GetEnergy(GetIndex()); } double GetPDG() const { return 0; } // ConvertToPDG(GetId()); } - void SetPDG(double v) { Stack().SetId(0, 0); } //fIndex, ConvertFromPDG(v)); } + void SetPDG(double v) { GetStack().SetId(0, 0); } //fIndex, ConvertFromPDG(v)); } }; + + + /** Memory implementation of the most simple particle stack object. */ @@ -40,6 +43,7 @@ namespace stack { { private: /// the actual memory to store particle data + std::vector<int> fId; std::vector<double> fData; diff --git a/Framework/ProcessSequence/ProcessSequence.h b/Framework/ProcessSequence/ProcessSequence.h index 5a8a7c268..967f6f347 100644 --- a/Framework/ProcessSequence/ProcessSequence.h +++ b/Framework/ProcessSequence/ProcessSequence.h @@ -48,7 +48,7 @@ namespace processes { { } template<typename D> - inline void DoContinuous(D& d) const { A.DoContinuous(d); B.DoContinuous(d); } + inline void DoContinuous(D& d) const { A.DoContinuous(d); B.DoContinuous(d); } // add trajectory template<typename D> inline double MinStepLength(D& d) const { return min(A.MinStepLength(d), B.MinStepLength(d)); } diff --git a/Framework/StackInterface/StackIterator.h b/Framework/StackInterface/StackIterator.h index 2fac50999..fdc67bf00 100644 --- a/Framework/StackInterface/StackIterator.h +++ b/Framework/StackInterface/StackIterator.h @@ -19,12 +19,8 @@ namespace stack { This allows to write code like \verbatim - for (auto p : theStack) { p.SetEnergy(newEnergy); } - \endverbatim - - It might be interesting to investigate whether auto or auto& is - better in the loop here... - + for (auto& p : theStack) { p.SetEnergy(newEnergy); } + \endverbatim */ template<typename Stack, typename Particle> @@ -71,7 +67,7 @@ namespace stack { Internal helper class for StackIterator. Document better... */ - template<class _Stack, class Particle> + template<typename _Stack, typename Particle> class StackIteratorInfo { friend Particle; @@ -79,9 +75,9 @@ namespace stack { StackIteratorInfo() {} protected: - inline _Stack& Stack() { return static_cast<StackIterator<_Stack, Particle>*>(this)->GetStack(); } - inline int Index() const { return static_cast<const StackIterator<_Stack, Particle>*>(this)->GetIndex(); } - inline const _Stack& Stack() const { return static_cast<const StackIterator<_Stack, Particle>*>(this)->GetStack(); } + inline _Stack& GetStack() { return static_cast<StackIterator<_Stack, Particle>*>(this)->GetStack(); } + inline int GetIndex() const { return static_cast<const StackIterator<_Stack, Particle>*>(this)->GetIndex(); } + inline const _Stack& GetStack() const { return static_cast<const StackIterator<_Stack, Particle>*>(this)->GetStack(); } }; } // end namespace stack diff --git a/Framework/Units/PhysicalUnits.h b/Framework/Units/PhysicalUnits.h index 481f5e216..2f91a23af 100644 --- a/Framework/Units/PhysicalUnits.h +++ b/Framework/Units/PhysicalUnits.h @@ -6,16 +6,20 @@ #include <Units/PhysicalConstants.h> -// define _XeV literals + /** + /file PhysicalUnits + + Define _XeV literals, alowing 10_GeV in the code. -//namespace corsika { - namespace phys { - namespace units { - namespace literals { - QUANTITY_DEFINE_SCALING_LITERALS(eV, energy_d, magnitude(eV) ) - } + */ + +namespace phys { + namespace units { + namespace literals { + QUANTITY_DEFINE_SCALING_LITERALS(eV, energy_d, magnitude(eV) ) } } -//} +} #endif + -- GitLab