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