40 "An input PeaksWorkspace with an instrument.");
41 std::vector<std::string> propOptions;
44 [](
const auto &group) { return group->getSymbol(); });
46 [](
const auto &group) { return group->getName(); });
48 propOptions.emplace_back(
"222 (Orthorombic)");
49 propOptions.emplace_back(
"mm2 (Orthorombic)");
50 propOptions.emplace_back(
"2mm (Orthorombic)");
51 propOptions.emplace_back(
"m2m (Orthorombic)");
52 propOptions.emplace_back(
"mmm (Orthorombic)");
53 declareProperty(
"PointGroup", propOptions[0], std::make_shared<StringListValidator>(propOptions),
54 "Which point group applies to this crystal?");
56 std::vector<std::string> centeringOptions;
58 centeringOptions.reserve(2 * reflectionConditions.size());
59 std::transform(reflectionConditions.cbegin(), reflectionConditions.cend(), std::back_inserter(centeringOptions),
60 [](
const auto &condition) { return condition->getSymbol(); });
61 std::transform(reflectionConditions.cbegin(), reflectionConditions.cend(), std::back_inserter(centeringOptions),
62 [](
const auto &condition) { return condition->getName(); });
63 declareProperty(
"LatticeCentering", centeringOptions[0], std::make_shared<StringListValidator>(centeringOptions),
64 "Appropriate lattice centering for the peaks.");
67 "Output PeaksWorkspace");
70 "An output table workspace for the statistics of the peaks.");
71 const std::vector<std::string> sortTypes{
"ResolutionShell",
"Bank",
"RunNumber",
"Overall"};
72 declareProperty(
"SortBy", sortTypes[0], std::make_shared<StringListValidator>(sortTypes),
73 "Sort the peaks by resolution shell in d-Spacing(default), "
74 "bank, run number, or only overall statistics.");
75 const std::vector<std::string> equivTypes{
"Mean",
"Median"};
76 declareProperty(
"EquivalentIntensities", equivTypes[0], std::make_shared<StringListValidator>(equivTypes),
77 "Replace intensities by mean(default), "
80 "Removes peaks whose intensity deviates more than "
81 "SigmaCritical from the mean (or median).");
84 "Output Equivalent Intensities");
86 "Use weighted ZScore if true.\n"
87 "If false, standard ZScore (default).");
99 tempWS->copyExperimentInfoFrom(
ws.get());
102 std::vector<std::pair<std::string, bool>> criteria;
103 if (sortType.compare(0, 2,
"Re") == 0)
104 criteria.emplace_back(
"DSpacing",
false);
105 else if (sortType.compare(0, 2,
"Ru") == 0)
106 criteria.emplace_back(
"RunNumber",
true);
107 criteria.emplace_back(
"BankName",
true);
108 criteria.emplace_back(
"h",
true);
109 criteria.emplace_back(
"k",
true);
110 criteria.emplace_back(
"l",
true);
114 std::vector<Peak> peaks =
ws->getPeaks();
116 if (sortType.compare(0, 2,
"Ov") == 0)
119 std::string oldSequence;
120 if (sortType.compare(0, 2,
"Re") == 0) {
121 double dspacing = peaks[0].getDSpacing();
123 oldSequence =
"Inf - 3.0";
124 else if (dspacing > 2.5)
125 oldSequence =
"3.0 - 2.5";
126 else if (dspacing > 2.0)
127 oldSequence =
"2.5 - 2.0";
128 else if (dspacing > 1.5)
129 oldSequence =
"2.0 - 1.5";
130 else if (dspacing > 1.0)
131 oldSequence =
"1.5 - 1.0";
132 else if (dspacing > 0.5)
133 oldSequence =
"1.0 - 0.5";
135 oldSequence =
"0.5 - 0.0";
136 }
else if (sortType.compare(0, 2,
"Ru") == 0)
139 oldSequence = peaks[0].getBankName();
141 for (
int wi = 0; wi <
ws->getNumberPeaks(); wi++) {
144 std::string sequence;
145 if (sortType.compare(0, 2,
"Re") == 0) {
148 sequence =
"Inf - 3.0";
149 else if (dspacing > 2.5)
150 sequence =
"3.0 - 2.5";
151 else if (dspacing > 2.0)
152 sequence =
"2.5 - 2.0";
153 else if (dspacing > 1.5)
154 sequence =
"2.0 - 1.5";
155 else if (dspacing > 1.0)
156 sequence =
"1.5 - 1.0";
157 else if (dspacing > 0.5)
158 sequence =
"1.0 - 0.5";
160 sequence =
"0.5 - 0.0";
161 }
else if (sortType.compare(0, 2,
"Ru") == 0)
166 if (sequence != oldSequence && tempWS->getNumberPeaks() > 0) {
167 if (tempWS->getNumberPeaks() > 1)
171 tempWS->copyExperimentInfoFrom(
ws.get());
172 oldSequence = sequence;
189 std::string equivalentIntensities =
getPropertyValue(
"EquivalentIntensities");
190 double sigmaCritical =
getProperty(
"SigmaCritical");
193 statsAlg->setProperty(
"InputWorkspace",
ws);
194 statsAlg->setPropertyValue(
"OutputWorkspace", wkspName);
195 statsAlg->setPropertyValue(
"StatisticsTable", tableName);
196 statsAlg->setProperty(
"PointGroup", pointGroup);
197 statsAlg->setProperty(
"LatticeCentering", latticeCentering);
198 statsAlg->setProperty(
"RowName", runName);
199 if (runName !=
"Overall")
200 statsAlg->setProperty(
"Append",
true);
201 statsAlg->setPropertyValue(
"EquivalentIntensities", equivalentIntensities);
202 statsAlg->setProperty(
"SigmaCritical", sigmaCritical);
203 statsAlg->setProperty(
"WeightedZScore", weightedZ);
204 statsAlg->executeAsChildAlg();
208 if (runName ==
"Overall")
#define DECLARE_ALGORITHM(classname)
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
std::string getPropertyValue(const std::string &name) const override
Get the value of a property as a string.
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
virtual 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)
Create a Child Algorithm.
A property class for workspaces.
Statistics of a PeaksWorkspace.
std::vector< Mantid::Geometry::PointGroup_sptr > m_pointGroups
Point Groups possible.
DataObjects::PeaksWorkspace_sptr ws
void exec() override
Run the algorithm.
void doSortHKL(const Mantid::API::Workspace_sptr &ws, const std::string &runName)
Runs SortHKL on workspace.
void init() override
Initialise the properties.
int getRunNumber() const override
Return the run number this peak was measured at.
Structure describing a single-crystal peak.
double getDSpacing() const override
Calculate the d-spacing of the peak, in 1/Angstroms
std::string getBankName() const
Find the name of the bank that is the parent of the detector.
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
The concrete, templated class for properties.
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
std::shared_ptr< IPeaksWorkspace > IPeaksWorkspace_sptr
shared pointer to Mantid::API::IPeaksWorkspace
std::shared_ptr< ITableWorkspace > ITableWorkspace_sptr
shared pointer to Mantid::API::ITableWorkspace
std::shared_ptr< Workspace > Workspace_sptr
shared pointer to Mantid::API::Workspace
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
std::shared_ptr< PeaksWorkspace > PeaksWorkspace_sptr
Typedef for a shared pointer to a peaks workspace.
MANTID_GEOMETRY_DLL const ReflectionConditions & getAllReflectionConditions()
MANTID_GEOMETRY_DLL std::vector< PointGroup_sptr > getAllPointGroups()
A namespace containing physical constants that are required by algorithms and unit routines.
std::string to_string(const wide_integer< Bits, Signed > &n)
@ Input
An input workspace.
@ Output
An output workspace.