Skip to content

Commit

Permalink
[pythia8] add --pythiaExtraSettings property
Browse files Browse the repository at this point in the history
  • Loading branch information
vvolkl committed Oct 20, 2021
1 parent 47fd230 commit bc2e5fa
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
11 changes: 10 additions & 1 deletion k4Gen/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions k4Gen/options/pythia.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
pythia8gentool.pythiacard = pythiafile
pythia8gentool.doEvtGenDecays = False
pythia8gentool.printPythiaStatistics = True
pythia8gentool.pythiaExtraSettings = [""]

from Configurables import GenAlg
pythia8gen = GenAlg("Pythia8")
Expand Down
8 changes: 6 additions & 2 deletions k4Gen/src/components/PythiaInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)!");
}

Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions k4Gen/src/components/PythiaInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string> m_pythiacard{this, "pythiacard", "Pythia_minbias_pp_100TeV.cmd"
"Name of the Pythia cmd file"};

Gaudi::Property<std::vector<std::string>> m_pythia_extrasettings{this, "pythiaExtraSettings", {""},
"Additional strings with Pythia settings, applied after the card."};
/// Pythia8 engine for jet clustering
std::unique_ptr<Pythia8::SlowJet> m_slowJet{nullptr};
// Tool to smear vertices
Expand Down

0 comments on commit bc2e5fa

Please sign in to comment.