File indexing completed on 2025-01-18 10:11:18
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #ifndef ROO_ABS_REAL_LVALUE
0017 #define ROO_ABS_REAL_LVALUE
0018
0019 #include <cmath>
0020 #include <cfloat>
0021 #include <utility>
0022 #include "TString.h"
0023
0024 #include "RooAbsReal.h"
0025 #include "RooNumber.h"
0026 #include "RooAbsLValue.h"
0027 #include "RooAbsBinning.h"
0028
0029 class RooArgSet ;
0030
0031 class RooAbsRealLValue : public RooAbsReal, public RooAbsLValue {
0032 public:
0033
0034 inline RooAbsRealLValue() { }
0035 RooAbsRealLValue(const char *name, const char *title, const char *unit= "") ;
0036 RooAbsRealLValue(const RooAbsRealLValue& other, const char* name=nullptr);
0037
0038
0039
0040 virtual void setVal(double value)=0;
0041
0042
0043 virtual void setVal(double value, const char* ) {
0044 return setVal(value) ;
0045 }
0046 virtual RooAbsArg& operator=(double newValue);
0047
0048
0049 void setBin(Int_t ibin, const char* rangeName=nullptr) override ;
0050 Int_t getBin(const char* rangeName=nullptr) const override { return getBinning(rangeName).binNumber(getVal()) ; }
0051 Int_t numBins(const char* rangeName=nullptr) const override { return getBins(rangeName) ; }
0052 double getBinWidth(Int_t i, const char* rangeName=nullptr) const override { return getBinning(rangeName).binWidth(i) ; }
0053 double volume(const char* rangeName) const override { return getMax(rangeName)-getMin(rangeName) ; }
0054 void randomize(const char* rangeName=nullptr) override;
0055
0056 const RooAbsBinning* getBinningPtr(const char* rangeName) const override { return &getBinning(rangeName) ; }
0057 Int_t getBin(const RooAbsBinning* ptr) const override { return ptr->binNumber(getVal()) ; }
0058
0059 virtual void setBin(Int_t ibin, const RooAbsBinning& binning) ;
0060 virtual Int_t getBin(const RooAbsBinning& binning) const { return binning.binNumber(getVal()) ; }
0061 virtual Int_t numBins(const RooAbsBinning& binning) const { return binning.numBins() ; }
0062 virtual double getBinWidth(Int_t i, const RooAbsBinning& binning) const { return binning.binWidth(i) ; }
0063 virtual double volume(const RooAbsBinning& binning) const { return binning.highBound() - binning.lowBound() ; }
0064 virtual void randomize(const RooAbsBinning& binning) ;
0065
0066
0067
0068
0069
0070 virtual const RooAbsBinning& getBinning(const char* name=nullptr, bool verbose=true, bool createOnTheFly=false) const = 0 ;
0071
0072 virtual RooAbsBinning& getBinning(const char* name=nullptr, bool verbose=true, bool createOnTheFly=false) = 0 ;
0073
0074 virtual bool hasBinning(const char* name) const = 0 ;
0075 bool inRange(const char* name) const override ;
0076
0077
0078 virtual Int_t getBins(const char* name=nullptr) const { return getBinning(name).numBins(); }
0079
0080
0081 virtual double getMin(const char* name=nullptr) const { return getBinning(name).lowBound(); }
0082
0083
0084 virtual double getMax(const char* name=nullptr) const { return getBinning(name).highBound(); }
0085
0086
0087
0088 std::pair<double, double> getRange(const char* name = nullptr) const {
0089 const auto& binning = getBinning(name);
0090 return {binning.lowBound(), binning.highBound()};
0091 }
0092
0093 inline bool hasMin(const char* name=nullptr) const { return !RooNumber::isInfinite(getMin(name)); }
0094
0095 inline bool hasMax(const char* name=nullptr) const { return !RooNumber::isInfinite(getMax(name)); }
0096
0097 bool hasRange(const char* name) const override { return hasBinning(name) ; }
0098
0099
0100 virtual bool isJacobianOK(const RooArgSet& depList) const ;
0101 virtual double jacobian() const { return 1 ; }
0102
0103 inline bool isLValue() const override { return true; }
0104
0105
0106 bool inRange(double value, const char* rangeName, double* clippedValue=nullptr) const;
0107 void inRange(std::span<const double> values, std::string const& rangeName, std::vector<bool>& out) const;
0108 bool isValidReal(double value, bool printError=false) const override ;
0109
0110
0111 inline void setConstant(bool value= true) { setAttribute("Constant",value); setValueDirty() ; setShapeDirty() ; }
0112
0113
0114 bool readFromStream(std::istream& is, bool compact, bool verbose=false) override ;
0115 void writeToStream(std::ostream& os, bool compact) const override ;
0116
0117
0118 void printMultiline(std::ostream& os, Int_t contents, bool verbose=false, TString indent="") const override ;
0119
0120
0121
0122 RooPlot* frame(const RooCmdArg& arg1, const RooCmdArg& arg2={},
0123 const RooCmdArg& arg3={}, const RooCmdArg& arg4={}, const RooCmdArg& arg5={},
0124 const RooCmdArg& arg6={}, const RooCmdArg& arg7={}, const RooCmdArg& arg8={}) const ;
0125 RooPlot *frame(const RooLinkedList& cmdList) const ;
0126 RooPlot *frame(double lo, double hi, Int_t nbins) const;
0127 RooPlot *frame(double lo, double hi) const;
0128 RooPlot *frame(Int_t nbins) const;
0129 RooPlot *frame() const;
0130
0131
0132 TH1 *createHistogram(const char *name,
0133 const RooCmdArg& arg1={}, const RooCmdArg& arg2={},
0134 const RooCmdArg& arg3={}, const RooCmdArg& arg4={},
0135 const RooCmdArg& arg5={}, const RooCmdArg& arg6={},
0136 const RooCmdArg& arg7={}, const RooCmdArg& arg8={}) const ;
0137 TH1 *createHistogram(const char *name, const RooLinkedList& cmdList) const ;
0138
0139 TH1F *createHistogram(const char *name, const char *yAxisLabel) const ;
0140 TH1F *createHistogram(const char *name, const char *yAxisLabel, double xlo, double xhi, Int_t nBins) const ;
0141 TH1F *createHistogram(const char *name, const char *yAxisLabel, const RooAbsBinning& bins) const ;
0142
0143 TH2F *createHistogram(const char *name, const RooAbsRealLValue &yvar, const char *zAxisLabel=nullptr,
0144 double* xlo=nullptr, double* xhi=nullptr, Int_t* nBins=nullptr) const ;
0145 TH2F *createHistogram(const char *name, const RooAbsRealLValue &yvar, const char *zAxisLabel, const RooAbsBinning** bins) const ;
0146
0147
0148 TH3F *createHistogram(const char *name, const RooAbsRealLValue &yvar, const RooAbsRealLValue &zvar,
0149 const char *tAxisLabel, double* xlo=nullptr, double* xhi=nullptr, Int_t* nBins=nullptr) const ;
0150 TH3F *createHistogram(const char *name, const RooAbsRealLValue &yvar, const RooAbsRealLValue &zvar, const char* tAxisLabel, const RooAbsBinning** bins) const ;
0151
0152 static TH1* createHistogram(const char *name, RooArgList &vars, const char *tAxisLabel, double* xlo, double* xhi, Int_t* nBins) ;
0153 static TH1* createHistogram(const char *name, RooArgList &vars, const char *tAxisLabel, const RooAbsBinning** bins) ;
0154
0155 RooFit::OwningPtr<RooAbsReal> createIntegral(const RooArgSet& iset, const RooArgSet* nset=nullptr, const RooNumIntConfig* cfg=nullptr, const char* rangeName=nullptr) const override;
0156
0157 protected:
0158
0159 virtual void setValFast(double value) { setVal(value) ; }
0160
0161 bool fitRangeOKForPlotting() const ;
0162 void copyCache(const RooAbsArg* source, bool valueOnly=false, bool setValDirty=true) override ;
0163
0164 ClassDefOverride(RooAbsRealLValue,1)
0165 };
0166
0167 #endif