Skip to content

Commit

Permalink
Refs #9993. Integrating point group extension into PoldiPeakCollection
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Wedel committed Aug 4, 2014
1 parent 044e499 commit 9cc7153
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 0 deletions.
Expand Up @@ -74,6 +74,7 @@ class MANTID_SINQ_DLL PoldiPeak
static PoldiPeak_sptr create(double qValue);
static PoldiPeak_sptr create(UncertainValue qValue, UncertainValue intensity);
static PoldiPeak_sptr create(double qValue, double intensity);
static PoldiPeak_sptr create(MillerIndices hkl, double dValue);
static PoldiPeak_sptr create(MillerIndices hkl, UncertainValue dValue, UncertainValue intensity, UncertainValue fwhmRelative);

static bool greaterThan(const PoldiPeak_sptr &first, const PoldiPeak_sptr &second, UncertainValue (PoldiPeak::*function)() const);
Expand Down
Expand Up @@ -4,6 +4,9 @@
#include "MantidSINQ/DllConfig.h"
#include "MantidSINQ/PoldiUtilities/PoldiPeak.h"
#include "MantidDataObjects/TableWorkspace.h"
#include "MantidGeometry/Crystal/UnitCell.h"
#include "MantidGeometry/Crystal/PointGroup.h"
#include "MantidKernel/V3D.h"
#include "boost/shared_ptr.hpp"

namespace Mantid {
Expand Down Expand Up @@ -43,6 +46,8 @@ class MANTID_SINQ_DLL PoldiPeakCollection
public:
PoldiPeakCollection();
PoldiPeakCollection(DataObjects::TableWorkspace_sptr workspace);
PoldiPeakCollection(const Geometry::UnitCell &unitCell, const Geometry::PointGroup_sptr &pointGroup, double dMin, double dMax);

virtual ~PoldiPeakCollection() {}

size_t peakCount() const;
Expand All @@ -59,6 +64,9 @@ class MANTID_SINQ_DLL PoldiPeakCollection
void constructFromTableWorkspace(DataObjects::TableWorkspace_sptr tableWorkspace);
bool checkColumns(DataObjects::TableWorkspace_sptr tableWorkspace);

std::vector<Kernel::V3D> getUniqueHKLSet(const Geometry::UnitCell &unitCell, const Geometry::PointGroup_sptr &pointGroup, double dMin, double dMax);
void setPeaks(const std::vector<Kernel::V3D> &hkls, const Geometry::UnitCell &unitCell);

std::vector<PoldiPeak_sptr> m_peaks;
};

Expand Down
5 changes: 5 additions & 0 deletions Code/Mantid/Framework/SINQ/src/PoldiUtilities/PoldiPeak.cpp
Expand Up @@ -134,6 +134,11 @@ PoldiPeak_sptr PoldiPeak::create(double qValue, double intensity)
return PoldiPeak::create(UncertainValue(qValue), UncertainValue(intensity));
}

PoldiPeak_sptr PoldiPeak::create(MillerIndices hkl, double dValue)
{
return PoldiPeak_sptr(new PoldiPeak(UncertainValue(dValue), UncertainValue(0.0), UncertainValue(0.0), hkl));
}

PoldiPeak_sptr PoldiPeak::create(MillerIndices hkl, UncertainValue dValue, UncertainValue intensity, UncertainValue fwhmRelative)
{
return PoldiPeak_sptr(new PoldiPeak(dValue, intensity, fwhmRelative, hkl));
Expand Down
Expand Up @@ -12,6 +12,8 @@ namespace Poldi {

using namespace Mantid::API;
using namespace Mantid::DataObjects;
using namespace Mantid::Geometry;
using namespace Mantid::Kernel;

PoldiPeakCollection::PoldiPeakCollection() :
m_peaks()
Expand All @@ -26,6 +28,13 @@ PoldiPeakCollection::PoldiPeakCollection(TableWorkspace_sptr workspace) :
}
}

PoldiPeakCollection::PoldiPeakCollection(const UnitCell &unitCell, const PointGroup_sptr &pointGroup, double dMin, double dMax) :
m_peaks()
{
std::vector<V3D> uniqueHKL = getUniqueHKLSet(unitCell, pointGroup, dMin, dMax);
setPeaks(uniqueHKL, unitCell);
}

size_t PoldiPeakCollection::peakCount() const
{
return m_peaks.size();
Expand Down Expand Up @@ -114,5 +123,42 @@ bool PoldiPeakCollection::checkColumns(TableWorkspace_sptr tableWorkspace)
return columnNames == shouldNames;
}

std::vector<V3D> PoldiPeakCollection::getUniqueHKLSet(const UnitCell &unitCell, const PointGroup_sptr &pointGroup, double dMin, double dMax)
{
std::set<V3D> uniqueHKLs;

int hMax = static_cast<int>(unitCell.a() / dMin);
int kMax = static_cast<int>(unitCell.b() / dMin);
int lMax = static_cast<int>(unitCell.c() / dMin);

for(int h = -hMax; h <= hMax; ++h) {
for(int k = -kMax; k < kMax; ++k) {
for(int l = -lMax; l < lMax; ++l) {
V3D hkl(h, k, l);
double d = unitCell.d(hkl);

if(d <= dMax && d >= dMin) {
V3D uniqueHKL = pointGroup->getReflectionFamily(hkl);

uniqueHKLs.insert(uniqueHKL);
}
}
}
}

return std::vector<V3D>(uniqueHKLs.begin(), uniqueHKLs.end());
}

void PoldiPeakCollection::setPeaks(const std::vector<V3D> &hkls, const UnitCell &unitCell)
{
m_peaks.clear();

for(size_t i = 0; i < hkls.size(); ++i) {
double d = unitCell.d(hkls[i]);

addPeak(PoldiPeak::create(MillerIndices(hkls[i].X(), hkls[i].Y(), hkls[i].Z()), d));
}
}

}
}

0 comments on commit 9cc7153

Please sign in to comment.