diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8992c3c453ddcae3daa1d83a92366e2c3862e5af..2fc025461b364b42cffc24acba8e145bdb0e6e4f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -92,7 +92,7 @@ check-clang-format: script: - mkdir -p build - cd build - - cmake .. -DCMAKE_BUILD_TYPE=Debug -DUSE_PYTHIA8_C8=SYSTEM + - cmake .. -DCMAKE_BUILD_TYPE=Debug -DUSE_PYTHIA8_C8=C8 rules: - if: $CI_MERGE_REQUEST_ID - if: $CI_COMMIT_TAG @@ -450,7 +450,7 @@ install-clang-8: - corsika script: - cd build - - cmake .. -DCMAKE_BUILD_TYPE=Release -DUSE_PYTHIA8_C8=SYSTEM + - cmake .. -DCMAKE_BUILD_TYPE=Release -DUSE_PYTHIA8_C8=C8 - cmake --build . -- -j4 - set -o pipefail - ctest -j4 @@ -513,7 +513,7 @@ coverage: - corsika script: - cd build - - cmake .. -DCMAKE_BUILD_TYPE=Coverage -DUSE_PYTHIA8_C8=SYSTEM + - cmake .. -DCMAKE_BUILD_TYPE=Coverage -DUSE_PYTHIA8_C8=C8 - cmake --build . -- -j4 - ctest -j4 - cmake --build . --target coverage diff --git a/CMakeLists.txt b/CMakeLists.txt index 541b597d633d0d27c66420299ad82c3f7604af3d..c8a4cb765ec196e42197e9a802f5dbfa0959ad7d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -225,7 +225,7 @@ add_subdirectory (documentation) # modules # set (CORSIKA_DATA_WITH_TEST ON) # we want to run the corsika-data unit test -add_subdirectory (modules/data) +add_subdirectory (modules/data) # this is corsika-data (submodule) add_subdirectory (modules/pythia) add_subdirectory (modules/sibyll) add_subdirectory (modules/qgsjetII) @@ -234,8 +234,8 @@ add_subdirectory (modules/conex) # # we really need a better proposal CMakeList.txt files: set (ADD_PYTHON OFF) -file(READ modules/CMakeLists_PROPOSAL.txt overwrite_CMakeLists_PROPOSAL_txt) -file(WRITE modules/proposal/CMakeLists.txt ${overwrite_CMakeLists_PROPOSAL_txt}) +file (READ modules/CMakeLists_PROPOSAL.txt overwrite_CMakeLists_PROPOSAL_txt) +file (WRITE modules/proposal/CMakeLists.txt ${overwrite_CMakeLists_PROPOSAL_txt}) add_subdirectory (modules/proposal) target_link_libraries (CORSIKA8 INTERFACE PROPOSAL) diff --git a/cmake/FindPythia8.cmake b/cmake/FindPythia8.cmake index 88535cede70317aa9c2c6a53f5e84e08f1924a34..0818c4f1be66834cade34eb4e6e146f269d76c0d 100644 --- a/cmake/FindPythia8.cmake +++ b/cmake/FindPythia8.cmake @@ -14,7 +14,7 @@ # function (_Pythia8_CONFIG_ option variable type doc) - execute_process(COMMAND ${Pythia8_CONFIG} ${option} + execute_process (COMMAND ${Pythia8_CONFIG} ${option} OUTPUT_VARIABLE _local_out_ RESULT_VARIABLE _local_res_) string (REGEX REPLACE "\n$" "" _local_out_ "${_local_out_}") @@ -25,6 +25,14 @@ function (_Pythia8_CONFIG_ option variable type doc) endif () endfunction (_Pythia8_CONFIG_) +################################################# +# +# take directory and assume standard install layout +# + +function (_Pythia8_LAYOUT_ dir variable type doc) + set (${variable} "${dir}" CACHE ${type} ${doc}) +endfunction (_Pythia8_LAYOUT_) ################################################# @@ -49,26 +57,42 @@ set (_SEARCH_Pythia8_ $ENV{PYTHIA8_ROOT} ${PYTHIA8_DIR} $ENV{PYTHIA8_DIR} + ${Pythia8_DIR} + $ENV{Pythia8_DIR} /opt/pythia8 ) -find_program (Pythia8_CONFIG - NAME pythia8-config +find_file (Pythia8_Pythia_h_LOC + NAME Pythia.h PATHS ${_SEARCH_Pythia8_} - PATH_SUFFIXES "/bin" - DOC "The location of the pythia8-config script") + PATH_SUFFIXES include/Pythia8 + DOC "The location of the Pythia8/Pythia.h script" + REQUIRED) +string (REPLACE "/include/Pythia8/Pythia.h" "" Pythia8_DIR ${Pythia8_Pythia_h_LOC}) +set (Pythia8_CONFIG ${Pythia8_DIR}/bin/pythia-config) if (Pythia8_CONFIG) set (HAVE_Pythia8 1 CACHE BOOL "presence of pythia8, found via pythia8-config") - _Pythia8_CONFIG_ ("--prefix" Pythia8_PREFIX PATH "location of pythia8 installation") - _Pythia8_CONFIG_ ("--includedir" Pythia8_INCLUDE_DIR PATH "pythia8 include directory") - _Pythia8_CONFIG_ ("--libdir" Pythia8_LIBRARY STRING "the pythia8 libs") - _Pythia8_CONFIG_ ("--datadir" Pythia8_DATA_DIR PATH "the pythia8 data dir") - _Pythia8_CONFIG_ ("--cxxflags" Pythia8_CXXFLAGS STRING "the pythia8 cxxflags") + # pythia-config is not relocatable + #_Pythia8_CONFIG_ ("--prefix" Pythia8_PREFIX PATH "location of pythia8 installation") + #_Pythia8_CONFIG_ ("--includedir" Pythia8_INCLUDE_DIR PATH "pythia8 include directory") + #_Pythia8_CONFIG_ ("--libdir" Pythia8_LIBRARY STRING "the pythia8 libs") + #_Pythia8_CONFIG_ ("--datadir" Pythia8_DATA_DIR PATH "the pythia8 data dir") + _Pythia8_LAYOUT_ ("${Pythia8_DIR}" Pythia8_PREFIX PATH "location of pythia8 installation") + _Pythia8_LAYOUT_ ("${Pythia8_DIR}/include" Pythia8_INCLUDE_DIR PATH "pythia8 include directory") + _Pythia8_LAYOUT_ ("${Pythia8_DIR}/lib" Pythia8_LIBRARY STRING "the pythia8 libs") + _Pythia8_LAYOUT_ ("${Pythia8_DIR}/share/Pythia8/xmldoc" Pythia8_DATA_DIR PATH "the pythia8 data dir") + + # read the config string + file (READ "${Pythia8_INCLUDE_DIR}/Pythia8/Pythia.h" Pythia8_TMP_PYTHIA_H) + string (REGEX MATCH "#define PYTHIA_VERSION_INTEGER ([0-9]*)" _ ${Pythia8_TMP_PYTHIA_H}) + set (Pythia8_VERSION ${CMAKE_MATCH_1}) + message (STATUS "Found Pythia8 version: ${Pythia8_VERSION}") + endif () # standard cmake infrastructure: include (FindPackageHandleStandardArgs) -find_package_handle_standard_args (Pythia8 DEFAULT_MSG Pythia8_PREFIX Pythia8_INCLUDE_DIR Pythia8_LIBRARY) -mark_as_advanced (Pythia8_DATA_DIR Pythia8_CXXFLAGS Pythia8_INCLUDE_DIR Pythia8_LIBRARY) +find_package_handle_standard_args (Pythia8 REQUIRED_VARS Pythia8_PREFIX Pythia8_INCLUDE_DIR Pythia8_LIBRARY VERSION_VAR Pythia8_VERSION) +mark_as_advanced (Pythia8_DATA_DIR Pythia8_INCLUDE_DIR Pythia8_LIBRARY) diff --git a/corsika/detail/framework/geometry/FourVector.inl b/corsika/detail/framework/geometry/FourVector.inl index 135790bfcfa83efaf1a78f218228d0c2557f5853..6c0a039e5466ef46d2d3014b7e91a6f0621c922c 100644 --- a/corsika/detail/framework/geometry/FourVector.inl +++ b/corsika/detail/framework/geometry/FourVector.inl @@ -95,7 +95,7 @@ namespace corsika { template <typename TTimeType, typename TSpaceVecType> typename FourVector<TTimeType, TSpaceVecType>::norm_type - FourVector<TTimeType, TSpaceVecType>::operator*(FourVector const& b) { + FourVector<TTimeType, TSpaceVecType>::operator*(FourVector const& b) { if constexpr (std::is_same<time_type, decltype(std::declval<space_type>() / meter * second)>::value) return timeLike_ * b.timeLike_ * constants::cSquared - spaceLike_.norm(); diff --git a/corsika/detail/framework/geometry/QuantityVector.inl b/corsika/detail/framework/geometry/QuantityVector.inl index 994f70689a97d2cc6f183f7d6e03e9558f08b7ba..9df35aab4827ecf034697b9554498eb45f7fb428 100644 --- a/corsika/detail/framework/geometry/QuantityVector.inl +++ b/corsika/detail/framework/geometry/QuantityVector.inl @@ -18,7 +18,7 @@ namespace corsika { template <typename TDimension> inline typename QuantityVector<TDimension>::quantity_type - QuantityVector<TDimension>::operator[](size_t const index) const { + QuantityVector<TDimension>::operator[](size_t const index) const { return quantity_type(phys::units::detail::magnitude_tag, eigenVector_[index]); } diff --git a/corsika/detail/media/WeightProvider.inl b/corsika/detail/media/WeightProvider.inl index c075b236350127c9978fb7c08d87ed035292e5a8..af9849aa3ca75b9bdaeefc661d56232f1ab895f4 100644 --- a/corsika/detail/media/WeightProvider.inl +++ b/corsika/detail/media/WeightProvider.inl @@ -20,7 +20,7 @@ namespace corsika { template <class AConstIterator, class BConstIterator> typename WeightProviderIterator<AConstIterator, BConstIterator>::value_type - WeightProviderIterator<AConstIterator, BConstIterator>::operator*() const { + WeightProviderIterator<AConstIterator, BConstIterator>::operator*() const { return ((*aIter_) * (*bIter_)).magnitude(); } diff --git a/corsika/detail/modules/LongitudinalProfile.inl b/corsika/detail/modules/LongitudinalProfile.inl index 592f71464ed54d75cc7a20c30f43d08cd59384ad..d18813c26f08a7fc42dfaa0042579943b3185d69 100644 --- a/corsika/detail/modules/LongitudinalProfile.inl +++ b/corsika/detail/modules/LongitudinalProfile.inl @@ -37,6 +37,7 @@ namespace corsika { "pos1={} m, pos2={}, X={} g/cm2", vTrack.getPosition(0).getCoordinates() / 1_m, vTrack.getPosition(1).getCoordinates() / 1_m, grammageStart / 1_g * square(1_cm)); + // Note: particle may go also "upward", thus, grammageEnd<grammageStart const int binStart = std::ceil(grammageStart / dX_); const int binEnd = std::floor(grammageEnd / dX_); diff --git a/corsika/detail/modules/energy_loss/BetheBlochPDG.inl b/corsika/detail/modules/energy_loss/BetheBlochPDG.inl index 1f3d0e9303cb60f40fb588ecad70034c634dd1c8..89fe81c7bee6316b97c9cd78322dfef247eade3d 100644 --- a/corsika/detail/modules/energy_loss/BetheBlochPDG.inl +++ b/corsika/detail/modules/energy_loss/BetheBlochPDG.inl @@ -149,7 +149,7 @@ namespace corsika { p.getChargeNumber(), dX / 1_g * square(1_cm)); HEPEnergyType dE = getTotalEnergyLoss(p, dX); auto E = p.getEnergy(); - const auto Ekin = E - p.getMass(); + [[maybe_unused]] const auto Ekin = E - p.getMass(); auto Enew = E + dE; CORSIKA_LOG_DEBUG("EnergyLoss dE={} MeV, E={} GeV, Ekin={} GeV, Enew={} GeV", dE / 1_MeV, E / 1_GeV, Ekin / 1_GeV, Enew / 1_GeV); @@ -197,23 +197,34 @@ namespace corsika { void BetheBlochPDG::fillProfile(setup::Trajectory const& vTrack, const HEPEnergyType dE) { - GrammageType const grammageStart = shower_axis_.getProjectedX(vTrack.getPosition(0)); - GrammageType const grammageEnd = shower_axis_.getProjectedX(vTrack.getPosition(1)); - const auto deltaX = grammageEnd - grammageStart; + GrammageType grammageStart = shower_axis_.getProjectedX(vTrack.getPosition(0)); + GrammageType grammageEnd = shower_axis_.getProjectedX(vTrack.getPosition(1)); + + if (grammageStart > grammageEnd) { // particle going upstream + std::swap(grammageStart, grammageEnd); + } + + GrammageType const deltaX = grammageEnd - grammageStart; - int const binStart = grammageStart / dX_; - if (binStart < 0) return; - int const binEnd = grammageEnd / dX_; - if (binEnd > int(profile_.size() - 1)) return; if (deltaX < dX_threshold_) return; + // only register the range that is covered by the profile + int const maxBin = int(profile_.size() - 1); + int binStart = grammageStart / dX_; + if (binStart < 0) binStart = 0; + if (binStart > maxBin) binStart = maxBin; + int binEnd = grammageEnd / dX_; + if (binEnd < 0) binEnd = 0; + if (binEnd > maxBin) binEnd = maxBin; + CORSIKA_LOG_DEBUG("energy deposit of -dE={} between {} and {}", -dE, grammageStart, grammageEnd); auto energyCount = HEPEnergyType::zero(); - auto fill = [&](const int bin, const double weight) { - auto const increment = -dE * weight; + auto const factor = -dE / deltaX; + auto fill = [&](int const bin, GrammageType const weight) { + auto const increment = factor * weight; profile_[bin] += increment; energyCount += increment; @@ -222,11 +233,11 @@ namespace corsika { // fill longitudinal profile if (binStart == binEnd) { - fill(binStart, 1); + fill(binStart, deltaX); } else { - fill(binStart, ((1 + binStart) * dX_ - grammageStart) / deltaX); - fill(binEnd, (grammageEnd - binEnd * dX_) / deltaX); - for (int bin = binStart + 1; bin < binEnd; ++bin) { fill(bin, dX_ / deltaX); } + fill(binStart, ((1 + binStart) * dX_ - grammageStart)); + fill(binEnd, (grammageEnd - binEnd * dX_)); + for (int bin = binStart + 1; bin < binEnd; ++bin) { fill(bin, dX_); } } CORSIKA_LOG_DEBUG("total energy added to histogram: {} ", energyCount); diff --git a/corsika/detail/modules/pythia8/Decay.inl b/corsika/detail/modules/pythia8/Decay.inl index 662afa95ae2ff806122a2a47c8387d36f4ee4fe0..a0dcc7e7c211447cad2e15a63d9ad3bcd53237b7 100644 --- a/corsika/detail/modules/pythia8/Decay.inl +++ b/corsika/detail/modules/pythia8/Decay.inl @@ -17,8 +17,9 @@ namespace corsika::pythia8 { - Decay::Decay(const bool print_listing) - : print_listing_(print_listing) { + Decay::Decay(bool const print_listing) + : Pythia8::Pythia(CORSIKA_Pythia8_XML_DIR) + , print_listing_(print_listing) { init(); } @@ -34,25 +35,16 @@ namespace corsika::pythia8 { // run this only once during construction - // set random number generator in pythia + // link random number generator in pythia to CORSIKA8 Pythia8::RndmEngine* rndm = new corsika::pythia8::Random(); - pythia_.setRndmEnginePtr(rndm); + Pythia8::Pythia::setRndmEnginePtr(rndm); - /* - issue xyz: definition of particles and decay channels use the same mechanism in - corsika and pythia we should force pythia to use the file in corsika. - */ - // bool ParticleData::reInit(string startFile, bool xmlFormat = true) - // read in particle data from Corsika 8 - // pythia_.particleData.reInit("/home/felix/ngcorsika/corsika-build/include/corsika/particles/ParticleData.xml"); - // pythia_.particleData.checkTable(); - - pythia_.readString("Next:numberShowInfo = 0"); - pythia_.readString("Next:numberShowProcess = 0"); - pythia_.readString("Next:numberShowEvent = 0"); + Pythia8::Pythia::readString("Next:numberShowInfo = 0"); + Pythia8::Pythia::readString("Next:numberShowProcess = 0"); + Pythia8::Pythia::readString("Next:numberShowEvent = 0"); - pythia_.readString("Print:quiet = on"); - pythia_.readString("Check:particleData = 0"); + Pythia8::Pythia::readString("Print:quiet = on"); + Pythia8::Pythia::readString("Check:particleData = off"); /* switching off event check in pythia is needed to allow decays that are off-shell @@ -60,17 +52,17 @@ namespace corsika::pythia8 { the consistency of particle masses between event generators is an unsolved issues */ CORSIKA_LOG_INFO("Pythia::Init: switching off event checking in pythia.."); - pythia_.readString("Check:event = 1"); + Pythia8::Pythia::readString("Check:event = 1"); - pythia_.readString("ProcessLevel:all = off"); - pythia_.readString("ProcessLevel:resonanceDecays = off"); + Pythia8::Pythia::readString("ProcessLevel:all = off"); + Pythia8::Pythia::readString("ProcessLevel:resonanceDecays = off"); // making sure setStable(Code::Pi0); - // pythia_.particleData.readString("59:m0 = 101.00"); + // Pythia8::Pythia::particleData.readString("59:m0 = 101.00"); - if (!pythia_.init()) + if (!Pythia8::Pythia::init()) throw std::runtime_error("Pythia::Decay: Initialization failed!"); } @@ -115,26 +107,27 @@ namespace corsika::pythia8 { void Decay::setUnstable(Code const pCode) { CORSIKA_LOG_INFO("Pythia::Decay: setting {} unstable..", pCode); - pythia_.particleData.mayDecay(static_cast<int>(get_PDG(pCode)), true); + Pythia8::Pythia::particleData.mayDecay(static_cast<int>(get_PDG(pCode)), true); } void Decay::setStable(Code const pCode) { CORSIKA_LOG_INFO("Pythia::Decay: setting {} stable..", pCode); - pythia_.particleData.mayDecay(static_cast<int>(get_PDG(pCode)), false); + Pythia8::Pythia::particleData.mayDecay(static_cast<int>(get_PDG(pCode)), false); } bool Decay::isStable(Code const vCode) { - return pythia_.particleData.canDecay(static_cast<int>(get_PDG(vCode))); + return Pythia8::Pythia::particleData.canDecay(static_cast<int>(get_PDG(vCode))); } bool Decay::canDecay(Code const pCode) { - const bool ans = pythia_.particleData.canDecay(static_cast<int>(get_PDG(pCode))); + bool const ans = + Pythia8::Pythia::particleData.canDecay(static_cast<int>(get_PDG(pCode))); CORSIKA_LOG_INFO("Pythia::Decay: checking if particle: {} can decay in PYTHIA? {} ", pCode, ans); return ans; } - void Decay::printDecayConfig(const Code vCode) { + void Decay::printDecayConfig(Code const vCode) { CORSIKA_LOG_INFO("Decay: Pythia decay configuration:"); CORSIKA_LOG_INFO(" {} is {} ", vCode, (isStable(vCode) ? "stable" : "unstable")); } @@ -151,14 +144,14 @@ namespace corsika::pythia8 { template <typename TParticle> TimeType Decay::getLifetime(TParticle const& particle) { - const auto pid = particle.getPID(); + auto const pid = particle.getPID(); if (canDecay(pid)) { HEPEnergyType E = particle.getEnergy(); HEPMassType m = particle.getMass(); - const double gamma = E / m; + double const gamma = E / m; - const TimeType t0 = get_lifetime(pid); + TimeType const t0 = get_lifetime(pid); auto const lifetime = gamma * t0; CORSIKA_LOG_INFO("Pythia::Decay: code: {}", particle.getPID()); CORSIKA_LOG_INFO("Pythia::Decay: MinStep: t0: {}", t0); @@ -193,7 +186,7 @@ namespace corsika::pythia8 { count_++; // pythia stack - Pythia8::Event& event = pythia_.event; + Pythia8::Event& event = Pythia8::Pythia::event; event.reset(); auto const particleId = projectile.getPID(); @@ -213,7 +206,7 @@ namespace corsika::pythia8 { // add particle to pythia stack event.append(pdgCode, 1, 0, 0, px, py, pz, en, m); - if (!pythia_.next()) + if (!Pythia8::Pythia::next()) throw std::runtime_error("Pythia::Decay: decay failed!"); else CORSIKA_LOG_INFO("Pythia::Decay: particles after decay: {} ", event.size()); diff --git a/corsika/detail/modules/pythia8/Interaction.inl b/corsika/detail/modules/pythia8/Interaction.inl index 61bee857ca971c7895ca8bfa182df5c3fb82871d..98ec35a8e31ac728c89f096a39e2e5e7df2eb264 100644 --- a/corsika/detail/modules/pythia8/Interaction.inl +++ b/corsika/detail/modules/pythia8/Interaction.inl @@ -25,43 +25,46 @@ namespace corsika::pythia8 { std::cout << "Pythia::Interaction n=" << count_ << std::endl; } - Interaction::Interaction(const bool print_listing) - : print_listing_(print_listing) { + Interaction::Interaction(bool const print_listing) + : Pythia8::Pythia(CORSIKA_Pythia8_XML_DIR) + , print_listing_(print_listing) { + std::cout << "Configuring Pythia8 from: " << CORSIKA_Pythia8_XML_DIR << std::endl; std::cout << "Pythia::Interaction n=" << count_ << std::endl; // initialize Pythia - if (!initialized_) { - - pythia_.readString("Print:quiet = off"); - pythia_.readString("Check:particleData = on"); // during init - pythia_.readString("Check:event = on"); // default: on - pythia_.readString("Check:levelParticleData = 12"); // 1 is default - // TODO: proper process initialization for MinBias needed - pythia_.readString("HardQCD:all = on"); - pythia_.readString("ProcessLevel:resonanceDecays = off"); - - pythia_.init(); - - // any decays in pythia? if yes need to define which particles - if (internalDecays_) { - // define which particles are passed to corsika, i.e. which particles make it into - // history even very shortlived particles like charm or pi0 are of interest here - const std::vector<Code> HadronsWeWantTrackedByCorsika = { - Code::PiPlus, Code::PiMinus, Code::Pi0, Code::KMinus, - Code::KPlus, Code::K0Long, Code::K0Short, Code::SigmaPlus, - Code::SigmaMinus, Code::Lambda0, Code::Xi0, Code::XiMinus, - Code::OmegaMinus, Code::DPlus, Code::DMinus, Code::D0, - Code::D0Bar}; - - Interaction::setStable(HadronsWeWantTrackedByCorsika); - } - - // basic initialization of cross section routines - sigma_.init(&pythia_.info, pythia_.settings, &pythia_.particleData, &pythia_.rndm); - initialized_ = true; + // reduce output from pythia if set to "on" + Pythia8::Pythia::readString("Print:quiet = on"); + // check if data in particle data file is minimally consistent. Very verbose! set to + // "off"! we do not change the basic file provided by pythia. + Pythia8::Pythia::readString("Check:particleData = off"); + Pythia8::Pythia::readString("Check:event = on"); // default: on + Pythia8::Pythia::readString("Check:levelParticleData = 12"); // 1 is default + /** \TODO: proper process initialization for MinBias needed, see + also Issue https://gitlab.ikp.kit.edu/AirShowerPhysics/corsika/-/issues/369 **/ + Pythia8::Pythia::readString("HardQCD:all = on"); + Pythia8::Pythia::readString("ProcessLevel:resonanceDecays = off"); + + if (!Pythia8::Pythia::init()) + throw std::runtime_error("Pythia::Interaction: Initialization failed!"); + + // any decays in pythia? if yes need to define which particles + if (internalDecays_) { + // define which particles are passed to corsika, i.e. which particles make it into + // history even very shortlived particles like charm or pi0 are of interest here + std::vector<Code> const HadronsWeWantTrackedByCorsika = { + Code::PiPlus, Code::PiMinus, Code::Pi0, Code::KMinus, Code::KPlus, + Code::K0Long, Code::K0Short, Code::SigmaPlus, Code::SigmaMinus, Code::Lambda0, + Code::Xi0, Code::XiMinus, Code::OmegaMinus, Code::DPlus, Code::DMinus, + Code::D0, Code::D0Bar}; + + Interaction::setStable(HadronsWeWantTrackedByCorsika); } + + // basic initialization of cross section routines + sigma_.init(&(Pythia8::Pythia::info), Pythia8::Pythia::settings, + &(Pythia8::Pythia::particleData), &(Pythia8::Pythia::rndm)); } void Interaction::setStable(std::vector<Code> const& particleList) { @@ -70,16 +73,16 @@ namespace corsika::pythia8 { void Interaction::setUnstable(Code const pCode) { std::cout << "Pythia::Interaction: setting " << pCode << " unstable.." << std::endl; - pythia_.particleData.mayDecay(static_cast<int>(get_PDG(pCode)), true); + Pythia8::Pythia::particleData.mayDecay(static_cast<int>(get_PDG(pCode)), true); } void Interaction::setStable(Code const pCode) { std::cout << "Pythia::Interaction: setting " << pCode << " stable.." << std::endl; - pythia_.particleData.mayDecay(static_cast<int>(get_PDG(pCode)), false); + Pythia8::Pythia::particleData.mayDecay(static_cast<int>(get_PDG(pCode)), false); } - void Interaction::configureLabFrameCollision(const Code BeamId, const Code TargetId, - const HEPEnergyType BeamEnergy) { + void Interaction::configureLabFrameCollision(Code const BeamId, Code const TargetId, + HEPEnergyType const BeamEnergy) { // Pythia configuration of the current event // very clumsy. I am sure this can be done better.. @@ -88,25 +91,27 @@ namespace corsika::pythia8 { auto const pdgBeam = static_cast<int>(get_PDG(BeamId)); std::stringstream stBeam; stBeam << "Beams:idA = " << pdgBeam; - pythia_.readString(stBeam.str()); + Pythia8::Pythia::readString(stBeam.str()); // set target auto pdgTarget = static_cast<int>(get_PDG(TargetId)); // replace hydrogen with proton, otherwise pythia goes into heavy ion mode! if (TargetId == Code::Hydrogen) pdgTarget = static_cast<int>(get_PDG(Code::Proton)); std::stringstream stTarget; stTarget << "Beams:idB = " << pdgTarget; - pythia_.readString(stTarget.str()); + Pythia8::Pythia::readString(stTarget.str()); // set frame to lab. frame - pythia_.readString("Beams:frameType = 2"); + Pythia8::Pythia::readString("Beams:frameType = 2"); // set beam energy - const double Elab = BeamEnergy / 1_GeV; + double const Elab = BeamEnergy / 1_GeV; std::stringstream stEnergy; stEnergy << "Beams:eA = " << Elab; - pythia_.readString(stEnergy.str()); + Pythia8::Pythia::readString(stEnergy.str()); // target at rest - pythia_.readString("Beams:eB = 0."); + Pythia8::Pythia::readString("Beams:eB = 0."); // initialize this config - pythia_.init(); + + if (!Pythia8::Pythia::init()) + throw std::runtime_error("Pythia::Interaction: Initialization failed!"); } bool Interaction::canInteract(Code const pCode) { @@ -115,20 +120,20 @@ namespace corsika::pythia8 { } std::tuple<CrossSectionType, CrossSectionType> Interaction::getCrossSection( - const Code BeamId, const Code TargetId, const HEPEnergyType CoMenergy) { + Code const BeamId, Code const TargetId, HEPEnergyType const CoMenergy) { // interaction possible in pythia? if (TargetId == Code::Proton || TargetId == Code::Hydrogen) { if (canInteract(BeamId) && isValidCoMEnergy(CoMenergy)) { // input particle PDG auto const pdgCodeBeam = static_cast<int>(get_PDG(BeamId)); auto const pdgCodeTarget = static_cast<int>(get_PDG(TargetId)); - const double ecm = CoMenergy / 1_GeV; + double const ecm = CoMenergy / 1_GeV; // calculate cross section sigma_.calc(pdgCodeBeam, pdgCodeTarget, ecm); if (sigma_.hasSigmaTot()) { - const double sigEla = sigma_.sigmaEl(); - const double sigProd = sigma_.sigmaTot() - sigEla; + double const sigEla = sigma_.sigmaEl(); + double const sigProd = sigma_.sigmaTot() - sigEla; return std::make_tuple(sigProd * (1_fm * 1_fm), sigEla * (1_fm * 1_fm)); @@ -144,7 +149,6 @@ namespace corsika::pythia8 { } } - // template <> GrammageType Interaction::getInteractionLength( corsika::setup::Stack::particle_type const& particle) { @@ -168,7 +172,7 @@ namespace corsika::pythia8 { pTotLab += pTarget; auto const pTotLabNorm = pTotLab.getNorm(); // calculate cm. energy - const HEPEnergyType ECoM = sqrt( + HEPEnergyType const ECoM = sqrt( (Elab + pTotLabNorm) * (Elab - pTotLabNorm)); // binomial for numerical accuracy std::cout << "Interaction: LambdaInt: \n" @@ -185,8 +189,8 @@ namespace corsika::pythia8 { ideally as full particle object so that the four momenta and the boosts can be defined.. */ - const auto* currentNode = particle.getNode(); - const auto mediumComposition = + auto const* currentNode = particle.getNode(); + auto const mediumComposition = currentNode->getModelProperties().getNuclearComposition(); // determine average interaction length @@ -213,17 +217,12 @@ namespace corsika::pythia8 { return std::numeric_limits<double>::infinity() * 1_g / (1_cm * 1_cm); } - /** - In this function PYTHIA is called to produce one event. The - event is copied (and boosted) into the shower lab frame. - */ - template <class TView> void Interaction::doInteraction(TView& view) { auto projectile = view.getProjectile(); - const auto corsikaBeamId = projectile.getPID(); + auto const corsikaBeamId = projectile.getPID(); std::cout << "Pythia::Interaction: " << "DoInteraction: " << corsikaBeamId << " interaction? " << corsika::pythia8::Interaction::canInteract(corsikaBeamId) << std::endl; @@ -246,9 +245,9 @@ namespace corsika::pythia8 { // define target // FOR NOW: target is always at rest - const auto eTargetLab = 0_GeV + constants::nucleonMass; - const auto pTargetLab = MomentumVector(labCS, 0_GeV, 0_GeV, 0_GeV); - const FourVector PtargLab(eTargetLab, pTargetLab); + auto const eTargetLab = 0_GeV + constants::nucleonMass; + auto const pTargetLab = MomentumVector(labCS, 0_GeV, 0_GeV, 0_GeV); + FourVector const PtargLab(eTargetLab, pTargetLab); std::cout << "Interaction: ebeam lab: " << eProjectileLab / 1_GeV << std::endl << "Interaction: pbeam lab: " << pProjectileLab.getComponents() / 1_GeV @@ -257,7 +256,7 @@ namespace corsika::pythia8 { << "Interaction: ptarget lab: " << pTargetLab.getComponents() / 1_GeV << std::endl; - const FourVector PprojLab(eProjectileLab, pProjectileLab); + FourVector const PprojLab(eProjectileLab, pProjectileLab); // define target kinematics in lab frame // define boost to and from CoM frame @@ -290,8 +289,8 @@ namespace corsika::pythia8 { HEPEnergyType Ecm = sqrt(Etot * Etot - Ptot.getSquaredNorm()); // sample target mass number - const auto* currentNode = projectile.getNode(); - const auto& mediumComposition = + auto const* currentNode = projectile.getNode(); + auto const& mediumComposition = currentNode->getModelProperties().getNuclearComposition(); // get cross sections for target materials /* @@ -304,12 +303,12 @@ namespace corsika::pythia8 { for (size_t i = 0; i < compVec.size(); ++i) { auto const targetId = compVec[i]; - const auto [sigProd, sigEla] = getCrossSection(corsikaBeamId, targetId, Ecm); - [[maybe_unused]] const auto& dummy_sigEla = sigEla; + auto const [sigProd, sigEla] = getCrossSection(corsikaBeamId, targetId, Ecm); + [[maybe_unused]] auto const& dummy_sigEla = sigEla; cross_section_of_components[i] = sigProd; } - const auto corsikaTargetId = + auto const corsikaTargetId = mediumComposition.sampleTarget(cross_section_of_components, RNG_); std::cout << "Interaction: target selected: " << corsikaTargetId << std::endl; @@ -333,10 +332,11 @@ namespace corsika::pythia8 { configureLabFrameCollision(corsikaBeamId, corsikaTargetId, eProjectileLab); // create event in pytia - if (!pythia_.next()) throw std::runtime_error("Pythia::DoInteraction: failed!"); + if (!Pythia8::Pythia::next()) + throw std::runtime_error("Pythia::DoInteraction: failed!"); // link to pythia stack - Pythia8::Event& event = pythia_.event; + Pythia8::Event& event = Pythia8::Pythia::event; if (print_listing_) { // print final state @@ -352,7 +352,7 @@ namespace corsika::pythia8 { auto const pyId = convert_from_PDG(static_cast<PDGCode>(p8p.id())); - const MomentumVector pyPlab( + MomentumVector const pyPlab( labCS, {p8p.px() * 1_GeV, p8p.py() * 1_GeV, p8p.pz() * 1_GeV}); HEPEnergyType const pyEn = p8p.e() * 1_GeV; diff --git a/corsika/detail/modules/sibyll/NuclearInteraction.inl b/corsika/detail/modules/sibyll/NuclearInteraction.inl index 4470ea28a8b1e2f504711346790b67bf2342370e..52296fbd423199e5398e45d0e72ed53ae2e01622 100644 --- a/corsika/detail/modules/sibyll/NuclearInteraction.inl +++ b/corsika/detail/modules/sibyll/NuclearInteraction.inl @@ -240,7 +240,7 @@ namespace corsika::sibyll { pTotLab += pTarget; auto const pTotLabNorm = pTotLab.getNorm(); // calculate cm. energy - HEPEnergyType const ECoM = sqrt( + [[maybe_unused]] HEPEnergyType const ECoM = sqrt( (Elab + pTotLabNorm) * (Elab - pTotLabNorm)); // binomial for numerical accuracy auto const ECoMNN = sqrt(2. * ElabNuc * constants::nucleonMass); CORSIKA_LOG_DEBUG( diff --git a/corsika/modules/ParticleCut.hpp b/corsika/modules/ParticleCut.hpp index ca7f87013d59cf2cbab4194c7e0fa02b31101c42..1678c528edbc9815bc9c1388bcd81d9c32748615 100644 --- a/corsika/modules/ParticleCut.hpp +++ b/corsika/modules/ParticleCut.hpp @@ -58,7 +58,7 @@ namespace corsika { } void printThresholds(); - void showResults(); + void showResults(); // LCOV_EXCL_LINE void reset(); HEPEnergyType getElectronECut() const { return get_energy_threshold(Code::Electron); } diff --git a/corsika/modules/pythia8/Decay.hpp b/corsika/modules/pythia8/Decay.hpp index 2bdfccb3c82a2a0aa8b653d7c117f062ee9bd1e6..5de68f4fbd2635471cc604a9fae3c2b783354195 100644 --- a/corsika/modules/pythia8/Decay.hpp +++ b/corsika/modules/pythia8/Decay.hpp @@ -17,7 +17,7 @@ namespace corsika::pythia8 { - class Decay : public DecayProcess<Decay> { + class Decay : public DecayProcess<Decay>, public Pythia8::Pythia { public: Decay(bool const print_listing = false); @@ -59,7 +59,6 @@ namespace corsika::pythia8 { void setStable(Code const); // data members - Pythia8::Pythia pythia_; int count_ = 0; bool handleAllDecays_ = true; std::set<Code> handledDecays_; diff --git a/corsika/modules/pythia8/Interaction.hpp b/corsika/modules/pythia8/Interaction.hpp index 08c1d429bebc47887a7b18f224f00936c9c4f6d7..f2d264db15befbad789b0ba2afd122fa0e586f86 100644 --- a/corsika/modules/pythia8/Interaction.hpp +++ b/corsika/modules/pythia8/Interaction.hpp @@ -20,7 +20,7 @@ namespace corsika::pythia8 { - class Interaction : public InteractionProcess<Interaction> { + class Interaction : public InteractionProcess<Interaction>, public Pythia8::Pythia { public: Interaction(const bool print_listing = false); @@ -30,7 +30,6 @@ namespace corsika::pythia8 { void setUnstable(const Code); void setStable(const Code); - bool wasInitialized() { return initialized_; } bool isValidCoMEnergy(HEPEnergyType ecm) { return (10_GeV < ecm) && (ecm < 1_PeV); } bool canInteract(const Code); @@ -39,24 +38,20 @@ namespace corsika::pythia8 { std::tuple<CrossSectionType, CrossSectionType> getCrossSection( const Code BeamId, const Code TargetId, const HEPEnergyType CoMenergy); - // template <typename TParticle> GrammageType getInteractionLength(corsika::setup::Stack::particle_type const&); /** In this function PYTHIA is called to produce one event. The event is copied (and boosted) into the shower lab frame. */ - template <typename TView> void doInteraction(TView&); private: default_prng_type& RNG_ = RNGManager::getInstance().getRandomStream("pythia"); - Pythia8::Pythia pythia_; Pythia8::SigmaTotal sigma_; const bool internalDecays_ = true; int count_ = 0; - bool initialized_ = false; bool print_listing_ = false; }; diff --git a/corsika/modules/pythia8/Pythia8.hpp b/corsika/modules/pythia8/Pythia8.hpp index 5b42ac148b97a9bc54059d27d3a34c61f4d8b87a..6e8f80e8955b813d3c9bfc30c80a781b9dba625d 100644 --- a/corsika/modules/pythia8/Pythia8.hpp +++ b/corsika/modules/pythia8/Pythia8.hpp @@ -8,4 +8,8 @@ #pragma once +// the location of the "xmldoc" pythia directory (data files, config) +#include <Pythia8ConfigurationDirectory.hpp> + +// the main pythia include #include <Pythia8/Pythia.h> diff --git a/modules/conex b/modules/conex index 820f042b6a055276d465437c74160ef7c199b646..73e3d1fa850d2d3602a15b3b948ac1789fbc968d 160000 --- a/modules/conex +++ b/modules/conex @@ -1 +1 @@ -Subproject commit 820f042b6a055276d465437c74160ef7c199b646 +Subproject commit 73e3d1fa850d2d3602a15b3b948ac1789fbc968d diff --git a/modules/data b/modules/data index 8b76a9ca2599cd0ce1f204b17362eb06bbcf5277..afe83dc19c1464deb176f38c3ddab80a64e081f4 160000 --- a/modules/data +++ b/modules/data @@ -1 +1 @@ -Subproject commit 8b76a9ca2599cd0ce1f204b17362eb06bbcf5277 +Subproject commit afe83dc19c1464deb176f38c3ddab80a64e081f4 diff --git a/modules/pythia/CMakeLists.txt b/modules/pythia/CMakeLists.txt index 980e42375a04347de5b8fd96cad79f6526d66a8a..3d2b269d493bda9b4b1cefb869b07a4bd198f165 100644 --- a/modules/pythia/CMakeLists.txt +++ b/modules/pythia/CMakeLists.txt @@ -8,7 +8,7 @@ mark_as_advanced (ThirdPartyChoiceValues) ############################################################################## # check for Pythia8: either use C8 or system-level installation -message ("***** Configuring Pythia8 version") +message (STATUS "***** Configuring Pythia8 version") set (USE_PYTHIA8_C8 "C8" CACHE STRING "Selection of pythia8 package. Can be \'C8\' or \'SYSTEM\'. Default: \'C8\'.") @@ -21,59 +21,77 @@ message (STATUS "USE_PYTHIA8_C8='${USE_PYTHIA8_C8}'") add_library (C8::ext::pythia8 STATIC IMPORTED GLOBAL) if ("x_${USE_PYTHIA8_C8}" STREQUAL "x_SYSTEM") - find_package (Pythia8 REQUIRED) - message (STATUS "Using system-level Pythia8 version ${Pythia8_VERSION} at ${Pythia8_INCLUDE_DIR}") + find_package (Pythia8 8245 EXACT REQUIRED) + message (STATUS "Using system-level Pythia8 version ${Pythia8_VERSION} at ${Pythia8_PREFIX}") + set (Pythia8_INCLUDE_DIRS_CMAKE ${Pythia8_INCLUDE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) set_target_properties ( C8::ext::pythia8 PROPERTIES IMPORTED_LOCATION ${Pythia8_LIBRARY}/libpythia8.a IMPORTED_LINK_INTERFACE_LIBRARIES dl - INTERFACE_INCLUDE_DIRECTORIES ${Pythia8_INCLUDE_DIR} + INTERFACE_INCLUDE_DIRECTORIES "${Pythia8_INCLUDE_DIRS_CMAKE}" ) set (Pythia8_FOUND 1 PARENT_SCOPE) - message ("Pythia8_LIBRARY=${Pythia8_LIBRARY}") - message ("Pythia8_INCLUDE_DIR=${Pythia8_INCLUDE_DIR}") + set (CORSIKA_Pythia8_LOCATION ${Pythia8_PREFIX}) # build and install location, pythia8 is external + configure_file (Pythia8ConfigurationDirectory.hpp.in ${CMAKE_CURRENT_BINARY_DIR}/Pythia8ConfigurationDirectory.hpp @ONLY) + configure_file (Pythia8ConfigurationDirectory.hpp.in ${CMAKE_CURRENT_BINARY_DIR}/Pythia8ConfigurationDirectory_install.hpp @ONLY) + + message (STATUS "Pythia8 (system) at ${Pythia8_PREFIX}") else () - set (_C8_Pythia8_VERSION "8235") + set (_C8_Pythia8_VERSION "8245") message (STATUS "Building modules/pythia8 using pythia${_C8_Pythia8_VERSION}-stripped.tar.bz2") message (STATUS "This will take a bit.....") + # this is not a full PYTHIA8 install, it is a bit simplified, e.g. no pythia8-config ExternalProject_Add (pythia8 URL ${CMAKE_CURRENT_SOURCE_DIR}/pythia${_C8_Pythia8_VERSION}-stripped.tar.bz2 - URL_MD5 83132880c0594b808bd7fd37fb642606 - SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/pythia8/source - INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/pythia8/install - CONFIGURE_COMMAND ./configure --cxx-common=-Wno-deprecated-copy --prefix=${CMAKE_CURRENT_BINARY_DIR}/pythia8/install + URL_MD5 d3e951a2f101e8cfec26405cb61db83b + SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/pythia8/source" + INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/pythia8/install" + CONFIGURE_COMMAND ./configure --cxx-common=\\"${CMAKE_CXX_FLAGS} -O2 -fPIC\\" --prefix=${CMAKE_CURRENT_BINARY_DIR}/pythia8/install + INSTALL_COMMAND make install COMMAND rm -rf ${CMAKE_CURRENT_BINARY_DIR}/pythia8/install/bin ${CMAKE_CURRENT_BINARY_DIR}/pythia8/install/share/Pythia8/examples BUILD_IN_SOURCE ON EXCLUDE_FROM_ALL TRUE - ) + ) set (Pythia8_FOUND 1 PARENT_SCOPE) - ExternalProject_Get_Property (pythia8 INSTALL_DIR) + ExternalProject_Get_Property (pythia8 INSTALL_DIR) # this is "make" + set (Pythia8_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/externals/pythia8) # this is "make install" set (Pythia8_VERSION ${_C8_Pythia8_VERSION} CACHE STRING "Version of Pythia8") set (Pythia8_PREFIX ${INSTALL_DIR}) set (Pythia8_INCLUDE_DIR ${Pythia8_PREFIX}/include) set (Pythia8_LIBRARY ${Pythia8_PREFIX}/lib/libpythia8.a) add_dependencies (C8::ext::pythia8 pythia8) - # create include directory at config time - file (MAKE_DIRECTORY ${Pythia8_INCLUDE_DIR}) - set (Pythia8_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/share/externals/pythia8) + set (CORSIKA_Pythia8_LOCATION ${Pythia8_PREFIX}) # build location + configure_file (Pythia8ConfigurationDirectory.hpp.in ${CMAKE_CURRENT_BINARY_DIR}/Pythia8ConfigurationDirectory.hpp @ONLY) + set (CORSIKA_Pythia8_LOCATION ${Pythia8_INSTALL_DIR}) # install location + configure_file (Pythia8ConfigurationDirectory.hpp.in ${CMAKE_CURRENT_BINARY_DIR}/Pythia8ConfigurationDirectory_install.hpp @ONLY) + install (DIRECTORY ${INSTALL_DIR}/ DESTINATION ${Pythia8_INSTALL_DIR}) + + set (Pythia8_INCLUDE_DIRS_CMAKE ${Pythia8_INCLUDE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) set_target_properties ( - C8::ext::pythia8 PROPERTIES + C8::ext::pythia8 + PROPERTIES IMPORTED_LOCATION ${Pythia8_LIBRARY} IMPORTED_LINK_INTERFACE_LIBRARIES dl - INTERFACE_INCLUDE_DIRECTORIES - $<BUILD_INTERFACE:${Pythia8_INCLUDE_DIR}> + INTERFACE_INCLUDE_DIRECTORIES "${Pythia8_INCLUDE_DIRS_CMAKE}" ) - - message (STATUS "Pythia8_INCLUDE_DIR ${Pythia8_INCLUDE_DIR}") + + message (STATUS "Pythia8 build at: ${INSTALL_DIR}, final install to: ${Pythia8_INSTALL_DIR}, include dirs: ${Pythia8_INCLUDE_DIRS_CMAKE}") endif () +# the install location of Pythia8 +install ( + FILES ${CMAKE_CURRENT_BINARY_DIR}/Pythia8ConfigurationDirectory_install.hpp + RENAME Pythia8ConfigurationDirectory.hpp + DESTINATION include/modules/pythia8 + ) ##### add pythia8 to CORSIKA8 build add_dependencies (CORSIKA8 C8::ext::pythia8) target_link_libraries (CORSIKA8 INTERFACE C8::ext::pythia8) + diff --git a/modules/pythia/Pythia8ConfigurationDirectory.hpp.in b/modules/pythia/Pythia8ConfigurationDirectory.hpp.in new file mode 100644 index 0000000000000000000000000000000000000000..d05df326aabcbfcd4c4342aa3621af2b116c8d7d --- /dev/null +++ b/modules/pythia/Pythia8ConfigurationDirectory.hpp.in @@ -0,0 +1,35 @@ +/* + * (c) Copyright 2020 CORSIKA Project, corsika-project@lists.kit.edu + * + * This software is distributed under the terms of the GNU General Public + * Licence version 3 (GPL Version 3). See file LICENSE for a full version of + * the license. + */ + +#pragma once + +#include <string> + +/** + * \file ConfigurationDirectory.hpp + * + * The location of Pythia XMLDOC configuration data files (particle + * data, decays, PDFs etc.) can be at different locations, depending + * on wether system version of pythia8, or the local CORSIKA8 version + * has been used. Also for the latter it is build in the + * ${PROJECT_BINARY_DIR}/modules/pythia/pythia8/install, while during + * installation (make install) it is copied to + * ${CMAKE_INSTALL_PREFIX}/share/external/pythia8. Thus, at config + * time different version of ConfigurationDirectory.hpp are created to + * always point to the right locations. + **/ + +namespace corsika::pythia8 { + + /** + * + * Location of the pythia XML directory with crucial input and config data, from cmake: + **/ + static std::string const CORSIKA_Pythia8_XML_DIR("@CORSIKA_Pythia8_LOCATION@/share/Pythia8/xmldoc/"); + +} diff --git a/modules/pythia/pythia8235-stripped.tar.bz2 b/modules/pythia/pythia8235-stripped.tar.bz2 deleted file mode 100644 index da280f738809e54eace85622485d13492448250e..0000000000000000000000000000000000000000 Binary files a/modules/pythia/pythia8235-stripped.tar.bz2 and /dev/null differ diff --git a/modules/pythia/pythia8245-stripped.tar.bz2 b/modules/pythia/pythia8245-stripped.tar.bz2 new file mode 100644 index 0000000000000000000000000000000000000000..0ad96435f488cac464393fee13b4d5f4a38794fd Binary files /dev/null and b/modules/pythia/pythia8245-stripped.tar.bz2 differ diff --git a/modules/pythia/strip-pythia8-package.py b/modules/pythia/strip-pythia8-package.py new file mode 100755 index 0000000000000000000000000000000000000000..2ddd8435a2a9379ea7b168be6f6d40d41c976719 --- /dev/null +++ b/modules/pythia/strip-pythia8-package.py @@ -0,0 +1,98 @@ +#!/usr/bin/env python3 + +import os +import sys +import shutil + +if (not os.path.exists('bin/pythia8-config') or + not os.path.exists('include/Pythia8/Pythia.h') or + not os.path.exists('src/Event.cc')) : + print ("You can only run this script from within an unpacked PYTHIA tar filedirectory. This was not detected!") + sys.exit(1) + +# find version +version = 'undefined' +pythia_header = open('include/Pythia8/Pythia.h') +for line in pythia_header: + line_list = line.strip().split(' ') + if (len(line_list) == 3 and + line_list[0] == '#define' and + line_list[1] == 'PYTHIA_VERSION_INTEGER') : + version = line_list[2] + break +pythia_header.close() + +if (version == 'undefined'): + print ("Could not find Pythia version info") + sys.exit(2) + +print ("Pythia version: {}".format(version)) + +if (os.path.exists('c8_package')) : + print ('Temporary directory \"c8_package\" already exists. Cleanup first.') + sys.exit(3) + +tmpdir = 'c8_package/pythia{}'.format(version) +print ('create \"{}\"'.format(tmpdir)) +os.makedirs(tmpdir) + +copy_files_s = "AUTHORS bin CODINGSTYLE configure COPYING GUIDELINES include Makefile Makefile.inc README share src" +copy_files = copy_files_s.split() + +for filename in os.listdir('./') : + file = os.path.join('./', filename) + fileNew = os.path.join(tmpdir, filename) + if (filename in copy_files) : + isdir = '' + if (os.path.isdir(file)): isdir = ' [dir]' + print ('Keep \"{}\"{}'.format(file, isdir)) + if (os.path.isfile(file)): + shutil.copy(file, tmpdir) + else: + shutil.copytree(file, fileNew) + +print ('Remove \"include/Pythia8Plugins\"') +plugindir = os.path.join(tmpdir, 'include/Pythia8Plugins') +if (os.path.exists(plugindir)): + shutil.rmtree(plugindir) + +# remove anything in share/Pythia but xmldoc that contains parameter definitions \"<parm\" +sharedir = os.path.join(tmpdir, 'share/Pythia8') +if (not os.path.isdir(sharedir)) : + print ('Why there is no \"share/Pythia8\" directory?') +else : + print ('Only keep \"xmldoc\" inside \"share/Phythia8\"') + + for filename in os.listdir(sharedir) : + file = os.path.join(sharedir, filename) + if (os.path.isdir(file)) : + if (not 'xmldoc' in file) : + print ('Remove \"{}\"'.format(file)) + shutil.rmtree(file) + else : + cleanupXMLDOC = False + if (cleanupXMLDOC) : + for filename_xml in os.listdir(file) : + xml = os.path.join(file, filename_xml) + xml_data = open(xml) + keep = False + for xml_line in xml_data: + if ('<parm ' in xml_line) : + keep = True + break + xml_data.close() + if (not keep): + print ('Removing {}'.format(xml)) + os.unlink(xml) + +# ... 'examples' subdirectory must exist ... +os.mkdir(os.path.join(tmpdir, 'examples')) + +print ('Create tar file \"pythia{version}-stripped.tar.bz2\"'.format(version=version)) +os.system('cd c8_package && tar cjf pythia{version}-stripped.tar.bz2 pythia{version} && mv pythia{version}-stripped.tar.bz2 ..'.format(version=version)) +os.system('md5sum pythia{version}-stripped.tar.bz2'.format(version=version)) + +# cleanup +shutil.rmtree('c8_package') + + diff --git a/tests/modules/testPythia8.cpp b/tests/modules/testPythia8.cpp index 4f93280f513ffdf243259d99dc4ea675bf60cb83..8ddd613ad21e26f50166a14fcb11a5f7580385cb 100644 --- a/tests/modules/testPythia8.cpp +++ b/tests/modules/testPythia8.cpp @@ -157,9 +157,11 @@ TEST_CASE("pythia process") { SECTION("pythia interaction") { - // feenableexcept(FE_INVALID); \todo how does this work nowadays + //! feenableexcept(FE_INVALID); \todo how does this work nowadays + + // this will be a p-p collision at sqrts=3.5TeV -> no problem for pythia auto [stackPtr, secViewPtr] = setup::testing::setup_stack( - Code::PiPlus, 0, 0, 100_GeV, (setup::Environment::BaseNodeType* const)nodePtr, + Code::Proton, 0, 0, 7_TeV, (setup::Environment::BaseNodeType* const)nodePtr, *csPtr); auto& view = *secViewPtr; auto particle = stackPtr->first(); @@ -167,6 +169,7 @@ TEST_CASE("pythia process") { corsika::pythia8::Interaction model; model.doInteraction(view); [[maybe_unused]] const GrammageType length = model.getInteractionLength(particle); - CHECK(length / 1_kg * square(1_m) == Approx(82.2524)); + CHECK(length / 1_kg * square(1_m) == Approx(43.04).margin(5e-1)); + CHECK(view.getSize() == 38); } }