Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooSegmentedIntegrator2D.cxx
Go to the documentation of this file.
1/*****************************************************************************
2 * Project: RooFit *
3 * Package: RooFitCore *
4 * @(#)root/roofitcore:$Id$
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
17/**
18\file RooSegmentedIntegrator2D.cxx
19\class RooSegmentedIntegrator2D
20\ingroup Roofitcore
21
22RooSegmentedIntegrator2D implements an adaptive one-dimensional
23numerical integration algorithm.
24**/
25
26
27#include "Riostream.h"
28
29#include "TClass.h"
31#include "RooArgSet.h"
33#include "RooRealVar.h"
34#include "RooNumber.h"
35#include "RooNumIntFactory.h"
36#include "RooMsgService.h"
37
38#include <assert.h>
39
40
41
42using namespace std;
43
45
46
47////////////////////////////////////////////////////////////////////////////////
48/// Register RooSegmentedIntegrator2D, its parameters, dependencies and capabilities with RooNumIntFactory
49
51{
53}
54
55
58
59
60////////////////////////////////////////////////////////////////////////////////
61/// Constructor of integral on given function binding and with given configuration. The
62/// integration limits are taken from the definition in the function binding
63
65{
66 _xIntegrator = std::make_unique<RooSegmentedIntegrator1D>(function, config);
67 _xint = std::make_unique<RooIntegratorBinding>(*_xIntegrator);
68 _function = _xint.get();
69 _config = config;
70 _nseg = (Int_t)config.getConfigSection(ClassName()).getRealValue("numSeg", 3);
72
74}
75
76
77////////////////////////////////////////////////////////////////////////////////
78/// Constructor integral on given function binding, with given configuration and
79/// explicit definition of integration range
80
82 double ymax, const RooNumIntConfig &config)
83{
84 _xIntegrator = std::make_unique<RooSegmentedIntegrator1D>(function, ymin, ymax, config);
85 _xint = std::make_unique<RooIntegratorBinding>(*_xIntegrator);
86 _function = _xint.get();
87 _config = config;
88 _nseg = (Int_t)config.getConfigSection(ClassName()).getRealValue("numSeg", 3);
89 _useIntegrandLimits = false;
90 _xmin = xmin;
91 _xmax = xmax;
92
94}
95
96
97////////////////////////////////////////////////////////////////////////////////
98/// Virtual constructor with given function and configuration. Needed by RooNumIntFactory
99
101{
102 return new RooSegmentedIntegrator2D(function,config) ;
103}
104
105
106////////////////////////////////////////////////////////////////////////////////
107/// Check that our integration range is finite and otherwise return false.
108/// Update the limits from the integrand if requested.
109
111{
113 assert(0 != integrand() && integrand()->isValid());
116 }
117 _range= _xmax - _xmin;
118 if(_range <= 0) {
119 oocoutE(nullptr,InputArguments) << "RooIntegrator1D::checkLimits: bad range with min >= max" << endl;
120 return false;
121 }
122 bool ret = (RooNumber::isInfinite(_xmin) || RooNumber::isInfinite(_xmax)) ? false : true;
123
124 // Adjust component integrators, if already created
125 if (!_array.empty() && ret) {
126 double segSize = (_xmax - _xmin) / _nseg ;
127 Int_t i ;
128 for (i=0 ; i<_nseg ; i++) {
129 _array[i]->setLimits(_xmin+i*segSize,_xmin+(i+1)*segSize) ;
130 }
131 }
132
133 return ret ;
134}
#define oocoutE(o, a)
int Int_t
Definition RtypesCore.h:45
#define ClassImp(name)
Definition Rtypes.h:377
float xmin
float ymin
float xmax
float ymax
Abstract interface for evaluating a real-valued function of one real variable and performing numerica...
Definition RooAbsFunc.h:27
virtual double getMaxLimit(UInt_t dimension) const =0
virtual double getMinLimit(UInt_t dimension) const =0
RooAbsIntegrator is the abstract interface for integrators of real-valued functions that implement th...
bool isValid() const
Is integrator in valid state.
const RooAbsFunc * _function
Pointer to function binding of integrand.
const RooAbsFunc * integrand() const
Return integrand function binding.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:55
RooNumIntConfig holds the configuration parameters of the various numeric integrators used by RooReal...
const RooArgSet & getConfigSection(const char *name) const
Retrieve configuration information specific to integrator with given name.
RooNumIntFactory is a factory to instantiate numeric integrators from a given function binding and a ...
bool storeProtoIntegrator(RooAbsIntegrator *proto, const RooArgSet &defConfig, const char *depName="")
Method accepting registration of a prototype numeric integrator along with a RooArgSet of its default...
static constexpr int isInfinite(double x)
Return true if x is infinite by RooNumber internal specification.
Definition RooNumber.h:34
static TClass * Class()
std::vector< std::unique_ptr< RooIntegrator1D > > _array
Array of segment integrators.
bool initialize()
One-time integrator initialization.
RooSegmentedIntegrator2D implements an adaptive one-dimensional numerical integration algorithm.
static void registerIntegrator(RooNumIntFactory &fact)
Register RooSegmentedIntegrator2D, its parameters, dependencies and capabilities with RooNumIntFactor...
std::unique_ptr< RooAbsFunc > _xint
RooAbsIntegrator * clone(const RooAbsFunc &function, const RooNumIntConfig &config) const override
Virtual constructor with given function and configuration. Needed by RooNumIntFactory.
bool checkLimits() const override
Check that our integration range is finite and otherwise return false.
std::unique_ptr< RooSegmentedIntegrator1D > _xIntegrator
~RooSegmentedIntegrator2D() override
virtual const char * GetName() const
Returns name of object.
Definition TObject.cxx:439
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition TObject.cxx:207