ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
19 namespace ROOT {
20 
21  namespace Minuit2 {
22 
23 
24 FunctionMinimum 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
static Vc_ALWAYS_INLINE int_v min(const int_v &x, const int_v &y)
Definition: vector.h:433
void fcn(Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t iflag)
Definition: Ifit.C:26
MinimumSeed contains the starting values for the minimization produced by the SeedGenerator.
Definition: MinimumSeed.h:31
const MinimumBuilder & Builder() const
const MnUserParameterState & UserState() const
#define MN_INFO_MSG(str)
Definition: MnPrint.h:110
const MinimumBuilder & Builder() const
class holding the full result of the minimization; both internal and external (MnUserParameterState) ...
Wrapper class to FCNBase interface used internally by Minuit.
Definition: MnFcn.h:33
const MinimumSeedGenerator & SeedGenerator() const
virtual FunctionMinimum Minimum(const MnFcn &, const GradientCalculator &, const MinimumSeed &, const MnStrategy &, unsigned int, double) const =0
const int strategy
Definition: testNdimFit.cxx:46
API class for defining three levels of strategies: low (0), medium (1), high (>=2); acts on: Migrad (...
Definition: MnStrategy.h:27
interface class for gradient calculators
virtual FunctionMinimum Minimum(const MnFcn &, const GradientCalculator &, const MinimumSeed &, const MnStrategy &, unsigned int, double) const