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