/*****************************************************************************
 * Project: RooFit                                                           *
 * Package: RooFitCore                                                       *
 *    File: $Id: RooErrorVar.h,v 1.16 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_ERROR_VAR
#define ROO_ERROR_VAR

#include "Riosfwd.h"
#include <math.h>
#include <float.h>

#include "RooNumber.h"
#include "RooAbsReal.h"
#include "RooRealVar.h"
#include "RooRealProxy.h"
class RooVectorDataStore ;

class RooErrorVar : public RooAbsRealLValue {
public:
  // Constructors, assignment etc.
  inline RooErrorVar() { 
    // Default constructor
  }
  RooErrorVar(const char *name, const char *title, const RooRealVar& input) ;
  RooErrorVar(const RooErrorVar& other, const char* name=0);
  virtual TObject* clone(const char* newname) const { return new RooErrorVar(*this,newname); }
  virtual ~RooErrorVar() ;

  virtual Double_t getValV(const RooArgSet* set=0) const ; 

  virtual Double_t evaluate() const { 
    // return error of input RooRealVar
    return ((RooRealVar&)_realVar.arg()).getError() ; 
  } 

  virtual void setVal(Double_t value) {
    // Set error of input RooRealVar to value
    ((RooRealVar&)_realVar.arg()).setVal(value) ; 
  }

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

  // 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 ;

  // Set/get finite fit range limits
  inline void setMin(Double_t value) { 
    // Set lower bound of default range to value
    setMin(0,value) ; 
  }
  inline void setMax(Double_t value) { 
    // Set upper bound of default range to value
    setMax(0,value) ; 
  }
  inline void setRange(Double_t min, Double_t max) { 
    // Set default ranges to [min,max]
    setRange(0,min,max) ; 
  }
  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 setBins(Int_t nBins) { 
    // Set default binning to nBins uniform bins
    setBinning(RooUniformBinning(getMin(),getMax(),nBins)) ; 
  }
  void setBinning(const RooAbsBinning& binning, const char* name=0) ;
  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) ;
  Bool_t hasBinning(const char* name) const ;
  std::list<std::string> getBinningNames() const ;

  // Set infinite fit range limits
  inline void removeMin(const char* name=0) { 
    // Remove lower bound from named binning, or default binning if name is null
    getBinning(name).setMin(-RooNumber::infinity()) ; 
  }
  inline void removeMax(const char* name=0) { 
    // Remove upper bound from named binning, or default binning if name is null
    getBinning(name).setMax(RooNumber::infinity()) ; 
  }
  inline void removeRange(const char* name=0) { 
    // Remove both upper and lower bounds from named binning, or
    // default binning if name is null
    getBinning(name).setRange(-RooNumber::infinity(),RooNumber::infinity()) ; 
  }

  using RooAbsRealLValue::operator= ;
  using RooAbsRealLValue::setVal ;

protected:

  RooLinkedList _altBinning ;  //! Optional alternative ranges and binnings

  void syncCache(const RooArgSet* set=0) ;

  RooRealProxy _realVar ; // RealVar with the original error
  RooAbsBinning* _binning ; //! Pointer to default binning definition

  ClassDef(RooErrorVar,1) // RooAbsRealLValue representation of an error of a RooRealVar
};

#endif
 RooErrorVar.h:1
 RooErrorVar.h:2
 RooErrorVar.h:3
 RooErrorVar.h:4
 RooErrorVar.h:5
 RooErrorVar.h:6
 RooErrorVar.h:7
 RooErrorVar.h:8
 RooErrorVar.h:9
 RooErrorVar.h:10
 RooErrorVar.h:11
 RooErrorVar.h:12
 RooErrorVar.h:13
 RooErrorVar.h:14
 RooErrorVar.h:15
 RooErrorVar.h:16
 RooErrorVar.h:17
 RooErrorVar.h:18
 RooErrorVar.h:19
 RooErrorVar.h:20
 RooErrorVar.h:21
 RooErrorVar.h:22
 RooErrorVar.h:23
 RooErrorVar.h:24
 RooErrorVar.h:25
 RooErrorVar.h:26
 RooErrorVar.h:27
 RooErrorVar.h:28
 RooErrorVar.h:29
 RooErrorVar.h:30
 RooErrorVar.h:31
 RooErrorVar.h:32
 RooErrorVar.h:33
 RooErrorVar.h:34
 RooErrorVar.h:35
 RooErrorVar.h:36
 RooErrorVar.h:37
 RooErrorVar.h:38
 RooErrorVar.h:39
 RooErrorVar.h:40
 RooErrorVar.h:41
 RooErrorVar.h:42
 RooErrorVar.h:43
 RooErrorVar.h:44
 RooErrorVar.h:45
 RooErrorVar.h:46
 RooErrorVar.h:47
 RooErrorVar.h:48
 RooErrorVar.h:49
 RooErrorVar.h:50
 RooErrorVar.h:51
 RooErrorVar.h:52
 RooErrorVar.h:53
 RooErrorVar.h:54
 RooErrorVar.h:55
 RooErrorVar.h:56
 RooErrorVar.h:57
 RooErrorVar.h:58
 RooErrorVar.h:59
 RooErrorVar.h:60
 RooErrorVar.h:61
 RooErrorVar.h:62
 RooErrorVar.h:63
 RooErrorVar.h:64
 RooErrorVar.h:65
 RooErrorVar.h:66
 RooErrorVar.h:67
 RooErrorVar.h:68
 RooErrorVar.h:69
 RooErrorVar.h:70
 RooErrorVar.h:71
 RooErrorVar.h:72
 RooErrorVar.h:73
 RooErrorVar.h:74
 RooErrorVar.h:75
 RooErrorVar.h:76
 RooErrorVar.h:77
 RooErrorVar.h:78
 RooErrorVar.h:79
 RooErrorVar.h:80
 RooErrorVar.h:81
 RooErrorVar.h:82
 RooErrorVar.h:83
 RooErrorVar.h:84
 RooErrorVar.h:85
 RooErrorVar.h:86
 RooErrorVar.h:87
 RooErrorVar.h:88
 RooErrorVar.h:89
 RooErrorVar.h:90
 RooErrorVar.h:91
 RooErrorVar.h:92
 RooErrorVar.h:93
 RooErrorVar.h:94
 RooErrorVar.h:95
 RooErrorVar.h:96
 RooErrorVar.h:97
 RooErrorVar.h:98
 RooErrorVar.h:99
 RooErrorVar.h:100
 RooErrorVar.h:101
 RooErrorVar.h:102
 RooErrorVar.h:103
 RooErrorVar.h:104
 RooErrorVar.h:105
 RooErrorVar.h:106
 RooErrorVar.h:107
 RooErrorVar.h:108
 RooErrorVar.h:109
 RooErrorVar.h:110
 RooErrorVar.h:111
 RooErrorVar.h:112
 RooErrorVar.h:113
 RooErrorVar.h:114
 RooErrorVar.h:115
 RooErrorVar.h:116
 RooErrorVar.h:117
 RooErrorVar.h:118