diff --git a/Documentation/Examples/cascade_example.cc b/Documentation/Examples/cascade_example.cc index 1b428066812c63c2a1cad080e0010446fb69ac08..6dda883951276c029cd0413351ff0a25c0075097 100644 --- a/Documentation/Examples/cascade_example.cc +++ b/Documentation/Examples/cascade_example.cc @@ -218,8 +218,9 @@ int main() { theMedium->SetModelProperties<MyHomogeneousModel>( 1_kg / (1_m * 1_m * 1_m), corsika::environment::NuclearComposition( - std::vector<corsika::particles::Code>{corsika::particles::Code::Nitrogen,corsika::particles::Code::Oxygen}, - std::vector<float>{(float)1.-fox, fox})); + std::vector<corsika::particles::Code>{corsika::particles::Code::Nitrogen, + corsika::particles::Code::Oxygen}, + std::vector<float>{(float)1. - fox, fox})); universe.AddChild(std::move(theMedium)); @@ -272,8 +273,8 @@ int main() { cout << "Result: E0=" << E0 / 1_GeV << endl; cut.ShowResults(); - const HEPEnergyType Efinal = cut.GetCutEnergy() + cut.GetInvEnergy() + cut.GetEmEnergy(); - cout << "total energy (GeV): " - << Efinal / 1_GeV << endl - << "relative difference (%): " << (Efinal / E0 - 1. ) * 100 << endl; + const HEPEnergyType Efinal = + cut.GetCutEnergy() + cut.GetInvEnergy() + cut.GetEmEnergy(); + cout << "total energy (GeV): " << Efinal / 1_GeV << endl + << "relative difference (%): " << (Efinal / E0 - 1.) * 100 << endl; } diff --git a/Environment/HomogeneousMedium.h b/Environment/HomogeneousMedium.h index 4c9a03f366a52c68b96e3ffe90bca8421b8f7810..9344d200922ad54a8584110c2b411b58fed14990 100644 --- a/Environment/HomogeneousMedium.h +++ b/Environment/HomogeneousMedium.h @@ -16,8 +16,8 @@ #include <corsika/geometry/Point.h> #include <corsika/geometry/Trajectory.h> #include <corsika/particles/ParticleProperties.h> -#include <corsika/units/PhysicalUnits.h> #include <corsika/random/RNGManager.h> +#include <corsika/units/PhysicalUnits.h> /** * a homogeneous medium @@ -42,29 +42,30 @@ namespace corsika::environment { } NuclearComposition const& GetNuclearComposition() const override { return fNuclComp; } - corsika::particles::Code const& GetTarget( std::vector<corsika::units::si::CrossSectionType> &sigma) const override { + corsika::particles::Code const& GetTarget( + std::vector<corsika::units::si::CrossSectionType>& sigma) const override { using namespace corsika::units::si; - int i=-1; + int i = -1; corsika::units::si::CrossSectionType total_weighted_sigma = 0._mbarn; - std::vector<float> fractions; - for(auto w: fNuclComp.GetFractions() ){ - i++; - std::cout << "HomogeneousMedium: fraction: " << w << std::endl; - total_weighted_sigma += w * sigma[i]; - fractions.push_back( w * sigma[i] / 1_mbarn ); + std::vector<float> fractions; + for (auto w : fNuclComp.GetFractions()) { + i++; + std::cout << "HomogeneousMedium: fraction: " << w << std::endl; + total_weighted_sigma += w * sigma[i]; + fractions.push_back(w * sigma[i] / 1_mbarn); } - - for(auto f: fractions){ - f = f / ( total_weighted_sigma / 1_mbarn ); - std::cout << "HomogeneousMedium: reweighted fraction: " << f << std::endl; + + for (auto f : fractions) { + f = f / (total_weighted_sigma / 1_mbarn); + std::cout << "HomogeneousMedium: reweighted fraction: " << f << std::endl; } - std::discrete_distribution channelDist( fractions.begin(), fractions.end() ); + std::discrete_distribution channelDist(fractions.begin(), fractions.end()); static corsika::random::RNG& kRNG = - corsika::random::RNGManager::GetInstance().GetRandomStream("s_rndm"); + corsika::random::RNGManager::GetInstance().GetRandomStream("s_rndm"); const int ichannel = channelDist(kRNG); return fNuclComp.GetComponents()[ichannel]; } - + corsika::units::si::GrammageType IntegratedGrammage( corsika::geometry::Trajectory<corsika::geometry::Line> const&, corsika::units::si::LengthType pTo) const override { @@ -76,7 +77,7 @@ namespace corsika::environment { corsika::geometry::Trajectory<corsika::geometry::Line> const&, corsika::units::si::GrammageType pGrammage) const override { return pGrammage / fDensity; - } + } }; } // namespace corsika::environment diff --git a/Environment/IMediumModel.h b/Environment/IMediumModel.h index 24393e805eb46a90febe4ac568c2949334f88bfe..3dabc3f983e187c0d88371262e38abc14720e02c 100644 --- a/Environment/IMediumModel.h +++ b/Environment/IMediumModel.h @@ -39,7 +39,8 @@ namespace corsika::environment { virtual NuclearComposition const& GetNuclearComposition() const = 0; - virtual corsika::particles::Code const& GetTarget( std::vector<corsika::units::si::CrossSectionType> &) const = 0; + virtual corsika::particles::Code const& GetTarget( + std::vector<corsika::units::si::CrossSectionType>&) const = 0; }; } // namespace corsika::environment diff --git a/Framework/ProcessSequence/ProcessSequence.h b/Framework/ProcessSequence/ProcessSequence.h index 632c57848fc734861cd2dab29325a0c0961206ff..6af26b0abdbc9cac073d1c833e085c4c8295ce78 100644 --- a/Framework/ProcessSequence/ProcessSequence.h +++ b/Framework/ProcessSequence/ProcessSequence.h @@ -138,7 +138,8 @@ namespace corsika::process { template <typename Particle, typename Stack> EProcessReturn SelectInteraction( - Particle& p, Stack& s, [[maybe_unused]]corsika::units::si::InverseGrammageType lambda_select, + Particle& p, Stack& s, + [[maybe_unused]] corsika::units::si::InverseGrammageType lambda_select, corsika::units::si::InverseGrammageType& lambda_inv_count) { if constexpr (is_process_sequence<T1type>::value) { @@ -204,9 +205,10 @@ namespace corsika::process { // select decay process template <typename Particle, typename Stack> - EProcessReturn SelectDecay(Particle& p, Stack& s, - [[maybe_unused]] corsika::units::si::InverseTimeType decay_select, - corsika::units::si::InverseTimeType& decay_inv_count) { + EProcessReturn SelectDecay( + Particle& p, Stack& s, + [[maybe_unused]] corsika::units::si::InverseTimeType decay_select, + corsika::units::si::InverseTimeType& decay_inv_count) { if constexpr (is_process_sequence<T1>::value) { // if A is a process sequence --> check inside const EProcessReturn ret = A.SelectDecay(p, s, decay_select, decay_inv_count); diff --git a/Processes/Sibyll/Decay.h b/Processes/Sibyll/Decay.h index a798f318db53e994ba7a1edff828e9010dec979d..e7ed3165dc46bd50e193298f8a63956becf028f4 100644 --- a/Processes/Sibyll/Decay.h +++ b/Processes/Sibyll/Decay.h @@ -169,7 +169,7 @@ namespace corsika::process { using corsika::geometry::Point; using namespace corsika::units::si; - // TODO: this should be done in a central, common place. Not here.. + // TODO: this should be done in a central, common place. Not here.. #ifndef CORSIKA_OSX feenableexcept(FE_INVALID); #endif @@ -185,7 +185,8 @@ namespace corsika::process { pin.SetMomentum(p.GetMomentum()); // setting particle mass with Corsika values, may be inconsistent with sibyll // internal values - // TODO: #warning setting particle mass with Corsika values, may be inconsistent with sibyll internal values + // TODO: #warning setting particle mass with Corsika values, may be inconsistent + // with sibyll internal values pin.SetMass(corsika::particles::GetMass(pCode)); // remember position Point decayPoint = p.GetPosition(); @@ -219,7 +220,7 @@ namespace corsika::process { // empty sibyll stack ss.Clear(); - // TODO: this should be done in a central, common place. Not here.. + // TODO: this should be done in a central, common place. Not here.. #ifndef CORSIKA_OSX fedisableexcept(FE_INVALID); #endif diff --git a/Processes/Sibyll/Interaction.h b/Processes/Sibyll/Interaction.h index e646858e813d4faee03ac41121f0729134609a7a..003d22a5f1bd5d97373be79ab0cbdf3980d48560 100644 --- a/Processes/Sibyll/Interaction.h +++ b/Processes/Sibyll/Interaction.h @@ -14,15 +14,15 @@ #include <corsika/process/InteractionProcess.h> +#include <corsika/environment/Environment.h> +#include <corsika/environment/NuclearComposition.h> +#include <corsika/particles/ParticleProperties.h> #include <corsika/process/sibyll/ParticleConversion.h> #include <corsika/process/sibyll/SibStack.h> #include <corsika/process/sibyll/sibyll2.3c.h> -#include <corsika/utl/COMBoost.h> -#include <corsika/particles/ParticleProperties.h> #include <corsika/random/RNGManager.h> #include <corsika/units/PhysicalUnits.h> -#include <corsika/environment/Environment.h> -#include <corsika/environment/NuclearComposition.h> +#include <corsika/utl/COMBoost.h> namespace corsika::process::sibyll { @@ -30,8 +30,10 @@ namespace corsika::process::sibyll { int fCount = 0; int fNucCount = 0; + public: - Interaction(corsika::environment::Environment const& env) : fEnvironment(env) { } + Interaction(corsika::environment::Environment const& env) + : fEnvironment(env) {} ~Interaction() { std::cout << "Sibyll::Interaction n=" << fCount << " Nnuc=" << fNucCount << std::endl; @@ -45,38 +47,37 @@ namespace corsika::process::sibyll { corsika::random::RNGManager& rmng = corsika::random::RNGManager::GetInstance(); rmng.RegisterRandomStream("s_rndm"); - + // initialize Sibyll sibyll_ini_(); } - std::tuple<corsika::units::si::CrossSectionType, int> GetCrossSection(const corsika::particles::Code &BeamId, const corsika::particles::Code & TargetId, const corsika::units::si::HEPEnergyType& CoMenergy) - { + std::tuple<corsika::units::si::CrossSectionType, int> GetCrossSection( + const corsika::particles::Code& BeamId, const corsika::particles::Code& TargetId, + const corsika::units::si::HEPEnergyType& CoMenergy) { using namespace corsika::units::si; double sigProd, dummy, dum1, dum2, dum3, dum4; double dumdif[3]; const int iBeam = process::sibyll::GetSibyllXSCode(BeamId); const double dEcm = CoMenergy / 1_GeV; - if(corsika::particles::IsNucleus( TargetId )){ - const int iTarget = corsika::particles::GetNucleusA( TargetId ); - if(iTarget>18||iTarget==0) - throw std::runtime_error("Sibyll target outside range. Only nuclei with A<18 are allowed."); - sib_sigma_hnuc_(iBeam, iTarget, dEcm, sigProd, dummy); - return std::make_tuple( sigProd * 1_mbarn, iTarget ); + if (corsika::particles::IsNucleus(TargetId)) { + const int iTarget = corsika::particles::GetNucleusA(TargetId); + if (iTarget > 18 || iTarget == 0) + throw std::runtime_error( + "Sibyll target outside range. Only nuclei with A<18 are allowed."); + sib_sigma_hnuc_(iBeam, iTarget, dEcm, sigProd, dummy); + return std::make_tuple(sigProd * 1_mbarn, iTarget); + } else { + if (TargetId == corsika::particles::Proton::GetCode()) { + sib_sigma_hp_(iBeam, dEcm, dum1, dum2, sigProd, dumdif, dum3, dum4); + return std::make_tuple(sigProd * 1_mbarn, 1); + } else + // no interaction in sibyll possible, return infinite cross section? or throw? + sigProd = std::numeric_limits<double>::infinity(); + return std::make_tuple(sigProd * 1_mbarn, 0); } - else - { - if (TargetId == corsika::particles::Proton::GetCode()){ - sib_sigma_hp_(iBeam, dEcm, dum1, dum2, sigProd, dumdif, dum3, dum4); - return std::make_tuple( sigProd * 1_mbarn, 1 ); - } - else - // no interaction in sibyll possible, return infinite cross section? or throw? - sigProd = std::numeric_limits<double>::infinity(); - return std::make_tuple( sigProd * 1_mbarn, 0 ); - } } - + template <typename Particle, typename Track> corsika::units::si::GrammageType GetInteractionLength(Particle& p, Track&) { @@ -95,9 +96,9 @@ namespace corsika::process::sibyll { // beam particles for sibyll : 1, 2, 3 for p, pi, k // read from cross section code table const bool kInteraction = process::sibyll::CanInteract(corsikaBeamId); - + const HEPMassType nucleon_mass = 0.5 * (corsika::particles::Proton::GetMass() + - corsika::particles::Neutron::GetMass()); + corsika::particles::Neutron::GetMass()); // FOR NOW: assume target is at rest MomentumVector pTarget(rootCS, {0.0_GeV, 0.0_GeV, 0.0_GeV}); @@ -117,42 +118,48 @@ namespace corsika::process::sibyll { if (kInteraction && Elab >= 8.5_GeV && ECoM >= 10_GeV) { - // get target from environment - /* - the target should be defined by the Environment, - ideally as full particle object so that the four momenta - and the boosts can be defined.. - */ - const auto currentNode = fEnvironment.GetUniverse()->GetContainingNode(p.GetPosition()); - const auto mediumComposition = currentNode->GetModelProperties().GetNuclearComposition(); - // determine average interaction length - // weighted sum - int i =-1; - double avgTargetMassNumber = 0.; - si::CrossSectionType weightedProdCrossSection = 0_mbarn; - // get weights of components from environment/medium - const auto w = mediumComposition.GetFractions(); - // loop over components in medium - for (auto targetId: mediumComposition.GetComponents() ){ - i++; - cout << "Interaction: get interaction length for target: " << targetId << endl; - - auto const [ productionCrossSection, numberOfNucleons ] = GetCrossSection( corsikaBeamId, targetId, ECoM); - - std::cout << "Interaction: " - << " IntLength: sibyll return (mb): " << productionCrossSection / 1_mbarn << std::endl; - weightedProdCrossSection += w[i] * productionCrossSection; - avgTargetMassNumber += w[i] * numberOfNucleons; - } - cout << "Interaction: " - << "IntLength: weighted CrossSection (mb): " << weightedProdCrossSection / 1_mbarn - << endl; - - // calculate interaction length in medium -#warning check interaction length units - GrammageType int_length = avgTargetMassNumber * corsika::units::constants::u / weightedProdCrossSection; - std::cout << "Interaction: " - << "interaction length (g/cm2): " << int_length / ( 0.001_kg ) * 1_cm * 1_cm << std::endl; + // get target from environment + /* + the target should be defined by the Environment, + ideally as full particle object so that the four momenta + and the boosts can be defined.. + */ + const auto currentNode = + fEnvironment.GetUniverse()->GetContainingNode(p.GetPosition()); + const auto mediumComposition = + currentNode->GetModelProperties().GetNuclearComposition(); + // determine average interaction length + // weighted sum + int i = -1; + double avgTargetMassNumber = 0.; + si::CrossSectionType weightedProdCrossSection = 0_mbarn; + // get weights of components from environment/medium + const auto w = mediumComposition.GetFractions(); + // loop over components in medium + for (auto targetId : mediumComposition.GetComponents()) { + i++; + cout << "Interaction: get interaction length for target: " << targetId << endl; + + auto const [productionCrossSection, numberOfNucleons] = + GetCrossSection(corsikaBeamId, targetId, ECoM); + + std::cout << "Interaction: " + << " IntLength: sibyll return (mb): " + << productionCrossSection / 1_mbarn << std::endl; + weightedProdCrossSection += w[i] * productionCrossSection; + avgTargetMassNumber += w[i] * numberOfNucleons; + } + cout << "Interaction: " + << "IntLength: weighted CrossSection (mb): " + << weightedProdCrossSection / 1_mbarn << endl; + + // calculate interaction length in medium +#warning check interaction length units + GrammageType int_length = + avgTargetMassNumber * corsika::units::constants::u / weightedProdCrossSection; + std::cout << "Interaction: " + << "interaction length (g/cm2): " + << int_length / (0.001_kg) * 1_cm * 1_cm << std::endl; return int_length; } @@ -173,99 +180,102 @@ namespace corsika::process::sibyll { const auto corsikaBeamId = p.GetPID(); cout << "ProcessSibyll: " << "DoInteraction: " << corsikaBeamId << " interaction? " - << process::sibyll::CanInteract( corsikaBeamId ) << endl; - if (process::sibyll::CanInteract(corsikaBeamId) ) { + << process::sibyll::CanInteract(corsikaBeamId) << endl; + if (process::sibyll::CanInteract(corsikaBeamId)) { const CoordinateSystem& rootCS = RootCoordinateSystem::GetInstance().GetRootCoordinateSystem(); - // position and time of interaction, not used in Sibyll + // position and time of interaction, not used in Sibyll Point pOrig = p.GetPosition(); TimeType tOrig = p.GetTime(); - - // define target - // for Sibyll is always a single nucleon + + // define target + // for Sibyll is always a single nucleon auto constexpr nucleon_mass = 0.5 * (corsika::particles::Proton::GetMass() + - corsika::particles::Neutron::GetMass()); - // FOR NOW: target is always at rest + corsika::particles::Neutron::GetMass()); + // FOR NOW: target is always at rest const auto eTargetLab = 0_GeV + nucleon_mass; const auto pTargetLab = MomentumVector(rootCS, 0_GeV, 0_GeV, 0_GeV); - // define projectile - auto const pProjectileLab = p.GetMomentum(); - HEPEnergyType const eProjectileLab = p.GetEnergy(); - - // define target kinematics in lab frame - HEPMassType const targetMass = nucleon_mass; - // define boost to and from CoM frame - // CoM frame definition in Sibyll projectile: +z - COMBoost const boost(eProjectileLab, pProjectileLab, targetMass); - - cout << "Interaction: ebeam lab: " << eProjectileLab / 1_GeV << endl - << "Interaction: pbeam lab: " << pProjectileLab.GetComponents() / 1_GeV << endl; - cout << "Interaction: etarget lab: " << eTargetLab / 1_GeV << endl - << "Interaction: ptarget lab: " << pTargetLab.GetComponents() / 1_GeV << endl; - - // just for show: - // boost projecticle - auto const [eProjectileCoM, pProjectileCoM] = - boost.toCoM(eProjectileLab, pProjectileLab); - - // boost target - auto const [eTargetCoM, pTargetCoM] = - boost.toCoM(eTargetLab, pTargetLab); - - cout << "Interaction: ebeam CoM: " << eProjectileCoM / 1_GeV << endl - << "Interaction: pbeam CoM: " << pProjectileCoM / 1_GeV << endl; - cout << "Interaction: etarget CoM: " << eTargetCoM / 1_GeV << endl - << "Interaction: ptarget CoM: " << pTargetCoM / 1_GeV << endl; - - cout << "Interaction: position of interaction: " << pOrig.GetCoordinates() << endl; + // define projectile + auto const pProjectileLab = p.GetMomentum(); + HEPEnergyType const eProjectileLab = p.GetEnergy(); + + // define target kinematics in lab frame + HEPMassType const targetMass = nucleon_mass; + // define boost to and from CoM frame + // CoM frame definition in Sibyll projectile: +z + COMBoost const boost(eProjectileLab, pProjectileLab, targetMass); + + cout << "Interaction: ebeam lab: " << eProjectileLab / 1_GeV << endl + << "Interaction: pbeam lab: " << pProjectileLab.GetComponents() / 1_GeV + << endl; + cout << "Interaction: etarget lab: " << eTargetLab / 1_GeV << endl + << "Interaction: ptarget lab: " << pTargetLab.GetComponents() / 1_GeV + << endl; + + // just for show: + // boost projecticle + auto const [eProjectileCoM, pProjectileCoM] = + boost.toCoM(eProjectileLab, pProjectileLab); + + // boost target + auto const [eTargetCoM, pTargetCoM] = boost.toCoM(eTargetLab, pTargetLab); + + cout << "Interaction: ebeam CoM: " << eProjectileCoM / 1_GeV << endl + << "Interaction: pbeam CoM: " << pProjectileCoM / 1_GeV << endl; + cout << "Interaction: etarget CoM: " << eTargetCoM / 1_GeV << endl + << "Interaction: ptarget CoM: " << pTargetCoM / 1_GeV << endl; + + cout << "Interaction: position of interaction: " << pOrig.GetCoordinates() + << endl; cout << "Interaction: time: " << tOrig << endl; - HEPEnergyType Etot = eProjectileLab + eTargetLab; - MomentumVector Ptot = p.GetMomentum(); - // invariant mass, i.e. cm. energy + HEPEnergyType Etot = eProjectileLab + eTargetLab; + MomentumVector Ptot = p.GetMomentum(); + // invariant mass, i.e. cm. energy HEPEnergyType Ecm = sqrt(Etot * Etot - Ptot.squaredNorm()); - - - // sample target mass number - const auto currentNode = fEnvironment.GetUniverse()->GetContainingNode(pOrig); - const auto mediumComposition = currentNode->GetModelProperties().GetNuclearComposition(); - // get cross sections for target materials - /* - Here we read the cross section from the interaction model again, - should be passed from GetInteractionLength if possible - */ + + // sample target mass number + const auto currentNode = fEnvironment.GetUniverse()->GetContainingNode(pOrig); + const auto mediumComposition = + currentNode->GetModelProperties().GetNuclearComposition(); + // get cross sections for target materials + /* + Here we read the cross section from the interaction model again, + should be passed from GetInteractionLength if possible + */ #warning reading interaction cross section again, should not be necessary - std::vector<si::CrossSectionType> cross_section_of_components; - for(auto targetId: mediumComposition.GetComponents() ){ - const auto [sigProd, nNuc] = GetCrossSection( corsikaBeamId, targetId, Ecm); - cross_section_of_components.push_back( sigProd ); - } - - const auto targetCode = currentNode->GetModelProperties().GetTarget( cross_section_of_components); - cout << "Interaction: target selected: " << targetCode << endl; - /* - FOR NOW: allow nuclei with A<18 or protons only. - when medium composition becomes more complex, approximations will have to be allowed - air in atmosphere also contains some Argon. - */ - int targetSibCode = -1; - if( IsNucleus(targetCode)) - targetSibCode = GetNucleusA( targetCode ); - if( targetCode == corsika::particles::Proton::GetCode()) - targetSibCode = 1; - cout << "Interaction: sibyll code: " << targetSibCode << endl; - if(targetSibCode>18||targetSibCode<1) - throw std::runtime_error("Sibyll target outside range. Only nuclei with A<18 or protons are allowed."); - - // beam id for sibyll + std::vector<si::CrossSectionType> cross_section_of_components; + for (auto targetId : mediumComposition.GetComponents()) { + const auto [sigProd, nNuc] = GetCrossSection(corsikaBeamId, targetId, Ecm); + cross_section_of_components.push_back(sigProd); + } + + const auto targetCode = + currentNode->GetModelProperties().GetTarget(cross_section_of_components); + cout << "Interaction: target selected: " << targetCode << endl; + /* + FOR NOW: allow nuclei with A<18 or protons only. + when medium composition becomes more complex, approximations will have to be + allowed air in atmosphere also contains some Argon. + */ + int targetSibCode = -1; + if (IsNucleus(targetCode)) targetSibCode = GetNucleusA(targetCode); + if (targetCode == corsika::particles::Proton::GetCode()) targetSibCode = 1; + cout << "Interaction: sibyll code: " << targetSibCode << endl; + if (targetSibCode > 18 || targetSibCode < 1) + throw std::runtime_error( + "Sibyll target outside range. Only nuclei with A<18 or protons are " + "allowed."); + + // beam id for sibyll const int kBeam = process::sibyll::ConvertToSibyllRaw(corsikaBeamId); std::cout << "Interaction: " << " DoInteraction: E(GeV):" << eProjectileLab / 1_GeV << " Ecm(GeV): " << Ecm / 1_GeV << std::endl; - if ( eProjectileLab < 8.5_GeV || Ecm < 10_GeV) { + if (eProjectileLab < 8.5_GeV || Ecm < 10_GeV) { std::cout << "Interaction: " << " DoInteraction: should have dropped particle.." << std::endl; // p.Delete(); delete later... different process @@ -298,35 +308,34 @@ namespace corsika::process::sibyll { if (psib.HasDecayed()) continue; // transform energy to lab. frame - auto const pCoM = psib.GetMomentum().GetComponents(); - HEPEnergyType const eCoM = psib.GetEnergy(); - auto const [ eLab, pLab ] = boost.fromCoM( eCoM, pCoM ); - + auto const pCoM = psib.GetMomentum().GetComponents(); + HEPEnergyType const eCoM = psib.GetEnergy(); + auto const [eLab, pLab] = boost.fromCoM(eCoM, pCoM); + // add to corsika stack auto pnew = s.NewParticle(); - pnew.SetPID(process::sibyll::ConvertFromSibyll(psib.GetPID())); - pnew.SetEnergy(eLab); + pnew.SetPID(process::sibyll::ConvertFromSibyll(psib.GetPID())); + pnew.SetEnergy(eLab); pnew.SetMomentum(pLab); pnew.SetPosition(pOrig); pnew.SetTime(tOrig); - + Plab_final += pnew.GetMomentum(); Elab_final += pnew.GetEnergy(); Ecm_final += psib.GetEnergy(); } - std::cout << "conservation (all GeV): Ecm_final=" << Ecm_final / 1_GeV << std::endl + std::cout << "conservation (all GeV): Ecm_final=" << Ecm_final / 1_GeV + << std::endl << "Elab_final=" << Elab_final / 1_GeV << ", Plab_final=" << (Plab_final / 1_GeV).GetComponents() << std::endl; - } } return process::EProcessReturn::eOk; } - + private: corsika::environment::Environment const& fEnvironment; - }; } // namespace corsika::process::sibyll diff --git a/Processes/Sibyll/testSibyll.cc b/Processes/Sibyll/testSibyll.cc index eb3259e792aa86899f6569b7a1247dce8acd4cf6..8c8ce3b5e69e563238fadc2416bd1f91351603ac 100644 --- a/Processes/Sibyll/testSibyll.cc +++ b/Processes/Sibyll/testSibyll.cc @@ -70,9 +70,9 @@ TEST_CASE("Sibyll", "[processes]") { #include <corsika/units/PhysicalUnits.h> +#include <corsika/particles/ParticleProperties.h> #include <corsika/setup/SetupStack.h> #include <corsika/setup/SetupTrajectory.h> -#include <corsika/particles/ParticleProperties.h> #include <corsika/environment/Environment.h> #include <corsika/environment/HomogeneousMedium.h> @@ -83,12 +83,12 @@ using namespace corsika::units; TEST_CASE("SibyllInterface", "[processes]") { - // setup environment, geometry + // setup environment, geometry corsika::environment::Environment env; auto& universe = *(env.GetUniverse()); auto theMedium = corsika::environment::Environment::CreateNode<geometry::Sphere>( - geometry::Point{env.GetCoordinateSystem(), 0_m, 0_m, 0_m}, + geometry::Point{env.GetCoordinateSystem(), 0_m, 0_m, 0_m}, 1_km * std::numeric_limits<double>::infinity()); using MyHomogeneousModel = @@ -109,14 +109,13 @@ TEST_CASE("SibyllInterface", "[processes]") { geometry::Line line(origin, v); geometry::Trajectory<geometry::Line> track(line, 10_s); - SECTION("InteractionInterface") { setup::Stack stack; auto particle = stack.NewParticle(); - + Interaction model(env); - + model.Init(); [[maybe_unused]] const process::EProcessReturn ret = model.DoInteraction(particle, stack); @@ -131,7 +130,8 @@ TEST_CASE("SibyllInterface", "[processes]") { { const HEPEnergyType E0 = 10_GeV; particle.SetPID(particles::Code::Proton); - HEPMomentumType P0 = sqrt(E0 * E0 - particles::Proton::GetMass() * particles::Proton::GetMass()); + HEPMomentumType P0 = + sqrt(E0 * E0 - particles::Proton::GetMass() * particles::Proton::GetMass()); auto plab = stack::super_stupid::MomentumVector(cs, {0_GeV, 0_GeV, -P0}); particle.SetEnergy(E0); particle.SetMomentum(plab); @@ -139,9 +139,9 @@ TEST_CASE("SibyllInterface", "[processes]") { geometry::Point p(cs, 0_m, 0_m, 0_m); particle.SetPosition(p); } - + Decay model; - + model.Init(); /*[[maybe_unused]] const process::EProcessReturn ret =*/model.DoDecay(particle, stack);