RooRealVar.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * Project: RooFit                                                           *
00003  * Package: RooFitCore                                                       *
00004  *    File: $Id: RooRealVar.h,v 1.54 2007/05/11 09:11:30 verkerke Exp $
00005  * Authors:                                                                  *
00006  *   WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu       *
00007  *   DK, David Kirkby,    UC Irvine,         dkirkby@uci.edu                 *
00008  *                                                                           *
00009  * Copyright (c) 2000-2005, Regents of the University of California          *
00010  *                          and Stanford University. All rights reserved.    *
00011  *                                                                           *
00012  * Redistribution and use in source and binary forms,                        *
00013  * with or without modification, are permitted according to the terms        *
00014  * listed in LICENSE (http://roofit.sourceforge.net/license.txt)             *
00015  *****************************************************************************/
00016 #ifndef ROO_REAL_VAR
00017 #define ROO_REAL_VAR
00018 
00019 #include "Riosfwd.h"
00020 #include <math.h>
00021 #include <float.h>
00022 #include "TString.h"
00023 
00024 #include "RooAbsRealLValue.h"
00025 #include "RooUniformBinning.h"
00026 #include "RooNumber.h"
00027 #include "RooSharedPropertiesList.h"
00028 #include "RooRealVarSharedProperties.h"
00029 
00030 class RooArgSet ;
00031 class RooErrorVar ;
00032 
00033 class RooRealVar : public RooAbsRealLValue {
00034 public:
00035   // Constructors, assignment etc.
00036   RooRealVar() ;
00037   RooRealVar(const char *name, const char *title,
00038            Double_t value, const char *unit= "") ;
00039   RooRealVar(const char *name, const char *title, Double_t minValue, 
00040            Double_t maxValue, const char *unit= "");
00041   RooRealVar(const char *name, const char *title, Double_t value, 
00042            Double_t minValue, Double_t maxValue, const char *unit= "") ;
00043   RooRealVar(const RooRealVar& other, const char* name=0);
00044   virtual TObject* clone(const char* newname) const { return new RooRealVar(*this,newname); }
00045   virtual ~RooRealVar();
00046   
00047   // Parameter value and error accessors
00048   virtual Double_t getVal(const RooArgSet* nset=0) const ;
00049   virtual void setVal(Double_t value);
00050   inline Double_t getError() const { return _error>=0?_error:0. ; }
00051   inline Bool_t hasError(Bool_t allowZero=kTRUE) const { return allowZero ? (_error>=0) : (_error>0) ; }
00052   inline void setError(Double_t value) { _error= value ; }
00053   inline void removeError() { _error = -1 ; }
00054   inline Double_t getAsymErrorLo() const { return _asymErrLo<=0?_asymErrLo:0. ; }
00055   inline Double_t getAsymErrorHi() const { return _asymErrHi>=0?_asymErrHi:0. ; }
00056   inline Bool_t hasAsymError(Bool_t allowZero=kTRUE) const { return allowZero ? ((_asymErrHi>=0 && _asymErrLo<=0)) :  ((_asymErrHi>0 && _asymErrLo<0)) ; }
00057   inline void removeAsymError() { _asymErrLo = 1 ; _asymErrHi = -1 ; }
00058   inline void setAsymError(Double_t lo, Double_t hi) { _asymErrLo = lo ; _asymErrHi = hi ; }
00059   inline Double_t getErrorLo() const { return _asymErrLo<=0?_asymErrLo:-1*_error ; }
00060   inline Double_t getErrorHi() const { return _asymErrHi>=0?_asymErrHi:_error ; }
00061   
00062   RooErrorVar* errorVar() const ;
00063 
00064   // Set/get finite fit range limits
00065   void setMin(const char* name, Double_t value) ;
00066   void setMax(const char* name, Double_t value) ;
00067   void setRange(const char* name, Double_t min, Double_t max) ;
00068   void setRange(const char* name, RooAbsReal& min, RooAbsReal& max) ;
00069   inline void setMin(Double_t value) { setMin(0,value) ; }
00070   inline void setMax(Double_t value) { setMax(0,value) ; }
00071   inline void setRange(Double_t min, Double_t max) { setRange(0,min,max) ; }
00072   inline void setRange(RooAbsReal& min, RooAbsReal& max) { setRange(0,min,max) ; }
00073 
00074   void setBins(Int_t nBins, const char* name=0) { setBinning(RooUniformBinning(getMin(name),getMax(name),nBins),name) ; } 
00075   void setBinning(const RooAbsBinning& binning, const char* name=0) ;
00076 
00077   // RooAbsRealLValue implementation
00078   Bool_t hasBinning(const char* name) const ;
00079   const RooAbsBinning& getBinning(const char* name=0, Bool_t verbose=kTRUE, Bool_t createOnTheFly=kFALSE) const ;
00080   RooAbsBinning& getBinning(const char* name=0, Bool_t verbose=kTRUE, Bool_t createOnTheFly=kFALSE) ; 
00081 
00082   // Set infinite fit range limits
00083   inline void removeMin(const char* name=0) { getBinning(name).setMin(-RooNumber::infinity()) ; }
00084   inline void removeMax(const char* name=0) { getBinning(name).setMax(RooNumber::infinity()) ; }
00085   inline void removeRange(const char* name=0) { getBinning(name).setRange(-RooNumber::infinity(),RooNumber::infinity()) ; }
00086  
00087   // I/O streaming interface (machine readable)
00088   virtual Bool_t readFromStream(istream& is, Bool_t compact, Bool_t verbose=kFALSE) ;
00089   virtual void writeToStream(ostream& os, Bool_t compact) const ;
00090 
00091   // We implement a fundamental type of AbsArg that can be stored in a dataset
00092   inline virtual Bool_t isFundamental() const { return kTRUE; }
00093 
00094   // Force to be a leaf-node of any expression tree, even if we have (shape) servers
00095   // virtual Bool_t isDerived() const { return kFALSE ; }
00096 
00097   // Printing interface (human readable)
00098   virtual void printValue(ostream& os) const ;
00099   virtual void printExtras(ostream& os) const ;
00100   virtual void printMultiline(ostream& os, Int_t contents, Bool_t verbose=kFALSE, TString indent="") const ;
00101   virtual Int_t defaultPrintContents(Option_t* opt) const ;
00102 
00103 
00104   TString* format(const RooCmdArg& formatArg) const ;
00105   TString* format(Int_t sigDigits, const char *options) const ;
00106 
00107   static void printScientific(Bool_t flag=kFALSE) ;
00108   static void printSigDigits(Int_t ndig=5) ;
00109 
00110   using RooAbsRealLValue::operator= ;
00111 
00112   void deleteSharedProperties() ;
00113 
00114   protected:
00115 
00116   static Bool_t _printScientific ;
00117   static Int_t  _printSigDigits ;
00118 
00119   virtual void setVal(Double_t value, const char* rangeName) ;
00120   virtual void setValFast(Double_t value) { _value = value ; setValueDirty() ; }
00121 
00122 
00123   virtual Double_t evaluate() const { return _value ; } // dummy because we overloaded getVal()
00124   virtual void copyCache(const RooAbsArg* source, Bool_t valueOnly=kFALSE) ;
00125   virtual void attachToTree(TTree& t, Int_t bufSize=32000) ;
00126   virtual void fillTreeBranch(TTree& t) ;
00127 
00128   Double_t chopAt(Double_t what, Int_t where) const ;
00129 
00130   Double_t _error;      // Symmetric error associated with current value
00131   Double_t _asymErrLo ; // Low side of asymmetric error associated with current value
00132   Double_t _asymErrHi ; // High side of asymmetric error associated with current value
00133   RooAbsBinning* _binning ; 
00134   RooLinkedList _altNonSharedBinning ; // Non-shareable alternative binnings
00135 
00136   inline RooRealVarSharedProperties* sharedProp() const {
00137     if (!_sharedProp) {
00138       _sharedProp = (RooRealVarSharedProperties*) _sharedPropList.registerProperties(new RooRealVarSharedProperties()) ;
00139     }
00140     return _sharedProp ;
00141   }
00142   
00143   static RooSharedPropertiesList _sharedPropList; // List of properties shared among clone sets 
00144   static RooRealVarSharedProperties _nullProp ; // Null property
00145   mutable RooRealVarSharedProperties* _sharedProp ; //! Shared properties associated with this instance
00146 
00147   ClassDef(RooRealVar,5) // Real-valued variable 
00148 };
00149 
00150 
00151 
00152 
00153 #endif

Generated on Tue Jul 5 14:26:20 2011 for ROOT_528-00b_version by  doxygen 1.5.1