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