Skip to content

Commit

Permalink
Refs #10541 fix intensity sum and zero at profile edge
Browse files Browse the repository at this point in the history
  • Loading branch information
VickieLynch committed Nov 13, 2014
1 parent 4caeae0 commit 25018a3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
8 changes: 6 additions & 2 deletions Code/Mantid/Framework/MDAlgorithms/src/IntegratePeaksMD2.cpp
Expand Up @@ -434,11 +434,15 @@ namespace MDAlgorithms

if (profileFunction.compare("NoFit") == 0)
{
signal = 0.;
for (size_t j = 0; j < numSteps; j++)
{
if (j < peakMin || j > peakMax)
background_total = background_total + wsProfile2D->dataY(i)[j];
else
signal = signal + wsProfile2D->dataY(i)[j];
}
errorSquared = std::fabs(signal);
}
else
{
Expand Down Expand Up @@ -522,7 +526,7 @@ namespace MDAlgorithms
signal = 0.0;
if (integrationOption.compare("Sum") == 0)
{
for (size_t j = 0; j < numSteps; j++) if ( !boost::math::isnan(yy[j]) && !boost::math::isinf(yy[j]))signal+= yy[j];
for (size_t j = peakMin; j <= peakMax; j++) if ( !boost::math::isnan(yy[j]) && !boost::math::isinf(yy[j]))signal+= yy[j];
}
else
{
Expand All @@ -535,7 +539,7 @@ namespace MDAlgorithms
F.function = &Mantid::MDAlgorithms::f_eval2;
F.params = &fun;

gsl_integration_qags (&F, x[0], x[numSteps-1], 0, 1e-7, 1000,
gsl_integration_qags (&F, x[peakMin], x[peakMax], 0, 1e-7, 1000,
w, &signal, &error);

gsl_integration_workspace_free (w);
Expand Down
5 changes: 2 additions & 3 deletions Code/Mantid/Framework/MDEvents/src/MDBox.cpp
Expand Up @@ -4,6 +4,7 @@
#include "MantidMDEvents/MDLeanEvent.h"
#include "MantidKernel/DiskBuffer.h"
#include "MantidMDEvents/MDGridBox.h"
#include <boost/math/special_functions/round.hpp>
#include <cmath>

using namespace Mantid::API;
Expand Down Expand Up @@ -644,9 +645,7 @@ namespace MDEvents
if (out[0] < radius && std::fabs(out[1]) < 0.5*length)
{
// add event to appropriate y channel
size_t xchannel;
if (out[1] < 0) xchannel = static_cast<int>(out[1] / deltaQ - 0.5) + static_cast<int>(numSteps / 2)-1;
else xchannel = static_cast<int>(out[1] / deltaQ + 0.5) + static_cast<int>(numSteps / 2)-1;
size_t xchannel = static_cast<size_t>(std::floor(out[1] / deltaQ)) + numSteps / 2;
if (xchannel < numSteps ) signal_fit[xchannel] += static_cast<signal_t>(it->getSignal());

signal += static_cast<signal_t>(it->getSignal());
Expand Down
7 changes: 2 additions & 5 deletions Code/Mantid/Framework/MDEvents/src/MDGridBox.cpp
Expand Up @@ -9,6 +9,7 @@
#include "MantidMDEvents/MDBox.h"
#include "MantidMDEvents/MDEvent.h"
#include "MantidMDEvents/MDGridBox.h"
#include <boost/math/special_functions/round.hpp>
#include <ostream>
#include "MantidKernel/Strings.h"

Expand Down Expand Up @@ -1436,11 +1437,7 @@ GCC_DIAG_OFF(array-bounds)
coord_t out[nd];
radiusTransform.apply(eventCenter, out);
// add event to appropriate y channel
size_t xchannel;
if (out[1] < 0)
xchannel = static_cast<int>(out[1] / deltaQ - 0.5) + static_cast<int>(numSteps / 2)-1;
else
xchannel = static_cast<int>(out[1] / deltaQ + 0.5) + static_cast<int>(numSteps / 2)-1;
size_t xchannel = static_cast<size_t>(std::floor(out[1] / deltaQ)) + numSteps / 2;

if (xchannel < numSteps )
signal_fit[xchannel] += coordTable[k*nColumns];
Expand Down

0 comments on commit 25018a3

Please sign in to comment.