Skip to content

Commit f860147

Browse files
committed
[Math] Make building old C++ Minuit implementation optional
Minuit 2 has been the default for 2 years, and one day we should consider not building ROOT with the old C++ TMinuit implementation anymore. To make it possible to try this out, introduce a new `minuit1` flag that is on by default. Building with `minuit1=OFF` will also help to ensure that we are actually using Minuit 2 in all out tests. With this, it was uncovered that the `stressRooFit` actually didn't use Minuit 2, even thought it's the default minimizer in RooFit as well. Therefore, the default minimizer setting in `stressRooFit`/`stressRooStats` are changed to `Minuit2`, reference files are updated, and new tests with the old Minuit 1 are added to keep previous test coverage.
1 parent 336fac6 commit f860147

File tree

13 files changed

+32
-11
lines changed

13 files changed

+32
-11
lines changed

cmake/modules/RootBuildOptions.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ ROOT_BUILD_OPTION(llvm13_broken_tests OFF "Enable broken tests with LLVM 13 on W
146146
ROOT_BUILD_OPTION(macos_native OFF "Disable looking for libraries, includes and binaries in locations other than a native installation (MacOS only)")
147147
ROOT_BUILD_OPTION(mathmore OFF "Build libMathMore extended math library (requires GSL) [GPL]")
148148
ROOT_BUILD_OPTION(memory_termination OFF "Free internal ROOT memory before process termination (experimental, used for leak checking)")
149+
ROOT_BUILD_OPTION(minuit1 ON "Build also the original C++ implementation of Minuit, alongside Minuit 2. This flag has no effect on Minuit 2, which is always built.")
149150
ROOT_BUILD_OPTION(minuit2_mpi OFF "Enable support for MPI in Minuit2")
150151
ROOT_BUILD_OPTION(minuit2_omp OFF "Enable support for OpenMP in Minuit2")
151152
ROOT_BUILD_OPTION(mpi OFF "Enable support for Message Passing Interface (MPI)")

math/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ if(mathmore)
99
add_subdirectory(mathmore)
1010
endif()
1111
add_subdirectory(matrix)
12-
add_subdirectory(minuit)
12+
if(minuit1)
13+
add_subdirectory(minuit)
14+
endif()
1315
add_subdirectory(minuit2)
1416
add_subdirectory(fumili)
1517
add_subdirectory(physics)

roofit/roofitcore/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,10 @@ if(fftw3)
492492
target_compile_definitions(RooFitCore PUBLIC ROOFIT_MATH_FFTW3)
493493
endif()
494494

495+
if(minuit1)
496+
target_compile_definitions(RooFitCore PUBLIC ROOFIT_MINUIT_1)
497+
endif()
498+
495499
target_include_directories(RooFitCore PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/res>)
496500

497501
# The SMatrix package is header-only, but it's only exposed via the Smatrix

roofit/roofitcore/test/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ if(mathmore)
9090
endif()
9191

9292
configure_file(stressRooFit_ref.root stressRooFit_ref.root COPYONLY)
93+
configure_file(stressRooFit_ref_minuit1.root stressRooFit_ref_minuit1.root COPYONLY)
94+
if(minuit1)
95+
ROOT_ADD_TEST(test-stressroofit-cpu-minuit1 COMMAND stressRooFit -minim Minuit -f stressRooFit_ref_minuit1.root -b cpu FAILREGEX "FAILED|Error in")
96+
endif()
9397
if(roofit_legacy_eval_backend)
9498
ROOT_ADD_TEST(test-stressroofit-legacy COMMAND stressRooFit -b legacy FAILREGEX "FAILED|Error in")
9599
endif()

roofit/roofitcore/test/stressRooFit.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ int main(int argc, const char *argv[])
255255

256256
// string refFileName = "http://root.cern.ch/files/stressRooFit_v534_ref.root" ;
257257
string refFileName = "stressRooFit_ref.root";
258-
string minimizerName = "Minuit";
258+
string minimizerName = "Minuit2";
259259

260260
auto verbosityOptionErrorMsg = "Multiple verbosity-related options have been passed to stressRooFit! The options "
261261
"-v, -vv, and -q are mutually exclusive.";
-6.1 KB
Binary file not shown.
423 KB
Binary file not shown.

roofit/roofitmore/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ ROOT_STANDARD_LIBRARY_PACKAGE(RooFitMore
4949
Hist
5050
Matrix
5151
Tree
52-
Minuit
5352
RIO
5453
MathCore
5554
Foam

roofit/roostats/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
# @author Pere Mato, CERN
1010
############################################################################
1111

12+
if(minuit1)
13+
list(APPEND EXTRA_LIBRARIES Minuit)
14+
endif()
15+
1216
set (EXTRA_DICT_OPTS)
1317
if (runtime_cxxmodules AND WIN32)
1418
set (EXTRA_DICT_OPTS NO_CXXMODULE)
@@ -121,6 +125,8 @@ ROOT_STANDARD_LIBRARY_PACKAGE(RooStats
121125
src/UpperLimitMCSModule.cxx
122126
DICTIONARY_OPTIONS
123127
"-writeEmptyRootPCM"
128+
LIBRARIES
129+
${EXTRA_LIBRARIES}
124130
DEPENDENCIES
125131
Core
126132
RooFit
@@ -130,7 +136,6 @@ ROOT_STANDARD_LIBRARY_PACKAGE(RooStats
130136
Hist
131137
Matrix
132138
MathCore
133-
Minuit
134139
Foam
135140
Graf
136141
Gpad

roofit/roostats/src/LikelihoodInterval.cxx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@
5858
#include "RooFunctor.h"
5959
#include "RooProfileLL.h"
6060

61+
#ifdef ROOFIT_MINUIT_1
6162
#include "TMinuitMinimizer.h"
63+
#endif
6264

6365
#include <string>
6466
#include <algorithm>
@@ -260,8 +262,10 @@ bool LikelihoodInterval::CreateMinimizer() {
260262
ccoutE(InputArguments) << minimType << " is wrong type of minimizer for getting interval limits or contours - must use Minuit or Minuit2" << std::endl;
261263
return false;
262264
}
265+
#ifdef ROOFIT_MINUIT_1
263266
// do not use static instance of TMInuit which could interfere with RooFit
264267
if (minimType == "Minuit") TMinuitMinimizer::UseStaticMinuit(false);
268+
#endif
265269
// create minimizer class
266270
fMinimizer = std::shared_ptr<ROOT::Math::Minimizer>(ROOT::Math::Factory::CreateMinimizer(minimType, "Migrad"));
267271

0 commit comments

Comments
 (0)