Mantid
Loading...
Searching...
No Matches
IntegrateEllipsoids.cpp
Go to the documentation of this file.
12
13#include <boost/algorithm/string.hpp>
14
15using namespace Mantid::API;
16using namespace Mantid::HistogramData;
17using namespace Mantid::Kernel;
18using namespace Mantid::Geometry;
19using namespace Mantid::DataObjects;
20
21namespace Mantid::MDAlgorithms {
22
23DECLARE_ALGORITHM(IntegrateEllipsoids)
24//---------------------------------------------------------------------
26const std::string IntegrateEllipsoids::name() const { return "IntegrateEllipsoids"; }
27
29int IntegrateEllipsoids::version() const { return 3; }
30
32const std::string IntegrateEllipsoids::category() const { return "Crystal\\Integration"; }
33//---------------------------------------------------------------------
34
38}
39
41 int indexCount = 0;
42 const int numPeaks = peakWorkspace->getNumberPeaks();
43 for (int i = 0; i < numPeaks; ++i) {
44 const auto peak = peakWorkspace->getPeak(i);
45 if (peak.getIntHKL().norm2() > 0)
46 indexCount += 1;
47 }
48 return indexCount;
49}
50
52 int indexCount = 0;
53 const int numPeaks = peakWorkspace->getNumberPeaks();
54 for (int i = 0; i < numPeaks; ++i) {
55 const auto peak = peakWorkspace->getPeak(i);
56 if (peak.getIntMNP().norm2() > 0)
57 indexCount += 1;
58 }
59 return indexCount;
60}
61
63 const bool isIntegrateInHKL = getProperty("IntegrateInHKL");
64 const bool isGetUBFromPeaksWorkspace = getProperty("GetUBFromPeaksWorkspace");
65 const bool shareBackground = getProperty("ShareBackground");
66
67 const PeaksWorkspace_sptr peakWorkspace = getProperty("PeaksWorkspace");
68
69 const int indexCount = getIndexCount(peakWorkspace);
70 const int satelliteIndexCount = getSatelliteIndexCount(peakWorkspace);
71
73
74 // detect which algo to run
75 if (isIntegrateInHKL || isGetUBFromPeaksWorkspace ||
76 (indexCount > 0 && satelliteIndexCount == 0 && !shareBackground)) {
77 // v1
78 alg = std::dynamic_pointer_cast<Algorithm>(createChildAlgorithm("IntegrateEllipsoids", -1., -1., true, 1));
79 } else {
80 // v2
81 alg = std::dynamic_pointer_cast<Algorithm>(createChildAlgorithm("IntegrateEllipsoids", -1., -1., true, 2));
82 }
83
84 // forward properties to algo
85 alg->copyPropertiesFrom(*this);
86 // run correct algo and return results
87 alg->execute();
88 if (!alg->isExecuted())
89 throw std::runtime_error("IntegrateEllipsoids Algorithm has not executed successfully");
90
91 PeaksWorkspace_sptr outputWorkspace = alg->getProperty("OutputWorkspace");
92 setProperty("OutputWorkspace", outputWorkspace);
93}
94} // namespace Mantid::MDAlgorithms
#define DECLARE_ALGORITHM(classname)
Definition: Algorithm.h:576
std::shared_ptr< Algorithm > createChildAlgorithm(const std::string &name, const double startProgress=-1., const double endProgress=-1., const bool enableLogging=true, const int &version=-1) override
Create a Child Algorithm.
Kernel::IPropertyManager::TypedValue getProperty(const std::string &name) const override
Get the property held by this object.
const std::string category() const override
Algorithm's category for identification.
int version() const override
Algorithm's version for identification.
std::shared_ptr< Algorithm > Algorithm_sptr
Typedef for a shared pointer to an Algorithm.
Definition: Algorithm.h:61
std::shared_ptr< PeaksWorkspace > PeaksWorkspace_sptr
Typedef for a shared pointer to a peaks workspace.
int getSatelliteIndexCount(PeaksWorkspace_sptr peakWorkspace)
int getIndexCount(PeaksWorkspace_sptr peakWorkspace)
STL namespace.