Logo ROOT  
Reference Guide
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"
14 #include "Minuit2/MinimumState.h"
17 
18 #include <vector>
19 #include <memory>
20 
21 #ifdef G__DICTIONARY
22 typedef ROOT::Minuit2::MinimumState MinimumState;
23 #endif
24 
25 namespace ROOT {
26 
27 namespace 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 
38 public:
39  enum Status {
43  };
44 
45 public:
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 
112 private:
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
ROOT::Minuit2::FunctionMinimum::Status
Status
Definition: FunctionMinimum.h:39
ROOT::Minuit2::FunctionMinimum::Up
double Up() const
Definition: FunctionMinimum.h:93
ROOT::Minuit2::MinimumState
MinimumState keeps the information (position, Gradient, 2nd deriv, etc) after one minimization step (...
Definition: MinimumState.h:27
ROOT::Minuit2::FunctionMinimum::HesseFailed
bool HesseFailed() const
Definition: FunctionMinimum.h:100
ROOT::Minuit2::MinimumState::IsValid
bool IsValid() const
Definition: MinimumState.h:68
MnUserTransformation.h
ROOT::Minuit2::FunctionMinimum::IsValid
bool IsValid() const
Definition: FunctionMinimum.h:94
ROOT::Minuit2::FunctionMinimum::Seed
const MinimumSeed & Seed() const
Definition: FunctionMinimum.h:71
MinimumSeed.h
ROOT::Minuit2::FunctionMinimum::HasAccurateCovar
bool HasAccurateCovar() const
Definition: FunctionMinimum.h:97
ROOT::Minuit2::FunctionMinimum::HasReachedCallLimit
bool HasReachedCallLimit() const
Definition: FunctionMinimum.h:103
MnUserParameterState.h
ROOT::Minuit2::FunctionMinimum::SetErrorDef
void SetErrorDef(double up)
Definition: FunctionMinimum.h:105
ROOT::Minuit2::MinimumError::IsValid
bool IsValid() const
Definition: MinimumError.h:72
ROOT::Minuit2::FunctionGradient
Definition: FunctionGradient.h:21
ROOT::Minuit2::MnUserCovariance
Class containing the covariance matrix data represented as a vector of size n*(n+1)/2 Used to hide in...
Definition: MnUserCovariance.h:26
ROOT::Minuit2::FunctionMinimum::MnValid
@ MnValid
Definition: FunctionMinimum.h:40
ROOT::Minuit2::FunctionMinimum::UserState
const MnUserParameterState & UserState() const
Definition: FunctionMinimum.h:75
ROOT::Minuit2::FunctionMinimum::FunctionMinimum
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.
Definition: FunctionMinimum.h:56
ROOT::Minuit2::FunctionMinimum::States
const std::vector< MinimumState > & States() const
Definition: FunctionMinimum.h:72
ROOT::Minuit2::FunctionMinimum::Error
const MinimumError & Error() const
Definition: FunctionMinimum.h:87
ROOT::Minuit2::FunctionMinimum::Fval
double Fval() const
Definition: FunctionMinimum.h:89
ROOT::Minuit2::MinimumError::HesseFailed
bool HesseFailed() const
Definition: MinimumError.h:75
ROOT::Minuit2::FunctionMinimum::Data::fReachedCallLimit
bool fReachedCallLimit
Definition: FunctionMinimum.h:118
ROOT::Minuit2::FunctionMinimum::Data::fSeed
MinimumSeed fSeed
Definition: FunctionMinimum.h:114
ROOT::Minuit2::MinimumParameters
Definition: MinimumParameters.h:19
ROOT::Minuit2::MinimumState::Error
const MinimumError & Error() const
Definition: MinimumState.h:62
ROOT::Minuit2::MnUserParameters
API class for the user interaction with the parameters; serves as input to the minimizer as well as o...
Definition: MnUserParameters.h:36
ROOT::Minuit2::FunctionMinimum::MnAboveMaxEdm
@ MnAboveMaxEdm
Definition: FunctionMinimum.h:42
ROOT::Minuit2::FunctionMinimum::Edm
double Edm() const
Definition: FunctionMinimum.h:90
ROOT::Minuit2::MinimumParameters::IsValid
bool IsValid() const
Definition: MinimumParameters.h:42
ROOT::Minuit2::FunctionMinimum::UserCovariance
const MnUserCovariance & UserCovariance() const
Definition: FunctionMinimum.h:82
ROOT::Minuit2::FunctionMinimum::Data::fStates
std::vector< MinimumState > fStates
Definition: FunctionMinimum.h:115
ROOT::Minuit2::FunctionMinimum::Data::fErrorDef
double fErrorDef
Definition: FunctionMinimum.h:116
ROOT::Minuit2::FunctionMinimum::Grad
const FunctionGradient & Grad() const
Definition: FunctionMinimum.h:88
ROOT::Minuit2::FunctionMinimum::Add
void Add(const MinimumState &state, Status status=MnValid)
add latest minimization state (for example add Hesse result after Migrad)
Definition: FunctionMinimum.h:62
ROOT::Minuit2::FunctionMinimum::fPtr
std::shared_ptr< Data > fPtr
Definition: FunctionMinimum.h:122
ROOT::Minuit2::FunctionMinimum
class holding the full result of the minimization; both internal and external (MnUserParameterState) ...
Definition: FunctionMinimum.h:36
ROOT::Minuit2::MnUserParameterState
class which holds the external user and/or internal Minuit representation of the parameters and error...
Definition: MnUserParameterState.h:33
ROOT::Minuit2::MinimumError
MinimumError keeps the inv.
Definition: MinimumError.h:28
ROOT::Minuit2::MinimumState::Parameters
const MinimumParameters & Parameters() const
Definition: MinimumState.h:58
ROOT::Minuit2::MnUserParameterState::Parameters
const MnUserParameters & Parameters() const
Definition: MnUserParameterState.h:89
ROOT::Minuit2::FunctionMinimum::Data::fUserState
MnUserParameterState fUserState
Definition: FunctionMinimum.h:119
ROOT::Minuit2::FunctionMinimum::NFcn
int NFcn() const
Definition: FunctionMinimum.h:91
ROOT::Minuit2::FunctionMinimum::HasValidCovariance
bool HasValidCovariance() const
Definition: FunctionMinimum.h:96
ROOT::Minuit2::FunctionMinimum::HasPosDefCovar
bool HasPosDefCovar() const
Definition: FunctionMinimum.h:98
ROOT::Minuit2::FunctionMinimum::Data
Definition: FunctionMinimum.h:113
ROOT::Minuit2::FunctionMinimum::MnReachedCallLimit
@ MnReachedCallLimit
Definition: FunctionMinimum.h:41
ROOT::Minuit2::FunctionMinimum::HasValidParameters
bool HasValidParameters() const
Definition: FunctionMinimum.h:95
ROOT::Minuit2::MinimumError::IsMadePosDef
bool IsMadePosDef() const
Definition: MinimumError.h:74
ROOT::Minuit2::FunctionMinimum::Parameters
const MinimumParameters & Parameters() const
Definition: FunctionMinimum.h:86
ROOT::Minuit2::FunctionMinimum::HasCovariance
bool HasCovariance() const
Definition: FunctionMinimum.h:101
ROOT::Minuit2::FunctionMinimum::IsAboveMaxEdm
bool IsAboveMaxEdm() const
Definition: FunctionMinimum.h:102
ROOT::Minuit2::FunctionMinimum::State
const MinimumState & State() const
Definition: FunctionMinimum.h:85
ROOT::Minuit2::FunctionMinimum::HasMadePosDefCovar
bool HasMadePosDefCovar() const
Definition: FunctionMinimum.h:99
ROOT::Minuit2::MinimumError::IsAvailable
bool IsAvailable() const
Definition: MinimumError.h:77
ROOT::Minuit2::MnUserParameterState::Covariance
const MnUserCovariance & Covariance() const
Definition: MnUserParameterState.h:90
ROOT::Minuit2::FunctionMinimum::UserParameters
const MnUserParameters & UserParameters() const
Definition: FunctionMinimum.h:81
ROOT::Minuit2::FunctionMinimum::FunctionMinimum
FunctionMinimum(const MinimumSeed &seed, double up)
Constructor from only MinimumSeed. Minimum is only from seed result not the full minimization.
Definition: FunctionMinimum.h:47
ROOT
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
Definition: EExecutionPolicy.hxx:4
ROOT::Minuit2::MinimumError::IsPosDef
bool IsPosDef() const
Definition: MinimumError.h:73
MinimumState.h
ROOT::Minuit2::MinimumSeed
Definition: MinimumSeed.h:23
ROOT::Minuit2::FunctionMinimum::Data::fAboveMaxEdm
bool fAboveMaxEdm
Definition: FunctionMinimum.h:117
ROOT::Minuit2::MinimumError::IsAccurate
bool IsAccurate() const
Definition: MinimumError.h:71