IAP GITLAB

Skip to content
Snippets Groups Projects
Commit a19e3746 authored by Ralf M Ulrich's avatar Ralf M Ulrich Committed by Felix Riehn
Browse files

improve Interaction class

parent 5842aff8
No related branches found
No related tags found
1 merge request!311Resolve "testModules fails with segfault on release build with clang-8"
...@@ -31,37 +31,34 @@ namespace corsika::pythia8 { ...@@ -31,37 +31,34 @@ namespace corsika::pythia8 {
std::cout << "Pythia::Interaction n=" << count_ << std::endl; std::cout << "Pythia::Interaction n=" << count_ << std::endl;
// initialize Pythia // 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; 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");
if (!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
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);
} }
void Interaction::setStable(std::vector<Code> const& particleList) { void Interaction::setStable(std::vector<Code> const& particleList) {
...@@ -106,7 +103,9 @@ namespace corsika::pythia8 { ...@@ -106,7 +103,9 @@ namespace corsika::pythia8 {
// target at rest // target at rest
pythia_.readString("Beams:eB = 0."); pythia_.readString("Beams:eB = 0.");
// initialize this config // initialize this config
pythia_.init();
if (!pythia_.init())
throw std::runtime_error("Pythia::Interaction: Initialization failed!");
} }
bool Interaction::canInteract(Code const pCode) { bool Interaction::canInteract(Code const pCode) {
......
...@@ -30,7 +30,6 @@ namespace corsika::pythia8 { ...@@ -30,7 +30,6 @@ namespace corsika::pythia8 {
void setUnstable(const Code); void setUnstable(const Code);
void setStable(const Code); void setStable(const Code);
bool wasInitialized() { return initialized_; }
bool isValidCoMEnergy(HEPEnergyType ecm) { return (10_GeV < ecm) && (ecm < 1_PeV); } bool isValidCoMEnergy(HEPEnergyType ecm) { return (10_GeV < ecm) && (ecm < 1_PeV); }
bool canInteract(const Code); bool canInteract(const Code);
...@@ -56,7 +55,6 @@ namespace corsika::pythia8 { ...@@ -56,7 +55,6 @@ namespace corsika::pythia8 {
Pythia8::SigmaTotal sigma_; Pythia8::SigmaTotal sigma_;
const bool internalDecays_ = true; const bool internalDecays_ = true;
int count_ = 0; int count_ = 0;
bool initialized_ = false;
bool print_listing_ = false; bool print_listing_ = false;
}; };
......
Subproject commit 8b76a9ca2599cd0ce1f204b17362eb06bbcf5277 Subproject commit 15ca93e3b9a766ba93aa40e626f41ba5bcbfa0b8
...@@ -43,10 +43,15 @@ else () ...@@ -43,10 +43,15 @@ else ()
URL ${CMAKE_CURRENT_SOURCE_DIR}/pythia${_C8_Pythia8_VERSION}-stripped.tar.bz2 URL ${CMAKE_CURRENT_SOURCE_DIR}/pythia${_C8_Pythia8_VERSION}-stripped.tar.bz2
URL_MD5 83132880c0594b808bd7fd37fb642606 URL_MD5 83132880c0594b808bd7fd37fb642606
SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/pythia8/source SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/pythia8/source
INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/pythia8/install INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/external/pythia8
CONFIGURE_COMMAND ./configure --cxx-common=-Wno-deprecated-copy --prefix=${CMAKE_CURRENT_BINARY_DIR}/pythia8/install LOG_DIR ${CMAKE_CURRENT_BINARY_DIR}/pythia8/log
CONFIGURE_COMMAND ./configure --cxx-common=\\"-Wall -pedantic -Wextra -Wno-ignored-qualifiers -O0 -DNDEBUG -Wno-nonportable-include-path -g -std=c++17 -Wno-deprecated-copy -fPIC\\" --prefix=${CMAKE_INSTALL_PREFIX}/external/pythia8
BUILD_IN_SOURCE ON BUILD_IN_SOURCE ON
EXCLUDE_FROM_ALL TRUE EXCLUDE_FROM_ALL TRUE
LOG_CONFIGURE TRUE
LOG_BUILD TRUE
LOG_INSTALL TRUE
LOG_MERGED_STDOUTERR TRUE
) )
set (Pythia8_FOUND 1 PARENT_SCOPE) set (Pythia8_FOUND 1 PARENT_SCOPE)
ExternalProject_Get_Property (pythia8 INSTALL_DIR) ExternalProject_Get_Property (pythia8 INSTALL_DIR)
...@@ -77,3 +82,4 @@ endif () ...@@ -77,3 +82,4 @@ endif ()
##### add pythia8 to CORSIKA8 build ##### add pythia8 to CORSIKA8 build
add_dependencies (CORSIKA8 C8::ext::pythia8) add_dependencies (CORSIKA8 C8::ext::pythia8)
target_link_libraries (CORSIKA8 INTERFACE C8::ext::pythia8) target_link_libraries (CORSIKA8 INTERFACE C8::ext::pythia8)
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