Commit 8808df60 authored by Andrii Verbytskyi's avatar Andrii Verbytskyi
Browse files

Add GenRunInfo in the deep copy of events

parent 8386b6f0
......@@ -64,7 +64,16 @@ inline McEventCollection& McEventCollection::operator=(const McEventCollection&
//
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;
......
......@@ -25,7 +25,6 @@
#include "Rivet/Tools/RivetYODA.hh"
#include <cstdlib>
#include <memory>
#include <regex>
......@@ -92,7 +91,7 @@ StatusCode Rivet_i::initialize() {
const std::string cmtconfig = getenv_str("CMTCONFIG");
if (cmtconfig.empty()) {
ATH_MSG_WARNING("$CMTCONFIG variable not set: finding the main analysis plugin directory will be difficult...");
}
}
else {
const std::string libpath = "/InstallArea/" + cmtconfig + "/lib";
for (const std::string& p : cmtpaths) {
......@@ -208,7 +207,7 @@ StatusCode Rivet_i::finalize() {
// Setting cross-section in Rivet
// 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;
m_analysisHandler->setCrossSection({custom_xs, m_crossSection_uncert});
......@@ -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
const DataHandle<EventInfo> eventInfo;
if (StatusCode::SUCCESS == evtStore()->retrieve(eventInfo)) {
//int run=eventInfo->event_ID()->run_number();
uint64_t eventNumber = eventInfo->event_ID()->event_number();
modEvent->set_event_number((int)eventNumber);
}
......@@ -256,14 +254,14 @@ const HepMC::GenEvent* Rivet_i::checkEvent(const HepMC::GenEvent* event) {
#ifdef HEPMC3
std::shared_ptr<HepMC3::GenRunInfo> modRunInfo;
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 {
ATH_MSG_ERROR("No run info, event weights size is " << event->weights().size() );
modRunInfo = std::make_shared<HepMC3::GenRunInfo>();
ATH_MSG_DEBUG("No run info, event weights size is " << event->weights().size() );
modRunInfo = std::make_shared<HepMC3::GenRunInfo>();
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)); }
modRunInfo->set_weight_names(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<std::string> w_names = modEvent->weight_names();
......@@ -337,8 +335,6 @@ const HepMC::GenEvent* Rivet_i::checkEvent(const HepMC::GenEvent* event) {
#endif
#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);
return modEvent;
#else
......
......@@ -62,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);
......
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