Commit 2e0881a8 authored by Adam Edward Barton's avatar Adam Edward Barton
Browse files

Merge branch 'runherwig7sherpamc' into 'master'

Add run info to Sherpa and Herwig  generators

See merge request !46217
parents b08e217e e32d859f
......@@ -9,6 +9,9 @@
#include "CLHEP/Random/RandomEngine.h"
#include "CLHEP/Random/RandPoisson.h"
#include <memory>
#ifdef HEPMC3
#include "AtlasHepMC/GenEvent.h"
#endif
/// @brief Base class for common behaviour of generator interfaces.
......@@ -85,6 +88,10 @@ protected:
/// Flag for normal vs. afterburner generators
int m_isAfterburner;
#ifdef HEPMC3
/// The run info for HepMC3
std::shared_ptr<HepMC3::GenRunInfo> m_runinfo;
#endif
private:
......
......@@ -142,6 +142,12 @@ StatusCode Herwig7::genInitialize() {
ATH_MSG_INFO("starting to prepare the run from runfile '"+m_runfile+"'...");
#ifdef HEPMC3
m_runinfo = std::make_shared<HepMC3::GenRunInfo>();
/// Here one can fill extra information, e.g. the used tools in a format generator name, version string, comment.
struct HepMC3::GenRunInfo::ToolInfo generator={std::string("Herwig7"), std::string("7"), std::string("Used generator")};
m_runinfo->tools().push_back(generator);
#endif
// read in a Herwig runfile and obtain the event generator
m_gen = Herwig::API::prepareRun(m_api);
ATH_MSG_DEBUG("preparing the run...");
......@@ -173,6 +179,9 @@ StatusCode Herwig7::fillEvt(HepMC::GenEvent* evt) {
// Convert the Herwig event into the HepMC GenEvent
ATH_MSG_DEBUG("Converting ThePEG::Event to HepMC::GenEvent");
convert_to_HepMC(*m_event, *evt, false, ThePEG::MeV, ThePEG::millimeter);
#ifdef HEPMC3
if (!evt->run_info()) evt->set_run_info(m_runinfo);
#endif
ATH_MSG_DEBUG("Converted ThePEG::Event to HepMC::GenEvent");
// Fill the event number into HepMC event record
......
......@@ -109,10 +109,6 @@ private:
std::vector<std::string> m_commands;
std::vector<std::string> m_userParams;
std::vector<std::string> m_userModes;
#ifdef HEPMC3
std::shared_ptr<HepMC3::GenRunInfo> m_runinfo;
#endif
enum PDGID {PROTON=2212, ANTIPROTON=-2212, LEAD=1000822080, NEUTRON=2112, ANTINEUTRON=-2112, MUON=13, ANTIMUON=-13, ELECTRON=11, POSITRON=-11, INVALID=0};
......
......@@ -118,9 +118,9 @@ m_athenaTool("")
m_pythia = std::make_unique<Pythia8::Pythia> (xmlpath());
#ifdef HEPMC3
m_runinfo = std::shared_ptr<HepMC3::GenRunInfo>();
/// Here one can fill extra information.
struct HepMC3::GenRunInfo::ToolInfo generator={std::string("Pythia8"),std::to_string(PYTHIA_VERSION).substr(0,5),std::string("Used generator")};
m_runinfo = std::make_shared<HepMC3::GenRunInfo>();
/// Here one can fill extra information, e.g. the used tools in a format generator name, version string, comment.
struct HepMC3::GenRunInfo::ToolInfo generator={std::string("Pythia8"),py8version(),std::string("Used generator")};
m_runinfo->tools().push_back(generator);
#endif
}
......
......@@ -14,6 +14,7 @@
#ifndef SHERPA_Main_Sherpa_H
#define SHERPA_Main_Sherpa_H
#include "ATOOLS/Org/CXXFLAGS.H"
#include "ATOOLS/Org/CXXFLAGS_PACKAGES.H"
#include "ATOOLS/Org/Exception.H"
#ifdef HEPMC3
......@@ -188,6 +189,12 @@ StatusCode Sherpa_i::genInitialize(){
return StatusCode::FAILURE;
}
#ifdef HEPMC3
m_runinfo = std::make_shared<HepMC3::GenRunInfo>();
/// Here one can fill extra information, e.g. the used tools in a format generator name, version string, comment.
struct HepMC3::GenRunInfo::ToolInfo generator={std::string("SHERPA"), std::string(SHERPA_VERSION)+ "." + std::string(SHERPA_SUBVERSION), std::string("Used generator")};
m_runinfo->tools().push_back(generator);
#endif
return StatusCode::SUCCESS;
}
......@@ -210,6 +217,9 @@ StatusCode Sherpa_i::fillEvt(HepMC::GenEvent* event) {
ATH_MSG_DEBUG( "Sherpa_i Filling event");
p_sherpa->FillHepMCEvent(*event);
#ifdef HEPMC3
if (!event->run_info()) event->set_run_info(m_runinfo);
#endif
if (event->weights().size()>2) {
//double weight_normalisation = event->weights()[2];
for (size_t i=0; i<event->weights().size(); ++i) {
......
Supports Markdown
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