From bc2e5fa38af3ebed0c21ad41cb6b47b1aa996caf Mon Sep 17 00:00:00 2001 From: Valentin Volkl Date: Wed, 20 Oct 2021 15:54:26 +0200 Subject: [PATCH] [pythia8] add --pythiaExtraSettings property --- k4Gen/CMakeLists.txt | 11 ++++++++++- k4Gen/options/pythia.py | 1 + k4Gen/src/components/PythiaInterface.cpp | 8 ++++++-- k4Gen/src/components/PythiaInterface.h | 3 +++ 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/k4Gen/CMakeLists.txt b/k4Gen/CMakeLists.txt index 5560031..8ea62fe 100644 --- a/k4Gen/CMakeLists.txt +++ b/k4Gen/CMakeLists.txt @@ -10,7 +10,7 @@ find_package(EvtGen) file(GLOB k4gen_plugin_sources src/components/*.cpp) gaudi_add_module(k4Gen SOURCES ${k4gen_plugin_sources} - LINK Gaudi::GaudiKernel ${HEPMC_LIBRARIES} Gaudi::GaudiAlgLib k4FWCore::k4FWCore k4FWCore::k4FWCorePlugins ${HEPPDT_LIBRARIES} ${EVTGEN_LIBRARIES} EDM4HEP::edm4hep EDM4HEP::edm4hepDict) + LINK Gaudi::GaudiKernel ${HEPMC_LIBRARIES} Gaudi::GaudiAlgLib k4FWCore::k4FWCore ${HEPPDT_LIBRARIES} ${EVTGEN_LIBRARIES} EDM4HEP::edm4hep EDM4HEP::edm4hepDict) target_include_directories(k4Gen PUBLIC ${PYTHIA8_INCLUDE_DIRS} $ @@ -56,6 +56,15 @@ add_test(NAME Pythia8Default ) set_test_env(Pythia8Default) +add_test(NAME Pythia8ExtraSettings + WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} + COMMAND k4run ${CMAKE_CURRENT_LIST_DIR}/options/pythia.py --pythiaExtraSettings "Beams:idA = 13" "Beams:idB = -13" + ) +set_tests_properties(Pythia8ExtraSettings PROPERTIES + PASS_REGULAR_EXPRESSION "We collide mu- with mu" + ) +set_test_env(Pythia8ExtraSettings) + #--- Install the example options to the directory where the spack installation #--- points the $K4GEN environment variable install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/options diff --git a/k4Gen/options/pythia.py b/k4Gen/options/pythia.py index fba3c0e..57fa2ed 100644 --- a/k4Gen/options/pythia.py +++ b/k4Gen/options/pythia.py @@ -39,6 +39,7 @@ pythia8gentool.pythiacard = pythiafile pythia8gentool.doEvtGenDecays = False pythia8gentool.printPythiaStatistics = True +pythia8gentool.pythiaExtraSettings = [""] from Configurables import GenAlg pythia8gen = GenAlg("Pythia8") diff --git a/k4Gen/src/components/PythiaInterface.cpp b/k4Gen/src/components/PythiaInterface.cpp index 115f8f1..f1c9743 100644 --- a/k4Gen/src/components/PythiaInterface.cpp +++ b/k4Gen/src/components/PythiaInterface.cpp @@ -35,7 +35,7 @@ StatusCode PythiaInterface::initialize() { StatusCode sc = GaudiTool::initialize(); if (!sc.isSuccess()) return sc; - if (m_pythiacard.empty()) { + if (m_pythiacard.empty() && m_pythia_extrasettings.size() < 2) { return Error("Define Pythia8 configuration file (*.cmd)!"); } @@ -62,7 +62,11 @@ StatusCode PythiaInterface::initialize() { // Read Pythia configuration files m_pythiaSignal->readFile(m_pythiacard.value().c_str()); - // do not bother with pileup configuration if no pileup + + // Apply any extra pythia8 settings + for (auto pythiacommand: m_pythia_extrasettings) { + m_pythiaSignal->settings.readString(pythiacommand); + } // Initialize variables from configuration file m_nAbort = m_pythiaSignal->settings.mode("Main:timesAllowErrors"); // how many aborts before run stops diff --git a/k4Gen/src/components/PythiaInterface.h b/k4Gen/src/components/PythiaInterface.h index 276d2ba..801d31d 100644 --- a/k4Gen/src/components/PythiaInterface.h +++ b/k4Gen/src/components/PythiaInterface.h @@ -53,6 +53,9 @@ class PythiaInterface : public GaudiTool, virtual public IHepMCProviderTool { /// Name of Pythia configuration file with Pythia simulation settings & input LHE file (if required) Gaudi::Property m_pythiacard{this, "pythiacard", "Pythia_minbias_pp_100TeV.cmd" "Name of the Pythia cmd file"}; + + Gaudi::Property> m_pythia_extrasettings{this, "pythiaExtraSettings", {""}, + "Additional strings with Pythia settings, applied after the card."}; /// Pythia8 engine for jet clustering std::unique_ptr m_slowJet{nullptr}; // Tool to smear vertices