Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooVoigtian.cxx
Go to the documentation of this file.
1/*****************************************************************************
2 * Project: RooFit *
3 * Package: RooFitModels *
4 * @(#)root/roofit:$Id$
5 * Authors: *
6 * TS, Thomas Schietinger, SLAC, schieti@slac.stanford.edu *
7 * *
8 * Copyright (c) 2000-2005, Regents of the University of California *
9 * and Stanford University. All rights reserved. *
10 * *
11 * Redistribution and use in source and binary forms, *
12 * with or without modification, are permitted according to the terms *
13 * listed in LICENSE (http://roofit.sourceforge.net/license.txt) *
14 *****************************************************************************/
15
16/** \class RooVoigtian
17 \ingroup Roofit
18
19RooVoigtian is an efficient implementation of the convolution of a
20Breit-Wigner with a Gaussian, making use of the complex error function.
21RooFitCore provides two algorithms for the evaluation of the complex error
22function (the default CERNlib C335 algorithm, and a faster, look-up-table
23based method). By default, RooVoigtian employs the default (CERNlib)
24algorithm. Select the faster algorithm either in the constructor, or with
25the selectFastAlgorithm() method.
26
27\note The "width" parameter that determines the Breit-Wigner shape
28 represents the **full width at half maximum (FWHM)** of the
29 Breit-Wigner (often referred to as \f$\Gamma\f$ or \f$2\gamma\f$).
30**/
31
32#include <RooVoigtian.h>
33
34#include <RooMath.h>
35#include <RooBatchCompute.h>
36
37#include <cmath>
38#include <complex>
39
41
42////////////////////////////////////////////////////////////////////////////////
43/// Construct a RooVoigtian PDF, which represents the convolution of a
44/// Breit-Wigner with a Gaussian.
45/// \param name Name that identifies the PDF in computations.
46/// \param title Title for plotting.
47/// \param _x The observable for the PDF.
48/// \param _mean The mean of the distribution.
49/// \param _width The **full width at half maximum (FWHM)** of the Breit-Wigner
50/// (often referred to as \f$\Gamma\f$ or \f$2\gamma\f$).
51/// \param _sigma The width of the Gaussian distribution.
52/// \param doFast Use the faster look-up-table-based method for the evaluation
53/// of the complex error function.
54
55RooVoigtian::RooVoigtian(const char *name, const char *title,
56 RooAbsReal& _x, RooAbsReal& _mean,
57 RooAbsReal& _width, RooAbsReal& _sigma,
58 bool doFast) :
59 RooAbsPdf(name,title),
60 x("x","Dependent",this,_x),
61 mean("mean","Mean",this,_mean),
62 width("width","Breit-Wigner Width",this,_width),
63 sigma("sigma","Gauss Width",this,_sigma),
64 _doFast(doFast)
65{
66
67}
68
69////////////////////////////////////////////////////////////////////////////////
70
71RooVoigtian::RooVoigtian(const RooVoigtian& other, const char* name) :
72 RooAbsPdf(other,name), x("x",this,other.x), mean("mean",this,other.mean),
73 width("width",this,other.width),sigma("sigma",this,other.sigma),
74 _doFast(other._doFast)
75{
76
77}
78
79////////////////////////////////////////////////////////////////////////////////
80
82{
83 double s = (sigma>0) ? sigma : -sigma ;
84 double w = (width>0) ? width : -width ;
85
86 double coef= -0.5/(s*s);
87 double arg = x - mean;
88
89 // return constant for zero width and sigma
90 if (s==0. && w==0.) return 1.;
91
92 // Breit-Wigner for zero sigma
93 if (s==0.) return (1./(arg*arg+0.25*w*w));
94
95 // Gauss for zero width
96 if (w==0.) return std::exp(coef*arg*arg);
97
98 // actual Voigtian for non-trivial width and sigma
99 double c = 1./(sqrt(2.)*s);
100 double a = 0.5*c*w;
101 double u = c*arg;
102 std::complex<double> z(u,a) ;
103 std::complex<double> v(0.) ;
104
105 if (_doFast) {
107 } else {
108 v = RooMath::faddeeva(z);
109 }
110 return c * v.real();
111}
112
113////////////////////////////////////////////////////////////////////////////////
114/// Compute multiple values of Voigtian distribution.
115void RooVoigtian::computeBatch(cudaStream_t* stream, double* output, size_t nEvents, RooFit::Detail::DataMap const& dataMap) const
116{
118 dispatch->compute(stream, RooBatchCompute::Voigtian, output, nEvents,
119 {dataMap.at(x), dataMap.at(mean), dataMap.at(width), dataMap.at(sigma)});
120}
#define c(i)
Definition RSha256.hxx:101
#define a(i)
Definition RSha256.hxx:99
#define ClassImp(name)
Definition Rtypes.h:377
Option_t Option_t width
char name[80]
Definition TGX11.cxx:110
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition RooAbsReal.h:62
virtual void compute(cudaStream_t *, Computer, RestrictArr, size_t, const VarVector &, ArgVector &)=0
RooSpan< const double > at(RooAbsArg const *arg, RooAbsArg const *caller=nullptr)
Definition DataMap.cxx:21
static std::complex< double > faddeeva(std::complex< double > z)
evaluate Faddeeva function for complex argument
Definition RooMath.cxx:30
static std::complex< double > faddeeva_fast(std::complex< double > z)
evaluate Faddeeva function for complex argument (fast version)
Definition RooMath.cxx:35
RooVoigtian is an efficient implementation of the convolution of a Breit-Wigner with a Gaussian,...
Definition RooVoigtian.h:22
RooRealProxy x
Definition RooVoigtian.h:42
void computeBatch(cudaStream_t *, double *output, size_t nEvents, RooFit::Detail::DataMap const &) const override
Compute multiple values of Voigtian distribution.
double evaluate() const override
Evaluate this PDF / function / constant. Needs to be overridden by all derived classes.
RooRealProxy sigma
Definition RooVoigtian.h:45
RooRealProxy mean
Definition RooVoigtian.h:43
RooRealProxy width
Definition RooVoigtian.h:44
const Double_t sigma
Double_t x[n]
Definition legend1.C:17
R__EXTERN RooBatchComputeInterface * dispatchCUDA
R__EXTERN RooBatchComputeInterface * dispatchCPU
This dispatch pointer points to an implementation of the compute library, provided one has been loade...
static void output()