ROOT   Reference Guide
BasicFunctionMinimum.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_BasicFunctionMinimum
11#define ROOT_Minuit2_BasicFunctionMinimum
12
13#include "Minuit2/MinimumSeed.h"
17
19
20#include <vector>
21
22namespace ROOT {
23
24 namespace Minuit2 {
25
26
27//extern StackAllocator gStackAllocator;
28
29/** result of the minimization;
30 both internal and external (MnUserParameterState) representation available
31 For the parameters at the Minimum
32 */
33
35
36public:
37
39 class MnAboveMaxEdm {};
40
41public:
42
43 /// constructor from only MinimumSeed. Minimum is only from seed result not the full minimization
44 BasicFunctionMinimum(const MinimumSeed& seed, double up) : fSeed(seed), fStates(std::vector<MinimumState>(1, MinimumState(seed.Parameters(), seed.Error(), seed.Gradient(), seed.Parameters().Fval(), seed.NFcn()))), fErrorDef(up), fAboveMaxEdm(false), fReachedCallLimit(false), fUserState(MnUserParameterState()) {}
45
46 /// constructor at the end of a successfull minimization from seed and vector of states
47 BasicFunctionMinimum(const MinimumSeed& seed, const std::vector<MinimumState>& states, double up) : fSeed(seed), fStates(states), fErrorDef(up), fAboveMaxEdm(false), fReachedCallLimit(false), fUserState(MnUserParameterState()) {}
48
49 /// constructor at the end of a failed minimization due to exceeding function call limit
50 BasicFunctionMinimum(const MinimumSeed& seed, const std::vector<MinimumState>& states, double up, MnReachedCallLimit) : fSeed(seed), fStates(states), fErrorDef(up), fAboveMaxEdm(false), fReachedCallLimit(true), fUserState(MnUserParameterState()) {}
51
52 /// constructor at the end of a failed minimization due to edm above maximum value
53 BasicFunctionMinimum(const MinimumSeed& seed, const std::vector<MinimumState>& states, double up, MnAboveMaxEdm) : fSeed(seed), fStates(states), fErrorDef(up), fAboveMaxEdm(true), fReachedCallLimit(false), fUserState(MnUserParameterState()) {}
54
55 /// copy constructor
57
59 fSeed = min.fSeed;
60 fStates = min.fStates;
61 fErrorDef = min.fErrorDef;
65 return *this;
66 }
67
69
71 void Add(const MinimumState& state ) {
72 fStates.push_back(state);
73 // LM : update also the user state
74 fUserState = MnUserParameterState(State(), Up(), Seed().Trafo());
75 // reset maxedm flag. If new state has edm over max other method must be used
76 fAboveMaxEdm = false;
77 }
78
79 ///Add a new state and flag that edm is above maximum
80 void Add(const MinimumState& state, MnAboveMaxEdm) {
82 fAboveMaxEdm = true;
83 }
84
85 const MinimumSeed& Seed() const {return fSeed;}
86 const std::vector<MinimumState>& States() const {return fStates;}
87
88// user representation of state at Minimum
90 if(!fUserState.IsValid())
91 fUserState = MnUserParameterState(State(), Up(), Seed().Trafo());
92 return fUserState;
93 }
95 if(!fUserState.IsValid())
96 fUserState = MnUserParameterState(State(), Up(), Seed().Trafo());
97 return fUserState.Parameters();
98 }
100 if(!fUserState.IsValid())
101 fUserState = MnUserParameterState(State(), Up(), Seed().Trafo());
102 return fUserState.Covariance();
103 }
104
105 void* operator new(size_t nbytes) {
106 return StackAllocatorHolder::Get().Allocate(nbytes);
107 }
108
109 void operator delete(void* p, size_t /*nbytes */) {
111 }
112
113 // forward interface of last state
114 const MinimumState& State() const {return fStates.back();}
115 const MinimumParameters& Parameters() const {return fStates.back().Parameters();}
116 const MinimumError& Error() const {return fStates.back().Error();}
118 double Fval() const {return fStates.back().Fval();}
119 double Edm() const {return fStates.back().Edm();}
120 int NFcn() const {return fStates.back().NFcn();}
121
122 double Up() const {return fErrorDef;}
123 bool IsValid() const {
124 return State().IsValid() && !IsAboveMaxEdm() && !HasReachedCallLimit();
125 }
126 bool HasValidParameters() const {return State().Parameters().IsValid();}
127 bool HasValidCovariance() const {return State().Error().IsValid();}
128 bool HasAccurateCovar() const {return State().Error().IsAccurate();}
129 bool HasPosDefCovar() const {return State().Error().IsPosDef();}
131 bool HesseFailed() const {return State().Error().HesseFailed();}
132 bool HasCovariance() const {return State().Error().IsAvailable();}
133 bool IsAboveMaxEdm() const {return fAboveMaxEdm;}
135
136 void SetErrorDef( double up) {
137 fErrorDef = up;
138 // update user state for new valeu of up (scaling of errors)
139 fUserState = MnUserParameterState(State(), up, Seed().Trafo());
140 }
141
142private:
143
145 std::vector<MinimumState> fStates;
146 double fErrorDef;
150};
151
152 } // namespace Minuit2
153
154} // namespace ROOT
155
156#endif // ROOT_Minuit2_BasicFunctionMinimum
result of the minimization; both internal and external (MnUserParameterState) representation availabl...
const MnUserParameterState & UserState() const
const MinimumParameters & Parameters() const
BasicFunctionMinimum(const MinimumSeed &seed, const std::vector< MinimumState > &states, double up, MnReachedCallLimit)
constructor at the end of a failed minimization due to exceeding function call limit
std::vector< MinimumState > fStates
const MinimumState & State() const
const MinimumError & Error() const
BasicFunctionMinimum & operator=(const BasicFunctionMinimum &min)
const std::vector< MinimumState > & States() const
BasicFunctionMinimum(const MinimumSeed &seed, double up)
constructor from only MinimumSeed. Minimum is only from seed result not the full minimization
BasicFunctionMinimum(const MinimumSeed &seed, const std::vector< MinimumState > &states, double up)
constructor at the end of a successfull minimization from seed and vector of states
const MnUserCovariance & UserCovariance() const
const MnUserParameters & UserParameters() const
BasicFunctionMinimum(const BasicFunctionMinimum &min)
copy constructor
BasicFunctionMinimum(const MinimumSeed &seed, const std::vector< MinimumState > &states, double up, MnAboveMaxEdm)
constructor at the end of a failed minimization due to edm above maximum value
Add a new state and flag that edm is above maximum.
const MinimumSeed & Seed() const
MinimumError keeps the inv.
Definition: MinimumError.h:26
MinimumSeed contains the starting values for the minimization produced by the SeedGenerator.
Definition: MinimumSeed.h:31
MinimumState keeps the information (position, Gradient, 2nd deriv, etc) after one minimization step (...
Definition: MinimumState.h:29
const MinimumError & Error() const
Definition: MinimumState.h:62
const MinimumParameters & Parameters() const
Definition: MinimumState.h:58
Class containing the covariance matrix data represented as a vector of size n*(n+1)/2 Used to hide in...
class which holds the external user and/or internal Minuit representation of the parameters and error...
const MnUserParameters & Parameters() const
const MnUserCovariance & Covariance() const
API class for the user interaction with the parameters; serves as input to the minimizer as well as o...
static StackAllocator & Get()
void * Allocate(size_t nBytes)
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
Definition: StringConv.hxx:21