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 removeMin();
112 removeMax();
113 setConstant(true) ;
115}
116
117
118////////////////////////////////////////////////////////////////////////////////
119/// Create a variable allowed to float in the given range.
120/// The initial value will be set to the center of the range.
121RooRealVar::RooRealVar(const char *name, const char *title,
122 double minValue, double maxValue,
123 const char *unit) :
124 RooAbsRealLValue(name, title, unit), _error(-1), _asymErrLo(1), _asymErrHi(-1),
126{
127 _fast = true ;
128
131 // [-inf,inf]
132 _value = 0 ;
133 } else {
134 // [-inf,X]
136 }
137 } else {
139 // [X,inf]
140 _value = minValue ;
141 } else {
142 // [X,X]
143 _value= 0.5*(minValue + maxValue);
144 }
145 }
146
147 // setPlotRange(minValue,maxValue) ;
150}
151
152
153////////////////////////////////////////////////////////////////////////////////
154/// Create a variable with the given starting value. It is allowed to float
155/// within the defined range. Optionally, a unit can be specified for axis labels.
156RooRealVar::RooRealVar(const char *name, const char *title,
157 double value, double minValue, double maxValue,
158 const char *unit) :
159 RooAbsRealLValue(name, title, unit), _error(-1), _asymErrLo(1), _asymErrHi(-1),
161{
162 _fast = true ;
164
165 double clipValue ;
166 inRange(value,nullptr,&clipValue) ;
167 _value = clipValue ;
168
170}
171
172
173////////////////////////////////////////////////////////////////////////////////
174/// Copy Constructor
175
178 _error(other._error),
179 _asymErrLo(other._asymErrLo),
180 _asymErrHi(other._asymErrHi)
181{
182 _sharedProp = other.sharedProp();
183 if (other._binning) {
184 _binning.reset(other._binning->clone());
185 _binning->insertHook(*this) ;
186 }
187 _fast = true ;
188
189 for (const auto& item : other._altNonSharedBinning) {
190 std::unique_ptr<RooAbsBinning> abc( item.second->clone() );
191 abc->insertHook(*this) ;
192 _altNonSharedBinning[item.first] = std::move(abc);
193 }
194
196
197}
198
199
200////////////////////////////////////////////////////////////////////////////////
201/// Destructor
202
204{
205 // We should not forget to explicitly call deleteSharedProperties() in the
206 // destructor, because this is where the expired weak_ptrs in the
207 // _sharedPropList get erased.
209
211}
212
213
214////////////////////////////////////////////////////////////////////////////////
215/// Return value of variable
216
217double RooRealVar::getValV(const RooArgSet*) const
218{
219 return _value ;
220}
221
222
223////////////////////////////////////////////////////////////////////////////////
224/// Enable or disable the silent clipping behavior of `RooRealVar::setVal()`
225/// that was the default in ROOT versions before 6.38. It is not recommended to
226/// enable this, as silently mutating data can be dangerous.
228{
230 if (flag) {
231 oocoutI(static_cast<TObject *>(nullptr), InputArguments)
232 << "Silent clipping of values to range in `RooRealVar::setVal()` enabled." << std::endl;
233 }
234}
235
237{
238 static bool isEnabled = false;
239 return isEnabled;
240}
241
242namespace {
243
244inline void throwOutOfRangeError(RooRealVar const &var, double value, const char *rangeName)
245{
246 std::stringstream ss;
247 ss << "Value " << value;
248 if (rangeName) {
249 ss << " is outside the range \"" << rangeName << "\" ";
250 } else {
251 ss << " is outside the default range ";
252 }
253 ss << "[" << var.getMin() << ", " << var.getMax() << "] of the variable \"";
254 ss << var.GetName() << "\"!";
255 ss << "\nTo restore the dangerous old behavior of silently clipping the value to the range,"
256 << " call `RooRealVar::enableSilentClipping()`.";
257 throw std::invalid_argument(ss.str());
258}
259
260void printOutOfRangeWarning(RooRealVar const &var, double value, const char *rangeName)
261{
262 std::stringstream ss;
263 ss << "Value " << value;
264 if (rangeName) {
265 ss << " is slightly outside the range \"" << rangeName << "\" ";
266 } else {
267 ss << " is slightly outside the default range ";
268 }
269 ss << "[" << var.getMin() << ", " << var.getMax() << "] of the variable \"";
270 ss << var.GetName() << "\"!";
271 ss << "\nThe value will be clipped. To restore the dangerous old behavior of silently clipping the value to the "
272 "range,"
273 << " call `RooRealVar::enableSilentClipping()`.";
274 oocoutW(&var, InputArguments) << ss.str() << std::endl;
275}
276
277}
278
279
280////////////////////////////////////////////////////////////////////////////////
281/// Set value of variable to 'value'. If 'value' is outside
282/// range of object, clip value into range
283
285{
286 double clipValue ;
287 bool isInRange = inRange(value,0,&clipValue) ;
288
289 if(!isInRange && !isSilentClippingEnabled()) {
290 if (std::abs(clipValue - value) > std::numeric_limits<double>::epsilon()) {
291 throwOutOfRangeError(*this, value, nullptr);
292 } else {
293 printOutOfRangeWarning(*this, value, nullptr);
294 }
295 }
296
297 if (clipValue != _value) {
298 setValueDirty() ;
301 }
302}
303
304
305
306////////////////////////////////////////////////////////////////////////////////
307/// Set value of variable to `value`. If `value` is outside of the
308/// range named `rangeName`, clip value into that range.
309void RooRealVar::setVal(double value, const char* rangeName)
310{
311 double clipValue ;
312 bool isInRange = inRange(value,rangeName,&clipValue) ;
313
314 if(!isInRange && !isSilentClippingEnabled()) {
315 if (std::abs(clipValue - value) > std::numeric_limits<double>::epsilon()) {
317 } else {
319 }
320 }
321
322 if (clipValue != _value) {
323 setValueDirty() ;
326 }
327}
328
329
330
331////////////////////////////////////////////////////////////////////////////////
332/// Return a RooAbsRealLValue representing the error associated
333/// with this variable. The callers takes ownership of the
334/// return object
335
337{
339 TString title(GetTitle());
340 name.Append("err") ;
341 title.Append(" Error") ;
342
343 return new RooErrorVar(name,title,*this) ;
344}
345
346
347
348////////////////////////////////////////////////////////////////////////////////
349/// Returns true if variable has a binning named 'name'.
350
351bool RooRealVar::hasBinning(const char* name) const
352{
353 return sharedProp()->_altBinning.find(name) != sharedProp()->_altBinning.end();
354}
355
356
357
358////////////////////////////////////////////////////////////////////////////////
359/// Return binning definition with name. If binning with 'name' is not found it is created
360/// on the fly as a clone of the default binning if createOnTheFly is true, otherwise
361/// a reference to the default binning is returned. If verbose is true a message
362/// is printed if a binning is created on the fly.
363
364const RooAbsBinning& RooRealVar::getBinning(const char* name, bool verbose, bool createOnTheFly) const
365{
366 return const_cast<RooRealVar*>(this)->getBinning(name, verbose, createOnTheFly) ;
367}
368
369
370
371////////////////////////////////////////////////////////////////////////////////
372/// Return binning definition with name. If binning with 'name' is not found it is created
373/// on the fly as a clone of the default binning if createOnTheFly is true, otherwise
374/// a reference to the default binning is returned. If verbose is true a message
375/// is printed if a binning is created on the fly.
376
378{
379 // Return default (normalization) binning and range if no name is specified
380 if (name==nullptr) {
381 return *_binning ;
382 }
383
384 if (strchr(name, ',')) {
385 coutW(InputArguments) << "Asking variable " << GetName() << "for binning '" << name
386 << "', but comma in binning names is not supported." << std::endl;
387 }
388
389 // Check if non-shared binning with this name has been created already
390 auto item = _altNonSharedBinning.find(name);
391 if (item != _altNonSharedBinning.end()) {
392 return *item->second;
393 }
394
395 // Check if binning with this name has been created already
396 auto item2 = sharedProp()->_altBinning.find(name);
397 if (item2 != sharedProp()->_altBinning.end()) {
398 return *item2->second;
399 }
400
401
402 // Return default binning if requested binning doesn't exist
403 if (!createOnTheFly) {
404 return *_binning ;
405 }
406
407 // Create a new RooRangeBinning with this name with default range
408 auto binning = new RooRangeBinning(getMin(),getMax(),name) ;
409 if (verbose) {
410 coutI(Eval) << "RooRealVar::getBinning(" << GetName() << ") new range named '"
411 << name << "' created with default bounds" << std::endl ;
412 }
413 sharedProp()->_altBinning[name] = binning;
414
415 return *binning ;
416}
417
418////////////////////////////////////////////////////////////////////////////////
419/// Get a list of all binning names. An empty name implies the default binning and
420/// a nullptr pointer should be passed to getBinning in this case.
421
422std::list<std::string> RooRealVar::getBinningNames() const
423{
424 std::list<std::string> binningNames;
425 if (_binning) {
426 binningNames.push_back("");
427 }
428
429 for (const auto& item : _altNonSharedBinning) {
430 binningNames.push_back(item.first);
431 }
432 for (const auto& item : sharedProp()->_altBinning) {
433 binningNames.push_back(item.first);
434 }
435
436 return binningNames;
437}
438
439void RooRealVar::removeMin(const char* name) {
441}
442void RooRealVar::removeMax(const char* name) {
444}
448
449
450////////////////////////////////////////////////////////////////////////////////
451/// Create a uniform binning under name 'name' for this variable.
452/// \param[in] nBins Number of bins. The limits are taken from the currently set limits.
453/// \param[in] name Optional name. If name is null, install as default binning.
454void RooRealVar::setBins(Int_t nBins, const char* name) {
456}
457
458////////////////////////////////////////////////////////////////////////////////
459/// Add given binning under name 'name' with this variable. If name is null,
460/// the binning is installed as the default binning.
461void RooRealVar::setBinning(const RooAbsBinning& binning, const char* name)
462{
463 std::unique_ptr<RooAbsBinning> newBinning( binning.clone() );
464
465 // Process insert hooks required for parameterized binnings
466 if (!name || name[0] == 0) {
467 if (_binning) {
468 _binning->removeHook(*this) ;
469 }
470 newBinning->insertHook(*this) ;
471 _binning = std::move(newBinning);
472 } else {
473 // Remove any old binning with this name
474 auto sharedProps = sharedProp();
475 auto item = sharedProps->_altBinning.find(name);
476 if (item != sharedProps->_altBinning.end()) {
477 item->second->removeHook(*this);
478 if (sharedProps->_ownBinnings)
479 delete item->second;
480
481 sharedProps->_altBinning.erase(item);
482 }
483 auto item2 = _altNonSharedBinning.find(name);
484 if (item2 != _altNonSharedBinning.end()) {
485 item2->second->removeHook(*this);
487 }
488
489 // Install new
490 newBinning->SetName(name) ;
491 newBinning->SetTitle(name) ;
492 newBinning->insertHook(*this) ;
493 if (newBinning->isShareable()) {
494 sharedProp()->_altBinning[name] = newBinning.release();
495 } else {
497 }
498 }
499}
500
501
502
503////////////////////////////////////////////////////////////////////////////////
504/// Set minimum of name range to given value. If name is null
505/// minimum of default range is set
506
507void RooRealVar::setMin(const char* name, double value)
508{
509 // Set new minimum of fit range
510 RooAbsBinning& binning = getBinning(name,true,true) ;
511
512 // Check if new limit is consistent
513 if (value >= getMax()) {
514 coutW(InputArguments) << "RooRealVar::setMin(" << GetName()
515 << "): Proposed new fit min. larger than max., setting min. to max." << std::endl ;
516 binning.setMin(getMax()) ;
517 } else {
518 binning.setMin(value) ;
519 }
520
521 // Clip current value in window if it fell out
522 if (!name) {
523 double clipValue ;
524 if (!inRange(_value,nullptr,&clipValue)) {
526 }
527 }
528
529 setShapeDirty() ;
530}
531
532
533////////////////////////////////////////////////////////////////////////////////
534/// Set maximum of name range to given value. If name is null
535/// maximum of default range is set
536
537void RooRealVar::setMax(const char* name, double value)
538{
539 // Set new maximum of fit range
540 RooAbsBinning& binning = getBinning(name,true,true) ;
541
542 // Check if new limit is consistent
543 if (value < getMin()) {
544 coutW(InputArguments) << "RooRealVar::setMax(" << GetName()
545 << "): Proposed new fit max. smaller than min., setting max. to min." << std::endl ;
546 binning.setMax(getMin()) ;
547 } else {
548 binning.setMax(value) ;
549 }
550
551 // Clip current value in window if it fell out
552 if (!name) {
553 double clipValue ;
554 if (!inRange(_value,nullptr,&clipValue)) {
556 }
557 }
558
559 setShapeDirty() ;
560}
561
562
563////////////////////////////////////////////////////////////////////////////////
564/// Set a fit or plotting range.
565/// Ranges can be selected for e.g. fitting, plotting or integration. Note that multiple
566/// variables can have ranges with the same name, so multi-dimensional PDFs can be sliced.
567/// See also the tutorial rf203_ranges.C
568/// \param[in] name Name this range (so it can be selected later for fitting or
569/// plotting). If the name is `nullptr`, the function sets the limits of the default range.
570/// \param[in] min Miniminum of the range.
571/// \param[in] max Maximum of the range.
572void RooRealVar::setRange(const char* name, double min, double max)
573{
574 bool exists = name == nullptr || sharedProp()->_altBinning.count(name) > 0;
575
576 // Set new fit range
577 RooAbsBinning& binning = getBinning(name,false,true) ;
578
579 // Check if new limit is consistent
580 if (min>max) {
581 coutW(InputArguments) << "RooRealVar::setRange(" << GetName()
582 << "): Proposed new fit max. smaller than min., setting max. to min." << std::endl ;
583 binning.setRange(min,min) ;
584 } else {
585 binning.setRange(min,max) ;
586 }
587
588 if (!exists) {
589 coutI(Eval) << "RooRealVar::setRange(" << GetName()
590 << ") new range named '" << name << "' created with bounds ["
591 << min << "," << max << "]" << std::endl ;
592 }
593
594 setShapeDirty() ;
595}
596
597
598
599////////////////////////////////////////////////////////////////////////////////
600/// Set or modify a parameterised range, i.e., a range the varies in dependence
601/// of parameters.
602/// See setRange() for more details.
603void RooRealVar::setRange(const char* name, RooAbsReal& min, RooAbsReal& max)
604{
605 RooParamBinning pb(min,max,100) ;
607}
608
609
610
611////////////////////////////////////////////////////////////////////////////////
612/// Read object contents from given stream
613
614bool RooRealVar::readFromStream(istream& is, bool compact, bool verbose)
615{
616 TString token;
617 TString errorPrefix("RooRealVar::readFromStream(");
618 errorPrefix.Append(GetName()) ;
619 errorPrefix.Append(")") ;
621 double value(0) ;
622
623 if (compact) {
624 // Compact mode: Read single token
625 if (parser.readDouble(value,verbose)) return true ;
626 if (isValidReal(value,verbose)) {
627 setVal(value) ;
628 return false ;
629 } else {
630 return true ;
631 }
632
633 } else {
634 // Extended mode: Read multiple tokens on a single line
635 bool haveValue(false) ;
636 bool haveConstant(false) ;
637 removeError() ;
639
640 bool reprocessToken = false ;
641 while(true) {
642 if (parser.atEOL() || parser.atEOF()) break ;
643
644 if (!reprocessToken) {
645 token=parser.readToken() ;
646 }
648
649 if (!token.CompareTo("+")) {
650
651 // Expect +/- as 3-token sequence
652 if (parser.expectToken("/",true) ||
653 parser.expectToken("-",true)) {
654 break ;
655 }
656
657 // Next token is error or asymmetric error, check if first char of token is a '('
658 TString tmp = parser.readToken() ;
659 if (tmp.CompareTo("(")) {
660 // Symmetric error, convert token do double
661
662 double error ;
663 parser.convertToDouble(tmp,error) ;
664 setError(error) ;
665
666 } else {
667 // Have error
668 double asymErrLo = 0.;
669 double asymErrHi = 0.;
670 if (parser.readDouble(asymErrLo,true) ||
671 parser.expectToken(",",true) ||
672 parser.readDouble(asymErrHi,true) ||
673 parser.expectToken(")",true)) break ;
675 }
676
677 } else if (!token.CompareTo("C")) {
678
679 // Set constant
680 setConstant(true) ;
682
683 } else if (!token.CompareTo("P")) {
684
685 // Next tokens are plot limits
686 double plotMin(0);
687 double plotMax(0);
688 Int_t plotBins(0);
689 if (parser.expectToken("(",true) ||
690 parser.readDouble(plotMin,true) ||
691 parser.expectToken("-",true) ||
692 parser.readDouble(plotMax,true) ||
693 parser.expectToken(":",true) ||
694 parser.readInteger(plotBins,true) ||
695 parser.expectToken(")",true)) break ;
696// setPlotRange(plotMin,plotMax) ;
697 coutW(Eval) << "RooRealVar::readFromStream(" << GetName()
698 << ") WARNING: plot range deprecated, removed P(...) token" << std::endl ;
699
700 } else if (!token.CompareTo("F")) {
701
702 // Next tokens are fit limits
703 double fitMin;
704 double fitMax;
705 Int_t fitBins ;
706 if (parser.expectToken("(",true) ||
707 parser.readDouble(fitMin,true) ||
708 parser.expectToken("-",true) ||
709 parser.readDouble(fitMax,true) ||
710 parser.expectToken(":",true) ||
711 parser.readInteger(fitBins,true) ||
712 parser.expectToken(")",true)) break ;
713 //setBins(fitBins) ;
714 //setRange(fitMin,fitMax) ;
715 coutW(Eval) << "RooRealVar::readFromStream(" << GetName()
716 << ") WARNING: F(lo-hi:bins) token deprecated, use L(lo-hi) B(bins)" << std::endl ;
717 if (!haveConstant) setConstant(false) ;
718
719 } else if (!token.CompareTo("L")) {
720
721 // Next tokens are fit limits
722 double fitMin = 0.0;
723 double fitMax = 0.0;
724 // Int_t fitBins ;
725 if (parser.expectToken("(",true) ||
726 parser.readDouble(fitMin,true) ||
727 parser.expectToken("-",true) ||
728 parser.readDouble(fitMax,true) ||
729 parser.expectToken(")",true)) break ;
731 if (!haveConstant) setConstant(false) ;
732
733 } else if (!token.CompareTo("B")) {
734
735 // Next tokens are fit limits
736 Int_t fitBins = 0;
737 if (parser.expectToken("(",true) ||
738 parser.readInteger(fitBins,true) ||
739 parser.expectToken(")",true)) break ;
741
742 } else {
743 // Token is value
744 if (parser.convertToDouble(token,value)) { parser.zapToEnd() ; break ; }
745 haveValue = true ;
746 // Defer value assignment to end
747 }
748 }
749 if (haveValue) setVal(value) ;
750 return false ;
751 }
752}
753
754
755////////////////////////////////////////////////////////////////////////////////
756/// Write object contents to given stream
757
758void RooRealVar::writeToStream(ostream &os, bool compact) const
759{
760 if (compact) {
761 // Write value only
762 os << getVal();
763 return;
764 }
765
766 // Write value with error (if not zero)
767 if (_printScientific) {
768 std::stringstream text;
769
771 int nDigitsErr = (_printSigDigits + 1) / 2;
772
773 text << std::scientific;
774
775 if (_value >= 0)
776 text << " ";
777 text << std::setprecision(nDigitsVal) << _value;
778
779 text << std::setprecision(nDigitsErr) << " +/- ";
780 if (hasAsymError()) {
781 text << "(" << getAsymErrorLo() << ", " << getAsymErrorHi() << ")";
782 } else if (hasError()) {
783 text << getError();
784 }
785
786 os << text.str() << " ";
787 } else {
788 os << format(_printSigDigits, "EFA") << " ";
789 }
790
791 // Append limits if not constants
792 if (isConstant()) {
793 os << "C ";
794 }
795
796 // Append fit limits
797 if (hasMin()) {
798 os << "L(" << getMin();
799 } else {
800 os << "L(-INF";
801 }
802 if (hasMax()) {
803 os << " - " << getMax() << ") ";
804 } else {
805 os << " - +INF) ";
806 }
807
808 if (getBins() != 100) {
809 os << "B(" << getBins() << ") ";
810 }
811
812 // Add comment with unit, if unit exists
813 if (!_unit.IsNull())
814 os << "// [" << getUnit() << "]";
815}
816
817
818
819////////////////////////////////////////////////////////////////////////////////
820/// Print value of variable
821
822void RooRealVar::printValue(ostream& os) const
823{
824 os << getVal() ;
825
826 if(hasError() && !hasAsymError()) {
827 os << " +/- " << getError() ;
828 } else if (hasAsymError()) {
829 os << " +/- (" << getAsymErrorLo() << "," << getAsymErrorHi() << ")" ;
830 }
831
832}
833
834
835////////////////////////////////////////////////////////////////////////////////
836/// Print extras of variable: (asymmetric) error, constant flag, limits and binning
837
838void RooRealVar::printExtras(ostream& os) const
839{
840 // Append limits if not constants
841 if (isConstant()) {
842 os << "C " ;
843 }
844
845 // Append fit limits
846 os << " L(" ;
847 if(hasMin()) {
848 os << getMin();
849 }
850 else {
851 os << "-INF";
852 }
853 if(hasMax()) {
854 os << " - " << getMax() ;
855 }
856 else {
857 os << " - +INF";
858 }
859 os << ") " ;
860
861 if (getBins()!=100) {
862 os << "B(" << getBins() << ") " ;
863 }
864
865 // Add comment with unit, if unit exists
866 if (!_unit.IsNull())
867 os << "// [" << getUnit() << "]" ;
868
869// std::cout << " _value = " << &_value << " _error = " << &_error ;
870
871
872}
873
874
875////////////////////////////////////////////////////////////////////////////////
876/// Mapping of Print() option string to RooPrintable contents specifications
877
879{
880 if (opt && TString(opt)=="I") {
881 return kName|kClassName|kValue ;
882 }
884}
885
886
887////////////////////////////////////////////////////////////////////////////////
888/// Detailed printing interface
889
890void RooRealVar::printMultiline(ostream& os, Int_t contents, bool verbose, TString indent) const
891{
892 RooAbsRealLValue::printMultiline(os,contents,verbose,indent);
893 os << indent << "--- RooRealVar ---" << std::endl;
894 TString unit(_unit);
895 if(!unit.IsNull()) unit.Prepend(' ');
896 os << indent << " Error = " << getError() << unit << std::endl;
897}
898
899
900
901////////////////////////////////////////////////////////////////////////////////
902/// Format contents of RooRealVar for pretty printing on RooPlot
903/// parameter boxes. This function processes the named arguments
904/// taken by paramOn() and translates them to an option string
905/// parsed by RooRealVar::format(Int_t sigDigits, const char *options)
906
907std::string RooRealVar::format(const RooCmdArg& formatArg) const
908{
909 RooCmdArg tmp(formatArg) ;
910 tmp.setProcessRecArgs(true) ;
911
912 RooCmdConfig pc("RooRealVar::format(" + std::string(GetName()) + ")");
913 pc.defineString("what","FormatArgs",0,"") ;
914 pc.defineInt("autop","FormatArgs::AutoPrecision",0,2) ;
915 pc.defineInt("fixedp","FormatArgs::FixedPrecision",0,2) ;
916 pc.defineInt("tlatex","FormatArgs::TLatexStyle",0,0) ;
917 pc.defineInt("latex","FormatArgs::LatexStyle",0,0) ;
918 pc.defineInt("latext","FormatArgs::LatexTableStyle",0,0) ;
919 pc.defineInt("verbn","FormatArgs::VerbatimName",0,0) ;
920 pc.defineMutex("FormatArgs::TLatexStyle","FormatArgs::LatexStyle","FormatArgs::LatexTableStyle") ;
921 pc.defineMutex("FormatArgs::AutoPrecision","FormatArgs::FixedPrecision") ;
922
923 // Process & check varargs
924 pc.process(tmp) ;
925 if (!pc.ok(true)) {
926 return "";
927 }
928
929 // Extract values from named arguments
930 TString options ;
931 options = pc.getString("what") ;
932
933 if (pc.getInt("tlatex")) {
934 options += "L" ;
935 } else if (pc.getInt("latex")) {
936 options += "X" ;
937 } else if (pc.getInt("latext")) {
938 options += "Y" ;
939 }
940
941 if (pc.getInt("verbn")) options += "V" ;
942 Int_t sigDigits = 2 ;
943 if (pc.hasProcessed("FormatArgs::AutoPrecision")) {
944 options += "P" ;
945 sigDigits = pc.getInt("autop") ;
946 } else if (pc.hasProcessed("FormatArgs::FixedPrecision")) {
947 options += "F" ;
948 sigDigits = pc.getInt("fixedp") ;
949 }
950
951 return format(sigDigits,options) ;
952}
953
954
955
956
957////////////////////////////////////////////////////////////////////////////////
958/// Format numeric value of RooRealVar and its error in a variety of ways
959///
960/// To control what is shown use the following options
961/// N = show name
962/// T = show title (takes precedent over `N`, falls back to `N` if title is empty)
963/// H = hide value
964/// E = show error
965/// A = show asymmetric error instead of parabolic error (if available)
966/// U = show unit
967///
968/// To control how it is shown use these options
969/// L = TLatex mode
970/// X = Latex mode
971/// Y = Latex table mode ( '=' replaced by '&' )
972/// V = Make name \\verbatim in Latex mode
973/// P = use error to control shown precision
974/// F = force fixed precision
975///
976
977std::string RooRealVar::format(Int_t sigDigits, const char *options) const
978{
979 // parse the options string
980 TString opts(options);
981 opts.ToLower();
982
983 bool showName= opts.Contains("n");
984 bool showTitle = opts.Contains("t");
985 bool hideValue= opts.Contains("h");
986 bool showError= opts.Contains("e");
987 bool showUnit= opts.Contains("u");
988 bool tlatexMode= opts.Contains("l");
989 bool latexMode= opts.Contains("x");
990 bool latexTableMode = opts.Contains("y") ;
991 bool latexVerbatimName = opts.Contains("v") ;
992
993 std::string label = showName ? getPlotLabel() : "";
994 if(showTitle) {
995 label = GetTitle();
996 if(label.empty()) label = getPlotLabel();
997 }
998
1000 bool asymError= opts.Contains("a") ;
1001 bool useErrorForPrecision= (((showError && hasError(false) && !isConstant()) || opts.Contains("p")) && !opts.Contains("f")) ;
1002 // calculate the precision to use
1003 if(sigDigits < 1) sigDigits= 1;
1006 leadingDigitVal = (Int_t)floor(log10(std::abs(_error+1e-10)));
1007 if (_value==0&&_error==0) leadingDigitVal=0 ;
1008 } else {
1009 leadingDigitVal = (Int_t)floor(log10(std::abs(_value+1e-10)));
1010 if (_value==0) leadingDigitVal=0 ;
1011 }
1012 Int_t leadingDigitErr= (Int_t)floor(log10(std::abs(_error+1e-10)));
1015
1016 if (_value<0) whereVal -= 1 ;
1017 int nDigitsVal = whereVal < 0 ? -whereVal : 0;
1018 int nDigitsErr = whereErr < 0 ? -whereErr : 0;
1019
1020 std::stringstream text;
1021
1022 if (latexMode)
1023 text << "$";
1024 // begin the string with "<name> = " if requested
1025 if(showName || showTitle) {
1027 text << "\\verb+";
1028 }
1029 text << label;
1031 text << "+";
1032
1033 if (!latexTableMode) {
1034 text << " = ";
1035 } else {
1036 text << " $ & $ ";
1037 }
1038 }
1039
1040 // Add leading space if value is positive
1041 if (_value >= 0)
1042 text << " ";
1043
1044 // append our value if requested
1045 text << std::fixed;
1046 if(!hideValue) {
1047 text << std::setprecision(nDigitsVal) << _value;
1048 }
1049 text << std::setprecision(nDigitsErr); // we only print errors from now on
1050
1051 // append our error if requested and this variable is not constant
1052 if(hasError(false) && showError && !(asymError && hasAsymError(false))) {
1053 if(tlatexMode) {
1054 text << " #pm " << getError();
1055 }
1056 else {
1057 text << (latexMode ? "\\pm " : " +/- ") << getError();
1058 }
1059 }
1060
1061 if (asymError && hasAsymError() && showError) {
1062 if(tlatexMode) {
1063 text << " #pm _{" << getAsymErrorLo() << "}^{+" << getAsymErrorHi() << "}";
1064 }
1065 else if(latexMode) {
1066 text << "\\pm _{" << getAsymErrorLo() << "}^{+" << getAsymErrorHi() << "}";
1067 }
1068 else {
1069 text << " +/- (" << getAsymErrorLo() << ", " << getAsymErrorHi() << ")";
1070 }
1071
1072 }
1073
1074 // append our units if requested
1075 if(!_unit.IsNull() && showUnit) {
1076 text << ' ' << _unit;
1077 }
1078 if (latexMode)
1079 text << "$";
1080 return text.str();
1081}
1082
1083////////////////////////////////////////////////////////////////////////////////
1084/// Overload RooAbsReal::attachToTree to also attach
1085/// branches for errors and/or asymmetric errors
1086/// attribute StoreError and/or StoreAsymError are set
1087
1089{
1090 // Follow usual procedure for value
1091
1092 if (getAttribute("StoreError") || getAttribute("StoreAsymError") || vstore.isFullReal(this) ) {
1093
1094 RooVectorDataStore::RealFullVector* rfv = vstore.addRealFull(this) ;
1095 rfv->setBuffer(this,&_value);
1096
1097 // Attach/create additional branch for error
1098 if (getAttribute("StoreError") || vstore.hasError(this) ) {
1099 rfv->setErrorBuffer(&_error) ;
1100 }
1101
1102 // Attach/create additional branches for asymmetric error
1103 if (getAttribute("StoreAsymError") || vstore.hasAsymError(this)) {
1104 rfv->setAsymErrorBuffer(&_asymErrLo,&_asymErrHi) ;
1105 }
1106
1107 } else {
1108
1110
1111 }
1112}
1113
1114
1115
1116////////////////////////////////////////////////////////////////////////////////
1117/// Overload RooAbsReal::attachToTree to also attach
1118/// branches for errors and/or asymmetric errors
1119/// attribute StoreError and/or StoreAsymError are set
1120
1122{
1123 // Follow usual procedure for value
1125// std::cout << "RooRealVar::attachToTree(" << this << ") name = " << GetName()
1126// << " StoreError = " << (getAttribute("StoreError")?"T":"F") << std::endl ;
1127
1128 // Attach/create additional branch for error
1129 if (getAttribute("StoreError")) {
1131 errName.Append("_err") ;
1133 if (branch) {
1135 } else {
1137 format2.Append("/D");
1138 t.Branch(errName, &_error, (const Text_t*)format2, bufSize);
1139 }
1140 }
1141
1142 // Attach/create additional branches for asymmetric error
1143 if (getAttribute("StoreAsymError")) {
1145 loName.Append("_aerr_lo") ;
1147 if (lobranch) {
1149 } else {
1151 format2.Append("/D");
1153 }
1154
1156 hiName.Append("_aerr_hi") ;
1158 if (hibranch) {
1160 } else {
1162 format2.Append("/D");
1164 }
1165 }
1166}
1167
1168
1169////////////////////////////////////////////////////////////////////////////////
1170/// Overload RooAbsReal::fillTreeBranch to also
1171/// fill tree branches with (asymmetric) errors
1172/// if requested.
1173
1175{
1176 // First determine if branch is taken
1179 if (!valBranch) {
1180 coutE(Eval) << "RooAbsReal::fillTreeBranch(" << GetName() << ") ERROR: not attached to tree" << std::endl ;
1181 assert(0) ;
1182 }
1183 valBranch->Fill() ;
1184
1185 if (getAttribute("StoreError")) {
1187 errName.Append("_err") ;
1189 if (errBranch) errBranch->Fill() ;
1190 }
1191
1192 if (getAttribute("StoreAsymError")) {
1194 loName.Append("_aerr_lo") ;
1196 if (loBranch) loBranch->Fill() ;
1197
1199 hiName.Append("_aerr_hi") ;
1201 if (hiBranch) hiBranch->Fill() ;
1202 }
1203}
1204
1205
1206
1207////////////////////////////////////////////////////////////////////////////////
1208/// Copy the cached value of another RooAbsArg to our cache
1209/// Warning: This function copies the cached values of source,
1210/// it is the callers responsibility to make sure the cache is clean
1211
1213{
1214 // Follow usual procedure for valueklog
1215 double oldVal = _value;
1217 if(_value != oldVal) {
1219 }
1220
1221 if (valueOnly) return ;
1222
1223 // Copy error too, if source has one
1224 RooRealVar* other = dynamic_cast<RooRealVar*>(const_cast<RooAbsArg*>(source)) ;
1225 if (other) {
1226 // Copy additional error value
1227 _error = other->_error ;
1228 _asymErrLo = other->_asymErrLo ;
1229 _asymErrHi = other->_asymErrHi ;
1230 }
1231}
1232
1233
1234
1235////////////////////////////////////////////////////////////////////////////////
1236/// Stream an object of class RooRealVar.
1237
1239{
1240 UInt_t R__s;
1241 UInt_t R__c;
1242 if (R__b.IsReading()) {
1243
1244 Version_t R__v = R__b.ReadVersion(&R__s, &R__c); if (R__v) { }
1246 if (R__v==1) {
1247 coutI(Eval) << "RooRealVar::Streamer(" << GetName() << ") converting version 1 data format" << std::endl ;
1248 double fitMin;
1249 double fitMax;
1250 Int_t fitBins ;
1251 R__b >> fitMin;
1252 R__b >> fitMax;
1253 R__b >> fitBins;
1254 _binning = std::make_unique<RooUniformBinning>(fitMin,fitMax,fitBins);
1255 }
1256 R__b >> _error;
1257 R__b >> _asymErrLo;
1258 R__b >> _asymErrHi;
1259 if (R__v>=2) {
1260 RooAbsBinning* binning;
1261 R__b >> binning;
1262 _binning.reset(binning);
1263 }
1264 if (R__v==3) {
1265 // In v3, properties were written as pointers, so read now and install:
1267 R__b >> tmpProp;
1268 installSharedProp(std::shared_ptr<RooRealVarSharedProperties>(tmpProp));
1269 }
1270 if (R__v>=4) {
1271 // In >= v4, properties were written directly, but they might be the "_nullProp"
1272 auto tmpProp = std::make_shared<RooRealVarSharedProperties>();
1273 tmpProp->Streamer(R__b);
1274 installSharedProp(std::move(tmpProp));
1275 }
1276
1277 R__b.CheckByteCount(R__s, R__c, RooRealVar::IsA());
1278
1279 } else {
1280
1281 R__c = R__b.WriteVersion(RooRealVar::IsA(), true);
1283 R__b << _error;
1284 R__b << _asymErrLo;
1285 R__b << _asymErrHi;
1286 R__b << _binning.get();
1287 if (_sharedProp) {
1288 _sharedProp->Streamer(R__b) ;
1289 } else {
1290 _nullProp().Streamer(R__b) ;
1291 }
1292 R__b.SetByteCount(R__c, true);
1293
1294 }
1295}
1296
1297/// Hand out our shared property, create on the fly and register
1298/// in shared map if necessary.
1299std::shared_ptr<RooRealVarSharedProperties> RooRealVar::sharedProp() const {
1300 if (!_sharedProp) {
1301 const_cast<RooRealVar*>(this)->installSharedProp(std::make_shared<RooRealVarSharedProperties>());
1302 }
1303
1304 return _sharedProp;
1305}
1306
1307
1308////////////////////////////////////////////////////////////////////////////////
1309/// Install the shared property into the member _sharedProp.
1310/// If a property with same name already exists, discard the incoming one,
1311/// and share the existing.
1312/// `nullptr` and properties equal to the RooRealVar::_nullProp will not be installed.
1313void RooRealVar::installSharedProp(std::shared_ptr<RooRealVarSharedProperties>&& prop) {
1314 if (prop == nullptr || (*prop == _nullProp())) {
1315 _sharedProp = nullptr;
1316 return;
1317 }
1318
1319
1320 auto& weakPtr = (*sharedPropList())[prop->uuid()];
1321 std::shared_ptr<RooRealVarSharedProperties> existingProp;
1322 if ( (existingProp = weakPtr.lock()) ) {
1323 // Property exists, discard incoming
1324 _sharedProp = std::move(existingProp);
1325 // Incoming is not allowed to delete the binnings now - they are owned by the other instance
1326 prop->disownBinnings();
1327 } else {
1328 // Doesn't exist. Install, register weak pointer for future sharing
1329 _sharedProp = std::move(prop);
1331 }
1332}
1333
1334
1335////////////////////////////////////////////////////////////////////////////////
1336/// Stop sharing properties.
1338{
1339 // Nothing to do if there were no shared properties to begin with.
1340 if(!_sharedProp) return;
1341
1342 // Get the key for the _sharedPropList.
1343 auto key = _sharedProp->uuid(); // we have to make a copy because _sharedPropList gets delete next.
1344
1345 // Actually delete the shared properties object.
1346 _sharedProp.reset();
1347
1348 // If the _sharedPropList was already deleted, we can return now.
1349 if(!sharedPropList()) return;
1350
1351 // Find the std::weak_ptr that the _sharedPropList holds to our
1352 // _sharedProp.
1353 auto iter = sharedPropList()->find(key);
1354
1355 // If no other RooRealVars shared the shared properties with us, the
1356 // weak_ptr in _sharedPropList is expired and we can erase it from the map.
1357 if(iter->second.expired()) {
1358 sharedPropList()->erase(iter);
1359 }
1360}
1361
1362
1363////////////////////////////////////////////////////////////////////////////////
1364/// If true, contents of RooRealVars will be printed in scientific notation
1365
1370
1371
1372////////////////////////////////////////////////////////////////////////////////
1373/// Set number of digits to show when printing RooRealVars
1374
#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 setVal(double value) override
Set value of variable to 'value'.
double _error
Symmetric error associated with current value.
Definition RooRealVar.h:159
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:163
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:171
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:162
void removeRange(const char *name=nullptr) R__DEPRECATED(6
Remove range limits for binning with given name. Empty name means default range.
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:160
void installSharedProp(std::shared_ptr< RooRealVarSharedProperties > &&prop)
Install the shared property into the member _sharedProp.
static bool _printScientific
Definition RooRealVar.h:141
std::shared_ptr< RooRealVarSharedProperties > _sharedProp
! Shared binnings associated with this instance
Definition RooRealVar.h:175
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:177
~RooRealVar() override
Destructor.
double _asymErrHi
High side of asymmetric error associated with current value.
Definition RooRealVar.h:161
static Int_t _printSigDigits
Definition RooRealVar.h:142
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...
void removeRange was a misleading name Please use removeMin()\" and \"removeMax()\" instead
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:181
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:42
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:464
TString & Prepend(const char *cs)
Definition TString.h:682
Bool_t IsNull() const
Definition TString.h:422
TString & Append(const char *cs)
Definition TString.h:581
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:8675
virtual TBranch * GetBranch(const char *name)
Return pointer to the branch with the given name in this tree or its friends.
Definition TTree.cxx:5430
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:397