66 return staticSharedPropList;
87 static const std::unique_ptr<RooRealVarSharedProperties> nullProp(
new RooRealVarSharedProperties(
"00000000-0000-0000-0000-000000000000"));
104 double value,
const char *unit) :
120 double minValue,
double maxValue,
141 _value= 0.5*(minValue + maxValue);
155 double value,
double minValue,
double maxValue,
176 _error(other._error),
177 _asymErrLo(other._asymErrLo),
178 _asymErrHi(other._asymErrHi)
188 std::unique_ptr<RooAbsBinning> abc( item.second->clone() );
189 abc->insertHook(*
this) ;
229 auto item = inputData.
spans.find(
this);
230 if (item != inputData.
spans.end()) {
234 for (
const auto& var_span : inputData.
spans) {
235 auto var = var_span.first;
238 inputData.
spans[
this] = var_span.second;
239 return var_span.second;
259 if (clipValue !=
_value) {
276 if (clipValue !=
_value) {
337 if (strchr(
name,
',')) {
339 <<
"', but comma in binning names is not supported." << std::endl;
345 return *item->second;
350 if (item2 !=
sharedProp()->_altBinning.end()) {
351 return *item2->second;
356 if (!createOnTheFly) {
363 coutI(
Eval) <<
"RooRealVar::getBinning(" <<
GetName() <<
") new range named '"
364 <<
name <<
"' created with default bounds" << endl ;
377 std::list<std::string> binningNames;
379 binningNames.push_back(
"");
383 binningNames.push_back(item.first);
385 for (
const auto& item :
sharedProp()->_altBinning) {
386 binningNames.push_back(item.first);
416 std::unique_ptr<RooAbsBinning> newBinning( binning.
clone() );
423 newBinning->insertHook(*
this) ;
428 auto item = sharedProps->_altBinning.find(
name);
429 if (item != sharedProps->_altBinning.end()) {
430 item->second->removeHook(*
this);
431 if (sharedProps->_ownBinnings)
434 sharedProps->_altBinning.erase(item);
438 item2->second->removeHook(*
this);
443 newBinning->SetName(
name) ;
444 newBinning->SetTitle(
name) ;
445 newBinning->insertHook(*
this) ;
446 if (newBinning->isShareable()) {
468 <<
"): Proposed new fit min. larger than max., setting min. to max." << endl ;
498 <<
"): Proposed new fit max. smaller than min., setting max. to min." << endl ;
535 <<
"): Proposed new fit max. smaller than min., setting max. to min." << endl ;
543 <<
") new range named '" <<
name <<
"' created with bounds ["
544 << min <<
"," << max <<
"]" << endl ;
569 TString token,errorPrefix(
"RooRealVar::readFromStream(") ;
587 bool haveValue(
false) ;
588 bool haveConstant(
false) ;
592 bool reprocessToken = false ;
596 if (!reprocessToken) {
599 reprocessToken = false ;
620 double asymErrLo=0., asymErrHi=0.;
632 haveConstant = true ;
637 double plotMin(0), plotMax(0) ;
648 <<
") WARNING: plot range deprecated, removed P(...) token" << endl ;
653 double fitMin, fitMax ;
665 <<
") WARNING: F(lo-hi:bins) token deprecated, use L(lo-hi) B(bins)" << endl ;
671 double fitMin = 0.0, fitMax = 0.0;
715 char fmtVal[16], fmtErr[16] ;
718 if (
_value>=0) os <<
" " ;
755 os <<
"B(" <<
getBins() <<
") " ;
760 os <<
"// [" <<
getUnit() <<
"]" ;
809 os <<
"B(" <<
getBins() <<
") " ;
814 os <<
"// [" <<
getUnit() <<
"]" ;
827 if (opt &&
TString(opt)==
"I") {
840 os <<
indent <<
"--- RooRealVar ---" << endl;
860 pc.defineString(
"what",
"FormatArgs",0,
"") ;
861 pc.defineInt(
"autop",
"FormatArgs::AutoPrecision",0,2) ;
862 pc.defineInt(
"fixedp",
"FormatArgs::FixedPrecision",0,2) ;
863 pc.defineInt(
"tlatex",
"FormatArgs::TLatexStyle",0,0) ;
864 pc.defineInt(
"latex",
"FormatArgs::LatexStyle",0,0) ;
865 pc.defineInt(
"latext",
"FormatArgs::LatexTableStyle",0,0) ;
866 pc.defineInt(
"verbn",
"FormatArgs::VerbatimName",0,0) ;
867 pc.defineMutex(
"FormatArgs::TLatexStyle",
"FormatArgs::LatexStyle",
"FormatArgs::LatexTableStyle") ;
868 pc.defineMutex(
"FormatArgs::AutoPrecision",
"FormatArgs::FixedPrecision") ;
878 options =
pc.getString(
"what") ;
880 if (
pc.getInt(
"tlatex")) {
882 }
else if (
pc.getInt(
"latex")) {
884 }
else if (
pc.getInt(
"latext")) {
888 if (
pc.getInt(
"verbn")) options +=
"V" ;
889 Int_t sigDigits = 2 ;
890 if (
pc.hasProcessed(
"FormatArgs::AutoPrecision")) {
892 sigDigits =
pc.getInt(
"autop") ;
893 }
else if (
pc.hasProcessed(
"FormatArgs::FixedPrecision")) {
895 sigDigits =
pc.getInt(
"fixedp") ;
898 return format(sigDigits,options) ;
934 bool tlatexMode= opts.
Contains(
"l");
936 bool latexTableMode = opts.
Contains(
"y") ;
937 bool latexVerbatimName = opts.
Contains(
"v") ;
939 if (latexTableMode) latexMode = true ;
940 bool asymError= opts.
Contains(
"a") ;
943 if(sigDigits < 1) sigDigits= 1;
944 Int_t leadingDigitVal = 0;
945 if (useErrorForPrecision) {
950 if (
_value==0) leadingDigitVal=0 ;
953 Int_t whereVal= leadingDigitVal - sigDigits + 1;
954 Int_t whereErr= leadingDigitErr - sigDigits + 1;
955 char fmtVal[16], fmtErr[16];
957 if (
_value<0) whereVal -= 1 ;
958 snprintf(fmtVal,16,
"%%.%df", whereVal < 0 ? -whereVal : 0);
959 snprintf(fmtErr,16,
"%%.%df", whereErr < 0 ? -whereErr : 0);
961 if(latexMode)
text->Append(
"$");
964 if (latexTableMode && latexVerbatimName) {
965 text->Append(
"\\verb+") ;
968 if (latexVerbatimName)
text->Append(
"+") ;
970 if (!latexTableMode) {
973 text->Append(
" $ & $ ");
985 text->Append(buffer);
991 text->Append(
" #pm ");
994 text->Append(
"\\pm ");
997 text->Append(
" +/- ");
1000 text->Append(buffer);
1005 text->Append(
" #pm ");
1006 text->Append(
"_{") ;
1008 text->Append(buffer);
1009 text->Append(
"}^{+") ;
1011 text->Append(buffer);
1014 else if(latexMode) {
1015 text->Append(
"\\pm ");
1016 text->Append(
"_{") ;
1018 text->Append(buffer);
1019 text->Append(
"}^{+") ;
1021 text->Append(buffer);
1025 text->Append(
" +/- ");
1026 text->Append(
" (") ;
1028 text->Append(buffer);
1029 text->Append(
", ") ;
1031 text->Append(buffer);
1042 if(latexMode)
text->Append(
"$");
1054 double scale=
pow(10.0,where);
1056 return (
double)
trunc*scale;
1123 loName.
Append(
"_aerr_lo") ;
1134 hiName.
Append(
"_aerr_hi") ;
1158 coutE(
Eval) <<
"RooAbsReal::fillTreeBranch(" <<
GetName() <<
") ERROR: not attached to tree" << endl ;
1167 if (errBranch) errBranch->
Fill() ;
1172 loName.
Append(
"_aerr_lo") ;
1174 if (loBranch) loBranch->
Fill() ;
1177 hiName.
Append(
"_aerr_hi") ;
1179 if (hiBranch) hiBranch->
Fill() ;
1199 if (valueOnly) return ;
1224 coutI(
Eval) <<
"RooRealVar::Streamer(" <<
GetName() <<
") converting version 1 data format" << endl ;
1225 double fitMin, fitMax ;
1248 auto tmpProp = std::make_shared<RooRealVarSharedProperties>();
1249 tmpProp->Streamer(R__b);
1297 std::shared_ptr<RooRealVarSharedProperties> existingProp;
1298 if ( (existingProp = weakPtr.lock()) ) {
1302 prop->disownBinnings();
1333 if(iter->second.expired()) {
static bool staticSharedPropListCleanedUp
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 Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h prop
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint const char text
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...
void setShapeDirty()
Notify that a shape-like property (e.g. binning) has changed.
bool isConstant() const
Check if the "Constant" attribute is set.
void setValueDirty()
Mark the element dirty. This forces a re-evaluation when a value is requested.
bool getAttribute(const Text_t *name) const
Check if a named attribute is set. By default, all attributes are unset.
TString cleanBranchName() const
Construct a mangled name from the actual name that is free of any math symbols that might be interpre...
RooAbsBinning is the abstract base class for RooRealVar binning definitions.
virtual void setRange(double xlo, double xhi)=0
virtual void setMin(double xlo)
Change lower bound to xlo.
virtual void setMax(double xhi)
Change upper bound to xhi.
virtual RooAbsBinning * clone(const char *name=nullptr) const =0
RooAbsRealLValue is the common abstract base class for objects that represent a real value that may a...
virtual Int_t getBins(const char *name=nullptr) const
Get number of bins of currently defined range.
bool isValidReal(double value, bool printError=false) const override
Check if given value is valid.
void setConstant(bool value=true)
virtual double getMax(const char *name=nullptr) const
Get maximum of currently defined range.
bool hasMax(const char *name=nullptr) const
Check if variable has an upper bound.
virtual double getMin(const char *name=nullptr) const
Get minimum of currently defined range.
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.
void Streamer(TBuffer &) override
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 attachToVStore(RooVectorDataStore &vstore) override
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.
void attachToTree(TTree &t, Int_t bufSize=32000) override
Attach object to a branch of given TTree.
const char * getPlotLabel() const
Get the label associated with the variable.
const Text_t * getUnit() const
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...
void setProcessRecArgs(bool flag, bool prefix=true)
Class RooCmdConfig is a configurable parser for RooCmdArg named arguments.
RooErrorVar is an auxilary class that represents the error of a RooRealVar as a seperate object.
static double infinity()
Return internal infinity representation.
static Int_t isInfinite(double x)
Return true if x is infinite by RooNumBer internal specification.
Class RooParamBinning is an implementation of RooAbsBinning that constructs a binning with a range de...
RooRangeBinning is binning/range definition that only defines a range but no binning.
Class RooRealVarSharedProperties is an implementation of RooSharedProperties that stores the properti...
void Streamer(TBuffer &) override
Stream an object of class TObject.
RooRealVar represents a variable that can be changed from the outside.
void fillTreeBranch(TTree &t) override
Overload RooAbsReal::fillTreeBranch to also fill tree branches with (asymmetric) errors if requested.
static void printScientific(bool flag=false)
If true, contents of RooRealVars will be printed in scientific notation.
void removeMin(const char *name=nullptr)
Remove lower range limit for binning with given name. Empty name means default range.
void setVal(double value) override
Set value of variable to 'value'.
double _error
Symmetric error associated with current value.
void removeRange(const char *name=nullptr)
Remove range limits for binning with given name. Empty name means default range.
static void printSigDigits(Int_t ndig=5)
Set number of digits to show when printing RooRealVars.
RooSpan< const double > getValues(RooBatchCompute::RunContext &inputData, const RooArgSet *=nullptr) const final
Retrieve data column of this variable.
void setError(double value)
std::unordered_map< std::string, std::unique_ptr< RooAbsBinning > > _altNonSharedBinning
! Non-shareable alternative binnings
static RooRealVarSharedProperties & _nullProp()
Null property.
void copyCache(const RooAbsArg *source, bool valueOnly=false, bool setValDirty=true) override
Copy the cached value of another RooAbsArg to our cache Warning: This function copies the cached valu...
std::shared_ptr< RooRealVarSharedProperties > sharedProp() const
Hand out our shared property, create on the fly and register in shared map if necessary.
void attachToTree(TTree &t, Int_t bufSize=32000) override
Overload RooAbsReal::attachToTree to also attach branches for errors and/or asymmetric errors attribu...
void attachToVStore(RooVectorDataStore &vstore) override
Overload RooAbsReal::attachToTree to also attach branches for errors and/or asymmetric errors attribu...
void printValue(std::ostream &os) const override
Print value of variable.
void printExtras(std::ostream &os) const override
Print extras of variable: (asymmetric) error, constant flag, limits and binning.
std::unique_ptr< RooAbsBinning > _binning
void setMin(const char *name, double value)
Set minimum of name range to given value.
bool hasBinning(const char *name) const override
Returns true if variable has a binning named 'name'.
double _asymErrLo
Low side of asymmetric error associated with current value.
void installSharedProp(std::shared_ptr< RooRealVarSharedProperties > &&prop)
Install the shared property into the member _sharedProp.
static bool _printScientific
std::shared_ptr< RooRealVarSharedProperties > _sharedProp
! Shared binnings associated with this instance
void setAsymError(double lo, double hi)
double getValV(const RooArgSet *nset=nullptr) const override
Return value of variable.
std::list< std::string > getBinningNames() const override
Get a list of all binning names.
void printMultiline(std::ostream &os, Int_t contents, bool verbose=false, TString indent="") const override
Detailed printing interface.
std::size_t _valueResetCounter
! How many times the value of this variable was reset
~RooRealVar() override
Destructor.
double _asymErrHi
High side of asymmetric error associated with current value.
static Int_t _printSigDigits
const RooAbsBinning & getBinning(const char *name=nullptr, bool verbose=true, bool createOnTheFly=false) const override
Return binning definition with name.
static void cleanup()
Explicitely deletes the shared properties list on exit to avoid problems with the initialization orde...
Int_t defaultPrintContents(Option_t *opt) const override
Mapping of Print() option string to RooPrintable contents specifications.
void setBinning(const RooAbsBinning &binning, const char *name=nullptr)
Add given binning under name 'name' with this variable.
bool hasError(bool allowZero=true) const
static SharedPropertiesMap * sharedPropList()
List of properties shared among clones of a variable.
void deleteSharedProperties()
Stop sharing properties.
void writeToStream(std::ostream &os, bool compact) const override
Write object contents to given stream.
std::map< RooSharedProperties::UUID, std::weak_ptr< RooRealVarSharedProperties > > SharedPropertiesMap
void Streamer(TBuffer &) override
Stream an object of class RooRealVar.
bool hasAsymError(bool allowZero=true) const
RooErrorVar * errorVar() const
Return a RooAbsRealLValue representing the error associated with this variable.
bool readFromStream(std::istream &is, bool compact, bool verbose=false) override
Read object contents from given stream.
double chopAt(double what, Int_t where) const
Utility to calculate number of decimals to show based on magnitude of error.
TString * format(const RooCmdArg &formatArg) const
Format contents of RooRealVar for pretty printing on RooPlot parameter boxes.
double getAsymErrorHi() const
void setRange(const char *name, double min, double max)
Set a fit or plotting range.
void setBins(Int_t nBins, const char *name=nullptr)
Create a uniform binning under name 'name' for this variable.
RooRealVar()
Default constructor.
void removeMax(const char *name=nullptr)
Remove upper range limit for binning with given name. Empty name means default range.
void setMax(const char *name, double value)
Set maximum of name range to given value.
TClass * IsA() const override
double getAsymErrorLo() const
static void activate()
Install atexit handler that calls CleanupRooFitAtExit() on program termination.
A simple container to hold a batch of data values.
bool expectToken(const TString &expected, bool zapOnError=false)
Read the next token and return true if it is identical to the given 'expected' token.
bool convertToDouble(const TString &token, double &value)
Convert given string to a double. Return true if the conversion fails.
bool atEOL()
If true, parser is at end of line in stream.
bool readDouble(double &value, bool zapOnError=false)
Read the next token and convert it to a double.
TString readToken()
Read one token separated by any of the know punctuation characters This function recognizes and handl...
bool readInteger(Int_t &value, bool zapOnError=false)
Read a token and convert it to an Int_t.
void zapToEnd(bool inclContLines=false)
Eat all characters up to and including then end of the current line.
void setErrorBuffer(double *newBuf)
void setAsymErrorBuffer(double *newBufL, double *newBufH)
void setBuffer(RooAbsReal *real, double *newBuf)
RooVectorDataStore uses std::vectors to store data columns.
RealFullVector * addRealFull(RooAbsReal *real)
bool isFullReal(RooAbsReal *real)
bool hasError(RooAbsReal *real)
bool hasAsymError(RooAbsReal *real)
A TTree is a list of TBranches.
Buffer base class used for serializing objects.
virtual Version_t ReadVersion(UInt_t *start=nullptr, UInt_t *bcnt=nullptr, const TClass *cl=nullptr)=0
virtual void SetByteCount(UInt_t cntpos, Bool_t packInVersion=kFALSE)=0
virtual Int_t CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *clss)=0
virtual UInt_t WriteVersion(const TClass *cl, Bool_t useBcnt=kFALSE)=0
const char * GetName() const override
Returns name of object.
const char * GetTitle() const override
Returns title of object.
void ToLower()
Change string to lower-case.
int CompareTo(const char *cs, ECaseCompare cmp=kExact) const
Compare a string to char *cs2.
const char * Data() const
TString & Prepend(const char *cs)
TString & Append(const char *cs)
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
A TTree represents a columnar dataset.
virtual TBranch * GetBranch(const char *name)
Return pointer to the branch with the given name in this tree or its friends.
virtual Int_t SetBranchAddress(const char *bname, void *add, TBranch **ptr=nullptr)
Change branch address, dealing with clone trees properly.
TBranch * Branch(const char *name, T *obj, Int_t bufsize=32000, Int_t splitlevel=99)
Add a new branch, and infer the data type from the type of obj being passed.
RVec< PromoteType< T > > abs(const RVec< T > &v)
RVec< PromoteType< T > > floor(const RVec< T > &v)
RVec< PromoteTypes< T0, T1 > > pow(const T0 &x, const RVec< T1 > &v)
RVec< PromoteType< T > > trunc(const RVec< T > &v)
RVec< PromoteType< T > > log10(const RVec< T > &v)
static constexpr double pc
This struct enables passing computation data around between elements of a computation graph.
RooSpan< double > makeBatch(const RooAbsArg *owner, std::size_t size)
Create a writable batch.
std::map< RooFit::Detail::DataKey, RooSpan< const double > > spans
Once an object has computed its value(s), the span pointing to the results is registered here.