diff --git a/Generators/Herwig7_i/src/Herwig7.cxx b/Generators/Herwig7_i/src/Herwig7.cxx
index f1a9e256653080163b0b35d69226b10cf709dcdd..1ee1a7173e59d23ef7a6bcf67b8ed6afe71a5814 100644
--- a/Generators/Herwig7_i/src/Herwig7.cxx
+++ b/Generators/Herwig7_i/src/Herwig7.cxx
@@ -215,7 +215,12 @@ StatusCode Herwig7::fillEvt(HepMC::GenEvent* evt) {
   double pdf1 = pdfs.first.xfx(sub->incoming().first ->dataPtr(), scale, x1);
   double pdf2 = pdfs.first.xfx(sub->incoming().second->dataPtr(), scale, x2);
   // Create the PDFinfo object
+#ifdef HEPMC3
+  HepMC3::GenPdfInfoPtr pdfi = std::shared_ptr<HepMC3::GenPdfInfo>();
+  pdfi->set(id1, id2, x1, x2, Q, pdf1, pdf2);
+#else
   HepMC::PdfInfo pdfi(id1, id2, x1, x2, Q, pdf1, pdf2);
+#endif
   evt->set_pdf_info(pdfi);
   ATH_MSG_DEBUG("Added PDF info to HepMC");