Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooConvIntegrandBinding.cxx
Go to the documentation of this file.
1/// \cond ROOFIT_INTERNAL
2
3/*****************************************************************************
4 * Project: RooFit *
5 * Package: RooFitCore *
6 * @(#)root/roofitcore:$Id$
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
19/**
20\file RooConvIntegrandBinding.cxx
21\class RooConvIntegrandBinding
22\ingroup Roofitcore
23
24Implementation of RooAbsFunc that represent the integrand
25of a generic (numeric) convolution A (x) B so that it can be
26passed to a numeric integrator. This is a utility class for
27RooNumConvPdf
28**/
29
31#include "RooAbsReal.h"
32#include "RooArgSet.h"
33#include "RooAbsRealLValue.h"
34#include "RooMsgService.h"
35
36#include <cassert>
37
38
39////////////////////////////////////////////////////////////////////////////////
40
41RooConvIntegrandBinding::RooConvIntegrandBinding(const RooAbsReal &func, const RooAbsReal &model, RooAbsReal &xprime,
42 RooAbsReal &x, const RooArgSet *nset, bool clipInvalid)
43 :
44
45 RooAbsFunc(2),
46 _func(&func),
47 _model(&model),
48 _vars(new RooAbsRealLValue *[2]),
49 _nset(nset),
50 _clipInvalid(clipInvalid)
51{
52 // Constructor where func and model
53 //
54 // 'func' = func(xprime)
55 // 'model' = model(xprime)
56 //
57 // and
58
59 // 'xprime' is the RRV that should be connected to func and model
60 // (i.e. the variable that will be integrated over)
61 // 'x' is RRV that represents the value at which the convolution is calculated
62 // (this variable should _not_ be connected to func and model)
63 //
64 // this function returns RCBB[x',x] = f[x']*g[x-x'], i.e. the substiturion g[x'] --> g[x-x']
65 // is taken care internally
66 //
67 // The integral of this binding over its 1st arg yields the convolution (f (x) g)[x]
68 //
69
70 // allocate memory
71
72 if(nullptr == _vars) {
73 _valid= false;
74 return;
75 }
76
77 // check that all of the arguments are real valued and store them
78 _vars[0]= dynamic_cast<RooAbsRealLValue*>(&xprime);
79 if(nullptr == _vars[0]) {
80 oocoutE(&func,InputArguments) << "RooConvIntegrandBinding: cannot bind to ";
81 xprime.Print("1");
82 _valid= false;
83 }
84
85 _vars[1]= dynamic_cast<RooAbsRealLValue*>(&x);
86 if(nullptr == _vars[1]) {
87 oocoutE(&func,InputArguments) << "RooConvIntegrandBinding: cannot bind to ";
88 x.Print("1");
89 _valid= false;
90 }
91
92 _xvecValid = true ;
93}
94
95
96
97////////////////////////////////////////////////////////////////////////////////
98/// Destructor
99
100RooConvIntegrandBinding::~RooConvIntegrandBinding()
101{
102 if(nullptr != _vars) delete[] _vars;
103}
104
105
106////////////////////////////////////////////////////////////////////////////////
107/// Load external input values
108
109void RooConvIntegrandBinding::loadValues(const double xvector[], bool clipInvalid) const
110{
111 _xvecValid = true ;
112 for(UInt_t index= 0; index < _dimension; index++) {
113 if (clipInvalid && !_vars[index]->isValidReal(xvector[index])) {
114 _xvecValid = false ;
115 } else {
116 //cout << "RooConvBasBinding::loadValues[" << index << "] loading value " << xvector[index] << std::endl ;
117 _vars[index]->setVal(xvector[index]);
118 }
119 }
120}
121
122
123////////////////////////////////////////////////////////////////////////////////
124/// Evaluate self at given parameter values
125
126double RooConvIntegrandBinding::operator()(const double xvector[]) const
127{
128 assert(isValid());
129 _ncall++ ;
130
131 // First evaluate function at x'
132 loadValues(xvector);
133 if (!_xvecValid) return 0 ;
134 //cout << "RooConvIntegrandBinding::operator(): evaluating f(x') at x' = " << xvector[0] << std::endl ;
135 double f_xp = _func->getVal(_nset) ;
136
137 // Next evaluate model at x-x'
138 const double xvec_tmp[2] = { xvector[1]-xvector[0] , xvector[1] } ;
139 loadValues(xvec_tmp,true);
140 if (!_xvecValid) return 0 ;
141 double g_xmxp = _model->getVal(_nset) ;
142
143 //cout << "RooConvIntegrandBinding::operator(): evaluating g(x-x') at x-x' = " << _vars[0]->getVal() << " = " << g_xmxp << std::endl ;
144 //cout << "RooConvIntegrandBinding::operator(): return value = " << f_xp << " * " << g_xmxp << " = " << f_xp*g_xmxp << std::endl ;
145
146 //cout << "_vars[0] = " << _vars[0]->getVal() << " _vars[1] = " << _vars[1]->getVal() << std::endl ;
147 //cout << "_xvec[0] = " << xvector[0] << " _xvec[1] = " << xvector[1] << std::endl ;
148
149 return f_xp*g_xmxp ;
150}
151
152
153////////////////////////////////////////////////////////////////////////////////
154/// Retrieve lower limit of i-th observable
155
156double RooConvIntegrandBinding::getMinLimit(UInt_t index) const
157{
158 assert(isValid());
159 return _vars[index]->getMin();
160}
161
162
163////////////////////////////////////////////////////////////////////////////////
164/// Retrieve upper limit of i-th observable
165
166double RooConvIntegrandBinding::getMaxLimit(UInt_t index) const
167{
168 assert(isValid());
169 return _vars[index]->getMax();
170}
171
172/// \endcond
#define oocoutE(o, a)
unsigned int UInt_t
Definition RtypesCore.h:46
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
void Print(Option_t *options=nullptr) const override
Print the object to the defaultPrintStream().
Definition RooAbsArg.h:263
Abstract interface for evaluating a real-valued function of one real variable and performing numerica...
Definition RooAbsFunc.h:27
Abstract base class for objects that represent a real value that may appear on the left hand side of ...
Abstract base class for objects that represent a real value and implements functionality common to al...
Definition RooAbsReal.h:59
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:24
Double_t x[n]
Definition legend1.C:17