From 0093a3249521a58a7d164c694385aec0df7820bd Mon Sep 17 00:00:00 2001 From: Maximilian Reininghaus <maximilian.reininghaus@kit.edu> Date: Fri, 21 Dec 2018 19:08:07 +0100 Subject: [PATCH] implemented TrackWriter --- Framework/Geometry/Trajectory.h | 4 ++ Processes/CMakeLists.txt | 1 + Processes/TrackWriter/CMakeLists.txt | 65 ++++++++++++++++++++++++++++ Processes/TrackWriter/TrackWriter.cc | 13 ++++++ Processes/TrackWriter/TrackWriter.h | 58 +++++++++++++++++++++++++ 5 files changed, 141 insertions(+) create mode 100644 Processes/TrackWriter/CMakeLists.txt create mode 100644 Processes/TrackWriter/TrackWriter.cc create mode 100644 Processes/TrackWriter/TrackWriter.h diff --git a/Framework/Geometry/Trajectory.h b/Framework/Geometry/Trajectory.h index 5a9d1ed56..d338119fd 100644 --- a/Framework/Geometry/Trajectory.h +++ b/Framework/Geometry/Trajectory.h @@ -43,6 +43,10 @@ namespace corsika::geometry { assert(t >= 0 * corsika::units::si::second); return T::ArcLength(0, t); } + + void LimitEndTo(corsika::units::si::LengthType limit) { + fTimeLength = T::TimeFromArclength(limit); + } }; } // namespace corsika::geometry diff --git a/Processes/CMakeLists.txt b/Processes/CMakeLists.txt index 41a8277d9..d6b90e70e 100644 --- a/Processes/CMakeLists.txt +++ b/Processes/CMakeLists.txt @@ -2,6 +2,7 @@ add_subdirectory (NullModel) add_subdirectory (Sibyll) add_subdirectory (StackInspector) +add_subdirectory (TrackWriter) add_subdirectory (TrackingLine) #add_custom_target(CORSIKAprocesses) diff --git a/Processes/TrackWriter/CMakeLists.txt b/Processes/TrackWriter/CMakeLists.txt new file mode 100644 index 000000000..e9c73d68b --- /dev/null +++ b/Processes/TrackWriter/CMakeLists.txt @@ -0,0 +1,65 @@ + +set ( + MODEL_SOURCES + TrackWriter.cc + ) + +set ( + MODEL_HEADERS + TrackWriter.h + ) + +set ( + MODEL_NAMESPACE + corsika/process/track_writer + ) + +add_library (ProcessTrackWriter STATIC ${MODEL_SOURCES}) +CORSIKA_COPY_HEADERS_TO_NAMESPACE (ProcessTrackWriter ${MODEL_NAMESPACE} ${MODEL_HEADERS}) + +set_target_properties ( + ProcessTrackWriter + PROPERTIES + VERSION ${PROJECT_VERSION} + SOVERSION 1 +# PUBLIC_HEADER "${MODEL_HEADERS}" + ) + +# target dependencies on other libraries (also the header onlys) +target_link_libraries ( + ProcessTrackWriter + CORSIKAunits + CORSIKAparticles + CORSIKAgeometry + CORSIKAsetup + ) + +target_include_directories ( + ProcessTrackWriter + INTERFACE + $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include> + $<INSTALL_INTERFACE:include/include> + ) + +install ( + TARGETS ProcessTrackWriter + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib +# PUBLIC_HEADER DESTINATION include/${MODEL_NAMESPACE} + ) + + +# -------------------- +# code unit testing +#add_executable (testNullModel testNullModel.cc) + +#target_link_libraries ( +# testNullModel ProcessNullModel +# CORSIKAsetup +# CORSIKAgeometry +# CORSIKAunits +# CORSIKAthirdparty # for catch2 +# ) + +#add_test (NAME testNullModel COMMAND testNullModel) + diff --git a/Processes/TrackWriter/TrackWriter.cc b/Processes/TrackWriter/TrackWriter.cc new file mode 100644 index 000000000..ef15c3d2d --- /dev/null +++ b/Processes/TrackWriter/TrackWriter.cc @@ -0,0 +1,13 @@ +/** + * (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu + * + * See file AUTHORS for a list of contributors. + * + * 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. + */ + +#include <corsika/process/track_writer/TrackWriter.h> + +void corsika::process::TrackWriter::TrackWriter::Init() { fFile.open(fFilename); } diff --git a/Processes/TrackWriter/TrackWriter.h b/Processes/TrackWriter/TrackWriter.h new file mode 100644 index 000000000..b86ae5ed3 --- /dev/null +++ b/Processes/TrackWriter/TrackWriter.h @@ -0,0 +1,58 @@ +/** + * (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu + * + * See file AUTHORS for a list of contributors. + * + * 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. + */ + +#ifndef _Processes_TrackWriter_h_ +#define _Processes_TrackWriter_h_ + +#include <corsika/particles/ParticleProperties.h> +#include <corsika/process/ContinuousProcess.h> +#include <corsika/setup/SetupTrajectory.h> +#include <corsika/units/PhysicalUnits.h> +#include <fstream> +#include <limits> +#include <string> + +namespace corsika::process::TrackWriter { + + class TrackWriter : public corsika::process::ContinuousProcess<TrackWriter> { + + public: + TrackWriter(std::string const& filename) + : fFilename(filename) {} + + void Init(); + + template <typename Particle, typename Track, typename Stack> + corsika::process::EProcessReturn DoContinuous(Particle& p, Track& t, Stack&) const { + using namespace corsika::units::si; + auto const start = t.GetPosition(0).GetCoordinates(); + auto const delta = t.GetPosition(1).GetCoordinates() - start; + auto const& name = corsika::particles::GetName(p.GetPID()); + + std::cerr << name << " " << start[0] / 1_m << ' ' << start[1] / 1_m << ' ' + << start[2] / 1_m << " " << delta[0] / 1_m << ' ' << delta[1] / 1_m + << ' ' << delta[2] / 1_m << '\n'; + + return corsika::process::EProcessReturn::eOk; + } + + template <typename Particle, typename Track> + corsika::units::si::LengthType MaxStepLength(Particle&, Track&) const { + return corsika::units::si::meter * std::numeric_limits<double>::infinity(); + } + + private: + std::string const fFilename; + std::ofstream fFile; + }; + +} // namespace corsika::process::TrackWriter + +#endif -- GitLab