Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
RooIntegrator1D.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * Project: RooFit *
3  * Package: RooFitCore *
4  * File: $Id: RooIntegrator1D.h,v 1.21 2007/05/11 09:11:30 verkerke Exp $
5  * Authors: *
6  * WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu *
7  * DK, David Kirkby, UC Irvine, dkirkby@uci.edu *
8  * *
9  * Copyright (c) 2000-2005, Regents of the University of California *
10  * and Stanford University. All rights reserved. *
11  * *
12  * Redistribution and use in source and binary forms, *
13  * with or without modification, are permitted according to the terms *
14  * listed in LICENSE (http://roofit.sourceforge.net/license.txt) *
15  *****************************************************************************/
16 #ifndef ROO_INTEGRATOR_1D
17 #define ROO_INTEGRATOR_1D
18 
19 #include "RooAbsIntegrator.h"
20 #include "RooNumIntConfig.h"
21 
22 class RooIntegrator1D : public RooAbsIntegrator {
23 public:
24 
25  // Constructors, assignment etc
26  enum SummationRule { Trapezoid, Midpoint };
27  RooIntegrator1D() ;
28 
29  RooIntegrator1D(const RooAbsFunc& function, SummationRule rule= Trapezoid,
30  Int_t maxSteps= 0, Double_t eps= 0) ;
31  RooIntegrator1D(const RooAbsFunc& function, Double_t xmin, Double_t xmax,
32  SummationRule rule= Trapezoid, Int_t maxSteps= 0, Double_t eps= 0) ;
33 
34  RooIntegrator1D(const RooAbsFunc& function, const RooNumIntConfig& config) ;
35  RooIntegrator1D(const RooAbsFunc& function, Double_t xmin, Double_t xmax,
36  const RooNumIntConfig& config) ;
37 
38  virtual RooAbsIntegrator* clone(const RooAbsFunc& function, const RooNumIntConfig& config) const ;
39  virtual ~RooIntegrator1D();
40 
41  virtual Bool_t checkLimits() const;
42  virtual Double_t integral(const Double_t *yvec=0) ;
43 
44  using RooAbsIntegrator::setLimits ;
45  Bool_t setLimits(Double_t* xmin, Double_t* xmax);
46  virtual Bool_t setUseIntegrandLimits(Bool_t flag) {_useIntegrandLimits = flag ; return kTRUE ; }
47 
48  virtual Bool_t canIntegrate1D() const { return kTRUE ; }
49  virtual Bool_t canIntegrate2D() const { return kFALSE ; }
50  virtual Bool_t canIntegrateND() const { return kFALSE ; }
51  virtual Bool_t canIntegrateOpenEnded() const { return kFALSE ; }
52 
53 protected:
54 
55  friend class RooNumIntFactory ;
56  static void registerIntegrator(RooNumIntFactory& fact) ;
57 
58  Bool_t initialize();
59 
60  Bool_t _useIntegrandLimits; // If true limits of function binding are ued
61 
62  // Integrator configuration
63  SummationRule _rule;
64  Int_t _maxSteps ; // Maximum number of steps
65  Int_t _minStepsZero ; // Minimum number of steps to declare convergence to zero
66  Int_t _fixSteps ; // Fixed number of steps
67  Double_t _epsAbs ; // Absolute convergence tolerance
68  Double_t _epsRel ; // Relative convergence tolerance
69  Bool_t _doExtrap ; // Apply conversion step?
70  enum { _nPoints = 5 };
71 
72  // Numerical integrator support functions
73  Double_t addTrapezoids(Int_t n) ;
74  Double_t addMidpoints(Int_t n) ;
75  void extrapolate(Int_t n) ;
76 
77  // Numerical integrator workspace
78  Double_t _xmin; //! Lower integration bound
79  Double_t _xmax; //! Upper integration bound
80  Double_t _range; //! Size of integration range
81  Double_t _extrapValue; //! Extrapolated value
82  Double_t _extrapError; //! Error on extrapolated value
83  Double_t *_h ; //! Integrator workspace
84  Double_t *_s ; //! Integrator workspace
85  Double_t *_c ; //! Integrator workspace
86  Double_t *_d ; //! Integrator workspace
87  Double_t _savedResult; //! Integrator workspace
88 
89  Double_t* xvec(Double_t& xx) { _x[0] = xx ; return _x ; }
90 
91  Double_t *_x ; //! do not persist
92 
93  ClassDef(RooIntegrator1D,0) // 1-dimensional numerical integration engine
94 };
95 
96 #endif