ROOT logo
/*****************************************************************************
 * Project: RooFit                                                           *
 * Package: RooFitCore                                                       *
 *    File: $Id: RooIntegrator1D.h,v 1.21 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_INTEGRATOR_1D
#define ROO_INTEGRATOR_1D

#include "RooAbsIntegrator.h"
#include "RooNumIntConfig.h"

class RooIntegrator1D : public RooAbsIntegrator {
public:

  // Constructors, assignment etc
  enum SummationRule { Trapezoid, Midpoint };
  RooIntegrator1D() ;

  RooIntegrator1D(const RooAbsFunc& function, SummationRule rule= Trapezoid,
		  Int_t maxSteps= 0, Double_t eps= 0) ; 
  RooIntegrator1D(const RooAbsFunc& function, Double_t xmin, Double_t xmax,
		  SummationRule rule= Trapezoid, Int_t maxSteps= 0, Double_t eps= 0) ; 

  RooIntegrator1D(const RooAbsFunc& function, const RooNumIntConfig& config) ;
  RooIntegrator1D(const RooAbsFunc& function, Double_t xmin, Double_t xmax, 
		  const RooNumIntConfig& config) ;

  virtual RooAbsIntegrator* clone(const RooAbsFunc& function, const RooNumIntConfig& config) const ;
  virtual ~RooIntegrator1D();

  virtual Bool_t checkLimits() const;
  virtual Double_t integral(const Double_t *yvec=0) ;

  using RooAbsIntegrator::setLimits ;
  Bool_t setLimits(Double_t* xmin, Double_t* xmax);
  virtual Bool_t setUseIntegrandLimits(Bool_t flag) {_useIntegrandLimits = flag ; return kTRUE ; }

  virtual Bool_t canIntegrate1D() const { return kTRUE ; }
  virtual Bool_t canIntegrate2D() const { return kFALSE ; }
  virtual Bool_t canIntegrateND() const { return kFALSE ; }
  virtual Bool_t canIntegrateOpenEnded() const { return kFALSE ; }

protected:

  friend class RooNumIntFactory ;
  static void registerIntegrator(RooNumIntFactory& fact) ;	

  Bool_t initialize();

  Bool_t _useIntegrandLimits;  // If true limits of function binding are ued

  // Integrator configuration
  SummationRule _rule;
  Int_t _maxSteps ;      // Maximum number of steps
  Int_t _minStepsZero ;  // Minimum number of steps to declare convergence to zero
  Int_t _fixSteps ;      // Fixed number of steps 
  Double_t _epsAbs ;     // Absolute convergence tolerance
  Double_t _epsRel ;     // Relative convergence tolerance
  Bool_t _doExtrap ;     // Apply conversion step?
  enum { _nPoints = 5 };

  // Numerical integrator support functions
  Double_t addTrapezoids(Int_t n) ;
  Double_t addMidpoints(Int_t n) ;
  void extrapolate(Int_t n) ;
  
  // Numerical integrator workspace
  mutable Double_t _xmin;              //! Lower integration bound
  mutable Double_t _xmax;              //! Upper integration bound
  mutable Double_t _range;             //! Size of integration range
  Double_t _extrapValue;               //! Extrapolated value
  Double_t _extrapError;               //! Error on extrapolated value
  Double_t *_h ;                       //! Integrator workspace
  Double_t *_s ;                       //! Integrator workspace
  Double_t *_c ;                       //! Integrator workspace
  Double_t *_d ;                       //! Integrator workspace
  Double_t _savedResult;               //! Integrator workspace

  Double_t* xvec(Double_t& xx) { _x[0] = xx ; return _x ; }

  Double_t *_x ; //! do not persist

  ClassDef(RooIntegrator1D,0) // 1-dimensional numerical integration engine
};

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