Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
16
17#include <memory>
18
19namespace ROOT {
20
21namespace Minuit2 {
22
23/** MinimumState keeps the information (position, Gradient, 2nd deriv, etc)
24 after one minimization step (usually in MinimumBuilder).
25 */
26
28
29public:
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 /// Constructor 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 has not the error matrix (MinimumError) and HasCovariance() returns false.
45 MinimumState(const MinimumParameters &states, double edm, int nfcn)
46 : MinimumState(states, MinimumError(states.Vec().size()), FunctionGradient(states.Vec().size()), edm, nfcn)
47 {
48 }
49
50 /// Constructor with parameters values, errors and gradient
51 MinimumState(const MinimumParameters &states, const MinimumError &err, const FunctionGradient &grad, double edm,
52 int nfcn)
53 : fPtr{new Data{states, err, grad, edm, nfcn}}
54 {
55 }
56
57 const MinimumParameters &Parameters() const { return fPtr->fParameters; }
58 const MnAlgebraicVector &Vec() const { return Parameters().Vec(); }
59 int size() const { return Vec().size(); }
60
61 const MinimumError &Error() const { return fPtr->fError; }
62 const FunctionGradient &Gradient() const { return fPtr->fGradient; }
63 double Fval() const { return Parameters().Fval(); }
64 double Edm() const { return fPtr->fEDM; }
65 int NFcn() const { return fPtr->fNFcn; }
66
67 bool IsValid() const
68 {
70 return Parameters().IsValid() && Error().IsValid();
71 else if (HasParameters())
72 return Parameters().IsValid();
73 else
74 return false;
75 }
76
77 bool HasParameters() const { return Parameters().IsValid(); }
78 bool HasCovariance() const { return Error().IsAvailable(); }
79
80private:
81 struct Data {
85 double fEDM;
86 int fNFcn;
87 };
88
89 std::shared_ptr<Data> fPtr;
90};
91
92} // namespace Minuit2
93
94} // namespace ROOT
95
96#endif // ROOT_Minuit2_MinimumState
unsigned int size() const
Definition LAVector.h:231
MinimumError keeps the inv.
const MnAlgebraicVector & Vec() const
MinimumState keeps the information (position, Gradient, 2nd deriv, etc) after one minimization step (...
std::shared_ptr< Data > fPtr
MinimumState(const MinimumParameters &states, const MinimumError &err, const FunctionGradient &grad, double edm, int nfcn)
Constructor with parameters values, errors and gradient.
MinimumState(unsigned int n)
Invalid state.
MinimumState(const MinimumParameters &states, double edm, int nfcn)
Constructor with only parameter values, edm and nfcn, but without errors (covariance).
const MinimumError & Error() const
const MnAlgebraicVector & Vec() const
const MinimumParameters & Parameters() const
const FunctionGradient & Gradient() const
MinimumState(double fval, double edm, int nfcn)
Constructor without parameter values, but with function value, edm and nfcn.
const Int_t n
Definition legend1.C:16
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.