From 1d2fb269e83f39a7347112076a278777125d540b Mon Sep 17 00:00:00 2001 From: Maximilian Sackel <maximilian.sackel@tu-dortmund.de> Date: Fri, 2 Oct 2020 11:56:54 +0000 Subject: [PATCH] not using scoped enumeration because static_cast is required to specify the tuple position. Instead mark variable with an extra letter 'e' and use it only very scoped. --- Processes/Proposal/ContinuousProcess.cc | 6 +++--- Processes/Proposal/ContinuousProcess.h | 2 +- Processes/Proposal/Interaction.cc | 10 +++++----- Processes/Proposal/Interaction.h | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Processes/Proposal/ContinuousProcess.cc b/Processes/Proposal/ContinuousProcess.cc index e552f49dd..986556904 100644 --- a/Processes/Proposal/ContinuousProcess.cc +++ b/Processes/Proposal/ContinuousProcess.cc @@ -69,7 +69,7 @@ namespace corsika::process::proposal { for (auto& it : rnd) it = distr(fRNG); // calculate deflection based on particle energy, loss - auto [mean_dir, final_dir] = get<SCATTERING>(c->second)->Scatter( + auto [mean_dir, final_dir] = get<eSCATTERING>(c->second)->Scatter( grammage / 1_g * square(1_cm), vP.GetEnergy() / 1_MeV, E_f / 1_MeV, direction, rnd); @@ -98,7 +98,7 @@ namespace corsika::process::proposal { // Get or build corresponding track integral calculator and solve the // integral auto c = GetCalculator(vP, calc); - auto final_energy = get<DISPLACEMENT>(c->second)->UpperLimitTrackIntegral( + auto final_energy = get<eDISPLACEMENT>(c->second)->UpperLimitTrackIntegral( vP.GetEnergy() / 1_MeV, dX / 1_g * 1_cm * 1_cm) * 1_MeV; auto dE = vP.GetEnergy() - final_energy; @@ -142,7 +142,7 @@ namespace corsika::process::proposal { // solving the track integral for giving energy lim auto c = GetCalculator(vP, calc); - auto grammage = get<DISPLACEMENT>(c->second)->SolveTrackIntegral( + auto grammage = get<eDISPLACEMENT>(c->second)->SolveTrackIntegral( vP.GetEnergy() / 1_MeV, energy_lim / 1_MeV) * 1_g / square(1_cm); diff --git a/Processes/Proposal/ContinuousProcess.h b/Processes/Proposal/ContinuousProcess.h index aefa4ffc6..7d9a88d28 100644 --- a/Processes/Proposal/ContinuousProcess.h +++ b/Processes/Proposal/ContinuousProcess.h @@ -27,7 +27,7 @@ namespace corsika::process::proposal { class ContinuousProcess : public process::ContinuousProcess<ContinuousProcess>, ProposalProcessBase { - enum { DISPLACEMENT, SCATTERING }; + enum { eDISPLACEMENT, eSCATTERING }; using calc_t = std::tuple<std::unique_ptr<PROPOSAL::Displacement>, std::unique_ptr<PROPOSAL::Scattering>>; diff --git a/Processes/Proposal/Interaction.cc b/Processes/Proposal/Interaction.cc index 4a1b767be..623556b90 100644 --- a/Processes/Proposal/Interaction.cc +++ b/Processes/Proposal/Interaction.cc @@ -61,13 +61,13 @@ namespace corsika::process::proposal { std::uniform_real_distribution<double> distr(0., 1.); // sample a interaction-type, loss and component - auto rates = get<INTERACTION>(c->second)->Rates(vP.GetEnergy() / 1_MeV); - auto [type, comp_ptr, v] = get<INTERACTION>(c->second)->SampleLoss( + auto rates = get<eINTERACTION>(c->second)->Rates(vP.GetEnergy() / 1_MeV); + auto [type, comp_ptr, v] = get<eINTERACTION>(c->second)->SampleLoss( vP.GetEnergy() / 1_MeV, rates, distr(fRNG)); // Read how much random numbers are required to calculate the secondaries. // Calculate the secondaries and deploy them on the corsika stack. - auto rnd = vector<double>(get<SECONDARIES>(c->second)->RequiredRandomNumbers(type)); + auto rnd = vector<double>(get<eSECONDARIES>(c->second)->RequiredRandomNumbers(type)); for (auto& it : rnd) it = distr(fRNG); auto point = PROPOSAL::Vector3D(vP.GetPosition().GetX() / 1_cm, vP.GetPosition().GetY() / 1_cm, @@ -78,7 +78,7 @@ namespace corsika::process::proposal { d.GetZ().magnitude()); auto loss = make_tuple(static_cast<int>(type), point, direction, v * vP.GetEnergy() / 1_MeV, 0.); - auto sec = get<SECONDARIES>(c->second)->CalculateSecondaries(vP.GetEnergy() / 1_MeV, + auto sec = get<eSECONDARIES>(c->second)->CalculateSecondaries(vP.GetEnergy() / 1_MeV, loss, *comp_ptr, rnd); for (auto& s : sec) { auto E = get<PROPOSAL::Loss::ENERGY>(s) * 1_MeV; @@ -102,7 +102,7 @@ namespace corsika::process::proposal { if (CanInteract(vP.GetPID())) { auto c = GetCalculator(vP, calc); - return get<INTERACTION>(c->second)->MeanFreePath(vP.GetEnergy() / 1_MeV) * 1_g / + return get<eINTERACTION>(c->second)->MeanFreePath(vP.GetEnergy() / 1_MeV) * 1_g / (1_cm * 1_cm); } return std::numeric_limits<double>::infinity() * 1_g / (1_cm * 1_cm); diff --git a/Processes/Proposal/Interaction.h b/Processes/Proposal/Interaction.h index 007cff4a8..b506dc739 100644 --- a/Processes/Proposal/Interaction.h +++ b/Processes/Proposal/Interaction.h @@ -27,7 +27,7 @@ namespace corsika::process::proposal { //! class Interaction : public InteractionProcess<Interaction>, ProposalProcessBase { - enum { SECONDARIES, INTERACTION }; + enum { eSECONDARIES, eINTERACTION }; using calculator_t = tuple<unique_ptr<PROPOSAL::SecondariesCalculator>, unique_ptr<PROPOSAL::Interaction>>; -- GitLab