IAP GITLAB

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

fix medium ptr map sec fault.

parent e0208d7c
No related branches found
No related tags found
1 merge request!245Include proposal process rebase
......@@ -39,20 +39,21 @@ namespace corsika::process::proposal {
Interaction::Interaction(SetupEnvironment const& _env, CORSIKA_ParticleCut const& _cut)
: cut(make_shared<const PROPOSAL::EnergyCutSettings>(_cut.GetCutEnergy() / 1_GeV, 1,
false)) {
auto all_compositions = std::vector<NuclearComposition>();
auto all_compositions = std::vector<const NuclearComposition*>();
_env.GetUniverse()->walk([&](auto& vtn) {
if (vtn.HasModelProperties())
all_compositions.push_back(vtn.GetModelProperties().GetNuclearComposition());
if (vtn.HasModelProperties()) {
all_compositions.push_back(&vtn.GetModelProperties().GetNuclearComposition());
}
});
for (auto& ncarg : all_compositions) {
auto comp_vec = std::vector<Component_PROPOSAL>();
auto frac_iter = ncarg.GetFractions().cbegin();
for (auto& pcode : ncarg.GetComponents()) {
auto frac_iter = ncarg->GetFractions().cbegin();
for (auto& pcode : ncarg->GetComponents()) {
comp_vec.emplace_back(GetName(pcode), GetNucleusZ(pcode), GetNucleusA(pcode),
*frac_iter);
++frac_iter;
}
media[&ncarg] = PROPOSAL::Medium(
media[ncarg] = PROPOSAL::Medium(
"Modified Air", 1., PROPOSAL::Air().GetI(), PROPOSAL::Air().GetC(),
PROPOSAL::Air().GetA(), PROPOSAL::Air().GetM(), PROPOSAL::Air().GetX0(),
PROPOSAL::Air().GetX1(), PROPOSAL::Air().GetD0(), 1.0, comp_vec);
......
......@@ -49,17 +49,46 @@ namespace corsika::process::proposal {
auto& comp = vP.GetNode()->GetModelProperties().GetNuclearComposition();
auto calc_it = calculators.find(&comp);
if (calc_it != calculators.end()) return calc_it;
auto cross =
PROPOSAL::GetStdCrossSections(particles[vP.GetPID()], media[&comp], cut, true);
auto inter_types = PROPOSAL::CrossSectionVector::GetInteractionTypes(cross);
auto [insert_it, success] = calculators.insert(
{&comp, make_tuple(PROPOSAL::SecondariesCalculator(
inter_types, particles[vP.GetPID()], media[&comp]),
PROPOSAL::make_interaction(cross, true),
PROPOSAL::make_displacement(cross, true))});
return insert_it;
return BuildCalculator(vP.GetPID(), comp);
}
auto BuildCalculator(particles::Code corsika_code, NuclearComposition const& comp) {
auto medium = media.at(&comp);
if (corsika_code == particles::Code::Gamma) {
auto cross =
GetStdCrossSections(PROPOSAL::GammaDef(), media.at(&comp), cut, true);
auto inter_types = PROPOSAL::CrossSectionVector::GetInteractionTypes(cross);
auto [insert_it, success] = calculators.insert(
{&comp, make_tuple(PROPOSAL::SecondariesCalculator(
inter_types, PROPOSAL::GammaDef(), media[&comp]),
PROPOSAL::make_interaction(cross, true),
PROPOSAL::make_displacement(cross, true))});
return insert_it;
}
if (corsika_code == particles::Code::Electron) {
auto cross =
GetStdCrossSections(PROPOSAL::EMinusDef(), media.at(&comp), cut, true);
auto inter_types = PROPOSAL::CrossSectionVector::GetInteractionTypes(cross);
auto [insert_it, success] = calculators.insert(
{&comp, make_tuple(PROPOSAL::SecondariesCalculator(
inter_types, PROPOSAL::EMinusDef(), media[&comp]),
PROPOSAL::make_interaction(cross, true),
PROPOSAL::make_displacement(cross, true))});
return insert_it;
}
if (corsika_code == particles::Code::Positron) {
auto cross =
GetStdCrossSections(PROPOSAL::EPlusDef(), media.at(&comp), cut, true);
auto inter_types = PROPOSAL::CrossSectionVector::GetInteractionTypes(cross);
auto [insert_it, success] = calculators.insert(
{&comp, make_tuple(PROPOSAL::SecondariesCalculator(
inter_types, PROPOSAL::EPlusDef(), media[&comp]),
PROPOSAL::make_interaction(cross, true),
PROPOSAL::make_displacement(cross, true))});
return insert_it;
}
} // namespace corsika::process::proposal
public:
template <typename TEnvironment>
Interaction(TEnvironment const& env, CORSIKA_ParticleCut const& cut);
......@@ -71,6 +100,6 @@ namespace corsika::process::proposal {
template <typename TParticle>
corsika::units::si::GrammageType GetInteractionLength(TParticle const& p);
};
}; // namespace corsika::process::proposal
} // namespace corsika::process::proposal
#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