// @(#)root/minuit2:$Id$
// Authors: M. Winkler, F. James, L. Moneta, A. Zsenei   2003-2005

/**********************************************************************
 *                                                                    *
 * Copyright (c) 2005 LCG ROOT Math team,  CERN/PH-SFT                *
 *                                                                    *
 **********************************************************************/

#ifndef ROOT_Minuit2_MnUserParameters
#define ROOT_Minuit2_MnUserParameters

#include "Minuit2/MnUserTransformation.h"


#include <vector>

namespace ROOT {

   namespace Minuit2 {


class MnMachinePrecision;

/** API class for the user interaction with the parameters;
    serves as input to the minimizer as well as output from it;
    users can interact: Fix/release parameters, set values and errors, etc.;
    parameters can be accessed via their Parameter number (determined
    internally by Minuit and followed the order how the parameters are created)
    or via their user-specified Name (10 character string).
    Minuit has also an internal parameter number which is used during the minimization
    (the fix parameter are skipped). The parameter number used in this class is the external
    one. The class ROOT::Minuit2::MnUserTransformation is used to keep the
    internal <-> external transformation
 */

class MnUserParameters {

public:

   MnUserParameters() : fTransformation(MnUserTransformation()) {}

   MnUserParameters(const std::vector<double>&, const std::vector<double>&);

   ~MnUserParameters() {}

   MnUserParameters(const MnUserParameters& par) :
      fTransformation(par.fTransformation) {}

   MnUserParameters& operator=(const MnUserParameters& par) {
      fTransformation = par.fTransformation;
      return *this;
   }

   const MnUserTransformation& Trafo() const {return fTransformation;}

   unsigned int VariableParameters() const {
      return fTransformation.VariableParameters();
   }

   /// access to parameters (row-wise)
   const std::vector<ROOT::Minuit2::MinuitParameter>& Parameters() const;

   /// access to parameters and errors in column-wise representation
   std::vector<double> Params() const;
   std::vector<double> Errors() const;

   /// access to single Parameter
   const MinuitParameter& Parameter(unsigned int) const;

   /// Add free Parameter Name, Value, Error
   bool Add(const std::string &, double, double);
   /// Add limited Parameter Name, Value, Lower bound, Upper bound
   bool Add(const std::string &, double, double, double, double);
   /// Add const Parameter Name, vale
   bool Add(const std::string &, double);

   /// interaction via external number of Parameter
   void Fix(unsigned int);
   void Release(unsigned int);
   void RemoveLimits(unsigned int);
   void SetValue(unsigned int, double);
   void SetError(unsigned int, double);
   void SetLimits(unsigned int, double, double);
   void SetUpperLimit(unsigned int, double);
   void SetLowerLimit(unsigned int, double);
   void SetName(unsigned int, const std::string &);

   double Value(unsigned int) const;
   double Error(unsigned int) const;

   /// interaction via Name of Parameter
   void Fix(const std::string &);
   void Release(const std::string &);
   void SetValue(const std::string &, double);
   void SetError(const std::string &, double);
   void SetLimits(const std::string &, double, double);
   void SetUpperLimit(const std::string &, double);
   void SetLowerLimit(const std::string &, double);
   void RemoveLimits(const std::string &);

   double Value(const std::string &) const;
   double Error(const std::string &) const;

   //convert Name into external number of Parameter
   unsigned int Index(const std::string &) const;
   //convert external number into Name of Parameter
   const std::string & GetName(unsigned int) const;
   // mantain interface with const char * for backward compatibility
   const char* Name(unsigned int) const;

   const MnMachinePrecision& Precision() const;
   void SetPrecision(double eps) {fTransformation.SetPrecision(eps);}

private:

   MnUserTransformation fTransformation;
};

  }  // namespace Minuit2

}  // namespace ROOT

#endif  // ROOT_Minuit2_MnUserParameters
 MnUserParameters.h:1
 MnUserParameters.h:2
 MnUserParameters.h:3
 MnUserParameters.h:4
 MnUserParameters.h:5
 MnUserParameters.h:6
 MnUserParameters.h:7
 MnUserParameters.h:8
 MnUserParameters.h:9
 MnUserParameters.h:10
 MnUserParameters.h:11
 MnUserParameters.h:12
 MnUserParameters.h:13
 MnUserParameters.h:14
 MnUserParameters.h:15
 MnUserParameters.h:16
 MnUserParameters.h:17
 MnUserParameters.h:18
 MnUserParameters.h:19
 MnUserParameters.h:20
 MnUserParameters.h:21
 MnUserParameters.h:22
 MnUserParameters.h:23
 MnUserParameters.h:24
 MnUserParameters.h:25
 MnUserParameters.h:26
 MnUserParameters.h:27
 MnUserParameters.h:28
 MnUserParameters.h:29
 MnUserParameters.h:30
 MnUserParameters.h:31
 MnUserParameters.h:32
 MnUserParameters.h:33
 MnUserParameters.h:34
 MnUserParameters.h:35
 MnUserParameters.h:36
 MnUserParameters.h:37
 MnUserParameters.h:38
 MnUserParameters.h:39
 MnUserParameters.h:40
 MnUserParameters.h:41
 MnUserParameters.h:42
 MnUserParameters.h:43
 MnUserParameters.h:44
 MnUserParameters.h:45
 MnUserParameters.h:46
 MnUserParameters.h:47
 MnUserParameters.h:48
 MnUserParameters.h:49
 MnUserParameters.h:50
 MnUserParameters.h:51
 MnUserParameters.h:52
 MnUserParameters.h:53
 MnUserParameters.h:54
 MnUserParameters.h:55
 MnUserParameters.h:56
 MnUserParameters.h:57
 MnUserParameters.h:58
 MnUserParameters.h:59
 MnUserParameters.h:60
 MnUserParameters.h:61
 MnUserParameters.h:62
 MnUserParameters.h:63
 MnUserParameters.h:64
 MnUserParameters.h:65
 MnUserParameters.h:66
 MnUserParameters.h:67
 MnUserParameters.h:68
 MnUserParameters.h:69
 MnUserParameters.h:70
 MnUserParameters.h:71
 MnUserParameters.h:72
 MnUserParameters.h:73
 MnUserParameters.h:74
 MnUserParameters.h:75
 MnUserParameters.h:76
 MnUserParameters.h:77
 MnUserParameters.h:78
 MnUserParameters.h:79
 MnUserParameters.h:80
 MnUserParameters.h:81
 MnUserParameters.h:82
 MnUserParameters.h:83
 MnUserParameters.h:84
 MnUserParameters.h:85
 MnUserParameters.h:86
 MnUserParameters.h:87
 MnUserParameters.h:88
 MnUserParameters.h:89
 MnUserParameters.h:90
 MnUserParameters.h:91
 MnUserParameters.h:92
 MnUserParameters.h:93
 MnUserParameters.h:94
 MnUserParameters.h:95
 MnUserParameters.h:96
 MnUserParameters.h:97
 MnUserParameters.h:98
 MnUserParameters.h:99
 MnUserParameters.h:100
 MnUserParameters.h:101
 MnUserParameters.h:102
 MnUserParameters.h:103
 MnUserParameters.h:104
 MnUserParameters.h:105
 MnUserParameters.h:106
 MnUserParameters.h:107
 MnUserParameters.h:108
 MnUserParameters.h:109
 MnUserParameters.h:110
 MnUserParameters.h:111
 MnUserParameters.h:112
 MnUserParameters.h:113
 MnUserParameters.h:114
 MnUserParameters.h:115
 MnUserParameters.h:116
 MnUserParameters.h:117
 MnUserParameters.h:118
 MnUserParameters.h:119
 MnUserParameters.h:120
 MnUserParameters.h:121
 MnUserParameters.h:122
 MnUserParameters.h:123
 MnUserParameters.h:124