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