diff --git a/Processes/Proposal/ContinuousProcess.cc b/Processes/Proposal/ContinuousProcess.cc index 0337bc8b0fc7c23cba77e4ecee186078d402ddea..2c5cfc3b96e9ced0a6193d61ae3a76d377d6a204 100644 --- a/Processes/Proposal/ContinuousProcess.cc +++ b/Processes/Proposal/ContinuousProcess.cc @@ -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; } diff --git a/Processes/Proposal/ContinuousProcess.h b/Processes/Proposal/ContinuousProcess.h index e2624ed48225277b4d1ced6b4a1b174dc72ca19b..aefa4ffc64f7be0e7dc3607683e1e3b9e7dcd235 100644 --- a/Processes/Proposal/ContinuousProcess.h +++ b/Processes/Proposal/ContinuousProcess.h @@ -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 diff --git a/Processes/Proposal/Interaction.cc b/Processes/Proposal/Interaction.cc index aeeaae4841c9fdda82b09439e8ce5f6d0c382d10..511f580a7690304cee8a83bace2b62dc82af92ac 100644 --- a/Processes/Proposal/Interaction.cc +++ b/Processes/Proposal/Interaction.cc @@ -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 / diff --git a/Processes/Proposal/Interaction.h b/Processes/Proposal/Interaction.h index 0a4aed0a4494e8cc5eba28784921f8602696ccfc..007cff4a8e48ca674dac0f979f87fc3219c053f0 100644 --- a/Processes/Proposal/Interaction.h +++ b/Processes/Proposal/Interaction.h @@ -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 diff --git a/Processes/Proposal/ProposalProcessBase.h b/Processes/Proposal/ProposalProcessBase.h index 018fd1b4ff218b604fb4c474579812b9f6aedfb9..b1696526ae5f4705b1c6a97e3e0ead131188bcda 100644 --- a/Processes/Proposal/ProposalProcessBase.h +++ b/Processes/Proposal/ProposalProcessBase.h @@ -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