106 double clippedValue(
value);
107 bool isInRange(
true) ;
126 if (clippedValPtr) *clippedValPtr=clippedValue ;
135 if(rangeName.empty()) {
140 const double min = binning.
lowBound() ;
149 for(std::size_t i = 0; i < values.size(); ++i) {
150 const double eps = std::max(epsRel *
std::abs(values[i]), epsAbs);
151 out[i] = out[i] && ((infiniteMax | (values[i] <= (max+eps))) && (infiniteMin | (values[i] >= (min-eps))));
165 <<
" out of range (" <<
getMin() <<
" - " <<
getMax() <<
")" << endl ;
199 inRange(newValue,0,&clipValue) ;
234 return frame(cmdList) ;
246 pc.defineDouble(
"min",
"Range",0,
getMin()) ;
247 pc.defineDouble(
"max",
"Range",1,
getMax()) ;
248 pc.defineInt(
"nbins",
"Bins",0,
getBins()) ;
249 pc.defineString(
"rangeName",
"RangeWithName",0,
"") ;
250 pc.defineString(
"name",
"Name",0,
"") ;
251 pc.defineString(
"title",
"Title",0,
"") ;
252 pc.defineMutex(
"Range",
"RangeWithName",
"AutoRange") ;
253 pc.defineObject(
"rangeData",
"AutoRange",0,0) ;
254 pc.defineDouble(
"rangeMargin",
"AutoRange",0,0.1) ;
255 pc.defineInt(
"rangeSym",
"AutoRange",0,0) ;
258 pc.process(cmdList) ;
265 if (
pc.hasProcessed(
"Range")) {
266 xmin =
pc.getDouble(
"min") ;
267 xmax =
pc.getDouble(
"max") ;
272 }
else if (
pc.hasProcessed(
"RangeWithName")) {
273 const char* rangeName=
pc.getString(
"rangeName",0,
true) ;
276 }
else if (
pc.hasProcessed(
"AutoRange")) {
277 auto rangeData =
static_cast<RooAbsData*
>(
pc.getObject(
"rangeData")) ;
283 if (
pc.getInt(
"rangeSym")==0) {
285 double margin =
pc.getDouble(
"rangeMargin")*(
xmax-
xmin) ;
293 double dmean = rangeData->moment((
RooRealVar&)*
this,1) ;
294 double ddelta = ((
xmax-dmean)>(dmean-
xmin)?(
xmax-dmean):(dmean-
xmin))*(1+
pc.getDouble(
"rangeMargin")) ;
295 xmin = dmean-ddelta ;
296 xmax = dmean+ddelta ;
305 Int_t nbins =
pc.getInt(
"nbins") ;
306 const char*
name =
pc.getString(
"name",0,
true) ;
307 const char* title =
pc.getString(
"title",0,
true) ;
331 return new RooPlot(*
this,xlo,xhi,nbins);
361 coutE(
InputArguments) <<
"RooAbsRealLValue::frame(" <<
GetName() <<
") ERROR: empty fit range, must specify plot range" << endl ;
365 coutE(
InputArguments) <<
"RooAbsRealLValue::frame(" <<
GetName() <<
") ERROR: open ended fit range, must specify plot range" << endl ;
386 coutE(
InputArguments) <<
"RooAbsRealLValue::frame(" <<
GetName() <<
") ERROR: empty fit range, must specify plot range" << endl ;
390 coutE(
InputArguments) <<
"RooAbsRealLValue::frame(" <<
GetName() <<
") ERROR: open ended fit range, must specify plot range" << endl ;
415 os <<
indent <<
"--- RooAbsRealLValue ---" << endl;
418 os <<
indent <<
" Fit range is [ ";
420 os <<
getMin() << unit <<
" , ";
426 os <<
getMax() << unit <<
" ]" << endl;
429 os <<
"+INF ]" << endl;
462 if (ibin<0 || ibin>=
numBins(rangeName)) {
464 <<
" is out of range (0," <<
getBins(rangeName)-1 <<
")" << endl ;
524 const double val =
getVal() ;
527 const auto minMax =
getRange(
nullptr);
528 return minMax.first -
epsilon <= val && val <= minMax.second +
epsilon;
532 return std::any_of(ranges.begin(), ranges.end(), [val,
epsilon,
this](
const std::string& range){
533 const auto minMax = this->getRange(range.c_str());
534 return minMax.first - epsilon <= val && val <= minMax.second + epsilon;
572 return createHistogram(
name,
l) ;
591 pc.defineObject(
"xbinning",
"Binning",0,0) ;
592 pc.defineString(
"xbinningName",
"BinningName",0,
"") ;
593 pc.defineInt(
"nxbins",
"BinningSpec",0) ;
594 pc.defineDouble(
"xlo",
"BinningSpec",0,0) ;
595 pc.defineDouble(
"xhi",
"BinningSpec",1,0) ;
597 pc.defineObject(
"yvar",
"YVar",0,0) ;
598 pc.defineObject(
"ybinning",
"YVar::Binning",0,0) ;
599 pc.defineString(
"ybinningName",
"YVar::BinningName",0,
"") ;
600 pc.defineInt(
"nybins",
"YVar::BinningSpec",0) ;
601 pc.defineDouble(
"ylo",
"YVar::BinningSpec",0,0) ;
602 pc.defineDouble(
"yhi",
"YVar::BinningSpec",1,0) ;
604 pc.defineObject(
"zvar",
"ZVar",0,0) ;
605 pc.defineObject(
"zbinning",
"ZVar::Binning",0,0) ;
606 pc.defineString(
"zbinningName",
"ZVar::BinningName",0,
"") ;
607 pc.defineInt(
"nzbins",
"ZVar::BinningSpec",0) ;
608 pc.defineDouble(
"zlo",
"ZVar::BinningSpec",0,0) ;
609 pc.defineDouble(
"zhi",
"ZVar::BinningSpec",1,0) ;
611 pc.defineString(
"axisLabel",
"AxisLabel",0,
"Events") ;
613 pc.defineDependency(
"ZVar",
"YVar") ;
616 pc.process(cmdList) ;
622 const char* axisLabel =
pc.getString(
"axisLabel") ;
624 bool ownBinning[3] = {
false,
false,
false } ;
629 if (
pc.hasProcessed(
"Binning")) {
631 }
else if (
pc.hasProcessed(
"BinningName")) {
632 binning[0] = &
getBinning(
pc.getString(
"xbinningName",0,
true)) ;
633 }
else if (
pc.hasProcessed(
"BinningSpec")) {
634 double xlo =
pc.getDouble(
"xlo") ;
635 double xhi =
pc.getDouble(
"xhi") ;
637 ownBinning[0] = true ;
642 if (
pc.hasProcessed(
"YVar")) {
645 if (
pc.hasProcessed(
"YVar::Binning")) {
647 }
else if (
pc.hasProcessed(
"YVar::BinningName")) {
648 binning[1] = &yvar.
getBinning(
pc.getString(
"ybinningName",0,
true)) ;
649 }
else if (
pc.hasProcessed(
"YVar::BinningSpec")) {
650 double ylo =
pc.getDouble(
"ylo") ;
651 double yhi =
pc.getDouble(
"yhi") ;
653 ownBinning[1] = true ;
659 if (
pc.hasProcessed(
"ZVar")) {
662 if (
pc.hasProcessed(
"ZVar::Binning")) {
664 }
else if (
pc.hasProcessed(
"ZVar::BinningName")) {
665 binning[2] = &zvar.
getBinning(
pc.getString(
"zbinningName",0,
true)) ;
666 }
else if (
pc.hasProcessed(
"ZVar::BinningSpec")) {
667 double zlo =
pc.getDouble(
"zlo") ;
668 double zhi =
pc.getDouble(
"zhi") ;
670 ownBinning[2] = true ;
679 if (ownBinning[0])
delete binning[0] ;
680 if (ownBinning[1])
delete binning[1] ;
681 if (ownBinning[2])
delete binning[2] ;
700 <<
") ERROR: fit range empty or open ended, must explicitly specify range" << endl ;
754 double* xlo,
double* xhi,
Int_t* nBins)
const
756 if ((!xlo && xhi) || (xlo && !xhi)) {
758 <<
") ERROR must specify either no range, or both limits" << endl ;
768 Int_t *nBins2 = nBins;
774 <<
") ERROR: fit range empty or open ended, must explicitly specify range" << endl ;
779 <<
") ERROR: fit range of " << yvar.
GetName() <<
" empty or open ended, must explicitly specify range" << endl ;
786 xlo_fit[1] = yvar.
getMin() ;
787 xhi_fit[1] = yvar.
getMax() ;
795 nbins_fit[1] = yvar.
getBins() ;
828 const char *tAxisLabel,
double* xlo,
double* xhi,
Int_t* nBins)
const
830 if ((!xlo && xhi) || (xlo && !xhi)) {
832 <<
") ERROR must specify either no range, or both limits" << endl ;
842 Int_t* nBins2 = nBins;
847 <<
") ERROR: fit range empty or open ended, must explicitly specify range" << endl ;
852 <<
") ERROR: fit range of " << yvar.
GetName() <<
" empty or open ended, must explicitly specify range" << endl ;
857 <<
") ERROR: fit range of " << zvar.
GetName() <<
" empty or open ended, must explicitly specify range" << endl ;
864 xlo_fit[1] = yvar.
getMin() ;
865 xhi_fit[1] = yvar.
getMax() ;
867 xlo_fit[2] = zvar.
getMin() ;
868 xhi_fit[2] = zvar.
getMax() ;
876 nbins_fit[1] = yvar.
getBins() ;
877 nbins_fit[2] = zvar.
getBins() ;
906 double* xlo,
double* xhi,
Int_t* nBins)
916 if (bin[0])
delete bin[0] ;
917 if (bin[1])
delete bin[1] ;
918 if (bin[2])
delete bin[2] ;
935 if(dim < 1 || dim > 3) {
936 oocoutE(
nullptr,
InputArguments) <<
"RooAbsReal::createHistogram: dimension not supported: " << dim << endl;
957 histTitle.
Prepend(
"Histogram of ");
963 if (bins[0]->isUniform()) {
972 if (bins[0]->isUniform() && bins[1]->isUniform()) {
983 if (bins[0]->isUniform() && bins[1]->isUniform() && bins[2]->isUniform()) {
997 oocoutE(
nullptr,
InputArguments) <<
"RooAbsReal::createHistogram: unable to create a new histogram" << endl;
1021 if((0 != tAxisLabel) && (0 != strlen(tAxisLabel))) {
1022 TString axisTitle(tAxisLabel);
1023 axisTitle.
Append(
" / ( ");
1024 for(
Int_t index2= 0; index2 < dim; index2++) {
1026 if(index2 > 0) axisTitle.
Append(
" x ");
1028 if(strlen(xyz[index2]->
getUnit())) {
1066 std::stringstream errStream;
1067 errStream <<
"Attempting to integrate the " <<
ClassName() <<
" \"" <<
GetName()
1068 <<
"\", but integrating a RooAbsRealLValue is not allowed!";
1069 const std::string errString = errStream.str();
1071 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.
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
RooAbsBinning is the 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
Int_t getSize() const
Return the number of elements in the collection.
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
RooAbsData is the common 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.
RooAbsRealLValue is the common abstract base class for objects that represent a real value that may a...
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.
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
Retrive 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,...
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 std::liste...
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.
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.
~RooAbsRealLValue() override
Destructor.
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.
TH1 * createHistogram(const char *name, const RooCmdArg &arg1=RooCmdArg::none(), const RooCmdArg &arg2=RooCmdArg::none(), const RooCmdArg &arg3=RooCmdArg::none(), const RooCmdArg &arg4=RooCmdArg::none(), const RooCmdArg &arg5=RooCmdArg::none(), const RooCmdArg &arg6=RooCmdArg::none(), const RooCmdArg &arg7=RooCmdArg::none(), const RooCmdArg &arg8=RooCmdArg::none()) const
bool hasMin(const char *name=nullptr) const
Check if variable has a lower bound.
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
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 std::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.
RooCmdArg is a named container for two doubles, two integers two object points and three string point...
Class RooCmdConfig is a configurable parser for RooCmdArg named arguments.
RooLinkedList is an collection class for internal use, storing a collection of RooAbsArg pointers in ...
virtual void Add(TObject *arg)
RooNumIntConfig holds the configuration parameters of the various numeric integrators used by RooReal...
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.
A RooPlot is a 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)
RooRealVar represents a 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)
RVec< PromoteType< T > > abs(const RVec< T > &v)
std::vector< std::string > Split(std::string_view str, std::string_view delims, bool skipEmpty=false)
Splits a string at each character in delims.
static constexpr double pc