Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
FunctionMinimum.h
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
10#ifndef ROOT_Minuit2_FunctionMinimum
11#define ROOT_Minuit2_FunctionMinimum
12
13#include "Minuit2/MinimumSeed.h"
17
18#include <vector>
19#include <memory>
20
21#ifdef G__DICTIONARY
22typedef ROOT::Minuit2::MinimumState MinimumState;
23#endif
24
25namespace ROOT {
26
27namespace Minuit2 {
28
29//______________________________________________________________________________________________
30/**
31 class holding the full result of the minimization;
32 both internal and external (MnUserParameterState) representation available
33 for the parameters at the Minimum
34 */
35
37
38public:
39 enum Status {
43 };
44
45public:
46 /// Constructor from only MinimumSeed. Minimum is only from seed result not the full minimization
47 FunctionMinimum(const MinimumSeed &seed, double up)
48 : FunctionMinimum(seed,
49 std::vector<MinimumState>(1, MinimumState(seed.Parameters(), seed.Error(), seed.Gradient(),
50 seed.Parameters().Fval(), seed.NFcn())),
51 up)
52 {
53 }
54
55 /// Constructor at the end of a minimization from seed and vector of states
56 FunctionMinimum(const MinimumSeed &seed, const std::vector<MinimumState> &states, double up, Status status = MnValid)
57 : fPtr{new Data{seed, states, up, status == MnAboveMaxEdm, status == MnReachedCallLimit, {}}}
58 {
59 }
60
61 /// add latest minimization state (for example add Hesse result after Migrad)
62 void Add(const MinimumState &state, Status status = MnValid)
63 {
64 fPtr->fStates.push_back(state);
65 // LM : update also the user state
66 fPtr->fUserState = MnUserParameterState(State(), Up(), Seed().Trafo());
67 // reset maxedm flag. If new state has edm over max other method must be used
68 fPtr->fAboveMaxEdm = status == MnAboveMaxEdm;
69 }
70
71 const MinimumSeed &Seed() const { return fPtr->fSeed; }
72 const std::vector<MinimumState> &States() const { return fPtr->fStates; }
73
74 // user representation of state at Minimum
76 {
77 if (!fPtr->fUserState.IsValid())
78 fPtr->fUserState = MnUserParameterState(State(), Up(), Seed().Trafo());
79 return fPtr->fUserState;
80 }
81 const MnUserParameters &UserParameters() const { return UserState().Parameters(); }
82 const MnUserCovariance &UserCovariance() const { return UserState().Covariance(); }
83
84 // forward interface of last state
85 const MinimumState &State() const { return States().back(); }
86 const MinimumParameters &Parameters() const { return States().back().Parameters(); }
87 const MinimumError &Error() const { return States().back().Error(); }
88 const FunctionGradient &Grad() const { return States().back().Gradient(); }
89 double Fval() const { return States().back().Fval(); }
90 double Edm() const { return States().back().Edm(); }
91 int NFcn() const { return States().back().NFcn(); }
92
93 double Up() const { return fPtr->fErrorDef; }
94 bool IsValid() const { return State().IsValid() && !IsAboveMaxEdm() && !HasReachedCallLimit(); }
95 bool HasValidParameters() const { return State().Parameters().IsValid(); }
96 bool HasValidCovariance() const { return State().Error().IsValid(); }
97 bool HasAccurateCovar() const { return State().Error().IsAccurate(); }
98 bool HasPosDefCovar() const { return State().Error().IsPosDef(); }
99 bool HasMadePosDefCovar() const { return State().Error().IsMadePosDef(); }
100 bool HesseFailed() const { return State().Error().HesseFailed(); }
101 bool HasCovariance() const { return State().Error().IsAvailable(); }
102 bool IsAboveMaxEdm() const { return fPtr->fAboveMaxEdm; }
103 bool HasReachedCallLimit() const { return fPtr->fReachedCallLimit; }
104
105 void SetErrorDef(double up)
106 {
107 fPtr->fErrorDef = up;
108 // update user state for new valeu of up (scaling of errors)
109 fPtr->fUserState = MnUserParameterState(State(), up, Seed().Trafo());
110 }
111
112private:
113 struct Data {
115 std::vector<MinimumState> fStates;
116 double fErrorDef;
120 };
121
122 std::shared_ptr<Data> fPtr;
123};
124
125} // namespace Minuit2
126
127} // namespace ROOT
128
129#endif // ROOT_Minuit2_FunctionMinimum
class holding the full result of the minimization; both internal and external (MnUserParameterState) ...
const std::vector< MinimumState > & States() const
FunctionMinimum(const MinimumSeed &seed, const std::vector< MinimumState > &states, double up, Status status=MnValid)
Constructor at the end of a minimization from seed and vector of states.
void Add(const MinimumState &state, Status status=MnValid)
add latest minimization state (for example add Hesse result after Migrad)
const MinimumParameters & Parameters() const
const MinimumError & Error() const
const FunctionGradient & Grad() const
std::shared_ptr< Data > fPtr
const MnUserParameterState & UserState() const
const MnUserCovariance & UserCovariance() const
const MinimumState & State() const
const MnUserParameters & UserParameters() const
FunctionMinimum(const MinimumSeed &seed, double up)
Constructor from only MinimumSeed. Minimum is only from seed result not the full minimization.
const MinimumSeed & Seed() const
MinimumError keeps the inv.
MinimumState keeps the information (position, Gradient, 2nd deriv, etc) after one minimization step (...
Class containing the covariance matrix data represented as a vector of size n*(n+1)/2 Used to hide in...
class which holds the external user and/or internal Minuit representation of the parameters and error...
API class for the user interaction with the parameters; serves as input to the minimizer as well as o...
const std::vector< ROOT::Minuit2::MinuitParameter > & Parameters() const
access to parameters (row-wise)
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
std::vector< MinimumState > fStates