Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-17 09:16:06

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    /// set the fit model function
0051    void SetFunction(const ROOT::Math::IMultiGenFunction & func) override;
0052 
0053    /// set free variable (dummy impl. since there is no need to set variables in the Linear Fitter)
0054    bool SetVariable(unsigned int , const std::string & , double , double ) override { return true; }
0055 
0056    /// set fixed variable (override if minimizer supports them )
0057    bool SetFixedVariable(unsigned int /* ivar */, const std::string & /* name */, double /* val */) override;
0058 
0059    /// method to perform the minimization
0060     bool Minimize() override;
0061 
0062    /// return minimum function value
0063    double MinValue() const override { return fMinVal; }
0064 
0065    /// return expected distance reached from the minimum
0066    double Edm() const override { return 0; }
0067 
0068    /// return  pointer to X values at the minimum
0069    const double *  X() const override { return &fParams.front(); }
0070 
0071    /// return pointer to gradient values at the minimum
0072    const double *  MinGradient() const override { return nullptr; } // not available in Minuit2
0073 
0074    /// number of function calls to reach the minimum
0075    unsigned int NCalls() const override { return 0; }
0076 
0077    /// this is <= Function().NDim() which is the total
0078    /// number of variables (free+ constrained ones)
0079    unsigned int NDim() const override { return fDim; }
0080 
0081    /// number of free variables (real dimension of the problem)
0082    /// this is <= Function().NDim() which is the total
0083    unsigned int NFree() const override { return fNFree; }
0084 
0085    /// minimizer provides error and error matrix
0086    bool ProvidesError() const override { return true; }
0087 
0088    /// return errors at the minimum
0089    const double * Errors() const override { return  fErrors.empty() ? nullptr : &fErrors.front(); }
0090 
0091    /** return covariance matrices elements
0092        if the variable is fixed the matrix is zero
0093        The ordering of the variables is the same as in errors
0094    */
0095    double CovMatrix(unsigned int i, unsigned int j) const override {
0096       return (fCovar.empty()) ? 0 : fCovar[i + fDim* j];
0097    }
0098 
0099    /// return covariance matrix status
0100    int CovMatrixStatus() const override {
0101       if (fCovar.empty()) return 0;
0102       return (fStatus ==0) ? 3 : 1;
0103    }
0104 
0105    /// return reference to the objective function
0106    ///virtual const ROOT::Math::IGenFunction & Function() const;
0107 
0108 
0109 
0110 
0111 protected:
0112 
0113 private:
0114 
0115    bool fRobust;
0116    unsigned int fDim;
0117    unsigned int fNFree;
0118    double fMinVal;
0119    std::vector<double> fParams;
0120    std::vector<double> fErrors;
0121    std::vector<double> fCovar;
0122 
0123    const ROOT::Math::IMultiGradFunction * fObjFunc;
0124    TLinearFitter * fFitter;
0125 
0126    ClassDef(TLinearMinimizer,1)  //Implementation of the Minimizer interface using TLinearFitter
0127 
0128 };
0129 
0130 
0131 
0132 #endif /* ROOT_TLinearMinimizer */