Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooRealVar.cxx
Go to the documentation of this file.
1/*****************************************************************************
2 * Project: RooFit *
3 * Package: RooFitCore *
4 * @(#)root/roofitcore:$Id$
5 * Authors: *
6 * WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu *
7 * DK, David Kirkby, UC Irvine, dkirkby@uci.edu *
8 * *
9 * Copyright (c) 2000-2005, Regents of the University of California *
10 * and Stanford University. All rights reserved. *
11 * *
12 * Redistribution and use in source and binary forms, *
13 * with or without modification, are permitted according to the terms *
14 * listed in LICENSE (http://roofit.sourceforge.net/license.txt) *
15 *****************************************************************************/
16
17/**
18\file RooRealVar.cxx
19\class RooRealVar
20\ingroup Roofitcore
21
22Variable that can be changed from the outside.
23For example by the user or a fitter.
24
25It can be written into datasets, can hold a (possibly asymmetric) error, and
26can have several ranges. These can be accessed with names, to e.g. limit fits
27or integrals to sub ranges. The range without any name is used as default range.
28**/
29
30#include "RooRealVar.h"
31
32#include "RooStreamParser.h"
33#include "RooErrorVar.h"
34#include "RooRangeBinning.h"
35#include "RooCmdConfig.h"
36#include "RooMsgService.h"
37#include "RooParamBinning.h"
38#include "RooVectorDataStore.h"
39#include "RooTrace.h"
41#include "RooUniformBinning.h"
42#include "RooSentinel.h"
43
44#include "TTree.h"
45#include "TBuffer.h"
46#include "TBranch.h"
47
48#include <iomanip>
49
50using std::endl, std::ostream, std::istream;
51
52
53
56
58
59/// Return a reference to a map of weak pointers to RooRealVarSharedProperties.
61{
62 RooSentinel::activate();
64 static auto * staticSharedPropList = new SharedPropertiesMap{};
66 }
67 return nullptr;
68}
69
70////////////////////////////////////////////////////////////////////////////////
71/// Explicitly deletes the shared properties list on exit to avoid problems
72/// with the initialization order. Meant to be only used internally in RooFit
73/// by RooSentinel.
74
76{
77 if(sharedPropList()) {
78 delete sharedPropList();
80 }
81}
82
83////////////////////////////////////////////////////////////////////////////////
84
85/// Return a dummy object to use when properties are not initialised.
87{
88 static const std::unique_ptr<RooRealVarSharedProperties> nullProp(new RooRealVarSharedProperties("00000000-0000-0000-0000-000000000000"));
89 return *nullProp;
90}
91
92////////////////////////////////////////////////////////////////////////////////
93/// Default constructor.
94
95RooRealVar::RooRealVar() : _error(0), _asymErrLo(0), _asymErrHi(0), _binning(new RooUniformBinning())
96{
97 _fast = true ;
99}
100
101
102////////////////////////////////////////////////////////////////////////////////
103/// Create a constant variable with a value and optional unit.
104RooRealVar::RooRealVar(const char *name, const char *title,
105 double value, const char *unit) :
106 RooAbsRealLValue(name, title, unit), _error(-1), _asymErrLo(1), _asymErrHi(-1),
107 _binning(new RooUniformBinning(-1,1,100))
108{
109 _value = value ;
110 _fast = true ;
111 removeRange();
112 setConstant(true) ;
114}
115
116
117////////////////////////////////////////////////////////////////////////////////
118/// Create a variable allowed to float in the given range.
119/// The initial value will be set to the center of the range.
120RooRealVar::RooRealVar(const char *name, const char *title,
121 double minValue, double maxValue,
122 const char *unit) :
123 RooAbsRealLValue(name, title, unit), _error(-1), _asymErrLo(1), _asymErrHi(-1),
125{
126 _fast = true ;
127
130 // [-inf,inf]
131 _value = 0 ;
132 } else {
133 // [-inf,X]
135 }
136 } else {
138 // [X,inf]
139 _value = minValue ;
140 } else {
141 // [X,X]
142 _value= 0.5*(minValue + maxValue);
143 }
144 }
145
146 // setPlotRange(minValue,maxValue) ;
149}
150
151
152////////////////////////////////////////////////////////////////////////////////
153/// Create a variable with the given starting value. It is allowed to float
154/// within the defined range. Optionally, a unit can be specified for axis labels.
155RooRealVar::RooRealVar(const char *name, const char *title,
156 double value, double minValue, double maxValue,
157 const char *unit) :
158 RooAbsRealLValue(name, title, unit), _error(-1), _asymErrLo(1), _asymErrHi(-1),
160{
161 _fast = true ;
163
164 double clipValue ;
165 inRange(value,nullptr,&clipValue) ;
166 _value = clipValue ;
167
169}
170
171
172////////////////////////////////////////////////////////////////////////////////
173/// Copy Constructor
174
177 _error(other._error),
178 _asymErrLo(other._asymErrLo),
179 _asymErrHi(other._asymErrHi)
180{
181 _sharedProp = other.sharedProp();
182 if (other._binning) {
183 _binning.reset(other._binning->clone());
184 _binning->insertHook(*this) ;
185 }
186 _fast = true ;
187
188 for (const auto& item : other._altNonSharedBinning) {
189 std::unique_ptr<RooAbsBinning> abc( item.second->clone() );
190 abc->insertHook(*this) ;
191 _altNonSharedBinning[item.first] = std::move(abc);
192 }
193
195
196}
197
198
199////////////////////////////////////////////////////////////////////////////////
200/// Destructor
201
203{
204 // We should not forget to explicitly call deleteSharedProperties() in the
205 // destructor, because this is where the expired weak_ptrs in the
206 // _sharedPropList get erased.
208
210}
211
212
213////////////////////////////////////////////////////////////////////////////////
214/// Return value of variable
215
216double RooRealVar::getValV(const RooArgSet*) const
217{
218 return _value ;
219}
220
221
222////////////////////////////////////////////////////////////////////////////////
223/// Enable or disable the silent clipping behavior of `RooRealVar::setVal()`
224/// that was the default in ROOT versions before 6.38. It is not recommended to
225/// enable this, as silently mutating data can be dangerous.
227{
229 if (flag) {
230 oocoutI(static_cast<TObject *>(nullptr), InputArguments)
231 << "Silent clipping of values to range in `RooRealVar::setVal()` enabled." << std::endl;
232 }
233}
234
236{
237 static bool isEnabled = false;
238 return isEnabled;
239}
240
241namespace {
242
243inline void throwOutOfRangeError(RooRealVar const &var, double value, const char *rangeName)
244{
245 std::stringstream ss;
246 ss << "Value " << value;
247 if (rangeName) {
248 ss << " is outside the range \"" << rangeName << "\" ";
249 } else {
250 ss << " is outside the default range ";
251 }
252 ss << "[" << var.getMin() << ", " << var.getMax() << "] of the variable \"";
253 ss << var.GetName() << "\"!";
254 ss << "\nTo restore the dangerous old behavior of silently clipping the value to the range,"
255 << " call `RooRealVar::enableSilentClipping()`.";
256 throw std::invalid_argument(ss.str());
257}
258
259void printOutOfRangeWarning(RooRealVar const &var, double value, const char *rangeName)
260{
261 std::stringstream ss;
262 ss << "Value " << value;
263 if (rangeName) {
264 ss << " is slightly outside the range \"" << rangeName << "\" ";
265 } else {
266 ss << " is slightly outside the default range ";
267 }
268 ss << "[" << var.getMin() << ", " << var.getMax() << "] of the variable \"";
269 ss << var.GetName() << "\"!";
270 ss << "\nThe value will be clipped. To restore the dangerous old behavior of silently clipping the value to the "
271 "range,"
272 << " call `RooRealVar::enableSilentClipping()`.";
273 oocoutW(&var, InputArguments) << ss.str() << std::endl;
274}
275
276}
277
278
279////////////////////////////////////////////////////////////////////////////////
280/// Set value of variable to 'value'. If 'value' is outside
281/// range of object, clip value into range
282
284{
285 double clipValue ;
286 bool isInRange = inRange(value,0,&clipValue) ;
287
288 if(!isInRange && !isSilentClippingEnabled()) {
289 if (std::abs(clipValue - value) > std::numeric_limits<double>::epsilon()) {
290 throwOutOfRangeError(*this, value, nullptr);
291 } else {
292 printOutOfRangeWarning(*this, value, nullptr);
293 }
294 }
295
296 if (clipValue != _value) {
297 setValueDirty() ;
300 }
301}
302
303
304
305////////////////////////////////////////////////////////////////////////////////
306/// Set value of variable to `value`. If `value` is outside of the
307/// range named `rangeName`, clip value into that range.
308void RooRealVar::setVal(double value, const char* rangeName)
309{
310 double clipValue ;
311 bool isInRange = inRange(value,rangeName,&clipValue) ;
312
313 if(!isInRange && !isSilentClippingEnabled()) {
314 if (std::abs(clipValue - value) > std::numeric_limits<double>::epsilon()) {
316 } else {
318 }
319 }
320
321 if (clipValue != _value) {
322 setValueDirty() ;
325 }
326}
327
328
329
330////////////////////////////////////////////////////////////////////////////////
331/// Return a RooAbsRealLValue representing the error associated
332/// with this variable. The callers takes ownership of the
333/// return object
334
336{
338 TString title(GetTitle());
339 name.Append("err") ;
340 title.Append(" Error") ;
341
342 return new RooErrorVar(name,title,*this) ;
343}
344
345
346
347////////////////////////////////////////////////////////////////////////////////
348/// Returns true if variable has a binning named 'name'.
349
350bool RooRealVar::hasBinning(const char* name) const
351{
352 return sharedProp()->_altBinning.find(name) != sharedProp()->_altBinning.end();
353}
354
355
356
357////////////////////////////////////////////////////////////////////////////////
358/// Return binning definition with name. If binning with 'name' is not found it is created
359/// on the fly as a clone of the default binning if createOnTheFly is true, otherwise
360/// a reference to the default binning is returned. If verbose is true a message
361/// is printed if a binning is created on the fly.
362
363const RooAbsBinning& RooRealVar::getBinning(const char* name, bool verbose, bool createOnTheFly) const
364{
365 return const_cast<RooRealVar*>(this)->getBinning(name, verbose, createOnTheFly) ;
366}
367
368
369
370////////////////////////////////////////////////////////////////////////////////
371/// Return binning definition with name. If binning with 'name' is not found it is created
372/// on the fly as a clone of the default binning if createOnTheFly is true, otherwise
373/// a reference to the default binning is returned. If verbose is true a message
374/// is printed if a binning is created on the fly.
375
377{
378 // Return default (normalization) binning and range if no name is specified
379 if (name==nullptr) {
380 return *_binning ;
381 }
382
383 if (strchr(name, ',')) {
384 coutW(InputArguments) << "Asking variable " << GetName() << "for binning '" << name
385 << "', but comma in binning names is not supported." << std::endl;
386 }
387
388 // Check if non-shared binning with this name has been created already
389 auto item = _altNonSharedBinning.find(name);
390 if (item != _altNonSharedBinning.end()) {
391 return *item->second;
392 }
393
394 // Check if binning with this name has been created already
395 auto item2 = sharedProp()->_altBinning.find(name);
396 if (item2 != sharedProp()->_altBinning.end()) {
397 return *item2->second;
398 }
399
400
401 // Return default binning if requested binning doesn't exist
402 if (!createOnTheFly) {
403 return *_binning ;
404 }
405
406 // Create a new RooRangeBinning with this name with default range
407 auto binning = new RooRangeBinning(getMin(),getMax(),name) ;
408 if (verbose) {
409 coutI(Eval) << "RooRealVar::getBinning(" << GetName() << ") new range named '"
410 << name << "' created with default bounds" << std::endl ;
411 }
412 sharedProp()->_altBinning[name] = binning;
413
414 return *binning ;
415}
416
417////////////////////////////////////////////////////////////////////////////////
418/// Get a list of all binning names. An empty name implies the default binning and
419/// a nullptr pointer should be passed to getBinning in this case.
420
421std::list<std::string> RooRealVar::getBinningNames() const
422{
423 std::list<std::string> binningNames;
424 if (_binning) {
425 binningNames.push_back("");
426 }
427
428 for (const auto& item : _altNonSharedBinning) {
429 binningNames.push_back(item.first);
430 }
431 for (const auto& item : sharedProp()->_altBinning) {
432 binningNames.push_back(item.first);
433 }
434
435 return binningNames;
436}
437
438void RooRealVar::removeMin(const char* name) {
440}
441void RooRealVar::removeMax(const char* name) {
443}
447
448
449////////////////////////////////////////////////////////////////////////////////
450/// Create a uniform binning under name 'name' for this variable.
451/// \param[in] nBins Number of bins. The limits are taken from the currently set limits.
452/// \param[in] name Optional name. If name is null, install as default binning.
453void RooRealVar::setBins(Int_t nBins, const char* name) {
455}
456
457////////////////////////////////////////////////////////////////////////////////
458/// Add given binning under name 'name' with this variable. If name is null,
459/// the binning is installed as the default binning.
460void RooRealVar::setBinning(const RooAbsBinning& binning, const char* name)
461{
462 std::unique_ptr<RooAbsBinning> newBinning( binning.clone() );
463
464 // Process insert hooks required for parameterized binnings
465 if (!name || name[0] == 0) {
466 if (_binning) {
467 _binning->removeHook(*this) ;
468 }
469 newBinning->insertHook(*this) ;
470 _binning = std::move(newBinning);
471 } else {
472 // Remove any old binning with this name
473 auto sharedProps = sharedProp();
474 auto item = sharedProps->_altBinning.find(name);
475 if (item != sharedProps->_altBinning.end()) {
476 item->second->removeHook(*this);
477 if (sharedProps->_ownBinnings)
478 delete item->second;
479
480 sharedProps->_altBinning.erase(item);
481 }
482 auto item2 = _altNonSharedBinning.find(name);
483 if (item2 != _altNonSharedBinning.end()) {
484 item2->second->removeHook(*this);
486 }
487
488 // Install new
489 newBinning->SetName(name) ;
490 newBinning->SetTitle(name) ;
491 newBinning->insertHook(*this) ;
492 if (newBinning->isShareable()) {
493 sharedProp()->_altBinning[name] = newBinning.release();
494 } else {
496 }
497 }
498}
499
500
501
502////////////////////////////////////////////////////////////////////////////////
503/// Set minimum of name range to given value. If name is null
504/// minimum of default range is set
505
506void RooRealVar::setMin(const char* name, double value)
507{
508 // Set new minimum of fit range
509 RooAbsBinning& binning = getBinning(name,true,true) ;
510
511 // Check if new limit is consistent
512 if (value >= getMax()) {
513 coutW(InputArguments) << "RooRealVar::setMin(" << GetName()
514 << "): Proposed new fit min. larger than max., setting min. to max." << std::endl ;
515 binning.setMin(getMax()) ;
516 } else {
517 binning.setMin(value) ;
518 }
519
520 // Clip current value in window if it fell out
521 if (!name) {
522 double clipValue ;
523 if (!inRange(_value,nullptr,&clipValue)) {
525 }
526 }
527
528 setShapeDirty() ;
529}
530
531
532////////////////////////////////////////////////////////////////////////////////
533/// Set maximum of name range to given value. If name is null
534/// maximum of default range is set
535
536void RooRealVar::setMax(const char* name, double value)
537{
538 // Set new maximum of fit range
539 RooAbsBinning& binning = getBinning(name,true,true) ;
540
541 // Check if new limit is consistent
542 if (value < getMin()) {
543 coutW(InputArguments) << "RooRealVar::setMax(" << GetName()
544 << "): Proposed new fit max. smaller than min., setting max. to min." << std::endl ;
545 binning.setMax(getMin()) ;
546 } else {
547 binning.setMax(value) ;
548 }
549
550 // Clip current value in window if it fell out
551 if (!name) {
552 double clipValue ;
553 if (!inRange(_value,nullptr,&clipValue)) {
555 }
556 }
557
558 setShapeDirty() ;
559}
560
561
562////////////////////////////////////////////////////////////////////////////////
563/// Set a fit or plotting range.
564/// Ranges can be selected for e.g. fitting, plotting or integration. Note that multiple
565/// variables can have ranges with the same name, so multi-dimensional PDFs can be sliced.
566/// See also the tutorial rf203_ranges.C
567/// \param[in] name Name this range (so it can be selected later for fitting or
568/// plotting). If the name is `nullptr`, the function sets the limits of the default range.
569/// \param[in] min Miniminum of the range.
570/// \param[in] max Maximum of the range.
571void RooRealVar::setRange(const char* name, double min, double max)
572{
573 bool exists = name == nullptr || sharedProp()->_altBinning.count(name) > 0;
574
575 // Set new fit range
576 RooAbsBinning& binning = getBinning(name,false,true) ;
577
578 // Check if new limit is consistent
579 if (min>max) {
580 coutW(InputArguments) << "RooRealVar::setRange(" << GetName()
581 << "): Proposed new fit max. smaller than min., setting max. to min." << std::endl ;
582 binning.setRange(min,min) ;
583 } else {
584 binning.setRange(min,max) ;
585 }
586
587 if (!exists) {
588 coutI(Eval) << "RooRealVar::setRange(" << GetName()
589 << ") new range named '" << name << "' created with bounds ["
590 << min << "," << max << "]" << std::endl ;
591 }
592
593 setShapeDirty() ;
594}
595
596
597
598////////////////////////////////////////////////////////////////////////////////
599/// Set or modify a parameterised range, i.e., a range the varies in dependence
600/// of parameters.
601/// See setRange() for more details.
602void RooRealVar::setRange(const char* name, RooAbsReal& min, RooAbsReal& max)
603{
604 RooParamBinning pb(min,max,100) ;
606}
607
608
609
610////////////////////////////////////////////////////////////////////////////////
611/// Read object contents from given stream
612
613bool RooRealVar::readFromStream(istream& is, bool compact, bool verbose)
614{
615 TString token;
616 TString errorPrefix("RooRealVar::readFromStream(");
617 errorPrefix.Append(GetName()) ;
618 errorPrefix.Append(")") ;
620 double value(0) ;
621
622 if (compact) {
623 // Compact mode: Read single token
624 if (parser.readDouble(value,verbose)) return true ;
625 if (isValidReal(value,verbose)) {
626 setVal(value) ;
627 return false ;
628 } else {
629 return true ;
630 }
631
632 } else {
633 // Extended mode: Read multiple tokens on a single line
634 bool haveValue(false) ;
635 bool haveConstant(false) ;
636 removeError() ;
638
639 bool reprocessToken = false ;
640 while(true) {
641 if (parser.atEOL() || parser.atEOF()) break ;
642
643 if (!reprocessToken) {
644 token=parser.readToken() ;
645 }
647
648 if (!token.CompareTo("+")) {
649
650 // Expect +/- as 3-token sequence
651 if (parser.expectToken("/",true) ||
652 parser.expectToken("-",true)) {
653 break ;
654 }
655
656 // Next token is error or asymmetric error, check if first char of token is a '('
657 TString tmp = parser.readToken() ;
658 if (tmp.CompareTo("(")) {
659 // Symmetric error, convert token do double
660
661 double error ;
662 parser.convertToDouble(tmp,error) ;
663 setError(error) ;
664
665 } else {
666 // Have error
667 double asymErrLo = 0.;
668 double asymErrHi = 0.;
669 if (parser.readDouble(asymErrLo,true) ||
670 parser.expectToken(",",true) ||
671 parser.readDouble(asymErrHi,true) ||
672 parser.expectToken(")",true)) break ;
674 }
675
676 } else if (!token.CompareTo("C")) {
677
678 // Set constant
679 setConstant(true) ;
681
682 } else if (!token.CompareTo("P")) {
683
684 // Next tokens are plot limits
685 double plotMin(0);
686 double plotMax(0);
687 Int_t plotBins(0);
688 if (parser.expectToken("(",true) ||
689 parser.readDouble(plotMin,true) ||
690 parser.expectToken("-",true) ||
691 parser.readDouble(plotMax,true) ||
692 parser.expectToken(":",true) ||
693 parser.readInteger(plotBins,true) ||
694 parser.expectToken(")",true)) break ;
695// setPlotRange(plotMin,plotMax) ;
696 coutW(Eval) << "RooRealVar::readFromStream(" << GetName()
697 << ") WARNING: plot range deprecated, removed P(...) token" << std::endl ;
698
699 } else if (!token.CompareTo("F")) {
700
701 // Next tokens are fit limits
702 double fitMin;
703 double fitMax;
704 Int_t fitBins ;
705 if (parser.expectToken("(",true) ||
706 parser.readDouble(fitMin,true) ||
707 parser.expectToken("-",true) ||
708 parser.readDouble(fitMax,true) ||
709 parser.expectToken(":",true) ||
710 parser.readInteger(fitBins,true) ||
711 parser.expectToken(")",true)) break ;
712 //setBins(fitBins) ;
713 //setRange(fitMin,fitMax) ;
714 coutW(Eval) << "RooRealVar::readFromStream(" << GetName()
715 << ") WARNING: F(lo-hi:bins) token deprecated, use L(lo-hi) B(bins)" << std::endl ;
716 if (!haveConstant) setConstant(false) ;
717
718 } else if (!token.CompareTo("L")) {
719
720 // Next tokens are fit limits
721 double fitMin = 0.0;
722 double fitMax = 0.0;
723 // Int_t fitBins ;
724 if (parser.expectToken("(",true) ||
725 parser.readDouble(fitMin,true) ||
726 parser.expectToken("-",true) ||
727 parser.readDouble(fitMax,true) ||
728 parser.expectToken(")",true)) break ;
730 if (!haveConstant) setConstant(false) ;
731
732 } else if (!token.CompareTo("B")) {
733
734 // Next tokens are fit limits
735 Int_t fitBins = 0;
736 if (parser.expectToken("(",true) ||
737 parser.readInteger(fitBins,true) ||
738 parser.expectToken(")",true)) break ;
740
741 } else {
742 // Token is value
743 if (parser.convertToDouble(token,value)) { parser.zapToEnd() ; break ; }
744 haveValue = true ;
745 // Defer value assignment to end
746 }
747 }
748 if (haveValue) setVal(value) ;
749 return false ;
750 }
751}
752
753
754////////////////////////////////////////////////////////////////////////////////
755/// Write object contents to given stream
756
757void RooRealVar::writeToStream(ostream &os, bool compact) const
758{
759 if (compact) {
760 // Write value only
761 os << getVal();
762 return;
763 }
764
765 // Write value with error (if not zero)
766 if (_printScientific) {
767 std::stringstream text;
768
770 int nDigitsErr = (_printSigDigits + 1) / 2;
771
772 text << std::scientific;
773
774 if (_value >= 0)
775 text << " ";
776 text << std::setprecision(nDigitsVal) << _value;
777
778 text << std::setprecision(nDigitsErr) << " +/- ";
779 if (hasAsymError()) {
780 text << "(" << getAsymErrorLo() << ", " << getAsymErrorHi() << ")";
781 } else if (hasError()) {
782 text << getError();
783 }
784
785 os << text.str() << " ";
786 } else {
787 os << format(_printSigDigits, "EFA") << " ";
788 }
789
790 // Append limits if not constants
791 if (isConstant()) {
792 os << "C ";
793 }
794
795 // Append fit limits
796 if (hasMin()) {
797 os << "L(" << getMin();
798 } else {
799 os << "L(-INF";
800 }
801 if (hasMax()) {
802 os << " - " << getMax() << ") ";
803 } else {
804 os << " - +INF) ";
805 }
806
807 if (getBins() != 100) {
808 os << "B(" << getBins() << ") ";
809 }
810
811 // Add comment with unit, if unit exists
812 if (!_unit.IsNull())
813 os << "// [" << getUnit() << "]";
814}
815
816
817
818////////////////////////////////////////////////////////////////////////////////
819/// Print value of variable
820
821void RooRealVar::printValue(ostream& os) const
822{
823 os << getVal() ;
824
825 if(hasError() && !hasAsymError()) {
826 os << " +/- " << getError() ;
827 } else if (hasAsymError()) {
828 os << " +/- (" << getAsymErrorLo() << "," << getAsymErrorHi() << ")" ;
829 }
830
831}
832
833
834////////////////////////////////////////////////////////////////////////////////
835/// Print extras of variable: (asymmetric) error, constant flag, limits and binning
836
837void RooRealVar::printExtras(ostream& os) const
838{
839 // Append limits if not constants
840 if (isConstant()) {
841 os << "C " ;
842 }
843
844 // Append fit limits
845 os << " L(" ;
846 if(hasMin()) {
847 os << getMin();
848 }
849 else {
850 os << "-INF";
851 }
852 if(hasMax()) {
853 os << " - " << getMax() ;
854 }
855 else {
856 os << " - +INF";
857 }
858 os << ") " ;
859
860 if (getBins()!=100) {
861 os << "B(" << getBins() << ") " ;
862 }
863
864 // Add comment with unit, if unit exists
865 if (!_unit.IsNull())
866 os << "// [" << getUnit() << "]" ;
867
868// std::cout << " _value = " << &_value << " _error = " << &_error ;
869
870
871}
872
873
874////////////////////////////////////////////////////////////////////////////////
875/// Mapping of Print() option string to RooPrintable contents specifications
876
878{
879 if (opt && TString(opt)=="I") {
880 return kName|kClassName|kValue ;
881 }
883}
884
885
886////////////////////////////////////////////////////////////////////////////////
887/// Detailed printing interface
888
889void RooRealVar::printMultiline(ostream& os, Int_t contents, bool verbose, TString indent) const
890{
891 RooAbsRealLValue::printMultiline(os,contents,verbose,indent);
892 os << indent << "--- RooRealVar ---" << std::endl;
893 TString unit(_unit);
894 if(!unit.IsNull()) unit.Prepend(' ');
895 os << indent << " Error = " << getError() << unit << std::endl;
896}
897
898
899
900////////////////////////////////////////////////////////////////////////////////
901/// Format contents of RooRealVar for pretty printing on RooPlot
902/// parameter boxes. This function processes the named arguments
903/// taken by paramOn() and translates them to an option string
904/// parsed by RooRealVar::format(Int_t sigDigits, const char *options)
905
906std::string RooRealVar::format(const RooCmdArg& formatArg) const
907{
908 RooCmdArg tmp(formatArg) ;
909 tmp.setProcessRecArgs(true) ;
910
911 RooCmdConfig pc("RooRealVar::format(" + std::string(GetName()) + ")");
912 pc.defineString("what","FormatArgs",0,"") ;
913 pc.defineInt("autop","FormatArgs::AutoPrecision",0,2) ;
914 pc.defineInt("fixedp","FormatArgs::FixedPrecision",0,2) ;
915 pc.defineInt("tlatex","FormatArgs::TLatexStyle",0,0) ;
916 pc.defineInt("latex","FormatArgs::LatexStyle",0,0) ;
917 pc.defineInt("latext","FormatArgs::LatexTableStyle",0,0) ;
918 pc.defineInt("verbn","FormatArgs::VerbatimName",0,0) ;
919 pc.defineMutex("FormatArgs::TLatexStyle","FormatArgs::LatexStyle","FormatArgs::LatexTableStyle") ;
920 pc.defineMutex("FormatArgs::AutoPrecision","FormatArgs::FixedPrecision") ;
921
922 // Process & check varargs
923 pc.process(tmp) ;
924 if (!pc.ok(true)) {
925 return "";
926 }
927
928 // Extract values from named arguments
929 TString options ;
930 options = pc.getString("what") ;
931
932 if (pc.getInt("tlatex")) {
933 options += "L" ;
934 } else if (pc.getInt("latex")) {
935 options += "X" ;
936 } else if (pc.getInt("latext")) {
937 options += "Y" ;
938 }
939
940 if (pc.getInt("verbn")) options += "V" ;
941 Int_t sigDigits = 2 ;
942 if (pc.hasProcessed("FormatArgs::AutoPrecision")) {
943 options += "P" ;
944 sigDigits = pc.getInt("autop") ;
945 } else if (pc.hasProcessed("FormatArgs::FixedPrecision")) {
946 options += "F" ;
947 sigDigits = pc.getInt("fixedp") ;
948 }
949
950 return format(sigDigits,options) ;
951}
952
953
954
955
956////////////////////////////////////////////////////////////////////////////////
957/// Format numeric value of RooRealVar and its error in a variety of ways
958///
959/// To control what is shown use the following options
960/// N = show name
961/// T = show title (takes precedent over `N`, falls back to `N` if title is empty)
962/// H = hide value
963/// E = show error
964/// A = show asymmetric error instead of parabolic error (if available)
965/// U = show unit
966///
967/// To control how it is shown use these options
968/// L = TLatex mode
969/// X = Latex mode
970/// Y = Latex table mode ( '=' replaced by '&' )
971/// V = Make name \\verbatim in Latex mode
972/// P = use error to control shown precision
973/// F = force fixed precision
974///
975
976std::string RooRealVar::format(Int_t sigDigits, const char *options) const
977{
978 // parse the options string
979 TString opts(options);
980 opts.ToLower();
981
982 bool showName= opts.Contains("n");
983 bool showTitle = opts.Contains("t");
984 bool hideValue= opts.Contains("h");
985 bool showError= opts.Contains("e");
986 bool showUnit= opts.Contains("u");
987 bool tlatexMode= opts.Contains("l");
988 bool latexMode= opts.Contains("x");
989 bool latexTableMode = opts.Contains("y") ;
990 bool latexVerbatimName = opts.Contains("v") ;
991
992 std::string label = showName ? getPlotLabel() : "";
993 if(showTitle) {
994 label = GetTitle();
995 if(label.empty()) label = getPlotLabel();
996 }
997
999 bool asymError= opts.Contains("a") ;
1000 bool useErrorForPrecision= (((showError && hasError(false) && !isConstant()) || opts.Contains("p")) && !opts.Contains("f")) ;
1001 // calculate the precision to use
1002 if(sigDigits < 1) sigDigits= 1;
1005 leadingDigitVal = (Int_t)floor(log10(std::abs(_error+1e-10)));
1006 if (_value==0&&_error==0) leadingDigitVal=0 ;
1007 } else {
1008 leadingDigitVal = (Int_t)floor(log10(std::abs(_value+1e-10)));
1009 if (_value==0) leadingDigitVal=0 ;
1010 }
1011 Int_t leadingDigitErr= (Int_t)floor(log10(std::abs(_error+1e-10)));
1014
1015 if (_value<0) whereVal -= 1 ;
1016 int nDigitsVal = whereVal < 0 ? -whereVal : 0;
1017 int nDigitsErr = whereErr < 0 ? -whereErr : 0;
1018
1019 std::stringstream text;
1020
1021 if (latexMode)
1022 text << "$";
1023 // begin the string with "<name> = " if requested
1024 if(showName || showTitle) {
1026 text << "\\verb+";
1027 }
1028 text << label;
1030 text << "+";
1031
1032 if (!latexTableMode) {
1033 text << " = ";
1034 } else {
1035 text << " $ & $ ";
1036 }
1037 }
1038
1039 // Add leading space if value is positive
1040 if (_value >= 0)
1041 text << " ";
1042
1043 // append our value if requested
1044 text << std::fixed;
1045 if(!hideValue) {
1046 text << std::setprecision(nDigitsVal) << _value;
1047 }
1048 text << std::setprecision(nDigitsErr); // we only print errors from now on
1049
1050 // append our error if requested and this variable is not constant
1051 if(hasError(false) && showError && !(asymError && hasAsymError(false))) {
1052 if(tlatexMode) {
1053 text << " #pm " << getError();
1054 }
1055 else {
1056 text << (latexMode ? "\\pm " : " +/- ") << getError();
1057 }
1058 }
1059
1060 if (asymError && hasAsymError() && showError) {
1061 if(tlatexMode) {
1062 text << " #pm _{" << getAsymErrorLo() << "}^{+" << getAsymErrorHi() << "}";
1063 }
1064 else if(latexMode) {
1065 text << "\\pm _{" << getAsymErrorLo() << "}^{+" << getAsymErrorHi() << "}";
1066 }
1067 else {
1068 text << " +/- (" << getAsymErrorLo() << ", " << getAsymErrorHi() << ")";
1069 }
1070
1071 }
1072
1073 // append our units if requested
1074 if(!_unit.IsNull() && showUnit) {
1075 text << ' ' << _unit;
1076 }
1077 if (latexMode)
1078 text << "$";
1079 return text.str();
1080}
1081
1082////////////////////////////////////////////////////////////////////////////////
1083/// Overload RooAbsReal::attachToTree to also attach
1084/// branches for errors and/or asymmetric errors
1085/// attribute StoreError and/or StoreAsymError are set
1086
1088{
1089 // Follow usual procedure for value
1090
1091 if (getAttribute("StoreError") || getAttribute("StoreAsymError") || vstore.isFullReal(this) ) {
1092
1093 RooVectorDataStore::RealFullVector* rfv = vstore.addRealFull(this) ;
1094 rfv->setBuffer(this,&_value);
1095
1096 // Attach/create additional branch for error
1097 if (getAttribute("StoreError") || vstore.hasError(this) ) {
1098 rfv->setErrorBuffer(&_error) ;
1099 }
1100
1101 // Attach/create additional branches for asymmetric error
1102 if (getAttribute("StoreAsymError") || vstore.hasAsymError(this)) {
1103 rfv->setAsymErrorBuffer(&_asymErrLo,&_asymErrHi) ;
1104 }
1105
1106 } else {
1107
1109
1110 }
1111}
1112
1113
1114
1115////////////////////////////////////////////////////////////////////////////////
1116/// Overload RooAbsReal::attachToTree to also attach
1117/// branches for errors and/or asymmetric errors
1118/// attribute StoreError and/or StoreAsymError are set
1119
1121{
1122 // Follow usual procedure for value
1124// std::cout << "RooRealVar::attachToTree(" << this << ") name = " << GetName()
1125// << " StoreError = " << (getAttribute("StoreError")?"T":"F") << std::endl ;
1126
1127 // Attach/create additional branch for error
1128 if (getAttribute("StoreError")) {
1130 errName.Append("_err") ;
1132 if (branch) {
1134 } else {
1136 format2.Append("/D");
1137 t.Branch(errName, &_error, (const Text_t*)format2, bufSize);
1138 }
1139 }
1140
1141 // Attach/create additional branches for asymmetric error
1142 if (getAttribute("StoreAsymError")) {
1144 loName.Append("_aerr_lo") ;
1146 if (lobranch) {
1148 } else {
1150 format2.Append("/D");
1152 }
1153
1155 hiName.Append("_aerr_hi") ;
1157 if (hibranch) {
1159 } else {
1161 format2.Append("/D");
1163 }
1164 }
1165}
1166
1167
1168////////////////////////////////////////////////////////////////////////////////
1169/// Overload RooAbsReal::fillTreeBranch to also
1170/// fill tree branches with (asymmetric) errors
1171/// if requested.
1172
1174{
1175 // First determine if branch is taken
1178 if (!valBranch) {
1179 coutE(Eval) << "RooAbsReal::fillTreeBranch(" << GetName() << ") ERROR: not attached to tree" << std::endl ;
1180 assert(0) ;
1181 }
1182 valBranch->Fill() ;
1183
1184 if (getAttribute("StoreError")) {
1186 errName.Append("_err") ;
1188 if (errBranch) errBranch->Fill() ;
1189 }
1190
1191 if (getAttribute("StoreAsymError")) {
1193 loName.Append("_aerr_lo") ;
1195 if (loBranch) loBranch->Fill() ;
1196
1198 hiName.Append("_aerr_hi") ;
1200 if (hiBranch) hiBranch->Fill() ;
1201 }
1202}
1203
1204
1205
1206////////////////////////////////////////////////////////////////////////////////
1207/// Copy the cached value of another RooAbsArg to our cache
1208/// Warning: This function copies the cached values of source,
1209/// it is the callers responsibility to make sure the cache is clean
1210
1212{
1213 // Follow usual procedure for valueklog
1214 double oldVal = _value;
1216 if(_value != oldVal) {
1218 }
1219
1220 if (valueOnly) return ;
1221
1222 // Copy error too, if source has one
1223 RooRealVar* other = dynamic_cast<RooRealVar*>(const_cast<RooAbsArg*>(source)) ;
1224 if (other) {
1225 // Copy additional error value
1226 _error = other->_error ;
1227 _asymErrLo = other->_asymErrLo ;
1228 _asymErrHi = other->_asymErrHi ;
1229 }
1230}
1231
1232
1233
1234////////////////////////////////////////////////////////////////////////////////
1235/// Stream an object of class RooRealVar.
1236
1238{
1239 UInt_t R__s;
1240 UInt_t R__c;
1241 if (R__b.IsReading()) {
1242
1243 Version_t R__v = R__b.ReadVersion(&R__s, &R__c); if (R__v) { }
1245 if (R__v==1) {
1246 coutI(Eval) << "RooRealVar::Streamer(" << GetName() << ") converting version 1 data format" << std::endl ;
1247 double fitMin;
1248 double fitMax;
1249 Int_t fitBins ;
1250 R__b >> fitMin;
1251 R__b >> fitMax;
1252 R__b >> fitBins;
1253 _binning = std::make_unique<RooUniformBinning>(fitMin,fitMax,fitBins);
1254 }
1255 R__b >> _error;
1256 R__b >> _asymErrLo;
1257 R__b >> _asymErrHi;
1258 if (R__v>=2) {
1259 RooAbsBinning* binning;
1260 R__b >> binning;
1261 _binning.reset(binning);
1262 }
1263 if (R__v==3) {
1264 // In v3, properties were written as pointers, so read now and install:
1266 R__b >> tmpProp;
1267 installSharedProp(std::shared_ptr<RooRealVarSharedProperties>(tmpProp));
1268 }
1269 if (R__v>=4) {
1270 // In >= v4, properties were written directly, but they might be the "_nullProp"
1271 auto tmpProp = std::make_shared<RooRealVarSharedProperties>();
1272 tmpProp->Streamer(R__b);
1273 installSharedProp(std::move(tmpProp));
1274 }
1275
1276 R__b.CheckByteCount(R__s, R__c, RooRealVar::IsA());
1277
1278 } else {
1279
1280 R__c = R__b.WriteVersion(RooRealVar::IsA(), true);
1282 R__b << _error;
1283 R__b << _asymErrLo;
1284 R__b << _asymErrHi;
1285 R__b << _binning.get();
1286 if (_sharedProp) {
1287 _sharedProp->Streamer(R__b) ;
1288 } else {
1289 _nullProp().Streamer(R__b) ;
1290 }
1291 R__b.SetByteCount(R__c, true);
1292
1293 }
1294}
1295
1296/// Hand out our shared property, create on the fly and register
1297/// in shared map if necessary.
1298std::shared_ptr<RooRealVarSharedProperties> RooRealVar::sharedProp() const {
1299 if (!_sharedProp) {
1300 const_cast<RooRealVar*>(this)->installSharedProp(std::make_shared<RooRealVarSharedProperties>());
1301 }
1302
1303 return _sharedProp;
1304}
1305
1306
1307////////////////////////////////////////////////////////////////////////////////
1308/// Install the shared property into the member _sharedProp.
1309/// If a property with same name already exists, discard the incoming one,
1310/// and share the existing.
1311/// `nullptr` and properties equal to the RooRealVar::_nullProp will not be installed.
1312void RooRealVar::installSharedProp(std::shared_ptr<RooRealVarSharedProperties>&& prop) {
1313 if (prop == nullptr || (*prop == _nullProp())) {
1314 _sharedProp = nullptr;
1315 return;
1316 }
1317
1318
1319 auto& weakPtr = (*sharedPropList())[prop->uuid()];
1320 std::shared_ptr<RooRealVarSharedProperties> existingProp;
1321 if ( (existingProp = weakPtr.lock()) ) {
1322 // Property exists, discard incoming
1323 _sharedProp = std::move(existingProp);
1324 // Incoming is not allowed to delete the binnings now - they are owned by the other instance
1325 prop->disownBinnings();
1326 } else {
1327 // Doesn't exist. Install, register weak pointer for future sharing
1328 _sharedProp = std::move(prop);
1330 }
1331}
1332
1333
1334////////////////////////////////////////////////////////////////////////////////
1335/// Stop sharing properties.
1337{
1338 // Nothing to do if there were no shared properties to begin with.
1339 if(!_sharedProp) return;
1340
1341 // Get the key for the _sharedPropList.
1342 auto key = _sharedProp->uuid(); // we have to make a copy because _sharedPropList gets delete next.
1343
1344 // Actually delete the shared properties object.
1345 _sharedProp.reset();
1346
1347 // If the _sharedPropList was already deleted, we can return now.
1348 if(!sharedPropList()) return;
1349
1350 // Find the std::weak_ptr that the _sharedPropList holds to our
1351 // _sharedProp.
1352 auto iter = sharedPropList()->find(key);
1353
1354 // If no other RooRealVars shared the shared properties with us, the
1355 // weak_ptr in _sharedPropList is expired and we can erase it from the map.
1356 if(iter->second.expired()) {
1357 sharedPropList()->erase(iter);
1358 }
1359}
1360
1361
1362////////////////////////////////////////////////////////////////////////////////
1363/// If true, contents of RooRealVars will be printed in scientific notation
1364
1369
1370
1371////////////////////////////////////////////////////////////////////////////////
1372/// Set number of digits to show when printing RooRealVars
1373
#define e(i)
Definition RSha256.hxx:103
#define coutI(a)
#define oocoutW(o, a)
#define coutW(a)
#define oocoutI(o, a)
#define coutE(a)
static bool staticSharedPropListCleanedUp
#define TRACE_DESTROY
Definition RooTrace.h:24
#define TRACE_CREATE
Definition RooTrace.h:23
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:59
char Text_t
General string (char)
Definition RtypesCore.h:76
short Version_t
Class version identifier (short)
Definition RtypesCore.h:79
const char Option_t
Option string (const char)
Definition RtypesCore.h:80
static void indent(ostringstream &buf, int indent_level)
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
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 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 Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t format
Option_t Option_t TPoint TPoint const char text
char name[80]
Definition TGX11.cxx:110
@ kName
const_iterator end() const
Common abstract base class for objects that represent a value and a "shape" in RooFit.
Definition RooAbsArg.h:76
void setShapeDirty()
Notify that a shape-like property (e.g. binning) has changed.
Definition RooAbsArg.h:431
bool isConstant() const
Check if the "Constant" attribute is set.
Definition RooAbsArg.h:283
bool _fast
Definition RooAbsArg.h:645
friend void RooRefArray::Streamer(TBuffer &)
void setValueDirty()
Mark the element dirty. This forces a re-evaluation when a value is requested.
Definition RooAbsArg.h:425
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...
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
Abstract base class for objects that represent a real value that may appear on the left hand side of ...
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.
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...
Definition RooAbsReal.h:63
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
Definition RooAbsReal.h:107
TString _unit
Unit for objects value.
Definition RooAbsReal.h:540
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.
Definition RooAbsReal.h:539
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
Definition RooAbsReal.h:149
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:24
Named container for two doubles, two integers two object points and three string pointers that can be...
Definition RooCmdArg.h:26
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.
bool ok(bool verbose) const
Return true of parsing was successful.
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'.
Auxiliary class that represents the error of a RooRealVar as a separate object.
Definition RooErrorVar.h:28
static constexpr double infinity()
Return internal infinity representation.
Definition RooNumber.h:25
static constexpr int isInfinite(double x)
Return true if x is infinite by RooNumber internal specification.
Definition RooNumber.h:27
Implementation of RooAbsBinning that constructs a binning with a range definition that depends on ext...
Binning/range definition that only defines a range but no binning.
Implementation of RooSharedProperties that stores the properties of a RooRealVar that are shared amon...
Variable that can be changed from the outside.
Definition RooRealVar.h:37
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.
Definition RooRealVar.h:150
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.
void setError(double value)
Definition RooRealVar.h:61
std::unordered_map< std::string, std::unique_ptr< RooAbsBinning > > _altNonSharedBinning
! Non-shareable alternative binnings
Definition RooRealVar.h:154
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::map< RooSharedProperties::UUID, std::weak_ptr< RooRealVarSharedProperties > > SharedPropertiesMap
Definition RooRealVar.h:162
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
Definition RooRealVar.h:153
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.
Definition RooRealVar.h:151
void installSharedProp(std::shared_ptr< RooRealVarSharedProperties > &&prop)
Install the shared property into the member _sharedProp.
static bool _printScientific
Definition RooRealVar.h:138
std::shared_ptr< RooRealVarSharedProperties > _sharedProp
! Shared binnings associated with this instance
Definition RooRealVar.h:166
void removeAsymError()
Definition RooRealVar.h:66
void setAsymError(double lo, double hi)
Definition RooRealVar.h:67
double getError() const
Definition RooRealVar.h:59
static bool & isSilentClippingEnabled()
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
Definition RooRealVar.h:168
~RooRealVar() override
Destructor.
double _asymErrHi
High side of asymmetric error associated with current value.
Definition RooRealVar.h:152
static Int_t _printSigDigits
Definition RooRealVar.h:139
const RooAbsBinning & getBinning(const char *name=nullptr, bool verbose=true, bool createOnTheFly=false) const override
Return binning definition with name.
static void cleanup()
Explicitly deletes the shared properties list on exit to avoid problems with the initialization order...
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
Definition RooRealVar.h:60
static SharedPropertiesMap * sharedPropList()
List of properties shared among clones of a variable.
void deleteSharedProperties()
Stop sharing properties.
static void enableSilentClipping(bool flag=true)
Enable or disable the silent clipping behavior of RooRealVar::setVal() that was the default in ROOT v...
void writeToStream(std::ostream &os, bool compact) const override
Write object contents to given stream.
bool hasAsymError(bool allowZero=true) const
Definition RooRealVar.h:65
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 getAsymErrorHi() const
Definition RooRealVar.h:64
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 removeError()
Definition RooRealVar.h:62
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.
std::string format(const RooCmdArg &formatArg) const
Format contents of RooRealVar for pretty printing on RooPlot parameter boxes.
TClass * IsA() const override
Definition RooRealVar.h:172
double getAsymErrorLo() const
Definition RooRealVar.h:63
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. Throws exceptions 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.
Implementation of RooAbsBinning that provides a uniform binning in 'n' bins between the range end poi...
Uses std::vector to store data columns.
A TTree is a list of TBranches.
Definition TBranch.h:93
Buffer base class used for serializing objects.
Definition TBuffer.h:43
const char * GetName() const override
Returns name of object.
Definition TNamed.h:49
const char * GetTitle() const override
Returns title of object.
Definition TNamed.h:50
Mother of all ROOT objects.
Definition TObject.h:41
Basic string class.
Definition TString.h:138
int CompareTo(const char *cs, ECaseCompare cmp=kExact) const
Compare a string to char *cs2.
Definition TString.cxx:465
TString & Prepend(const char *cs)
Definition TString.h:681
Bool_t IsNull() const
Definition TString.h:422
TString & Append(const char *cs)
Definition TString.h:580
A TTree represents a columnar dataset.
Definition TTree.h:89
virtual Int_t SetBranchAddress(const char *bname, void *add, TBranch **ptr, TClass *realClass, EDataType datatype, bool isptr, bool suppressMissingBranchError)
Definition TTree.cxx:8638
virtual TBranch * GetBranch(const char *name)
Return pointer to the branch with the given name in this tree or its friends.
Definition TTree.cxx:5431
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.
Definition TTree.h:387