diff --git a/Documentation/Examples/vertical_EAS.cc b/Documentation/Examples/vertical_EAS.cc index 79f3d7ea0e41f7db75de2da60632bac328b86253..01c5d7382d0de1f83c775b774e52bec071f1f8cb 100644 --- a/Documentation/Examples/vertical_EAS.cc +++ b/Documentation/Examples/vertical_EAS.cc @@ -214,8 +214,7 @@ int main(int argc, char** argv) { process::longitudinal_profile::LongitudinalProfile longprof{showerAxis}; Plane const obsPlane(showerCore, Vector<dimensionless_d>(rootCS, {0., 0., 1.})); - process::observation_plane::ObservationPlane observationLevel(obsPlane, false, - "particles"); + process::observation_plane::ObservationPlane observationLevel(obsPlane, false); // register the observation plane with the manager outputs.Register("obsplane", observationLevel); diff --git a/Outputs/ObservationPlaneWriterParquet.h b/Outputs/ObservationPlaneWriterParquet.h index 7a87709e2779ef4b04917d514679f76d8047f820..89e1fef1940f71a96eda5a5b335c1cd9a91a0352 100644 --- a/Outputs/ObservationPlaneWriterParquet.h +++ b/Outputs/ObservationPlaneWriterParquet.h @@ -23,9 +23,8 @@ namespace corsika::output { * * @param name The name of this output. */ - ObservationPlaneWriterParquet(std::string const& name) + ObservationPlaneWriterParquet() : ParquetStreamer() - , name_(name) , event_(0){}; /** @@ -48,7 +47,6 @@ namespace corsika::output { // and build the streamer BuildStreamer(); - } /** @@ -64,7 +62,7 @@ namespace corsika::output { /** * Called at the end of each run. */ - void EndOfRun() final { writer_.reset(); outfile_->Close(); } + void EndOfRun() final { CloseStreamer(); } /** * Get final text outputs for the config file. @@ -84,8 +82,6 @@ namespace corsika::output { << distance / 1_m << parquet::EndRow; } - std::string const name_; ///< The name of this output. - private: int event_; ///< The current event number we are processing. diff --git a/Outputs/OutputManager.h b/Outputs/OutputManager.h index 2a1af4760d11164be95374ed33aa195b55b4fcb6..e8a38022b57c1aff46b2c94b9e25f7362440ad19 100644 --- a/Outputs/OutputManager.h +++ b/Outputs/OutputManager.h @@ -86,8 +86,14 @@ namespace corsika::output { // create the directory for this process. std::filesystem::create_directory(path); + // get the config for this output + auto config = outputs_.at(name).get().GetConfig(); + + // and assign the name for this output + config["name"] = name; + // write the config for this output to the file - WriteNode(outputs_.at(name).get().GetConfig(), path / "config.yaml"); + WriteNode(config, path / "config.yaml"); } public: diff --git a/Outputs/ParquetStreamer.h b/Outputs/ParquetStreamer.h index d8352516881dacf53c2a61ba4d499d3dd4596459..4c2679e56f7f0a58b588c7ba670786a694b5e17d 100644 --- a/Outputs/ParquetStreamer.h +++ b/Outputs/ParquetStreamer.h @@ -63,10 +63,19 @@ namespace corsika::output { parquet::ParquetFileWriter::Open(outfile_, schema_, builder_.build())); } + /** + * Finish writing this stream. + * + */ + void CloseStreamer() { + writer_.reset(); + outfile_->Close(); + } + protected: - std::shared_ptr<parquet::StreamWriter> writer_; ///< The stream writer to 'outfile' - parquet::WriterProperties::Builder builder_; ///< The writer properties builder. - parquet::schema::NodeVector fields_; ///< The fields in this file. + std::shared_ptr<parquet::StreamWriter> writer_; ///< The stream writer to 'outfile' + parquet::WriterProperties::Builder builder_; ///< The writer properties builder. + parquet::schema::NodeVector fields_; ///< The fields in this file. std::shared_ptr<parquet::schema::GroupNode> schema_; ///< The schema for this file. std::shared_ptr<arrow::io::FileOutputStream> outfile_; ///< The output file. diff --git a/Processes/ObservationPlane/ObservationPlane.h b/Processes/ObservationPlane/ObservationPlane.h index b2dff07ed09ac72a756aa858af6835a27fdc3388..1b797d0957c122e157d465c797aaf91d3b569dd4 100644 --- a/Processes/ObservationPlane/ObservationPlane.h +++ b/Processes/ObservationPlane/ObservationPlane.h @@ -94,7 +94,6 @@ namespace corsika::process::observation_plane { YAML::Node node; // basic info - node["name"] = this->name_; node["type"] = "ObservationPlane"; // the center of the plane