Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/TLinearMinimizer.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // @(#)root/minuit:$Id$
0002 // Author: L. Moneta Wed Oct 25 16:28:55 2006
0003 
0004 /**********************************************************************
0005  *                                                                    *
0006  * Copyright (c) 2006  LCG ROOT Math Team, CERN/PH-SFT                *
0007  *                                                                    *
0008  *                                                                    *
0009  **********************************************************************/
0010 
0011 // Header file for class TLinearMinimizer
0012 
0013 #ifndef ROOT_TLinearMinimizer
0014 #define ROOT_TLinearMinimizer
0015 
0016 #include "Math/Minimizer.h"
0017 
0018 #include "Rtypes.h"
0019 
0020 #include <vector>
0021 #include <string>
0022 
0023 class TLinearFitter;
0024 
0025 
0026 
0027 
0028 /**
0029    TLinearMinimizer class: minimizer implementation based on TMinuit.
0030 */
0031 class TLinearMinimizer  : public ROOT::Math::Minimizer {
0032 
0033 public:
0034 
0035    /**
0036       Default constructor
0037    */
0038    TLinearMinimizer (int type = 0);
0039 
0040    /**
0041       Constructor from a char * (used by PM)
0042    */
0043    TLinearMinimizer ( const char * type );
0044 
0045    /**
0046       Destructor (no operations)
0047    */
0048    ~TLinearMinimizer () override;
0049 
0050 private:
0051    // usually copying is non trivial, so we make this unaccessible
0052 
0053    /**
0054       Copy constructor
0055    */
0056    TLinearMinimizer(const TLinearMinimizer &);
0057 
0058    /**
0059       Assignment operator
0060    */
0061    TLinearMinimizer & operator = (const TLinearMinimizer & rhs);
0062 
0063 public:
0064 
0065    /// set the fit model function
0066    void SetFunction(const ROOT::Math::IMultiGenFunction & func) override;
0067 
0068    /// set free variable (dummy impl. since there is no need to set variables in the Linear Fitter)
0069    bool SetVariable(unsigned int , const std::string & , double , double ) override { return true; }
0070 
0071    /// set fixed variable (override if minimizer supports them )
0072    bool SetFixedVariable(unsigned int /* ivar */, const std::string & /* name */, double /* val */) override;
0073 
0074    /// method to perform the minimization
0075     bool Minimize() override;
0076 
0077    /// return minimum function value
0078    double MinValue() const override { return fMinVal; }
0079 
0080    /// return expected distance reached from the minimum
0081    double Edm() const override { return 0; }
0082 
0083    /// return  pointer to X values at the minimum
0084    const double *  X() const override { return &fParams.front(); }
0085 
0086    /// return pointer to gradient values at the minimum
0087    const double *  MinGradient() const override { return nullptr; } // not available in Minuit2
0088 
0089    /// number of function calls to reach the minimum
0090    unsigned int NCalls() const override { return 0; }
0091 
0092    /// this is <= Function().NDim() which is the total
0093    /// number of variables (free+ constrained ones)
0094    unsigned int NDim() const override { return fDim; }
0095 
0096    /// number of free variables (real dimension of the problem)
0097    /// this is <= Function().NDim() which is the total
0098    unsigned int NFree() const override { return fNFree; }
0099 
0100    /// minimizer provides error and error matrix
0101    bool ProvidesError() const override { return true; }
0102 
0103    /// return errors at the minimum
0104    const double * Errors() const override { return  fErrors.empty() ? nullptr : &fErrors.front(); }
0105 
0106    /** return covariance matrices elements
0107        if the variable is fixed the matrix is zero
0108        The ordering of the variables is the same as in errors
0109    */
0110    double CovMatrix(unsigned int i, unsigned int j) const override {
0111       return (fCovar.empty()) ? 0 : fCovar[i + fDim* j];
0112    }
0113 
0114    /// return covariance matrix status
0115    int CovMatrixStatus() const override {
0116       if (fCovar.empty()) return 0;
0117       return (fStatus ==0) ? 3 : 1;
0118    }
0119 
0120    /// return reference to the objective function
0121    ///virtual const ROOT::Math::IGenFunction & Function() const;
0122 
0123 
0124 
0125 
0126 protected:
0127 
0128 private:
0129 
0130    bool fRobust;
0131    unsigned int fDim;
0132    unsigned int fNFree;
0133    double fMinVal;
0134    std::vector<double> fParams;
0135    std::vector<double> fErrors;
0136    std::vector<double> fCovar;
0137 
0138    const ROOT::Math::IMultiGradFunction * fObjFunc;
0139    TLinearFitter * fFitter;
0140 
0141    ClassDef(TLinearMinimizer,1)  //Implementation of the Minimizer interface using TLinearFitter
0142 
0143 };
0144 
0145 
0146 
0147 #endif /* ROOT_TLinearMinimizer */