File indexing completed on 2025-12-17 10:26:02
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef ROO_PARAMHISTFUNC
0013 #define ROO_PARAMHISTFUNC
0014
0015 #include "RooAbsReal.h"
0016 #include "RooListProxy.h"
0017 #include "RooObjCacheManager.h"
0018 #include "RooDataHist.h"
0019
0020
0021 class RooRealVar;
0022 class RooWorkspace;
0023
0024 class ParamHistFunc : public RooAbsReal {
0025 public:
0026
0027 ParamHistFunc() ;
0028 ParamHistFunc(const char *name, const char *title, const RooArgList& vars, const RooArgList& paramSet );
0029 ParamHistFunc(const char *name, const char *title, const RooArgList& vars, const RooArgList& paramSet, const TH1* hist );
0030
0031 ParamHistFunc(const ParamHistFunc& other, const char *name = nullptr);
0032 TObject* clone(const char* newname=nullptr) const override { return new ParamHistFunc(*this, newname); }
0033
0034 const RooArgList& paramList() const { return _paramSet ; }
0035
0036 Int_t numBins() const { return _dataSet.numEntries(); }
0037
0038 void setParamConst( Int_t, bool=true );
0039 void setConstant(bool constant);
0040
0041 void setShape(TH1* shape);
0042
0043 RooAbsReal& getParameter() const ;
0044 RooAbsReal& getParameter( Int_t masterIdx ) const ;
0045
0046 const RooArgSet* get(Int_t masterIdx) const { return _dataSet.get( masterIdx ) ; }
0047 const RooArgSet* get(const RooArgSet& coord) const { return _dataSet.get( coord ) ; }
0048
0049 RooDataHist const& dataHist() const { return _dataSet; }
0050
0051 double binVolume() const { return _dataSet.binVolume(); }
0052
0053 bool forceAnalyticalInt(const RooAbsArg&) const override { return true ; }
0054
0055 Int_t getAnalyticalIntegralWN(RooArgSet& allVars, RooArgSet& analVars, const RooArgSet* normSet,const char* rangeName=nullptr) const override;
0056 double analyticalIntegralWN(Int_t code, const RooArgSet* normSet, const char* rangeName=nullptr) const override;
0057
0058 static RooArgList createParamSet(RooWorkspace& w, const std::string&, const RooArgList& Vars);
0059 static RooArgList createParamSet(RooWorkspace& w, const std::string&, const RooArgList& Vars, double, double);
0060 static RooArgList createParamSet(const std::string&, Int_t, double, double);
0061
0062 std::list<double>* binBoundaries(RooAbsRealLValue& , double , double ) const override;
0063 std::list<double>* plotSamplingHint(RooAbsRealLValue& obs, double xlo, double xhi) const override;
0064 bool isBinnedDistribution(const RooArgSet& obs) const override { return _dataVars.overlaps(obs); }
0065
0066 const RooArgList& dataVars() const { return _dataVars; }
0067
0068 protected:
0069
0070 class CacheElem : public RooAbsCacheElement {
0071 public:
0072 RooArgList containedArgs(Action) override {
0073 RooArgList ret(_funcIntList) ;
0074 ret.add(_lowIntList);
0075 ret.add(_highIntList);
0076 return ret ;
0077 }
0078 RooArgList _funcIntList ;
0079 RooArgList _lowIntList ;
0080 RooArgList _highIntList ;
0081
0082 } ;
0083 mutable RooObjCacheManager _normIntMgr ;
0084
0085 RooListProxy _dataVars;
0086 RooListProxy _paramSet ;
0087
0088 Int_t _numBins = 0;
0089 struct NumBins {
0090 NumBins() {}
0091 NumBins(int nx, int ny, int nz) : x{nx}, y{ny}, z{nz}, xy{x*y}, xz{x*z}, yz{y*z}, xyz{xy*z} {}
0092 int x = 0;
0093 int y = 0;
0094 int z = 0;
0095 int xy = 0;
0096 int xz = 0;
0097 int yz = 0;
0098 int xyz = 0;
0099 };
0100 mutable NumBins _numBinsPerDim;
0101 mutable RooDataHist _dataSet;
0102
0103 Int_t getCurrentBin() const;
0104 Int_t addParamSet( const RooArgList& params );
0105 static Int_t GetNumBins( const RooArgSet& vars );
0106 double evaluate() const override;
0107 void doEval(RooFit::EvalContext &) const override;
0108
0109 private:
0110 static NumBins getNumBinsPerDim(RooArgSet const& vars);
0111
0112 ClassDefOverride(ParamHistFunc, 7)
0113 };
0114
0115 #endif