Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
RooRombergIntegrator.h
Go to the documentation of this file.
1/// \cond ROOFIT_INTERNAL
2
3/*****************************************************************************
4 * Project: RooFit *
5 * Package: RooFitCore *
6 * File: $Id: RooRombergIntegrator.h,v 1.21 2007/05/11 09:11:30 verkerke Exp $
7 * Authors: *
8 * WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu *
9 * DK, David Kirkby, UC Irvine, dkirkby@uci.edu *
10 * *
11 * Copyright (c) 2000-2005, Regents of the University of California *
12 * and Stanford University. All rights reserved. *
13 * *
14 * Redistribution and use in source and binary forms, *
15 * with or without modification, are permitted according to the terms *
16 * listed in LICENSE (http://roofit.sourceforge.net/license.txt) *
17 *****************************************************************************/
18#ifndef ROO_INTEGRATOR_1D
19#define ROO_INTEGRATOR_1D
20
21#include "RooAbsIntegrator.h"
22#include "RooNumIntConfig.h"
23
24#include <ROOT/RSpan.hxx>
25
26#include <functional>
27
28namespace RooFit {
29namespace Detail {
30
31std::pair<double, int> integrate1d(std::function<double(double)> func, bool doTrapezoid, int maxSteps, int minStepsZero,
32 int fixSteps, double epsAbs, double epsRel, bool doExtrap, double xmin, double xmax,
33 std::span<double> hArr, std::span<double> sArr);
34
35} // namespace Detail
36} // namespace RooFit
37
38class RooRombergIntegrator : public RooAbsIntegrator {
39public:
40 // Constructors, assignment etc
41 enum SummationRule { Trapezoid, Midpoint };
42
43 RooRombergIntegrator(const RooAbsFunc &function, SummationRule rule = Trapezoid, int maxSteps = 0, double eps = 0);
44 RooRombergIntegrator(const RooAbsFunc &function, double xmin, double xmax, SummationRule rule = Trapezoid,
45 int maxSteps = 0, double eps = 0);
46
47 RooRombergIntegrator(const RooAbsFunc &function, const RooNumIntConfig &config, int nDim = 1,
48 bool doSegmentation = false);
49 RooRombergIntegrator(const RooAbsFunc &function, double xmin, double xmax, const RooNumIntConfig &config,
50 int nDim = 1);
51
52 bool checkLimits() const override;
53 double integral(const double *yvec = nullptr) override;
54
56 bool setLimits(double *xmin, double *xmax) override;
57 bool setUseIntegrandLimits(bool flag) override
58 {
59 _useIntegrandLimits = flag;
60 return true;
61 }
62
63protected:
64 friend class RooNumIntFactory;
65 static void registerIntegrator(RooNumIntFactory &fact);
66
67 bool initialize();
68 double integral(int iDim, int nSeg, std::span<double> wksp);
69
70 bool _useIntegrandLimits; ///< If true limits of function binding are used
71
72 // Integrator configuration
73 int _nDim = 1;
74 SummationRule _rule;
75 int _maxSteps; ///< Maximum number of steps
76 int _minStepsZero = 999; ///< Minimum number of steps to declare convergence to zero
77 int _fixSteps = 0; ///< Fixed number of steps
78 double _epsAbs; ///< Absolute convergence tolerance
79 double _epsRel; ///< Relative convergence tolerance
80 bool _doExtrap = true; ///< Apply conversion step?
81 int _nSeg = 1; ///< Number of segments
82 std::vector<double> _xmin; ///<! Lower integration bounds
83 std::vector<double> _xmax; ///<! Upper integration bounds
84
85 // Numerical integrator workspace
86 std::vector<double> _wksp; ///<! Integrator workspace
87 std::vector<double> _x; ///<! do not persist
88};
89
90#endif
91
92/// \endcond
void initialize()
float xmin
float xmax
Abstract interface for integrators of real-valued functions that implement the RooAbsFunc interface.
virtual bool setUseIntegrandLimits(bool flag)
Interface function that allows to defer limit definition to integrand definition.
virtual bool checkLimits() const
If true, finite limits are required on the observable range.
virtual double integral(const double *yvec=nullptr)=0
virtual bool setLimits(double *, double *)
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
Definition CodegenImpl.h:72