IAP GITLAB

Commit 61323de5 authored by Ralf Ulrich's avatar Ralf Ulrich

file extension examples

parent eabed243
......@@ -12,15 +12,15 @@
#include <cmath>
#include <limits>
#include <corsika/media/Environment.hpp>
#include <corsika/setup/SetupStack.hpp>
#include <corsika/setup/SetupTrajectory.hpp>
#include <corsika/framework/core/PhysicalUnits.hpp>
#include <corsika/framework/random/ExponentialDistribution.hpp>
#include <corsika/framework/random/RNGManager.hpp>
#include <corsika/framework/random/UniformRealDistribution.hpp>
#include <corsika/framework/sequence/ProcessReturn.hpp>
#include <corsika/framework/stack/SecondaryView.hpp>
#include <corsika/framework/core/PhysicalUnits.hpp>
#include <corsika/media/Environment.hpp>
#include <corsika/setup/SetupStack.hpp>
#include <corsika/setup/SetupTrajectory.hpp>
/**
* The cascade namespace assembles all objects needed to simulate full particles cascades.
......@@ -50,25 +50,23 @@ namespace corsika {
*
*/
template <typename TTracking, typename TProcessList, typename TStack,
typename TStackView = corsika::setup::StackView>
class Cascade
{
typename TStackView = corsika::setup::StackView>
class Cascade {
typedef typename TStack::ParticleType Particle;
typedef std::remove_pointer_t<decltype(((Particle*)nullptr)->GetNode())> VolumeTreeNode;
typedef std::remove_pointer_t<decltype(((Particle*)nullptr)->GetNode())>
VolumeTreeNode;
typedef typename VolumeTreeNode::IModelProperties MediumInterface;
public:
Cascade() = delete;
Cascade(corsika::Environment<MediumInterface> const& env, TTracking& tr,
TProcessList& pl, TStack& stack):
fEnvironment(env),
fTracking(tr),
fProcessSequence(pl),
fStack(stack)
{ }
TProcessList& pl, TStack& stack)
: fEnvironment(env)
, fTracking(tr)
, fProcessSequence(pl)
, fStack(stack) {}
/**
* The Init function is called before the actual cascade simulations.
......@@ -96,20 +94,19 @@ namespace corsika {
void forceInteraction();
private:
void Step(Particle& vParticle);
auto decay(Particle& particle, decltype(std::declval<TStackView>().GetProjectile()) projectile);
auto decay(Particle& particle,
decltype(std::declval<TStackView>().GetProjectile()) projectile);
auto interaction(Particle& particle, decltype(std::declval<TStackView>().GetProjectile()) projectile) ;
auto interaction(Particle& particle,
decltype(std::declval<TStackView>().GetProjectile()) projectile);
corsika::Environment<MediumInterface> const& fEnvironment;
TTracking& fTracking;
TProcessList& fProcessSequence;
TStack& fStack;
corsika::RNG& fRNG =
corsika::RNGManager::GetInstance().GetRandomStream("cascade");
corsika::RNG& fRNG = corsika::RNGManager::GetInstance().GetRandomStream("cascade");
};
} // namespace corsika
......
......@@ -99,7 +99,8 @@ namespace corsika::particles {
}
inline corsika::units::si::TimeType constexpr GetLifetime(Code const p) {
return particle::detail::lifetime[static_cast<CodeIntType>(p)] * corsika::units::si::second;
return particle::detail::lifetime[static_cast<CodeIntType>(p)] *
corsika::units::si::second;
}
inline bool constexpr IsHadron(Code const p) {
......@@ -157,9 +158,9 @@ namespace corsika::particles {
/**
* Get mass of nucleus
**/
inline corsika::units::si::HEPMassType constexpr GetNucleusMass(const int vA, const int vZ) {
inline corsika::units::si::HEPMassType constexpr GetNucleusMass(const int vA,
const int vZ) {
return Proton::GetMass() * vZ + (vA - vZ) * Neutron::GetMass();
}
} // namespace corsika
......@@ -64,4 +64,3 @@ namespace corsika::units::constants {
// etc.
} // namespace corsika::units::constants
......@@ -10,7 +10,7 @@
#include <corsika/framework/core/PhysicalConstants.hpp>
//FIXME: What package is this?
// FIXME: What package is this?
#include <phys/units/io.hpp>
#include <phys/units/quantity.hpp>
......
......@@ -13,36 +13,32 @@
namespace corsika {
/*!
* Common base class for Vector and Point. Currently it does basically nothing.
*/
/*
* FIXME Many potential issues:
* 1. does this class really need to be templated ?
* 2. copy constructor, assignment operator not implemented
* 3. this member pointer is quite scary...
*/
template <typename dim>
class BaseVector {
public:
/*
* FIXME Why to copy pQVector twice?
*/
BaseVector(CoordinateSystem const& pCS, QuantityVector<dim> pQVector):
qVector(pQVector),
cs(&pCS)
{}
auto const& GetCoordinateSystem() const;
protected:
QuantityVector<dim> qVector;
CoordinateSystem const* cs;
};
/*!
* Common base class for Vector and Point. Currently it does basically nothing.
*/
/*
* FIXME Many potential issues:
* 1. does this class really need to be templated ?
* 2. copy constructor, assignment operator not implemented
* 3. this member pointer is quite scary...
*/
template <typename dim>
class BaseVector {
public:
/*
* FIXME Why to copy pQVector twice?
*/
BaseVector(CoordinateSystem const& pCS, QuantityVector<dim> pQVector)
: qVector(pQVector)
, cs(&pCS) {}
auto const& GetCoordinateSystem() const;
protected:
QuantityVector<dim> qVector;
CoordinateSystem const* cs;
};
} // namespace corsika
......
......@@ -8,14 +8,13 @@
#pragma once
#include <corsika/framework/core/PhysicalUnits.hpp>
#include <corsika/framework/geometry/QuantityVector.hpp>
#include <corsika/framework/utility/sgn.hpp>
#include <corsika/framework/core/PhysicalUnits.hpp>
#include <Eigen/Dense>
#include <stdexcept>
/*
* FIXME Review this global typedef.
*/
......@@ -26,7 +25,6 @@ namespace corsika {
class RootCoordinateSystem;
template <typename T>
class Vector;
......@@ -35,24 +33,21 @@ namespace corsika {
*/
using corsika::units::si::length_d;
class CoordinateSystem
{
class CoordinateSystem {
CoordinateSystem const* reference = nullptr;
EigenTransform transf;
CoordinateSystem(CoordinateSystem const& reference, EigenTransform const& transf):
reference(&reference),
transf(transf)
{}
CoordinateSystem(CoordinateSystem const& reference, EigenTransform const& transf)
: reference(&reference)
, transf(transf) {}
CoordinateSystem()
: // for creating the root CS
transf(EigenTransform::Identity()) {}
public:
//FIXME missing test for self assignment
// FIXME missing test for self assignment
inline CoordinateSystem& operator=(const CoordinateSystem& pCS);
inline CoordinateSystem translate(QuantityVector<length_d> vector) const;
......@@ -64,7 +59,7 @@ namespace corsika {
auto RotateToZ(Vector<TDim> vVec) const;
template <typename TDim>
auto rotate(QuantityVector<TDim> axis, double angle) const ;
auto rotate(QuantityVector<TDim> axis, double angle) const;
template <typename TDim>
auto translateAndRotate(QuantityVector<phys::units::length_d> translation,
......@@ -75,16 +70,15 @@ namespace corsika {
inline const EigenTransform& GetTransform() const;
protected:
static CoordinateSystem CreateCS() { return CoordinateSystem(); }
friend corsika::RootCoordinateSystem; /// this is the only class that can
/// create ONE unique root CS
/// create ONE unique root CS
};
EigenTransform getTransformation(CoordinateSystem const& c1,
CoordinateSystem const& c2);
EigenTransform getTransformation(CoordinateSystem const& c1, CoordinateSystem const& c2);
} // namespace corsika
#include <corsika/detail/framework/geometry/CoordinateSystem.inl>
......@@ -8,10 +8,10 @@
#pragma once
#include <iostream>
#include <type_traits>
#include <corsika/framework/core/PhysicalUnits.hpp>
#include <corsika/framework/geometry/Vector.hpp>
#include <iostream>
#include <type_traits>
namespace corsika {
......@@ -34,11 +34,9 @@ namespace corsika {
*/
template <typename TimeType, typename SpaceVecType>
class FourVector
{
class FourVector {
public:
using SpaceType = typename std::decay<SpaceVecType>::type::Quantity;
//! check the types and the physical units here:
......@@ -51,13 +49,11 @@ namespace corsika {
"(e.g. GeV) or [E/c]=[p]");
public:
FourVector() = default;
FourVector(const TimeType& eT, const SpaceVecType& eS):
fTimeLike(eT),
fSpaceLike(eS)
{}
FourVector(const TimeType& eT, const SpaceVecType& eS)
: fTimeLike(eT)
, fSpaceLike(eS) {}
/*
* FIXME: These Getters are mis-leading and does not favor
......@@ -68,21 +64,21 @@ namespace corsika {
*
* @return fTimeLike
*/
TimeType GetTimeLikeComponent() const ;
TimeType GetTimeLikeComponent() const;
/**
* @brief
*
* @return fSpaceLike
*/
SpaceVecType& GetSpaceLikeComponents() ;
SpaceVecType& GetSpaceLikeComponents();
/**
* @brief
*
* @return fSpaceLike;
*/
const SpaceVecType& GetSpaceLikeComponents() const ;
const SpaceVecType& GetSpaceLikeComponents() const;
/**
* @brief
......@@ -98,7 +94,6 @@ namespace corsika {
*/
SpaceType GetNorm() const;
/*
* FIXME: a better alternative would be to define an enumeration
* enum { SpaceLike =-1, TimeLike, LightLike } V4R_Category;
......@@ -118,7 +113,6 @@ namespace corsika {
*/
bool IsSpacelike() const;
FourVector& operator+=(const FourVector& b);
FourVector& operator-=(const FourVector& b);
......@@ -135,11 +129,9 @@ namespace corsika {
for this. You cannot mix different conventions due to
unit-checking.
*/
SpaceType operator*(const FourVector& b) ;
SpaceType operator*(const FourVector& b);
protected:
//! the data members
TimeType fTimeLike;
SpaceVecType fSpaceLike;
......@@ -161,46 +153,48 @@ namespace corsika {
friend FourVector<typename std::decay<T>::type, typename std::decay<U>::type>
operator/(const FourVector<T, U>&, const double);
private:
private:
/**
This function is automatically compiled to use of ignore the
extra factor of "c" for the time-like quantity
*/
auto GetTimeSquared() const ;
auto GetTimeSquared() const;
};
/**
The math operator+
*/
template <typename TimeType, typename SpaceVecType>
inline FourVector<typename std::decay<TimeType>::type, typename std::decay<SpaceVecType>::type>
operator+(const FourVector<TimeType, SpaceVecType>& a, const FourVector<TimeType, SpaceVecType>& b) ;
inline FourVector<typename std::decay<TimeType>::type,
typename std::decay<SpaceVecType>::type>
operator+(const FourVector<TimeType, SpaceVecType>& a,
const FourVector<TimeType, SpaceVecType>& b);
/**
The math operator-
*/
template <typename TimeType, typename SpaceVecType>
inline FourVector<typename std::decay<TimeType>::type, typename std::decay<SpaceVecType>::type>
operator-(const FourVector<TimeType, SpaceVecType>& a, const FourVector<TimeType, SpaceVecType>& b) ;
inline FourVector<typename std::decay<TimeType>::type,
typename std::decay<SpaceVecType>::type>
operator-(const FourVector<TimeType, SpaceVecType>& a,
const FourVector<TimeType, SpaceVecType>& b);
/**
The math operator*
FIXME: Add overload to deal with multiplication by a scalar and 3-vectors
*/
template <typename TimeType, typename SpaceVecType>
inline FourVector<typename std::decay<TimeType>::type, typename std::decay<SpaceVecType>::type>
operator*(const FourVector<TimeType, SpaceVecType>& a, const double b) ;
inline FourVector<typename std::decay<TimeType>::type,
typename std::decay<SpaceVecType>::type>
operator*(const FourVector<TimeType, SpaceVecType>& a, const double b);
/**
The math operator/
*/
template <typename TimeType, typename SpaceVecType>
inline FourVector<typename std::decay<TimeType>::type,typename std::decay<SpaceVecType>::type>
operator/(const FourVector<TimeType, SpaceVecType>& a, const double b) ;
inline FourVector<typename std::decay<TimeType>::type,
typename std::decay<SpaceVecType>::type>
operator/(const FourVector<TimeType, SpaceVecType>& a, const double b);
} // namespace corsika
......
......@@ -38,9 +38,8 @@ namespace corsika {
corsika::units::si::LengthType const radius;
public:
Helix(Point const& pR0, units::si::FrequencyType pOmegaC,
VelocityVec const& pvPar, VelocityVec const& pvPerp)
Helix(Point const& pR0, units::si::FrequencyType pOmegaC, VelocityVec const& pvPar,
VelocityVec const& pvPerp)
: r0(pR0)
, omegaC(pOmegaC)
, vPar(pvPar)
......@@ -48,17 +47,16 @@ namespace corsika {
, uPerp(vPerp.cross(vPar.normalized()))
, radius(pvPar.norm() / abs(pOmegaC)) {}
inline Point GetPosition(units::si::TimeType t) const ;
inline Point PositionFromArclength(units::si::LengthType l) const ;
inline Point GetPosition(units::si::TimeType t) const;
inline units::si::LengthType GetRadius() const ;
inline Point PositionFromArclength(units::si::LengthType l) const;
inline units::si::LengthType
ArcLength(units::si::TimeType t1, units::si::TimeType t2) const ;
inline units::si::LengthType GetRadius() const;
inline units::si::TimeType TimeFromArclength(units::si::LengthType l) const ;
inline units::si::LengthType ArcLength(units::si::TimeType t1,
units::si::TimeType t2) const;
inline units::si::TimeType TimeFromArclength(units::si::LengthType l) const;
};
} // namespace corsika
......
......@@ -32,23 +32,22 @@ namespace corsika {
VelocityVec const v0;
public:
Line(Point const& pR0, VelocityVec const& pV0)
: r0(pR0)
, v0(pV0) {}
inline Point GetPosition(units::si::TimeType t) const ;
inline Point PositionFromArclength(units::si::LengthType l) const ;
inline Point GetPosition(units::si::TimeType t) const;
inline units::si::LengthType ArcLength(units::si::TimeType t1, units::si::TimeType t2) const ;
inline Point PositionFromArclength(units::si::LengthType l) const;
inline units::si::TimeType TimeFromArclength( units::si::LengthType t) const ;
inline units::si::LengthType ArcLength(units::si::TimeType t1,
units::si::TimeType t2) const;
inline const Point& GetR0() const ;
inline units::si::TimeType TimeFromArclength(units::si::LengthType t) const;
inline const VelocityVec& GetV0() const ;
inline const Point& GetR0() const;
inline const VelocityVec& GetV0() const;
};
} // namespace corsika
......
......@@ -8,9 +8,9 @@
#pragma once
#include <corsika/framework/core/PhysicalUnits.hpp>
#include <corsika/framework/geometry/Point.hpp>
#include <corsika/framework/geometry/Vector.hpp>
#include <corsika/framework/core/PhysicalUnits.hpp>
namespace corsika {
......@@ -22,23 +22,19 @@ namespace corsika {
DimLessVec const fNormal;
public:
Plane(Point const& vCenter, DimLessVec const& vNormal)
: fCenter(vCenter)
, fNormal(vNormal.normalized()) {}
bool IsAbove(Point const& vP) const ;
bool IsAbove(Point const& vP) const;
units::si::LengthType DistanceTo(corsika::Point const& vP) const ;
units::si::LengthType DistanceTo(corsika::Point const& vP) const;
Point const& GetCenter() const;
Point const& GetCenter() const ;
DimLessVec const& GetNormal() const ;
DimLessVec const& GetNormal() const;
};
} // namespace corsika
#include <corsika/detail/framework/geometry/Plane.inl>
......@@ -8,14 +8,14 @@
#pragma once
#include <corsika/framework/geometry/QuantityVector.hpp>
#include <corsika/framework/core/PhysicalUnits.hpp>
#include <corsika/framework/geometry/BaseVector.hpp>
#include <corsika/framework/geometry/QuantityVector.hpp>
#include <corsika/framework/geometry/Vector.hpp>
namespace corsika {
//FIXME: remove aliasing here
// FIXME: remove aliasing here
using corsika::units::si::length_d;
using corsika::units::si::LengthType;
......@@ -26,7 +26,6 @@ namespace corsika {
class Point : public BaseVector<length_d> {
public:
Point(CoordinateSystem const& pCS, QuantityVector<length_d> pQVector)
: BaseVector<length_d>(pCS, pQVector) {}
......@@ -35,30 +34,29 @@ namespace corsika {
// TODO: this should be private or protected, we don NOT want to expose numbers
// without reference to outside:
inline auto GetCoordinates() const ;
inline auto GetCoordinates() const;
inline auto GetX() const ;
inline auto GetX() const;
inline auto GetY() const ;
inline auto GetY() const;
inline auto GetZ() const ;
inline auto GetZ() const;
/// this always returns a QuantityVector as triple
inline auto GetCoordinates(CoordinateSystem const& pCS) const ;
inline auto GetCoordinates(CoordinateSystem const& pCS) const;
/*!
* transforms the Point into another CoordinateSystem by changing its
* coordinates interally
*/
inline void rebase(CoordinateSystem const& pCS) ;
inline void rebase(CoordinateSystem const& pCS);
inline Point operator+(Vector<length_d> const& pVec) const ;
inline Point operator+(Vector<length_d> const& pVec) const;
/*!
* returns the distance Vector between two points
*/
inline Vector<length_d> operator-(Point const& pB) const ;
inline Vector<length_d> operator-(Point const& pB) const;
};
} // namespace corsika
......
......@@ -10,9 +10,9 @@
#include <Eigen/Dense>
#include <corsika/framework/core/PhysicalUnits.hpp>
#include <iostream>
#include <utility>
#include <corsika/framework/core/PhysicalUnits.hpp>
namespace corsika {
......@@ -46,46 +46,45 @@ namespace corsika {
QuantityVector(Eigen::Vector3d pBareVector)
: eVector(pBareVector) {}
auto operator[](size_t index) const ;