Commit 6b71c9fb authored by Lynch, Vickie's avatar Lynch, Vickie
Browse files

Refs #21752 clang-format

parent 5d9c9a3e
...@@ -76,8 +76,7 @@ int LoadIsawPeaks::confidence(Kernel::FileDescriptor &descriptor) const { ...@@ -76,8 +76,7 @@ int LoadIsawPeaks::confidence(Kernel::FileDescriptor &descriptor) const {
getWord(in, false); getWord(in, false);
readToEndOfLine(in, true); readToEndOfLine(in, true);
confidence = 95; confidence = 95;
} } catch (std::exception &) {
catch (std::exception &) {
} }
return confidence; return confidence;
...@@ -87,11 +86,11 @@ int LoadIsawPeaks::confidence(Kernel::FileDescriptor &descriptor) const { ...@@ -87,11 +86,11 @@ int LoadIsawPeaks::confidence(Kernel::FileDescriptor &descriptor) const {
/** Initialize the algorithm's properties. /** Initialize the algorithm's properties.
*/ */
void LoadIsawPeaks::init() { void LoadIsawPeaks::init() {
const std::vector<std::string> exts{ ".peaks", ".integrate" }; const std::vector<std::string> exts{".peaks", ".integrate"};
declareProperty(Kernel::make_unique<FileProperty>("Filename", "", declareProperty(Kernel::make_unique<FileProperty>("Filename", "",
FileProperty::Load, exts), FileProperty::Load, exts),
"Path to an ISAW-style .peaks filename."); "Path to an ISAW-style .peaks filename.");
declareProperty(make_unique<WorkspaceProperty<Workspace> >( declareProperty(make_unique<WorkspaceProperty<Workspace>>(
"OutputWorkspace", "", Direction::Output), "OutputWorkspace", "", Direction::Output),
"Name of the output workspace."); "Name of the output workspace.");
} }
...@@ -237,8 +236,7 @@ std::string LoadIsawPeaks::readHeader(PeaksWorkspace_sptr outWS, ...@@ -237,8 +236,7 @@ std::string LoadIsawPeaks::readHeader(PeaksWorkspace_sptr outWS,
if (!alg->execute()) if (!alg->execute())
throw std::runtime_error( throw std::runtime_error(
"MaskDetectors Child Algorithm has not executed successfully"); "MaskDetectors Child Algorithm has not executed successfully");
} } catch (...) {
catch (...) {
g_log.error("Can't execute MaskBTP algorithm"); g_log.error("Can't execute MaskBTP algorithm");
} }
} }
...@@ -513,8 +511,7 @@ void LoadIsawPeaks::appendFile(PeaksWorkspace_sptr outWS, ...@@ -513,8 +511,7 @@ void LoadIsawPeaks::appendFile(PeaksWorkspace_sptr outWS,
peak.setWavelength(wl.singleFromTOF(tof)); peak.setWavelength(wl.singleFromTOF(tof));
// Add the peak to workspace // Add the peak to workspace
outWS->addPeak(peak); outWS->addPeak(peak);
} } catch (std::runtime_error &e) {
catch (std::runtime_error &e) {
g_log.error() << "Error reading peak SEQN " << seqNum << " : " << e.what() g_log.error() << "Error reading peak SEQN " << seqNum << " : " << e.what()
<< '\n'; << '\n';
throw std::runtime_error("Corrupted input file. "); throw std::runtime_error("Corrupted input file. ");
......
...@@ -128,8 +128,8 @@ UniqueReflectionCollection::UniqueReflectionCollection( ...@@ -128,8 +128,8 @@ UniqueReflectionCollection::UniqueReflectionCollection(
/// Assigns the supplied peaks to the proper UniqueReflection. Peaks for which /// Assigns the supplied peaks to the proper UniqueReflection. Peaks for which
/// the reflection family can not be found are ignored. /// the reflection family can not be found are ignored.
void void UniqueReflectionCollection::addObservations(
UniqueReflectionCollection::addObservations(const std::vector<Peak> &peaks) { const std::vector<Peak> &peaks) {
for (auto const &peak : peaks) { for (auto const &peak : peaks) {
V3D hkl = peak.getHKL(); V3D hkl = peak.getHKL();
hkl.round(); hkl.round();
...@@ -257,8 +257,8 @@ void PeaksStatistics::calculatePeaksStatistics( ...@@ -257,8 +257,8 @@ void PeaksStatistics::calculatePeaksStatistics(
double sumOfDeviationsFromMean = double sumOfDeviationsFromMean =
std::accumulate(intensities.begin(), intensities.end(), 0.0, std::accumulate(intensities.begin(), intensities.end(), 0.0,
[meanIntensity](double sum, double intensity) { [meanIntensity](double sum, double intensity) {
return sum + fabs(intensity - meanIntensity); return sum + fabs(intensity - meanIntensity);
}); });
// Accumulate into total sum for numerator of RMerge // Accumulate into total sum for numerator of RMerge
rMergeNumerator += sumOfDeviationsFromMean; rMergeNumerator += sumOfDeviationsFromMean;
...@@ -311,9 +311,9 @@ void PeaksStatistics::calculatePeaksStatistics( ...@@ -311,9 +311,9 @@ void PeaksStatistics::calculatePeaksStatistics(
/// Returns the sum of all I/sigma-ratios defined by the two vectors using /// Returns the sum of all I/sigma-ratios defined by the two vectors using
/// std::inner_product. /// std::inner_product.
double PeaksStatistics::getIOverSigmaSum(const std::vector<double> &sigmas, double PeaksStatistics::getIOverSigmaSum(
const std::vector<double> &intensities) const std::vector<double> &sigmas,
const { const std::vector<double> &intensities) const {
return std::inner_product(intensities.begin(), intensities.end(), return std::inner_product(intensities.begin(), intensities.end(),
sigmas.begin(), 0.0, std::plus<double>(), sigmas.begin(), 0.0, std::plus<double>(),
std::divides<double>()); std::divides<double>());
......
...@@ -33,11 +33,11 @@ DECLARE_ALGORITHM(SaveHKL) ...@@ -33,11 +33,11 @@ DECLARE_ALGORITHM(SaveHKL)
/** Initialize the algorithm's properties. /** Initialize the algorithm's properties.
*/ */
void SaveHKL::init() { void SaveHKL::init() {
declareProperty(make_unique<WorkspaceProperty<PeaksWorkspace> >( declareProperty(make_unique<WorkspaceProperty<PeaksWorkspace>>(
"InputWorkspace", "", Direction::Input), "InputWorkspace", "", Direction::Input),
"An input PeaksWorkspace."); "An input PeaksWorkspace.");
auto mustBePositive = boost::make_shared<BoundedValidator<double> >(); auto mustBePositive = boost::make_shared<BoundedValidator<double>>();
mustBePositive->setLower(0.0); mustBePositive->setLower(0.0);
declareProperty("ScalePeaks", 1.0, mustBePositive, declareProperty("ScalePeaks", 1.0, mustBePositive,
"Multiply FSQ and sig(FSQ) by scaleFactor"); "Multiply FSQ and sig(FSQ) by scaleFactor");
...@@ -69,7 +69,7 @@ void SaveHKL::init() { ...@@ -69,7 +69,7 @@ void SaveHKL::init() {
make_unique<FileProperty>("Filename", "", FileProperty::Save, ".hkl"), make_unique<FileProperty>("Filename", "", FileProperty::Save, ".hkl"),
"Path to an hkl file to save."); "Path to an hkl file to save.");
std::vector<std::string> histoTypes{ "Bank", "RunNumber", "" }; std::vector<std::string> histoTypes{"Bank", "RunNumber", ""};
declareProperty("SortBy", histoTypes[2], declareProperty("SortBy", histoTypes[2],
boost::make_shared<StringListValidator>(histoTypes), boost::make_shared<StringListValidator>(histoTypes),
"Sort the histograms by bank, run number or both (default)."); "Sort the histograms by bank, run number or both (default).");
...@@ -78,7 +78,7 @@ void SaveHKL::init() { ...@@ -78,7 +78,7 @@ void SaveHKL::init() {
declareProperty("WidthBorder", EMPTY_INT(), "Width of border of detectors"); declareProperty("WidthBorder", EMPTY_INT(), "Width of border of detectors");
declareProperty("MinIntensity", EMPTY_DBL(), mustBePositive, declareProperty("MinIntensity", EMPTY_DBL(), mustBePositive,
"The minimum Intensity"); "The minimum Intensity");
declareProperty(make_unique<WorkspaceProperty<PeaksWorkspace> >( declareProperty(make_unique<WorkspaceProperty<PeaksWorkspace>>(
"OutputWorkspace", "SaveHKLOutput", Direction::Output), "OutputWorkspace", "SaveHKLOutput", Direction::Output),
"Output PeaksWorkspace"); "Output PeaksWorkspace");
declareProperty( declareProperty(
...@@ -88,7 +88,7 @@ void SaveHKL::init() { ...@@ -88,7 +88,7 @@ void SaveHKL::init() {
"DirectionCosines", false, "DirectionCosines", false,
"Extra columns (22 total) in file if true for direction cosines.\n" "Extra columns (22 total) in file if true for direction cosines.\n"
"If false, original 14 columns (default)."); "If false, original 14 columns (default).");
const std::vector<std::string> exts{ ".mat", ".ub", ".txt" }; const std::vector<std::string> exts{".mat", ".ub", ".txt"};
declareProperty(Kernel::make_unique<FileProperty>( declareProperty(Kernel::make_unique<FileProperty>(
"UBFilename", "", FileProperty::OptionalLoad, exts), "UBFilename", "", FileProperty::OptionalLoad, exts),
"Path to an ISAW-style UB matrix text file only needed for " "Path to an ISAW-style UB matrix text file only needed for "
...@@ -185,7 +185,7 @@ void SaveHKL::exec() { ...@@ -185,7 +185,7 @@ void SaveHKL::exec() {
std::string bankPart = "?"; std::string bankPart = "?";
// We must sort the peaks first by run, then bank #, and save the list of // We must sort the peaks first by run, then bank #, and save the list of
// workspace indices of it // workspace indices of it
typedef std::map<int, std::vector<size_t> > bankMap_t; typedef std::map<int, std::vector<size_t>> bankMap_t;
typedef std::map<int, bankMap_t> runMap_t; typedef std::map<int, bankMap_t> runMap_t;
std::set<int> uniqueBanks; std::set<int> uniqueBanks;
std::set<int> uniqueRuns; std::set<int> uniqueRuns;
...@@ -221,8 +221,8 @@ void SaveHKL::exec() { ...@@ -221,8 +221,8 @@ void SaveHKL::exec() {
} }
bool correctPeaks = getProperty("ApplyAnvredCorrections"); bool correctPeaks = getProperty("ApplyAnvredCorrections");
std::vector<std::vector<double> > spectra; std::vector<std::vector<double>> spectra;
std::vector<std::vector<double> > time; std::vector<std::vector<double>> time;
int iSpec = 0; int iSpec = 0;
m_smu = getProperty("LinearScatteringCoef"); // in 1/cm m_smu = getProperty("LinearScatteringCoef"); // in 1/cm
m_amu = getProperty("LinearAbsorptionCoef"); // in 1/cm m_amu = getProperty("LinearAbsorptionCoef"); // in 1/cm
...@@ -688,8 +688,8 @@ double SaveHKL::absor_sphere(double &twoth, double &wl, double &tbar) { ...@@ -688,8 +688,8 @@ double SaveHKL::absor_sphere(double &twoth, double &wl, double &tbar) {
} }
double SaveHKL::spectrumCalc(double TOF, int iSpec, double SaveHKL::spectrumCalc(double TOF, int iSpec,
std::vector<std::vector<double> > time, std::vector<std::vector<double>> time,
std::vector<std::vector<double> > spectra, std::vector<std::vector<double>> spectra,
size_t id) { size_t id) {
double spect = 0; double spect = 0;
if (iSpec == 1) { if (iSpec == 1) {
...@@ -717,9 +717,9 @@ double SaveHKL::spectrumCalc(double TOF, int iSpec, ...@@ -717,9 +717,9 @@ double SaveHKL::spectrumCalc(double TOF, int iSpec,
for (i = 1; i < spectra[id].size(); ++i) for (i = 1; i < spectra[id].size(); ++i)
if (TOF < time[id][i]) if (TOF < time[id][i])
break; break;
spect = spectra[id][i - 1] + (TOF - time[id][i - 1]) / spect = spectra[id][i - 1] +
(time[id][i] - time[id][i - 1]) * (TOF - time[id][i - 1]) / (time[id][i] - time[id][i - 1]) *
(spectra[id][i] - spectra[id][i - 1]); (spectra[id][i] - spectra[id][i - 1]);
} }
return spect; return spect;
......
...@@ -27,7 +27,7 @@ DECLARE_ALGORITHM(SaveIsawPeaks) ...@@ -27,7 +27,7 @@ DECLARE_ALGORITHM(SaveIsawPeaks)
/** Initialize the algorithm's properties. /** Initialize the algorithm's properties.
*/ */
void SaveIsawPeaks::init() { void SaveIsawPeaks::init() {
declareProperty(make_unique<WorkspaceProperty<PeaksWorkspace> >( declareProperty(make_unique<WorkspaceProperty<PeaksWorkspace>>(
"InputWorkspace", "", Direction::Input, "InputWorkspace", "", Direction::Input,
boost::make_shared<InstrumentValidator>()), boost::make_shared<InstrumentValidator>()),
"An input PeaksWorkspace with an instrument."); "An input PeaksWorkspace with an instrument.");
...@@ -35,13 +35,13 @@ void SaveIsawPeaks::init() { ...@@ -35,13 +35,13 @@ void SaveIsawPeaks::init() {
declareProperty("AppendFile", false, "Append to file if true.\n" declareProperty("AppendFile", false, "Append to file if true.\n"
"If false, new file (default)."); "If false, new file (default).");
const std::vector<std::string> exts{ ".peaks", ".integrate" }; const std::vector<std::string> exts{".peaks", ".integrate"};
declareProperty(Kernel::make_unique<FileProperty>("Filename", "", declareProperty(Kernel::make_unique<FileProperty>("Filename", "",
FileProperty::Save, exts), FileProperty::Save, exts),
"Path to an ISAW-style peaks or integrate file to save."); "Path to an ISAW-style peaks or integrate file to save.");
declareProperty( declareProperty(
make_unique<WorkspaceProperty<Workspace2D> >( make_unique<WorkspaceProperty<Workspace2D>>(
"ProfileWorkspace", "", Direction::Input, PropertyMode::Optional), "ProfileWorkspace", "", Direction::Input, PropertyMode::Optional),
"An optional Workspace2D of profiles from integrating cylinder."); "An optional Workspace2D of profiles from integrating cylinder.");
} }
...@@ -62,9 +62,9 @@ void SaveIsawPeaks::exec() { ...@@ -62,9 +62,9 @@ void SaveIsawPeaks::exec() {
// We must sort the peaks first by run, then bank #, and save the list of // We must sort the peaks first by run, then bank #, and save the list of
// workspace indices of it // workspace indices of it
typedef std::map<int, std::vector<size_t> > bankMap_t; typedef std::map<int, std::vector<size_t>> bankMap_t;
typedef std::map<int, bankMap_t> runMap_t; typedef std::map<int, bankMap_t> runMap_t;
std::set<int, std::less<int> > uniqueBanks; std::set<int, std::less<int>> uniqueBanks;
if (!inst) if (!inst)
throw std::runtime_error( throw std::runtime_error(
"No instrument in the Workspace. Cannot save DetCal file."); "No instrument in the Workspace. Cannot save DetCal file.");
......
...@@ -38,7 +38,7 @@ SortHKL::SortHKL() { ...@@ -38,7 +38,7 @@ SortHKL::SortHKL() {
SortHKL::~SortHKL() = default; SortHKL::~SortHKL() = default;
void SortHKL::init() { void SortHKL::init() {
declareProperty(make_unique<WorkspaceProperty<PeaksWorkspace> >( declareProperty(make_unique<WorkspaceProperty<PeaksWorkspace>>(
"InputWorkspace", "", Direction::Input), "InputWorkspace", "", Direction::Input),
"An input PeaksWorkspace with an instrument."); "An input PeaksWorkspace with an instrument.");
...@@ -60,31 +60,31 @@ void SortHKL::init() { ...@@ -60,31 +60,31 @@ void SortHKL::init() {
boost::make_shared<StringListValidator>(centeringOptions), boost::make_shared<StringListValidator>(centeringOptions),
"Appropriate lattice centering for the peaks."); "Appropriate lattice centering for the peaks.");
declareProperty(make_unique<WorkspaceProperty<PeaksWorkspace> >( declareProperty(make_unique<WorkspaceProperty<PeaksWorkspace>>(
"OutputWorkspace", "", Direction::Output), "OutputWorkspace", "", Direction::Output),
"Output PeaksWorkspace"); "Output PeaksWorkspace");
declareProperty("OutputChi2", 0.0, "Chi-square is available as output", declareProperty("OutputChi2", 0.0, "Chi-square is available as output",
Direction::Output); Direction::Output);
declareProperty(make_unique<WorkspaceProperty<ITableWorkspace> >( declareProperty(make_unique<WorkspaceProperty<ITableWorkspace>>(
"StatisticsTable", "StatisticsTable", Direction::Output), "StatisticsTable", "StatisticsTable", Direction::Output),
"An output table workspace for the statistics of the peaks."); "An output table workspace for the statistics of the peaks.");
declareProperty(make_unique<PropertyWithValue<std::string> >( declareProperty(make_unique<PropertyWithValue<std::string>>(
"RowName", "Overall", Direction::Input), "RowName", "Overall", Direction::Input),
"name of row"); "name of row");
declareProperty("Append", false, declareProperty("Append", false,
"Append to output table workspace if true.\n" "Append to output table workspace if true.\n"
"If false, new output table workspace (default)."); "If false, new output table workspace (default).");
std::vector<std::string> equivTypes{ "Mean", "Median" }; std::vector<std::string> equivTypes{"Mean", "Median"};
declareProperty("EquivalentIntensities", equivTypes[0], declareProperty("EquivalentIntensities", equivTypes[0],
boost::make_shared<StringListValidator>(equivTypes), boost::make_shared<StringListValidator>(equivTypes),
"Replace intensities by mean(default), " "Replace intensities by mean(default), "
"or median."); "or median.");
declareProperty(Kernel::make_unique<PropertyWithValue<double> >( declareProperty(Kernel::make_unique<PropertyWithValue<double>>(
"SigmaCritical", 3.0, Direction::Input), "SigmaCritical", 3.0, Direction::Input),
"Removes peaks whose intensity deviates more than " "Removes peaks whose intensity deviates more than "
"SigmaCritical from the mean (or median)."); "SigmaCritical from the mean (or median).");
declareProperty( declareProperty(
make_unique<WorkspaceProperty<MatrixWorkspace> >( make_unique<WorkspaceProperty<MatrixWorkspace>>(
"EquivalentsWorkspace", "EquivalentIntensities", Direction::Output), "EquivalentsWorkspace", "EquivalentIntensities", Direction::Output),
"Output Equivalent Intensities"); "Output Equivalent Intensities");
} }
...@@ -230,9 +230,10 @@ SortHKL::getNonZeroPeaks(const std::vector<Peak> &inputPeaks) const { ...@@ -230,9 +230,10 @@ SortHKL::getNonZeroPeaks(const std::vector<Peak> &inputPeaks) const {
std::remove_copy_if(inputPeaks.begin(), inputPeaks.end(), std::remove_copy_if(inputPeaks.begin(), inputPeaks.end(),
std::back_inserter(peaks), [](const Peak &peak) { std::back_inserter(peaks), [](const Peak &peak) {
return peak.getIntensity() <= 0.0 || peak.getSigmaIntensity() <= 0.0 || return peak.getIntensity() <= 0.0 ||
peak.getHKL() == V3D(0, 0, 0); peak.getSigmaIntensity() <= 0.0 ||
}); peak.getHKL() == V3D(0, 0, 0);
});
return peaks; return peaks;
} }
...@@ -331,9 +332,9 @@ SortHKL::getStatisticsTable(const std::string &name) const { ...@@ -331,9 +332,9 @@ SortHKL::getStatisticsTable(const std::string &name) const {
/// Inserts statistics the supplied PeaksStatistics-objects into the supplied /// Inserts statistics the supplied PeaksStatistics-objects into the supplied
/// TableWorkspace. /// TableWorkspace.
void void SortHKL::insertStatisticsIntoTable(
SortHKL::insertStatisticsIntoTable(const ITableWorkspace_sptr &table, const ITableWorkspace_sptr &table,
const PeaksStatistics &statistics) const { const PeaksStatistics &statistics) const {
if (!table) { if (!table) {
throw std::runtime_error("Can't store statistics into Null-table."); throw std::runtime_error("Can't store statistics into Null-table.");
} }
...@@ -367,9 +368,8 @@ PeaksWorkspace_sptr SortHKL::getOutputPeaksWorkspace( ...@@ -367,9 +368,8 @@ PeaksWorkspace_sptr SortHKL::getOutputPeaksWorkspace(
/// Sorts the peaks in the workspace by H, K and L. /// Sorts the peaks in the workspace by H, K and L.
void SortHKL::sortOutputPeaksByHKL(IPeaksWorkspace_sptr outputPeaksWorkspace) { void SortHKL::sortOutputPeaksByHKL(IPeaksWorkspace_sptr outputPeaksWorkspace) {
// Sort by HKL // Sort by HKL
std::vector<std::pair<std::string, bool> > criteria{ { "H", true }, std::vector<std::pair<std::string, bool>> criteria{
{ "K", true }, {"H", true}, {"K", true}, {"L", true}};
{ "L", true } };
outputPeaksWorkspace->sort(criteria); outputPeaksWorkspace->sort(criteria);
} }
......
...@@ -33,7 +33,7 @@ StatisticsOfPeaksWorkspace::StatisticsOfPeaksWorkspace() { ...@@ -33,7 +33,7 @@ StatisticsOfPeaksWorkspace::StatisticsOfPeaksWorkspace() {
/** Initialize the algorithm's properties. /** Initialize the algorithm's properties.
*/ */
void StatisticsOfPeaksWorkspace::init() { void StatisticsOfPeaksWorkspace::init() {
declareProperty(make_unique<WorkspaceProperty<PeaksWorkspace> >( declareProperty(make_unique<WorkspaceProperty<PeaksWorkspace>>(
"InputWorkspace", "", Direction::Input), "InputWorkspace", "", Direction::Input),
"An input PeaksWorkspace with an instrument."); "An input PeaksWorkspace with an instrument.");
std::vector<std::string> propOptions; std::vector<std::string> propOptions;
...@@ -54,29 +54,29 @@ void StatisticsOfPeaksWorkspace::init() { ...@@ -54,29 +54,29 @@ void StatisticsOfPeaksWorkspace::init() {
boost::make_shared<StringListValidator>(centeringOptions), boost::make_shared<StringListValidator>(centeringOptions),
"Appropriate lattice centering for the peaks."); "Appropriate lattice centering for the peaks.");
declareProperty(make_unique<WorkspaceProperty<PeaksWorkspace> >( declareProperty(make_unique<WorkspaceProperty<PeaksWorkspace>>(
"OutputWorkspace", "", Direction::Output), "OutputWorkspace", "", Direction::Output),
"Output PeaksWorkspace"); "Output PeaksWorkspace");
declareProperty(make_unique<WorkspaceProperty<ITableWorkspace> >( declareProperty(make_unique<WorkspaceProperty<ITableWorkspace>>(
"StatisticsTable", "StatisticsTable", Direction::Output), "StatisticsTable", "StatisticsTable", Direction::Output),
"An output table workspace for the statistics of the peaks."); "An output table workspace for the statistics of the peaks.");
std::vector<std::string> sortTypes{ "ResolutionShell", "Bank", std::vector<std::string> sortTypes{"ResolutionShell", "Bank", "RunNumber",
"RunNumber", "Overall" }; "Overall"};
declareProperty("SortBy", sortTypes[0], declareProperty("SortBy", sortTypes[0],
boost::make_shared<StringListValidator>(sortTypes), boost::make_shared<StringListValidator>(sortTypes),
"Sort the peaks by resolution shell in d-Spacing(default), " "Sort the peaks by resolution shell in d-Spacing(default), "
"bank, run number, or only overall statistics."); "bank, run number, or only overall statistics.");
std::vector<std::string> equivTypes{ "Mean", "Median" }; std::vector<std::string> equivTypes{"Mean", "Median"};
declareProperty("EquivalentIntensities", equivTypes[0], declareProperty("EquivalentIntensities", equivTypes[0],
boost::make_shared<StringListValidator>(equivTypes), boost::make_shared<StringListValidator>(equivTypes),
"Replace intensities by mean(default), " "Replace intensities by mean(default), "
"or median."); "or median.");
declareProperty(Kernel::make_unique<PropertyWithValue<double> >( declareProperty(Kernel::make_unique<PropertyWithValue<double>>(
"SigmaCritical", 3.0, Direction::Input), "SigmaCritical", 3.0, Direction::Input),
"Removes peaks whose intensity deviates more than " "Removes peaks whose intensity deviates more than "
"SigmaCritical from the mean (or median)."); "SigmaCritical from the mean (or median).");
declareProperty( declareProperty(
make_unique<WorkspaceProperty<MatrixWorkspace> >( make_unique<WorkspaceProperty<MatrixWorkspace>>(
"EquivalentsWorkspace", "EquivalentIntensities", Direction::Output), "EquivalentsWorkspace", "EquivalentIntensities", Direction::Output),
"Output Equivalent Intensities"); "Output Equivalent Intensities");
} }
...@@ -93,7 +93,7 @@ void StatisticsOfPeaksWorkspace::exec() { ...@@ -93,7 +93,7 @@ void StatisticsOfPeaksWorkspace::exec() {
tempWS->copyExperimentInfoFrom(ws.get()); tempWS->copyExperimentInfoFrom(ws.get());
// We must sort the peaks // We must sort the peaks
std::vector<std::pair<std::string, bool> > criteria; std::vector<std::pair<std::string, bool>> criteria;
if (sortType.compare(0, 2, "Re") == 0) if (sortType.compare(0, 2, "Re") == 0)
criteria.push_back(std::pair<std::string, bool>("DSpacing", false)); criteria.push_back(std::pair<std::string, bool>("DSpacing", false));
else if (sortType.compare(0, 2, "Ru") == 0) else if (sortType.compare(0, 2, "Ru") == 0)
......
...@@ -111,12 +111,12 @@ public: ...@@ -111,12 +111,12 @@ public:
Mantid::Kernel::V3D getDetectorPosition() const override; Mantid::Kernel::V3D getDetectorPosition() const override;
Mantid::Kernel::V3D getDetectorPositionNoCheck() const override; Mantid::Kernel::V3D getDetectorPositionNoCheck() const override;
void setQSampleFrame(const Mantid::Kernel::V3D &QSampleFrame, void setQSampleFrame(
boost::optional<double> detectorDistance = const Mantid::Kernel::V3D &QSampleFrame,
boost::none) override; boost::optional<double> detectorDistance = boost::none) override;
void setQLabFrame(const Mantid::Kernel::V3D &QLabFrame, void
boost::optional<double> detectorDistance = setQLabFrame(const Mantid::Kernel::V3D &QLabFrame,
boost::none) override; boost::optional<double> detectorDistance = boost::none) override;
void setWavelength(double wavelength) override; void setWavelength(double wavelength) override;
double getWavelength() const override; double getWavelength() const override;
......
...@@ -94,7 +94,8 @@ Statistics getStatistics(const std::vector<TYPE> &data, ...@@ -94,7 +94,8 @@ Statistics getStatistics(const std::vector<TYPE> &data,
template <typename TYPE> template <typename TYPE>
std::vector<double> getZscore(const std::vector<TYPE> &data); std::vector<double> getZscore(const std::vector<TYPE> &data);
template <typename TYPE> template <typename TYPE>
std::vector<double> getWeightedZscore(const std::vector<TYPE> &data,const std::vector<TYPE> &weights); std::vector<double> getWeightedZscore(const std::vector<TYPE> &data,
const std::vector<TYPE> &weights);
/// Return the modified Z score values for a dataset /// Return the modified Z score values for a dataset
template <typename TYPE> template <typename TYPE>
std::vector<double> getModifiedZscore(const std::vector<TYPE> &data, std::vector<double> getModifiedZscore(const std::vector<TYPE> &data,
......
...@@ -68,7 +68,7 @@ double getMedian(const vector<TYPE> &data, const size_t num_data, ...@@ -68,7 +68,7 @@ double getMedian(const vector<TYPE> &data, const size_t num_data,
// return the average // return the average
return (left + right) / 2.; return (left + right) / 2.;
} else } else
// Odd number // Odd number
{ {
if (sorted) { if (sorted) {
// If sorted and odd, just return the centre value // If sorted and odd, just return the centre value
...@@ -111,7 +111,8 @@ std::vector<double> getZscore(const vector<TYPE> &data) { ...@@ -111,7 +111,8 @@ std::vector<double> getZscore(const vector<TYPE> &data) {
* put it in a single function. * put it in a single function.
*/ */
template <typename TYPE> template <typename TYPE>
std::vector<double> getWeightedZscore(const vector<TYPE> &data, const vector<TYPE> &weights) { std::vector<double> getWeightedZscore(const vector<TYPE> &data,
const vector<TYPE> &weights) {
if (data.size() < 3) { if (data.size() < 3) {
std::vector<double> Zscore(data.size(), 0.); std::vector<double> Zscore(data.size(), 0.);
return Zscore; return Zscore;
...@@ -129,9 +130,10 @@ std::vector<double> getWeightedZscore(const vector<TYPE> &data, const vector<TYP ...@@ -129,9 +130,10 @@ std::vector<double> getWeightedZscore(const vector<TYPE> &data, const vector<TYP
sumWeights += static_cast<double>(weights[it]); sumWeights += static_cast<double>(weights[it]);
sumWeightedData += static_cast<double>(weights[it] * data[it]); sumWeightedData += static_cast<double>(weights[it] * data[it]);
} }
double weightedMean = sumWeightedData/sumWeights; double weightedMean = sumWeightedData / sumWeights;
for (size_t it = 0; it != data.size(); ++it) { for (size_t it = 0; it != data.size(); ++it) {
weightedVariance += std::pow(data[it] - weightedMean, 2) * std::pow(weights[it]/sumWeights, 2); weightedVariance += std::pow(data[it] - weightedMean, 2) *
std::pow(weights[it] / sumWeights, 2);
} }
for (auto it = data.cbegin(); it != data.cend(); ++it) { for (auto it = data.cbegin(); it != data.cend(); ++it) {
Zscore.push_back(fabs((*it - weightedMean) / std::sqrt(weightedVariance))); Zscore.push_back(fabs((*it - weightedMean) / std::sqrt(weightedVariance)));
...@@ -190,7 +192,7 @@ Statistics getStatistics(const vector<TYPE> &data, const unsigned int flags) { ...@@ -190,7 +192,7 @@ Statistics getStatistics(const vector<TYPE> &data, const unsigned int flags) {
(flags & StatOptions::CorrectedStdDev)); (flags & StatOptions::CorrectedStdDev));
if (stddev) {