3#include "CLHEP/GenericFunctions/PuncturedSmearedExp.hh"
12 _lifetime ("Lifetime", 1.0, 0.0),
13 _sigma ("
Sigma", 1.0, 0.0)
19 _lifetime (right._lifetime),
20 _sigma (right._sigma),
21 _punctures (right._punctures)
26 std::ostringstream mn, mx;
27 mn <<
"Min_" << _punctures.size()/2;
28 mx <<
"Max_" << _punctures.size()/2;
29 _punctures.push_back(
Parameter(mn.str(), xmin, 0.0, 10.0));
30 _punctures.push_back(
Parameter(mx.str(), xmax, 0.0, 10.0));
35 return _punctures[2*i];
39 return _punctures[2*i];
44 return _punctures[2*i+1];
49 return _punctures[2*i+1];
75 static const double sqrtTwo = sqrt(2.0);
82 std::vector<double> punctures(_punctures.size());
83 for (
size_t i=0;i<_punctures.size();i++) punctures[i]=_punctures[i].getValue();
92 for (
size_t i=0;i<punctures.size()/2;i++) {
93 std::sort(punctures.begin()+2*i, punctures.begin()+2*i+2);
94 double min1=punctures[2*i];
95 double max1=punctures[2*i+1];
96 for (
size_t j=i+1;j<punctures.size()/2;j++) {
97 std::sort(punctures.begin()+2*j, punctures.begin()+2*j+2);
98 double min2=punctures[2*j];
99 double max2=punctures[2*j+1];
100 if ((min2>min1 && max1>min2) || (min1>min2 && max2<min1)) {
101 punctures[2*i] =std::min(min1,min2);
102 punctures[2*i+1]=std::max(max1,max2);
103 std::vector<double>::iterator t0=punctures.begin()+2*j, t1=t0+2;
104 punctures.erase(t0,t1);
113 double expG=0,norm=0;
114 for (
size_t i=0;i<punctures.size()/2;i++) {
116 double a = punctures[2*i];
117 double b = punctures[2*i+1];
119 double alpha = (a/xsigma + xsigma/tau)/sqrtTwo;
120 double beta = (b/xsigma + xsigma/tau)/sqrtTwo;
121 double delta = 1/sqrtTwo/xsigma;
124 norm += 2*tau*exp(1/(4*delta*delta*tau*tau))*(exp(-alpha/(delta*tau)) - exp(-beta/(delta*tau)));
126 expG += ((erfc(alpha-delta*x) - erfc(beta-delta*x))*exp(-x/tau) );
132 if (norm==0)
return norm;
137double PuncturedSmearedExp::erfc(
double x)
const {
141 z = (x < 0) ? -x : x;
143 ans = t*exp(-z*z-1.26551223+t*(1.00002368+t*(0.37409196+t*(0.09678418+
144 t*(-0.18628806+t*(0.27886807+t*(-1.13520398+t*(1.48851587+
145 t*(-0.82215223+t*0.17087277 ))) ))) )));
146 if ( x < 0 ) ans = 2.0 - ans;
150double PuncturedSmearedExp::pow(
double x,
int n)
const {
152 for(
int i=0;i<n;i++){
#define FUNCTION_OBJECT_IMP(classname)
virtual double getValue() const
void puncture(double min, double max)
Parameter & min(unsigned int i)
virtual ~PuncturedSmearedExp()
Parameter & max(unsigned int i)
virtual double operator()(double argument) const override