Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/RooAbsReal.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: RooAbsReal.h,v 1.75 2007/07/13 21:50:24 wouter 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_ABS_REAL
0017 #define ROO_ABS_REAL
0018 
0019 #include "RooAbsArg.h"
0020 #include "RooArgList.h"
0021 #include "RooArgProxy.h"
0022 #include "RooArgSet.h"
0023 #include "RooCmdArg.h"
0024 #include "RooCurve.h"
0025 #include "RooFit/CodegenContext.h"
0026 #include "RooFit/EvalContext.h"
0027 #include "RooGlobalFunc.h"
0028 
0029 #include <ROOT/RSpan.hxx>
0030 
0031 #include <TList.h>
0032 #include <TObjString.h>
0033 
0034 class RooDataSet ;
0035 class RooPlot;
0036 class RooRealVar;
0037 class RooAbsFunc;
0038 class RooAbsCategoryLValue ;
0039 class RooLinkedList ;
0040 class RooNumIntConfig ;
0041 class RooDataHist ;
0042 class RooFunctor ;
0043 class RooFitResult ;
0044 class RooAbsMoment ;
0045 class RooDerivative ;
0046 class RooVectorDataStore ;
0047 struct TreeReadBuffer; /// A space to attach TBranches
0048 namespace RooBatchCompute {
0049 struct RunContext;
0050 }
0051 
0052 class TH1;
0053 class TH1F;
0054 class TH2F;
0055 class TH3F;
0056 
0057 #include <iostream>
0058 #include <list>
0059 #include <map>
0060 #include <string>
0061 #include <sstream>
0062 
0063 class RooAbsReal : public RooAbsArg {
0064 public:
0065   using value_type = double;
0066 
0067   /// A RooAbsReal::Ref can be constructed from a `RooAbsReal&` or a `double`
0068   /// that will be implicitly converted to a RooConstVar&. The RooAbsReal::Ref
0069   /// can be used as a replacement for `RooAbsReal&`. With this type
0070   /// definition, you can write RooFit interfaces that accept both RooAbsReal,
0071   /// or simply a number that will be implicitly converted to a RooConstVar&.
0072   class Ref {
0073   public:
0074      inline Ref(RooAbsReal &ref) : _ref{ref} {}
0075      Ref(double val);
0076      inline operator RooAbsReal &() const { return _ref; }
0077 
0078   private:
0079      RooAbsReal &_ref;
0080   };
0081 
0082   // Constructors, assignment etc
0083   RooAbsReal() ;
0084   RooAbsReal(const char *name, const char *title, const char *unit= "") ;
0085   RooAbsReal(const char *name, const char *title, double minVal, double maxVal,
0086         const char *unit= "") ;
0087   RooAbsReal(const RooAbsReal& other, const char* name=nullptr);
0088   ~RooAbsReal() override;
0089 
0090 
0091 
0092 
0093   //////////////////////////////////////////////////////////////////////////////////
0094   /// Evaluate object. Returns either cached value or triggers a recalculation.
0095   /// The recalculation happens by calling getValV(), which in the end calls the
0096   /// virtual evaluate() functions of the respective PDFs.
0097   /// \param[in] normalisationSet getValV() reacts differently depending on the value of the normalisation set.
0098   /// If the set is `nullptr`, an unnormalised value is returned.
0099   /// \note The normalisation is arbitrary, because it is up to the implementation
0100   /// of the PDF to e.g. leave out normalisation constants for speed reasons. The range
0101   /// of the variables is also ignored.
0102   ///
0103   /// To normalise the result properly, a RooArgSet has to be passed, which contains
0104   /// the variables to normalise over.
0105   /// These are integrated over their current ranges to compute the normalisation constant,
0106   /// and the unnormalised result is divided by this value.
0107   inline double getVal(const RooArgSet* normalisationSet = nullptr) const {
0108     // Sometimes, the calling code uses an empty RooArgSet to request evaluation
0109     // without normalization set instead of following the `nullptr` convention.
0110     // To remove this ambiguity which might not always be correctly handled in
0111     // downstream code, we set `normalisationSet` to nullptr if it is pointing
0112     // to an empty set.
0113     if(normalisationSet && normalisationSet->empty()) {
0114       normalisationSet = nullptr;
0115     }
0116 #ifdef ROOFIT_CHECK_CACHED_VALUES
0117     return _DEBUG_getVal(normalisationSet);
0118 #else
0119 
0120 #ifndef _WIN32
0121     return (_fast && !_inhibitDirty) ? _value : getValV(normalisationSet) ;
0122 #else
0123     return (_fast && !inhibitDirty()) ? _value : getValV(normalisationSet) ;
0124 #endif
0125 
0126 #endif
0127   }
0128 
0129   /// Like getVal(const RooArgSet*), but always requires an argument for normalisation.
0130   inline  double getVal(const RooArgSet& normalisationSet) const {
0131     // Sometimes, the calling code uses an empty RooArgSet to request evaluation
0132     // without normalization set instead of following the `nullptr` convention.
0133     // To remove this ambiguity which might not always be correctly handled in
0134     // downstream code, we set `normalisationSet` to nullptr if it is an empty set.
0135     return _fast ? _value : getValV(normalisationSet.empty() ? nullptr : &normalisationSet) ;
0136   }
0137 
0138   double getVal(RooArgSet &&) const;
0139 
0140   virtual double getValV(const RooArgSet* normalisationSet = nullptr) const ;
0141 
0142   double getPropagatedError(const RooFitResult &fr, const RooArgSet &nset = {}) const;
0143 
0144   bool operator==(double value) const ;
0145   bool operator==(const RooAbsArg& other) const override;
0146   bool isIdentical(const RooAbsArg& other, bool assumeSameType=false) const override;
0147 
0148 
0149   inline const Text_t *getUnit() const {
0150     // Return string with unit description
0151     return _unit.Data();
0152   }
0153   inline void setUnit(const char *unit) {
0154     // Set unit description to given string
0155     _unit= unit;
0156   }
0157   TString getTitle(bool appendUnit= false) const;
0158 
0159   // Lightweight interface adaptors (caller takes ownership)
0160   RooFit::OwningPtr<RooAbsFunc> bindVars(const RooArgSet &vars, const RooArgSet* nset=nullptr, bool clipInvalid=false) const;
0161 
0162   // Create a fundamental-type object that can hold our value.
0163   RooFit::OwningPtr<RooAbsArg> createFundamental(const char* newname=nullptr) const override;
0164 
0165   // Analytical integration support
0166   virtual Int_t getAnalyticalIntegralWN(RooArgSet& allVars, RooArgSet& analVars, const RooArgSet* normSet, const char* rangeName=nullptr) const ;
0167   virtual double analyticalIntegralWN(Int_t code, const RooArgSet* normSet, const char* rangeName=nullptr) const ;
0168   virtual Int_t getAnalyticalIntegral(RooArgSet& allVars, RooArgSet& analVars, const char* rangeName=nullptr) const ;
0169   virtual double analyticalIntegral(Int_t code, const char* rangeName=nullptr) const ;
0170   virtual bool forceAnalyticalInt(const RooAbsArg& /*dep*/) const {
0171     // Interface to force RooRealIntegral to offer given observable for internal integration
0172     // even if this is deemed unsafe. This default implementation returns always false
0173     return false ;
0174   }
0175   virtual void forceNumInt(bool flag=true) {
0176     // If flag is true, all advertised analytical integrals will be ignored
0177     // and all integrals are calculated numerically
0178     _forceNumInt = flag ;
0179   }
0180   bool getForceNumInt() const { return _forceNumInt ; }
0181 
0182   // Chi^2 fits to histograms
0183   virtual RooFit::OwningPtr<RooFitResult> chi2FitTo(RooDataHist& data, const RooCmdArg& arg1={},  const RooCmdArg& arg2={},
0184                               const RooCmdArg& arg3={},  const RooCmdArg& arg4={}, const RooCmdArg& arg5={},
0185                               const RooCmdArg& arg6={},  const RooCmdArg& arg7={}, const RooCmdArg& arg8={}) ;
0186   virtual RooFit::OwningPtr<RooFitResult> chi2FitTo(RooDataHist& data, const RooLinkedList& cmdList) ;
0187 
0188   virtual RooFit::OwningPtr<RooAbsReal> createChi2(RooDataHist& data, const RooLinkedList& cmdList) ;
0189   virtual RooFit::OwningPtr<RooAbsReal> createChi2(RooDataHist& data, const RooCmdArg& arg1={},  const RooCmdArg& arg2={},
0190              const RooCmdArg& arg3={},  const RooCmdArg& arg4={}, const RooCmdArg& arg5={},
0191              const RooCmdArg& arg6={},  const RooCmdArg& arg7={}, const RooCmdArg& arg8={}) ;
0192 
0193   // Chi^2 fits to X-Y datasets
0194   virtual RooFit::OwningPtr<RooFitResult> chi2FitTo(RooDataSet& xydata, const RooCmdArg& arg1={},  const RooCmdArg& arg2={},
0195                               const RooCmdArg& arg3={},  const RooCmdArg& arg4={}, const RooCmdArg& arg5={},
0196                               const RooCmdArg& arg6={},  const RooCmdArg& arg7={}, const RooCmdArg& arg8={}) ;
0197   virtual RooFit::OwningPtr<RooFitResult> chi2FitTo(RooDataSet& xydata, const RooLinkedList& cmdList) ;
0198 
0199   virtual RooFit::OwningPtr<RooAbsReal> createChi2(RooDataSet& data, const RooLinkedList& cmdList) ;
0200   virtual RooFit::OwningPtr<RooAbsReal> createChi2(RooDataSet& data, const RooCmdArg& arg1={},  const RooCmdArg& arg2={},
0201                const RooCmdArg& arg3={},  const RooCmdArg& arg4={}, const RooCmdArg& arg5={},
0202                const RooCmdArg& arg6={},  const RooCmdArg& arg7={}, const RooCmdArg& arg8={}) ;
0203 
0204   virtual RooFit::OwningPtr<RooAbsReal> createProfile(const RooArgSet& paramsOfInterest) ;
0205 
0206 
0207   RooFit::OwningPtr<RooAbsReal> createIntegral(const RooArgSet& iset, const RooCmdArg& arg1, const RooCmdArg& arg2={},
0208                              const RooCmdArg& arg3={}, const RooCmdArg& arg4={},
0209               const RooCmdArg& arg5={}, const RooCmdArg& arg6={},
0210               const RooCmdArg& arg7={}, const RooCmdArg& arg8={}) const ;
0211 
0212   /// Create integral over observables in iset in range named rangeName.
0213   RooFit::OwningPtr<RooAbsReal> createIntegral(const RooArgSet& iset, const char* rangeName) const {
0214     return createIntegral(iset,nullptr,nullptr,rangeName) ;
0215   }
0216   /// Create integral over observables in iset in range named rangeName with integrand normalized over observables in nset
0217   RooFit::OwningPtr<RooAbsReal> createIntegral(const RooArgSet& iset, const RooArgSet& nset, const char* rangeName=nullptr) const {
0218     return createIntegral(iset,&nset,nullptr,rangeName) ;
0219   }
0220   /// Create integral over observables in iset in range named rangeName with integrand normalized over observables in nset while
0221   /// using specified configuration for any numeric integration.
0222   RooFit::OwningPtr<RooAbsReal> createIntegral(const RooArgSet& iset, const RooArgSet& nset, const RooNumIntConfig& cfg, const char* rangeName=nullptr) const {
0223     return createIntegral(iset,&nset,&cfg,rangeName) ;
0224   }
0225   /// Create integral over observables in iset in range named rangeName using specified configuration for any numeric integration.
0226   RooFit::OwningPtr<RooAbsReal> createIntegral(const RooArgSet& iset, const RooNumIntConfig& cfg, const char* rangeName=nullptr) const {
0227     return createIntegral(iset,nullptr,&cfg,rangeName) ;
0228   }
0229   virtual RooFit::OwningPtr<RooAbsReal> createIntegral(const RooArgSet& iset, const RooArgSet* nset=nullptr, const RooNumIntConfig* cfg=nullptr, const char* rangeName=nullptr) const ;
0230 
0231 
0232   void setParameterizeIntegral(const RooArgSet& paramVars) ;
0233 
0234   // Create running integrals
0235   RooFit::OwningPtr<RooAbsReal> createRunningIntegral(const RooArgSet& iset, const RooArgSet& nset={}) ;
0236   RooFit::OwningPtr<RooAbsReal> createRunningIntegral(const RooArgSet& iset, const RooCmdArg& arg1, const RooCmdArg& arg2={},
0237          const RooCmdArg& arg3={}, const RooCmdArg& arg4={},
0238          const RooCmdArg& arg5={}, const RooCmdArg& arg6={},
0239          const RooCmdArg& arg7={}, const RooCmdArg& arg8={}) ;
0240   RooFit::OwningPtr<RooAbsReal> createIntRI(const RooArgSet& iset, const RooArgSet& nset={}) ;
0241   RooFit::OwningPtr<RooAbsReal> createScanRI(const RooArgSet& iset, const RooArgSet& nset, Int_t numScanBins, Int_t intOrder) ;
0242 
0243 
0244   // Optimized accept/reject generator support
0245   virtual Int_t getMaxVal(const RooArgSet& vars) const ;
0246   virtual double maxVal(Int_t code) const ;
0247   virtual Int_t minTrialSamples(const RooArgSet& /*arGenObs*/) const { return 0 ; }
0248 
0249 
0250   // Plotting options
0251   void setPlotLabel(const char *label);
0252   const char *getPlotLabel() const;
0253 
0254   virtual double defaultErrorLevel() const {
0255     // Return default level for MINUIT error analysis
0256     return 1.0 ;
0257   }
0258 
0259   const RooNumIntConfig* getIntegratorConfig() const ;
0260   RooNumIntConfig* getIntegratorConfig() ;
0261   static RooNumIntConfig* defaultIntegratorConfig()  ;
0262   RooNumIntConfig* specialIntegratorConfig() const ;
0263   RooNumIntConfig* specialIntegratorConfig(bool createOnTheFly) ;
0264   void setIntegratorConfig() ;
0265   void setIntegratorConfig(const RooNumIntConfig& config) ;
0266 
0267   virtual void fixAddCoefNormalization(const RooArgSet& addNormSet=RooArgSet(),bool force=true) ;
0268   virtual void fixAddCoefRange(const char* rangeName=nullptr,bool force=true) ;
0269 
0270   virtual void preferredObservableScanOrder(const RooArgSet& obs, RooArgSet& orderedObs) const ;
0271 
0272   // User entry point for plotting
0273   virtual RooPlot* plotOn(RooPlot* frame,
0274            const RooCmdArg& arg1={}, const RooCmdArg& arg2={},
0275            const RooCmdArg& arg3={}, const RooCmdArg& arg4={},
0276            const RooCmdArg& arg5={}, const RooCmdArg& arg6={},
0277            const RooCmdArg& arg7={}, const RooCmdArg& arg8={},
0278            const RooCmdArg& arg9={}, const RooCmdArg& arg10={}
0279               ) const ;
0280 
0281 
0282   enum ScaleType { Raw, Relative, NumEvent, RelativeExpected } ;
0283 
0284   // Fill an existing histogram
0285   TH1 *fillHistogram(TH1 *hist, const RooArgList &plotVars,
0286            double scaleFactor= 1, const RooArgSet *projectedVars= nullptr, bool scaling=true,
0287            const RooArgSet* condObs=nullptr, bool setError=true) const;
0288 
0289   // Create 1,2, and 3D histograms from and fill it
0290   TH1 *createHistogram(RooStringView varNameList, Int_t xbins=0, Int_t ybins=0, Int_t zbins=0) const ;
0291   TH1* createHistogram(const char *name, const RooAbsRealLValue& xvar, RooLinkedList& argList) const ;
0292   TH1 *createHistogram(const char *name, const RooAbsRealLValue& xvar,
0293                        const RooCmdArg& arg1={}, const RooCmdArg& arg2={},
0294                        const RooCmdArg& arg3={}, const RooCmdArg& arg4={},
0295                        const RooCmdArg& arg5={}, const RooCmdArg& arg6={},
0296                        const RooCmdArg& arg7={}, const RooCmdArg& arg8={}) const ;
0297 
0298   // Fill a RooDataHist
0299   RooDataHist* fillDataHist(RooDataHist *hist, const RooArgSet* nset, double scaleFactor,
0300              bool correctForBinVolume=false, bool showProgress=false) const ;
0301 
0302   // I/O streaming interface (machine readable)
0303   bool readFromStream(std::istream& is, bool compact, bool verbose=false) override ;
0304   void writeToStream(std::ostream& os, bool compact) const override ;
0305 
0306   // Printing interface (human readable)
0307   void printValue(std::ostream& os) const override ;
0308   void printMultiline(std::ostream& os, Int_t contents, bool verbose=false, TString indent="") const override ;
0309 
0310   inline void setCachedValue(double value, bool notifyClients = true) final;
0311 
0312   // Evaluation error logging
0313   class EvalError {
0314   public:
0315     EvalError() { }
0316     EvalError(const EvalError& other) : _msg(other._msg), _srvval(other._srvval) { }
0317     void setMessage(const char* tmp) { std::string s(tmp); s.swap(_msg); }
0318     void setServerValues(const char* tmp) { std::string s(tmp); s.swap(_srvval); }
0319     std::string _msg;
0320     std::string _srvval;
0321   } ;
0322 
0323   enum ErrorLoggingMode { PrintErrors, CollectErrors, CountErrors, Ignore } ;
0324 
0325   /// Context to temporarily change the error logging mode as long as the context is alive.
0326   class EvalErrorContext {
0327   public:
0328      EvalErrorContext(ErrorLoggingMode m) : _old{evalErrorLoggingMode()} { setEvalErrorLoggingMode(m); }
0329 
0330      EvalErrorContext(EvalErrorContext const&) = delete;
0331      EvalErrorContext(EvalErrorContext &&) = delete;
0332      EvalErrorContext& operator=(EvalErrorContext const&) = delete;
0333      EvalErrorContext& operator=(EvalErrorContext &&) = delete;
0334 
0335      ~EvalErrorContext() { setEvalErrorLoggingMode(_old); }
0336   private:
0337      ErrorLoggingMode _old;
0338   };
0339 
0340   static ErrorLoggingMode evalErrorLoggingMode() ;
0341   static void setEvalErrorLoggingMode(ErrorLoggingMode m) ;
0342   void logEvalError(const char* message, const char* serverValueString=nullptr) const ;
0343   static void logEvalError(const RooAbsReal* originator, const char* origName, const char* message, const char* serverValueString=nullptr) ;
0344   static void printEvalErrors(std::ostream&os=std::cout, Int_t maxPerNode=10000000) ;
0345   static Int_t numEvalErrors() ;
0346   static Int_t numEvalErrorItems();
0347   static std::map<const RooAbsArg *, std::pair<std::string, std::list<RooAbsReal::EvalError>>>::iterator evalErrorIter();
0348 
0349   static void clearEvalErrorLog() ;
0350 
0351   /// Tests if the distribution is binned. Unless overridden by derived classes, this always returns false.
0352   virtual bool isBinnedDistribution(const RooArgSet& /*obs*/) const { return false ; }
0353   virtual std::list<double>* binBoundaries(RooAbsRealLValue& obs, double xlo, double xhi) const;
0354   virtual std::list<double>* plotSamplingHint(RooAbsRealLValue& obs, double xlo, double xhi) const;
0355 
0356   RooFunctor* functor(const RooArgList& obs, const RooArgList& pars=RooArgList(), const RooArgSet& nset=RooArgSet()) const ;
0357   TF1* asTF(const RooArgList& obs, const RooArgList& pars=RooArgList(), const RooArgSet& nset=RooArgSet()) const ;
0358 
0359   RooDerivative* derivative(RooRealVar& obs, Int_t order=1, double eps=0.001) ;
0360   RooDerivative* derivative(RooRealVar& obs, const RooArgSet& normSet, Int_t order, double eps=0.001) ;
0361 
0362   RooAbsMoment* moment(RooRealVar& obs, Int_t order, bool central, bool takeRoot) ;
0363   RooAbsMoment* moment(RooRealVar& obs, const RooArgSet& normObs, Int_t order, bool central, bool takeRoot, bool intNormObs) ;
0364 
0365   RooAbsMoment* mean(RooRealVar& obs) { return moment(obs,1,false,false) ; }
0366   RooAbsMoment* mean(RooRealVar& obs, const RooArgSet& nset) { return moment(obs,nset,1,false,false,true) ; }
0367   RooAbsMoment* sigma(RooRealVar& obs) { return moment(obs,2,true,true) ; }
0368   RooAbsMoment* sigma(RooRealVar& obs, const RooArgSet& nset) { return moment(obs,nset,2,true,true,true) ; }
0369 
0370   double findRoot(RooRealVar& x, double xmin, double xmax, double yval) ;
0371 
0372 
0373   virtual bool setData(RooAbsData& /*data*/, bool /*cloneData*/=true) { return true ; }
0374 
0375   virtual void enableOffsetting(bool);
0376   virtual bool isOffsetting() const { return false ; }
0377   virtual double offset() const { return 0 ; }
0378 
0379   static void setHideOffset(bool flag);
0380   static bool hideOffset() ;
0381 
0382   bool isSelectedComp() const ;
0383   void selectComp(bool flag) {
0384      // If flag is true, only selected component will be included in evaluates of RooAddPdf components
0385      _selectComp = flag ;
0386   }
0387 
0388   const RooAbsReal* createPlotProjection(const RooArgSet& depVars, const RooArgSet& projVars, RooArgSet*& cloneSet) const ;
0389   const RooAbsReal *createPlotProjection(const RooArgSet &dependentVars, const RooArgSet *projectedVars,
0390                      RooArgSet *&cloneSet, const char* rangeName=nullptr, const RooArgSet* condObs=nullptr) const;
0391   virtual void doEval(RooFit::EvalContext &) const;
0392 
0393   virtual bool hasGradient() const { return false; }
0394   virtual void gradient(double *) const {
0395     if(!hasGradient()) throw std::runtime_error("RooAbsReal::gradient(double *) not implemented by this class!");
0396   }
0397 
0398   // PlotOn with command list
0399   virtual RooPlot* plotOn(RooPlot* frame, RooLinkedList& cmdList) const ;
0400 
0401 protected:
0402   friend class BatchInterfaceAccessor;
0403   friend class RooVectorDataStore;
0404   friend class RooRealBinding;
0405   friend class RooRealSumPdf;
0406   friend class RooRealSumFunc;
0407   friend class RooAddHelpers;
0408   friend class RooAddPdf;
0409   friend class RooAddModel;
0410   friend class AddCacheElem;
0411   friend class RooFit::EvalContext;
0412 
0413   // Hook for objects with normalization-dependent parameters interpretation
0414   virtual void selectNormalization(const RooArgSet* depSet=nullptr, bool force=false) ;
0415   virtual void selectNormalizationRange(const char* rangeName=nullptr, bool force=false) ;
0416 
0417   // Helper functions for plotting
0418   bool plotSanityChecks(RooPlot* frame) const ;
0419   void makeProjectionSet(const RooAbsArg* plotVar, const RooArgSet* allVars,
0420           RooArgSet& projectedVars, bool silent) const ;
0421 
0422   TString integralNameSuffix(const RooArgSet& iset, const RooArgSet* nset=nullptr, const char* rangeName=nullptr, bool omitEmpty=false) const ;
0423 
0424   void plotOnCompSelect(RooArgSet* selNodes) const ;
0425   RooPlot* plotOnWithErrorBand(RooPlot* frame,const RooFitResult& fr, double Z, const RooArgSet* params, const RooLinkedList& argList, bool method1) const ;
0426 
0427   template<typename... Proxies>
0428   bool matchArgs(const RooArgSet& allDeps, RooArgSet& analDeps, const RooArgProxy& a, const Proxies&... proxies) const
0429   {
0430     TList nameList;
0431     // Fold expression to add all proxy names to the list
0432     nameList.Add(new TObjString(a.absArg()->GetName()));
0433     (nameList.Add(new TObjString(proxies.absArg()->GetName())), ...);
0434 
0435     bool result = matchArgsByName(allDeps, analDeps, nameList);
0436     nameList.Delete(); // Clean up the list contents
0437     return result;
0438   }
0439 
0440   bool matchArgs(const RooArgSet& allDeps, RooArgSet& numDeps,
0441          const RooArgSet& set) const ;
0442 
0443   RooFit::OwningPtr<RooAbsReal> createIntObj(const RooArgSet& iset, const RooArgSet* nset, const RooNumIntConfig* cfg, const char* rangeName) const ;
0444   void findInnerMostIntegration(const RooArgSet& allObs, RooArgSet& innerObs, const char* rangeName) const ;
0445 
0446   // Internal consistency checking (needed by RooDataSet)
0447   /// Check if current value is valid.
0448   bool isValid() const override { return isValidReal(_value); }
0449   /// Interface function to check if given value is a valid value for this object. Returns true unless overridden.
0450   virtual bool isValidReal(double /*value*/, bool printError = false) const { (void)printError; return true; }
0451 
0452   // Function evaluation and error tracing
0453   double traceEval(const RooArgSet* set) const ;
0454 
0455   /// Evaluate this PDF / function / constant. Needs to be overridden by all derived classes.
0456   virtual double evaluate() const = 0;
0457 
0458   // Hooks for RooDataSet interface
0459   void syncCache(const RooArgSet* set=nullptr) override { getVal(set) ; }
0460   void copyCache(const RooAbsArg* source, bool valueOnly=false, bool setValDirty=true) override ;
0461   void attachToTree(TTree& t, Int_t bufSize=32000) override ;
0462   void attachToVStore(RooVectorDataStore& vstore) override ;
0463   void setTreeBranchStatus(TTree& t, bool active) override ;
0464   void fillTreeBranch(TTree& t) override ;
0465 
0466   struct PlotOpt {
0467      Option_t *drawOptions = "L";
0468      double scaleFactor = 1.0;
0469      ScaleType stype = Relative;
0470      const RooAbsData *projData = nullptr;
0471      bool binProjData = false;
0472      const RooArgSet *projSet = nullptr;
0473      double precision = 1e-3;
0474      bool shiftToZero = false;
0475      const RooArgSet *projDataSet = nullptr;
0476      const char *normRangeName = nullptr;
0477      double rangeLo = 0.0;
0478      double rangeHi = 0.0;
0479      bool postRangeFracScale = false;
0480      RooCurve::WingMode wmode = RooCurve::Extended;
0481      const char *projectionRangeName = nullptr;
0482      bool curveInvisible = false;
0483      const char *curveName = nullptr;
0484      const char *addToCurveName = nullptr;
0485      double addToWgtSelf = 1.0;
0486      double addToWgtOther = 1.0;
0487      Int_t numCPU = 1;
0488      RooFit::MPSplit interleave = RooFit::Interleave;
0489      const char *curveNameSuffix = "";
0490      Int_t numee = 10;
0491      double eeval = 0.0;
0492      bool doeeval = false;
0493      bool progress = false;
0494      const RooFitResult *errorFR = nullptr;
0495   };
0496 
0497   // Plot implementation functions
0498   virtual RooPlot *plotOn(RooPlot* frame, PlotOpt o) const;
0499 
0500   virtual RooPlot *plotAsymOn(RooPlot *frame, const RooAbsCategoryLValue& asymCat, PlotOpt o) const;
0501 
0502   bool matchArgsByName(const RooArgSet &allArgs, RooArgSet &matchedArgs, const TList &nameList) const;
0503 
0504   bool redirectServersHook(const RooAbsCollection & newServerList, bool mustReplaceAll,
0505                                    bool nameChange, bool isRecursiveStep) override;
0506 
0507   static void globalSelectComp(bool flag) ;
0508 
0509   // This struct can be used to flip the global switch to select components.
0510   // Doing this with RAII prevents forgetting to reset the state.
0511   struct GlobalSelectComponentRAII {
0512       GlobalSelectComponentRAII(bool state) :
0513       _oldState{_globalSelectComp} {
0514         if (state != RooAbsReal::_globalSelectComp)
0515           RooAbsReal::_globalSelectComp = state;
0516       }
0517 
0518       ~GlobalSelectComponentRAII() {
0519         if (RooAbsReal::_globalSelectComp != _oldState)
0520           RooAbsReal::_globalSelectComp = _oldState;
0521       }
0522 
0523       bool _oldState;
0524   };
0525 
0526 
0527 private:
0528 
0529   /// Debug version of getVal(), which is slow and does error checking.
0530   double _DEBUG_getVal(const RooArgSet* normalisationSet) const;
0531 
0532   //--------------------------------------------------------------------
0533 
0534  protected:
0535 
0536    double _plotMin = 0.0;                                  ///< Minimum of plot range
0537    double _plotMax = 0.0;                                  ///< Maximum of plot range
0538    Int_t _plotBins = 100;                                  ///< Number of plot bins
0539    mutable double _value = 0.0;                            ///< Cache for current value of object
0540    TString _unit;                                          ///< Unit for objects value
0541    TString _label;                                         ///< Plot label for objects value
0542    bool _forceNumInt = false;                              ///< Force numerical integration if flag set
0543    std::unique_ptr<RooNumIntConfig> _specIntegratorConfig; // Numeric integrator configuration specific for this object
0544    TreeReadBuffer *_treeReadBuffer = nullptr;              //! A buffer for reading values from trees
0545    bool _selectComp = true;                                //! Component selection flag for RooAbsPdf::plotCompOn
0546    mutable RooFit::UniqueId<RooArgSet>::Value_t _lastNormSetId = RooFit::UniqueId<RooArgSet>::nullval; ///<!
0547 
0548    static bool _globalSelectComp; // Global activation switch for component selection
0549    static bool _hideOffset;       ///< Offset hiding flag
0550 
0551    ClassDefOverride(RooAbsReal,3); // Abstract real-valued variable
0552 };
0553 
0554 
0555 ////////////////////////////////////////////////////////////////////////////////
0556 /// Overwrite the value stored in this object's cache.
0557 /// This can be used to fake a computation that resulted in `value`.
0558 /// \param[in] value Value to write.
0559 /// \param[in] notifyClients If true, notify users of this object that its value changed.
0560 /// This is the default.
0561 void RooAbsReal::setCachedValue(double value, bool notifyClients) {
0562   _value = value;
0563 
0564   if (notifyClients) {
0565     setValueDirty();
0566     _valueDirty = false;
0567   }
0568 }
0569 
0570 
0571 #endif