IAP GITLAB

Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • AirShowerPhysics/corsika
  • rulrich/corsika
  • AAAlvesJr/corsika
  • Andre/corsika
  • arrabito/corsika
  • Nikos/corsika
  • olheiser73/corsika
  • AirShowerPhysics/papers/corsika
  • pranav/corsika
9 results
Show changes
Commits on Source (2)
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include <corsika/units/PhysicalUnits.h> #include <corsika/units/PhysicalUnits.h>
#include <cassert> #include <cassert>
#include <functional>
#include <numeric> #include <numeric>
#include <random> #include <random>
#include <stdexcept> #include <stdexcept>
...@@ -82,7 +83,6 @@ namespace corsika::environment { ...@@ -82,7 +83,6 @@ namespace corsika::environment {
auto WeightedSum(TFunction func) const { auto WeightedSum(TFunction func) const {
using ResultQuantity = decltype(func(*fComponents.cbegin())); using ResultQuantity = decltype(func(*fComponents.cbegin()));
auto const sum = [](auto x, auto y) { return x + y; };
auto const prod = [&](auto const compID, auto const fraction) { auto const prod = [&](auto const compID, auto const fraction) {
return func(compID) * fraction; return func(compID) * fraction;
}; };
...@@ -91,12 +91,12 @@ namespace corsika::environment { ...@@ -91,12 +91,12 @@ namespace corsika::environment {
return std::inner_product( return std::inner_product(
fComponents.cbegin(), fComponents.cend(), fNumberFractions.cbegin(), fComponents.cbegin(), fComponents.cend(), fNumberFractions.cbegin(),
ResultQuantity::zero(), // .zero() is defined for quantity types only ResultQuantity::zero(), // .zero() is defined for quantity types only
sum, prod); std::plus<ResultQuantity>(), prod);
} else { } else {
return std::inner_product( return std::inner_product(
fComponents.cbegin(), fComponents.cend(), fNumberFractions.cbegin(), fComponents.cbegin(), fComponents.cend(), fNumberFractions.cbegin(),
ResultQuantity(0), // in other cases we have to use a bare 0 ResultQuantity(0), // in other cases we have to use a bare 0
sum, prod); std::plus<ResultQuantity>(), prod);
} }
} }
......
...@@ -76,37 +76,37 @@ namespace corsika::process::pythia { ...@@ -76,37 +76,37 @@ namespace corsika::process::pythia {
} }
void Interaction::SetParticleListStable( void Interaction::SetParticleListStable(
std::vector<particles::Code> const& particleList) { std::vector<particles::Code> const& vParticleList) {
for (auto p : particleList) Interaction::SetStable(p); for (auto p : vParticleList) Interaction::SetStable(p);
} }
void Interaction::SetUnstable(const particles::Code pCode) { void Interaction::SetUnstable(const particles::Code vCode) {
cout << "Pythia::Interaction: setting " << pCode << " unstable.." << endl; cout << "Pythia::Interaction: setting " << vCode << " unstable.." << endl;
fPythia.particleData.mayDecay(static_cast<int>(particles::GetPDG(pCode)), true); fPythia.particleData.mayDecay(static_cast<int>(particles::GetPDG(vCode)), true);
} }
void Interaction::SetStable(const particles::Code pCode) { void Interaction::SetStable(const particles::Code vCode) {
cout << "Pythia::Interaction: setting " << pCode << " stable.." << endl; cout << "Pythia::Interaction: setting " << vCode << " stable.." << endl;
fPythia.particleData.mayDecay(static_cast<int>(particles::GetPDG(pCode)), false); fPythia.particleData.mayDecay(static_cast<int>(particles::GetPDG(vCode)), false);
} }
void Interaction::ConfigureLabFrameCollision( void Interaction::ConfigureLabFrameCollision(
const particles::Code BeamId, const particles::Code TargetId, const particles::Code vBeamId, const particles::Code vTargetId,
const units::si::HEPEnergyType BeamEnergy) { const units::si::HEPEnergyType vBeamEnergy) {
using namespace units::si; using namespace units::si;
// Pythia configuration of the current event // Pythia configuration of the current event
// very clumsy. I am sure this can be done better.. // very clumsy. I am sure this can be done better..
// set beam // set beam
// beam id for pythia // beam id for pythia
auto const pdgBeam = static_cast<int>(particles::GetPDG(BeamId)); auto const pdgBeam = static_cast<int>(particles::GetPDG(vBeamId));
std::stringstream stBeam; std::stringstream stBeam;
stBeam << "Beams:idA = " << pdgBeam; stBeam << "Beams:idA = " << pdgBeam;
fPythia.readString(stBeam.str()); fPythia.readString(stBeam.str());
// set target // set target
auto pdgTarget = static_cast<int>(particles::GetPDG(TargetId)); auto pdgTarget = static_cast<int>(particles::GetPDG(vTargetId));
// replace hydrogen with proton, otherwise pythia goes into heavy ion mode! // replace hydrogen with proton, otherwise pythia goes into heavy ion mode!
if (TargetId == particles::Code::Hydrogen) if (vTargetId == particles::Code::Hydrogen)
pdgTarget = static_cast<int>(particles::GetPDG(particles::Code::Proton)); pdgTarget = static_cast<int>(particles::GetPDG(particles::Code::Proton));
std::stringstream stTarget; std::stringstream stTarget;
stTarget << "Beams:idB = " << pdgTarget; stTarget << "Beams:idB = " << pdgTarget;
...@@ -114,7 +114,7 @@ namespace corsika::process::pythia { ...@@ -114,7 +114,7 @@ namespace corsika::process::pythia {
// set frame to lab. frame // set frame to lab. frame
fPythia.readString("Beams:frameType = 2"); fPythia.readString("Beams:frameType = 2");
// set beam energy // set beam energy
const double Elab = BeamEnergy / 1_GeV; const double Elab = vBeamEnergy / 1_GeV;
std::stringstream stEnergy; std::stringstream stEnergy;
stEnergy << "Beams:eA = " << Elab; stEnergy << "Beams:eA = " << Elab;
fPythia.readString(stEnergy.str()); fPythia.readString(stEnergy.str());
...@@ -124,28 +124,28 @@ namespace corsika::process::pythia { ...@@ -124,28 +124,28 @@ namespace corsika::process::pythia {
fPythia.init(); fPythia.init();
} }
bool Interaction::CanInteract(const corsika::particles::Code pCode) { bool Interaction::CanInteract(const corsika::particles::Code vCode) {
return pCode == corsika::particles::Code::Proton || return vCode == corsika::particles::Code::Proton ||
pCode == corsika::particles::Code::Neutron || vCode == corsika::particles::Code::Neutron ||
pCode == corsika::particles::Code::AntiProton || vCode == corsika::particles::Code::AntiProton ||
pCode == corsika::particles::Code::AntiNeutron || vCode == corsika::particles::Code::AntiNeutron ||
pCode == corsika::particles::Code::PiMinus || vCode == corsika::particles::Code::PiMinus ||
pCode == corsika::particles::Code::PiPlus; vCode == corsika::particles::Code::PiPlus;
} }
tuple<units::si::CrossSectionType, units::si::CrossSectionType> tuple<units::si::CrossSectionType, units::si::CrossSectionType>
Interaction::GetCrossSection(const particles::Code BeamId, Interaction::GetCrossSection(const particles::Code vBeamId,
const particles::Code TargetId, const particles::Code vTargetId,
const units::si::HEPEnergyType CoMenergy) { const units::si::HEPEnergyType vCoMenergy) {
using namespace units::si; using namespace units::si;
// interaction possible in pythia? // interaction possible in pythia?
if (TargetId == particles::Code::Proton || TargetId == particles::Code::Hydrogen) { if (TargetId == particles::Code::Proton || TargetId == particles::Code::Hydrogen) {
if (CanInteract(BeamId) && ValidCoMEnergy(CoMenergy)) { if (CanInteract(vBeamId) && ValidCoMEnergy(vCoMenergy)) {
// input particle PDG // input particle PDG
auto const pdgCodeBeam = static_cast<int>(particles::GetPDG(BeamId)); auto const pdgCodeBeam = static_cast<int>(particles::GetPDG(vBeamId));
auto const pdgCodeTarget = static_cast<int>(particles::GetPDG(TargetId)); auto const pdgCodeTarget = static_cast<int>(particles::GetPDG(vTargetId));
const double ecm = CoMenergy / 1_GeV; const double ecm = vCoMenergy / 1_GeV;
// calculate cross section // calculate cross section
fSigma.calc(pdgCodeBeam, pdgCodeTarget, ecm); fSigma.calc(pdgCodeBeam, pdgCodeTarget, ecm);
...@@ -168,7 +168,7 @@ namespace corsika::process::pythia { ...@@ -168,7 +168,7 @@ namespace corsika::process::pythia {
} }
template <> template <>
units::si::GrammageType Interaction::GetInteractionLength(Particle& p, Track&) { units::si::GrammageType Interaction::GetInteractionLength(Particle& vP, Track&) {
using namespace units; using namespace units;
using namespace units::si; using namespace units::si;
...@@ -178,7 +178,7 @@ namespace corsika::process::pythia { ...@@ -178,7 +178,7 @@ namespace corsika::process::pythia {
CoordinateSystem& rootCS = CoordinateSystem& rootCS =
RootCoordinateSystem::GetInstance().GetRootCoordinateSystem(); RootCoordinateSystem::GetInstance().GetRootCoordinateSystem();
const particles::Code corsikaBeamId = p.GetPID(); const particles::Code corsikaBeamId = vP.GetPID();
// beam particles for pythia : 1, 2, 3 for p, pi, k // beam particles for pythia : 1, 2, 3 for p, pi, k
// read from cross section code table // read from cross section code table
...@@ -188,9 +188,9 @@ namespace corsika::process::pythia { ...@@ -188,9 +188,9 @@ namespace corsika::process::pythia {
process::pythia::MomentumVector pTarget(rootCS, {0_GeV, 0_GeV, 0_GeV}); process::pythia::MomentumVector pTarget(rootCS, {0_GeV, 0_GeV, 0_GeV});
// total momentum and energy // total momentum and energy
HEPEnergyType Elab = p.GetEnergy() + constants::nucleonMass; HEPEnergyType Elab = vP.GetEnergy() + constants::nucleonMass;
process::pythia::MomentumVector pTotLab(rootCS, {0_GeV, 0_GeV, 0_GeV}); process::pythia::MomentumVector pTotLab(rootCS, {0_GeV, 0_GeV, 0_GeV});
pTotLab += p.GetMomentum(); pTotLab += vP.GetMomentum();
pTotLab += pTarget; pTotLab += pTarget;
auto const pTotLabNorm = pTotLab.norm(); auto const pTotLabNorm = pTotLab.norm();
// calculate cm. energy // calculate cm. energy
...@@ -198,9 +198,9 @@ namespace corsika::process::pythia { ...@@ -198,9 +198,9 @@ namespace corsika::process::pythia {
(Elab + pTotLabNorm) * (Elab - pTotLabNorm)); // binomial for numerical accuracy (Elab + pTotLabNorm) * (Elab - pTotLabNorm)); // binomial for numerical accuracy
cout << "Interaction: LambdaInt: \n" cout << "Interaction: LambdaInt: \n"
<< " input energy: " << p.GetEnergy() / 1_GeV << endl << " input energy: " << vP.GetEnergy() / 1_GeV << endl
<< " beam can interact:" << kInteraction << endl << " beam can interact:" << kInteraction << endl
<< " beam pid:" << p.GetPID() << endl; << " beam pid:" << vP.GetPID() << endl;
// TODO: move limits into variables // TODO: move limits into variables
if (kInteraction && Elab >= 8.5_GeV && ValidCoMEnergy(ECoM)) { if (kInteraction && Elab >= 8.5_GeV && ValidCoMEnergy(ECoM)) {
...@@ -211,30 +211,16 @@ namespace corsika::process::pythia { ...@@ -211,30 +211,16 @@ namespace corsika::process::pythia {
ideally as full particle object so that the four momenta ideally as full particle object so that the four momenta
and the boosts can be defined.. and the boosts can be defined..
*/ */
const auto* currentNode = p.GetNode(); const auto* currentNode = vP.GetNode();
const auto mediumComposition = const auto mediumComposition =
currentNode->GetModelProperties().GetNuclearComposition(); currentNode->GetModelProperties().GetNuclearComposition();
// determine average interaction length // determine average interaction length
// weighted sum
int i = -1; auto const weightedProdCrossSection =
si::CrossSectionType weightedProdCrossSection = 0_mb; mediumComposition.WeightedSum([=](auto vTargetID) {
// get weights of components from environment/medium return std::get<0>(this->GetCrossSection(corsikaBeamId, vTargetID, ECoM));
const auto& w = mediumComposition.GetFractions(); });
// loop over components in medium
for (auto const targetId : mediumComposition.GetComponents()) {
i++;
cout << "Interaction: get interaction length for target: " << targetId << endl;
auto const [productionCrossSection, elaCrossSection] =
GetCrossSection(corsikaBeamId, targetId, ECoM);
[[maybe_unused]] const auto& dummy_elaCrossSection = elaCrossSection;
cout << "Interaction: IntLength: pythia return (mb): "
<< productionCrossSection / 1_mb << endl
<< "Interaction: IntLength: weight : " << w[i] << endl;
weightedProdCrossSection += w[i] * productionCrossSection;
}
cout << "Interaction: IntLength: weighted CrossSection (mb): " cout << "Interaction: IntLength: weighted CrossSection (mb): "
<< weightedProdCrossSection / 1_mb << endl << weightedProdCrossSection / 1_mb << endl
<< "Interaction: IntLength: average mass number: " << "Interaction: IntLength: average mass number: "
......
...@@ -37,9 +37,9 @@ namespace corsika::process::pythia { ...@@ -37,9 +37,9 @@ namespace corsika::process::pythia {
void SetStable(const corsika::particles::Code); void SetStable(const corsika::particles::Code);
bool WasInitialized() { return fInitialized; } bool WasInitialized() { return fInitialized; }
bool ValidCoMEnergy(corsika::units::si::HEPEnergyType ecm) { bool ValidCoMEnergy(corsika::units::si::HEPEnergyType vEcm) {
using namespace corsika::units::si; using namespace corsika::units::si;
return (10_GeV < ecm) && (ecm < 1_PeV); return (10_GeV < vEcm) && (vEcm < 1_PeV);
} }
bool CanInteract(const corsika::particles::Code); bool CanInteract(const corsika::particles::Code);
...@@ -47,9 +47,9 @@ namespace corsika::process::pythia { ...@@ -47,9 +47,9 @@ namespace corsika::process::pythia {
const corsika::particles::Code, const corsika::particles::Code,
const corsika::units::si::HEPEnergyType); const corsika::units::si::HEPEnergyType);
std::tuple<corsika::units::si::CrossSectionType, corsika::units::si::CrossSectionType> std::tuple<corsika::units::si::CrossSectionType, corsika::units::si::CrossSectionType>
GetCrossSection(const corsika::particles::Code BeamId, GetCrossSection(const corsika::particles::Code,
const corsika::particles::Code TargetId, const corsika::particles::Code,
const corsika::units::si::HEPEnergyType CoMenergy); const corsika::units::si::HEPEnergyType);
template <typename TParticle, typename TTrack> template <typename TParticle, typename TTrack>
corsika::units::si::GrammageType GetInteractionLength(TParticle&, TTrack&); corsika::units::si::GrammageType GetInteractionLength(TParticle&, TTrack&);
......