IAP GITLAB

Skip to content
Snippets Groups Projects
Commit 91aa210e authored by Maximilian Sackel's avatar Maximilian Sackel
Browse files

resolve the namespace pollution in the proposal process

parent f26e4e91
No related branches found
No related tags found
1 merge request!245Include proposal process rebase
......@@ -20,8 +20,6 @@
namespace corsika::process::proposal {
using namespace corsika::units::si;
void ContinuousProcess::BuildCalculator(particles::Code code,
environment::NuclearComposition const& comp) {
// search crosssection builder for given particle
......@@ -45,13 +43,15 @@ namespace corsika::process::proposal {
template <>
ContinuousProcess::ContinuousProcess(setup::SetupEnvironment const& _env,
corsika::units::si::HEPEnergyType _emCut)
corsika::units::si::HEPEnergyType _emCut)
: ProposalProcessBase(_env, _emCut) {}
template <>
void ContinuousProcess::Scatter(setup::Stack::ParticleType& vP,
HEPEnergyType const& loss,
GrammageType const& grammage) {
corsika::units::si::HEPEnergyType const& loss,
corsika::units::si::GrammageType const& grammage) {
using namespace corsika::units::si; // required for operator::_MeV
// Get or build corresponding calculators
auto c = GetCalculator(vP, calc);
......@@ -87,6 +87,8 @@ namespace corsika::process::proposal {
template <>
EProcessReturn ContinuousProcess::DoContinuous(setup::Stack::ParticleType& vP,
setup::Trajectory const& vT) {
using namespace corsika::units::si; // required for operator::_MeV
if (!CanInteract(vP.GetPID())) return process::EProcessReturn::eOk;
// calculate passed grammage
......@@ -100,15 +102,14 @@ namespace corsika::process::proposal {
1_MeV;
auto dE = vP.GetEnergy() - final_energy;
energy_lost_ += dE;
// if the particle has a charge take multiple scattering into account
if (vP.GetChargeNumber() != 0) Scatter(vP, dE, dX);
// Update the energy and absorbe the particle if it's below the energy
// threshold, because it will no longer propagated.
vP.SetEnergy(final_energy);
if (vP.GetEnergy() <= emCut_)
return process::EProcessReturn::eParticleAbsorbed;
if (vP.GetEnergy() <= emCut_) return process::EProcessReturn::eParticleAbsorbed;
vP.SetMomentum(vP.GetMomentum() * vP.GetEnergy() / vP.GetMomentum().GetNorm());
return process::EProcessReturn::eOk;
}
......@@ -116,13 +117,16 @@ namespace corsika::process::proposal {
template <>
units::si::LengthType ContinuousProcess::MaxStepLength(
setup::Stack::ParticleType const& vP, setup::Trajectory const& vT) {
using namespace corsika::units::si; // required for operator::_MeV
if (!CanInteract(vP.GetPID()))
return units::si::meter * std::numeric_limits<double>::infinity();
// Limit the step size of a conitnous loss. The maximal continuous loss seems to be a
// hyper parameter which must be adjusted.
// in any case: never go below emCut_
auto energy_lim = std::max(0.9 * vP.GetEnergy(), emCut_);;
auto energy_lim = std::max(0.9 * vP.GetEnergy(), emCut_);
;
// solving the track integral for giving energy lim
auto c = GetCalculator(vP, calc);
......@@ -135,12 +139,14 @@ namespace corsika::process::proposal {
}
void ContinuousProcess::ShowResults() const {
using namespace corsika::units::si; // required for operator::_MeV
std::cout << " ******************************" << std::endl
<< " PROCESS::ContinuousProcess: " << std::endl;
std::cout << " energy lost dE (GeV) : " << energy_lost_ / 1_GeV << std::endl;
}
void ContinuousProcess::Reset() {
using namespace corsika::units::si; // required for operator::_MeV
energy_lost_ = 0_GeV;
}
......
......@@ -35,14 +35,13 @@ namespace corsika::process::proposal {
calc; //!< Stores the displacement and scattering calculators.
units::si::HEPEnergyType energy_lost_ = 0 * units::si::electronvolt;
//!
//! Build the displacement and scattering calculators and add it to calc.
//!
void BuildCalculator(particles::Code, environment::NuclearComposition const&) final;
public:
//!
//! Produces the continuous loss calculator for leptons based on nuclear
//! compositions and stochastic description limited by the particle cut.
......@@ -50,7 +49,6 @@ namespace corsika::process::proposal {
template <typename TEnvironment>
ContinuousProcess(TEnvironment const&, corsika::units::si::HEPEnergyType _emCut);
//!
//! Multiple Scattering of the lepton. Stochastic deflection is not yet taken into
//! account. Displacment of the track due to multiple scattering is not possible
......
......@@ -20,8 +20,6 @@
#include <tuple>
namespace corsika::process::proposal {
using namespace corsika::environment;
using namespace corsika::units::si;
template <>
Interaction::Interaction(setup::SetupEnvironment const& _env,
......@@ -53,6 +51,8 @@ namespace corsika::process::proposal {
template <>
corsika::process::EProcessReturn Interaction::DoInteraction(
setup::StackView::StackIterator& vP) {
using namespace corsika::units::si; // required for operator::_MeV
if (CanInteract(vP.GetPID())) {
// Get or build corresponding calculators
auto c = GetCalculator(vP, calc);
......@@ -100,6 +100,8 @@ namespace corsika::process::proposal {
template <>
corsika::units::si::GrammageType Interaction::GetInteractionLength(
setup::Stack::StackIterator const& vP) {
using namespace corsika::units::si; // required for operator::_MeV
if (CanInteract(vP.GetPID())) {
auto c = GetCalculator(vP, calc);
return get<INTERACTION>(c->second)->MeanFreePath(vP.GetEnergy() / 1_MeV) * 1_g /
......
......@@ -20,8 +20,6 @@
namespace corsika::process::proposal {
using namespace corsika::units::si;
//!
//! Electro-magnetic and gamma stochastic losses produced by proposal. It makes
//! use of interpolation tables which are runtime intensive calculation, but can be
......
......@@ -9,9 +9,6 @@
namespace corsika::process::proposal {
using namespace corsika::units::si;
using namespace std::placeholders;
//!
//! Particles which can be handled by proposal. That means they can be
//! propagated and decayed if they decays.
......@@ -40,20 +37,23 @@ namespace corsika::process::proposal {
//! Crosssection factories for different particle types.
//!
template <typename T>
static auto cross_builder = [](PROPOSAL::Medium& m, corsika::units::si::HEPEnergyType emCut) {
auto p_cut = std::make_shared<const PROPOSAL::EnergyCutSettings>(
emCut / 1_MeV, 1, true);
return PROPOSAL::DefaultCrossSections<T>::template Get<std::false_type>(T(), m, p_cut,
true);
};
static auto cross_builder =
[](PROPOSAL::Medium& m, corsika::units::si::HEPEnergyType emCut) {
using namespace corsika::units::si;
auto p_cut =
std::make_shared<const PROPOSAL::EnergyCutSettings>(emCut / 1_MeV, 1, true);
return PROPOSAL::DefaultCrossSections<T>::template Get<std::false_type>(
T(), m, p_cut, true);
};
//!
//! PROPOSAL default crosssections are maped to corresponding corsika particle
//! code.
//!
static std::map<particles::Code, std::function<PROPOSAL::crosssection_list_t<
PROPOSAL::ParticleDef, PROPOSAL::Medium>(
PROPOSAL::Medium&, corsika::units::si::HEPEnergyType)>>
static std::map<particles::Code,
std::function<PROPOSAL::crosssection_list_t<PROPOSAL::ParticleDef,
PROPOSAL::Medium>(
PROPOSAL::Medium&, corsika::units::si::HEPEnergyType)>>
cross = {{particles::Code::Gamma, cross_builder<PROPOSAL::GammaDef>},
{particles::Code::Electron, cross_builder<PROPOSAL::EMinusDef>},
{particles::Code::Positron, cross_builder<PROPOSAL::EPlusDef>},
......@@ -68,9 +68,10 @@ namespace corsika::process::proposal {
//!
class ProposalProcessBase {
protected:
corsika::units::si::HEPEnergyType emCut_; //!< Stochastic losses smaller than the given cut
//!< will be handeled continuously.
corsika::random::RNG& fRNG; //!< random number generator used by proposal
corsika::units::si::HEPEnergyType
emCut_; //!< Stochastic losses smaller than the given cut
//!< will be handeled continuously.
corsika::random::RNG& fRNG; //!< random number generator used by proposal
std::unordered_map<const environment::NuclearComposition*, PROPOSAL::Medium>
media; //!< maps nuclear composition from univers to media to produce
......
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