IAP GITLAB

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

Add z-coordinate to ParticleWriter.

parent 8502abaf
No related branches found
No related tags found
No related merge requests found
......@@ -55,11 +55,11 @@ namespace corsika {
if (pid == Code::Nucleus) {
// add our particles to the output file stream
output_.write(particle.getNuclearA(), particle.getNuclearZ(), energy,
displacement.dot(xAxis_), displacement.dot(yAxis_), weight);
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_),
displacement.dot(yAxis_), weight);
displacement.dot(yAxis_), 0_m, weight);
}
CORSIKA_LOG_TRACE("Particle detected absorbed={}", deleteOnHit_);
......
......@@ -15,7 +15,7 @@ namespace corsika {
inline ParticleWriterParquet::ParticleWriterParquet()
: output_()
, showerId_(0)
, energyGround_(0_eV) {}
, totalEnergy_(0_eV) {}
inline void ParticleWriterParquet::startOfLibrary(
boost::filesystem::path const& directory) {
......@@ -35,6 +35,10 @@ namespace corsika {
parquet::ConvertedType::NONE);
output_.addField("y", parquet::Repetition::REQUIRED, parquet::Type::FLOAT,
parquet::ConvertedType::NONE);
output_.addField("z", parquet::Repetition::REQUIRED, parquet::Type::FLOAT,
parquet::ConvertedType::NONE);
output_.addField("z", parquet::Repetition::REQUIRED, parquet::Type::FLOAT,
parquet::ConvertedType::NONE);
output_.addField("weight", parquet::Repetition::REQUIRED, parquet::Type::FLOAT,
parquet::ConvertedType::NONE);
......@@ -42,7 +46,7 @@ namespace corsika {
output_.buildStreamer();
showerId_ = 0;
energyGround_ = 0_eV;
totalEnergy_ = 0_eV;
countHadrons_ = 0;
countOthers_ = 0;
countEM_ = 0;
......@@ -59,15 +63,17 @@ namespace corsika {
inline void ParticleWriterParquet::write(Code const& pid, HEPEnergyType const& energy,
LengthType const& x, LengthType const& y,
LengthType const& z,
double const weight) {
// write the next row - we must write `shower_` first.
*(output_.getWriter()) << showerId_ << static_cast<int>(get_PDG(pid))
<< static_cast<float>(energy / 1_GeV)
<< static_cast<float>(x / 1_m) << static_cast<float>(y / 1_m)
<< static_cast<float>(z / 1_m)
<< static_cast<float>(weight) << parquet::EndRow;
energyGround_ += energy;
totalEnergy_ += energy;
if (is_hadron(pid)) {
++countHadrons_;
......@@ -83,13 +89,15 @@ namespace corsika {
inline void ParticleWriterParquet::write(unsigned int const A, unsigned int const Z,
HEPEnergyType const& energy,
LengthType const& x, LengthType const& y,
LengthType const& z,
double const weight) {
// write the next row - we must write `shower_` first.
*(output_.getWriter()) << showerId_ << static_cast<int>(get_PDG(A, Z))
<< static_cast<float>(energy / 1_GeV)
<< static_cast<float>(x / 1_m) << static_cast<float>(y / 1_m)
<< static_cast<float>(z / 1_m)
<< static_cast<float>(weight) << parquet::EndRow;
energyGround_ += energy;
totalEnergy_ += energy;
++countHadrons_;
}
......
......@@ -27,12 +27,12 @@ namespace corsika {
void endOfLibrary() final override {}
// for pdg particles
void write(Code const&, HEPEnergyType const&, LengthType const&, LengthType const&,
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&, double const) {}
LengthType const&, LengthType const&, LengthType const&, double const) {}
}; // class ParticleWriterOff
......
......@@ -51,6 +51,7 @@ namespace corsika {
*/
void write(Code const& pid, units::si::HEPEnergyType const& energy,
units::si::LengthType const& x, units::si::LengthType const& y,
units::si::LengthType const& z,
const double weight);
/**
......@@ -58,7 +59,7 @@ namespace corsika {
*/
void write(unsigned int const A, unsigned int const Z,
units::si::HEPEnergyType const& energy, units::si::LengthType const& x,
units::si::LengthType const& y, const double weight);
units::si::LengthType const& y, units::si::LengthType const& z, const double weight);
/**
* Return collected library-level summary for output.
......@@ -68,7 +69,7 @@ namespace corsika {
/**
* If plane is absorbing particles: return the total energy absorbed.
*/
HEPEnergyType getEnergyGround() const { return energyGround_; }
HEPEnergyType getTotalEnergy() const { return totalEnergy_; }
private:
ParquetStreamer output_; ///< The primary output file.
......@@ -79,7 +80,7 @@ namespace corsika {
double countEM_ = 0; ///< count EM particles hitting plane.
double countOthers_ = 0; ///< count othe types of particles hitting plane
HEPEnergyType energyGround_; ///< energy absorbed in ground.
HEPEnergyType totalEnergy_; ///< energy absorbed in ground.
}; // class ParticleWriterParquet
......
......@@ -21,7 +21,7 @@ struct TestWriterPlane : public ParticleWriterParquet {
YAML::Node getConfig() const { return YAML::Node(); }
void checkWrite() { ParticleWriterParquet::write(Code::Unknown, 1_eV, 2_m, 3_m, 1.0); }
void checkWrite() { ParticleWriterParquet::write(Code::Unknown, 1_eV, 2_m, 3_m, 0_m, 1.0); }
};
TEST_CASE("ObservationPlaneWriterParquet") {
......
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