Back to home page

EIC code displayed by LXR

 
 

    


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

0001 /*****************************************************************************
0002  * Project: RooFit                                                           *
0003  * Package: RooFitCore                                                       *
0004  *    File: $Id: RooFitResult.h,v 1.28 2007/05/11 09:11:30 verkerke Exp $
0005  * Authors:                                                                  *
0006  *   WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu       *
0007  *   DK, David Kirkby,    UC Irvine,         dkirkby@uci.edu                 *
0008  *                                                                           *
0009  * Copyright (c) 2000-2005, Regents of the University of California          *
0010  *                          and Stanford University. All rights reserved.    *
0011  *                                                                           *
0012  * Redistribution and use in source and binary forms,                        *
0013  * with or without modification, are permitted according to the terms        *
0014  * listed in LICENSE (http://roofit.sourceforge.net/license.txt)             *
0015  *****************************************************************************/
0016 #ifndef ROO_FIT_RESULT
0017 #define ROO_FIT_RESULT
0018 
0019 #include "RooAbsArg.h"
0020 #include "RooPrintable.h"
0021 #include "RooDirItem.h"
0022 #include "RooArgList.h"
0023 
0024 #include "RVersion.h"
0025 #include "TMatrixFfwd.h"
0026 #include "TMatrixDSym.h"
0027 #include "TList.h"
0028 
0029 #include <vector>
0030 #include <string>
0031 #include <utility>
0032 
0033 class RooArgSet ;
0034 class RooAbsPdf ;
0035 class RooPlot;
0036 class TObject ;
0037 class TH2 ;
0038 typedef RooArgSet* pRooArgSet ;
0039 
0040 class RooFitResult : public TNamed, public RooPrintable, public RooDirItem {
0041 public:
0042 
0043   // Constructors, assignment etc.
0044   RooFitResult(const char* name=nullptr, const char* title=nullptr) ;
0045   RooFitResult(const RooFitResult& other) ;
0046   TObject* Clone(const char* newname = nullptr) const override {
0047     RooFitResult* r =  new RooFitResult(*this) ;
0048     if (newname && *newname) r->SetName(newname) ;
0049     return r ;
0050   }
0051   virtual TObject* clone() const { return new RooFitResult(*this); }
0052   ~RooFitResult() override ;
0053 
0054   static RooFitResult* lastMinuitFit(const RooArgList& varList=RooArgList()) ;
0055 
0056   static RooFitResult *prefitResult(const RooArgList &paramList);
0057 
0058   // Printing interface (human readable)
0059   void printValue(std::ostream& os) const override ;
0060   void printName(std::ostream& os) const override ;
0061   void printTitle(std::ostream& os) const override ;
0062   void printClassName(std::ostream& os) const override ;
0063   void printArgs(std::ostream& os) const override ;
0064   void printMultiline(std::ostream& os, Int_t contents, bool verbose=false, TString indent="") const override ;
0065 
0066   inline void Print(Option_t *options= nullptr) const override {
0067     // Printing interface
0068     printStream(defaultPrintStream(),defaultPrintContents(options),defaultPrintStyle(options));
0069   }
0070 
0071   Int_t defaultPrintContents(Option_t* opt) const override ;
0072   StyleOption defaultPrintStyle(Option_t* opt) const override ;
0073 
0074   RooAbsPdf* createHessePdf(const RooArgSet& params) const ;
0075 
0076   // Accessors
0077   /// Return MINUIT status code
0078   inline Int_t status() const {
0079     return _status ;
0080   }
0081 
0082   inline UInt_t numStatusHistory() const { return _statusHistory.size() ; }
0083   Int_t statusCodeHistory(UInt_t icycle) const ;
0084   const char* statusLabelHistory(UInt_t icycle) const ;
0085 
0086   /// Return MINUIT quality code of covariance matrix
0087   inline Int_t covQual() const {
0088     return _covQual ;
0089   }
0090   /// Return number of NLL evaluations with problems.
0091   inline Int_t numInvalidNLL() const {
0092     return _numBadNLL ;
0093   }
0094   /// Return estimated distance to minimum.
0095   inline double edm() const {
0096     return _edm ;
0097   }
0098   /// Return minimized -log(L) value.
0099   inline double minNll() const {
0100     return _minNLL ;
0101   }
0102   /// Return list of constant parameters.
0103   inline const RooArgList& constPars() const {
0104     return *_constPars ;
0105   }
0106   /// Return list of floating parameters before fit.
0107   inline const RooArgList& floatParsInit() const {
0108     return *_initPars ;
0109   }
0110   /// Return list of floating parameters after fit.
0111   inline const RooArgList& floatParsFinal() const {
0112     return *_finalPars ;
0113   }
0114 
0115   TH2* correlationHist(const char* name = "correlation_matrix") const ;
0116 
0117   /// Return correlation between par1 and par2.
0118   double correlation(const RooAbsArg& par1, const RooAbsArg& par2) const {
0119     return correlation(par1.GetName(),par2.GetName()) ;
0120   }
0121   /// Return pointer to list of correlations of all parameters with par.
0122   const RooArgList* correlation(const RooAbsArg& par) const {
0123     return correlation(par.GetName()) ;
0124   }
0125 
0126   double correlation(const char* parname1, const char* parname2) const ;
0127   const RooArgList* correlation(const char* parname) const ;
0128 
0129 
0130   const TMatrixDSym& covarianceMatrix() const ;
0131   const TMatrixDSym& correlationMatrix() const ;
0132   TMatrixDSym reducedCovarianceMatrix(const RooArgList& params) const ;
0133   TMatrixDSym conditionalCovarianceMatrix(const RooArgList& params) const ;
0134 
0135 
0136   // Global correlation accessors
0137   double globalCorr(const RooAbsArg& par) { return globalCorr(par.GetName()) ; }
0138   double globalCorr(const char* parname) ;
0139   const RooArgList* globalCorr() ;
0140 
0141 
0142   /// Add objects to a 2D plot.
0143   /// Plot error ellipse in par1 and par2 on frame.
0144   inline RooPlot *plotOn(RooPlot *frame, const RooAbsArg &par1, const RooAbsArg &par2,
0145           const char *options= "ME") const {
0146     return plotOn(frame,par1.GetName(),par2.GetName(),options);
0147   }
0148   RooPlot *plotOn(RooPlot *plot, const char *parName1, const char *parName2,
0149         const char *options= "ME") const;
0150 
0151   /// Generate random perturbations of the final parameters using the covariance matrix.
0152   const RooArgList& randomizePars() const;
0153 
0154   bool isIdenticalNoCov(const RooFitResult& other, double tol=1e-6, double tolErr=1e-3, bool verbose=true) const ;
0155   bool isIdentical(const RooFitResult& other, double tol=1e-6, double tolCorr=1e-4, bool verbose=true) const ;
0156 
0157   void SetName(const char *name) override ;
0158   void SetNameTitle(const char *name, const char* title) override ;
0159 
0160 
0161 
0162   void setCovarianceMatrix(TMatrixDSym& V) ;
0163   void setConstParList(const RooArgList& list) ;
0164   void setInitParList(const RooArgList& list) ;
0165   void setFinalParList(const RooArgList& list) ;
0166   inline void setMinNLL(double val) { _minNLL = val ; }
0167   inline void setEDM(double val) { _edm = val ; }
0168   inline void setStatus(Int_t val) { _status = val ; }
0169   inline void setCovQual(Int_t val) { _covQual = val ; }
0170   inline void setNumInvalidNLL(Int_t val) { _numBadNLL=val ; }
0171   void setStatusHistory(std::vector<std::pair<std::string,int> >& hist) { _statusHistory = hist ; }
0172   void fillCorrMatrix(const std::vector<double>& globalCC, const TMatrixDSym& corrs, const TMatrixDSym& covs) ;
0173 
0174 protected:
0175 
0176   void fillCorrMatrix() ;
0177   void fillLegacyCorrMatrix() const ;
0178   void fillPrefitCorrMatrix();
0179   double correlation(Int_t row, Int_t col) const;
0180   double covariance(Int_t row, Int_t col) const;
0181 
0182   Int_t    _status ;          ///< MINUIT status code
0183   Int_t    _covQual ;         ///< MINUIT quality code of covariance matrix
0184   Int_t    _numBadNLL ;       ///< Number calls with bad (zero,negative) likelihood
0185   double _minNLL ;          ///< NLL at minimum
0186   double _edm ;             ///< Estimated distance to minimum
0187   RooArgList* _constPars = nullptr;    ///< List of constant parameters
0188   RooArgList* _initPars = nullptr;     ///< List of floating parameters with initial values
0189   RooArgList* _finalPars = nullptr;    ///< List of floating parameters with final values
0190 
0191   mutable RooArgList* _globalCorr = nullptr;   ///<! List of global correlation coefficients
0192   mutable TList       _corrMatrix ;   ///<! Correlation matrix (list of RooArgLists)
0193 
0194   mutable RooArgList *_randomPars = nullptr; ///<! List of floating parameters with most recent random perturbation applied
0195   mutable TMatrixF* _Lt = nullptr;           ///<! triangular matrix used for generate random perturbations
0196 
0197   TMatrixDSym* _CM = nullptr;  ///< Correlation matrix
0198   TMatrixDSym* _VM = nullptr;  ///< Covariance matrix
0199   TVectorD* _GC = nullptr;     ///< Global correlation coefficients
0200 
0201   std::vector<std::pair<std::string,int> > _statusHistory ; ///< History of status codes
0202 
0203   ClassDefOverride(RooFitResult,5) // Container class for fit result
0204 };
0205 
0206 #endif