Skip to content

Commit

Permalink
Fix crash in ExternalLHEProducer in case of earler exception
Browse files Browse the repository at this point in the history
If ExternalLHEProducer throws an exception in begin run, the code will
no longer crash when the module is called in end run.
  • Loading branch information
Dr15Jones committed Jul 4, 2017
1 parent 2af1298 commit 10267be
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions GeneratorInterface/LHEInterface/plugins/ExternalLHEProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class ExternalLHEProducer : public edm::one::EDProducer<edm::BeginRunProducer,
edm::EndRunProducer> {
public:
explicit ExternalLHEProducer(const edm::ParameterSet& iConfig);
virtual ~ExternalLHEProducer();
virtual ~ExternalLHEProducer() override;

static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);

Expand All @@ -81,7 +81,7 @@ class ExternalLHEProducer : public edm::one::EDProducer<edm::BeginRunProducer,
void executeScript();
std::unique_ptr<std::string> readOutput();

virtual void nextEvent();
void nextEvent();

// ----------member data ---------------------------
std::string scriptName_;
Expand All @@ -92,7 +92,7 @@ class ExternalLHEProducer : public edm::one::EDProducer<edm::BeginRunProducer,
unsigned int nThreads_{1};
std::string outputContents_;

std::auto_ptr<lhef::LHEReader> reader_;
std::unique_ptr<lhef::LHEReader> reader_;
boost::shared_ptr<lhef::LHERunInfo> runInfoLast;
boost::shared_ptr<lhef::LHERunInfo> runInfo;
boost::shared_ptr<lhef::LHEEvent> partonLevel;
Expand Down Expand Up @@ -267,8 +267,7 @@ ExternalLHEProducer::beginRunProduce(edm::Run& run, edm::EventSetup const& es)

std::vector<std::string> infiles(1, outputFile_);
unsigned int skip = 0;
std::auto_ptr<lhef::LHEReader> thisRead(new lhef::LHEReader(infiles, skip));
reader_ = thisRead;
reader_ = std::make_unique<lhef::LHEReader>(infiles, skip);

nextEvent();
if (runInfoLast) {
Expand Down Expand Up @@ -496,6 +495,7 @@ void ExternalLHEProducer::nextEvent()
if (partonLevel)
return;

if(not reader_) { return;}
partonLevel = reader_->next();
if (!partonLevel)
return;
Expand Down

0 comments on commit 10267be

Please sign in to comment.