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