|
ROOT
Reference Guide |
|
Go to the documentation of this file.
60 static std::map<std::string,std::weak_ptr<RooRealVarSharedProperties>> sharedPropList;
61 return sharedPropList;
67 static const std::unique_ptr<RooRealVarSharedProperties> nullProp(
new RooRealVarSharedProperties(
"00000000-0000-0000-0000-000000000000"));
121 _value= 0.5*(minValue + maxValue);
156 _error(other._error),
157 _asymErrLo(other._asymErrLo),
158 _asymErrHi(other._asymErrHi)
168 std::unique_ptr<RooAbsBinning> abc( item.second->clone() );
169 abc->insertHook(*
this) ;
232 auto item = inputData.
spans.find(
this);
233 if (item != inputData.
spans.end()) {
237 for (
const auto& var_span : inputData.
spans) {
238 auto var = var_span.first;
239 if (strcmp(var->GetName(),
GetName()) == 0) {
241 inputData.
spans[
this] = var_span.second;
242 return var_span.second;
262 if (clipValue !=
_value) {
276 inRange(value,rangeName,&clipValue) ;
278 if (clipValue !=
_value) {
338 if (strchr(
name,
',')) {
340 <<
"', but comma in binning names is not supported." << std::endl;
346 return *item->second;
351 if (item2 !=
sharedProp()->_altBinning.end()) {
352 return *item2->second;
357 if (!createOnTheFly) {
364 coutI(
Eval) <<
"RooRealVar::getBinning(" <<
GetName() <<
") new range named '"
365 <<
name <<
"' created with default bounds" << endl ;
378 std::list<std::string> binningNames;
380 binningNames.push_back(
"");
384 binningNames.push_back(item.first);
386 for (
const auto& item :
sharedProp()->_altBinning) {
387 binningNames.push_back(item.first);
417 std::unique_ptr<RooAbsBinning> newBinning( binning.
clone() );
424 newBinning->insertHook(*
this) ;
429 auto item = sharedProps->_altBinning.find(
name);
430 if (item != sharedProps->_altBinning.end()) {
431 item->second->removeHook(*
this);
432 if (sharedProps->_ownBinnings)
435 sharedProps->_altBinning.erase(item);
439 item2->second->removeHook(*
this);
444 newBinning->SetName(
name) ;
445 newBinning->SetTitle(
name) ;
446 newBinning->insertHook(*
this) ;
447 if (newBinning->isShareable()) {
469 <<
"): Proposed new fit min. larger than max., setting min. to max." << endl ;
499 <<
"): Proposed new fit max. smaller than min., setting max. to min." << endl ;
536 <<
"): Proposed new fit max. smaller than min., setting max. to min." << endl ;
544 <<
") new range named '" <<
name <<
"' created with bounds ["
545 << min <<
"," << max <<
"]" << endl ;
570 TString token,errorPrefix(
"RooRealVar::readFromStream(") ;
597 if (!reprocessToken) {
621 Double_t asymErrLo=0., asymErrHi=0.;
633 haveConstant =
kTRUE ;
649 <<
") WARNING: plot range deprecated, removed P(...) token" << endl ;
666 <<
") WARNING: F(lo-hi:bins) token deprecated, use L(lo-hi) B(bins)" << endl ;
672 Double_t fitMin = 0.0, fitMax = 0.0;
698 if (haveValue)
setVal(value) ;
716 char fmtVal[16], fmtErr[16] ;
719 if (
_value>=0) os <<
" " ;
732 os << tmp->
Data() <<
" " ;
758 os <<
"B(" <<
getBins() <<
") " ;
763 os <<
"// [" <<
getUnit() <<
"]" ;
812 os <<
"B(" <<
getBins() <<
") " ;
817 os <<
"// [" <<
getUnit() <<
"]" ;
830 if (opt &&
TString(opt)==
"I") {
843 os <<
indent <<
"--- RooRealVar ---" << endl;
863 pc.defineString(
"what",
"FormatArgs",0,
"") ;
864 pc.defineInt(
"autop",
"FormatArgs::AutoPrecision",0,2) ;
865 pc.defineInt(
"fixedp",
"FormatArgs::FixedPrecision",0,2) ;
866 pc.defineInt(
"tlatex",
"FormatArgs::TLatexStyle",0,0) ;
867 pc.defineInt(
"latex",
"FormatArgs::LatexStyle",0,0) ;
868 pc.defineInt(
"latext",
"FormatArgs::LatexTableStyle",0,0) ;
869 pc.defineInt(
"verbn",
"FormatArgs::VerbatimName",0,0) ;
870 pc.defineMutex(
"FormatArgs::TLatexStyle",
"FormatArgs::LatexStyle",
"FormatArgs::LatexTableStyle") ;
871 pc.defineMutex(
"FormatArgs::AutoPrecision",
"FormatArgs::FixedPrecision") ;
881 options =
pc.getString(
"what") ;
883 if (
pc.getInt(
"tlatex")) {
885 }
else if (
pc.getInt(
"latex")) {
887 }
else if (
pc.getInt(
"latext")) {
891 if (
pc.getInt(
"verbn")) options +=
"V" ;
892 Int_t sigDigits = 2 ;
893 if (
pc.hasProcessed(
"FormatArgs::AutoPrecision")) {
895 sigDigits =
pc.getInt(
"autop") ;
896 }
else if (
pc.hasProcessed(
"FormatArgs::FixedPrecision")) {
898 sigDigits =
pc.getInt(
"fixedp") ;
901 return format(sigDigits,options) ;
942 if (latexTableMode) latexMode =
kTRUE ;
946 if(sigDigits < 1) sigDigits= 1;
947 Int_t leadingDigitVal = 0;
948 if (useErrorForPrecision) {
953 if (
_value==0) leadingDigitVal=0 ;
956 Int_t whereVal= leadingDigitVal - sigDigits + 1;
957 Int_t whereErr= leadingDigitErr - sigDigits + 1;
958 char fmtVal[16], fmtErr[16];
960 if (
_value<0) whereVal -= 1 ;
961 snprintf(fmtVal,16,
"%%.%df", whereVal < 0 ? -whereVal : 0);
962 snprintf(fmtErr,16,
"%%.%df", whereErr < 0 ? -whereErr : 0);
964 if(latexMode)
text->Append(
"$");
967 if (latexTableMode && latexVerbatimName) {
968 text->Append(
"\\verb+") ;
971 if (latexVerbatimName)
text->Append(
"+") ;
973 if (!latexTableMode) {
976 text->Append(
" $ & $ ");
988 text->Append(buffer);
994 text->Append(
" #pm ");
997 text->Append(
"\\pm ");
1000 text->Append(
" +/- ");
1003 text->Append(buffer);
1008 text->Append(
" #pm ");
1009 text->Append(
"_{") ;
1011 text->Append(buffer);
1012 text->Append(
"}^{+") ;
1014 text->Append(buffer);
1017 else if(latexMode) {
1018 text->Append(
"\\pm ");
1019 text->Append(
"_{") ;
1021 text->Append(buffer);
1022 text->Append(
"}^{+") ;
1024 text->Append(buffer);
1028 text->Append(
" +/- ");
1029 text->Append(
" (") ;
1031 text->Append(buffer);
1032 text->Append(
", ") ;
1034 text->Append(buffer);
1045 if(latexMode)
text->Append(
"$");
1126 loName.
Append(
"_aerr_lo") ;
1137 hiName.
Append(
"_aerr_hi") ;
1161 coutE(
Eval) <<
"RooAbsReal::fillTreeBranch(" <<
GetName() <<
") ERROR: not attached to tree" << endl ;
1170 if (errBranch) errBranch->
Fill() ;
1175 loName.
Append(
"_aerr_lo") ;
1177 if (loBranch) loBranch->
Fill() ;
1180 hiName.
Append(
"_aerr_hi") ;
1182 if (hiBranch) hiBranch->
Fill() ;
1198 if (valueOnly) return ;
1215 void RooRealVar::Streamer(
TBuffer &R__b)
1221 RooAbsRealLValue::Streamer(R__b);
1223 coutI(
Eval) <<
"RooRealVar::Streamer(" <<
GetName() <<
") converting version 1 data format" << endl ;
1247 auto tmpProp = std::make_shared<RooRealVarSharedProperties>();
1248 tmpProp->Streamer(R__b);
1257 RooAbsRealLValue::Streamer(R__b);
1289 if (prop ==
nullptr || (*prop ==
_nullProp())) {
1296 std::shared_ptr<RooRealVarSharedProperties> existingProp;
1297 if ( (existingProp = weakPtr.lock()) ) {
1301 prop->disownBinnings();
1317 if (it->second.expired()) {
Double_t getAsymErrorHi() const
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 Bool_t inRange(const char *name) const
Check if current value is inside range with given name.
RooCmdArg is a named container for two doubles, two integers two object points and three string point...
Class RooRealVarSharedProperties is an implementation of RooSharedProperties that stores the properti...
std::shared_ptr< RooRealVarSharedProperties > _sharedProp
void zapToEnd(Bool_t inclContLines=kFALSE)
Eat all characters up to and including then end of the current line.
virtual void setVal(Double_t value)
Set value of variable to 'value'.
std::unordered_map< std::string, std::unique_ptr< RooAbsBinning > > _altNonSharedBinning
void installSharedProp(std::shared_ptr< RooRealVarSharedProperties > &&prop)
Install the shared property into the member _sharedProp.
RooSpan< double > makeBatch(const RooAbsReal *owner, std::size_t size)
Create a writable batch.
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.
static void printSigDigits(Int_t ndig=5)
Set number of digits to show when printing RooRealVars.
void setMin(const char *name, Double_t value)
Set minimum of name range to given value.
virtual Double_t getMax(const char *name=0) const
Get maximum of currently defined range.
TString & Prepend(const char *cs)
virtual UInt_t WriteVersion(const TClass *cl, Bool_t useBcnt=kFALSE)=0
virtual void SetByteCount(UInt_t cntpos, Bool_t packInVersion=kFALSE)=0
static Bool_t _printScientific
std::list< std::string > getBinningNames() const
Get a list of all binning names.
TString * format(const RooCmdArg &formatArg) const
Format contents of RooRealVar for pretty printing on RooPlot parameter boxes.
const char * Data() const
char * Form(const char *fmt,...)
virtual const char * GetTitle() const
Returns title of object.
TString cleanBranchName() const
Construct a mangled name from the actual name that is free of any math symbols that might be interpre...
virtual void insertHook(RooAbsRealLValue &) const
Hook interface function to execute code upon insertion into a RooAbsRealLValue.
static void output(int code)
const char * getPlotLabel() const
Get the label associated with the variable.
virtual void attachToTree(TTree &t, Int_t bufSize=32000)
Attach object to a branch of given TTree.
A TTree represents a columnar dataset.
virtual Int_t SetBranchAddress(const char *bname, void *add, TBranch **ptr=0)
Change branch address, dealing with clone trees properly.
RooAbsRealLValue & operator=(const RooAbsRealLValue &)=default
Double_t getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
virtual void fillTreeBranch(TTree &t)
Overload RooAbsReal::fillTreeBranch to also fill tree branches with (asymmetric) errors if requested.
Bool_t atEOL()
If true, parser is at end of line in stream.
RooAbsRealLValue & operator=(const RooAbsRealLValue &)=default
static constexpr double pc
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
virtual void setMax(Double_t xhi)
Change upper bound to xhi.
static void indent(ostringstream &buf, int indent_level)
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
RooErrorVar is an auxilary class that represents the error of a RooRealVar as a seperate object.
virtual void writeToStream(std::ostream &os, Bool_t compact) const
Write object contents to given stream.
Buffer base class used for serializing objects.
virtual ~RooRealVar()
Destructor.
static std::map< std::string, std::weak_ptr< RooRealVarSharedProperties > > & _sharedPropList()
Return a reference to a map of weak pointers to RooRealVarSharedProperties.
Double_t chopAt(Double_t what, Int_t where) const
Utility to calculate number of decimals to show based on magnitude of error.
TString readToken()
Read one token separated by any of the know punctuation characters This function recognizes and handl...
Bool_t hasMax(const char *name=0) const
Check if variable has an upper bound.
virtual Int_t CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *clss)=0
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...
void setRange(const char *name, Double_t min, Double_t max)
Set a fit or plotting range.
Bool_t readInteger(Int_t &value, Bool_t zapOnError=kFALSE)
Read a token and convert it to an Int_t.
virtual void printValue(std::ostream &os) const
Print value of variable.
RooErrorVar * errorVar() const
Return a RooAbsRealLValue representing the error associated with this variable.
Bool_t hasAsymError(RooAbsReal *real)
virtual Double_t getMin(const char *name=0) const
Get miniminum of currently defined range.
Class RooCmdConfig is a configurable parser for RooCmdArg named arguments.
virtual Bool_t readFromStream(std::istream &is, Bool_t compact, Bool_t verbose=kFALSE)
Read object contents from given stream.
Bool_t isFullReal(RooAbsReal *real)
A TTree is a list of TBranches.
virtual TBranch * GetBranch(const char *name)
Return pointer to the branch with the given name in this tree or its friends.
virtual void attachToVStore(RooVectorDataStore &vstore)
Overload RooAbsReal::attachToTree to also attach branches for errors and/or asymmetric errors attribu...
VecExpr< UnaryOp< Fabs< T >, VecExpr< A, T, D >, T >, T, D > fabs(const VecExpr< A, T, D > &rhs)
static RooRealVarSharedProperties & _nullProp()
Return a dummy object to use when properties are not initialised.
RooRealVar()
Default constructor.
Class RooParamBinning is an implementation of RooAbsBinning that constructs a binning with a range de...
Double_t getError() const
void setErrorBuffer(Double_t *newBuf)
Double_t getAsymErrorLo() const
void removeMax(const char *name=0)
Remove upper range limit for binning with given name. Empty name means default range.
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.
const Text_t * getUnit() const
static Int_t isInfinite(Double_t x)
Return true if x is infinite by RooNumBer internal specification.
TString & Append(const char *cs)
void setError(Double_t value)
Bool_t convertToDouble(const TString &token, Double_t &value)
Convert given string to a double. Return true if the conversion fails.
Bool_t readDouble(Double_t &value, Bool_t zapOnError=kFALSE)
Read the next token and convert it to a Double_t.
Bool_t hasBinning(const char *name) const
Returns true if variable has a binning named 'name'.
RooAbsBinning is the abstract base class for RooRealVar binning definitions.
virtual void attachToTree(TTree &t, Int_t bufSize=32000)
Overload RooAbsReal::attachToTree to also attach branches for errors and/or asymmetric errors attribu...
virtual Version_t ReadVersion(UInt_t *start=0, UInt_t *bcnt=0, const TClass *cl=0)=0
Bool_t hasError(RooAbsReal *real)
virtual void printExtras(std::ostream &os) const
Print extras of variable: (asymmetric) error, constant flag, limits and binning.
const RooAbsBinning & getBinning(const char *name=0, Bool_t verbose=kTRUE, Bool_t createOnTheFly=kFALSE) const
Return binning definition with name.
void setProcessRecArgs(Bool_t flag, Bool_t prefix=kTRUE)
virtual Int_t defaultPrintContents(Option_t *opt) const
Mapping of Print() option string to RooPrintable contents specifications.
Bool_t hasMin(const char *name=0) const
Check if variable has a lower bound.
virtual Double_t getValV(const RooArgSet *nset=0) const
Return value of variable.
static Double_t infinity()
Return internal infinity representation.
int CompareTo(const char *cs, ECaseCompare cmp=kExact) const
Compare a string to char *cs2.
void setMax(const char *name, Double_t value)
Set maximum of name range to given value.
void setBuffer(RooAbsReal *real, Double_t *newBuf)
void setShapeDirty()
Notify that a shape-like property (e.g. binning) has changed.
virtual void setMin(Double_t xlo)
Change lower bound to xlo.
RealFullVector * addRealFull(RooAbsReal *real)
void setBinning(const RooAbsBinning &binning, const char *name=0)
Add given binning under name 'name' with this variable.
virtual RooAbsBinning * clone(const char *name=0) const =0
static void printScientific(Bool_t flag=kFALSE)
If true, contents of RooRealVars will be printed in scientific notation.
RooVectorDataStore uses std::vectors to store data columns.
Bool_t hasAsymError(Bool_t allowZero=kTRUE) const
std::shared_ptr< RooRealVarSharedProperties > sharedProp() const
Non-shareable alternative binnings.
RooRangeBinning is binning/range definition that only defines a range but no binning.
void removeRange(const char *name=0)
Remove range limits for binning with given name. Empty name means default range.
void setConstant(Bool_t value=kTRUE)
void removeMin(const char *name=0)
Remove lower range limit for binning with given name. Empty name means default range.
virtual void setRange(Double_t xlo, Double_t xhi)=0
std::unique_ptr< RooAbsBinning > _binning
static Int_t _printSigDigits
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
virtual Int_t getBins(const char *name=0) const
Get number of bins of currently defined range.
void setValueDirty()
Mark the element dirty. This forces a re-evaluation when a value is requested.
void setAsymError(Double_t lo, Double_t hi)
void setAsymErrorBuffer(Double_t *newBufL, Double_t *newBufH)
virtual const char * GetName() const
Returns name of object.
virtual Bool_t isValidReal(Double_t value, Bool_t printError=kFALSE) const
Check if given value is valid.
void setBins(Int_t nBins, const char *name=0)
Create a uniform binning under name 'name' for this variable.
void ToLower()
Change string to lower-case.
RooRealVar represents a variable that can be changed from the outside.
double pow(double, double)
RooAbsRealLValue is the common abstract base class for objects that represent a real value that may a...
virtual void printMultiline(std::ostream &os, Int_t contents, Bool_t verbose=kFALSE, TString indent="") const
Structure printing.
void deleteSharedProperties()
Stop sharing properties.
RooSpan< const double > getValues(RooBatchCompute::RunContext &inputData, const RooArgSet *=nullptr) const final
Retrieve data column of this variable.
Bool_t isConstant() const
Check if the "Constant" attribute is set.
std::unordered_map< const RooAbsReal *, RooSpan< const double > > spans
Once an object has computed its value(s), the span pointing to the results is registered here.
Data that has to be passed around when evaluating functions / PDFs.
A simple container to hold a batch of data values.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Bool_t hasError(Bool_t allowZero=kTRUE) const
Bool_t getAttribute(const Text_t *name) const
Check if a named attribute is set. By default, all attributes are unset.
virtual void attachToVStore(RooVectorDataStore &vstore)
virtual void printMultiline(std::ostream &os, Int_t contents, Bool_t verbose=kFALSE, TString indent="") const
Detailed printing interface.