IAP GITLAB

Skip to content
Snippets Groups Projects
Commit 99697d4b authored by Remy Prechelt's avatar Remy Prechelt Committed by ralfulrich
Browse files

Rework ObservationPlane into old-style with ParticleWriter.

parent 5c911754
No related branches found
No related tags found
1 merge request!371Additional outputs ported to new architecture
......@@ -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);
}
......
......@@ -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
......
......@@ -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_;
......
......@@ -9,16 +9,15 @@
#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 {
class WriterOff : public BaseOutput {
public:
ParticleWriterOff() {}
virtual ~ParticleWriterOff() {}
WriterOff() {}
virtual ~WriterOff() {}
void startOfLibrary(boost::filesystem::path const&) final override {}
......@@ -26,14 +25,9 @@ namespace corsika {
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) {}
template <typename... TArgs>
void write(TArgs&&... args) {}
}; // class ParticleWriterOff
}; // class WriterOff
} // namespace corsika
......@@ -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.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment