IAP GITLAB

Skip to content
Snippets Groups Projects
Commit e2641191 authored by Felix Riehn's avatar Felix Riehn
Browse files

added sampling of target nucleus from environment in sibyll interface

parent 24614536
No related branches found
No related tags found
No related merge requests found
...@@ -213,8 +213,8 @@ int main() { ...@@ -213,8 +213,8 @@ int main() {
theMedium->SetModelProperties<MyHomogeneousModel>( theMedium->SetModelProperties<MyHomogeneousModel>(
1_kg / (1_m * 1_m * 1_m), 1_kg / (1_m * 1_m * 1_m),
corsika::environment::NuclearComposition( corsika::environment::NuclearComposition(
std::vector<corsika::particles::Code>{corsika::particles::Code::Oxygen}, std::vector<corsika::particles::Code>{corsika::particles::Code::Nitrogen,corsika::particles::Code::Oxygen,corsika::particles::Code::Proton},
std::vector<float>{1.})); std::vector<float>{0.5,0.3,0.2}));
universe.AddChild(std::move(theMedium)); universe.AddChild(std::move(theMedium));
...@@ -237,7 +237,7 @@ int main() { ...@@ -237,7 +237,7 @@ int main() {
// setup particle stack, and add primary particle // setup particle stack, and add primary particle
setup::Stack stack; setup::Stack stack;
stack.Clear(); stack.Clear();
const hep::EnergyType E0 = 100_TeV; const hep::EnergyType E0 = 100_GeV;
double theta = 0.; double theta = 0.;
double phi = 0.; double phi = 0.;
{ {
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <corsika/random/RNGManager.h> #include <corsika/random/RNGManager.h>
#include <corsika/units/PhysicalUnits.h> #include <corsika/units/PhysicalUnits.h>
#include <corsika/environment/Environment.h> #include <corsika/environment/Environment.h>
#include <corsika/environment/NuclearComposition.h>
namespace corsika::process::sibyll { namespace corsika::process::sibyll {
...@@ -29,6 +30,7 @@ namespace corsika::process::sibyll { ...@@ -29,6 +30,7 @@ namespace corsika::process::sibyll {
int fCount = 0; int fCount = 0;
int fNucCount = 0; int fNucCount = 0;
int kTarget = 0;
public: public:
Interaction(corsika::environment::Environment const& env) : fEnvironment(env) { } Interaction(corsika::environment::Environment const& env) : fEnvironment(env) { }
~Interaction() { ~Interaction() {
...@@ -44,7 +46,7 @@ namespace corsika::process::sibyll { ...@@ -44,7 +46,7 @@ namespace corsika::process::sibyll {
corsika::random::RNGManager& rmng = corsika::random::RNGManager::GetInstance(); corsika::random::RNGManager& rmng = corsika::random::RNGManager::GetInstance();
rmng.RegisterRandomStream("s_rndm"); rmng.RegisterRandomStream("s_rndm");
// initialize Sibyll // initialize Sibyll
sibyll_ini_(); sibyll_ini_();
} }
...@@ -70,21 +72,63 @@ namespace corsika::process::sibyll { ...@@ -70,21 +72,63 @@ namespace corsika::process::sibyll {
const int kBeam = process::sibyll::GetSibyllXSCode(corsikaBeamId); const int kBeam = process::sibyll::GetSibyllXSCode(corsikaBeamId);
const bool kInteraction = process::sibyll::CanInteract(corsikaBeamId); const bool kInteraction = process::sibyll::CanInteract(corsikaBeamId);
// get target from environment
/* /*
the target should be defined by the Environment, the target should be defined by the Environment,
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..
*/ */
// target nuclei: A < 18 const auto currentNode = fEnvironment.GetUniverse()->GetContainingNode(p.GetPosition());
// FOR NOW: assume target is oxygen const auto sample_target = [](const corsika::environment::NuclearComposition& comp)
const int kTarget = corsika::particles::Oxygen::GetNucleusA(); {
double prev =0.;
std::vector<float> cumFrac;
for (auto f: comp.GetFractions()){
cumFrac.push_back(prev+f);
prev = cumFrac.back();
}
int a = 1;
const double r = s_rndm_(a);
int i = -1;
//cout << "rndm: " << r << endl;
for (auto cf: cumFrac){
++i;
//cout << "cf: " << cf << " " << comp.GetComponents()[i] << endl;
if(r<cf) break;
}
return comp.GetComponents()[i];
};
const auto compo = currentNode->GetModelProperties().GetNuclearComposition();
for (auto tid: compo.GetComponents()){
cout << "Interaction: possible targets: " << tid << endl;
}
const auto tg = sample_target( compo );
cout << "Interaction: target selected: " << tg << endl;
// test if valid in sibyll
// FOR NOW: throw error if not, may need workaround for atmosphere, contains small argon fraction
if(IsNucleus(tg))
kTarget = GetNucleusA(tg);
else
if(tg==corsika::particles::Proton::GetCode())
kTarget = 1;
else
throw std::runtime_error("Sibyll target particle unknown. Only nuclei with A<18 or protons are allowed.");
cout << "Interaction: kTarget: " << kTarget << endl;
// redundant check
if(kTarget>18||kTarget==0)
throw std::runtime_error("Sibyll target outside range. Only nuclei with A<18 are allowed.");
const hep::MassType nucleon_mass = 0.5 * (corsika::particles::Proton::GetMass() + const hep::MassType nucleon_mass = 0.5 * (corsika::particles::Proton::GetMass() +
corsika::particles::Neutron::GetMass()); corsika::particles::Neutron::GetMass());
hep::EnergyType Etot = p.GetEnergy() + nucleon_mass;
MomentumVector Ptot(rootCS, {0.0_GeV, 0.0_GeV, 0.0_GeV});
// FOR NOW: assume target is at rest // FOR NOW: assume target is at rest
MomentumVector pTarget(rootCS, {0.0_GeV, 0.0_GeV, 0.0_GeV}); MomentumVector pTarget(rootCS, {0.0_GeV, 0.0_GeV, 0.0_GeV});
// total momentum and energy
hep::EnergyType Etot = p.GetEnergy() + nucleon_mass;
MomentumVector Ptot(rootCS, {0.0_GeV, 0.0_GeV, 0.0_GeV});
Ptot += p.GetMomentum(); Ptot += p.GetMomentum();
Ptot += pTarget; Ptot += pTarget;
// calculate cm. energy // calculate cm. energy
...@@ -175,17 +219,10 @@ namespace corsika::process::sibyll { ...@@ -175,17 +219,10 @@ namespace corsika::process::sibyll {
const CoordinateSystem tempCS = rootCS.rotate(zAxis, phi); const CoordinateSystem tempCS = rootCS.rotate(zAxis, phi);
const CoordinateSystem sibyllCS = tempCS.rotate(yAxis, theta); const CoordinateSystem sibyllCS = tempCS.rotate(yAxis, theta);
/*
the target should be defined by the Environment,
ideally as full particle object so that the four momenta
and the boosts can be defined..
here we need: GetTargetMassNumber() or GetTargetPID()?? // redundant check if target code is valid
GetTargetMomentum() (zero in EAS) if(kTarget>18||kTarget==0)
*/ throw std::runtime_error("Interaction: Sibyll target outside range. Only nuclei with A<18 are allowed.");
// FOR NOW: set target to oxygen
const int kTarget = corsika::particles::Oxygen::
GetNucleusA(); // env.GetTargetParticle().GetPID();
// FOR NOW: target is always at rest // FOR NOW: target is always at rest
const hep::MassType nucleon_mass = 0.5 * (corsika::particles::Proton::GetMass() + const hep::MassType nucleon_mass = 0.5 * (corsika::particles::Proton::GetMass() +
......
...@@ -18,10 +18,6 @@ ...@@ -18,10 +18,6 @@
#include <corsika/geometry/Point.h> #include <corsika/geometry/Point.h>
#include <corsika/units/PhysicalUnits.h> #include <corsika/units/PhysicalUnits.h>
#include <corsika/environment/Environment.h>
#include <corsika/environment/HomogeneousMedium.h>
#include <corsika/environment/NuclearComposition.h>
#define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one #define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one
// cpp file // cpp file
#include <catch2/catch.hpp> #include <catch2/catch.hpp>
...@@ -78,6 +74,10 @@ TEST_CASE("Sibyll", "[processes]") { ...@@ -78,6 +74,10 @@ TEST_CASE("Sibyll", "[processes]") {
#include <corsika/setup/SetupTrajectory.h> #include <corsika/setup/SetupTrajectory.h>
#include <corsika/particles/ParticleProperties.h> #include <corsika/particles/ParticleProperties.h>
#include <corsika/environment/Environment.h>
#include <corsika/environment/HomogeneousMedium.h>
#include <corsika/environment/NuclearComposition.h>
using namespace corsika::units::si; using namespace corsika::units::si;
using namespace corsika::units; using namespace corsika::units;
......
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