Skip to content

Commit

Permalink
Fix for Pythia >=8.310
Browse files Browse the repository at this point in the history
The interface of setRndmEnginePtr has changed Pythia versions starting from 8.310. A possible solution has been implemented which selects the pointer type at compilation time.
  • Loading branch information
jackal1-66 authored and ktf committed Apr 28, 2024
1 parent 806f2fe commit 4117b0c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
8 changes: 6 additions & 2 deletions EvtGenExternal/EvtPythiaEngine.hh
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,12 @@ class EvtPythiaEngine : public EvtAbsExternalGen {

bool _convertPhysCodes, _initialised, _useEvtGenRandom;

std::unique_ptr<EvtPythiaRandom> _evtgenRandom;

#if PYTHIA_VERSION_INTEGER < 8310
std::unique_ptr<EvtPythiaRandom> _evtgenRandom;
#else
std::shared_ptr<EvtPythiaRandom> _evtgenRandom;
#endif

std::map<int, int> _addedPDGCodes;
};

Expand Down
15 changes: 12 additions & 3 deletions src/EvtGenExternal/EvtPythiaEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@ EvtPythiaEngine::EvtPythiaEngine( std::string xmlDir, bool convertPhysCodes,
// from EvtGen for Pythia 8.
_useEvtGenRandom = useEvtGenRandom;

_evtgenRandom = std::make_unique<EvtPythiaRandom>();
#if PYTHIA_VERSION_INTEGER < 8310
_evtgenRandom = std::make_unique<EvtPythiaRandom>();
#else
_evtgenRandom = std::make_shared<EvtPythiaRandom>();
#endif

_initialised = false;
}
Expand Down Expand Up @@ -128,8 +132,13 @@ void EvtPythiaEngine::initialise()

// Set the random number generator
if ( _useEvtGenRandom == true ) {
_genericPythiaGen->setRndmEnginePtr( _evtgenRandom.get() );
_aliasPythiaGen->setRndmEnginePtr( _evtgenRandom.get() );
#if PYTHIA_VERSION_INTEGER < 8310
_genericPythiaGen->setRndmEnginePtr( _evtgenRandom.get() );
_aliasPythiaGen->setRndmEnginePtr( _evtgenRandom.get() );
#else
_genericPythiaGen->setRndmEnginePtr( _evtgenRandom );
_aliasPythiaGen->setRndmEnginePtr( _evtgenRandom );
#endif
}

_genericPythiaGen->init();
Expand Down

0 comments on commit 4117b0c

Please sign in to comment.