Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed exceptional case handling in SherpaHadronizer #35204

Merged
merged 2 commits into from
Sep 9, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 11 additions & 5 deletions GeneratorInterface/SherpaInterface/src/SherpaHadronizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

#include "CLHEP/Random/RandomEngine.h"

#include "FWCore/Utilities/interface/Exception.h"

//This unnamed namespace is used (instead of static variables) to pass the
//randomEngine passed to doSetRandomEngine to the External Random
//Number Generator CMS_SHERPA_RNG of sherpa
Expand Down Expand Up @@ -95,8 +97,11 @@ void SherpaHadronizer::doSetRandomEngine(CLHEP::HepRandomEngine *v) {
SetExternalEngine(v);
// Throw exception if there is no reference to an external RNG and it is not the first call!
} else {
throw edm::Exception(edm::errors::LogicError) << "The Sherpa interface got a randomEngine reference but there is "
"no reference to the external RNG to hand it over to\n";
if (isInitialized and v != nullptr) {
throw edm::Exception(edm::errors::LogicError)
<< "The Sherpa interface got a randomEngine reference but there is "
"no reference to the external RNG to hand it over to\n";
}
}
} else {
cmsSherpaRng->setRandomEngine(v);
Expand Down Expand Up @@ -199,6 +204,9 @@ SherpaHadronizer::SherpaHadronizer(const edm::ParameterSet &params)
arguments.push_back(shRng);
isInitialized = false;
//initialization of Sherpa moved to initializeForInternalPartons
#ifdef USING__MPI
MPI::Init();
#endif
}

SherpaHadronizer::~SherpaHadronizer() {
Expand All @@ -210,14 +218,12 @@ SherpaHadronizer::~SherpaHadronizer() {

bool SherpaHadronizer::initializeForInternalPartons() {
//initialize Sherpa but only once
throw cms::Exception("TEST");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Argg! This was left over from my testing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in #35224

if (!isInitialized) {
int argc = arguments.size();
char *argv[argc];
for (int l = 0; l < argc; l++)
argv[l] = (char *)arguments[l].c_str();
#ifdef USING__MPI
MPI::Init();
#endif
Generator->InitializeTheRun(argc, argv);
Generator->InitializeTheEventHandler();
isInitialized = true;
Expand Down