Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
20namespace ROOT {
21
22namespace 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 */
29
30public:
31 enum Status {
36 };
37
38public:
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
79private:
80 struct Data {
82 double fDCovar;
83 bool fValid;
84 bool fPosDef;
89 };
90
91 std::shared_ptr<Data> fPtr;
92};
93
94} // namespace Minuit2
95
96} // namespace ROOT
97
98#endif // ROOT_Minuit2_MinimumError
Class describing a symmetric matrix of size n.
Definition LASymMatrix.h:45
MinimumError keeps the inv.
MinimumError(const MnAlgebraicSymMatrix &mat, Status status)
MinimumError(unsigned int n)
const MnAlgebraicSymMatrix & InvHessian() const
MnAlgebraicSymMatrix Matrix() const
MnAlgebraicSymMatrix Hessian() const
std::shared_ptr< Data > fPtr
MinimumError(const MnAlgebraicSymMatrix &mat, double dcov)
void Warn(const Ts &... args)
Definition MnPrint.h:126
const Int_t n
Definition legend1.C:16
int Invert(LASymMatrix &)
Definition LaInverse.cxx:21
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...