Logo ROOT  
Reference Guide
MinimumError.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_MinimumError
11 #define ROOT_Minuit2_MinimumError
12 
13 #include "Minuit2/MnConfig.h"
14 #include "Minuit2/MnMatrix.h"
15 #include "Minuit2/MnPrint.h"
16 #include "Minuit2/LaSum.h"
17 
18 #include <memory>
19 
20 namespace ROOT {
21 
22 namespace Minuit2 {
23 
24 /** MinimumError keeps the inv. 2nd derivative (inv. Hessian) used for
25  calculating the Parameter step size (-V*g) and for the covariance Update
26  (ErrorUpdator). The covariance matrix is equal to twice the inv. Hessian.
27  */
28 class MinimumError {
29 
30 public:
31  enum Status {
36  };
37 
38 public:
39  MinimumError(unsigned int n) : fPtr{new Data{{n}, 1.0, false, false, false, false, false, false}} {}
40 
41  MinimumError(const MnAlgebraicSymMatrix &mat, double dcov)
42  : fPtr{new Data{mat, dcov, true, true, false, false, false, true}}
43  {
44  }
45 
47  : fPtr{new Data{mat, 1.0, status == MnMadePosDef, false, status == MnMadePosDef, status == MnHesseFailed,
48  status == MnInvertFailed, true}}
49  {
50  }
51 
52  MnAlgebraicSymMatrix Matrix() const { return 2. * fPtr->fMatrix; }
53 
54  const MnAlgebraicSymMatrix &InvHessian() const { return fPtr->fMatrix; }
55 
57  {
58  // calculate Heassian: inverse of error matrix
59  MnAlgebraicSymMatrix tmp(fPtr->fMatrix);
60  if (Invert(tmp) != 0) {
61  MnPrint print("MinimumError::Hessian");
62  print.Warn("Inversion fails; return diagonal matrix");
63  for (unsigned int i = 0; i < fPtr->fMatrix.Nrow(); ++i)
64  for (unsigned int j = 0; j <= i; j++)
65  tmp(i, j) = i == j ? 1. / fPtr->fMatrix(i, i) : 0;
66  }
67  return tmp;
68  }
69 
70  double Dcovar() const { return fPtr->fDCovar; }
71  bool IsAccurate() const { return Dcovar() < 0.1; }
72  bool IsValid() const { return fPtr->fValid; }
73  bool IsPosDef() const { return fPtr->fPosDef; }
74  bool IsMadePosDef() const { return fPtr->fMadePosDef; }
75  bool HesseFailed() const { return fPtr->fHesseFailed; }
76  bool InvertFailed() const { return fPtr->fInvertFailed; }
77  bool IsAvailable() const { return fPtr->fAvailable; }
78 
79 private:
80  struct Data {
82  double fDCovar;
83  bool fValid;
84  bool fPosDef;
88  bool fAvailable;
89  };
90 
91  std::shared_ptr<Data> fPtr;
92 };
93 
94 } // namespace Minuit2
95 
96 } // namespace ROOT
97 
98 #endif // ROOT_Minuit2_MinimumError
n
const Int_t n
Definition: legend1.C:16
ROOT::Minuit2::MinimumError::Hessian
MnAlgebraicSymMatrix Hessian() const
Definition: MinimumError.h:56
ROOT::Minuit2::Invert
int Invert(LASymMatrix &)
Definition: LaInverse.cxx:21
ROOT::Minuit2::MinimumError::Matrix
MnAlgebraicSymMatrix Matrix() const
Definition: MinimumError.h:52
ROOT::Minuit2::MinimumError::Data::fMadePosDef
bool fMadePosDef
Definition: MinimumError.h:85
ROOT::Minuit2::LASymMatrix
Class describing a symmetric matrix of size n.
Definition: LASymMatrix.h:45
MnMatrix.h
ROOT::Minuit2::MinimumError::MinimumError
MinimumError(unsigned int n)
Definition: MinimumError.h:39
ROOT::Minuit2::MinimumError::MinimumError
MinimumError(const MnAlgebraicSymMatrix &mat, double dcov)
Definition: MinimumError.h:41
ROOT::Minuit2::MinimumError::IsValid
bool IsValid() const
Definition: MinimumError.h:72
ROOT::Minuit2::MinimumError::Data::fPosDef
bool fPosDef
Definition: MinimumError.h:84
ROOT::Minuit2::MinimumError::HesseFailed
bool HesseFailed() const
Definition: MinimumError.h:75
ROOT::Minuit2::MnPrint::Warn
void Warn(const Ts &... args)
Definition: MnPrint.h:126
ROOT::Minuit2::MinimumError::Status
Status
Definition: MinimumError.h:31
ROOT::Minuit2::MinimumError::Data::fDCovar
double fDCovar
Definition: MinimumError.h:82
ROOT::Minuit2::MinimumError::MnNotPosDef
@ MnNotPosDef
Definition: MinimumError.h:32
ROOT::Minuit2::MinimumError::Data::fAvailable
bool fAvailable
Definition: MinimumError.h:88
ROOT::Minuit2::MinimumError::Dcovar
double Dcovar() const
Definition: MinimumError.h:70
ROOT::Minuit2::MinimumError::InvertFailed
bool InvertFailed() const
Definition: MinimumError.h:76
ROOT::Minuit2::MinimumError::fPtr
std::shared_ptr< Data > fPtr
Definition: MinimumError.h:91
ROOT::Minuit2::MinimumError::MnHesseFailed
@ MnHesseFailed
Definition: MinimumError.h:34
ROOT::Minuit2::MinimumError::Data
Definition: MinimumError.h:80
ROOT::Minuit2::MinimumError::MnInvertFailed
@ MnInvertFailed
Definition: MinimumError.h:35
ROOT::Minuit2::MinimumError
MinimumError keeps the inv.
Definition: MinimumError.h:28
ROOT::Minuit2::MinimumError::Data::fValid
bool fValid
Definition: MinimumError.h:83
ROOT::Minuit2::MinimumError::MinimumError
MinimumError(const MnAlgebraicSymMatrix &mat, Status status)
Definition: MinimumError.h:46
ROOT::Minuit2::MinimumError::IsMadePosDef
bool IsMadePosDef() const
Definition: MinimumError.h:74
ROOT::Minuit2::MinimumError::Data::fInvertFailed
bool fInvertFailed
Definition: MinimumError.h:87
ROOT::Minuit2::MinimumError::Data::fHesseFailed
bool fHesseFailed
Definition: MinimumError.h:86
ROOT::Minuit2::MinimumError::InvHessian
const MnAlgebraicSymMatrix & InvHessian() const
Definition: MinimumError.h:54
LaSum.h
ROOT::Minuit2::MinimumError::MnMadePosDef
@ MnMadePosDef
Definition: MinimumError.h:33
MnPrint.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
ROOT::Minuit2::MinimumError::IsPosDef
bool IsPosDef() const
Definition: MinimumError.h:73
MnConfig.h
ROOT::Minuit2::MnPrint
Definition: MnPrint.h:73
ROOT::Minuit2::MinimumError::Data::fMatrix
MnAlgebraicSymMatrix fMatrix
Definition: MinimumError.h:81
ROOT::Minuit2::MinimumError::IsAccurate
bool IsAccurate() const
Definition: MinimumError.h:71