Commit cf60403b authored by Vakhtang Tsulaia's avatar Vakhtang Tsulaia
Browse files

Merge branch 'hepmc3_22.10.21_rivet' into 'master'

Fix Rivet errors due to absent GenRunInfo in HepMC3 branch

See merge request atlas/athena!47537
parents 9f9842a3 8808df60
...@@ -64,7 +64,16 @@ inline McEventCollection& McEventCollection::operator=(const McEventCollection& ...@@ -64,7 +64,16 @@ inline McEventCollection& McEventCollection::operator=(const McEventCollection&
// //
for (const HepMC::GenEvent* ev : in) for (const HepMC::GenEvent* ev : in)
{ {
DataVector<HepMC::GenEvent>::push_back(new HepMC::GenEvent(*ev)); HepMC::GenEvent* nev = new HepMC::GenEvent(*ev);
#ifdef HEPMC3
auto ri = ev->run_info();
if (ri) {
std::shared_ptr<HepMC3::GenRunInfo> nri = std::make_shared<HepMC3::GenRunInfo>(*(ri.get()));
nev->set_run_info(nri);
}
#endif
DataVector<HepMC::GenEvent>::push_back(nev);
} }
return *this; return *this;
......
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
#include "Rivet/Tools/RivetYODA.hh" #include "Rivet/Tools/RivetYODA.hh"
#include <cstdlib> #include <cstdlib>
#include <memory> #include <memory>
#include <regex> #include <regex>
...@@ -92,7 +91,7 @@ StatusCode Rivet_i::initialize() { ...@@ -92,7 +91,7 @@ StatusCode Rivet_i::initialize() {
const std::string cmtconfig = getenv_str("CMTCONFIG"); const std::string cmtconfig = getenv_str("CMTCONFIG");
if (cmtconfig.empty()) { if (cmtconfig.empty()) {
ATH_MSG_WARNING("$CMTCONFIG variable not set: finding the main analysis plugin directory will be difficult..."); ATH_MSG_WARNING("$CMTCONFIG variable not set: finding the main analysis plugin directory will be difficult...");
} }
else { else {
const std::string libpath = "/InstallArea/" + cmtconfig + "/lib"; const std::string libpath = "/InstallArea/" + cmtconfig + "/lib";
for (const std::string& p : cmtpaths) { for (const std::string& p : cmtpaths) {
...@@ -208,7 +207,7 @@ StatusCode Rivet_i::finalize() { ...@@ -208,7 +207,7 @@ StatusCode Rivet_i::finalize() {
// Setting cross-section in Rivet // Setting cross-section in Rivet
// If no user-specified cross-section available, // If no user-specified cross-section available,
// set AMI cross-section at plotting time // set AMI cross-section at plotting time
double custom_xs = m_crossSection != 0 ? m_crossSection : 1.0; double custom_xs = m_crossSection != 0 ? m_crossSection : 1.0;
m_analysisHandler->setCrossSection({custom_xs, m_crossSection_uncert}); m_analysisHandler->setCrossSection({custom_xs, m_crossSection_uncert});
...@@ -247,7 +246,6 @@ const HepMC::GenEvent* Rivet_i::checkEvent(const HepMC::GenEvent* event) { ...@@ -247,7 +246,6 @@ const HepMC::GenEvent* Rivet_i::checkEvent(const HepMC::GenEvent* event) {
// overwrite the HEPMC dummy event number with the proper ATLAS event number // overwrite the HEPMC dummy event number with the proper ATLAS event number
const DataHandle<EventInfo> eventInfo; const DataHandle<EventInfo> eventInfo;
if (StatusCode::SUCCESS == evtStore()->retrieve(eventInfo)) { if (StatusCode::SUCCESS == evtStore()->retrieve(eventInfo)) {
//int run=eventInfo->event_ID()->run_number();
uint64_t eventNumber = eventInfo->event_ID()->event_number(); uint64_t eventNumber = eventInfo->event_ID()->event_number();
modEvent->set_event_number((int)eventNumber); modEvent->set_event_number((int)eventNumber);
} }
...@@ -256,14 +254,14 @@ const HepMC::GenEvent* Rivet_i::checkEvent(const HepMC::GenEvent* event) { ...@@ -256,14 +254,14 @@ const HepMC::GenEvent* Rivet_i::checkEvent(const HepMC::GenEvent* event) {
#ifdef HEPMC3 #ifdef HEPMC3
std::shared_ptr<HepMC3::GenRunInfo> modRunInfo; std::shared_ptr<HepMC3::GenRunInfo> modRunInfo;
if (event->run_info()) { if (event->run_info()) {
modRunInfo = std::make_shared<HepMC3::GenRunInfo>(*(event->run_info().get())); modRunInfo = std::make_shared<HepMC3::GenRunInfo>(*(event->run_info().get()));
} }
else { else {
ATH_MSG_ERROR("No run info, event weights size is " << event->weights().size() ); ATH_MSG_DEBUG("No run info, event weights size is " << event->weights().size() );
modRunInfo = std::make_shared<HepMC3::GenRunInfo>(); modRunInfo = std::make_shared<HepMC3::GenRunInfo>();
std::vector<std::string> w_names; std::vector<std::string> 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); modRunInfo->set_weight_names(w_names);
} }
modEvent->set_run_info(modRunInfo); modEvent->set_run_info(modRunInfo);
std::vector<std::string> w_names = modEvent->weight_names(); std::vector<std::string> w_names = modEvent->weight_names();
...@@ -337,8 +335,6 @@ const HepMC::GenEvent* Rivet_i::checkEvent(const HepMC::GenEvent* event) { ...@@ -337,8 +335,6 @@ const HepMC::GenEvent* Rivet_i::checkEvent(const HepMC::GenEvent* event) {
#endif #endif
#ifdef HEPMC3 #ifdef HEPMC3
//ATH_MSG_ALWAYS("BEAM ENERGY = " << beams[0]->momentum().e());
//ATH_MSG_ALWAYS("UNITS == MEV = " << std::boolalpha << (modEvent->momentum_unit() == HepMC::Units::MEV));
modEvent->set_units(HepMC3::Units::GEV, HepMC3::Units::MM); modEvent->set_units(HepMC3::Units::GEV, HepMC3::Units::MM);
return modEvent; return modEvent;
#else #else
......
...@@ -62,7 +62,7 @@ StatusCode HepMCReadFromFile::execute() { ...@@ -62,7 +62,7 @@ StatusCode HepMCReadFromFile::execute() {
HepMC3::GenEvent* evt = new HepMC3::GenEvent(); HepMC3::GenEvent* evt = new HepMC3::GenEvent();
m_hepmcio->read_event(*evt); m_hepmcio->read_event(*evt);
if (m_hepmcio) { 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; ++m_event_number;
evt->set_event_number(m_event_number); evt->set_event_number(m_event_number);
evt->set_units(HepMC3::Units::MEV, HepMC3::Units::MM); evt->set_units(HepMC3::Units::MEV, HepMC3::Units::MM);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment