diff --git a/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegratePeaksMD2.h b/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegratePeaksMD2.h index f78b1555a8f2..74a78a88ac97 100644 --- a/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegratePeaksMD2.h +++ b/Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegratePeaksMD2.h @@ -51,6 +51,10 @@ namespace MDAlgorithms /// Instrument reference Geometry::Instrument_const_sptr inst; + /// Check if peaks overlap + void checkOverlap(int i, + Mantid::DataObjects::PeaksWorkspace_sptr peakWS, int CoordinatesToUse, double radius); + }; diff --git a/Code/Mantid/Framework/MDAlgorithms/src/IntegratePeaksMD2.cpp b/Code/Mantid/Framework/MDAlgorithms/src/IntegratePeaksMD2.cpp index 6d2968fba409..586bb7287ffd 100644 --- a/Code/Mantid/Framework/MDAlgorithms/src/IntegratePeaksMD2.cpp +++ b/Code/Mantid/Framework/MDAlgorithms/src/IntegratePeaksMD2.cpp @@ -593,6 +593,8 @@ namespace MDAlgorithms } } } + checkOverlap (i, peakWS, CoordinatesToUse, + 2.0 * std::max(PeakRadiusVector[i],BackgroundOuterRadiusVector[i])); // Save it back in the peak object. if (signal != 0. || replaceIntensity) { @@ -676,7 +678,36 @@ namespace MDAlgorithms } return in; } - + void IntegratePeaksMD2::checkOverlap(int i, + Mantid::DataObjects::PeaksWorkspace_sptr peakWS, int CoordinatesToUse, double radius) + { + // Get a direct ref to that peak. + IPeak & p1 = peakWS->getPeak(i); + V3D pos1; + if (CoordinatesToUse == 1) //"Q (lab frame)" + pos1 = p1.getQLabFrame(); + else if (CoordinatesToUse == 2) //"Q (sample frame)" + pos1 = p1.getQSampleFrame(); + else if (CoordinatesToUse == 3) //"HKL" + pos1 = p1.getHKL(); + for (int j=i+1; j < peakWS->getNumberPeaks(); ++j) + { + // Get a direct ref to rest of peaks peak. + IPeak & p2 = peakWS->getPeak(j); + V3D pos2; + if (CoordinatesToUse == 1) //"Q (lab frame)" + pos2 = p2.getQLabFrame(); + else if (CoordinatesToUse == 2) //"Q (sample frame)" + pos2 = p2.getQSampleFrame(); + else if (CoordinatesToUse == 3) //"HKL" + pos2 = p2.getHKL(); + if (pos1.distance(pos2) < radius) + { + g_log.warning() << " Warning: Peak integration spheres for peaks " + << i << " and " << j <<" overlap. Distance between peaks is "<< pos1.distance(pos2)<