Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:11:26

0001 /*****************************************************************************
0002  * Project: RooFit                                                           *
0003  *                                                                           *
0004  * Copyright (c) 2000-2005, Regents of the University of California          *
0005  *                          and Stanford University. All rights reserved.    *
0006  *                                                                           *
0007  * Redistribution and use in source and binary forms,                        *
0008  * with or without modification, are permitted according to the terms        *
0009  * listed in LICENSE (http://roofit.sourceforge.net/license.txt)             *
0010  *****************************************************************************/
0011 
0012 #ifndef ROOPROFILELL
0013 #define ROOPROFILELL
0014 
0015 #include "RooAbsReal.h"
0016 #include "RooMinimizer.h"
0017 #include "RooRealProxy.h"
0018 #include "RooSetProxy.h"
0019 #include <map>
0020 #include <string>
0021 
0022 class RooProfileLL : public RooAbsReal {
0023 public:
0024 
0025   RooProfileLL() ;
0026   RooProfileLL(const char *name, const char *title, RooAbsReal& nll, const RooArgSet& observables);
0027   RooProfileLL(const RooProfileLL& other, const char* name=nullptr) ;
0028   TObject* clone(const char* newname) const override { return new RooProfileLL(*this,newname); }
0029 
0030   void setAlwaysStartFromMin(bool flag) { _startFromMin = flag ; }
0031   bool alwaysStartFromMin() const { return _startFromMin ; }
0032 
0033   RooMinimizer* minimizer() { if (!_minimizer) initializeMinimizer(); return _minimizer.get() ; }
0034   RooAbsReal& nll() { return const_cast<RooAbsReal&>(_nll.arg()) ; }
0035   const RooArgSet& bestFitParams() const ;
0036   const RooArgSet& bestFitObs() const ;
0037 
0038   RooFit::OwningPtr<RooAbsReal> createProfile(const RooArgSet& paramsOfInterest) override ;
0039 
0040   bool redirectServersHook(const RooAbsCollection& /*newServerList*/, bool /*mustReplaceAll*/, bool /*nameChange*/, bool /*isRecursive*/) override ;
0041 
0042   void clearAbsMin() { _absMinValid = false ; }
0043 
0044   Int_t numEval() const { return _neval ; }
0045 
0046 
0047 protected:
0048 
0049   void validateAbsMin() const ;
0050   void initializeMinimizer() const ;
0051 
0052   RooRealProxy _nll ;    ///< Input -log(L) function
0053   RooSetProxy _obs ;     ///< Parameters of profile likelihood
0054   RooSetProxy _par ;     ///< Marginalised parameters of likelihood
0055   bool _startFromMin = true; ///< Always start minimization for global minimum?
0056 
0057   mutable std::unique_ptr<RooMinimizer> _minimizer = nullptr ; ///<! Internal minimizer instance
0058 
0059   mutable bool _absMinValid = false; ///< flag if absmin is up-to-date
0060   mutable double _absMin = 0.0; ///< absolute minimum of -log(L)
0061   mutable RooArgSet _paramAbsMin ; ///< Parameter values at absolute minimum
0062   mutable RooArgSet _obsAbsMin ; ///< Observable values at absolute minimum
0063   mutable std::map<std::string,bool> _paramFixed ; ///< Parameter constant status at last time of use
0064   mutable Int_t _neval = 0; ///< Number evaluations used in last minimization
0065   double evaluate() const override ;
0066 
0067 
0068 private:
0069 
0070   ClassDefOverride(RooProfileLL,0) // Real-valued function representing profile likelihood of external (likelihood) function
0071 };
0072 
0073 #endif