Logo ROOT  
Reference Guide
MinimumState.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_MinimumState
11 #define ROOT_Minuit2_MinimumState
12 
14 #include "Minuit2/MinimumError.h"
16 
17 #include <memory>
18 
19 namespace ROOT {
20 
21 namespace Minuit2 {
22 
23 /** MinimumState keeps the information (position, Gradient, 2nd deriv, etc)
24  after one minimization step (usually in MinimumBuilder).
25  */
26 
27 class MinimumState {
28 
29 public:
30  /// Invalid state.
32  {
33  }
34 
35  /// Constructor without parameter values, but with function value, edm and nfcn.
36  /// This constructor will result in a state that is flagged as not valid
37  MinimumState(double fval, double edm, int nfcn)
38  : MinimumState(MinimumParameters(0, fval), MinimumError(0), FunctionGradient(0), edm, nfcn)
39  {
40  }
41 
42  /// Constuctor with only parameter values, edm and nfcn, but without errors (covariance).
43  /// The resulting state it will be considered valid, since it contains the parameter values,
44  /// although it will has not the error matrix (MinimumError) with
45  /// HasCovariance() returning false.
46  MinimumState(const MinimumParameters &states, double edm, int nfcn)
47  : MinimumState(states, MinimumError(states.Vec().size()), FunctionGradient(states.Vec().size()), edm, nfcn)
48  {
49  }
50 
51  /// Constructor with parameters values, errors and gradient
52  MinimumState(const MinimumParameters &states, const MinimumError &err, const FunctionGradient &grad, double edm,
53  int nfcn)
54  : fPtr{new Data{states, err, grad, edm, nfcn}}
55  {
56  }
57 
58  const MinimumParameters &Parameters() const { return fPtr->fParameters; }
59  const MnAlgebraicVector &Vec() const { return Parameters().Vec(); }
60  int size() const { return Vec().size(); }
61 
62  const MinimumError &Error() const { return fPtr->fError; }
63  const FunctionGradient &Gradient() const { return fPtr->fGradient; }
64  double Fval() const { return Parameters().Fval(); }
65  double Edm() const { return fPtr->fEDM; }
66  int NFcn() const { return fPtr->fNFcn; }
67 
68  bool IsValid() const
69  {
70  if (HasParameters() && HasCovariance())
71  return Parameters().IsValid() && Error().IsValid();
72  else if (HasParameters())
73  return Parameters().IsValid();
74  else
75  return false;
76  }
77 
78  bool HasParameters() const { return Parameters().IsValid(); }
79  bool HasCovariance() const { return Error().IsAvailable(); }
80 
81 private:
82  struct Data {
86  double fEDM;
87  int fNFcn;
88  };
89 
90  std::shared_ptr<Data> fPtr;
91 };
92 
93 } // namespace Minuit2
94 
95 } // namespace ROOT
96 
97 #endif // ROOT_Minuit2_MinimumState
n
const Int_t n
Definition: legend1.C:16
ROOT::Minuit2::MinimumState::Edm
double Edm() const
Definition: MinimumState.h:65
ROOT::Minuit2::MinimumState::HasCovariance
bool HasCovariance() const
Definition: MinimumState.h:79
ROOT::Minuit2::MinimumState
MinimumState keeps the information (position, Gradient, 2nd deriv, etc) after one minimization step (...
Definition: MinimumState.h:27
ROOT::Minuit2::LAVector
Definition: LAVector.h:32
ROOT::Minuit2::MinimumState::Data::fEDM
double fEDM
Definition: MinimumState.h:86
ROOT::Minuit2::MinimumState::IsValid
bool IsValid() const
Definition: MinimumState.h:68
ROOT::Minuit2::MinimumState::Gradient
const FunctionGradient & Gradient() const
Definition: MinimumState.h:63
ROOT::Minuit2::MinimumState::Data
Definition: MinimumState.h:82
ROOT::Minuit2::MinimumParameters::Vec
const MnAlgebraicVector & Vec() const
Definition: MinimumParameters.h:39
ROOT::Minuit2::MinimumState::MinimumState
MinimumState(double fval, double edm, int nfcn)
Constructor without parameter values, but with function value, edm and nfcn.
Definition: MinimumState.h:37
ROOT::Minuit2::MinimumState::fPtr
std::shared_ptr< Data > fPtr
Definition: MinimumState.h:90
ROOT::Minuit2::MinimumState::MinimumState
MinimumState(const MinimumParameters &states, const MinimumError &err, const FunctionGradient &grad, double edm, int nfcn)
Constructor with parameters values, errors and gradient.
Definition: MinimumState.h:52
ROOT::Minuit2::MinimumState::NFcn
int NFcn() const
Definition: MinimumState.h:66
ROOT::Minuit2::MinimumError::IsValid
bool IsValid() const
Definition: MinimumError.h:72
ROOT::Minuit2::FunctionGradient
Definition: FunctionGradient.h:21
ROOT::Minuit2::MinimumState::MinimumState
MinimumState(unsigned int n)
Invalid state.
Definition: MinimumState.h:31
ROOT::Minuit2::MinimumState::MinimumState
MinimumState(const MinimumParameters &states, double edm, int nfcn)
Constuctor with only parameter values, edm and nfcn, but without errors (covariance).
Definition: MinimumState.h:46
ROOT::Minuit2::MinimumParameters::Fval
double Fval() const
Definition: MinimumParameters.h:41
ROOT::Minuit2::MinimumState::Data::fParameters
MinimumParameters fParameters
Definition: MinimumState.h:83
ROOT::Minuit2::MinimumParameters
Definition: MinimumParameters.h:19
FunctionGradient.h
ROOT::Minuit2::MinimumState::Error
const MinimumError & Error() const
Definition: MinimumState.h:62
ROOT::Minuit2::MinimumState::Data::fNFcn
int fNFcn
Definition: MinimumState.h:87
ROOT::Minuit2::MinimumState::Fval
double Fval() const
Definition: MinimumState.h:64
ROOT::Minuit2::MinimumState::Data::fGradient
FunctionGradient fGradient
Definition: MinimumState.h:85
ROOT::Minuit2::MinimumParameters::IsValid
bool IsValid() const
Definition: MinimumParameters.h:42
ROOT::Minuit2::MinimumState::size
int size() const
Definition: MinimumState.h:60
ROOT::Minuit2::MinimumState::Vec
const MnAlgebraicVector & Vec() const
Definition: MinimumState.h:59
ROOT::Minuit2::MinimumState::Data::fError
MinimumError fError
Definition: MinimumState.h:84
ROOT::Minuit2::LAVector::size
unsigned int size() const
Definition: LAVector.h:227
ROOT::Minuit2::MinimumError
MinimumError keeps the inv.
Definition: MinimumError.h:28
ROOT::Minuit2::MinimumState::Parameters
const MinimumParameters & Parameters() const
Definition: MinimumState.h:58
MinimumError.h
ROOT::Minuit2::MinimumState::HasParameters
bool HasParameters() const
Definition: MinimumState.h:78
MinimumParameters.h
ROOT::Minuit2::MinimumError::IsAvailable
bool IsAvailable() const
Definition: MinimumError.h:77
ROOT
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
Definition: EExecutionPolicy.hxx:4