From 810a05cfba78bdea1ac976667d0a24fbac106ef2 Mon Sep 17 00:00:00 2001 From: Andrii Verbytskyi Date: Sun, 17 Oct 2021 14:49:14 +0200 Subject: [PATCH 1/4] Should fix Rivet crashes --- Generators/Rivet_i/src/Rivet_i.cxx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Generators/Rivet_i/src/Rivet_i.cxx b/Generators/Rivet_i/src/Rivet_i.cxx index 32edb4fa7e2..1ba8d7371d3 100644 --- a/Generators/Rivet_i/src/Rivet_i.cxx +++ b/Generators/Rivet_i/src/Rivet_i.cxx @@ -254,6 +254,8 @@ const HepMC::GenEvent* Rivet_i::checkEvent(const HepMC::GenEvent* event) { // weight-name cleaning #ifdef HEPMC3 + std::shared_ptr modRunInfo = std::make_shared(*(event->run_info().get())); + modEvent->set_run_info(modRunInfo); std::vector w_names = event->weight_names(); if (w_names.size()) { std::vector > w_subs = { -- GitLab From b0dabb5d9f2171be3a7d3767b0d1267a721e5447 Mon Sep 17 00:00:00 2001 From: Andrii Verbytskyi Date: Mon, 18 Oct 2021 18:27:14 +0200 Subject: [PATCH 2/4] A fix to prevent rivet from crashing --- Generators/Rivet_i/src/Rivet_i.cxx | 14 ++++++++++++-- Generators/TruthIO/src/HepMCReadFromFile.cxx | 5 ++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Generators/Rivet_i/src/Rivet_i.cxx b/Generators/Rivet_i/src/Rivet_i.cxx index 1ba8d7371d3..ce9054d0509 100644 --- a/Generators/Rivet_i/src/Rivet_i.cxx +++ b/Generators/Rivet_i/src/Rivet_i.cxx @@ -254,9 +254,19 @@ const HepMC::GenEvent* Rivet_i::checkEvent(const HepMC::GenEvent* event) { // weight-name cleaning #ifdef HEPMC3 - std::shared_ptr modRunInfo = std::make_shared(*(event->run_info().get())); + std::shared_ptr modRunInfo; + if (event->run_info()) { + modRunInfo = std::make_shared(*(event->run_info().get())); + } else { + ATH_MSG_ERROR("No run info, event weights size is "<weights().size() ); + modRunInfo = std::make_shared(); + std::vector w_names; + for (size_t i = 0; i < event->weights().size(); i++) w_names.push_back(std::string("badweight")+std::to_string(i)); + modRunInfo->set_weight_names(w_names); + } + } modEvent->set_run_info(modRunInfo); - std::vector w_names = event->weight_names(); + std::vector w_names = modEvent->weight_names(); if (w_names.size()) { std::vector > w_subs = { {" nominal ",""}, diff --git a/Generators/TruthIO/src/HepMCReadFromFile.cxx b/Generators/TruthIO/src/HepMCReadFromFile.cxx index d22f9f999cb..4a89e32de9a 100644 --- a/Generators/TruthIO/src/HepMCReadFromFile.cxx +++ b/Generators/TruthIO/src/HepMCReadFromFile.cxx @@ -41,13 +41,15 @@ StatusCode HepMCReadFromFile::initialize() { return StatusCode::SUCCESS; } - +#include "HepMC3/Print.h" StatusCode HepMCReadFromFile::execute() { McEventCollection* mcEvtColl; if ( m_sgSvc->contains(m_mcEventKey) && m_sgSvc->retrieve(mcEvtColl, m_mcEventKey).isSuccess() ) { if (msgLvl(MSG::VERBOSE)) msg(MSG::VERBOSE) << "found an McEventCollecion in store" << endmsg; + + } else { // McCollection doesn't exist. Create it (empty) if (msgLvl(MSG::VERBOSE)) msg(MSG::VERBOSE) << "create new McEventCollecion in store" << endmsg; @@ -62,6 +64,7 @@ StatusCode HepMCReadFromFile::execute() { HepMC3::GenEvent* evt = new HepMC3::GenEvent(); m_hepmcio->read_event(*evt); if (m_hepmcio) { + if (!evt->run_info()) evt->set_run_info(m_hepmcio->run_info()); ++m_event_number; evt->set_event_number(m_event_number); evt->set_units(HepMC3::Units::MEV, HepMC3::Units::MM); -- GitLab From ac0c1188d5d542cc66e021679961eaa5976049e2 Mon Sep 17 00:00:00 2001 From: Andrii Verbytskyi Date: Mon, 18 Oct 2021 18:32:11 +0200 Subject: [PATCH 3/4] Sync with master --- Generators/TruthIO/src/HepMCReadFromFile.cxx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Generators/TruthIO/src/HepMCReadFromFile.cxx b/Generators/TruthIO/src/HepMCReadFromFile.cxx index 4a89e32de9a..717502f6482 100644 --- a/Generators/TruthIO/src/HepMCReadFromFile.cxx +++ b/Generators/TruthIO/src/HepMCReadFromFile.cxx @@ -41,15 +41,13 @@ StatusCode HepMCReadFromFile::initialize() { return StatusCode::SUCCESS; } -#include "HepMC3/Print.h" + StatusCode HepMCReadFromFile::execute() { McEventCollection* mcEvtColl; if ( m_sgSvc->contains(m_mcEventKey) && m_sgSvc->retrieve(mcEvtColl, m_mcEventKey).isSuccess() ) { if (msgLvl(MSG::VERBOSE)) msg(MSG::VERBOSE) << "found an McEventCollecion in store" << endmsg; - - } else { // McCollection doesn't exist. Create it (empty) if (msgLvl(MSG::VERBOSE)) msg(MSG::VERBOSE) << "create new McEventCollecion in store" << endmsg; @@ -64,7 +62,7 @@ StatusCode HepMCReadFromFile::execute() { HepMC3::GenEvent* evt = new HepMC3::GenEvent(); m_hepmcio->read_event(*evt); if (m_hepmcio) { - if (!evt->run_info()) evt->set_run_info(m_hepmcio->run_info()); + if (!evt->run_info()) evt->set_run_info(m_hepmcio->run_info()); ++m_event_number; evt->set_event_number(m_event_number); evt->set_units(HepMC3::Units::MEV, HepMC3::Units::MM); -- GitLab From 4caf8952e8db6952d70777785ef2b22f50ba3bba Mon Sep 17 00:00:00 2001 From: Andrii Verbytskyi Date: Mon, 18 Oct 2021 20:38:05 +0200 Subject: [PATCH 4/4] Update Rivet_i.cxx --- Generators/Rivet_i/src/Rivet_i.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Generators/Rivet_i/src/Rivet_i.cxx b/Generators/Rivet_i/src/Rivet_i.cxx index ce9054d0509..bf9a5082f6b 100644 --- a/Generators/Rivet_i/src/Rivet_i.cxx +++ b/Generators/Rivet_i/src/Rivet_i.cxx @@ -256,12 +256,12 @@ const HepMC::GenEvent* Rivet_i::checkEvent(const HepMC::GenEvent* event) { #ifdef HEPMC3 std::shared_ptr modRunInfo; if (event->run_info()) { - modRunInfo = std::make_shared(*(event->run_info().get())); + modRunInfo = std::make_shared(*(event->run_info().get())); } else { - ATH_MSG_ERROR("No run info, event weights size is "<weights().size() ); - modRunInfo = std::make_shared(); + ATH_MSG_ERROR("No run info, event weights size is " << event->weights().size() ); + modRunInfo = std::make_shared(); std::vector w_names; - for (size_t i = 0; i < event->weights().size(); i++) w_names.push_back(std::string("badweight")+std::to_string(i)); + for (size_t i = 0; i < event->weights().size(); i++) { w_names.push_back(std::string("badweight")+std::to_string(i)); } modRunInfo->set_weight_names(w_names); } } -- GitLab