65 static auto * staticSharedPropList =
new std::map<std::string,std::weak_ptr<RooRealVarSharedProperties>>();
66 return staticSharedPropList;
87 static const std::unique_ptr<RooRealVarSharedProperties> nullProp(
new RooRealVarSharedProperties(
"00000000-0000-0000-0000-000000000000"));
141 _value= 0.5*(minValue + 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) ;
257 auto item = inputData.
spans.find(
this);
258 if (item != inputData.
spans.end()) {
262 for (
const auto& var_span : inputData.
spans) {
263 auto var = var_span.first;
266 inputData.
spans[
this] = var_span.second;
267 return var_span.second;
287 if (clipValue !=
_value) {
302 inRange(value,rangeName,&clipValue) ;
304 if (clipValue !=
_value) {
365 if (strchr(
name,
',')) {
366 coutW(InputArguments) <<
"Asking variable " <<
GetName() <<
"for binning '" <<
name
367 <<
"', but comma in binning names is not supported." << std::endl;
373 return *item->second;
378 if (item2 !=
sharedProp()->_altBinning.end()) {
379 return *item2->second;
384 if (!createOnTheFly) {
391 coutI(Eval) <<
"RooRealVar::getBinning(" <<
GetName() <<
") new range named '"
392 <<
name <<
"' created with default bounds" << endl ;
405 std::list<std::string> binningNames;
407 binningNames.push_back(
"");
411 binningNames.push_back(item.first);
413 for (
const auto& item :
sharedProp()->_altBinning) {
414 binningNames.push_back(item.first);
444 std::unique_ptr<RooAbsBinning> newBinning( binning.
clone() );
451 newBinning->insertHook(*
this) ;
456 auto item = sharedProps->_altBinning.find(
name);
457 if (item != sharedProps->_altBinning.end()) {
458 item->second->removeHook(*
this);
459 if (sharedProps->_ownBinnings)
462 sharedProps->_altBinning.erase(item);
466 item2->second->removeHook(*
this);
471 newBinning->SetName(
name) ;
472 newBinning->SetTitle(
name) ;
473 newBinning->insertHook(*
this) ;
474 if (newBinning->isShareable()) {
495 coutW(InputArguments) <<
"RooRealVar::setMin(" <<
GetName()
496 <<
"): Proposed new fit min. larger than max., setting min. to max." << endl ;
525 coutW(InputArguments) <<
"RooRealVar::setMax(" <<
GetName()
526 <<
"): Proposed new fit max. smaller than min., setting max. to min." << endl ;
562 coutW(InputArguments) <<
"RooRealVar::setRange(" <<
GetName()
563 <<
"): Proposed new fit max. smaller than min., setting max. to min." << endl ;
571 <<
") new range named '" <<
name <<
"' created with bounds ["
572 << min <<
"," << max <<
"]" << endl ;
597 TString token,errorPrefix(
"RooRealVar::readFromStream(") ;
624 if (!reprocessToken) {
648 Double_t asymErrLo=0., asymErrHi=0.;
660 haveConstant =
kTRUE ;
675 coutW(Eval) <<
"RooRealVar::readFromStrem(" <<
GetName()
676 <<
") WARNING: plot range deprecated, removed P(...) token" << endl ;
692 coutW(Eval) <<
"RooRealVar::readFromStream(" <<
GetName()
693 <<
") WARNING: F(lo-hi:bins) token deprecated, use L(lo-hi) B(bins)" << endl ;
699 Double_t fitMin = 0.0, fitMax = 0.0;
725 if (haveValue)
setVal(value) ;
743 char fmtVal[16], fmtErr[16] ;
746 if (
_value>=0) os <<
" " ;
759 os << tmp->
Data() <<
" " ;
785 os <<
"B(" <<
getBins() <<
") " ;
790 os <<
"// [" <<
getUnit() <<
"]" ;
839 os <<
"B(" <<
getBins() <<
") " ;
844 os <<
"// [" <<
getUnit() <<
"]" ;
857 if (opt &&
TString(opt)==
"I") {
870 os <<
indent <<
"--- RooRealVar ---" << endl;
891 pc.
defineInt(
"autop",
"FormatArgs::AutoPrecision",0,2) ;
892 pc.
defineInt(
"fixedp",
"FormatArgs::FixedPrecision",0,2) ;
893 pc.
defineInt(
"tlatex",
"FormatArgs::TLatexStyle",0,0) ;
894 pc.
defineInt(
"latex",
"FormatArgs::LatexStyle",0,0) ;
895 pc.
defineInt(
"latext",
"FormatArgs::LatexTableStyle",0,0) ;
896 pc.
defineInt(
"verbn",
"FormatArgs::VerbatimName",0,0) ;
897 pc.
defineMutex(
"FormatArgs::TLatexStyle",
"FormatArgs::LatexStyle",
"FormatArgs::LatexTableStyle") ;
898 pc.
defineMutex(
"FormatArgs::AutoPrecision",
"FormatArgs::FixedPrecision") ;
910 if (pc.
getInt(
"tlatex")) {
912 }
else if (pc.
getInt(
"latex")) {
914 }
else if (pc.
getInt(
"latext")) {
918 if (pc.
getInt(
"verbn")) options +=
"V" ;
919 Int_t sigDigits = 2 ;
922 sigDigits = pc.
getInt(
"autop") ;
923 }
else if (pc.
hasProcessed(
"FormatArgs::FixedPrecision")) {
925 sigDigits = pc.
getInt(
"fixedp") ;
928 return format(sigDigits,options) ;
969 if (latexTableMode) latexMode =
kTRUE ;
973 if(sigDigits < 1) sigDigits= 1;
974 Int_t leadingDigitVal = 0;
975 if (useErrorForPrecision) {
976 leadingDigitVal = (
Int_t)floor(log10(fabs(
_error+1
e-10)));
979 leadingDigitVal = (
Int_t)floor(log10(fabs(
_value+1
e-10)));
980 if (
_value==0) leadingDigitVal=0 ;
983 Int_t whereVal= leadingDigitVal - sigDigits + 1;
984 Int_t whereErr= leadingDigitErr - sigDigits + 1;
985 char fmtVal[16], fmtErr[16];
987 if (
_value<0) whereVal -= 1 ;
988 snprintf(fmtVal,16,
"%%.%df", whereVal < 0 ? -whereVal : 0);
989 snprintf(fmtErr,16,
"%%.%df", whereErr < 0 ? -whereErr : 0);
991 if(latexMode)
text->Append(
"$");
994 if (latexTableMode && latexVerbatimName) {
995 text->Append(
"\\verb+") ;
998 if (latexVerbatimName)
text->Append(
"+") ;
1000 if (!latexTableMode) {
1001 text->Append(
" = ");
1003 text->Append(
" $ & $ ");
1015 text->Append(buffer);
1021 text->Append(
" #pm ");
1023 else if(latexMode) {
1024 text->Append(
"\\pm ");
1027 text->Append(
" +/- ");
1030 text->Append(buffer);
1035 text->Append(
" #pm ");
1036 text->Append(
"_{") ;
1038 text->Append(buffer);
1039 text->Append(
"}^{+") ;
1041 text->Append(buffer);
1044 else if(latexMode) {
1045 text->Append(
"\\pm ");
1046 text->Append(
"_{") ;
1048 text->Append(buffer);
1049 text->Append(
"}^{+") ;
1051 text->Append(buffer);
1055 text->Append(
" +/- ");
1056 text->Append(
" (") ;
1058 text->Append(buffer);
1059 text->Append(
", ") ;
1061 text->Append(buffer);
1072 if(latexMode)
text->Append(
"$");
1153 loName.
Append(
"_aerr_lo") ;
1164 hiName.
Append(
"_aerr_hi") ;
1188 coutE(Eval) <<
"RooAbsReal::fillTreeBranch(" <<
GetName() <<
") ERROR: not attached to tree" << endl ;
1197 if (errBranch) errBranch->
Fill() ;
1202 loName.
Append(
"_aerr_lo") ;
1204 if (loBranch) loBranch->
Fill() ;
1207 hiName.
Append(
"_aerr_hi") ;
1209 if (hiBranch) hiBranch->
Fill() ;
1229 if (valueOnly) return ;
1254 coutI(Eval) <<
"RooRealVar::Streamer(" <<
GetName() <<
") converting version 1 data format" << endl ;
1278 auto tmpProp = std::make_shared<RooRealVarSharedProperties>();
1279 tmpProp->Streamer(R__b);
1320 if (prop ==
nullptr || (*prop ==
_nullProp())) {
1327 std::shared_ptr<RooRealVarSharedProperties> existingProp;
1328 if ( (existingProp = weakPtr.lock()) ) {
1332 prop->disownBinnings();
1349 const std::string key =
_sharedProp->asString().Data();
1363 if(iter->second.expired()) {
static bool staticSharedPropListCleanedUp
static void indent(ostringstream &buf, int indent_level)
char * Form(const char *fmt,...)
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.
friend void RooRefArray::Streamer(TBuffer &)
void setValueDirty()
Mark the element dirty. This forces a re-evaluation when a value is requested.
TString cleanBranchName() const
Construct a mangled name from the actual name that is free of any math symbols that might be interpre...
Bool_t getAttribute(const Text_t *name) const
Check if a named attribute is set. By default, all attributes are unset.
Bool_t isConstant() const
Check if the "Constant" attribute is set.
RooAbsBinning is the abstract base class for RooRealVar binning definitions.
virtual RooAbsBinning * clone(const char *name=0) const =0
virtual void insertHook(RooAbsRealLValue &) const
Hook interface function to execute code upon insertion into a RooAbsRealLValue.
virtual void setMin(Double_t xlo)
Change lower bound to xlo.
virtual void setMax(Double_t xhi)
Change upper bound to xhi.
virtual void setRange(Double_t xlo, Double_t xhi)=0
RooAbsRealLValue is the common abstract base class for objects that represent a real value that may a...
virtual Double_t getMax(const char *name=0) const
Get maximum of currently defined range.
Bool_t hasMax(const char *name=0) const
Check if variable has an upper bound.
virtual Bool_t isValidReal(Double_t value, Bool_t printError=kFALSE) const
Check if given value is valid.
virtual void printMultiline(std::ostream &os, Int_t contents, Bool_t verbose=kFALSE, TString indent="") const
Structure printing.
virtual Bool_t inRange(const char *name) const
Check if current value is inside range with given name.
virtual Int_t getBins(const char *name=0) const
Get number of bins of currently defined range.
RooAbsRealLValue & operator=(const RooAbsRealLValue &)=default
void setConstant(Bool_t value=kTRUE)
Bool_t hasMin(const char *name=0) const
Check if variable has a lower bound.
virtual Double_t getMin(const char *name=0) const
Get miniminum of currently defined range.
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
virtual void copyCache(const RooAbsArg *source, Bool_t valueOnly=kFALSE, Bool_t setValDirty=kTRUE)
Copy the cached value of another RooAbsArg to our cache.
virtual void attachToVStore(RooVectorDataStore &vstore)
virtual void attachToTree(TTree &t, Int_t bufSize=32000)
Attach object to a branch of given TTree.
Double_t getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
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_t flag, Bool_t prefix=kTRUE)
Class RooCmdConfig is a configurable parser for RooCmdArg named arguments.
Bool_t defineInt(const char *name, const char *argName, Int_t intNum, Int_t defValue=0)
Define integer property name 'name' mapped to integer in slot 'intNum' in RooCmdArg with name argName...
void defineMutex(const char *argName1, const char *argName2)
Define arguments named argName1 and argName2 mutually exclusive.
const char * getString(const char *name, const char *defaultValue="", Bool_t convEmptyToNull=kFALSE)
Return string property registered with name 'name'.
Int_t getInt(const char *name, Int_t defaultValue=0)
Return integer property registered with name 'name'.
Bool_t defineString(const char *name, const char *argName, Int_t stringNum, const char *defValue="", Bool_t appendMode=kFALSE)
Define Double_t property name 'name' mapped to Double_t in slot 'stringNum' in RooCmdArg with name ar...
Bool_t ok(Bool_t verbose) const
Return true of parsing was successful.
Bool_t process(const RooCmdArg &arg)
Process given RooCmdArg.
Bool_t hasProcessed(const char *cmdName) const
Return true if RooCmdArg with name 'cmdName' has been processed.
RooErrorVar is an auxilary class that represents the error of a RooRealVar as a seperate object.
static Int_t isInfinite(Double_t x)
Return true if x is infinite by RooNumBer internal specification.
static Double_t infinity()
Return internal infinity representation.
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...
RooRealVar represents a variable that can be changed from the outside.
Double_t getAsymErrorLo() const
static std::map< std::string, std::weak_ptr< RooRealVarSharedProperties > > * sharedPropList()
Return a reference to a map of weak pointers to RooRealVarSharedProperties.
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.
Bool_t hasBinning(const char *name) const
Returns true if variable has a binning named 'name'.
std::unordered_map< std::string, std::unique_ptr< RooAbsBinning > > _altNonSharedBinning
static RooRealVarSharedProperties & _nullProp()
Return a dummy object to use when properties are not initialised.
Bool_t hasAsymError(Bool_t allowZero=kTRUE) const
std::shared_ptr< RooRealVarSharedProperties > sharedProp() const
Non-shareable alternative binnings.
virtual void printValue(std::ostream &os) const
Print value of variable.
static void printScientific(Bool_t flag=kFALSE)
If true, contents of RooRealVars will be printed in scientific notation.
virtual Int_t defaultPrintContents(Option_t *opt) const
Mapping of Print() option string to RooPrintable contents specifications.
void setMin(const char *name, Double_t value)
Set minimum of name range to given value.
void setBins(Int_t nBins, const char *name=0)
Create a uniform binning under name 'name' for this variable.
std::unique_ptr< RooAbsBinning > _binning
void installSharedProp(std::shared_ptr< RooRealVarSharedProperties > &&prop)
Install the shared property into the member _sharedProp.
virtual void writeToStream(std::ostream &os, Bool_t compact) const
Write object contents to given stream.
std::shared_ptr< RooRealVarSharedProperties > _sharedProp
void setError(Double_t value)
virtual void printMultiline(std::ostream &os, Int_t contents, Bool_t verbose=kFALSE, TString indent="") const
Detailed printing interface.
virtual void printExtras(std::ostream &os) const
Print extras of variable: (asymmetric) error, constant flag, limits and binning.
std::size_t _valueResetCounter
Shared binnings associated with this instance.
Double_t chopAt(Double_t what, Int_t where) const
Utility to calculate number of decimals to show based on magnitude of error.
static Int_t _printSigDigits
void setRange(const char *name, Double_t min, Double_t max)
Set a fit or plotting range.
static void cleanup()
Explicitely deletes the shared properties list on exit to avoid problems with the initialization orde...
std::list< std::string > getBinningNames() const
Get a list of all binning names.
virtual void attachToVStore(RooVectorDataStore &vstore)
Overload RooAbsReal::attachToTree to also attach branches for errors and/or asymmetric errors attribu...
void removeRange(const char *name=0)
Remove range limits for binning with given name. Empty name means default range.
Double_t getAsymErrorHi() const
void setMax(const char *name, Double_t value)
Set maximum of name range to given value.
virtual Double_t getValV(const RooArgSet *nset=0) const
Return value of variable.
void setAsymError(Double_t lo, Double_t hi)
void deleteSharedProperties()
Stop sharing properties.
virtual void fillTreeBranch(TTree &t)
Overload RooAbsReal::fillTreeBranch to also fill tree branches with (asymmetric) errors if requested.
Bool_t hasError(Bool_t allowZero=kTRUE) const
virtual ~RooRealVar()
Destructor.
RooErrorVar * errorVar() const
Return a RooAbsRealLValue representing the error associated with this variable.
Double_t getError() const
void removeMax(const char *name=0)
Remove upper range limit for binning with given name. Empty name means default range.
virtual void copyCache(const RooAbsArg *source, Bool_t valueOnly=kFALSE, Bool_t setValDirty=kTRUE)
Copy the cached value of another RooAbsArg to our cache Warning: This function copies the cached valu...
virtual Bool_t readFromStream(std::istream &is, Bool_t compact, Bool_t verbose=kFALSE)
Read object contents from given stream.
void removeMin(const char *name=0)
Remove lower range limit for binning with given name. Empty name means default range.
static Bool_t _printScientific
TString * format(const RooCmdArg &formatArg) const
Format contents of RooRealVar for pretty printing on RooPlot parameter boxes.
const RooAbsBinning & getBinning(const char *name=0, Bool_t verbose=kTRUE, Bool_t createOnTheFly=kFALSE) const
Return binning definition with name.
RooRealVar()
Default constructor.
virtual void attachToTree(TTree &t, Int_t bufSize=32000)
Overload RooAbsReal::attachToTree to also attach branches for errors and/or asymmetric errors attribu...
void setBinning(const RooAbsBinning &binning, const char *name=0)
Add given binning under name 'name' with this variable.
virtual void setVal(Double_t value)
Set value of variable to 'value'.
RooRealVar & operator=(const RooRealVar &other)
Assign the values of another RooRealVar to this instance.
static void activate()
Install atexit handler that calls CleanupRooFitAtExit() on program termination.
A simple container to hold a batch of data values.
Bool_t atEOL()
If true, parser is at end of line in stream.
Bool_t readInteger(Int_t &value, Bool_t zapOnError=kFALSE)
Read a token and convert it to an Int_t.
Bool_t readDouble(Double_t &value, Bool_t zapOnError=kFALSE)
Read the next token and convert it to a Double_t.
Bool_t convertToDouble(const TString &token, Double_t &value)
Convert given string to a double. Return true if the conversion fails.
void zapToEnd(Bool_t inclContLines=kFALSE)
Eat all characters up to and including then end of the current line.
Bool_t expectToken(const TString &expected, Bool_t zapOnError=kFALSE)
Read the next token and return kTRUE if it is identical to the given 'expected' token.
TString readToken()
Read one token separated by any of the know punctuation characters This function recognizes and handl...
void setAsymErrorBuffer(Double_t *newBufL, Double_t *newBufH)
void setErrorBuffer(Double_t *newBuf)
void setBuffer(RooAbsReal *real, Double_t *newBuf)
RooVectorDataStore uses std::vectors to store data columns.
Bool_t hasAsymError(RooAbsReal *real)
Bool_t isFullReal(RooAbsReal *real)
RealFullVector * addRealFull(RooAbsReal *real)
Bool_t hasError(RooAbsReal *real)
A TTree is a list of TBranches.
Buffer base class used for serializing objects.
virtual void SetByteCount(UInt_t cntpos, Bool_t packInVersion=kFALSE)=0
virtual Version_t ReadVersion(UInt_t *start=0, UInt_t *bcnt=0, const TClass *cl=0)=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
virtual const char * GetTitle() const
Returns title of object.
virtual const char * GetName() const
Returns name 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=0)
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.
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.
static void output(int code)