diff --git a/corsika/detail/modules/ObservationPlane.inl b/corsika/detail/modules/ObservationPlane.inl index 4a9efbca6fb1a99c03b11212edbf19da08537a33..0d2ea0639db1c7f7f877d3ad2a3a9c8ae6d59d65 100644 --- a/corsika/detail/modules/ObservationPlane.inl +++ b/corsika/detail/modules/ObservationPlane.inl @@ -11,9 +11,8 @@ namespace corsika { template <typename TOutput> ObservationPlane<TOutput>::ObservationPlane(Plane const& obsPlane, DirectionVector const& x_axis, - TOutput& output, bool deleteOnHit) + bool const deleteOnHit) : plane_(obsPlane) - , output_(output) , deleteOnHit_(deleteOnHit) , energy_ground_(0_GeV) , count_ground_(0) @@ -54,11 +53,11 @@ namespace corsika { Code const pid = particle.getPID(); if (pid == Code::Nucleus) { // add our particles to the output file stream - output_.write(particle.getNuclearA(), particle.getNuclearZ(), energy, + this->write(particle.getNuclearA(), particle.getNuclearZ(), energy, displacement.dot(xAxis_), displacement.dot(yAxis_), 0_m, weight); } else { // add our particles to the output file stream - output_.write(particle.getPID(), energy, displacement.dot(xAxis_), + this->write(particle.getPID(), energy, displacement.dot(xAxis_), displacement.dot(yAxis_), 0_m, weight); } diff --git a/corsika/detail/output/OutputManager.inl b/corsika/detail/output/OutputManager.inl index 2cc5e9780b9bab0bbab6d2c9fba5e45ec12115dd..82fe4cdb442626d3c3076ba3d615926c3d60358f 100644 --- a/corsika/detail/output/OutputManager.inl +++ b/corsika/detail/output/OutputManager.inl @@ -153,6 +153,15 @@ namespace corsika { // and start the library output.get().startOfLibrary(root_ / name); + + // get the config from this output + auto config = output.get().getConfig(); + + // add the name keyword + config["name"] = name; + + // write the output configuration to config.yaml in the output directory + writeYAML(config, root_ / name / ("config.yaml")); } // we have now started running diff --git a/corsika/modules/ObservationPlane.hpp b/corsika/modules/ObservationPlane.hpp index bf1798c18efb04932b2834e8833bae487bb5b506..b2c276ee64abcf89a58d84be2b7a184a178b7930 100644 --- a/corsika/modules/ObservationPlane.hpp +++ b/corsika/modules/ObservationPlane.hpp @@ -36,16 +36,9 @@ namespace corsika { public TOutputWriter { public: - ObservationPlane(Plane const&, DirectionVector const&, TOutput& output, bool = true); + ObservationPlane(Plane const&, DirectionVector const&, bool const = true); - ObservationPlane(Plane const& p, DirectionVector const& d, bool f = true) - : ObservationPlane(p, d, *(new ParticleWriterOff()), f) { - ownOutput_ = true; - } - - ~ObservationPlane() { - if (ownOutput_) delete &output_; - } + ~ObservationPlane() {} template <typename TParticle, typename TTrajectory> ProcessReturn doContinuous(TParticle& vParticle, TTrajectory& vTrajectory, @@ -61,8 +54,6 @@ namespace corsika { private: Plane const plane_; - TOutput& output_; - bool ownOutput_ = false; bool const deleteOnHit_; HEPEnergyType energy_ground_; unsigned int count_ground_; diff --git a/corsika/modules/writers/ParticleWriterOff.hpp b/corsika/modules/writers/ParticleWriterOff.hpp deleted file mode 100644 index 27a6ab76328c370584a0e212273b785bd713d0a9..0000000000000000000000000000000000000000 --- a/corsika/modules/writers/ParticleWriterOff.hpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * (c) Copyright 2021 CORSIKA Project, corsika-project@lists.kit.edu - * - * This software is distributed under the terms of the GNU General Public - * Licence version 3 (GPL Version 3). See file LICENSE for a full version of - * the license. - */ - -#pragma once - -#include <corsika/output/BaseOutput.hpp> -#include <corsika/framework/core/PhysicalUnits.hpp> -#include <corsika/framework/core/ParticleProperties.hpp> - -namespace corsika { - - class ParticleWriterOff : public BaseOutput { - - public: - ParticleWriterOff() {} - virtual ~ParticleWriterOff() {} - - void startOfLibrary(boost::filesystem::path const&) final override {} - - void endOfShower(unsigned int const) final override {} - - void endOfLibrary() final override {} - - // for pdg particles - void write(Code const&, HEPEnergyType const&, LengthType const&, LengthType const&, LengthType const&, - double const) {} - - // for nuclei - void write(unsigned int const, unsigned int const, HEPEnergyType const&, - LengthType const&, LengthType const&, LengthType const&, double const) {} - - }; // class ParticleWriterOff - -} // namespace corsika diff --git a/corsika/modules/writers/WriterOff.hpp b/corsika/modules/writers/WriterOff.hpp new file mode 100644 index 0000000000000000000000000000000000000000..783507a481a2f02da5523d6d77a6e8ca0b5d5be4 --- /dev/null +++ b/corsika/modules/writers/WriterOff.hpp @@ -0,0 +1,33 @@ +/* + * (c) Copyright 2021 CORSIKA Project, corsika-project@lists.kit.edu + * + * This software is distributed under the terms of the GNU General Public + * Licence version 3 (GPL Version 3). See file LICENSE for a full version of + * the license. + */ + +#pragma once + +#include <corsika/output/BaseOutput.hpp> + + +namespace corsika { + + class WriterOff : public BaseOutput { + + public: + WriterOff() {} + virtual ~WriterOff() {} + + void startOfLibrary(boost::filesystem::path const&) final override {} + + void endOfShower(unsigned int const) final override {} + + void endOfLibrary() final override {} + + template <typename... TArgs> + void write(TArgs&&... args) {} + + }; // class WriterOff + +} // namespace corsika diff --git a/corsika/output/BaseOutput.hpp b/corsika/output/BaseOutput.hpp index 8581f1fa4a612f6aee71246ccdbd8d9215bf2e3a..435519a2c89937636214eacdc703516ecba80fa0 100644 --- a/corsika/output/BaseOutput.hpp +++ b/corsika/output/BaseOutput.hpp @@ -63,6 +63,11 @@ namespace corsika { */ virtual YAML::Node getSummary() const { return YAML::Node(); } + /** + * Provide YAML configuration for this BaseOutput. + */ + virtual YAML::Node getConfig() const = 0; + protected: /** * Set init flag.