Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
MnApplication.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
13#include "Minuit2/FCNBase.h"
14#include "Minuit2/MnPrint.h"
15
16namespace ROOT {
17
18namespace Minuit2 {
19
20// constructor from non-gradient functions
22 unsigned int nfcn)
23 : fFCN(fcn), fState(state), fStrategy(stra), fNumCall(nfcn)
24{
25}
26
28{
29 // constructor from macfcn calls and tolerance
30 MnPrint print("MnApplication");
31
33 unsigned int npar = State().VariableParameters();
34 // assert(npar > 0);
35 if (maxfcn == 0)
36 maxfcn = 200 + 100 * npar + 5 * npar * npar;
37
38 const FCNBase &fcn = Fcnbase();
39
40
41 if (npar == 0) {
42 double fval = fcn(fState.Params());
43 print.Info("Function has zero parameters - returning current function value - ",fval);
44 // create a valid Minuit-Parameter object with just the function value
48 }
49
51
52 fNumCall += min.NFcn();
53 fState = min.UserState();
54
55 const std::vector<ROOT::Minuit2::MinimumState> &iterationStates = min.States();
56 print.Debug("State resulting from Migrad after", iterationStates.size(), "iterations:", fState);
57
58 print.Debug([&](std::ostream &os) {
59 for (unsigned int i = 0; i < iterationStates.size(); ++i) {
60 // std::cout << iterationStates[i] << std::endl;
62 os << "\n----------> Iteration " << i << '\n';
63 int pr = os.precision(18);
64 os << " FVAL = " << st.Fval() << " Edm = " << st.Edm() << " Nfcn = " << st.NFcn() << '\n';
65 os.precision(pr);
66 os << " Error matrix change = " << st.Error().Dcovar() << '\n';
67 os << " Internal parameters : ";
68 for (int j = 0; j < st.size(); ++j)
69 os << " p" << j << " = " << st.Vec()(j);
70 }
71 });
72
73 return min;
74}
75
76} // namespace Minuit2
77
78} // namespace ROOT
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Interface (abstract class) defining the function to be minimized, which has to be implemented by the ...
Definition FCNBase.h:49
class holding the full result of the minimization; both internal and external (MnUserParameterState) ...
MinimumState keeps the information (position, Gradient, 2nd deriv, etc) after one minimization step (...
MnUserParameterState fState
virtual ModularFunctionMinimizer & Minimizer()=0
virtual FunctionMinimum operator()(unsigned int maxfcn=0, double tolerance=0.1)
Minimize the function.
virtual const FCNBase & Fcnbase() const
MnUserParameterState & State()
MnApplication(const FCNBase &fcn, const MnUserParameterState &state, const MnStrategy &stra, unsigned int nfcn=0)
constructor from non-gradient functions
void Debug(const Ts &... args)
Definition MnPrint.h:135
void Info(const Ts &... args)
Definition MnPrint.h:129
API class for defining four levels of strategies: low (0), medium (1), high (2), very high (>=3); act...
Definition MnStrategy.h:27
class which holds the external user and/or internal Minuit representation of the parameters and error...
const MnUserTransformation & Trafo() const
Namespace for new ROOT classes and functions.