diff -Naur ORIG/Analysis/RivetAnalysis.cc PATCHED/Analysis/RivetAnalysis.cc
--- ORIG/Analysis/RivetAnalysis.cc	2026-04-07 20:23:06.522048122 +0000
+++ PATCHED/Analysis/RivetAnalysis.cc	2026-04-07 20:23:06.522158384 +0000
@@ -184,7 +184,11 @@
 
   // check that analysis list is available
   _rivet = new Rivet::AnalysisHandler; //(fname);
+#if ThePEG_RIVET_VERSION > 3
+  _rivet->setCheckBeams(_checkBeams);
+#else
   _rivet->checkBeams(_checkBeams);
+#endif
   for ( int i = 0, N = _paths.size(); i < N; ++i ) Rivet::addAnalysisLibPath(_paths[i]);
   _rivet->addAnalyses(_analyses);
   if ( _rivet->analysisNames().size() != _analyses.size() ) {
@@ -202,7 +206,11 @@
   // create Rivet analysis handler
   CurrentGenerator::Redirect stdout(cout);
   _rivet = new Rivet::AnalysisHandler;
+#if ThePEG_RIVET_VERSION > 3
+  _rivet->setCheckBeams(_checkBeams);
+#else
   _rivet->checkBeams(_checkBeams);
+#endif
   for ( int i = 0, N = _paths.size(); i < N; ++i ) Rivet::addAnalysisLibPath(_paths[i]);
   _rivet->addAnalyses(_analyses);
   // check that analysis list is still available
diff -Naur ORIG/m4/hepmc.m4 PATCHED/m4/hepmc.m4
--- ORIG/m4/hepmc.m4	2026-04-07 20:23:06.522048122 +0000
+++ PATCHED/m4/hepmc.m4	2026-04-07 20:23:06.522158384 +0000
@@ -56,12 +56,12 @@
 else
 	AC_MSG_RESULT([$with_hepmc])
 	HEPMCINCLUDE=-I$with_hepmc/include
-	HEPMCLIBS="-L$with_hepmc/lib -R$with_hepmc/lib "$SHORTHEPMCLIBS
+	HEPMCLIBS="-L$with_hepmc/lib -L$with_hepmc/lib/root -Wl,-rpath=$with_hepmc/lib "$SHORTHEPMCLIBS
 	if test "${host_cpu}" == "x86_64" -a "x$with_hepmcversion" = "x2" -a -e $with_hepmc/lib64/libHepMC.so ; then
-	  HEPMCLIBS="-L$with_hepmc/lib64 -R$with_hepmc/lib64 "$SHORTHEPMCLIBS
+	  HEPMCLIBS="-L$with_hepmc/lib64 -Wl,-rpath=$with_hepmc/lib64 "$SHORTHEPMCLIBS
 	fi
 	if test "${host_cpu}" == "x86_64" -a "x$with_hepmcversion" = "x3" -a -e $with_hepmc/lib64/libHepMC3.so ; then
-	  HEPMCLIBS="-L$with_hepmc/lib64 -R$with_hepmc/lib64 "$SHORTHEPMCLIBS
+	  HEPMCLIBS="-L$with_hepmc/lib64  -L$with_hepmc/lib64/root -Wl,-rpath=$with_hepmc/lib64 "$SHORTHEPMCLIBS
 	fi
 fi
 
@@ -111,11 +111,13 @@
        [ 
          HEPMCROOTIO=1
          AC_MSG_RESULT([HepMC3 has ROOT support.])
+       	AC_DEFINE([HAVE_HEPMC_ROOTIO],  [1],[ We have HepMC3 ROOT support])
        ],[])
        AC_CHECK_HEADERS([HepMC3/WriterRootTree.h],
        [       
         HEPMCROOTIO=1
         AC_MSG_RESULT([HepMC has ROOT Tree support.])
+        AC_DEFINE([HAVE_HEPMC_ROOTIO],  [1],[ We have HepMC3 ROOT support])
        ],[])
        
        AC_CHECK_HEADERS([HepMC3/Writer.h],    
diff -Naur ORIG/m4/rivet.m4 PATCHED/m4/rivet.m4
--- ORIG/m4/rivet.m4	2026-04-07 20:23:06.522132440 +0000
+++ PATCHED/m4/rivet.m4	2026-04-07 20:23:06.522203971 +0000
@@ -67,12 +67,14 @@
 if test "x$with_rivet" = "xsystem"; then
    echo $( rivet-config --version ) | grep -q '^2\.' && rivetversion=2
    echo $( rivet-config --version ) | grep -q '^3\.' && rivetversion=3
+   echo $( rivet-config --version ) | grep -q '^4\.' && rivetversion=4
 elif test "x$with_rivet" != "xno"; then
    echo $( "$with_rivet/bin/rivet-config" --version ) | grep -q '^2\.' && rivetversion=2
    echo $( "$with_rivet/bin/rivet-config" --version ) | grep -q '^3\.' && rivetversion=3
+   echo $( "$with_rivet/bin/rivet-config" --version ) | grep -q '^4\.' && rivetversion=4
 fi
 
-AC_DEFINE_UNQUOTED([ThePEG_RIVET_VERSION], [$rivetversion], [Rivet major version (1,2,3)])
+AC_DEFINE_UNQUOTED([ThePEG_RIVET_VERSION], [$rivetversion], [Rivet major version (1,2,3,4)])
 
 AM_CONDITIONAL(HAVE_RIVET,[test "x$with_rivet" != "xno"])
 AC_SUBST(RIVETINCLUDE)
