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