00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef ROOT_Math_MinimizerVariable
00013 #define ROOT_Math_MinimizerVariable
00014
00015 #ifndef ROOT_Math_MinimizerVariableTransformation
00016 #include "MinimizerVariableTransformation.h"
00017 #endif
00018
00019 #include <memory>
00020
00021 namespace ROOT {
00022
00023 namespace Math {
00024
00025
00026
00027
00028
00029
00030 enum EMinimVariableType {
00031 kDefault,
00032 kFix,
00033 kBounds,
00034 kLowBound,
00035 kUpBound
00036 };
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047 class MinimizerVariable {
00048
00049 public:
00050
00051
00052
00053
00054 MinimizerVariable () :
00055 fFix(false), fLowBound(false), fUpBound(false), fBounds(false),
00056 fTransform(0), fLower(1), fUpper(0)
00057 {}
00058
00059
00060 MinimizerVariable (double value) :
00061 fFix(true), fLowBound(false), fUpBound(false), fBounds(false),
00062 fTransform(0), fLower(value), fUpper(value)
00063 {}
00064
00065
00066 MinimizerVariable (double lower, double upper, SinVariableTransformation * trafo) :
00067 fFix(false), fLowBound(false), fUpBound(false), fBounds(true),
00068 fTransform(trafo),
00069 fLower(lower), fUpper(upper)
00070 { }
00071
00072
00073 MinimizerVariable (double lower, SqrtLowVariableTransformation * trafo) :
00074 fFix(false), fLowBound(true), fUpBound(false), fBounds(false),
00075 fTransform(trafo), fLower(lower), fUpper(lower)
00076 {}
00077
00078
00079 MinimizerVariable (double upper, SqrtUpVariableTransformation * trafo) :
00080 fFix(false), fLowBound(true), fUpBound(false), fBounds(false),
00081 fTransform(trafo), fLower(upper), fUpper(upper)
00082 {}
00083
00084
00085 MinimizerVariable (const MinimizerVariable & rhs) :
00086 fFix(rhs.fFix), fLowBound(rhs.fLowBound), fUpBound(rhs.fUpBound), fBounds(rhs.fBounds),
00087 fLower(rhs.fLower), fUpper(rhs.fUpper)
00088 {
00089
00090 fTransform.reset( const_cast<MinimizerVariable &>( rhs).fTransform.release() ) ;
00091 }
00092
00093
00094 MinimizerVariable & operator= (const MinimizerVariable & rhs) {
00095 if (&rhs == this) return *this;
00096 fFix = rhs.fFix;
00097 fLowBound = rhs.fLowBound;
00098 fUpBound = rhs.fUpBound;
00099 fBounds = rhs.fBounds;
00100 fLower = rhs.fLower; fUpper = rhs.fUpper;
00101
00102
00103 fTransform.reset( const_cast<MinimizerVariable &>( rhs).fTransform.release() ) ;
00104 return *this;
00105 }
00106
00107
00108 bool IsFixed() const { return fFix; }
00109
00110 bool IsLimited() const { return fBounds || fLowBound || fUpBound; }
00111
00112 bool HasLowerBound() const { return fLowBound || fBounds; }
00113
00114 bool HasUpperBound() const { return fUpBound || fBounds; }
00115
00116 double LowerBound() const { return fLower; }
00117
00118 double UpperBound() const { return fUpper; }
00119
00120 double FixValue() const { return fLower; }
00121
00122
00123 double InternalToExternal( double x) const {
00124 return fTransform->Int2ext(x, fLower, fUpper);
00125 }
00126
00127
00128 double DerivativeIntToExt ( double x) const {
00129 return fTransform->DInt2Ext( x, fLower, fUpper);
00130 }
00131
00132
00133 double ExternalToInternal(double x) const {
00134 return fTransform->Ext2int(x, fLower, fUpper);
00135 }
00136
00137 private:
00138
00139 bool fFix;
00140 bool fLowBound;
00141 bool fUpBound;
00142 bool fBounds;
00143 std::auto_ptr< MinimizerVariableTransformation> fTransform;
00144 double fLower;
00145 double fUpper;
00146
00147 };
00148
00149 }
00150
00151 }
00152
00153
00154 #endif
00155
00156