From b4b6bd22fa9aae8926c13c71d371df8769e8c88b Mon Sep 17 00:00:00 2001 From: Antonin Portelli Date: Tue, 16 Nov 2021 21:34:25 +0000 Subject: [PATCH] compatible with Minuit2 in ROOT --- ci-scripts/install-minuit.sh | 11 +++++------ configure.ac | 22 ++++++++++++++++++---- lib/Numerical/MinuitMinimizer.cpp | 14 ++++++++++++++ 3 files changed, 37 insertions(+), 10 deletions(-) diff --git a/ci-scripts/install-minuit.sh b/ci-scripts/install-minuit.sh index 3c15118..0f6c716 100755 --- a/ci-scripts/install-minuit.sh +++ b/ci-scripts/install-minuit.sh @@ -1,6 +1,5 @@ #!/usr/bin/env bash -NAME='Minuit2-5.34.14' if (( $# != 1 )); then echo "usage: `basename $0` " 1>&2 @@ -14,11 +13,11 @@ mkdir -p ${PREFIX} cd ${PREFIX} PREFIX=$(pwd -P) cd ${INITDIR}/local/build -wget http://www.cern.ch/mathlibs/sw/5_34_14/Minuit2/${NAME}.tar.gz -tar -xzvf ${NAME}.tar.gz -mkdir -p ${NAME}/build -cd ${NAME}/build -../configure --prefix=${PREFIX} --disable-openmp +rm -rf root +git clone https://github.com/root-project/root.git +cd root/math/minuit2/ +mkdir build; cd build +cmake .. -Dminuit2_standalone=ON -DCMAKE_INSTALL_PREFIX=${PREFIX} make -j4 make install cd ${INITDIR}/local diff --git a/configure.ac b/configure.ac index 17b3aed..d1f2fab 100644 --- a/configure.ac +++ b/configure.ac @@ -36,7 +36,7 @@ AC_ARG_WITH([gsl], AC_ARG_WITH([minuit], [AS_HELP_STRING([--with-minuit=prefix], [try this for a non-standard install prefix of the Minuit2 library])], - [AM_CXXFLAGS="$AM_CXXFLAGS -I$with_minuit/include"] + [AM_CXXFLAGS="$AM_CXXFLAGS -I$with_minuit/include -I$with_minuit/include/Minuit2 -I$with_minuit/include/Fit"] [AM_LDFLAGS="$AM_LDFLAGS -L$with_minuit/lib"]) AC_ARG_WITH([nlopt], [AS_HELP_STRING([--with-nlopt=prefix], @@ -90,10 +90,10 @@ AC_CHECK_LIB([hdf5_cpp],[H5Fopen], [AC_MSG_ERROR([HDF5 library not found])], [-lhdf5]) SAVED_LDFLAGS=$LDFLAGS LDFLAGS="$LDFLAGS -lMinuit2" -AC_MSG_CHECKING([for ROOT::Minuit2::BasicMinimumError in -lMinuit2]); +AC_MSG_CHECKING([for ROOT::Minuit2::VariableMetricMinimizer in -lMinuit2]); AC_LINK_IFELSE( - [AC_LANG_PROGRAM([#include ], - [ROOT::Minuit2::BasicMinimumError dummy(0)])], + [AC_LANG_PROGRAM([#include ], + [ROOT::Minuit2::VariableMetricMinimizer dummy()])], [LIBS="$LIBS -lMinuit2"] [AC_DEFINE([HAVE_MINUIT2], [1], @@ -103,6 +103,20 @@ AC_LINK_IFELSE( [have_minuit=false] [AC_MSG_RESULT([no])]) AM_CONDITIONAL([HAVE_MINUIT], [test x$have_minuit = xtrue]) +LDFLAGS="$LDFLAGS -lMinuit2Math" +AC_MSG_CHECKING([for ROOT::Math::MinimizerOptions in -lMinuit2Math]); +AC_LINK_IFELSE( + [AC_LANG_PROGRAM([#include ], + [ROOT::Math::MinimizerOptions dummy()])], + [LIBS="$LIBS -lMinuit2Math"] + [AC_DEFINE([HAVE_MINUIT2MATH], + [1], + [Define to 1 if you have the `Minuit2Math' library (-lMinuit2Math).])] + [have_minuitmath=true] + [AC_MSG_RESULT([yes])], + [have_minuitmath=false] + [AC_MSG_RESULT([no])]) +AM_CONDITIONAL([HAVE_MINUITMATH], [test x$have_minuit = xtrue]) LDFLAGS=$SAVED_LDFLAGS CXXFLAGS=$CXXFLAGS_CPY LDFLAGS=$LDFLAGS_CPY diff --git a/lib/Numerical/MinuitMinimizer.cpp b/lib/Numerical/MinuitMinimizer.cpp index c01ff19..bab7638 100644 --- a/lib/Numerical/MinuitMinimizer.cpp +++ b/lib/Numerical/MinuitMinimizer.cpp @@ -19,6 +19,20 @@ #include #include + +// forward declaration necessary in the ROOT-based version of Minuit2 +namespace ROOT +{ + namespace Fit + { + class ParameterSettings; + }; +}; + +// macros necessary in the ROOT-based version of Minuit2 +#define ROOT_Math_VecTypes +#define MATHCORE_STANDALONE + #include #include