ROOT logo
/*****************************************************************************
 * Project: RooFit                                                           *
 * Package: RooFitCore                                                       *
 *    File: $Id: RooRealVar.h,v 1.54 2007/05/11 09:11:30 verkerke Exp $
 * Authors:                                                                  *
 *   WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu       *
 *   DK, David Kirkby,    UC Irvine,         dkirkby@uci.edu                 *
 *                                                                           *
 * Copyright (c) 2000-2005, Regents of the University of California          *
 *                          and Stanford University. All rights reserved.    *
 *                                                                           *
 * Redistribution and use in source and binary forms,                        *
 * with or without modification, are permitted according to the terms        *
 * listed in LICENSE (http://roofit.sourceforge.net/license.txt)             *
 *****************************************************************************/
#ifndef ROO_REAL_VAR
#define ROO_REAL_VAR

#include <list>
#include <string>
#include "Riosfwd.h"
#include <math.h>
#include <float.h>
#include "TString.h"

#include "RooAbsRealLValue.h"
#include "RooUniformBinning.h"
#include "RooNumber.h"
#include "RooSharedPropertiesList.h"
#include "RooRealVarSharedProperties.h"

class RooArgSet ;
class RooErrorVar ;
class RooVectorDataStore ;
class RooExpensiveObjectCache ;

class RooRealVar : public RooAbsRealLValue {
public:
  // Constructors, assignment etc.
  RooRealVar() ;
  RooRealVar(const char *name, const char *title,
  	   Double_t value, const char *unit= "") ;
  RooRealVar(const char *name, const char *title, Double_t minValue, 
	   Double_t maxValue, const char *unit= "");
  RooRealVar(const char *name, const char *title, Double_t value, 
	   Double_t minValue, Double_t maxValue, const char *unit= "") ;
  RooRealVar(const RooRealVar& other, const char* name=0);
  virtual TObject* clone(const char* newname) const { return new RooRealVar(*this,newname); }
  virtual ~RooRealVar();
  
  // Parameter value and error accessors
  virtual Double_t getValV(const RooArgSet* nset=0) const ;
  virtual void setVal(Double_t value);
  inline Double_t getError() const { return _error>=0?_error:0. ; }
  inline Bool_t hasError(Bool_t allowZero=kTRUE) const { return allowZero ? (_error>=0) : (_error>0) ; }
  inline void setError(Double_t value) { _error= value ; }
  inline void removeError() { _error = -1 ; }
  inline Double_t getAsymErrorLo() const { return _asymErrLo<=0?_asymErrLo:0. ; }
  inline Double_t getAsymErrorHi() const { return _asymErrHi>=0?_asymErrHi:0. ; }
  inline Bool_t hasAsymError(Bool_t allowZero=kTRUE) const { return allowZero ? ((_asymErrHi>=0 && _asymErrLo<=0)) :  ((_asymErrHi>0 && _asymErrLo<0)) ; }
  inline void removeAsymError() { _asymErrLo = 1 ; _asymErrHi = -1 ; }
  inline void setAsymError(Double_t lo, Double_t hi) { _asymErrLo = lo ; _asymErrHi = hi ; }
  inline Double_t getErrorLo() const { return _asymErrLo<=0?_asymErrLo:-1*_error ; }
  inline Double_t getErrorHi() const { return _asymErrHi>=0?_asymErrHi:_error ; }
  
  RooErrorVar* errorVar() const ;

  // Set/get finite fit range limits
  void setMin(const char* name, Double_t value) ;
  void setMax(const char* name, Double_t value) ;
  void setRange(const char* name, Double_t min, Double_t max) ;
  void setRange(const char* name, RooAbsReal& min, RooAbsReal& max) ;
  inline void setMin(Double_t value) { setMin(0,value) ; }
  inline void setMax(Double_t value) { setMax(0,value) ; }
  inline void setRange(Double_t min, Double_t max) { setRange(0,min,max) ; }
  inline void setRange(RooAbsReal& min, RooAbsReal& max) { setRange(0,min,max) ; }

  void setBins(Int_t nBins, const char* name=0) { setBinning(RooUniformBinning(getMin(name),getMax(name),nBins),name) ; } 
  void setBinning(const RooAbsBinning& binning, const char* name=0) ;

  // RooAbsRealLValue implementation
  Bool_t hasBinning(const char* name) const ;
  const RooAbsBinning& getBinning(const char* name=0, Bool_t verbose=kTRUE, Bool_t createOnTheFly=kFALSE) const ;
  RooAbsBinning& getBinning(const char* name=0, Bool_t verbose=kTRUE, Bool_t createOnTheFly=kFALSE) ; 
  std::list<std::string> getBinningNames() const ;

  // Set infinite fit range limits
  inline void removeMin(const char* name=0) { getBinning(name).setMin(-RooNumber::infinity()) ; }
  inline void removeMax(const char* name=0) { getBinning(name).setMax(RooNumber::infinity()) ; }
  inline void removeRange(const char* name=0) { getBinning(name).setRange(-RooNumber::infinity(),RooNumber::infinity()) ; }
 
  // I/O streaming interface (machine readable)
  virtual Bool_t readFromStream(std::istream& is, Bool_t compact, Bool_t verbose=kFALSE) ;
  virtual void writeToStream(std::ostream& os, Bool_t compact) const ;

  // We implement a fundamental type of AbsArg that can be stored in a dataset
  inline virtual Bool_t isFundamental() const { return kTRUE; }

  // Force to be a leaf-node of any expression tree, even if we have (shape) servers
  virtual Bool_t isDerived() const { 
    // Does value or shape of this arg depend on any other arg?
    return (_serverList.GetSize()>0 || _proxyList.GetEntries()>0)?kTRUE:kFALSE; 
  }

  // Printing interface (human readable)
  virtual void printValue(std::ostream& os) const ;
  virtual void printExtras(std::ostream& os) const ;
  virtual void printMultiline(std::ostream& os, Int_t contents, Bool_t verbose=kFALSE, TString indent="") const ;
  virtual Int_t defaultPrintContents(Option_t* opt) const ;


  TString* format(const RooCmdArg& formatArg) const ;
  TString* format(Int_t sigDigits, const char *options) const ;

  static void printScientific(Bool_t flag=kFALSE) ;
  static void printSigDigits(Int_t ndig=5) ;

  using RooAbsRealLValue::operator= ;

  void deleteSharedProperties() ;

  void copyCacheFast(const RooRealVar& other, Bool_t setValDirty=kTRUE) { _value = other._value ; if (setValDirty) setValueDirty() ; }

  protected:

  static Bool_t _printScientific ;
  static Int_t  _printSigDigits ;

  virtual void setVal(Double_t value, const char* rangeName) ;

  friend class RooAbsRealLValue ;
  virtual void setValFast(Double_t value) { _value = value ; setValueDirty() ; }


  virtual Double_t evaluate() const { return _value ; } // dummy because we overloaded getVal()
  virtual void copyCache(const RooAbsArg* source, Bool_t valueOnly=kFALSE, Bool_t setValDirty=kTRUE) ;
  virtual void attachToTree(TTree& t, Int_t bufSize=32000) ;
  virtual void attachToVStore(RooVectorDataStore& vstore) ;
  virtual void fillTreeBranch(TTree& t) ;

  Double_t chopAt(Double_t what, Int_t where) const ;

  Double_t _error;      // Symmetric error associated with current value
  Double_t _asymErrLo ; // Low side of asymmetric error associated with current value
  Double_t _asymErrHi ; // High side of asymmetric error associated with current value
  RooAbsBinning* _binning ; 
  RooLinkedList _altNonSharedBinning ; // Non-shareable alternative binnings

  inline RooRealVarSharedProperties* sharedProp() const {
    if (!_sharedProp) {
      _sharedProp = (RooRealVarSharedProperties*) _sharedPropList.registerProperties(new RooRealVarSharedProperties()) ;
    }
    return _sharedProp ;
  }

  virtual void setExpensiveObjectCache(RooExpensiveObjectCache&) { ; } // variables don't need caches 
  
  static RooSharedPropertiesList _sharedPropList; // List of properties shared among clone sets 
  static RooRealVarSharedProperties _nullProp ; // Null property
  mutable RooRealVarSharedProperties* _sharedProp ; //! Shared properties associated with this instance

  ClassDef(RooRealVar,5) // Real-valued variable 
};




#endif
 RooRealVar.h:1
 RooRealVar.h:2
 RooRealVar.h:3
 RooRealVar.h:4
 RooRealVar.h:5
 RooRealVar.h:6
 RooRealVar.h:7
 RooRealVar.h:8
 RooRealVar.h:9
 RooRealVar.h:10
 RooRealVar.h:11
 RooRealVar.h:12
 RooRealVar.h:13
 RooRealVar.h:14
 RooRealVar.h:15
 RooRealVar.h:16
 RooRealVar.h:17
 RooRealVar.h:18
 RooRealVar.h:19
 RooRealVar.h:20
 RooRealVar.h:21
 RooRealVar.h:22
 RooRealVar.h:23
 RooRealVar.h:24
 RooRealVar.h:25
 RooRealVar.h:26
 RooRealVar.h:27
 RooRealVar.h:28
 RooRealVar.h:29
 RooRealVar.h:30
 RooRealVar.h:31
 RooRealVar.h:32
 RooRealVar.h:33
 RooRealVar.h:34
 RooRealVar.h:35
 RooRealVar.h:36
 RooRealVar.h:37
 RooRealVar.h:38
 RooRealVar.h:39
 RooRealVar.h:40
 RooRealVar.h:41
 RooRealVar.h:42
 RooRealVar.h:43
 RooRealVar.h:44
 RooRealVar.h:45
 RooRealVar.h:46
 RooRealVar.h:47
 RooRealVar.h:48
 RooRealVar.h:49
 RooRealVar.h:50
 RooRealVar.h:51
 RooRealVar.h:52
 RooRealVar.h:53
 RooRealVar.h:54
 RooRealVar.h:55
 RooRealVar.h:56
 RooRealVar.h:57
 RooRealVar.h:58
 RooRealVar.h:59
 RooRealVar.h:60
 RooRealVar.h:61
 RooRealVar.h:62
 RooRealVar.h:63
 RooRealVar.h:64
 RooRealVar.h:65
 RooRealVar.h:66
 RooRealVar.h:67
 RooRealVar.h:68
 RooRealVar.h:69
 RooRealVar.h:70
 RooRealVar.h:71
 RooRealVar.h:72
 RooRealVar.h:73
 RooRealVar.h:74
 RooRealVar.h:75
 RooRealVar.h:76
 RooRealVar.h:77
 RooRealVar.h:78
 RooRealVar.h:79
 RooRealVar.h:80
 RooRealVar.h:81
 RooRealVar.h:82
 RooRealVar.h:83
 RooRealVar.h:84
 RooRealVar.h:85
 RooRealVar.h:86
 RooRealVar.h:87
 RooRealVar.h:88
 RooRealVar.h:89
 RooRealVar.h:90
 RooRealVar.h:91
 RooRealVar.h:92
 RooRealVar.h:93
 RooRealVar.h:94
 RooRealVar.h:95
 RooRealVar.h:96
 RooRealVar.h:97
 RooRealVar.h:98
 RooRealVar.h:99
 RooRealVar.h:100
 RooRealVar.h:101
 RooRealVar.h:102
 RooRealVar.h:103
 RooRealVar.h:104
 RooRealVar.h:105
 RooRealVar.h:106
 RooRealVar.h:107
 RooRealVar.h:108
 RooRealVar.h:109
 RooRealVar.h:110
 RooRealVar.h:111
 RooRealVar.h:112
 RooRealVar.h:113
 RooRealVar.h:114
 RooRealVar.h:115
 RooRealVar.h:116
 RooRealVar.h:117
 RooRealVar.h:118
 RooRealVar.h:119
 RooRealVar.h:120
 RooRealVar.h:121
 RooRealVar.h:122
 RooRealVar.h:123
 RooRealVar.h:124
 RooRealVar.h:125
 RooRealVar.h:126
 RooRealVar.h:127
 RooRealVar.h:128
 RooRealVar.h:129
 RooRealVar.h:130
 RooRealVar.h:131
 RooRealVar.h:132
 RooRealVar.h:133
 RooRealVar.h:134
 RooRealVar.h:135
 RooRealVar.h:136
 RooRealVar.h:137
 RooRealVar.h:138
 RooRealVar.h:139
 RooRealVar.h:140
 RooRealVar.h:141
 RooRealVar.h:142
 RooRealVar.h:143
 RooRealVar.h:144
 RooRealVar.h:145
 RooRealVar.h:146
 RooRealVar.h:147
 RooRealVar.h:148
 RooRealVar.h:149
 RooRealVar.h:150
 RooRealVar.h:151
 RooRealVar.h:152
 RooRealVar.h:153
 RooRealVar.h:154
 RooRealVar.h:155
 RooRealVar.h:156
 RooRealVar.h:157
 RooRealVar.h:158
 RooRealVar.h:159
 RooRealVar.h:160
 RooRealVar.h:161
 RooRealVar.h:162
 RooRealVar.h:163
 RooRealVar.h:164
 RooRealVar.h:165
 RooRealVar.h:166
 RooRealVar.h:167
 RooRealVar.h:168