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