Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-16 09:08:16

0001 // @(#)root/minuit2:$Id$
0002 // Authors: M. Winkler, F. James, L. Moneta, A. Zsenei   2003-2005
0003 
0004 /**********************************************************************
0005  *                                                                    *
0006  * Copyright (c) 2005 LCG ROOT Math team,  CERN/PH-SFT                *
0007  *                                                                    *
0008  **********************************************************************/
0009 
0010 #ifndef ROOT_Minuit2_MnUserParameters
0011 #define ROOT_Minuit2_MnUserParameters
0012 
0013 #include "Minuit2/MnUserTransformation.h"
0014 
0015 #include <vector>
0016 #include <string>
0017 
0018 namespace ROOT {
0019 
0020 namespace Minuit2 {
0021 
0022 class MnMachinePrecision;
0023 
0024 /** API class for the user interaction with the parameters;
0025     serves as input to the minimizer as well as output from it;
0026     users can interact: Fix/release parameters, set values and errors, etc.;
0027     parameters can be accessed via their Parameter number (determined
0028     internally by Minuit and followed the order how the parameters are created)
0029     or via their user-specified Name (10 character string).
0030     Minuit has also an internal parameter number which is used during the minimization
0031     (the fix parameter are skipped). The parameter number used in this class is the external
0032     one. The class ROOT::Minuit2::MnUserTransformation is used to keep the
0033     internal <-> external transformation
0034  */
0035 
0036 class MnUserParameters {
0037 
0038 public:
0039    MnUserParameters() : fTransformation(MnUserTransformation()) {}
0040 
0041    MnUserParameters(std::span<const double>, std::span<const double>);
0042 
0043    MnUserParameters(const MnUserParameters &par) : fTransformation(par.fTransformation) {}
0044 
0045    MnUserParameters &operator=(const MnUserParameters &par)
0046    {
0047       fTransformation = par.fTransformation;
0048       return *this;
0049    }
0050 
0051    const MnUserTransformation &Trafo() const { return fTransformation; }
0052 
0053    unsigned int VariableParameters() const { return fTransformation.VariableParameters(); }
0054 
0055    /// access to parameters (row-wise)
0056    const std::vector<ROOT::Minuit2::MinuitParameter> &Parameters() const;
0057 
0058    /// access to parameters and errors in column-wise representation
0059    std::vector<double> Params() const;
0060    std::vector<double> Errors() const;
0061 
0062    /// access to single Parameter
0063    const MinuitParameter &Parameter(unsigned int) const;
0064 
0065    /// Add free Parameter Name, Value, Error
0066    bool Add(const std::string &, double, double);
0067    /// Add limited Parameter Name, Value, Lower bound, Upper bound
0068    bool Add(const std::string &, double, double, double, double);
0069    /// Add const Parameter Name, vale
0070    bool Add(const std::string &, double);
0071 
0072    /// interaction via external number of Parameter
0073    void Fix(unsigned int);
0074    void Release(unsigned int);
0075    void RemoveLimits(unsigned int);
0076    void SetValue(unsigned int, double);
0077    void SetError(unsigned int, double);
0078    void SetLimits(unsigned int, double, double);
0079    void SetUpperLimit(unsigned int, double);
0080    void SetLowerLimit(unsigned int, double);
0081    void SetName(unsigned int, const std::string &);
0082 
0083    double Value(unsigned int) const;
0084    double Error(unsigned int) const;
0085 
0086    /// interaction via Name of Parameter
0087    void Fix(const std::string &);
0088    void Release(const std::string &);
0089    void SetValue(const std::string &, double);
0090    void SetError(const std::string &, double);
0091    void SetLimits(const std::string &, double, double);
0092    void SetUpperLimit(const std::string &, double);
0093    void SetLowerLimit(const std::string &, double);
0094    void RemoveLimits(const std::string &);
0095 
0096    double Value(const std::string &) const;
0097    double Error(const std::string &) const;
0098 
0099    // convert Name into external number of Parameter
0100    unsigned int Index(const std::string &) const;
0101    // convert external number into Name of Parameter
0102    const std::string &GetName(unsigned int) const;
0103    // maintain interface with const char * for backward compatibility
0104    const char *Name(unsigned int) const;
0105 
0106    const MnMachinePrecision &Precision() const;
0107    void SetPrecision(double eps) { fTransformation.SetPrecision(eps); }
0108 
0109 private:
0110    MnUserTransformation fTransformation;
0111 };
0112 
0113 } // namespace Minuit2
0114 
0115 } // namespace ROOT
0116 
0117 #endif // ROOT_Minuit2_MnUserParameters