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
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 /// 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 {
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
81private:
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
unsigned int size() const
Definition: LAVector.h:225
MinimumError keeps the inv.
Definition: MinimumError.h:28
const MnAlgebraicVector & Vec() const
MinimumState keeps the information (position, Gradient, 2nd deriv, etc) after one minimization step (...
Definition: MinimumState.h:27
std::shared_ptr< Data > fPtr
Definition: MinimumState.h:90
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
MinimumState(unsigned int n)
Invalid state.
Definition: MinimumState.h:31
MinimumState(const MinimumParameters &states, double edm, int nfcn)
Constuctor with only parameter values, edm and nfcn, but without errors (covariance).
Definition: MinimumState.h:46
const MinimumError & Error() const
Definition: MinimumState.h:62
const MnAlgebraicVector & Vec() const
Definition: MinimumState.h:59
const MinimumParameters & Parameters() const
Definition: MinimumState.h:58
const FunctionGradient & Gradient() const
Definition: MinimumState.h:63
MinimumState(double fval, double edm, int nfcn)
Constructor without parameter values, but with function value, edm and nfcn.
Definition: MinimumState.h:37
const Int_t n
Definition: legend1.C:16
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.