Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooGaussModel.cxx
Go to the documentation of this file.
1/*****************************************************************************
2 * Project: RooFit *
3 * Package: RooFitModels *
4 * @(#)root/roofit:$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/** \class RooGaussModel
18 \ingroup Roofit
19
20Class RooGaussModel implements a RooResolutionModel that models a Gaussian
21distribution. Object of class RooGaussModel can be used
22for analytical convolutions with classes inheriting from RooAbsAnaConvPdf
23**/
24
25#include "TMath.h"
26#include "RooGaussModel.h"
27#include "RooMath.h"
28#include "RooRealConstant.h"
29#include "RooRandom.h"
30#include "RooBatchCompute.h"
31
32#include "TError.h"
33
35
36#include <array>
37
38namespace {
39
40enum RooGaussBasis {
41 noBasis = 0,
42 expBasisMinus = 1,
43 expBasisSum = 2,
44 expBasisPlus = 3,
45 sinBasisMinus = 11,
46 sinBasisSum = 12,
47 sinBasisPlus = 13,
48 cosBasisMinus = 21,
49 cosBasisSum = 22,
50 cosBasisPlus = 23,
51 linBasisPlus = 33,
52 quadBasisPlus = 43,
53 coshBasisMinus = 51,
54 coshBasisSum = 52,
55 coshBasisPlus = 53,
56 sinhBasisMinus = 61,
57 sinhBasisSum = 62,
58 sinhBasisPlus = 63
59};
60
61enum BasisType {
62 none = 0,
63 expBasis = 1,
64 sinBasis = 2,
65 cosBasis = 3,
66 linBasis = 4,
67 quadBasis = 5,
68 coshBasis = 6,
69 sinhBasis = 7
70};
71
72enum BasisSign { Both = 0, Plus = +1, Minus = -1 };
73
74BasisType getBasisType(int basisCode)
75{
76 return static_cast<BasisType>(basisCode == 0 ? 0 : (basisCode / 10) + 1);
77}
78
79} // namespace
80
83
84
85////////////////////////////////////////////////////////////////////////////////
86
87RooGaussModel::RooGaussModel(const char *name, const char *title, RooAbsRealLValue &xIn, RooAbsReal &_mean,
88 RooAbsReal &_sigma)
89 : RooGaussModel{name, title, xIn, _mean, _sigma, RooRealConstant::value(1), RooRealConstant::value(1)}
90{
91}
92
93////////////////////////////////////////////////////////////////////////////////
94
95RooGaussModel::RooGaussModel(const char *name, const char *title, RooAbsRealLValue &xIn, RooAbsReal &_mean,
96 RooAbsReal &_sigma, RooAbsReal &_msSF)
97 : RooGaussModel{name, title, xIn, _mean, _sigma, _msSF, _msSF}
98{
99}
100
101////////////////////////////////////////////////////////////////////////////////
102
103RooGaussModel::RooGaussModel(const char *name, const char *title, RooAbsRealLValue& xIn,
104 RooAbsReal& _mean, RooAbsReal& _sigma,
105 RooAbsReal& _meanSF, RooAbsReal& _sigmaSF) :
107 _flatSFInt(false),
108 _asympInt(false),
109 mean("mean","Mean",this,_mean),
110 sigma("sigma","Width",this,_sigma),
111 msf("msf","Mean Scale Factor",this,_meanSF),
112 ssf("ssf","Sigma Scale Factor",this,_sigmaSF)
113{
114}
115
116////////////////////////////////////////////////////////////////////////////////
117
120 _flatSFInt(other._flatSFInt),
121 _asympInt(other._asympInt),
122 mean("mean",this,other.mean),
123 sigma("sigma",this,other.sigma),
124 msf("msf",this,other.msf),
125 ssf("ssf",this,other.ssf)
126{
127}
128
129////////////////////////////////////////////////////////////////////////////////
130
132{
133 std::string str = name;
134
135 // Remove whitespaces from the input string
136 str.erase(remove(str.begin(),str.end(),' '),str.end());
137
138 if (str == "exp(-@0/@1)") return expBasisPlus ;
139 if (str == "exp(@0/@1)") return expBasisMinus ;
140 if (str == "exp(-abs(@0)/@1)") return expBasisSum ;
141 if (str == "exp(-@0/@1)*sin(@0*@2)") return sinBasisPlus ;
142 if (str == "exp(@0/@1)*sin(@0*@2)") return sinBasisMinus ;
143 if (str == "exp(-abs(@0)/@1)*sin(@0*@2)") return sinBasisSum ;
144 if (str == "exp(-@0/@1)*cos(@0*@2)") return cosBasisPlus ;
145 if (str == "exp(@0/@1)*cos(@0*@2)") return cosBasisMinus ;
146 if (str == "exp(-abs(@0)/@1)*cos(@0*@2)") return cosBasisSum ;
147 if (str == "(@0/@1)*exp(-@0/@1)") return linBasisPlus ;
148 if (str == "(@0/@1)*(@0/@1)*exp(-@0/@1)") return quadBasisPlus ;
149 if (str == "exp(-@0/@1)*cosh(@0*@2/2)") return coshBasisPlus;
150 if (str == "exp(@0/@1)*cosh(@0*@2/2)") return coshBasisMinus;
151 if (str == "exp(-abs(@0)/@1)*cosh(@0*@2/2)") return coshBasisSum;
152 if (str == "exp(-@0/@1)*sinh(@0*@2/2)") return sinhBasisPlus;
153 if (str == "exp(@0/@1)*sinh(@0*@2/2)") return sinhBasisMinus;
154 if (str == "exp(-abs(@0)/@1)*sinh(@0*@2/2)") return sinhBasisSum;
155
156 return 0;
157}
158
159////////////////////////////////////////////////////////////////////////////////
160
162{
163 auto arg1 = static_cast<RooAbsReal*>(basis().getParameter(1));
164 auto arg2 = static_cast<RooAbsReal*>(basis().getParameter(2));
165 double param1 = arg1 ? arg1->getVal() : 0.0;
166 double param2 = arg2 ? arg2->getVal() : 0.0;
167 return evaluate(x, mean * msf, sigma * ssf, param1, param2, _basisCode);
168}
169
171{
172 std::span<double> output = ctx.output();
173 std::size_t size = output.size();
174
175 auto xVals = ctx.at(x);
176 auto meanVals = ctx.at(mean);
177 auto meanSfVals = ctx.at(msf);
178 auto sigmaVals = ctx.at(sigma);
179 auto sigmaSfVals = ctx.at(ssf);
180
181 auto param1 = static_cast<RooAbsReal *>(basis().getParameter(1));
182 auto param2 = static_cast<RooAbsReal *>(basis().getParameter(2));
183 const double zeroVal = 0.0;
184 auto param1Vals = param1 ? ctx.at(param1) : std::span<const double>{&zeroVal, 1};
185 auto param2Vals = param2 ? ctx.at(param2) : std::span<const double>{&zeroVal, 1};
186
187 BasisType basisType = getBasisType(_basisCode);
188 double basisSign = _basisCode - 10 * (basisType - 1) - 2;
189
190 // We have an implementation also for CUDA right now only for the most used
191 // basis type, which is expBasis. If the need to support other basis types
192 // arises, they can be implemented following this example. Remember to also
193 // adapt RooGaussModel::canComputeBatchWithCuda().
194 if (basisType == expBasis) {
195 std::array<double, 1> extraArgs{basisSign};
197 {xVals, meanVals, meanSfVals, sigmaVals, sigmaSfVals, param1Vals}, extraArgs);
198 return;
199 }
200
201 // For now, if the arrays don't have the expected input shape, fall back to the scalar mode
202 if (xVals.size() != size || meanVals.size() != 1 || meanSfVals.size() != 1 || sigmaVals.size() != 1 ||
203 sigmaSfVals.size() != 1 || param1Vals.size() != 1 || param2Vals.size() != 1) {
204 return RooAbsPdf::doEval(ctx);
205 }
206
207 for (unsigned int i = 0; i < size; ++i) {
208 output[i] = evaluate(xVals[i], meanVals[0] * meanSfVals[0], sigmaVals[0] * sigmaSfVals[0], param1Vals[0],
210 }
211}
212
213double RooGaussModel::evaluate(double x, double mean, double sigma, double param1, double param2, int basisCode)
214{
215 // *** 1st form: Straight Gaussian, used for unconvoluted PDF or expBasis with 0 lifetime ***
216 static double root2(std::sqrt(2.)) ;
217 static double root2pi(std::sqrt(2.*std::atan2(0.,-1.))) ;
218 static double rootpi(std::sqrt(std::atan2(0.,-1.))) ;
219
220 BasisType basisType = getBasisType(basisCode);
221 BasisSign basisSign = (BasisSign)( basisCode - 10*(basisType-1) - 2 ) ;
222
223 double tau = (basisCode!=noBasis) ? param1 : 0.0;
224 if (basisType == coshBasis && basisCode!=noBasis ) {
225 double dGamma = param2;
226 if (dGamma==0) basisType = expBasis;
227 }
228
229 if (basisType==none || ((basisType==expBasis || basisType==cosBasis) && tau==0.)) {
230 double xprime = (x-mean)/sigma ;
231 double result = std::exp(-0.5*xprime*xprime)/(sigma*root2pi) ;
232 if (basisCode!=0 && basisSign==Both) result *= 2 ;
233 return result ;
234 }
235
236 // *** 2nd form: 0, used for sinBasis, linBasis, and quadBasis with tau=0 ***
237 if (tau==0) {
238 return 0. ;
239 }
240
241 // *** 3nd form: Convolution with exp(-t/tau), used for expBasis and cosBasis(omega=0) ***
242 double omega = (basisType==sinBasis || basisType==cosBasis) ? param2 : 0 ;
243 double dgamma = (basisType==sinhBasis || basisType==coshBasis) ? param2 : 0 ;
244 double _x = omega *tau ;
245 double _y = tau*dgamma/2;
246 double xprime = (x-mean)/tau ;
247 double c = sigma/(root2*tau) ;
248 double u = xprime/(2*c) ;
249
250 if (basisType==expBasis || (basisType==cosBasis && _x==0.)) {
251 double result(0) ;
252 if (basisSign!=Minus) result += evalCerf(0,-u,c).real();
253 if (basisSign!=Plus) result += evalCerf(0, u,c).real();
254 return result ;
255 }
256
257 // *** 4th form: Convolution with exp(-t/tau)*sin(omega*t), used for sinBasis(omega<>0,tau<>0) ***
258 if (basisType==sinBasis) {
259 double result(0) ;
260 if (_x==0.) return result ;
261 if (basisSign!=Minus) result += -evalCerf(-_x,-u,c).imag();
262 if (basisSign!=Plus) result += -evalCerf( _x, u,c).imag();
263 return result ;
264 }
265
266 // *** 5th form: Convolution with exp(-t/tau)*cos(omega*t), used for cosBasis(omega<>0) ***
267 if (basisType==cosBasis) {
268 double result(0) ;
269 if (basisSign!=Minus) result += evalCerf(-_x,-u,c).real();
270 if (basisSign!=Plus) result += evalCerf( _x, u,c).real();
271 return result ;
272 }
273
274 // ***8th form: Convolution with exp(-|t|/tau)*cosh(dgamma*t/2), used for coshBasisSum ***
276 double result(0);
277 int sgn = ( basisType == coshBasis ? +1 : -1 );
278 if (basisSign!=Minus) result += 0.5*( evalCerf(0,-u,c*(1-_y)).real()+sgn*evalCerf(0,-u,c*(1+_y)).real()) ;
279 if (basisSign!=Plus) result += 0.5*(sgn*evalCerf(0, u,c*(1-_y)).real()+ evalCerf(0, u,c*(1+_y)).real()) ;
280 return result ;
281 }
282
283 // *** 6th form: Convolution with (t/tau)*exp(-t/tau), used for linBasis ***
284 if (basisType==linBasis) {
285 R__ASSERT(basisSign==Plus); // This should only be for positive times
286
287 double f0 = std::exp(-xprime+c*c) * RooMath::erfc(-u+c);
288 double f1 = std::exp(-u*u);
289 return (xprime - 2*c*c)*f0 + (2*c/rootpi)*f1 ;
290 }
291
292 // *** 7th form: Convolution with (t/tau)^2*exp(-t/tau), used for quadBasis ***
293 if (basisType==quadBasis) {
294 R__ASSERT(basisSign==Plus); // This should only be for positive times
295
296 double f0 = std::exp(-xprime+c*c) * RooMath::erfc(-u+c);
297 double f1 = std::exp(-u*u);
298 double x2c2 = xprime - 2*c*c;
299 return ( x2c2*x2c2*f0 + (2*c/rootpi)*x2c2*f1 + 2*c*c*f0 );
300 }
301
302 R__ASSERT(0) ;
303 return 0 ;
304}
305
306////////////////////////////////////////////////////////////////////////////////
307
308Int_t RooGaussModel::getAnalyticalIntegral(RooArgSet& allVars, RooArgSet& analVars, const char* /*rangeName*/) const
309{
310 switch(_basisCode) {
311
312 // Analytical integration capability of raw PDF
313 case noBasis:
314
315 // Optionally advertise flat integral over sigma scale factor
316 if (_flatSFInt) {
317 if (matchArgs(allVars,analVars,RooArgSet(convVar(),ssf.arg()))) return 2 ;
318 }
319
320 if (matchArgs(allVars,analVars,convVar())) return 1 ;
321 break ;
322
323 // Analytical integration capability of convoluted PDF
324 case expBasisPlus:
325 case expBasisMinus:
326 case expBasisSum:
327 case sinBasisPlus:
328 case sinBasisMinus:
329 case sinBasisSum:
330 case cosBasisPlus:
331 case cosBasisMinus:
332 case cosBasisSum:
333 case linBasisPlus:
334 case quadBasisPlus:
335 case coshBasisMinus:
336 case coshBasisPlus:
337 case coshBasisSum:
338 case sinhBasisMinus:
339 case sinhBasisPlus:
340 case sinhBasisSum:
341
342 // Optionally advertise flat integral over sigma scale factor
343 if (_flatSFInt) {
344
345 if (matchArgs(allVars,analVars,RooArgSet(convVar(),ssf.arg()))) {
346 return 2 ;
347 }
348 }
349
350 if (matchArgs(allVars,analVars,convVar())) return 1 ;
351 break ;
352 }
353
354 return 0 ;
355}
356
357////////////////////////////////////////////////////////////////////////////////
358
359double RooGaussModel::analyticalIntegral(Int_t code, const char* rangeName) const
360{
361 static const double root2 = std::sqrt(2.) ;
362 //static double rootPiBy2 = std::sqrt(std::atan2(0.0,-1.0)/2.0);
363 static const double rootpi = std::sqrt(std::atan2(0.0,-1.0));
364 double ssfInt(1.0) ;
365
366 // Code must be 1 or 2
367 R__ASSERT(code==1||code==2) ;
368 if (code==2) ssfInt = (ssf.max(rangeName)-ssf.min(rangeName)) ;
369
370 BasisType basisType = (BasisType)( (_basisCode == 0) ? 0 : (_basisCode/10) + 1 );
371 BasisSign basisSign = (BasisSign)( _basisCode - 10*(basisType-1) - 2 ) ;
372
373 // *** 1st form: Straight Gaussian, used for unconvoluted PDF or expBasis with 0 lifetime ***
374 double tau = (_basisCode!=noBasis)?(static_cast<RooAbsReal*>(basis().getParameter(1)))->getVal():0 ;
376 double dGamma = (static_cast<RooAbsReal*>(basis().getParameter(2)))->getVal();
377 if (dGamma==0) basisType = expBasis;
378 }
379 if (basisType==none || ((basisType==expBasis || basisType==cosBasis) && tau==0.)) {
380 double xscale = root2*(sigma*ssf);
381 if (verboseEval()>0) std::cout << "RooGaussModel::analyticalIntegral(" << GetName() << ") 1st form" << std::endl ;
382
383 double xpmin = (x.min(rangeName)-(mean*msf))/xscale ;
384 double xpmax = (x.max(rangeName)-(mean*msf))/xscale ;
385
386 double result ;
387 if (_asympInt) { // modified FMV, 07/24/03
388 result = 1.0 ;
389 } else {
391 }
392
393 if (_basisCode!=0 && basisSign==Both) result *= 2 ;
394 //cout << "Integral 1st form " << " result= " << result*ssfInt << std::endl;
395 if (TMath::IsNaN(result)) { cxcoutE(Tracing) << "RooGaussModel::analyticalIntegral(" << GetName() << ") got nan during case 1 " << std::endl; }
396 return result*ssfInt ;
397 }
398
399
400 double omega = ((basisType==sinBasis)||(basisType==cosBasis)) ? (static_cast<RooAbsReal*>(basis().getParameter(2)))->getVal() : 0 ;
401 double dgamma =((basisType==sinhBasis)||(basisType==coshBasis)) ? (static_cast<RooAbsReal*>(basis().getParameter(2)))->getVal() : 0 ;
402
403 // *** 2nd form: unity, used for sinBasis and linBasis with tau=0 (PDF is zero) ***
404 if (tau==0) {
405 if (verboseEval()>0) std::cout << "RooGaussModel::analyticalIntegral(" << GetName() << ") 2nd form" << std::endl ;
406 return 0. ;
407 }
408
409 // *** 3rd form: Convolution with exp(-t/tau), used for expBasis and cosBasis(omega=0) ***
410 double c = (sigma*ssf)/(root2*tau) ;
411 double xpmin = (x.min(rangeName)-(mean*msf))/tau ;
412 double xpmax = (x.max(rangeName)-(mean*msf))/tau ;
413 double umin = xpmin/(2*c) ;
414 double umax = xpmax/(2*c) ;
415
416 if (basisType==expBasis || (basisType==cosBasis && omega==0.)) {
417 if (verboseEval()>0) std::cout << "RooGaussModel::analyticalIntegral(" << GetName() << ") 3d form tau=" << tau << std::endl ;
418 double result(0) ;
419 if (basisSign!=Minus) result += evalCerfInt(+1,0,tau,-umin,-umax,c).real();
420 if (basisSign!=Plus) result += evalCerfInt(-1,0,tau, umin, umax,c).real();
421 if (TMath::IsNaN(result)) { cxcoutE(Tracing) << "RooGaussModel::analyticalIntegral(" << GetName() << ") got nan during case 3 " << std::endl; }
422 return result*ssfInt ;
423 }
424
425 // *** 4th form: Convolution with exp(-t/tau)*sin(omega*t), used for sinBasis(omega<>0,tau<>0) ***
426 double _x = omega * tau ;
427 double _y = tau*dgamma/2;
428
429 if (basisType==sinBasis) {
430 if (verboseEval()>0) std::cout << "RooGaussModel::analyticalIntegral(" << GetName() << ") 4th form omega = " << omega << ", tau = " << tau << std::endl ;
431 double result(0) ;
432 if (_x==0) return result*ssfInt ;
433 if (basisSign!=Minus) result += -1*evalCerfInt(+1,-_x,tau,-umin,-umax,c).imag();
434 if (basisSign!=Plus) result += -1*evalCerfInt(-1, _x,tau, umin, umax,c).imag();
435 if (TMath::IsNaN(result)) { cxcoutE(Tracing) << "RooGaussModel::analyticalIntegral(" << GetName() << ") got nan during case 4 " << std::endl; }
436 return result*ssfInt ;
437 }
438
439 // *** 5th form: Convolution with exp(-t/tau)*cos(omega*t), used for cosBasis(omega<>0) ***
440 if (basisType==cosBasis) {
441 if (verboseEval()>0) std::cout << "RooGaussModel::analyticalIntegral(" << GetName() << ") 5th form omega = " << omega << ", tau = " << tau << std::endl ;
442 double result(0) ;
443 if (basisSign!=Minus) result += evalCerfInt(+1,-_x,tau,-umin,-umax,c).real();
444 if (basisSign!=Plus) result += evalCerfInt(-1, _x,tau, umin, umax,c).real();
445 if (TMath::IsNaN(result)) { cxcoutE(Tracing) << "RooGaussModel::analyticalIntegral(" << GetName() << ") got nan during case 5 " << std::endl; }
446 return result*ssfInt ;
447 }
448
449 // *** 8th form: Convolution with exp(-|t|/tau)*cosh(dgamma*t/2), used for coshBasis ***
450 // *** 9th form: Convolution with exp(-|t|/tau)*sinh(dgamma*t/2), used for sinhBasis ***
452 if (verboseEval()>0) {std::cout << "RooGaussModel::analyticalIntegral(" << GetName() << ") 8th form tau=" << tau << std::endl ; }
453 double result(0) ;
454 int sgn = ( basisType == coshBasis ? +1 : -1 );
455 if (basisSign!=Minus) result += 0.5*( evalCerfInt(+1,0,tau/(1-_y),-umin,-umax,c*(1-_y)).real()+ sgn*evalCerfInt(+1,0,tau/(1+_y),-umin,-umax,c*(1+_y)).real());
456 if (basisSign!=Plus) result += 0.5*(sgn*evalCerfInt(-1,0,tau/(1-_y), umin, umax,c*(1-_y)).real()+ evalCerfInt(-1,0,tau/(1+_y), umin, umax,c*(1+_y)).real());
457 if (TMath::IsNaN(result)) { cxcoutE(Tracing) << "RooGaussModel::analyticalIntegral(" << GetName() << ") got nan during case 6 " << std::endl; }
458 return result*ssfInt ;
459 }
460
461 // *** 6th form: Convolution with (t/tau)*exp(-t/tau), used for linBasis ***
462 if (basisType==linBasis) {
463 if (verboseEval()>0) std::cout << "RooGaussModel::analyticalIntegral(" << GetName() << ") 6th form tau=" << tau << std::endl ;
464
465 double f0 = RooMath::erf(-umax) - RooMath::erf(-umin);
466 double f1 = std::exp(-umax*umax) - std::exp(-umin*umin);
467
468 double tmp1 = std::exp(-xpmax)*RooMath::erfc(-umax + c);
469 double tmp2 = std::exp(-xpmin)*RooMath::erfc(-umin + c);
470
471 double f2 = tmp1 - tmp2;
472 double f3 = xpmax*tmp1 - xpmin*tmp2;
473
474 double expc2 = std::exp(c*c);
475
476 return -tau*( f0 +
477 (2*c/rootpi)*f1 +
478 (1 - 2*c*c)*expc2*f2 +
479 expc2*f3
480 )*ssfInt;
481 }
482
483 // *** 7th form: Convolution with (t/tau)*(t/tau)*exp(-t/tau), used for quadBasis ***
484 if (basisType==quadBasis) {
485 if (verboseEval()>0) std::cout << "RooGaussModel::analyticalIntegral(" << GetName() << ") 7th form tau=" << tau << std::endl ;
486
487 double f0 = RooMath::erf(-umax) - RooMath::erf(-umin);
488
489 double tmpA1 = std::exp(-umax*umax);
490 double tmpA2 = std::exp(-umin*umin);
491
492 double f1 = tmpA1 - tmpA2;
493 double f2 = umax*tmpA1 - umin*tmpA2;
494
495 double tmpB1 = std::exp(-xpmax)*RooMath::erfc(-umax + c);
496 double tmpB2 = std::exp(-xpmin)*RooMath::erfc(-umin + c);
497
498 double f3 = tmpB1 - tmpB2;
499 double f4 = xpmax*tmpB1 - xpmin*tmpB2;
500 double f5 = xpmax*xpmax*tmpB1 - xpmin*xpmin*tmpB2;
501
502 double expc2 = std::exp(c*c);
503
504 return -tau*( 2*f0 +
505 (4*c/rootpi)*((1-c*c)*f1 + c*f2) +
506 (2*c*c*(2*c*c-1) + 2)*expc2*f3 - (4*c*c-2)*expc2*f4 + expc2*f5
507 )*ssfInt;
508 }
509 R__ASSERT(0) ;
510 return 0 ;
511}
512
513
514////////////////////////////////////////////////////////////////////////////////
515
516std::complex<double> RooGaussModel::evalCerfInt(double sign, double _x, double tau, double umin, double umax, double c) const
517{
518 std::complex<double> diff(2., 0.);
519 if (!_asympInt) {
520 diff = evalCerf(_x,umin,c);
521 diff -= evalCerf(_x,umax,c);
523 diff *= sign;
524 }
525 diff *= std::complex<double>(1., _x);
526 diff *= tau / (1.+_x*_x);
527 return diff;
528}
529
530////////////////////////////////////////////////////////////////////////////////
531
533{
534 return matchArgs(directVars,generateVars,x) ? 1 : 0;
535}
536
537////////////////////////////////////////////////////////////////////////////////
538
540{
541 R__ASSERT(code==1) ;
542 double xmin = x.min();
543 double xmax = x.max();
545 while(true) {
546 double xgen = generator->Gaus(mean*msf,sigma*ssf);
548 x = xgen ;
549 return ;
550 }
551 }
552}
553
#define c(i)
Definition RSha256.hxx:101
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
#define cxcoutE(a)
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
#define R__ASSERT(e)
Checks condition e and reports a fatal error if it's false.
Definition TError.h:130
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
char name[80]
Definition TGX11.cxx:142
float xmin
float xmax
static int verboseEval()
Return global level of verbosity for p.d.f. evaluations.
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:63
virtual void doEval(RooFit::EvalContext &) const
Base function for computing multiple values of a RooAbsReal.
bool matchArgs(const RooArgSet &allDeps, RooArgSet &analDeps, const RooArgProxy &a, const Proxies &... proxies) const
Definition RooAbsReal.h:425
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:24
Class RooGaussModel implements a RooResolutionModel that models a Gaussian distribution.
RooRealProxy sigma
double evaluate() const override
Evaluate this PDF / function / constant. Needs to be overridden by all derived classes.
std::complex< double > evalCerfInt(double sign, double wt, double tau, double umin, double umax, double c) const
RooRealProxy msf
void doEval(RooFit::EvalContext &) const override
Base function for computing multiple values of a RooAbsReal.
Int_t getAnalyticalIntegral(RooArgSet &allVars, RooArgSet &analVars, const char *rangeName=nullptr) const override
Interface function getAnalyticalIntergral advertises the analytical integrals that are supported.
void generateEvent(Int_t code) override
Interface for generation of an event using the algorithm corresponding to the specified code.
RooGaussModel()=default
bool canComputeBatchWithCuda() const override
Int_t basisCode(const char *name) const override
Int_t getGenerator(const RooArgSet &directVars, RooArgSet &generateVars, bool staticInitOK=true) const override
Load generatedVars with the subset of directVars that we can generate events for, and return a code t...
RooRealProxy mean
double analyticalIntegral(Int_t code, const char *rangeName) const override
Implements the actual analytical integral(s) advertised by getAnalyticalIntegral.
RooRealProxy ssf
static std::complex< double > erfc(const std::complex< double > z)
complex erfc function
Definition RooMath.cxx:40
static std::complex< double > erf(const std::complex< double > z)
complex erf function
Definition RooMath.cxx:59
static TRandom * randomGenerator()
Return a pointer to a singleton random-number generator implementation.
Definition RooRandom.cxx:47
Provides static functions to create and keep track of RooRealVar constants.
RooResolutionModel is the base class for PDFs that represent a resolution model that can be convolute...
Int_t _basisCode
Identifier code for selected basis function.
RooAbsRealLValue & convVar() const
Return the convolution variable of the resolution model.
const RooFormulaVar & basis() const
RooTemplateProxy< RooAbsRealLValue > x
Dependent/convolution variable.
double max(const char *rname=nullptr) const
Query upper limit of range. This requires the payload to be RooAbsRealLValue or derived.
const T & arg() const
Return reference to object held in proxy.
double min(const char *rname=nullptr) const
Query lower limit of range. This requires the payload to be RooAbsRealLValue or derived.
const char * GetName() const override
Returns name of object.
Definition TNamed.h:49
This is the base class for the ROOT Random number generators.
Definition TRandom.h:28
const Double_t sigma
Double_t x[n]
Definition legend1.C:17
TF1 * f1
Definition legend1.C:11
void compute(Config cfg, Computer comp, std::span< double > output, VarSpan vars, ArgSpan extraArgs={})
STD::complex< double > evalCerf(double swt, double u, double c)
STD::complex< double > evalCerfApprox(double _x, double u, double c)
use the approximation: erf(z) = exp(-z*z)/(STD::sqrt(pi)*z) to explicitly cancel the divergent exp(y*...
Bool_t IsNaN(Double_t x)
Definition TMath.h:905