CLHEP 2.4.6.4
C++ Class Library for High Energy Physics
Loading...
Searching...
No Matches
Genfun::AnalyticConvolution Class Reference

#include <AnalyticConvolution.hh>

+ Inheritance diagram for Genfun::AnalyticConvolution:

Public Types

enum  Type {
  MIXED =0 , UNMIXED =1 , SMEARED_EXP =2 , SMEARED_COS_EXP =3 ,
  SMEARED_SIN_EXP =4 , SMEARED_NEG_EXP =5
}
 

Public Member Functions

 AnalyticConvolution (Type=SMEARED_EXP)
 
 AnalyticConvolution (const AnalyticConvolution &right)
 
virtual ~AnalyticConvolution ()
 
virtual double operator() (double argument) const override
 
virtual double operator() (const Argument &a) const override
 
Parameterfrequency ()
 
const Parameterfrequency () const
 
Parameterlifetime ()
 
const Parameterlifetime () const
 
Parametersigma ()
 
const Parametersigma () const
 
Parameteroffset ()
 
const Parameteroffset () const
 
- Public Member Functions inherited from Genfun::AbsFunction
 AbsFunction ()
 
 AbsFunction (const AbsFunction &right)
 
virtual ~AbsFunction ()
 
virtual unsigned int dimensionality () const
 
virtual double operator() (double argument) const =0
 
virtual double operator() (const Argument &argument) const =0
 
virtual AbsFunctionclone () const =0
 
virtual FunctionComposition operator() (const AbsFunction &f) const
 
virtual ParameterComposition operator() (const AbsParameter &p) const
 
Derivative derivative (const Variable &v) const
 
Derivative prime () const
 
virtual bool hasAnalyticDerivative () const
 
virtual Derivative partial (unsigned int) const
 

Detailed Description

Author

Definition at line 27 of file AnalyticConvolution.hh.

Member Enumeration Documentation

◆ Type

Enumerator
MIXED 
UNMIXED 
SMEARED_EXP 
SMEARED_COS_EXP 
SMEARED_SIN_EXP 
SMEARED_NEG_EXP 

Definition at line 34 of file AnalyticConvolution.hh.

34 {MIXED =0, // PDF for mixed events
35 UNMIXED =1, // PDF for unmixed events
36 SMEARED_EXP =2, // Exponential (convolve) Gaussian
37 SMEARED_COS_EXP=3, // Exponential * Cosine (convolve) Gaussian
38 SMEARED_SIN_EXP=4, // Exponential * Sine (convolve) Gaussian
39 SMEARED_NEG_EXP=5}; // Negative exponential (convolve) Gaussian

Constructor & Destructor Documentation

◆ AnalyticConvolution() [1/2]

Genfun::AnalyticConvolution::AnalyticConvolution ( AnalyticConvolution::Type  type = SMEARED_EXP)

Definition at line 16 of file AnalyticConvolution.cc.

16 :
17 _lifetime ("Lifetime", 1.0, 0.0), // Bounded from below by zero, by default
18 _frequency("Frequency", 0.0, 0.0), // Bounded from below by zero, by default
19 _sigma ("Sigma", 1.0, 0.0), // Bounded from below by zero, by default
20 _offset ("Offset", 0.0), // Offset is unbounded
21 _type(type)
22{
23}

◆ AnalyticConvolution() [2/2]

Genfun::AnalyticConvolution::AnalyticConvolution ( const AnalyticConvolution right)

Definition at line 25 of file AnalyticConvolution.cc.

25 :
26 AbsFunction(right),
27 _lifetime (right._lifetime),
28 _frequency (right._frequency),
29 _sigma (right._sigma),
30 _offset (right._offset),
31 _type(right._type)
32{
33}

◆ ~AnalyticConvolution()

Genfun::AnalyticConvolution::~AnalyticConvolution ( )
virtual

Definition at line 35 of file AnalyticConvolution.cc.

35 {
36}

Member Function Documentation

◆ frequency() [1/2]

Parameter & Genfun::AnalyticConvolution::frequency ( )

Definition at line 38 of file AnalyticConvolution.cc.

38 {
39 return _frequency;
40}

◆ frequency() [2/2]

const Parameter & Genfun::AnalyticConvolution::frequency ( ) const

Definition at line 42 of file AnalyticConvolution.cc.

42 {
43 return _frequency;
44}

◆ lifetime() [1/2]

Parameter & Genfun::AnalyticConvolution::lifetime ( )

Definition at line 46 of file AnalyticConvolution.cc.

46 {
47 return _lifetime;
48}

◆ lifetime() [2/2]

const Parameter & Genfun::AnalyticConvolution::lifetime ( ) const

Definition at line 50 of file AnalyticConvolution.cc.

50 {
51 return _lifetime;
52}

◆ offset() [1/2]

Parameter & Genfun::AnalyticConvolution::offset ( )

Definition at line 62 of file AnalyticConvolution.cc.

62 {
63 return _offset;
64}

◆ offset() [2/2]

const Parameter & Genfun::AnalyticConvolution::offset ( ) const

Definition at line 66 of file AnalyticConvolution.cc.

66 {
67 return _offset;
68}

◆ operator()() [1/2]

virtual double Genfun::AnalyticConvolution::operator() ( const Argument a) const
inlineoverridevirtual

Implements Genfun::AbsFunction.

Definition at line 51 of file AnalyticConvolution.hh.

51{return operator() (a[0]);}
virtual double operator()(double argument) const override

◆ operator()() [2/2]

double Genfun::AnalyticConvolution::operator() ( double  argument) const
overridevirtual

Implements Genfun::AbsFunction.

Definition at line 69 of file AnalyticConvolution.cc.

69 {
70 // Fetch the paramters. This operator does not convolve numerically.
71 static const double sqrtTwo = sqrt(2.0);
72 double xsigma = _sigma.getValue();
73 double tau = _lifetime.getValue();
74 double xoffset = _offset.getValue();
75 double x = argument-xoffset;
76 double freq = _frequency.getValue();
77
78 // smeared exponential an its asymmetry.
79 double expG=0.0, asymm=0.0;
80
81 if (_type==SMEARED_NEG_EXP) {
82 expG = exp((xsigma*xsigma +2*tau*(/*xoffset*/x))/(2.0*tau*tau)) *
83 erfc((xsigma*xsigma+tau*(/*xoffset*/x))/(sqrtTwo*xsigma*tau))/(2.0*tau);
84#if (defined _WIN32)
85 if (!_finite(expG)) {
86 expG=0.0;
87 }
88#else
89 if (!std::isfinite(expG)) {
90 expG=0.0;
91 }
92#endif
93 return expG;
94 }
95 else {
96 expG = exp((xsigma*xsigma +2*tau*(/*xoffset*/-x))/(2.0*tau*tau)) *
97 erfc((xsigma*xsigma+tau*(/*xoffset*/-x))/(sqrtTwo*xsigma*tau))/(2.0*tau);
98 }
99
100 // Both sign distribution=> return smeared exponential:
101 if (_type==SMEARED_EXP) {
102#if (defined _WIN32)
103 if (!_finite(expG)) {
104 expG=0.0;
105 }
106#else
107 if (!std::isfinite(expG)) {
108 expG=0.0;
109 }
110#endif
111 return expG;
112 }
113
114
115 // Calcualtion of asymmetry:
116
117 // First, if the mixing frequency is too high compared with the lifetime, we
118 // cannot see this oscillation. We abandon the complicated approach and just do
119 // this instead:
120 if (xsigma>6.0*tau) {
121 asymm = expG*(1/(1+tau*tau*freq*freq));
122 }
123 else if (xsigma==0.0) {
124 if (_type==SMEARED_COS_EXP|| _type==MIXED || _type==UNMIXED ) {
125 if (x>=0) asymm= (expG*cos(freq*x));
126 }
127 else if (_type==SMEARED_SIN_EXP) {
128 if (x>=0) asymm= (expG*sin(freq*x));
129 }
130 }
131 else {
132 std::complex<double> z(freq*xsigma/sqrtTwo, (xsigma/tau-x/xsigma)/sqrtTwo);
133 if (x<0) {
134 if (_type==SMEARED_COS_EXP|| _type==MIXED || _type==UNMIXED ) {
135 asymm= 2.0*nwwerf(z).real()/tau/4.0*exp(-x*x/2.0/xsigma/xsigma);
136 }
137 else if (_type==SMEARED_SIN_EXP) {
138 asymm= 2.0*nwwerf(z).imag()/tau/4.0*exp(-x*x/2.0/xsigma/xsigma);
139 }
140 }
141 else {
142 if (_type==SMEARED_COS_EXP||_type==MIXED || _type==UNMIXED) {
143 asymm= -2.0*nwwerf(std::conj(z)).real()/tau/4*exp(-x*x/2.0/xsigma/xsigma) +
144 exp(xsigma*xsigma/2 *(1/tau/tau - freq*freq) - x/tau)*(1./tau)*cos(freq*x - freq/tau*xsigma*xsigma);
145 }
146 else if (_type==SMEARED_SIN_EXP) {
147 asymm= +2.0*nwwerf(std::conj(z)).imag()/tau/4*exp(-x*x/2.0/xsigma/xsigma) +
148 exp(xsigma*xsigma/2 *(1/tau/tau - freq*freq) - x/tau)*(1./tau)*sin(freq*x - freq/tau*xsigma*xsigma);
149 }
150 }
151 }
152
153 // Return either MIXED, UNMIXED, or ASYMMETRY function.
154 if (_type==UNMIXED) {
155 double retVal = (expG+asymm)/2.0;
156 if (retVal<0)
157 std::cerr
158 << "Warning in AnalyticConvolution: negative probablity"
159 << std::endl;
160 if (retVal<0)
161 std::cerr
162 << xsigma << ' ' << tau << ' ' << xoffset << ' '
163 << freq << ' '<< argument
164 << std::endl;
165 if (retVal<0)
166 std::cerr << retVal << std::endl;
167 return retVal;
168 }
169 else if (_type==MIXED) {
170 double retVal = (expG-asymm)/2.0;
171 if (retVal<0)
172 std::cerr
173 << "Warning in AnalyticConvolution: negative probablity"
174 << std::endl;
175 if (retVal<0)
176 std::cerr
177 << xsigma << ' ' << tau << ' ' << xoffset << ' '
178 << freq << ' ' << argument
179 << std::endl;
180 if (retVal<0)
181 std::cerr << retVal << std::endl;
182 return retVal;
183 }
184 else if (_type==SMEARED_COS_EXP || _type==SMEARED_SIN_EXP) {
185 return asymm;
186 }
187 else {
188 std::cerr
189 << "Unknown sign parity. State is not allowed"
190 << std::endl;
191 exit(0);
192 return 0.0;
193 }
194
195}
virtual double getValue() const
Definition: Parameter.cc:29
#define exit(x)

Referenced by operator()().

◆ sigma() [1/2]

Parameter & Genfun::AnalyticConvolution::sigma ( )

Definition at line 54 of file AnalyticConvolution.cc.

54 {
55 return _sigma;
56}

◆ sigma() [2/2]

const Parameter & Genfun::AnalyticConvolution::sigma ( ) const

Definition at line 58 of file AnalyticConvolution.cc.

58 {
59 return _sigma;
60}

The documentation for this class was generated from the following files: