From 6cae76f1c11da90f28c8fe5bb79cdf8f07a43709 Mon Sep 17 00:00:00 2001 From: Andreas Suter Date: Tue, 21 Feb 2017 11:28:53 +0100 Subject: [PATCH] fixed a little annoying bug in the LF none-analytic integral estimate. --- src/classes/PTheory.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/classes/PTheory.cpp b/src/classes/PTheory.cpp index 3c093b3a..30174ce8 100644 --- a/src/classes/PTheory.cpp +++ b/src/classes/PTheory.cpp @@ -2687,14 +2687,16 @@ void PTheory::CalculateGaussLFIntegral(const Double_t *val) const fLFIntegral.push_back(0.0); // start value of the integral ft = 0.0; - Double_t step = 0.0; + Double_t step = 0.0, lastStep = 1.0, diff = 0.0; do { t += dt; step = 0.5*dt*preFactor*(exp(-0.5*pow(Delta * (t-dt), 2.0))*sin(w0*(t-dt))+ exp(-0.5*pow(Delta * t, 2.0))*sin(w0*t)); + diff = fabs(fabs(step)-fabs(lastStep)); + lastStep = step; ft += step; fLFIntegral.push_back(ft); - } while ((t <= 20.0) && (fabs(step) > 1.0e-10)); + } while ((t <= 20.0) && (diff > 1.0e-10)); } //-------------------------------------------------------------------------- @@ -2760,13 +2762,15 @@ void PTheory::CalculateLorentzLFIntegral(const Double_t *val) const ft += 0.5*dt*preFactor*(1.0+sin(w0*t)/(w0*t)*exp(-a*t)); fLFIntegral.push_back(ft); // calculate all the other integral bin values - Double_t step = 0.0; + Double_t step = 0.0, lastStep = 1.0, diff = 0.0; do { t += dt; step = 0.5*dt*preFactor*(sin(w0*(t-dt))/(w0*(t-dt))*exp(-a*(t-dt))+sin(w0*t)/(w0*t)*exp(-a*t)); + diff = fabs(fabs(step)-fabs(lastStep)); + lastStep = step; ft += step; fLFIntegral.push_back(ft); - } while ((t <= 20.0) && (fabs(step) > 1.0e-10)); + } while ((t <= 20.0) && (diff > 1.0e-10)); }