IAP GITLAB

Skip to content
Snippets Groups Projects
Commit 70467c15 authored by Maximilian Sackel's avatar Maximilian Sackel Committed by Ralf Ulrich
Browse files

add flag if PROPOSAL can track the particle

parent 9397c1a9
No related branches found
No related tags found
1 merge request!245Include proposal process rebase
...@@ -15,6 +15,11 @@ SET_TARGET_PROPERTIES ( ProcessProposal PROPERTIES VERSION ${PROJECT_VERSION} ...@@ -15,6 +15,11 @@ SET_TARGET_PROPERTIES ( ProcessProposal PROPERTIES VERSION ${PROJECT_VERSION}
TARGET_LINK_LIBRARIES ( TARGET_LINK_LIBRARIES (
ProcessProposal ProcessProposal
CORSIKAparticles
CORSIKAutilities
CORSIKAunits
CORSIKAthirdparty
CORSIKAgeometry
CORSIKAenvironment CORSIKAenvironment
${PROPOSAL_LIBRARY} ${PROPOSAL_LIBRARY}
) )
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#include <corsika/environment/IMediumModel.h> #include <corsika/environment/IMediumModel.h>
#include <corsika/environment/NuclearComposition.h> #include <corsika/environment/NuclearComposition.h>
#include <corsika/process/proposal/Interaction.h> #include <corsika/process/proposal/Interaction.h>
#include <corsika/setup/SetupEnvironment.h>
#include <corsika/setup/SetupStack.h> #include <corsika/setup/SetupStack.h>
#include <corsika/setup/SetupTrajectory.h> #include <corsika/setup/SetupTrajectory.h>
#include <corsika/units/PhysicalUnits.h> #include <corsika/units/PhysicalUnits.h>
...@@ -14,12 +15,11 @@ ...@@ -14,12 +15,11 @@
#include <tuple> #include <tuple>
using Component_PROPOSAL = PROPOSAL::Components::Component; using Component_PROPOSAL = PROPOSAL::Components::Component;
namespace corsika::process::proposal {
namespace corsika::process::proposal {
using namespace corsika::setup; using namespace corsika::setup;
using namespace corsika::environment; using namespace corsika::environment;
using namespace corsika::units::si; using namespace corsika::units::si;
using SetupParticle = corsika::setup::Stack::StackIterator;
template <> template <>
std::unordered_map<particles::Code, PROPOSAL::ParticleDef> std::unordered_map<particles::Code, PROPOSAL::ParticleDef>
...@@ -65,43 +65,42 @@ namespace corsika::process::proposal { ...@@ -65,43 +65,42 @@ namespace corsika::process::proposal {
template <> template <>
template <> template <>
corsika::process::EProcessReturn Interaction<SetupEnvironment>::DoInteraction( corsika::process::EProcessReturn Interaction<SetupEnvironment>::DoInteraction(
SetupParticle& vP) { setup::StackView::StackIterator& vP) {
auto calc = GetCalculator(vP); // [CrossSections] if (CanInteract(vP.GetPID())) {
std::uniform_real_distribution<double> distr(0., 1.); auto calc = GetCalculator(vP); // [CrossSections]
auto [type, comp_ptr, v] = std::get<INTERACTION>(calc->second) std::uniform_real_distribution<double> distr(0., 1.);
->TypeInteraction(vP.GetEnergy() / 1_GeV, distr(fRNG)); auto [type, comp_ptr, v] =
auto rnd = std::vector<double>(); std::get<INTERACTION>(calc->second)
for (size_t i = 0; ->TypeInteraction(vP.GetEnergy() / 1_GeV, distr(fRNG));
i < std::get<SECONDARIES>(calc->second).RequiredRandomNumbers(type); ++i) auto rnd = std::vector<double>();
rnd.push_back(distr(fRNG)); for (size_t i = 0;
double primary_energy = vP.GetEnergy() / 1_GeV; i < std::get<SECONDARIES>(calc->second).RequiredRandomNumbers(type); ++i)
auto point = rnd.push_back(distr(fRNG));
PROPOSAL::Vector3D(vP.GetPosition().GetX() / 1_cm, vP.GetPosition().GetY() / 1_cm, double primary_energy = vP.GetEnergy() / 1_GeV;
vP.GetPosition().GetZ() / 1_cm); auto point = PROPOSAL::Vector3D(vP.GetPosition().GetX() / 1_cm,
auto p = vP.GetMomentum().GetComponents(); vP.GetPosition().GetY() / 1_cm,
auto direction = PROPOSAL::Vector3D(p[0] / 1_GeV, p[1] / 1_GeV, p[2] / 1_GeV); vP.GetPosition().GetZ() / 1_cm);
auto loss = auto p = vP.GetMomentum().GetComponents();
make_tuple(static_cast<int>(type), point, direction, v * primary_energy, 0.); auto direction = PROPOSAL::Vector3D(p[0] / 1_GeV, p[1] / 1_GeV, p[2] / 1_GeV);
auto sec = std::get<SECONDARIES>(calc->second) auto loss =
.CalculateSecondaries(primary_energy, loss, *comp_ptr, rnd); make_tuple(static_cast<int>(type), point, direction, v * primary_energy, 0.);
for (auto& s : sec) { auto sec = std::get<SECONDARIES>(calc->second)
auto energy = get<PROPOSAL::Loss::ENERGY>(s) * 1_MeV; .CalculateSecondaries(primary_energy, loss, *comp_ptr, rnd);
auto vec = corsika::geometry::QuantityVector( for (auto& s : sec) {
std::get<PROPOSAL::Loss::DIRECTION>(s).GetX() * energy, auto energy = get<PROPOSAL::Loss::ENERGY>(s) * 1_MeV;
std::get<PROPOSAL::Loss::DIRECTION>(s).GetY() * energy, auto vec = corsika::geometry::QuantityVector(
std::get<PROPOSAL::Loss::DIRECTION>(s).GetZ() * energy); std::get<PROPOSAL::Loss::DIRECTION>(s).GetX() * energy,
auto momentum = corsika::stack::MomentumVector( std::get<PROPOSAL::Loss::DIRECTION>(s).GetY() * energy,
corsika::geometry::RootCoordinateSystem::GetInstance() std::get<PROPOSAL::Loss::DIRECTION>(s).GetZ() * energy);
.GetRootCoordinateSystem(), auto momentum = corsika::stack::MomentumVector(
vec); corsika::geometry::RootCoordinateSystem::GetInstance()
particles::Code sec_code = corsika::particles::ConvertFromPDG( .GetRootCoordinateSystem(),
static_cast<particles::PDGCode>(get<PROPOSAL::Loss::TYPE>(s))); vec);
corsika::units::si::HEPEnergyType sec_energy = energy; particles::Code sec_code = corsika::particles::ConvertFromPDG(
stack::MomentumVector sec_momentum = momentum; static_cast<particles::PDGCode>(get<PROPOSAL::Loss::TYPE>(s)));
geometry::Point sec_position = vP.GetPosition(); vP.AddSecondary(
corsika::units::si::TimeType sec_time = vP.GetTime(); make_tuple(sec_code, energy, momentum, vP.GetPosition(), vP.GetTime()));
vP.AddSecondary( }
make_tuple(sec_code, sec_energy, sec_momentum, sec_position, sec_time));
} }
return process::EProcessReturn::eOk; return process::EProcessReturn::eOk;
} }
...@@ -109,13 +108,16 @@ namespace corsika::process::proposal { ...@@ -109,13 +108,16 @@ namespace corsika::process::proposal {
template <> template <>
template <> template <>
corsika::units::si::GrammageType Interaction<SetupEnvironment>::GetInteractionLength( corsika::units::si::GrammageType Interaction<SetupEnvironment>::GetInteractionLength(
SetupParticle const& vP) { setup::Stack::StackIterator& vP) {
auto calc = GetCalculator(vP); // [CrossSections] if (CanInteract(vP.GetPID())) {
std::uniform_real_distribution<double> distr(0., 1.); auto calc = GetCalculator(vP); // [CrossSections]
auto energy = get<INTERACTION>(calc->second) std::uniform_real_distribution<double> distr(0., 1.);
->EnergyInteraction(vP.GetEnergy() / 1_GeV, distr(fRNG)); auto energy = get<INTERACTION>(calc->second)
return get<DISPLACEMENT>(calc->second) ->EnergyInteraction(vP.GetEnergy() / 1_GeV, distr(fRNG));
->SolveTrackIntegral(vP.GetEnergy() / 1_GeV, energy) * return get<DISPLACEMENT>(calc->second)
1_g / 1_cm / 1_cm; ->SolveTrackIntegral(vP.GetEnergy() / 1_GeV, energy) *
1_g / 1_cm / 1_cm;
}
return std::numeric_limits<double>::infinity() * 1_g / (1_cm * 1_cm);
} }
} // namespace corsika::process::proposal } // namespace corsika::process::proposal
...@@ -38,12 +38,10 @@ namespace corsika::process::proposal { ...@@ -38,12 +38,10 @@ namespace corsika::process::proposal {
static std::unordered_map<particles::Code, PROPOSAL::ParticleDef> particles; static std::unordered_map<particles::Code, PROPOSAL::ParticleDef> particles;
std::unordered_map<const NuclearComposition*, PROPOSAL::Medium> media; std::unordered_map<const NuclearComposition*, PROPOSAL::Medium> media;
enum { SECONDARIES, INTERACTION, DISPLACEMENT };
corsika::random::RNG& fRNG = corsika::random::RNG& fRNG =
corsika::random::RNGManager::GetInstance().GetRandomStream("s_rndm"); corsika::random::RNGManager::GetInstance().GetRandomStream("p_rndm");
auto IsTracked(particles::Code pcode) const noexcept { bool CanInteract(particles::Code pcode) const noexcept {
auto search = particles.find(pcode); auto search = particles.find(pcode);
if (search != particles.end()) return true; if (search != particles.end()) return true;
return false; return false;
...@@ -54,6 +52,7 @@ namespace corsika::process::proposal { ...@@ -54,6 +52,7 @@ namespace corsika::process::proposal {
unique_ptr<PROPOSAL::Displacement>>; unique_ptr<PROPOSAL::Displacement>>;
std::unordered_map<const NuclearComposition*, calculator_t> calculators; std::unordered_map<const NuclearComposition*, calculator_t> calculators;
enum { SECONDARIES, INTERACTION, DISPLACEMENT };
template <typename Particle> template <typename Particle>
auto GetCalculator(Particle& vP) { auto GetCalculator(Particle& vP) {
auto& comp = vP.GetNode()->GetModelProperties().GetNuclearComposition(); auto& comp = vP.GetNode()->GetModelProperties().GetNuclearComposition();
...@@ -81,6 +80,5 @@ namespace corsika::process::proposal { ...@@ -81,6 +80,5 @@ namespace corsika::process::proposal {
template <typename TParticle> template <typename TParticle>
corsika::units::si::GrammageType GetInteractionLength(TParticle& p); corsika::units::si::GrammageType GetInteractionLength(TParticle& p);
}; };
} // namespace corsika::process::proposal } // namespace corsika::process::proposal
#endif #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