File indexing completed on 2025-01-18 10:11:23
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #ifndef ROO_HIST_FUNC
0017 #define ROO_HIST_FUNC
0018
0019 #include "RooAbsReal.h"
0020 #include "RooRealProxy.h"
0021 #include "RooSetProxy.h"
0022 #include "RooAICRegistry.h"
0023 #include "RooTrace.h"
0024 #include "RooDataHist.h"
0025
0026 #include <list>
0027
0028 class RooRealVar;
0029 class RooAbsReal;
0030
0031 class RooHistFunc : public RooAbsReal {
0032 public:
0033 RooHistFunc() {}
0034 RooHistFunc(const char *name, const char *title, const RooArgSet& vars, const RooDataHist& dhist, Int_t intOrder=0);
0035 RooHistFunc(const char *name, const char *title, const RooArgList& funcObs, const RooArgList& histObs, const RooDataHist& dhist, Int_t intOrder=0);
0036 RooHistFunc(const char *name, const char *title, const RooArgSet& vars,
0037 std::unique_ptr<RooDataHist> dhist, int intOrder=0);
0038 RooHistFunc(const char *name, const char *title, const RooArgList& pdfObs, const RooArgList& histObs,
0039 std::unique_ptr<RooDataHist> dhist, int intOrder=0);
0040 RooHistFunc(const RooHistFunc& other, const char* name=nullptr);
0041 TObject* clone(const char* newname) const override { return new RooHistFunc(*this,newname); }
0042 ~RooHistFunc() override ;
0043
0044
0045 RooDataHist& dataHist() {
0046 return *_dataHist ;
0047 }
0048
0049
0050 const RooDataHist& dataHist() const {
0051 return *_dataHist ;
0052 }
0053
0054
0055
0056 RooDataHist* cloneAndOwnDataHist(const char* newname="");
0057
0058
0059
0060 double totVolume() const;
0061
0062
0063 void setInterpolationOrder(Int_t order) {
0064
0065 _intOrder = order ;
0066 }
0067
0068
0069 Int_t getInterpolationOrder() const {
0070
0071 return _intOrder ;
0072 }
0073
0074 Int_t getAnalyticalIntegral(RooArgSet& allVars, RooArgSet& analVars, const char* rangeName=nullptr) const override ;
0075 double analyticalIntegral(Int_t code, const char* rangeName=nullptr) const override ;
0076
0077 bool forceAnalyticalInt(const RooAbsArg& dep) const override;
0078
0079
0080 void setCdfBoundaries(bool flag) {
0081 _cdfBoundaries = flag ;
0082 }
0083
0084
0085 bool getCdfBoundaries() const {
0086
0087 return _cdfBoundaries ;
0088 }
0089
0090 Int_t getMaxVal(const RooArgSet& vars) const override;
0091 double maxVal(Int_t code) const override;
0092
0093 std::list<double>* binBoundaries(RooAbsRealLValue& , double , double ) const override ;
0094 std::list<double>* plotSamplingHint(RooAbsRealLValue& obs, double xlo, double xhi) const override ;
0095 bool isBinnedDistribution(const RooArgSet&) const override { return _intOrder==0 ; }
0096 RooArgSet const& getHistObsList() const { return _histObsList; }
0097
0098
0099 Int_t getBin() const;
0100 std::vector<Int_t> getBins(RooFit::EvalContext & ctx) const;
0101
0102 void translate(RooFit::Detail::CodeSquashContext &ctx) const override;
0103 std::string
0104 buildCallToAnalyticIntegral(int code, const char *rangeName, RooFit::Detail::CodeSquashContext &ctx) const override;
0105
0106 RooArgSet const &variables() const { return _depList; }
0107
0108 protected:
0109
0110 bool importWorkspaceHook(RooWorkspace& ws) override ;
0111 bool areIdentical(const RooDataHist& dh1, const RooDataHist& dh2) ;
0112
0113 double evaluate() const override;
0114 void doEval(RooFit::EvalContext &) const override;
0115 friend class RooAbsCachedReal ;
0116
0117 void ioStreamerPass2() override ;
0118
0119 RooArgSet _histObsList;
0120 RooSetProxy _depList;
0121 RooDataHist* _dataHist = nullptr;
0122 std::unique_ptr<RooDataHist> _ownedDataHist;
0123 mutable RooAICRegistry _codeReg;
0124 Int_t _intOrder = 0;
0125 bool _cdfBoundaries = false;
0126 mutable double _totVolume = 0.0;
0127 bool _unitNorm = false;
0128
0129 private:
0130 inline void initializeOwnedDataHist(std::unique_ptr<RooDataHist> &&dataHist)
0131 {
0132 _ownedDataHist = std::move(dataHist);
0133 }
0134
0135 ClassDefOverride(RooHistFunc,2)
0136 };
0137
0138 #endif