ROOT logo
/*****************************************************************************
 * Project: RooFit                                                           *
 * Package: RooFitCore                                                       *
 *    File: $Id: RooCurve.h,v 1.24 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_CURVE
#define ROO_CURVE

#include "TGraph.h"
#include "RooPlotable.h"
#include <list>
#include <vector>
#include "TMatrixDfwd.h"

class RooAbsReal;
class RooRealVar;
class RooAbsFunc;
class RooArgSet;
class RooAbsRealLValue ;
class RooHist ;

class RooCurve : public TGraph, public RooPlotable {
public:
  RooCurve();
  enum WingMode { NoWings=0 ,Straight=1, Extended=2 } ;
  RooCurve(const RooAbsReal &func, RooAbsRealLValue &x, Double_t xlo, Double_t xhi, Int_t xbins,
	   Double_t scaleFactor= 1, const RooArgSet *normVars= 0, Double_t prec= 1e-3, Double_t resolution= 1e-3,
	   Bool_t shiftToZero=kFALSE, WingMode wmode=Extended, Int_t nEvalError=-1, Int_t doEEVal=kFALSE, Double_t eeVal=0);
  RooCurve(const char *name, const char *title, const RooAbsFunc &func, Double_t xlo,
	   Double_t xhi, UInt_t minPoints, Double_t prec= 1e-3, Double_t resolution= 1e-3,
	   Bool_t shiftToZero=kFALSE, WingMode wmode=Extended, Int_t nEvalError=-1, Int_t doEEVal=kFALSE, Double_t eeVal=0);
  virtual ~RooCurve();

  RooCurve(const char* name, const char* title, const RooCurve& c1, const RooCurve& c2, Double_t scale1=1., Double_t scale2=1.) ;

  void addPoint(Double_t x, Double_t y);

  Double_t getFitRangeBinW() const;
  Double_t getFitRangeNEvt(Double_t xlo, Double_t xhi) const ;
  Double_t getFitRangeNEvt() const;


  virtual void printName(ostream& os) const ;
  virtual void printTitle(ostream& os) const ;
  virtual void printClassName(ostream& os) const ;
  virtual void printMultiline(ostream& os, Int_t contents, Bool_t verbose=kFALSE, TString indent="") const;

  inline virtual void Print(Option_t *options= 0) const {
    // Printing interface
    printStream(defaultPrintStream(),defaultPrintContents(options),defaultPrintStyle(options));
  }

  Double_t chiSquare(const RooHist& hist, int nFitParam) const ;
  Int_t findPoint(Double_t value, Double_t tolerance=1e-10) const ;
  Double_t average(Double_t lo, Double_t hi) const ;
  Double_t interpolate(Double_t x, Double_t tolerance=1e-10) const ;

  Bool_t isIdentical(const RooCurve& other, Double_t tol=1e-6) const ;

  RooCurve* makeErrorBand(const std::vector<RooCurve*>& variations, Double_t Z=1) const ;
  RooCurve* makeErrorBand(const std::vector<RooCurve*>& plusVar, const std::vector<RooCurve*>& minusVar, const TMatrixD& V, Double_t Z=1) const ;

protected:

  void calcBandInterval(const std::vector<RooCurve*>& variations,Int_t i,Double_t Z,Double_t& lo, Double_t& hi, Bool_t approxGauss) const ;
  void calcBandInterval(const std::vector<RooCurve*>& plusVar, const std::vector<RooCurve*>& minusVar, Int_t i, const TMatrixD& V,
			Double_t Z,Double_t& lo, Double_t& hi) const ;

  void initialize();
  void addPoints(const RooAbsFunc &func, Double_t xlo, Double_t xhi,
		 Int_t minPoints, Double_t prec, Double_t resolution, WingMode wmode,
		 Int_t numee=0, Bool_t doEEVal=kFALSE, Double_t eeVal=0.,std::list<Double_t>* samplingHint=0) ;
  void addRange(const RooAbsFunc& func, Double_t x1, Double_t x2, Double_t y1,
		Double_t y2, Double_t minDy, Double_t minDx,
		Int_t numee=0, Bool_t doEEVal=kFALSE, Double_t eeVal=0.)  ;


  void shiftCurveToZero(Double_t prevYMax) ;

  ClassDef(RooCurve,1) // 1-dimensional smooth curve for use in RooPlots
};

#endif
 RooCurve.h:1
 RooCurve.h:2
 RooCurve.h:3
 RooCurve.h:4
 RooCurve.h:5
 RooCurve.h:6
 RooCurve.h:7
 RooCurve.h:8
 RooCurve.h:9
 RooCurve.h:10
 RooCurve.h:11
 RooCurve.h:12
 RooCurve.h:13
 RooCurve.h:14
 RooCurve.h:15
 RooCurve.h:16
 RooCurve.h:17
 RooCurve.h:18
 RooCurve.h:19
 RooCurve.h:20
 RooCurve.h:21
 RooCurve.h:22
 RooCurve.h:23
 RooCurve.h:24
 RooCurve.h:25
 RooCurve.h:26
 RooCurve.h:27
 RooCurve.h:28
 RooCurve.h:29
 RooCurve.h:30
 RooCurve.h:31
 RooCurve.h:32
 RooCurve.h:33
 RooCurve.h:34
 RooCurve.h:35
 RooCurve.h:36
 RooCurve.h:37
 RooCurve.h:38
 RooCurve.h:39
 RooCurve.h:40
 RooCurve.h:41
 RooCurve.h:42
 RooCurve.h:43
 RooCurve.h:44
 RooCurve.h:45
 RooCurve.h:46
 RooCurve.h:47
 RooCurve.h:48
 RooCurve.h:49
 RooCurve.h:50
 RooCurve.h:51
 RooCurve.h:52
 RooCurve.h:53
 RooCurve.h:54
 RooCurve.h:55
 RooCurve.h:56
 RooCurve.h:57
 RooCurve.h:58
 RooCurve.h:59
 RooCurve.h:60
 RooCurve.h:61
 RooCurve.h:62
 RooCurve.h:63
 RooCurve.h:64
 RooCurve.h:65
 RooCurve.h:66
 RooCurve.h:67
 RooCurve.h:68
 RooCurve.h:69
 RooCurve.h:70
 RooCurve.h:71
 RooCurve.h:72
 RooCurve.h:73
 RooCurve.h:74
 RooCurve.h:75
 RooCurve.h:76
 RooCurve.h:77
 RooCurve.h:78
 RooCurve.h:79
 RooCurve.h:80
 RooCurve.h:81
 RooCurve.h:82
 RooCurve.h:83
 RooCurve.h:84
 RooCurve.h:85
 RooCurve.h:86
 RooCurve.h:87
 RooCurve.h:88
 RooCurve.h:89
 RooCurve.h:90
 RooCurve.h:91
 RooCurve.h:92
 RooCurve.h:93