ROOT   Reference Guide
CombinedMinimumBuilder.cxx
Go to the documentation of this file.
1// @(#)root/minuit2:$Id$
2// Authors: M. Winkler, F. James, L. Moneta, A. Zsenei 2003-2005
3
4/**********************************************************************
5 * *
6 * Copyright (c) 2005 LCG ROOT Math team, CERN/PH-SFT *
7 * *
8 **********************************************************************/
9
12#include "Minuit2/MnStrategy.h"
13
14#if defined(DEBUG) || defined(WARNINGMSG)
15#include "Minuit2/MnPrint.h"
16#endif
17
18
19namespace ROOT {
20
21 namespace Minuit2 {
22
23
24FunctionMinimum CombinedMinimumBuilder::Minimum(const MnFcn& fcn, const GradientCalculator& gc, const MinimumSeed& seed, const MnStrategy& strategy, unsigned int maxfcn, double edmval) const {
25 // find minimum using combined method
26 // (Migrad then if fails try Simplex and then Migrad again)
27
28 FunctionMinimum min = fVMMinimizer.Builder().Minimum(fcn, gc, seed, strategy, maxfcn, edmval);
29
30 if(!min.IsValid()) {
31#ifdef WARNINGMSG
32 MN_INFO_MSG("CombinedMinimumBuilder: migrad method fails, will try with simplex method first.");
33#endif
34 MnStrategy str(2);
35 FunctionMinimum min1 = fSimplexMinimizer.Builder().Minimum(fcn, gc, seed, str, maxfcn, edmval);
36 if(!min1.IsValid()) {
37#ifdef WARNINGMSG
38 MN_INFO_MSG("CombinedMinimumBuilder: both migrad and simplex method fail.");
39#endif
40 return min1;
41 }
42 MinimumSeed seed1 = fVMMinimizer.SeedGenerator()(fcn, gc, min1.UserState(), str);
43
44 FunctionMinimum min2 = fVMMinimizer.Builder().Minimum(fcn, gc, seed1, str, maxfcn, edmval);
45 if(!min2.IsValid()) {
46#ifdef WARNINGMSG
47 MN_INFO_MSG("CombinedMinimumBuilder: both migrad and method fails also at 2nd attempt.");
48 MN_INFO_MSG("CombinedMinimumBuilder: return simplex Minimum.");
49#endif
50 return min1;
51 }
52
53 return min2;
54 }
55
56 return min;
57}
58
59 } // namespace Minuit2
60
61} // namespace ROOT
#define MN_INFO_MSG(str)
Definition: MnPrint.h:110
virtual FunctionMinimum Minimum(const MnFcn &, const GradientCalculator &, const MinimumSeed &, const MnStrategy &, unsigned int, double) const
class holding the full result of the minimization; both internal and external (MnUserParameterState) ...
const MnUserParameterState & UserState() const