CORSIKA  @c8_version@
The framework to simulate particle cascades for astroparticle physics
EnergyLossWriter.hpp
Go to the documentation of this file.
1 /*
2  * (c) Copyright 2021 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 
11 #include <corsika/output/BaseOutput.hpp>
14 #include <corsika/media/ShowerAxis.hpp>
15 #include <corsika/modules/writers/WriterOff.hpp>
16 #include <corsika/modules/writers/EnergyLossWriterParquet.hpp>
17 
18 #include <vector>
19 #include <array>
20 
25 namespace corsika {
26 
27  // clang-format-off
53  // clang-format-on
54 
58  namespace dEdX_output {
59 
63  enum class ProfileIndex { Total, Entries };
64 
68  size_t constexpr NColumns = static_cast<int>(ProfileIndex::Entries);
69 
73  static std::array<char const*, NColumns> constexpr ProfileIndexNames{{"total"}};
74 
78  typedef std::array<HEPEnergyType, NColumns> Profile;
79 
80  } // namespace dEdX_output
81 
107  template <typename TOutput = EnergyLossWriterParquet<dEdX_output::NColumns>>
108  class EnergyLossWriter : public TOutput {
109 
110  public:
114  EnergyLossWriter(ShowerAxis const& axis,
115  GrammageType dX = 10_g / square(1_cm), // profile binning
116  unsigned int const nBins = 200, // number of bins
117  GrammageType dX_threshold = 0.0001_g /
118  square(1_cm)); // ignore too short tracks
119 
120  void startOfLibrary(boost::filesystem::path const& directory) final override;
121 
122  void startOfShower(unsigned int const showerId) final override;
123 
124  void endOfShower(unsigned int const showerId) final override;
125 
126  void endOfLibrary() final override;
127 
131  void write(Point const& p0, Point const& p1, Code const PID, HEPEnergyType const dE);
132 
136  void write(Point const& point, Code const PID, HEPEnergyType const dE);
137 
141  void write(GrammageType const Xstart, GrammageType const Xend, Code const PID,
142  HEPEnergyType const dE);
143 
149  HEPEnergyType getEnergyLost() const;
150 
154  YAML::Node getSummary() const;
155 
159  YAML::Node getConfig() const;
160 
161  private:
162  ShowerAxis const& showerAxis_;
163  GrammageType dX_;
164  size_t nBins_;
165  GrammageType dX_threshold_;
166  std::vector<dEdX_output::Profile> profile_; // longitudinal profile
167 
168  }; // namespace corsika
169 
170 } // namespace corsika
171 
172 #include <corsika/detail/modules/writers/EnergyLossWriter.inl>
The environment::ShowerAxis is created from a Point and a Vector and inside an Environment.
Definition: ShowerAxis.hpp:44
Import and extend the phys::units package.
ProfileIndex
Definition of longitudinal profile columns.
size_t constexpr NColumns
Number of columns (static).
std::array< HEPEnergyType, NColumns > Profile
Data type to store column data.
constexpr detail::Power< D, 2, X > square(quantity< D, X > const &x)
square.
Definition: quantity.hpp:650
`, since they are used everywhere as integral part of the framework.
The EnergyLossWriter can be used to pool the dEdX energy loss of several processes/modules into one o...
Interface to particle properties.