IAP GITLAB

Commit 932d4376 authored by Ralf Ulrich's avatar Ralf Ulrich

fixed pythia8

parent 04291651
......@@ -89,7 +89,9 @@ check-clang-format:
stage: config
tags:
- corsika
script:
before_script:
- pip install conan
script:
- mkdir -p build
- cd build
- cmake .. -DCMAKE_BUILD_TYPE=Debug -DWITH_PYTHIA=ON
......
#
n#
# (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu
#
# See file AUTHORS for a list of contributors.
......@@ -13,17 +13,17 @@
# run pythia8-config and interpret result
#
function (Pythia8_CONFIG_ option variable type doc)
execute_process (COMMAND ${Pythia8_CONFIG} ${option}
function (_Pythia8_CONFIG_ option variable type doc)
execute_process(COMMAND ${Pythia8_CONFIG} ${option}
OUTPUT_VARIABLE _local_out_
RESULT_VARIABLE _local_res_)
string (REGEX REPLACE "\n$" "" _local_out_ "${_local_out_}")
if (NOT ${_local_res_} EQUAL 0)
message (WARNING "Error in running ${Pythia8_CONFIG} ${option}")
message ("Error in running ${Pythia8_CONFIG} ${option}")
else ()
set (${variable} "${_local_out_}" CACHE ${type} ${doc})
endif ()
endfunction (Pythia8_CONFIG_)
endfunction (_Pythia8_CONFIG_)
......@@ -32,15 +32,15 @@ endfunction (Pythia8_CONFIG_)
# Searched Pythia8 on system. Expect pythia8-config in PATH, or typical installation location
#
# This module defines
# HAVE_Pythia8
# Pythia8_INCLUDE_DIR where to locate Pythia.h file
# Pythia8_LIBRARY (not cached) the libraries to link against to use Pythia8
# Pythia8_VERSION
# Pythia8_LIBRARY where to find the libpythia8 library
# Pythia8_LIBRARIES (not cached) the libraries to link against to use Pythia8
# Pythia8_VERSION version of Pythia8 if found
#
set (SEARCH_Pythia8_
${WITH_PYTHIA8}
${PYTHIA8_DIR}
$ENV{PYTHIA8_DIR}
set (_SEARCH_Pythia8_
${PROJECT_BINARY_DIR}/ThirdParty/pythia8-install
${PYTHIA8}
$ENV{PYTHIA8}
${PYTHIA8DIR}
......@@ -52,58 +52,21 @@ set (SEARCH_Pythia8_
find_program (Pythia8_CONFIG
NAME pythia8-config
PATHS ${SEARCH_Pythia8_}
PATH_SUFFIXES bin
DOC "The location of the pythia8-config script"
)
PATHS ${_SEARCH_Pythia8_}
PATH_SUFFIXES "/bin"
DOC "The location of the pythia8-config script")
if (Pythia8_CONFIG)
set (HAVE_Pythia8 1 CACHE BOOL "presence of pythia8, found via pythia8-config")
Pythia8_CONFIG_ ("--includedir" Pythia8_INCLUDE_DIR PATH "pythia8 include directory")
Pythia8_CONFIG_ ("--prefix" Pythia8_PREFIX PATH "pythia8 prefix directory")
find_library (Pythia8_LIBRARY
NAMES libpythia8.a libpythia8.so
PATH_SUFFIXES lib
PATHS ${Pythia8_PREFIX}
NO_DEFAULT_PATH
DOC "pythia8 library"
)
set (Pythia8_VERSION "n/a")
else ()
# if we get here, pythia8-config was not found by CMake so we use
# CMake to try and find Pythia8 for us (but let the user know first).
# We set these variables to exactly match the format of pythia8-config.
# If any one of the variables is not found, CMake will automatically report
# that Pythia8 is NOT FOUND (which is what we want).
message (STATUS "pythia8-config was not found. Attempting to manually locate Pythia8...")
# find the main header
find_path (Pythia8_INCLUDE_DIR
NAME Pythia8/Pythia.h
PATH_SUFFIXES include
PATHS ${SEARCH_Pythia8_}
)
# and find the main library
find_library (Pythia8_LIBRARY
NAMES libpythia8.a libpythia8.so
PATH_SUFFIXES lib
PATHS ${SEARCH_Pythia8_}
)
endif ()
# also determine Pythia8 detailed version number
if (EXISTS "${Pythia8_INCLUDE_DIR}/Pythia8/Pythia.h")
file (READ "${Pythia8_INCLUDE_DIR}/Pythia8/Pythia.h" PYTHIA_H_DATA)
string (REGEX MATCH "#define PYTHIA_VERSION_INTEGER ([0-9]*)" test "${PYTHIA_H_DATA}")
set (Pythia8_VERSION ${CMAKE_MATCH_1})
_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")
endif ()
# standard cmake infrastructure:
include (FindPackageHandleStandardArgs)
find_package_handle_standard_args (Pythia8
"Did not find system-level Pythia8."
Pythia8_INCLUDE_DIR Pythia8_LIBRARY Pythia8_VERSION)
mark_as_advanced (Pythia8_INCLUDE_DIR Pythia8_LIBRARY Pythia8_VERSION)
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)
......@@ -19,6 +19,20 @@ namespace corsika::pythia8 {
Decay::Decay(const bool print_listing)
: print_listing_(print_listing) {
init();
}
Decay::Decay(std::set<Code> const& those)
: handleAllDecays_(false)
, handledDecays_(those) {
init();
}
Decay::~Decay() { CORSIKA_LOG_INFO("Pythia::Decay n={}", count_); }
void Decay::init() {
// run this only once during construction
// set random number generator in pythia
Pythia8::RndmEngine* rndm = new corsika::pythia8::Random();
......@@ -45,7 +59,7 @@ namespace corsika::pythia8 {
according to the mass definition in pythia.
the consistency of particle masses between event generators is an unsolved issues
*/
std::cout << "Pythia::Init: switching off event checking in pythia.." << std::endl;
CORSIKA_LOG_INFO("Pythia::Init: switching off event checking in pythia..");
pythia_.readString("Check:event = 1");
pythia_.readString("ProcessLevel:all = off");
......@@ -60,12 +74,6 @@ namespace corsika::pythia8 {
throw std::runtime_error("Pythia::Decay: Initialization failed!");
}
Decay::Decay(std::set<Code> const& those)
: handleAllDecays_(false)
, handledDecays_(those) {}
Decay::~Decay() { std::cout << "Pythia::Decay n=" << count_ << std::endl; }
bool Decay::canHandleDecay(Code const vParticleCode) {
// if known to pythia and not proton, electron or neutrino it can decay
if (vParticleCode == Code::Proton || vParticleCode == Code::AntiProton ||
......@@ -82,7 +90,7 @@ namespace corsika::pythia8 {
void Decay::setHandleDecay(Code const vParticleCode) {
handleAllDecays_ = false;
std::cout << "Pythia::Decay: set to handle decay of " << vParticleCode << std::endl;
CORSIKA_LOG_INFO("Pythia::Decay: set to handle decay of {} ", vParticleCode);
if (Decay::canHandleDecay(vParticleCode))
handledDecays_.insert(vParticleCode);
else
......@@ -106,12 +114,12 @@ namespace corsika::pythia8 {
}
void Decay::setUnstable(Code const pCode) {
std::cout << "Pythia::Decay: setting " << pCode << " unstable.." << std::endl;
CORSIKA_LOG_INFO("Pythia::Decay: setting {} unstable..", pCode);
pythia_.particleData.mayDecay(static_cast<int>(get_PDG(pCode)), true);
}
void Decay::setStable(Code const pCode) {
std::cout << "Pythia::Decay: setting " << pCode << " stable.." << std::endl;
CORSIKA_LOG_INFO("Pythia::Decay: setting {} stable..", pCode);
pythia_.particleData.mayDecay(static_cast<int>(get_PDG(pCode)), false);
}
......@@ -120,30 +128,24 @@ namespace corsika::pythia8 {
}
bool Decay::canDecay(Code const pCode) {
std::cout << "Pythia::Decay: checking if particle: " << pCode
<< " can decay in PYTHIA? ";
const bool ans = pythia_.particleData.canDecay(static_cast<int>(get_PDG(pCode)));
std::cout << ans << std::endl;
CORSIKA_LOG_INFO("Pythia::Decay: checking if particle: {} can decay in PYTHIA? {} ",
pCode, ans);
return ans;
}
void Decay::printDecayConfig(const Code vCode) {
std::cout << "Decay: Pythia decay configuration:" << std::endl;
std::cout << vCode << " is ";
if (isStable(vCode))
std::cout << "stable" << std::endl;
else
std::cout << "unstable" << std::endl;
CORSIKA_LOG_INFO("Decay: Pythia decay configuration:");
CORSIKA_LOG_INFO(" {} is {} " , vCode, (isStable(vCode)?"stable":"unstable"));
}
void Decay::printDecayConfig() {
std::cout << "Pythia::Decay: decay configuration:" << std::endl;
CORSIKA_LOG_INFO("Pythia::Decay: decay configuration:");
if (handleAllDecays_)
std::cout << " all particles known to Pythia are handled by Pythia::Decay!"
<< std::endl;
CORSIKA_LOG_INFO(" all particles known to Pythia are handled by Pythia::Decay!");
else
for (auto& pCode : handledDecays_)
std::cout << "Decay of " << pCode << " is handled by Pythia!" << std::endl;
CORSIKA_LOG_INFO("Decay of {} is handled by Pythia!", pCode);
}
template <typename TParticle>
......@@ -158,13 +160,13 @@ namespace corsika::pythia8 {
const TimeType t0 = get_lifetime(pid);
auto const lifetime = gamma * t0;
std::cout << "Pythia::Decay: code: " << particle.getPID() << std::endl;
std::cout << "Pythia::Decay: MinStep: t0: " << t0 << std::endl;
std::cout << "Pythia::Decay: MinStep: energy: " << E / 1_GeV << " GeV" << std::endl;
std::cout << "Pythia::Decay: momentum: "
<< particle.getMomentum().getComponents() / 1_GeV << " GeV" << std::endl;
std::cout << "Pythia::Decay: MinStep: gamma: " << gamma << std::endl;
std::cout << "Pythia::Decay: MinStep: tau: " << lifetime << std::endl;
CORSIKA_LOG_INFO("Pythia::Decay: code: {}", particle.getPID());
CORSIKA_LOG_INFO("Pythia::Decay: MinStep: t0: {}", t0);
CORSIKA_LOG_INFO("Pythia::Decay: MinStep: energy: {} GeV", E / 1_GeV);
CORSIKA_LOG_INFO("Pythia::Decay: momentum: {} GeV",
particle.getMomentum().getComponents() / 1_GeV);
CORSIKA_LOG_INFO("Pythia::Decay: MinStep: gamma: {}", gamma);
CORSIKA_LOG_INFO("Pythia::Decay: MinStep: tau: {} ", lifetime);
return lifetime;
} else
......@@ -214,7 +216,7 @@ namespace corsika::pythia8 {
if (!pythia_.next())
throw std::runtime_error("Pythia::Decay: decay failed!");
else
std::cout << "Pythia::Decay: particles after decay: " << event.size() << std::endl;
CORSIKA_LOG_INFO("Pythia::Decay: particles after decay: {} ", event.size());
if (print_listing_) {
// list final state
......@@ -232,9 +234,9 @@ namespace corsika::pythia8 {
FourVector const fourMomRest{Erest, pRest};
auto const fourMomLab = boost.fromCoM(fourMomRest);
std::cout << "particle: id=" << pyId << " momentum="
<< fourMomLab.getSpaceLikeComponents().getComponents(labCS) / 1_GeV
<< " energy=" << fourMomLab.getTimeLikeComponent() << std::endl;
CORSIKA_LOG_INFO("particle: id={} momentum={} energy={} ", pyId,
fourMomLab.getSpaceLikeComponents().getComponents(labCS) / 1_GeV,
fourMomLab.getTimeLikeComponent());
view.addSecondary(std::make_tuple(pyId, fourMomLab.getTimeLikeComponent(),
fourMomLab.getSpaceLikeComponents(), decayPoint,
......
......@@ -33,7 +33,10 @@ namespace corsika::pythia8 {
// initialize Pythia
if (!initialized_) {
pythia_.readString("Print:quiet = on");
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");
......
......@@ -51,6 +51,8 @@ namespace corsika::pythia8 {
void doDecay(TView&);
private:
void init();
bool isStable(Code const vCode);
void setStable(std::vector<Code> const&);
void setUnstable(Code const);
......
......@@ -25,12 +25,15 @@ if ("x_${USE_PYTHIA8_C8}" STREQUAL "x_SYSTEM")
message (STATUS "Using system-level Pythia8 version ${Pythia8_VERSION} at ${Pythia8_INCLUDE_DIR}")
set_target_properties (
C8::ext::pythia8 PROPERTIES
IMPORTED_LOCATION ${Pythia8_LIBRARY}
IMPORTED_LOCATION ${Pythia8_LIBRARY}/libpythia8.a
IMPORTED_LINK_INTERFACE_LIBRARIES dl
INTERFACE_INCLUDE_DIRECTORIES ${Pythia8_INCLUDE_DIR}
)
set (Pythia8_FOUND 1 PARENT_SCOPE)
message ("Pythia8_LIBRARY=${Pythia8_LIBRARY}")
message ("Pythia8_INCLUDE_DIR=${Pythia8_INCLUDE_DIR}")
else ()
set (_C8_Pythia8_VERSION "8235")
......
......@@ -36,6 +36,7 @@ TEST_CASE("Pythia", "[processes]") {
pythia.readString("ProcessLevel:all = off");
pythia.init();
Event& event = pythia.event;
......
......@@ -98,7 +98,7 @@ TEST_CASE("UrQMD") {
unsigned short constexpr A = 14, Z = 7;
auto [stackPtr, secViewPtr] = setup::testing::setup_stack(
Code::Nucleus, A, Z, 400_GeV, (setup::Environment::BaseNodeType* const)nodePtr,
Code::Nucleus, A, Z, 40_GeV, (setup::Environment::BaseNodeType* const)nodePtr,
*csPtr);
CHECK(stackPtr->getEntries() == 1);
CHECK(secViewPtr->getEntries() == 0);
......@@ -122,7 +122,7 @@ TEST_CASE("UrQMD") {
[[maybe_unused]] auto const& node_dummy = nodePtr; // against warnings
auto [stackPtr, secViewPtr] = setup::testing::setup_stack(
Code::PiPlus, 0, 0, 400_GeV, (setup::Environment::BaseNodeType* const)nodePtr,
Code::PiPlus, 0, 0, 40_GeV, (setup::Environment::BaseNodeType* const)nodePtr,
*csPtr);
CHECK(stackPtr->getEntries() == 1);
CHECK(secViewPtr->getEntries() == 0);
......@@ -148,7 +148,7 @@ TEST_CASE("UrQMD") {
[[maybe_unused]] auto const& node_dummy = nodePtr; // against warnings
auto [stackPtr, secViewPtr] = setup::testing::setup_stack(
Code::K0Long, 0, 0, 400_GeV, (setup::Environment::BaseNodeType* const)nodePtr,
Code::K0Long, 0, 0, 40_GeV, (setup::Environment::BaseNodeType* const)nodePtr,
*csPtr);
CHECK(stackPtr->getEntries() == 1);
CHECK(secViewPtr->getEntries() == 0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment