ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
MnUserTransformation.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_MnUserTransformation
11 #define ROOT_Minuit2_MnUserTransformation
12 
13 #ifndef ROOT_Minuit2_MnConfig
14 #include "Minuit2/MnConfig.h"
15 #endif
16 #ifndef ROOT_Minuit2_MnMatrix
17 #include "Minuit2/MnMatrix.h"
18 #endif
19 #ifndef ROOT_Minuit2_MinuitParameter
21 #endif
22 #ifndef ROOT_Minuit2_MnMachinePrecision
24 #endif
25 #ifndef ROOT_Minuit2_SinParameterTransformation
27 #endif
28 #ifndef ROOT_Minuit2_SqrtLowParameterTransformation
30 #endif
31 #ifndef ROOT_Minuit2_SqrtUpParameterTransformation
33 #endif
34 
35 #include <vector>
36 #include <cassert>
37 
38 namespace ROOT {
39 
40  namespace Minuit2 {
41 
42 
43 class MnUserCovariance;
44 
45 // class MnMachinePrecision;
46 
47 /**
48  class dealing with the transformation between user specified parameters (external) and
49  internal parameters used for minimization
50  */
51 
53 
54 public:
55 
57  fParameters(std::vector<MinuitParameter>()),
58  fExtOfInt(std::vector<unsigned int>()),
62  fCache(std::vector<double>()) {}
63 
64  MnUserTransformation(const std::vector<double>&, const std::vector<double>&);
65 
67 
69  fPrecision(trafo.fPrecision),
73  fLowerLimTrafo(trafo.fLowerLimTrafo), fCache(trafo.fCache) {}
74 
76  if(this != &trafo) {
77  fPrecision = trafo.fPrecision;
78  fParameters = trafo.fParameters;
79  fExtOfInt = trafo.fExtOfInt;
83  fCache = trafo.fCache;
84  }
85  return *this;
86  }
87 
88 
89 //#ifdef MINUIT2_THREAD_SAFE
90  // thread-safe version (do not use cache)
91  std::vector<double> operator()(const MnAlgebraicVector&) const;
92 //#else // not thread safe
93 // const std::vector<double>& operator()(const MnAlgebraicVector&) const;
94 //#endif
95 
96  // Index = internal Parameter
97  double Int2ext(unsigned int, double) const;
98 
99  // Index = internal Parameter
100  double Int2extError(unsigned int, double, double) const;
101 
103 
104  // Index = external Parameter
105  double Ext2int(unsigned int, double) const;
106 
107  // Index = internal Parameter
108  double DInt2Ext(unsigned int, double) const;
109 
110 // // Index = external Parameter
111 // double dExt2Int(unsigned int, double) const;
112 
113  // Index = external Parameter
114  unsigned int IntOfExt(unsigned int) const;
115 
116  // Index = internal Parameter
117  unsigned int ExtOfInt(unsigned int internal) const {
118  assert(internal < fExtOfInt.size());
119  return fExtOfInt[internal];
120  }
121 
122  const std::vector<MinuitParameter>& Parameters() const {
123  return fParameters;
124  }
125 
126  unsigned int VariableParameters() const {return static_cast<unsigned int> ( fExtOfInt.size() );}
127 
128  // return initial parameter values (useful especially to get fixed parameter values)
129  const std::vector<double> & InitialParValues() const {
130  return fCache;
131  }
132 
133 
134  /** forwarded interface */
135 
136  const MnMachinePrecision& Precision() const {return fPrecision;}
137  void SetPrecision(double eps) {fPrecision.SetPrecision(eps);}
138 
139  /// access to parameters and errors in column-wise representation
140 
141  std::vector<double> Params() const;
142  std::vector<double> Errors() const;
143 
144  //access to single Parameter
145  const MinuitParameter& Parameter(unsigned int) const;
146 
147  //add free Parameter
148  bool Add(const std::string &, double, double);
149  //add limited Parameter
150  bool Add(const std::string &, double, double, double, double);
151  //add const Parameter
152  bool Add(const std::string &, double);
153 
154  //interaction via external number of Parameter
155  void Fix(unsigned int);
156  void Release(unsigned int);
157  void RemoveLimits(unsigned int);
158  void SetValue(unsigned int, double);
159  void SetError(unsigned int, double);
160  void SetLimits(unsigned int, double, double);
161  void SetUpperLimit(unsigned int, double);
162  void SetLowerLimit(unsigned int, double);
163  void SetName(unsigned int, const std::string &);
164 
165  double Value(unsigned int) const;
166  double Error(unsigned int) const;
167 
168  //interaction via Name of Parameter
169  void Fix(const std::string &);
170  void Release(const std::string &);
171  void SetValue(const std::string &, double);
172  void SetError(const std::string &, double);
173  void SetLimits(const std::string &, double, double);
174  void SetUpperLimit(const std::string &, double);
175  void SetLowerLimit(const std::string &, double);
176  void RemoveLimits(const std::string &);
177 
178  double Value(const std::string &) const;
179  double Error(const std::string &) const;
180 
181  //convert Name into external number of Parameter (will assert if parameter is not found)
182  unsigned int Index(const std::string &) const;
183  // find parameter index given a name. If it is not found return a -1
184  int FindIndex(const std::string & ) const;
185 
186  //convert external number into Name of Parameter (will assert if index is out of range)
187  const std::string & GetName(unsigned int) const;
188  // mantain interface with const char * for backward compatibility
189  const char* Name(unsigned int) const;
190 
191 private:
192 
194 
195  std::vector<MinuitParameter> fParameters;
196  std::vector<unsigned int> fExtOfInt;
197 
201 
202  mutable std::vector<double> fCache;
203 
204 
205 };
206 
207  } // namespace Minuit2
208 
209 } // namespace ROOT
210 
211 #endif // ROOT_Minuit2_MnUserTransformation
double Ext2int(unsigned int, double) const
std::vector< MinuitParameter > fParameters
const char * Name(unsigned int) const
void SetLowerLimit(unsigned int, double)
double Int2extError(unsigned int, double, double) const
#define assert(cond)
Definition: unittest.h:542
Class describing a symmetric matrix of size n.
Definition: LASymMatrix.h:51
std::vector< double > Errors() const
class for the individual Minuit Parameter with Name and number; contains the input numbers for the mi...
determines the relative floating point arithmetic precision.
const std::vector< MinuitParameter > & Parameters() const
MnUserTransformation(const MnUserTransformation &trafo)
double Int2ext(unsigned int, double) const
void SetUpperLimit(unsigned int, double)
int FindIndex(const std::string &) const
SqrtLowParameterTransformation fLowerLimTrafo
void SetName(unsigned int, const std::string &)
std::vector< unsigned int > fExtOfInt
const MinuitParameter & Parameter(unsigned int) const
unsigned int Index(const std::string &) const
MnUserTransformation & operator=(const MnUserTransformation &trafo)
double DInt2Ext(unsigned int, double) const
class for the transformation for double-limited parameter Using a sin function one goes from a double...
unsigned int IntOfExt(unsigned int) const
unsigned int ExtOfInt(unsigned int internal) const
class dealing with the transformation between user specified parameters (external) and internal param...
Transformation from external to internal Parameter based on sqrt(1 + x**2)
MnUserCovariance Int2extCovariance(const MnAlgebraicVector &, const MnAlgebraicSymMatrix &) const
SinParameterTransformation fDoubleLimTrafo
std::vector< double > operator()(const MnAlgebraicVector &) const
SqrtUpParameterTransformation fUpperLimTrafo
std::vector< double > Params() const
access to parameters and errors in column-wise representation
const std::string & GetName(unsigned int) const
void SetLimits(unsigned int, double, double)
bool Add(const std::string &, double, double)
Transformation from external to internal Parameter based on sqrt(1 + x**2)
const MnMachinePrecision & Precision() const
forwarded interface
const std::vector< double > & InitialParValues() const
void SetPrecision(double prec)
override Minuit's own determination
Class containing the covariance matrix data represented as a vector of size n*(n+1)/2 Used to hide in...