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