Skip to content

Commit

Permalink
Minor refactoring of method signatures to avoid copies.
Browse files Browse the repository at this point in the history
Refs #8369
  • Loading branch information
martyngigg committed Sep 24, 2014
1 parent d8842ed commit c66397b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
Expand Up @@ -4,9 +4,7 @@
#include "MantidAPI/Algorithm.h"
#include "MantidAPI/IMDEventWorkspace.h"
#include "MantidDataObjects/PeaksWorkspace.h"
#include "MantidKernel/System.h"
#include "MantidMDEvents/MDEventWorkspace.h"
#include "MantidAPI/CompositeFunction.h"

namespace Mantid
{
Expand All @@ -25,12 +23,12 @@ namespace MDAlgorithms
~IntegratePeaksMD2();

/// Algorithm's name for identification
virtual const std::string name() const { return "IntegratePeaksMD";};
virtual const std::string name() const { return "IntegratePeaksMD";}
///Summary of algorithms purpose
virtual const std::string summary() const {return "Integrate single-crystal peaks in reciprocal space, for MDEventWorkspaces.";}

/// Algorithm's version for identification
virtual int version() const { return 2;};
virtual int version() const { return 2;}
/// Algorithm's category for identification
virtual const std::string category() const { return "MDAlgorithms";}

Expand All @@ -47,15 +45,14 @@ namespace MDAlgorithms
Mantid::API::IMDEventWorkspace_sptr inWS;

/// Calculate if this Q is on a detector
bool detectorQ(Mantid::Kernel::V3D QLabFrame, double PeakRadius);
bool detectorQ(const Kernel::V3D & QLabFrame, double PeakRadius);

/// Instrument reference
Geometry::Instrument_const_sptr inst;

/// Check if peaks overlap
void checkOverlap(int i,
Mantid::DataObjects::PeaksWorkspace_sptr peakWS, int CoordinatesToUse, double radius);

void checkOverlap(int i, DataObjects::PeaksWorkspace & peakWS,
int CoordinatesToUse, double radius);
};


Expand Down
16 changes: 8 additions & 8 deletions Code/Mantid/Framework/MDAlgorithms/src/IntegratePeaksMD2.cpp
Expand Up @@ -533,8 +533,8 @@ namespace MDAlgorithms
}
}
}
checkOverlap (i, peakWS, CoordinatesToUse,
2.0 * std::max(PeakRadiusVector[i],BackgroundOuterRadiusVector[i]));
checkOverlap (i, *peakWS, CoordinatesToUse,
2.0 * std::max(PeakRadiusVector[i],BackgroundOuterRadiusVector[i]));
// Save it back in the peak object.
if (signal != 0. || replaceIntensity)
{
Expand Down Expand Up @@ -583,7 +583,7 @@ namespace MDAlgorithms
* @param QLabFrame: The Peak center.
* @param r: Peak radius.
*/
bool IntegratePeaksMD2::detectorQ(Mantid::Kernel::V3D QLabFrame, double r)
bool IntegratePeaksMD2::detectorQ(const V3D &QLabFrame, double r)
{
// Define a "hit" if > 75% of attempts make it to a detector
const int nAngles(8);
Expand Down Expand Up @@ -614,22 +614,22 @@ namespace MDAlgorithms
}
return static_cast<double>(nhits)/(dAngles*dAngles) > 0.75;
}
void IntegratePeaksMD2::checkOverlap(int i,
Mantid::DataObjects::PeaksWorkspace_sptr peakWS, int CoordinatesToUse, double radius)
void IntegratePeaksMD2::checkOverlap(int i, DataObjects::PeaksWorkspace &peakWS,
int CoordinatesToUse, double radius)
{
// Get a direct ref to that peak.
IPeak & p1 = peakWS->getPeak(i);
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)
for (int j=i+1; j < peakWS.getNumberPeaks(); ++j)
{
// Get a direct ref to rest of peaks peak.
IPeak & p2 = peakWS->getPeak(j);
IPeak & p2 = peakWS.getPeak(j);
V3D pos2;
if (CoordinatesToUse == 1) //"Q (lab frame)"
pos2 = p2.getQLabFrame();
Expand Down

0 comments on commit c66397b

Please sign in to comment.