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
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
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
0050 bool forceAnalyticalInt(const RooAbsArg& ) 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
0057 return true ;
0058 }
0059
0060 ExtendMode extendMode() const override {
0061
0062 return ((_haveLastCoef&&!_recursive) || _allExtendable) ? MustBeExtended : CanNotBeExtended;
0063 }
0064
0065
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
0072 return _pdfList ;
0073 }
0074 const RooArgList& coefList() const {
0075
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& , double , double ) 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 ;
0105 mutable TNamed* _refCoefRangeName = nullptr ;
0106
0107 mutable std::vector<double> _coefCache;
0108
0109
0110 mutable RooObjCacheManager _projCacheMgr ;
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;
0130
0131 RooListProxy _pdfList ;
0132 RooListProxy _coefList ;
0133 mutable RooArgList* _snormList{nullptr};
0134
0135 bool _haveLastCoef = false;
0136 bool _allExtendable = false;
0137 bool _recursive = false;
0138
0139 mutable Int_t _coefErrCount ;
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)
0154 };
0155
0156 #endif