CORSIKA  @c8_version@
The framework to simulate particle cascades for astroparticle physics
Step.hpp
1 /*
2  * (c) Copyright 2022 CORSIKA Project, corsika-project@lists.kit.edu
3  *
4  * This software is distributed under the terms of the GNU General Public
5  * Licence version 3 (GPL Version 3). See file LICENSE for a full version of
6  * the license.
7  */
8 
9 #pragma once
10 
12 #include <corsika/framework/core/PhysicalGeometry.hpp>
13 #include <corsika/framework/geometry/Vector.hpp>
14 #include <corsika/framework/geometry/Point.hpp>
15 #include <corsika/framework/geometry/StraightTrajectory.hpp>
16 
17 namespace corsika {
18 
20  public:
22  DirectionVector const& du)
23  : delta_Ekin_{dEkin}
24  , delta_time_{dT}
25  , displacement_{ds}
26  , delta_direction_{du} {}
27 
28  HEPEnergyType delta_Ekin_ = HEPEnergyType::zero();
29  TimeType delta_time_ = TimeType::zero();
30  LengthVector displacement_;
31  DirectionVector delta_direction_;
32  };
33 
34  template <typename TParticle>
35  class Step {
36  public:
37  template <typename TTrajectory>
38  Step(TParticle const& particle, TTrajectory const& track)
39  : particlePreStep_{particle} //~ , track_{track}
40  , diff_{HEPEnergyType::zero(), track.getDuration(1),
41  track.getPosition(1) - particle.getPosition(),
42  track.getDirection(1) - particle.getDirection()}
43 
44  {}
45 
46  HEPEnergyType const& add_dEkin(HEPEnergyType dEkin) {
47  diff_.delta_Ekin_ += dEkin;
48  return diff_.delta_Ekin_;
49  }
50 
51  TimeType const& add_dt(TimeType dt) {
52  diff_.delta_time_ += dt;
53  return diff_.delta_time_;
54  }
55 
56  LengthVector const& add_displacement(LengthVector const& dis) {
57  diff_.displacement_ += dis;
58  return diff_.displacement_;
59  }
60 
61  DirectionVector const& add_dU(DirectionVector const& du) {
62  diff_.delta_direction_ += du;
63  return diff_.delta_direction_;
64  }
65 
66  // getters for difference
67 
68  HEPEnergyType getDiffEkin() const { return diff_.delta_Ekin_; }
69 
70  TimeType getDiffT() const { return diff_.delta_time_; };
71 
72  DirectionVector const& getDiffDirection() const { return diff_.delta_direction_; }
73 
74  LengthVector const& getDisplacement() const { return diff_.displacement_; }
75 
77  LengthVector const& getDiffPosition() const { return getDisplacement(); }
78 
79  // getters for absolute
80  TParticle const& getParticlePre() const { return particlePreStep_; }
81 
82  HEPEnergyType getEkinPre() const { return getParticlePre().getKineticEnergy(); }
83 
84  HEPEnergyType getEkinPost() const { return getEkinPre() + getDiffEkin(); }
85 
86  TimeType getTimePre() const { return getParticlePre().getTime(); }
87 
88  TimeType getTimePost() const { return getTimePre() + getDiffT(); }
89 
90  DirectionVector const getDirectionPre() const {
91  return getParticlePre().getDirection();
92  }
93 
94  VelocityVector getVelocityVector() const { return getDisplacement() / getDiffT(); }
95 
96  StraightTrajectory getStraightTrack() const {
97  Line const line(getPositionPre(), getVelocityVector());
98  StraightTrajectory track(line, getDiffT());
99  return track;
100  }
101 
102  DirectionVector getDirectionPost() const {
103  return (getDirectionPre() + getDiffDirection()).normalized();
104  }
105 
106  Point const& getPositionPre() const { return getParticlePre().getPosition(); }
107 
108  Point getPositionPost() const { return getPositionPre() + getDisplacement(); }
109 
110  private:
111  TParticle const& particlePreStep_;
112  //~ TTrajectory const& track_; // TODO: perhaps remove
113  DeltaParticleState diff_;
114  };
115 
116 } // namespace corsika
Import and extend the phys::units package.
A Line describes a movement in three dimensional space.
Definition: Line.hpp:27
LengthVector const & getDiffPosition() const
alias for getDisplacement()
Definition: Step.hpp:77
`, since they are used everywhere as integral part of the framework.
static constexpr quantity zero()
We need a "zero" of each type – for comparisons, to initialize running totals, etc.
Definition: quantity.hpp:359
This implements a straight trajectory between two points.