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