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_MnUserParameters 11 #define ROOT_Minuit2_MnUserParameters 12 13 #include "Minuit2/MnUserTransformation.h" 14 15 #include <vector> 16 #include <string> 17 18 namespace ROOT { 19 20 namespace Minuit2 { 21 22 class MnMachinePrecision; 23 24 /** API class for the user interaction with the parameters; 25 serves as input to the minimizer as well as output from it; 26 users can interact: Fix/release parameters, set values and errors, etc.; 27 parameters can be accessed via their Parameter number (determined 28 internally by Minuit and followed the order how the parameters are created) 29 or via their user-specified Name (10 character string). 30 Minuit has also an internal parameter number which is used during the minimization 31 (the fix parameter are skipped). The parameter number used in this class is the external 32 one. The class ROOT::Minuit2::MnUserTransformation is used to keep the 33 internal <-> external transformation 34 */ 35 36 class MnUserParameters { 37 38 public: MnUserParameters()39 MnUserParameters() : fTransformation(MnUserTransformation()) {} 40 41 MnUserParameters(const std::vector<double> &, const std::vector<double> &); 42 ~MnUserParameters()43 ~MnUserParameters() {} 44 MnUserParameters(const MnUserParameters & par)45 MnUserParameters(const MnUserParameters &par) : fTransformation(par.fTransformation) {} 46 47 MnUserParameters &operator=(const MnUserParameters &par) 48 { 49 fTransformation = par.fTransformation; 50 return *this; 51 } 52 Trafo()53 const MnUserTransformation &Trafo() const { return fTransformation; } 54 VariableParameters()55 unsigned int VariableParameters() const { return fTransformation.VariableParameters(); } 56 57 /// access to parameters (row-wise) 58 const std::vector<ROOT::Minuit2::MinuitParameter> &Parameters() const; 59 60 /// access to parameters and errors in column-wise representation 61 std::vector<double> Params() const; 62 std::vector<double> Errors() const; 63 64 /// access to single Parameter 65 const MinuitParameter &Parameter(unsigned int) const; 66 67 /// Add free Parameter Name, Value, Error 68 bool Add(const std::string &, double, double); 69 /// Add limited Parameter Name, Value, Lower bound, Upper bound 70 bool Add(const std::string &, double, double, double, double); 71 /// Add const Parameter Name, vale 72 bool Add(const std::string &, double); 73 74 /// interaction via external number of Parameter 75 void Fix(unsigned int); 76 void Release(unsigned int); 77 void RemoveLimits(unsigned int); 78 void SetValue(unsigned int, double); 79 void SetError(unsigned int, double); 80 void SetLimits(unsigned int, double, double); 81 void SetUpperLimit(unsigned int, double); 82 void SetLowerLimit(unsigned int, double); 83 void SetName(unsigned int, const std::string &); 84 85 double Value(unsigned int) const; 86 double Error(unsigned int) const; 87 88 /// interaction via Name of Parameter 89 void Fix(const std::string &); 90 void Release(const std::string &); 91 void SetValue(const std::string &, double); 92 void SetError(const std::string &, double); 93 void SetLimits(const std::string &, double, double); 94 void SetUpperLimit(const std::string &, double); 95 void SetLowerLimit(const std::string &, double); 96 void RemoveLimits(const std::string &); 97 98 double Value(const std::string &) const; 99 double Error(const std::string &) const; 100 101 // convert Name into external number of Parameter 102 unsigned int Index(const std::string &) const; 103 // convert external number into Name of Parameter 104 const std::string &GetName(unsigned int) const; 105 // mantain interface with const char * for backward compatibility 106 const char *Name(unsigned int) const; 107 108 const MnMachinePrecision &Precision() const; SetPrecision(double eps)109 void SetPrecision(double eps) { fTransformation.SetPrecision(eps); } 110 111 private: 112 MnUserTransformation fTransformation; 113 }; 114 115 } // namespace Minuit2 116 117 } // namespace ROOT 118 119 #endif // ROOT_Minuit2_MnUserParameters 120