58using std::endl, std::istream, std::ostream;
96 double clippedValue(
value);
97 bool isInRange(
true) ;
116 if (clippedValPtr) *clippedValPtr=clippedValue ;
125 if(rangeName.empty()) {
130 const double min = binning.
lowBound() ;
139 for(std::size_t i = 0; i < values.size(); ++i) {
140 const double eps = std::max(epsRel * std::abs(values[i]), epsAbs);
141 out[i] = out[i] && ((infiniteMax | (values[i] <= (max+eps))) && (infiniteMin | (values[i] >= (min-eps))));
154 coutI(InputArguments) <<
"RooRealVar::isValid(" <<
GetName() <<
"): value " <<
value <<
" out of range ("
190 inRange(newValue,
nullptr,&clipValue) ;
225 return frame(cmdList) ;
243 pc.
defineMutex(
"Range",
"RangeWithName",
"AutoRange") ;
246 pc.
defineInt(
"rangeSym",
"AutoRange",0,0) ;
265 const char* rangeName=pc.
getString(
"rangeName",
nullptr,
true) ;
275 if (pc.
getInt(
"rangeSym")==0) {
285 double dmean = rangeData->moment(
const_cast<RooRealVar &
>(
static_cast<RooRealVar const&
>(*
this)),1) ;
287 xmin = dmean-ddelta ;
288 xmax = dmean+ddelta ;
299 const char* title = pc.
getString(
"title",
nullptr,
true) ;
323 return new RooPlot(*
this,xlo,xhi,nbins);
353 coutE(InputArguments) <<
"RooAbsRealLValue::frame(" <<
GetName() <<
") ERROR: empty fit range, must specify plot range" << endl ;
357 coutE(InputArguments) <<
"RooAbsRealLValue::frame(" <<
GetName() <<
") ERROR: open ended fit range, must specify plot range" << endl ;
378 coutE(InputArguments) <<
"RooAbsRealLValue::frame(" <<
GetName() <<
") ERROR: empty fit range, must specify plot range" << endl ;
382 coutE(InputArguments) <<
"RooAbsRealLValue::frame(" <<
GetName() <<
") ERROR: open ended fit range, must specify plot range" << endl ;
407 os <<
indent <<
"--- RooAbsRealLValue ---" << endl;
410 os <<
indent <<
" Fit range is [ ";
412 os <<
getMin() << unit <<
" , ";
418 os <<
getMax() << unit <<
" ]" << endl;
421 os <<
"+INF ]" << endl;
441 coutE(Generation) <<
fName <<
"::" <<
ClassName() <<
":randomize: fails with unbounded fit range" << endl;
454 if (ibin<0 || ibin>=
numBins(rangeName)) {
455 coutE(InputArguments) <<
"RooAbsRealLValue::setBin(" <<
GetName() <<
") ERROR: bin index " << ibin
456 <<
" is out of range (0," <<
getBins(rangeName)-1 <<
")" << endl ;
516 const double val =
getVal() ;
519 const auto minMax =
getRange(
nullptr);
520 return minMax.first - epsilon <= val && val <= minMax.second + epsilon;
524 return std::any_of(ranges.begin(), ranges.end(), [val,epsilon,
this](
const std::string& range){
525 const auto minMax = this->getRange(range.c_str());
526 return minMax.first - epsilon <= val && val <= minMax.second + epsilon;
564 return createHistogram(
name,
l) ;
591 pc.
defineString(
"ybinningName",
"YVar::BinningName",0,
"") ;
592 pc.
defineInt(
"nybins",
"YVar::BinningSpec",0) ;
598 pc.
defineString(
"zbinningName",
"ZVar::BinningName",0,
"") ;
599 pc.
defineInt(
"nzbins",
"ZVar::BinningSpec",0) ;
614 const char* axisLabel = pc.
getString(
"axisLabel") ;
616 bool ownBinning[3] = {
false,
false,
false } ;
629 ownBinning[0] = true ;
645 ownBinning[1] = true ;
662 ownBinning[2] = true ;
671 if (ownBinning[0])
delete binning[0] ;
672 if (ownBinning[1])
delete binning[1] ;
673 if (ownBinning[2])
delete binning[2] ;
691 coutE(InputArguments) <<
"RooAbsRealLValue::createHistogram(" <<
GetName()
692 <<
") ERROR: fit range empty or open ended, must explicitly specify range" << endl ;
746 double* xlo,
double* xhi,
Int_t* nBins)
const
748 if ((!xlo && xhi) || (xlo && !xhi)) {
749 coutE(InputArguments) <<
"RooAbsRealLValue::createHistogram(" <<
GetName()
750 <<
") ERROR must specify either no range, or both limits" << endl ;
760 Int_t *nBins2 = nBins;
765 coutE(InputArguments) <<
"RooAbsRealLValue::createHistogram(" <<
GetName()
766 <<
") ERROR: fit range empty or open ended, must explicitly specify range" << endl ;
770 coutE(InputArguments) <<
"RooAbsRealLValue::createHistogram(" <<
GetName()
771 <<
") ERROR: fit range of " << yvar.
GetName() <<
" empty or open ended, must explicitly specify range" << endl ;
778 xlo_fit[1] = yvar.
getMin() ;
779 xhi_fit[1] = yvar.
getMax() ;
787 nbins_fit[1] = yvar.
getBins() ;
820 const char *tAxisLabel,
double* xlo,
double* xhi,
Int_t* nBins)
const
822 if ((!xlo && xhi) || (xlo && !xhi)) {
823 coutE(InputArguments) <<
"RooAbsRealLValue::createHistogram(" <<
GetName()
824 <<
") ERROR must specify either no range, or both limits" << endl ;
834 Int_t* nBins2 = nBins;
838 coutE(InputArguments) <<
"RooAbsRealLValue::createHistogram(" <<
GetName()
839 <<
") ERROR: fit range empty or open ended, must explicitly specify range" << endl ;
843 coutE(InputArguments) <<
"RooAbsRealLValue::createHistogram(" <<
GetName()
844 <<
") ERROR: fit range of " << yvar.
GetName() <<
" empty or open ended, must explicitly specify range" << endl ;
848 coutE(InputArguments) <<
"RooAbsRealLValue::createHistogram(" <<
GetName()
849 <<
") ERROR: fit range of " << zvar.
GetName() <<
" empty or open ended, must explicitly specify range" << endl ;
856 xlo_fit[1] = yvar.
getMin() ;
857 xhi_fit[1] = yvar.
getMax() ;
859 xlo_fit[2] = zvar.
getMin() ;
860 xhi_fit[2] = zvar.
getMax() ;
868 nbins_fit[1] = yvar.
getBins() ;
869 nbins_fit[2] = zvar.
getBins() ;
898 double* xlo,
double* xhi,
Int_t* nBins)
908 if (bin[0])
delete bin[0] ;
909 if (bin[1])
delete bin[1] ;
910 if (bin[2])
delete bin[2] ;
927 if(dim < 1 || dim > 3) {
928 oocoutE(
nullptr,InputArguments) <<
"RooAbsReal::createHistogram: dimension not supported: " << dim << endl;
942 oocoutE(
nullptr,InputArguments) <<
"RooAbsRealLValue::createHistogram: variable is not real lvalue: " << arg->
GetName() << endl;
949 histTitle.
Prepend(
"Histogram of ");
952 TH1 *histogram =
nullptr;
955 if (bins[0]->isUniform()) {
964 if (bins[0]->isUniform() && bins[1]->isUniform()) {
975 if (bins[0]->isUniform() && bins[1]->isUniform() && bins[2]->isUniform()) {
989 oocoutE(
nullptr,InputArguments) <<
"RooAbsReal::createHistogram: unable to create a new histogram" << endl;
1013 if((
nullptr != tAxisLabel) && (0 != strlen(tAxisLabel))) {
1014 TString axisTitle(tAxisLabel);
1015 axisTitle.
Append(
" / ( ");
1016 for(
Int_t index2= 0; index2 < dim; index2++) {
1018 if(index2 > 0) axisTitle.
Append(
" x ");
1020 if(strlen(xyz[index2]->
getUnit())) {
1058 std::stringstream errStream;
1059 errStream <<
"Attempting to integrate the " <<
ClassName() <<
" \"" <<
GetName()
1060 <<
"\", but integrating a RooAbsRealLValue is not allowed!";
1061 const std::string errString = errStream.str();
1062 coutE(InputArguments) << errString << std::endl;
1063 throw std::runtime_error(errString);
static void indent(ostringstream &buf, int indent_level)
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Common abstract base class for objects that represent a value and a "shape" in RooFit.
Abstract base class for RooRealVar binning definitions.
virtual double binCenter(Int_t bin) const =0
Int_t numBins() const
Return number of bins.
virtual double averageBinWidth() const =0
virtual double highBound() const =0
virtual double lowBound() const =0
virtual double * array() const =0
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
Storage_t::size_type size() const
Abstract base class for binned and unbinned datasets.
bool getRange(const RooAbsRealLValue &var, double &lowest, double &highest, double marginFrac=0.0, bool symMode=false) const
Fill Doubles 'lowest' and 'highest' with the lowest and highest value of observable 'var' in this dat...
Abstract base class for objects that are lvalues, i.e.
Abstract base class for objects that represent a real value that may appear on the left hand side of ...
Int_t numBins(const char *rangeName=nullptr) const override
virtual Int_t getBins(const char *name=nullptr) const
Get number of bins of currently defined range.
RooFit::OwningPtr< RooAbsReal > createIntegral(const RooArgSet &iset, const RooArgSet *nset=nullptr, const RooNumIntConfig *cfg=nullptr, const char *rangeName=nullptr) const override
Create an object that represents the integral of the function over one or more observables listed in ...
virtual void setValFast(double value)
bool isValidReal(double value, bool printError=false) const override
Check if given value is valid.
virtual const RooAbsBinning & getBinning(const char *name=nullptr, bool verbose=true, bool createOnTheFly=false) const =0
Retrieve binning configuration with given name or default binning.
virtual bool isJacobianOK(const RooArgSet &depList) const
virtual double getMax(const char *name=nullptr) const
Get maximum of currently defined range.
RooPlot * frame() const
Create a new RooPlot on the heap with a drawing frame initialized for this object,...
bool hasMax(const char *name=nullptr) const
Check if variable has an upper bound.
void copyCache(const RooAbsArg *source, bool valueOnly=false, bool setValDirty=true) override
Copy cache of another RooAbsArg to our cache.
bool fitRangeOKForPlotting() const
Check if fit range is usable as plot range, i.e.
void setBin(Int_t ibin, const char *rangeName=nullptr) override
Set value to center of bin 'ibin' of binning 'rangeName' (or of default binning if no range is specif...
void writeToStream(std::ostream &os, bool compact) const override
Write object contents to given stream.
void randomize(const char *rangeName=nullptr) override
Set a new value sampled from a uniform distribution over the fit range.
TH1 * createHistogram(const char *name, const RooCmdArg &arg1={}, const RooCmdArg &arg2={}, const RooCmdArg &arg3={}, const RooCmdArg &arg4={}, const RooCmdArg &arg5={}, const RooCmdArg &arg6={}, const RooCmdArg &arg7={}, const RooCmdArg &arg8={}) const
virtual void setVal(double value)=0
Set the current value of the object. Needs to be overridden by implementations.
virtual double getMin(const char *name=nullptr) const
Get minimum of currently defined range.
bool readFromStream(std::istream &is, bool compact, bool verbose=false) override
Read object contents from given stream.
RooPlot * frame(const RooCmdArg &arg1, const RooCmdArg &arg2={}, const RooCmdArg &arg3={}, const RooCmdArg &arg4={}, const RooCmdArg &arg5={}, const RooCmdArg &arg6={}, const RooCmdArg &arg7={}, const RooCmdArg &arg8={}) const
Create a new RooPlot on the heap with a drawing frame initialized for this object,...
bool inRange(const char *name) const override
Check if current value is inside range with given name.
void printMultiline(std::ostream &os, Int_t contents, bool verbose=false, TString indent="") const override
Structure printing.
std::pair< double, double > getRange(const char *name=nullptr) const
Get low and high bound of the variable.
virtual RooAbsArg & operator=(double newValue)
Assignment operator from a double.
bool hasMin(const char *name=nullptr) const
Check if variable has a lower bound.
Abstract base class for objects that represent a real value and implements functionality common to al...
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
TString _unit
Unit for objects value.
void printMultiline(std::ostream &os, Int_t contents, bool verbose=false, TString indent="") const override
Structure printing.
void copyCache(const RooAbsArg *source, bool valueOnly=false, bool setValDirty=true) override
Copy the cached value of another RooAbsArg to our cache.
double _value
Cache for current value of object.
TString getTitle(bool appendUnit=false) const
Return this variable's title string.
const Text_t * getUnit() const
RooArgList is a container object that can hold multiple RooAbsArg objects.
RooAbsArg * at(Int_t idx) const
Return object at given index, or nullptr if index is out of range.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Named container for two doubles, two integers two object points and three string pointers that can be...
Configurable parser for RooCmdArg named arguments.
void defineMutex(const char *head, Args_t &&... tail)
Define arguments where any pair is mutually exclusive.
bool process(const RooCmdArg &arg)
Process given RooCmdArg.
bool hasProcessed(const char *cmdName) const
Return true if RooCmdArg with name 'cmdName' has been processed.
double getDouble(const char *name, double defaultValue=0.0) const
Return double property registered with name 'name'.
void defineDependency(const char *refArgName, const char *neededArgName)
Define that processing argument name refArgName requires processing of argument named neededArgName t...
bool defineDouble(const char *name, const char *argName, int doubleNum, double defValue=0.0)
Define double property name 'name' mapped to double in slot 'doubleNum' in RooCmdArg with name argNam...
bool ok(bool verbose) const
Return true of parsing was successful.
bool defineObject(const char *name, const char *argName, int setNum, const TObject *obj=nullptr, bool isArray=false)
Define TObject property name 'name' mapped to object in slot 'setNum' in RooCmdArg with name argName ...
const char * getString(const char *name, const char *defaultValue="", bool convEmptyToNull=false) const
Return string property registered with name 'name'.
bool defineString(const char *name, const char *argName, int stringNum, const char *defValue="", bool appendMode=false)
Define double property name 'name' mapped to double in slot 'stringNum' in RooCmdArg with name argNam...
bool defineInt(const char *name, const char *argName, int intNum, int defValue=0)
Define integer property name 'name' mapped to integer in slot 'intNum' in RooCmdArg with name argName...
int getInt(const char *name, int defaultValue=0) const
Return integer property registered with name 'name'.
TObject * getObject(const char *name, TObject *obj=nullptr) const
Return TObject property registered with name 'name'.
Collection class for internal use, storing a collection of RooAbsArg pointers in a doubly linked list...
virtual void Add(TObject *arg)
Holds the configuration parameters of the various numeric integrators used by RooRealIntegral.
static double rangeEpsRel()
Get the relative epsilon that is used by range checks in RooFit, e.g., in RooAbsRealLValue::inRange()...
static double rangeEpsAbs()
Get the absolute epsilon that is used by range checks in RooFit, e.g., in RooAbsRealLValue::inRange()...
static constexpr int isInfinite(double x)
Return true if x is infinite by RooNumber internal specification.
Plot frame and a container for graphics objects within that frame.
void SetName(const char *name) override
Set the name of the RooPlot to 'name'.
void SetTitle(const char *name) override
Set the title of the RooPlot to 'title'.
static double uniform(TRandom *generator=randomGenerator())
Return a number uniformly distributed from (0,1)
Variable that can be changed from the outside.
1-D histogram with a float per channel (see TH1 documentation)
TH1 is the base class of all histogram classes in ROOT.
virtual void SetXTitle(const char *title)
virtual void SetZTitle(const char *title)
virtual void SetYTitle(const char *title)
2-D histogram with a float per channel (see TH1 documentation)
3-D histogram with a float per channel (see TH1 documentation)
const char * GetName() const override
Returns name of object.
Mother of all ROOT objects.
virtual const char * ClassName() const
Returns name of class to which the object belongs.
const char * Data() const
TString & Prepend(const char *cs)
TString & Append(const char *cs)
std::vector< std::string > Split(std::string_view str, std::string_view delims, bool skipEmpty=false)
Splits a string at each character in delims.
T * OwningPtr
An alias for raw pointers for indicating that the return type of a RooFit function is an owning point...