From 567ae6e5fa9aa1e36aaaf9d4e56dafd5b3009657 Mon Sep 17 00:00:00 2001 From: Andrii Verbytskyi <andrii.verbytskyi@cern.ch> Date: Wed, 17 Nov 2021 14:27:31 +0100 Subject: [PATCH] Fix the wrong number of beam particles in SHERPA-MC in the HepMC3 branch. --- Generators/EvgenProdTools/src/FixHepMC.cxx | 10 ++++++++++ Generators/Sherpa_i/src/Sherpa_i.cxx | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Generators/EvgenProdTools/src/FixHepMC.cxx b/Generators/EvgenProdTools/src/FixHepMC.cxx index 45fbe8675a3b..1f4ba737627c 100644 --- a/Generators/EvgenProdTools/src/FixHepMC.cxx +++ b/Generators/EvgenProdTools/src/FixHepMC.cxx @@ -46,6 +46,7 @@ StatusCode FixHepMC::execute() { // Some heuristics std::vector<HepMC::GenParticlePtr> tofix; + // Herwig7+EvtGen has problems with bad pdg id. 16.11.2021 std::vector<HepMC::GenParticlePtr> bad_pdg_id_particles; for (auto ip: evt->particles()) { // Skip this particle if (somehow) its pointer is null @@ -60,6 +61,15 @@ StatusCode FixHepMC::execute() { if (pdg_id == 43 || pdg_id == 44 || pdg_id == -43 || pdg_id == -44 || pdg_id == 30353 || pdg_id == -30353 || pdg_id == 30343 || pdg_id == -30343) bad_pdg_id_particles.push_back(ip); } + // SHERPA has problems with bad beam particles. 16.11.2021 + auto beams_t = evt->beams(); + if (beams_t.size() != 2) { + ATH_MSG_INFO("Invalid number of beam particles " << beams_t.size() << ". Will try to fix."); + std::vector<HepMC::GenParticlePtr> bparttoremove; + for (auto bpart: beams_t) if (bpart->id() == 0 && bpart->production_vertex()) bparttoremove.push_back(bpart); + for (auto bpart: bparttoremove) bpart->production_vertex()->remove_particle_out(bpart); + } + /// AV: In case we have 3 particles, we try to add a vertex that correspond to 1->2 and 1->1 splitting. if (tofix.size() == 3 || tofix.size() == 2) { size_t no_endv = 0; diff --git a/Generators/Sherpa_i/src/Sherpa_i.cxx b/Generators/Sherpa_i/src/Sherpa_i.cxx index 33dc2d47c02f..6af340906e98 100644 --- a/Generators/Sherpa_i/src/Sherpa_i.cxx +++ b/Generators/Sherpa_i/src/Sherpa_i.cxx @@ -237,7 +237,8 @@ StatusCode Sherpa_i::fillEvt(HepMC::GenEvent* event) { #ifdef HEPMC3 // units correction - event->set_units(HepMC3::Units::MEV, HepMC3::Units::MM); + event->set_units(HepMC3::Units::GEV, HepMC3::Units::MM); + GeVToMeV(event); //uncomment to list HepMC3 events // std::cout << " print::listing Sherpa " << std::endl; // HepMC3::Print::listing(std::cout, *event); -- GitLab