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