Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-11-03 10:03:38

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(const char *name, const char *title, RooAbsReal& nll, const RooArgSet& observables);
0026   RooProfileLL(const RooProfileLL& other, const char* name=nullptr) ;
0027   TObject* clone(const char* newname=nullptr) const override { return new RooProfileLL(*this,newname); }
0028 
0029   void setAlwaysStartFromMin(bool flag) { _startFromMin = flag ; }
0030   bool alwaysStartFromMin() const { return _startFromMin ; }
0031 
0032   RooMinimizer* minimizer() { if (!_minimizer) initializeMinimizer(); return _minimizer.get() ; }
0033   RooAbsReal& nll() { return const_cast<RooAbsReal&>(_nll.arg()) ; }
0034   const RooArgSet& bestFitParams() const ;
0035   const RooArgSet& bestFitObs() const ;
0036 
0037   RooFit::OwningPtr<RooAbsReal> createProfile(const RooArgSet& paramsOfInterest) override ;
0038 
0039   bool redirectServersHook(const RooAbsCollection& /*newServerList*/, bool /*mustReplaceAll*/, bool /*nameChange*/, bool /*isRecursive*/) override ;
0040 
0041   void clearAbsMin() { _absMinValid = false ; }
0042 
0043   Int_t numEval() const { return _neval ; }
0044 
0045 
0046 protected:
0047 
0048   void validateAbsMin() const ;
0049   void initializeMinimizer() const ;
0050 
0051   RooRealProxy _nll ;    ///< Input -log(L) function
0052   RooSetProxy _obs ;     ///< Parameters of profile likelihood
0053   RooSetProxy _par ;     ///< Marginalised parameters of likelihood
0054   bool _startFromMin = true; ///< Always start minimization for global minimum?
0055 
0056   mutable std::unique_ptr<RooMinimizer> _minimizer = nullptr ; ///<! Internal minimizer instance
0057 
0058   mutable bool _absMinValid = false; ///< flag if absmin is up-to-date
0059   mutable double _absMin = 0.0; ///< absolute minimum of -log(L)
0060   mutable RooArgSet _paramAbsMin ; ///< Parameter values at absolute minimum
0061   mutable RooArgSet _obsAbsMin ; ///< Observable values at absolute minimum
0062   mutable std::map<std::string,bool> _paramFixed ; ///< Parameter constant status at last time of use
0063   mutable Int_t _neval = 0; ///< Number evaluations used in last minimization
0064   double evaluate() const override ;
0065 
0066 
0067 private:
0068 
0069   ClassDefOverride(RooProfileLL,0) // Real-valued function representing profile likelihood of external (likelihood) function
0070 };
0071 
0072 #endif