ROOT
master
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
19
RooVoigtian is an efficient implementation of the convolution of a
20
Breit-Wigner with a Gaussian, making use of the complex error function.
21
RooFitCore provides two algorithms for the evaluation of the complex error
22
function (the default CERNlib C335 algorithm, and a faster, look-up-table
23
based method). By default, RooVoigtian employs the default (CERNlib)
24
algorithm. Select the faster algorithm either in the constructor, or with
25
the 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
40
41
////////////////////////////////////////////////////////////////////////////////
42
/// Construct a RooVoigtian PDF, which represents the convolution of a
43
/// Breit-Wigner with a Gaussian.
44
/// \param name Name that identifies the PDF in computations.
45
/// \param title Title for plotting.
46
/// \param _x The observable for the PDF.
47
/// \param _mean The mean of the distribution.
48
/// \param _width The **full width at half maximum (FWHM)** of the Breit-Wigner
49
/// (often referred to as \f$\Gamma\f$ or \f$2\gamma\f$).
50
/// \param _sigma The width of the Gaussian distribution.
51
/// \param doFast Use the faster look-up-table-based method for the evaluation
52
/// of the complex error function.
53
54
RooVoigtian::RooVoigtian
(
const
char
*
name
,
const
char
*title,
55
RooAbsReal
& _x,
RooAbsReal
& _mean,
56
RooAbsReal
&
_width
,
RooAbsReal
& _sigma,
57
bool
doFast
) :
58
RooAbsPdf
(
name
,title),
59
x
(
"x"
,
"Dependent"
,
this
,_x),
60
mean(
"mean"
,
"Mean"
,
this
,_mean),
61
width
(
"width"
,
"Breit-Wigner Width"
,
this
,
_width
),
62
sigma
(
"sigma"
,
"Gauss Width"
,
this
,_sigma),
63
_doFast(
doFast
)
64
{
65
66
}
67
68
////////////////////////////////////////////////////////////////////////////////
69
70
RooVoigtian::RooVoigtian
(
const
RooVoigtian
&
other
,
const
char
*
name
) :
71
RooAbsPdf
(
other
,
name
),
x
(
"x"
,
this
,
other
.
x
), mean(
"mean"
,
this
,
other
.mean),
72
width
(
"width"
,
this
,
other
.
width
),
sigma
(
"sigma"
,
this
,
other
.
sigma
),
73
_doFast(
other
._doFast)
74
{
75
76
}
77
78
////////////////////////////////////////////////////////////////////////////////
79
80
double
RooVoigtian::evaluate
()
const
81
{
82
double
s = (
sigma
>0) ?
sigma
: -
sigma
;
83
double
w
= (
width
>0) ?
width
: -
width
;
84
85
double
coef= -0.5/(s*s);
86
double
arg =
x
-
mean
;
87
88
// return constant for zero width and sigma
89
if
(s==0. &&
w
==0.)
return
1.;
90
91
// Breit-Wigner for zero sigma
92
if
(s==0.)
return
(1./(arg*arg+0.25*
w
*
w
));
93
94
// Gauss for zero width
95
if
(
w
==0.)
return
std::exp(coef*arg*arg);
96
97
// actual Voigtian for non-trivial width and sigma
98
double
c
= 1./(sqrt(2.)*s);
99
double
a
= 0.5*
c
*
w
;
100
double
u
=
c
*arg;
101
std::complex<double> z(
u
,
a
) ;
102
std::complex<double>
v
(0.) ;
103
104
if
(
_doFast
) {
105
v
=
RooMath::faddeeva_fast
(z);
106
}
else
{
107
v
=
RooMath::faddeeva
(z);
108
}
109
return
c
*
v
.real();
110
}
111
112
////////////////////////////////////////////////////////////////////////////////
113
/// Compute multiple values of Voigtian distribution.
114
void
RooVoigtian::doEval
(
RooFit::EvalContext
&ctx)
const
115
{
116
RooBatchCompute::compute
(ctx.
config
(
this
),
RooBatchCompute::Voigtian
, ctx.
output
(),
117
{ctx.at(x), ctx.at(mean), ctx.at(width), ctx.at(sigma)});
118
}
c
#define c(i)
Definition
RSha256.hxx:101
a
#define a(i)
Definition
RSha256.hxx:99
RooBatchCompute.h
RooMath.h
RooVoigtian.h
w
winID w
Definition
TGWin32VirtualGLProxy.cxx:39
width
Option_t Option_t width
Definition
TGWin32VirtualXProxy.cxx:56
name
char name[80]
Definition
TGX11.cxx:110
ROOT::Detail::TRangeCast
Definition
TCollection.h:311
RooAbsPdf
Abstract interface for all probability density functions.
Definition
RooAbsPdf.h:40
RooAbsReal
Abstract base class for objects that represent a real value and implements functionality common to al...
Definition
RooAbsReal.h:59
RooFit::EvalContext
Definition
EvalContext.h:84
RooFit::EvalContext::output
std::span< double > output()
Definition
EvalContext.h:112
RooFit::EvalContext::config
RooBatchCompute::Config config(RooAbsArg const *arg) const
Definition
EvalContext.cxx:73
RooMath::faddeeva
static std::complex< double > faddeeva(std::complex< double > z)
evaluate Faddeeva function for complex argument
Definition
RooMath.cxx:30
RooMath::faddeeva_fast
static std::complex< double > faddeeva_fast(std::complex< double > z)
evaluate Faddeeva function for complex argument (fast version)
Definition
RooMath.cxx:35
RooVoigtian
RooVoigtian is an efficient implementation of the convolution of a Breit-Wigner with a Gaussian,...
Definition
RooVoigtian.h:22
RooVoigtian::x
RooRealProxy x
Definition
RooVoigtian.h:42
RooVoigtian::doEval
void doEval(RooFit::EvalContext &) const override
Compute multiple values of Voigtian distribution.
Definition
RooVoigtian.cxx:114
RooVoigtian::evaluate
double evaluate() const override
Evaluate this PDF / function / constant. Needs to be overridden by all derived classes.
Definition
RooVoigtian.cxx:80
RooVoigtian::_doFast
bool _doFast
Definition
RooVoigtian.h:53
RooVoigtian::sigma
RooRealProxy sigma
Definition
RooVoigtian.h:45
RooVoigtian::RooVoigtian
RooVoigtian()
Definition
RooVoigtian.h:24
RooVoigtian::mean
RooRealProxy mean
Definition
RooVoigtian.h:43
RooVoigtian::width
RooRealProxy width
Definition
RooVoigtian.h:44
sigma
const Double_t sigma
Definition
h1analysisProxy.h:11
x
Double_t x[n]
Definition
legend1.C:17
RooBatchCompute::compute
void compute(Config cfg, Computer comp, std::span< double > output, VarSpan vars, ArgSpan extraArgs={})
Definition
RooBatchCompute.h:212
RooBatchCompute::Voigtian
@ Voigtian
Definition
RooBatchCompute.h:113
v
@ v
Definition
rootcling_impl.cxx:3699
roofit
roofit
src
RooVoigtian.cxx
ROOT master - Reference Guide Generated on Tue May 20 2025 15:42:21 (GVA Time) using Doxygen 1.10.0