CORSIKA  @c8_version@
The framework to simulate particle cascades for astroparticle physics
LongitudinalWriter.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/LongitudinalProfileWriterParquet.hpp>
17 
18 #include <vector>
19 #include <array>
20 
25 namespace corsika {
26 
30  namespace number_profile {
31 
35  enum class ProfileIndex {
36  Charged,
37  Hadron,
38  Photon,
39  Electron,
40  Positron,
41  MuPlus,
42  MuMinus,
43  Entries
44  };
45 
49  size_t constexpr NColumns = static_cast<size_t>(ProfileIndex::Entries);
50 
54  static std::array<char const*, NColumns> constexpr ProfileIndexNames{
55  {"charged", "hadron", "photon", "electron", "positron", "muplus", "muminus"}};
56 
60  typedef std::array<double, NColumns> ProfileData;
61  } // namespace number_profile
62 
63  // clang-format-off
88  // clang-format-on
89 
90  template <typename TOutput = LongitudinalProfileWriterParquet<number_profile::NColumns>>
91  class LongitudinalWriter : public TOutput {
92 
93  public:
97  LongitudinalWriter(ShowerAxis const& axis,
98  GrammageType dX = 10_g / square(1_cm)); // profile binning
99 
100  LongitudinalWriter(ShowerAxis const& axis, size_t nbins,
101  GrammageType dX = 10_g / square(1_cm));
102 
103  void startOfLibrary(boost::filesystem::path const& directory) final override;
104 
105  void startOfShower(unsigned int const showerId) final override;
106 
107  void endOfShower(unsigned int const showerId) final override;
108 
109  void endOfLibrary() final override;
110 
114  void write(Point const& p0, Point const& p1, Code const pid, double const weight);
115 
119  void write(GrammageType const Xstart, GrammageType const Xend, Code const pid,
120  double const weight);
121 
125  YAML::Node getSummary() const;
126 
130  YAML::Node getConfig() const;
131 
132  number_profile::ProfileData const& getProfile(
133  number_profile::ProfileIndex index) const {
134  return profile_.at(static_cast<int>(index));
135  }
136 
137  private:
138  ShowerAxis const& showerAxis_;
139  GrammageType const dX_;
140  size_t const nBins_;
141  std::vector<number_profile::ProfileData> profile_; // longitudinal profile
142  };
143 
144 } // namespace corsika
145 
146 #include <corsika/detail/modules/writers/LongitudinalWriter.inl>
size_t constexpr NColumns
Number of columns (static).
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.
std::array< double, NColumns > ProfileData
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.
Interface to particle properties.
The LongitudinalWriter can be used to pool the particle counts of several longitudinal profile proces...