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 "Riostream.h"
27#include "RooGaussModel.h"
28#include "RooMath.h"
29#include "RooRealConstant.h"
30#include "RooRandom.h"
31#include "RooBatchCompute.h"
32
33#include "TError.h"
34
36
37#include <array>
38
39namespace {
40
41enum RooGaussBasis {
42 noBasis = 0,
43 expBasisMinus = 1,
44 expBasisSum = 2,
45 expBasisPlus = 3,
46 sinBasisMinus = 11,
47 sinBasisSum = 12,
48 sinBasisPlus = 13,
49 cosBasisMinus = 21,
50 cosBasisSum = 22,
51 cosBasisPlus = 23,
52 linBasisPlus = 33,
53 quadBasisPlus = 43,
54 coshBasisMinus = 51,
55 coshBasisSum = 52,
56 coshBasisPlus = 53,
57 sinhBasisMinus = 61,
58 sinhBasisSum = 62,
59 sinhBasisPlus = 63
60};
61
62enum BasisType {
63 none = 0,
64 expBasis = 1,
65 sinBasis = 2,
66 cosBasis = 3,
67 linBasis = 4,
68 quadBasis = 5,
69 coshBasis = 6,
70 sinhBasis = 7
71};
72
73enum BasisSign { Both = 0, Plus = +1, Minus = -1 };
74
75BasisType getBasisType(int basisCode)
76{
77 return static_cast<BasisType>(basisCode == 0 ? 0 : (basisCode / 10) + 1);
78}
79
80} // namespace
81
84
85
86////////////////////////////////////////////////////////////////////////////////
87
88RooGaussModel::RooGaussModel(const char *name, const char *title, RooAbsRealLValue &xIn, RooAbsReal &_mean,
89 RooAbsReal &_sigma)
90 : RooGaussModel{name, title, xIn, _mean, _sigma, RooRealConstant::value(1), RooRealConstant::value(1)}
91{
92}
93
94////////////////////////////////////////////////////////////////////////////////
95
96RooGaussModel::RooGaussModel(const char *name, const char *title, RooAbsRealLValue &xIn, RooAbsReal &_mean,
97 RooAbsReal &_sigma, RooAbsReal &_msSF)
98 : RooGaussModel{name, title, xIn, _mean, _sigma, _msSF, _msSF}
99{
100}
101
102////////////////////////////////////////////////////////////////////////////////
103
104RooGaussModel::RooGaussModel(const char *name, const char *title, RooAbsRealLValue& xIn,
105 RooAbsReal& _mean, RooAbsReal& _sigma,
106 RooAbsReal& _meanSF, RooAbsReal& _sigmaSF) :
108 _flatSFInt(false),
109 _asympInt(false),
110 mean("mean","Mean",this,_mean),
111 sigma("sigma","Width",this,_sigma),
112 msf("msf","Mean Scale Factor",this,_meanSF),
113 ssf("ssf","Sigma Scale Factor",this,_sigmaSF)
114{
115}
116
117////////////////////////////////////////////////////////////////////////////////
118
121 _flatSFInt(other._flatSFInt),
122 _asympInt(other._asympInt),
123 mean("mean",this,other.mean),
124 sigma("sigma",this,other.sigma),
125 msf("msf",this,other.msf),
126 ssf("ssf",this,other.ssf)
127{
128}
129
130////////////////////////////////////////////////////////////////////////////////
131
133{
134 std::string str = name;
135
136 // Remove whitespaces from the input string
137 str.erase(remove(str.begin(),str.end(),' '),str.end());
138
139 if (str == "exp(-@0/@1)") return expBasisPlus ;
140 if (str == "exp(@0/@1)") return expBasisMinus ;
141 if (str == "exp(-abs(@0)/@1)") return expBasisSum ;
142 if (str == "exp(-@0/@1)*sin(@0*@2)") return sinBasisPlus ;
143 if (str == "exp(@0/@1)*sin(@0*@2)") return sinBasisMinus ;
144 if (str == "exp(-abs(@0)/@1)*sin(@0*@2)") return sinBasisSum ;
145 if (str == "exp(-@0/@1)*cos(@0*@2)") return cosBasisPlus ;
146 if (str == "exp(@0/@1)*cos(@0*@2)") return cosBasisMinus ;
147 if (str == "exp(-abs(@0)/@1)*cos(@0*@2)") return cosBasisSum ;
148 if (str == "(@0/@1)*exp(-@0/@1)") return linBasisPlus ;
149 if (str == "(@0/@1)*(@0/@1)*exp(-@0/@1)") return quadBasisPlus ;
150 if (str == "exp(-@0/@1)*cosh(@0*@2/2)") return coshBasisPlus;
151 if (str == "exp(@0/@1)*cosh(@0*@2/2)") return coshBasisMinus;
152 if (str == "exp(-abs(@0)/@1)*cosh(@0*@2/2)") return coshBasisSum;
153 if (str == "exp(-@0/@1)*sinh(@0*@2/2)") return sinhBasisPlus;
154 if (str == "exp(@0/@1)*sinh(@0*@2/2)") return sinhBasisMinus;
155 if (str == "exp(-abs(@0)/@1)*sinh(@0*@2/2)") return sinhBasisSum;
156
157 return 0;
158}
159
160////////////////////////////////////////////////////////////////////////////////
161
163{
164 auto arg1 = static_cast<RooAbsReal*>(basis().getParameter(1));
165 auto arg2 = static_cast<RooAbsReal*>(basis().getParameter(2));
166 double param1 = arg1 ? arg1->getVal() : 0.0;
167 double param2 = arg2 ? arg2->getVal() : 0.0;
168 return evaluate(x, mean * msf, sigma * ssf, param1, param2, _basisCode);
169}
170
172{
173 std::span<double> output = ctx.output();
174 std::size_t size = output.size();
175
176 auto xVals = ctx.at(x);
177 auto meanVals = ctx.at(mean);
178 auto meanSfVals = ctx.at(msf);
179 auto sigmaVals = ctx.at(sigma);
180 auto sigmaSfVals = ctx.at(ssf);
181
182 auto param1 = static_cast<RooAbsReal *>(basis().getParameter(1));
183 auto param2 = static_cast<RooAbsReal *>(basis().getParameter(2));
184 const double zeroVal = 0.0;
185 auto param1Vals = param1 ? ctx.at(param1) : std::span<const double>{&zeroVal, 1};
186 auto param2Vals = param2 ? ctx.at(param2) : std::span<const double>{&zeroVal, 1};
187
188 BasisType basisType = getBasisType(_basisCode);
189 double basisSign = _basisCode - 10 * (basisType - 1) - 2;
190
191 // We have an implementation also for CUDA right now only for the most used
192 // basis type, which is expBasis. If the need to support other basis types
193 // arises, they can be implemented following this example. Remember to also
194 // adapt RooGaussModel::canComputeBatchWithCuda().
195 if (basisType == expBasis) {
196 std::array<double, 1> extraArgs{basisSign};
198 {xVals, meanVals, meanSfVals, sigmaVals, sigmaSfVals, param1Vals}, extraArgs);
199 return;
200 }
201
202 // For now, if the arrays don't have the expected input shape, fall back to the scalar mode
203 if (xVals.size() != size || meanVals.size() != 1 || meanSfVals.size() != 1 || sigmaVals.size() != 1 ||
204 sigmaSfVals.size() != 1 || param1Vals.size() != 1 || param2Vals.size() != 1) {
205 return RooAbsPdf::doEval(ctx);
206 }
207
208 for (unsigned int i = 0; i < size; ++i) {
211 }
212}
213
214double RooGaussModel::evaluate(double x, double mean, double sigma, double param1, double param2, int basisCode)
215{
216 // *** 1st form: Straight Gaussian, used for unconvoluted PDF or expBasis with 0 lifetime ***
217 static double root2(std::sqrt(2.)) ;
218 static double root2pi(std::sqrt(2.*std::atan2(0.,-1.))) ;
219 static double rootpi(std::sqrt(std::atan2(0.,-1.))) ;
220
221 BasisType basisType = getBasisType(basisCode);
222 BasisSign basisSign = (BasisSign)( basisCode - 10*(basisType-1) - 2 ) ;
223
224 double tau = (basisCode!=noBasis) ? param1 : 0.0;
225 if (basisType == coshBasis && basisCode!=noBasis ) {
226 double dGamma = param2;
227 if (dGamma==0) basisType = expBasis;
228 }
229
230 if (basisType==none || ((basisType==expBasis || basisType==cosBasis) && tau==0.)) {
231 double xprime = (x-mean)/sigma ;
232 double result = std::exp(-0.5*xprime*xprime)/(sigma*root2pi) ;
233 if (basisCode!=0 && basisSign==Both) result *= 2 ;
234 return result ;
235 }
236
237 // *** 2nd form: 0, used for sinBasis, linBasis, and quadBasis with tau=0 ***
238 if (tau==0) {
239 return 0. ;
240 }
241
242 // *** 3nd form: Convolution with exp(-t/tau), used for expBasis and cosBasis(omega=0) ***
243 double omega = (basisType==sinBasis || basisType==cosBasis) ? param2 : 0 ;
244 double dgamma = (basisType==sinhBasis || basisType==coshBasis) ? param2 : 0 ;
245 double _x = omega *tau ;
246 double _y = tau*dgamma/2;
247 double xprime = (x-mean)/tau ;
248 double c = sigma/(root2*tau) ;
249 double u = xprime/(2*c) ;
250
251 if (basisType==expBasis || (basisType==cosBasis && _x==0.)) {
252 double result(0) ;
253 if (basisSign!=Minus) result += evalCerf(0,-u,c).real();
254 if (basisSign!=Plus) result += evalCerf(0, u,c).real();
255 return result ;
256 }
257
258 // *** 4th form: Convolution with exp(-t/tau)*sin(omega*t), used for sinBasis(omega<>0,tau<>0) ***
259 if (basisType==sinBasis) {
260 double result(0) ;
261 if (_x==0.) return result ;
262 if (basisSign!=Minus) result += -evalCerf(-_x,-u,c).imag();
263 if (basisSign!=Plus) result += -evalCerf( _x, u,c).imag();
264 return result ;
265 }
266
267 // *** 5th form: Convolution with exp(-t/tau)*cos(omega*t), used for cosBasis(omega<>0) ***
268 if (basisType==cosBasis) {
269 double result(0) ;
270 if (basisSign!=Minus) result += evalCerf(-_x,-u,c).real();
271 if (basisSign!=Plus) result += evalCerf( _x, u,c).real();
272 return result ;
273 }
274
275 // ***8th form: Convolution with exp(-|t|/tau)*cosh(dgamma*t/2), used for coshBasisSum ***
277 double result(0);
278 int sgn = ( basisType == coshBasis ? +1 : -1 );
279 if (basisSign!=Minus) result += 0.5*( evalCerf(0,-u,c*(1-_y)).real()+sgn*evalCerf(0,-u,c*(1+_y)).real()) ;
280 if (basisSign!=Plus) result += 0.5*(sgn*evalCerf(0, u,c*(1-_y)).real()+ evalCerf(0, u,c*(1+_y)).real()) ;
281 return result ;
282 }
283
284 // *** 6th form: Convolution with (t/tau)*exp(-t/tau), used for linBasis ***
285 if (basisType==linBasis) {
286 R__ASSERT(basisSign==Plus); // This should only be for positive times
287
288 double f0 = std::exp(-xprime+c*c) * RooMath::erfc(-u+c);
289 double f1 = std::exp(-u*u);
290 return (xprime - 2*c*c)*f0 + (2*c/rootpi)*f1 ;
291 }
292
293 // *** 7th form: Convolution with (t/tau)^2*exp(-t/tau), used for quadBasis ***
294 if (basisType==quadBasis) {
295 R__ASSERT(basisSign==Plus); // This should only be for positive times
296
297 double f0 = std::exp(-xprime+c*c) * RooMath::erfc(-u+c);
298 double f1 = std::exp(-u*u);
299 double x2c2 = xprime - 2*c*c;
300 return ( x2c2*x2c2*f0 + (2*c/rootpi)*x2c2*f1 + 2*c*c*f0 );
301 }
302
303 R__ASSERT(0) ;
304 return 0 ;
305}
306
307////////////////////////////////////////////////////////////////////////////////
308
309Int_t RooGaussModel::getAnalyticalIntegral(RooArgSet& allVars, RooArgSet& analVars, const char* /*rangeName*/) const
310{
311 switch(_basisCode) {
312
313 // Analytical integration capability of raw PDF
314 case noBasis:
315
316 // Optionally advertise flat integral over sigma scale factor
317 if (_flatSFInt) {
318 if (matchArgs(allVars,analVars,RooArgSet(convVar(),ssf.arg()))) return 2 ;
319 }
320
321 if (matchArgs(allVars,analVars,convVar())) return 1 ;
322 break ;
323
324 // Analytical integration capability of convoluted PDF
325 case expBasisPlus:
326 case expBasisMinus:
327 case expBasisSum:
328 case sinBasisPlus:
329 case sinBasisMinus:
330 case sinBasisSum:
331 case cosBasisPlus:
332 case cosBasisMinus:
333 case cosBasisSum:
334 case linBasisPlus:
335 case quadBasisPlus:
336 case coshBasisMinus:
337 case coshBasisPlus:
338 case coshBasisSum:
339 case sinhBasisMinus:
340 case sinhBasisPlus:
341 case sinhBasisSum:
342
343 // Optionally advertise flat integral over sigma scale factor
344 if (_flatSFInt) {
345
346 if (matchArgs(allVars,analVars,RooArgSet(convVar(),ssf.arg()))) {
347 return 2 ;
348 }
349 }
350
351 if (matchArgs(allVars,analVars,convVar())) return 1 ;
352 break ;
353 }
354
355 return 0 ;
356}
357
358////////////////////////////////////////////////////////////////////////////////
359
360double RooGaussModel::analyticalIntegral(Int_t code, const char* rangeName) const
361{
362 static const double root2 = std::sqrt(2.) ;
363 //static double rootPiBy2 = std::sqrt(std::atan2(0.0,-1.0)/2.0);
364 static const double rootpi = std::sqrt(std::atan2(0.0,-1.0));
365 double ssfInt(1.0) ;
366
367 // Code must be 1 or 2
368 R__ASSERT(code==1||code==2) ;
369 if (code==2) ssfInt = (ssf.max(rangeName)-ssf.min(rangeName)) ;
370
371 BasisType basisType = (BasisType)( (_basisCode == 0) ? 0 : (_basisCode/10) + 1 );
372 BasisSign basisSign = (BasisSign)( _basisCode - 10*(basisType-1) - 2 ) ;
373
374 // *** 1st form: Straight Gaussian, used for unconvoluted PDF or expBasis with 0 lifetime ***
375 double tau = (_basisCode!=noBasis)?(static_cast<RooAbsReal*>(basis().getParameter(1)))->getVal():0 ;
377 double dGamma = (static_cast<RooAbsReal*>(basis().getParameter(2)))->getVal();
378 if (dGamma==0) basisType = expBasis;
379 }
380 if (basisType==none || ((basisType==expBasis || basisType==cosBasis) && tau==0.)) {
381 double xscale = root2*(sigma*ssf);
382 if (verboseEval()>0) std::cout << "RooGaussModel::analyticalIntegral(" << GetName() << ") 1st form" << std::endl ;
383
384 double xpmin = (x.min(rangeName)-(mean*msf))/xscale ;
385 double xpmax = (x.max(rangeName)-(mean*msf))/xscale ;
386
387 double result ;
388 if (_asympInt) { // modified FMV, 07/24/03
389 result = 1.0 ;
390 } else {
392 }
393
394 if (_basisCode!=0 && basisSign==Both) result *= 2 ;
395 //cout << "Integral 1st form " << " result= " << result*ssfInt << std::endl;
396 if (TMath::IsNaN(result)) { cxcoutE(Tracing) << "RooGaussModel::analyticalIntegral(" << GetName() << ") got nan during case 1 " << std::endl; }
397 return result*ssfInt ;
398 }
399
400
401 double omega = ((basisType==sinBasis)||(basisType==cosBasis)) ? (static_cast<RooAbsReal*>(basis().getParameter(2)))->getVal() : 0 ;
402 double dgamma =((basisType==sinhBasis)||(basisType==coshBasis)) ? (static_cast<RooAbsReal*>(basis().getParameter(2)))->getVal() : 0 ;
403
404 // *** 2nd form: unity, used for sinBasis and linBasis with tau=0 (PDF is zero) ***
405 if (tau==0) {
406 if (verboseEval()>0) std::cout << "RooGaussModel::analyticalIntegral(" << GetName() << ") 2nd form" << std::endl ;
407 return 0. ;
408 }
409
410 // *** 3rd form: Convolution with exp(-t/tau), used for expBasis and cosBasis(omega=0) ***
411 double c = (sigma*ssf)/(root2*tau) ;
412 double xpmin = (x.min(rangeName)-(mean*msf))/tau ;
413 double xpmax = (x.max(rangeName)-(mean*msf))/tau ;
414 double umin = xpmin/(2*c) ;
415 double umax = xpmax/(2*c) ;
416
417 if (basisType==expBasis || (basisType==cosBasis && omega==0.)) {
418 if (verboseEval()>0) std::cout << "RooGaussModel::analyticalIntegral(" << GetName() << ") 3d form tau=" << tau << std::endl ;
419 double result(0) ;
420 if (basisSign!=Minus) result += evalCerfInt(+1,0,tau,-umin,-umax,c).real();
421 if (basisSign!=Plus) result += evalCerfInt(-1,0,tau, umin, umax,c).real();
422 if (TMath::IsNaN(result)) { cxcoutE(Tracing) << "RooGaussModel::analyticalIntegral(" << GetName() << ") got nan during case 3 " << std::endl; }
423 return result*ssfInt ;
424 }
425
426 // *** 4th form: Convolution with exp(-t/tau)*sin(omega*t), used for sinBasis(omega<>0,tau<>0) ***
427 double _x = omega * tau ;
428 double _y = tau*dgamma/2;
429
430 if (basisType==sinBasis) {
431 if (verboseEval()>0) std::cout << "RooGaussModel::analyticalIntegral(" << GetName() << ") 4th form omega = " << omega << ", tau = " << tau << std::endl ;
432 double result(0) ;
433 if (_x==0) return result*ssfInt ;
434 if (basisSign!=Minus) result += -1*evalCerfInt(+1,-_x,tau,-umin,-umax,c).imag();
435 if (basisSign!=Plus) result += -1*evalCerfInt(-1, _x,tau, umin, umax,c).imag();
436 if (TMath::IsNaN(result)) { cxcoutE(Tracing) << "RooGaussModel::analyticalIntegral(" << GetName() << ") got nan during case 4 " << std::endl; }
437 return result*ssfInt ;
438 }
439
440 // *** 5th form: Convolution with exp(-t/tau)*cos(omega*t), used for cosBasis(omega<>0) ***
441 if (basisType==cosBasis) {
442 if (verboseEval()>0) std::cout << "RooGaussModel::analyticalIntegral(" << GetName() << ") 5th form omega = " << omega << ", tau = " << tau << std::endl ;
443 double result(0) ;
444 if (basisSign!=Minus) result += evalCerfInt(+1,-_x,tau,-umin,-umax,c).real();
445 if (basisSign!=Plus) result += evalCerfInt(-1, _x,tau, umin, umax,c).real();
446 if (TMath::IsNaN(result)) { cxcoutE(Tracing) << "RooGaussModel::analyticalIntegral(" << GetName() << ") got nan during case 5 " << std::endl; }
447 return result*ssfInt ;
448 }
449
450 // *** 8th form: Convolution with exp(-|t|/tau)*cosh(dgamma*t/2), used for coshBasis ***
451 // *** 9th form: Convolution with exp(-|t|/tau)*sinh(dgamma*t/2), used for sinhBasis ***
453 if (verboseEval()>0) {std::cout << "RooGaussModel::analyticalIntegral(" << GetName() << ") 8th form tau=" << tau << std::endl ; }
454 double result(0) ;
455 int sgn = ( basisType == coshBasis ? +1 : -1 );
456 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());
457 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());
458 if (TMath::IsNaN(result)) { cxcoutE(Tracing) << "RooGaussModel::analyticalIntegral(" << GetName() << ") got nan during case 6 " << std::endl; }
459 return result*ssfInt ;
460 }
461
462 // *** 6th form: Convolution with (t/tau)*exp(-t/tau), used for linBasis ***
463 if (basisType==linBasis) {
464 if (verboseEval()>0) std::cout << "RooGaussModel::analyticalIntegral(" << GetName() << ") 6th form tau=" << tau << std::endl ;
465
466 double f0 = RooMath::erf(-umax) - RooMath::erf(-umin);
467 double f1 = std::exp(-umax*umax) - std::exp(-umin*umin);
468
469 double tmp1 = std::exp(-xpmax)*RooMath::erfc(-umax + c);
470 double tmp2 = std::exp(-xpmin)*RooMath::erfc(-umin + c);
471
472 double f2 = tmp1 - tmp2;
473 double f3 = xpmax*tmp1 - xpmin*tmp2;
474
475 double expc2 = std::exp(c*c);
476
477 return -tau*( f0 +
478 (2*c/rootpi)*f1 +
479 (1 - 2*c*c)*expc2*f2 +
480 expc2*f3
481 )*ssfInt;
482 }
483
484 // *** 7th form: Convolution with (t/tau)*(t/tau)*exp(-t/tau), used for quadBasis ***
485 if (basisType==quadBasis) {
486 if (verboseEval()>0) std::cout << "RooGaussModel::analyticalIntegral(" << GetName() << ") 7th form tau=" << tau << std::endl ;
487
488 double f0 = RooMath::erf(-umax) - RooMath::erf(-umin);
489
490 double tmpA1 = std::exp(-umax*umax);
491 double tmpA2 = std::exp(-umin*umin);
492
493 double f1 = tmpA1 - tmpA2;
494 double f2 = umax*tmpA1 - umin*tmpA2;
495
496 double tmpB1 = std::exp(-xpmax)*RooMath::erfc(-umax + c);
497 double tmpB2 = std::exp(-xpmin)*RooMath::erfc(-umin + c);
498
499 double f3 = tmpB1 - tmpB2;
500 double f4 = xpmax*tmpB1 - xpmin*tmpB2;
501 double f5 = xpmax*xpmax*tmpB1 - xpmin*xpmin*tmpB2;
502
503 double expc2 = std::exp(c*c);
504
505 return -tau*( 2*f0 +
506 (4*c/rootpi)*((1-c*c)*f1 + c*f2) +
507 (2*c*c*(2*c*c-1) + 2)*expc2*f3 - (4*c*c-2)*expc2*f4 + expc2*f5
508 )*ssfInt;
509 }
510 R__ASSERT(0) ;
511 return 0 ;
512}
513
514
515////////////////////////////////////////////////////////////////////////////////
516
517std::complex<double> RooGaussModel::evalCerfInt(double sign, double _x, double tau, double umin, double umax, double c) const
518{
519 std::complex<double> diff(2., 0.);
520 if (!_asympInt) {
521 diff = evalCerf(_x,umin,c);
522 diff -= evalCerf(_x,umax,c);
524 diff *= sign;
525 }
526 diff *= std::complex<double>(1., _x);
527 diff *= tau / (1.+_x*_x);
528 return diff;
529}
530
531////////////////////////////////////////////////////////////////////////////////
532
534{
535 return matchArgs(directVars,generateVars,x) ? 1 : 0;
536}
537
538////////////////////////////////////////////////////////////////////////////////
539
541{
542 R__ASSERT(code==1) ;
543 double xmin = x.min();
544 double xmax = x.max();
546 while(true) {
547 double xgen = generator->Gaus(mean*msf,sigma*ssf);
549 x = xgen ;
550 return ;
551 }
552 }
553}
554
#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:125
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:110
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:59
bool matchArgs(const RooArgSet &allDeps, RooArgSet &numDeps, const RooArgProxy &a) const
Utility function for use in getAnalyticalIntegral().
virtual void doEval(RooFit::EvalContext &) const
Base function for computing multiple values of a RooAbsReal.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:24
std::span< const double > at(RooAbsArg const *arg, RooAbsArg const *caller=nullptr)
std::span< double > output()
RooBatchCompute::Config config(RooAbsArg const *arg) const
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:27
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:896
static void output()