Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/RooAddPdf.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: RooAddPdf.h,v 1.46 2007/07/12 20:30:28 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_ADD_PDF
0017 #define ROO_ADD_PDF
0018 
0019 #include "RooAbsPdf.h"
0020 #include "RooListProxy.h"
0021 #include "RooSetProxy.h"
0022 #include "RooAICRegistry.h"
0023 #include "RooObjCacheManager.h"
0024 #include "RooNameReg.h"
0025 #include "RooTrace.h"
0026 
0027 #include <vector>
0028 #include <list>
0029 #include <utility>
0030 
0031 class AddCacheElem;
0032 
0033 class RooAddPdf : public RooAbsPdf {
0034 public:
0035 
0036   RooAddPdf() : _projCacheMgr(this,10) { TRACE_CREATE; }
0037   RooAddPdf(const char *name, const char *title=nullptr);
0038   RooAddPdf(const char *name, const char *title,
0039             RooAbsPdf& pdf1, RooAbsPdf& pdf2, RooAbsReal& coef1) ;
0040   RooAddPdf(const char *name, const char *title, const RooArgList& pdfList) ;
0041   RooAddPdf(const char *name, const char *title, const RooArgList& pdfList, const RooArgList& coefList, bool recursiveFraction=false) ;
0042 
0043   RooAddPdf(const RooAddPdf& other, const char* name=nullptr) ;
0044   TObject* clone(const char* newname) const override { return new RooAddPdf(*this,newname) ; }
0045   ~RooAddPdf() override { TRACE_DESTROY; }
0046 
0047   bool checkObservables(const RooArgSet* nset) const override;
0048 
0049   /// Force RooRealIntegral to offer all observables for internal integration.
0050   bool forceAnalyticalInt(const RooAbsArg& /*dep*/) const override {
0051     return true ;
0052   }
0053   Int_t getAnalyticalIntegralWN(RooArgSet& allVars, RooArgSet& numVars, const RooArgSet* normSet, const char* rangeName=nullptr) const override;
0054   double analyticalIntegralWN(Int_t code, const RooArgSet* normSet, const char* rangeName=nullptr) const override;
0055   bool selfNormalized() const override {
0056     // P.d.f is self normalized
0057     return true ;
0058   }
0059 
0060   ExtendMode extendMode() const override {
0061     // Return extended mode capabilities
0062     return ((_haveLastCoef&&!_recursive) || _allExtendable) ? MustBeExtended : CanNotBeExtended;
0063   }
0064   /// Return expected number of events for extended likelihood calculation, which
0065   /// is the sum of all coefficients.
0066   double expectedEvents(const RooArgSet* nset) const override;
0067 
0068   std::unique_ptr<RooAbsReal> createExpectedEventsFunc(const RooArgSet* nset) const override;
0069 
0070   const RooArgList& pdfList() const {
0071     // Return list of component p.d.fs
0072     return _pdfList ;
0073   }
0074   const RooArgList& coefList() const {
0075     // Return list of coefficients of component p.d.f.s
0076     return _coefList ;
0077   }
0078 
0079   void fixCoefNormalization(const RooArgSet& refCoefNorm) ;
0080   void fixCoefRange(const char* rangeName) ;
0081 
0082   const RooArgSet& getCoefNormalization() const;
0083   const char* getCoefRange() const { return _refCoefRangeName?RooNameReg::str(_refCoefRangeName):"" ; }
0084 
0085   void resetErrorCounters(Int_t resetValue=10) override;
0086 
0087   std::list<double>* plotSamplingHint(RooAbsRealLValue& obs, double xlo, double xhi) const override;
0088   std::list<double>* binBoundaries(RooAbsRealLValue& /*obs*/, double /*xlo*/, double /*xhi*/) const override;
0089   bool isBinnedDistribution(const RooArgSet& obs) const override;
0090 
0091   void printMetaArgs(std::ostream& os) const override;
0092 
0093   CacheMode canNodeBeCached() const override { return RooAbsArg::NotAdvised ; };
0094   void setCacheAndTrackHints(RooArgSet&) override;
0095 
0096   void translate(RooFit::Detail::CodeSquashContext &ctx) const override;
0097 
0098   std::unique_ptr<RooAbsArg> compileForNormSet(RooArgSet const &normSet, RooFit::Detail::CompileContext & ctx) const override;
0099 
0100   protected:
0101   void selectNormalization(const RooArgSet* depSet=nullptr, bool force=false) override;
0102   void selectNormalizationRange(const char* rangeName=nullptr, bool force=false) override;
0103 
0104   mutable RooSetProxy _refCoefNorm ;   ///< Reference observable set for coefficient interpretation
0105   mutable TNamed* _refCoefRangeName = nullptr ;  ///< Reference range name for coefficient interpretation
0106 
0107   mutable std::vector<double> _coefCache; ///<! Transient cache with transformed values of coefficients
0108 
0109 
0110   mutable RooObjCacheManager _projCacheMgr ;  //! Manager of cache with coefficient projections and transformations
0111   AddCacheElem* getProjCache(const RooArgSet* nset, const RooArgSet* iset=nullptr) const ;
0112   void updateCoefficients(AddCacheElem& cache, const RooArgSet* nset, bool syncCoefValues=true) const ;
0113 
0114 
0115   friend class RooAddGenContext ;
0116   friend class RooAddModel ;
0117   RooAbsGenContext* genContext(const RooArgSet &vars, const RooDataSet *prototype=nullptr,
0118                                const RooArgSet* auxProto=nullptr, bool verbose= false) const override;
0119 
0120 
0121   double evaluate() const override {
0122       return getValV(nullptr);
0123   }
0124   double getValV(const RooArgSet* set=nullptr) const override ;
0125   void doEval(RooFit::EvalContext &) const override;
0126   inline bool canComputeBatchWithCuda() const override { return true; }
0127 
0128 
0129   mutable RooAICRegistry _codeReg; ///<! Registry of component analytical integration codes
0130 
0131   RooListProxy _pdfList ;   ///<  List of component PDFs
0132   RooListProxy _coefList ;  ///<  List of coefficients
0133   mutable RooArgList* _snormList{nullptr};  ///<!  List of supplemental normalization factors
0134 
0135   bool _haveLastCoef = false;  ///<  Flag indicating if last PDFs coefficient was supplied in the constructor
0136   bool _allExtendable = false; ///<  Flag indicating if all PDF components are extendable
0137   bool _recursive = false;     ///<  Flag indicating is fractions are treated recursively
0138 
0139   mutable Int_t _coefErrCount ; ///<! Coefficient error counter
0140 
0141   bool redirectServersHook(const RooAbsCollection&, bool, bool, bool) override;
0142 
0143 private:
0144   std::pair<const RooArgSet*, AddCacheElem*> getNormAndCache(const RooArgSet* nset) const;
0145   mutable RooFit::UniqueId<RooArgSet>::Value_t _idOfLastUsedNormSet = RooFit::UniqueId<RooArgSet>::nullval; ///<!
0146   mutable std::unique_ptr<const RooArgSet> _copyOfLastNormSet = nullptr; ///<!
0147 
0148   void finalizeConstruction();
0149   void materializeRefCoefNormFromAttribute() const;
0150   inline void setRecursiveFraction(bool recursiveFraction) { _recursive = recursiveFraction; }
0151   inline void setAllExtendable(bool allExtendable) { _allExtendable = allExtendable; }
0152 
0153   ClassDefOverride(RooAddPdf,5) // PDF representing a sum of PDFs
0154 };
0155 
0156 #endif