MINT2
RooSplineProduct.cpp
Go to the documentation of this file.
1 /*****************************************************************************
2  * Project: RooFit *
3  * Package: RooFitModels *
4  * @(#)root/roofit:$Id: RooSplineProduct.cxx
5  * Authors: *
6  * Katya Govorkova, Nikhef 2k17
7  * *
8  *****************************************************************************/
9 
10 // STD & STL
11 #include <cmath>
12 #include <complex>
13 #include <sstream>
14 
15 // ROOT
16 #include "TH1.h"
17 #include "TGraph.h"
18 #include "TGraphErrors.h"
19 
20 // RooFit
21 #include "RooMsgService.h"
22 #include "RooMath.h"
23 #include "RooAbsReal.h"
24 #include "RooRealVar.h"
25 #include "RooConstVar.h"
26 #include "RooArgList.h"
27 
28 #include "Mint/RooSplineProduct.h"
29 
30 using namespace std;
31 
32 //_____________________________________________________________________________
34  // TODO: current implementation of product of two splines
35  // only for splines with the same knot vector
36  assert(_sp1.knots() == _sp2.knots());
37  assert(_sp1.knotSize() == _sp2.knotSize());
38 }
39 
40 //_____________________________________________________________________________
42 {
43 }
44 
45 //_____________________________________________________________________________
47  const char* title, RooRealVar& x,
48  const RooCubicSplineFun& sp1,
49  const RooCubicSplineFun& sp2
50  ) :
51  RooAbsGaussModelEfficiency(name, title),
52  _x("x", "Dependent", this, x),
53  _sp1(sp1,"spline1"),
54  _sp2(sp2,"spline2"),
55  _coefList1("coefficients1","List of coefficients for first spline",this),
56  _coefList2("coefficients2","List of coefficients for second spline",this)
57 {
58  _coefList1.add(sp1.coefficients());
59  _coefList2.add(sp2.coefficients());
60  init();
61 }
62 
63 //_____________________________________________________________________________
64 RooSplineProduct::RooSplineProduct(const RooSplineProduct& other, const char* name) :
65  RooAbsGaussModelEfficiency(other, name),
66  _x("x", this, other._x),
67  _sp1(other._sp1,"spline1"),
68  _sp2(other._sp2,"spline2"),
69  _coefList1("coefList1", this, other._coefList1),
70  _coefList2("coefList2", this, other._coefList2)
71 {
72 }
73 
74 //_____________________________________________________________________________
76 {
77 }
78 
79 //_____________________________________________________________________________
81 {
83 }
84 
85 //_____________________________________________________________________________
86 Int_t RooSplineProduct::getAnalyticalIntegral(RooArgSet& allVars, RooArgSet& analVars, const char* rangeName) const
87 {
88  return 0;
89 }
90 //_____________________________________________________________________________
91 Double_t RooSplineProduct::analyticalIntegral(Int_t code, const char* /* rangeName */) const
92 {
93  return 0;
94 }
95 
96 //_____________________________________________________________________________
98  const RooGaussModelAcceptance::K_n& K, double offset,
99  double* sc) const
100 {
102  std::complex<double> sum(0,0);
103  for (int j=0;j<3;++j) for (int k=0;k<3-j;++k) sum += dM(j)*s2_jk(j,k)*K(k)*sc[j+k];
104  return sum;
105 }
106 
107 //_____________________________________________________________________________
108 std::complex<double>
109 RooSplineProduct::productAnalyticalIntegral(Double_t umin, Double_t umax,
110  Double_t scale, Double_t offset,
111  const std::complex<double>& z) const
112 {
114  assert(_sp1.knotSize()>1);
115  double lo = scale*umin+offset;
116  double hi = scale*umax+offset+1.e-7;
118  std::vector<M_n> M; M.reserve( _sp1.knotSize() );
119  for (unsigned int i=0;i<_sp1.knotSize();++i) {
120  double x = (_sp1.u(i)-offset)/scale ;
121  if (lo>=_sp1.u(i)) x = umin ; // take M[i] if lo<=u(i) else M_n(lo)
122  if (_sp1.u(i)>=hi) x = umax ; // take M[i+1] if u(i+1)<=hi else M_n(hi)
123  M.push_back( M_n( x, z ) );
124  }
125  double sc[7]; for (int i=0;i<7;++i) sc[i] = pow(scale,i);
126  std::complex<double> sum(0,0);
127  if (lo<_sp1.u(0)) sum += gaussIntegralE(true, M.front()-M_n( umin,z), K, offset, sc);
128  for (unsigned i=0;i<_sp1.knotSize()-1 && _sp1.u(i)<hi ;++i) {
129  M_n dM = M[i+1]-M[i];
131  for (int j=0;j<7;++j) for (int k=0;k<7-j;++k) sum += dM(j)*s2_jk(j,k)*K(k)*sc[j+k];
132  }
133  if (hi>_sp1.u(_sp1.knotSize()-1)) sum += gaussIntegralE(false, M_n(umax,z)-M.back(), K, offset, sc);
134  return sum;
135 }
std::complex< double > productAnalyticalIntegral(Double_t umin, Double_t umax, Double_t scale, Double_t offset, const std::complex< double > &z) const
double u(int i) const
RooCubicSplineFun _sp1
RooCubicSplineKnot::S2_jk S2_jk_sum(int i, const RooArgList &b1, const RooArgList &b2) const
RooCubicSplineKnot::S2_edge S2_jk_edge(bool left, const RooArgList &b1, const RooArgList &b2) const
RooListProxy _coefList1
const RooArgList & coefficients() const
RooListProxy _coefList2
Int_t getAnalyticalIntegral(RooArgSet &allVars, RooArgSet &analVars, const char *rangeName) const
std::complex< double > gaussIntegralE(bool left, const RooGaussModelAcceptance::M_n< 7U > &dM, const RooGaussModelAcceptance::K_n &K, double offset, double *sc) const
RooCubicSplineFun _sp2
unsigned knotSize() const
Double_t evaluate() const
double evaluate(double _u, const RooArgList &b) const
RooCubicSplineKnot _aux
Double_t analyticalIntegral(Int_t code, const char *rangeName) const