IAP GITLAB

Skip to content
Snippets Groups Projects
Commit b18d0dc0 authored by Maximilian Reininghaus's avatar Maximilian Reininghaus :vulcan:
Browse files

added ObservationPlane

parent ef16c7ac
No related branches found
No related tags found
1 merge request!133added ObservationPlane
...@@ -14,6 +14,7 @@ add_subdirectory (SwitchProcess) ...@@ -14,6 +14,7 @@ add_subdirectory (SwitchProcess)
# continuous physics # continuous physics
add_subdirectory (EnergyLoss) add_subdirectory (EnergyLoss)
add_subdirectory (TrackWriter) add_subdirectory (TrackWriter)
add_subdirectory (ObservationPlane)
# stack processes # stack processes
add_subdirectory (StackInspector) add_subdirectory (StackInspector)
# secondaries process # secondaries process
......
set (
MODEL_HEADERS
ObservationPlane.h
)
set (
MODEL_SOURCES
ObservationPlane.cc
)
set (
MODEL_NAMESPACE
corsika/process/observation_plane
)
add_library (ProcessObservationPlane STATIC ${MODEL_SOURCES})
CORSIKA_COPY_HEADERS_TO_NAMESPACE (ProcessObservationPlane ${MODEL_NAMESPACE} ${MODEL_HEADERS})
# target dependencies on other libraries (also the header onlys)
target_link_libraries (
ProcessObservationPlane
CORSIKAgeometry
CORSIKAprocesssequence
)
target_include_directories (
ProcessObservationPlane
INTERFACE
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>
$<INSTALL_INTERFACE:include/include>
)
install (FILES ${MODEL_HEADERS} DESTINATION include/${MODEL_NAMESPACE})
# --------------------
# code unit testing
#CORSIKA_ADD_TEST(testObservationPlane)
#target_link_libraries (
# testObservationPlane
# ProcessObservationPlane
# CORSIKAstackinterface
# CORSIKAthirdparty # for catch2
#)
/*
* (c) Copyright 2019 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/observation_plane/ObservationPlane.h>
#include <fstream>
using namespace corsika::process::observation_plane;
using namespace corsika::units::si;
ObservationPlane::ObservationPlane(geometry::Plane const& vObsPlane,
std::string const& vFilename)
: fObsPlane(vObsPlane)
, fOutputStream(vFilename) {
fOutputStream << "#PDG code, energy / eV, distance to center / m" << std::endl;
}
corsika::process::EProcessReturn ObservationPlane::DoContinuous(
setup::Stack::ParticleType const& vParticle, setup::Trajectory const& vTrajectory) {
if (fObsPlane.IsAbove(vTrajectory.GetPosition(1.0001))) {
return process::EProcessReturn::eOk;
}
fOutputStream << static_cast<int>(particles::GetPDG(vParticle.GetPID())) << ' '
<< vParticle.GetEnergy() * (1 / 1_eV) << ' '
<< (vTrajectory.GetPosition(1) - fObsPlane.GetCenter()).norm() / 1_m
<< std::endl;
return process::EProcessReturn::eParticleAbsorbed;
}
LengthType ObservationPlane::MaxStepLength(setup::Stack::ParticleType const&,
setup::Trajectory const& vTrajectory) {
if (!fObsPlane.IsAbove(vTrajectory.GetR0())) {
return std::numeric_limits<double>::infinity() * 1_m;
}
auto const pointOfIntersection = vTrajectory.GetPosition(
(fObsPlane.GetCenter() - vTrajectory.GetR0()).dot(fObsPlane.GetNormal()) /
vTrajectory.GetV0().dot(fObsPlane.GetNormal()));
return (vTrajectory.GetR0() - pointOfIntersection).norm();
}
/*
* (c) Copyright 2019 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_ObservationPlane_h_
#define _Processes_ObservationPlane_h_
#include <corsika/geometry/Plane.h>
#include <corsika/process/ContinuousProcess.h>
#include <corsika/setup/SetupStack.h>
#include <corsika/setup/SetupTrajectory.h>
#include <corsika/units/PhysicalUnits.h>
#include <fstream>
namespace corsika::process::observation_plane {
/**
* The ObservationPlane writes PDG codes, energies, and distances of particles to the
* central point of the plane into its output file. The particles are considered
* "absorbed" afterwards.
*/
class ObservationPlane : public corsika::process::ContinuousProcess<ObservationPlane> {
public:
ObservationPlane(geometry::Plane const& vObsPlane, std::string const& vFilename);
void Init() {}
corsika::process::EProcessReturn DoContinuous(
corsika::setup::Stack::ParticleType const& vParticle,
corsika::setup::Trajectory const& vTrajectory);
corsika::units::si::LengthType MaxStepLength(
corsika::setup::Stack::ParticleType const&,
corsika::setup::Trajectory const& vTrajectory);
private:
geometry::Plane const fObsPlane;
std::ofstream fOutputStream;
};
} // namespace corsika::process::observation_plane
#endif
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