Commit 35a948e3 authored by Lynch, Vickie's avatar Lynch, Vickie
Browse files

Refs #22420 no duplicate integer peaks

parent a1af3852
......@@ -33,57 +33,56 @@ DECLARE_ALGORITHM(PredictSatellitePeaks)
void PredictSatellitePeaks::init() {
auto latticeValidator = boost::make_shared<OrientedLatticeValidator>();
declareProperty(
make_unique<WorkspaceProperty<PeaksWorkspace>>("Peaks", "",
Direction::Input, latticeValidator),
make_unique<WorkspaceProperty<PeaksWorkspace> >(
"Peaks", "", Direction::Input, latticeValidator),
"Workspace of Peaks with orientation matrix that indexed the peaks and "
"instrument loaded");
declareProperty(
make_unique<WorkspaceProperty<PeaksWorkspace>>("SatellitePeaks", "",
Direction::Output),
make_unique<WorkspaceProperty<PeaksWorkspace> >("SatellitePeaks", "",
Direction::Output),
"Workspace of Peaks with peaks with fractional h,k, and/or l values");
declareProperty(Kernel::make_unique<Kernel::ArrayProperty<double>>(
declareProperty(Kernel::make_unique<Kernel::ArrayProperty<double> >(
string("ModVector1"), "0.0,0.0,0.0"),
"Offsets for h, k, l directions ");
declareProperty(Kernel::make_unique<Kernel::ArrayProperty<double>>(
declareProperty(Kernel::make_unique<Kernel::ArrayProperty<double> >(
string("ModVector2"), "0.0,0.0,0.0"),
"Offsets for h, k, l directions ");
declareProperty(Kernel::make_unique<Kernel::ArrayProperty<double>>(
declareProperty(Kernel::make_unique<Kernel::ArrayProperty<double> >(
string("ModVector3"), "0.0,0.0,0.0"),
"Offsets for h, k, l directions ");
declareProperty(
make_unique<PropertyWithValue<int>>("MaxOrder", 0, Direction::Input),
make_unique<PropertyWithValue<int> >("MaxOrder", 0, Direction::Input),
"Maximum order to apply ModVectors. Default = 0");
declareProperty("GetModVectorsFromUB", true,
"If false Modulation Vectors will be read from input");
declareProperty(make_unique<PropertyWithValue<bool>>("CrossTerms", false,
Direction::Input),
declareProperty(make_unique<PropertyWithValue<bool> >("CrossTerms", false,
Direction::Input),
"Include cross terms (false)");
declareProperty(
"IncludeIntegerHKL", true,
"If false order 0 peaks are not included in workspace (integer HKL)");
declareProperty("IncludeAllPeaksInRange", false,
"If false only offsets from "
"peaks from Peaks workspace "
"in input are used");
declareProperty("IncludeAllPeaksInRange", false, "If false only offsets from "
"peaks from Peaks workspace "
"in input are used");
declareProperty(make_unique<PropertyWithValue<double>>("WavelengthMin", 0.1,
Direction::Input),
declareProperty(make_unique<PropertyWithValue<double> >("WavelengthMin", 0.1,
Direction::Input),
"Minimum wavelength limit at which to start looking for "
"single-crystal peaks.");
declareProperty(make_unique<PropertyWithValue<double>>("WavelengthMax", 100.0,
Direction::Input),
declareProperty(make_unique<PropertyWithValue<double> >(
"WavelengthMax", 100.0, Direction::Input),
"Maximum wavelength limit at which to start looking for "
"single-crystal peaks.");
declareProperty(make_unique<PropertyWithValue<double>>("MinDSpacing", 0.1,
Direction::Input),
declareProperty(make_unique<PropertyWithValue<double> >("MinDSpacing", 0.1,
Direction::Input),
"Minimum d-spacing of peaks to consider. Default = 1.0");
declareProperty(make_unique<PropertyWithValue<double>>("MaxDSpacing", 100.0,
Direction::Input),
declareProperty(make_unique<PropertyWithValue<double> >("MaxDSpacing", 100.0,
Direction::Input),
"Maximum d-spacing of peaks to consider");
setPropertySettings(
......@@ -181,16 +180,16 @@ void PredictSatellitePeaks::exec() {
auto &UB = lattice.getUB();
goniometer = peak0.getGoniometerMatrix();
Progress prog(this, 0.0, 1.0, N);
vector<vector<int>> AlreadyDonePeaks;
vector<vector<int> > AlreadyDonePeaks;
auto orientedUB = goniometer * UB;
HKLFilterWavelength lambdaFilter(orientedUB, lambdaMin, lambdaMax);
int seqNum = 0;
OutPeaks->mutableRun().addProperty<std::vector<double>>("Offset1", offsets1,
true);
OutPeaks->mutableRun().addProperty<std::vector<double>>("Offset2", offsets2,
true);
OutPeaks->mutableRun().addProperty<std::vector<double>>("Offset3", offsets3,
true);
OutPeaks->mutableRun().addProperty<std::vector<double> >("Offset1", offsets1,
true);
OutPeaks->mutableRun().addProperty<std::vector<double> >("Offset2", offsets2,
true);
OutPeaks->mutableRun().addProperty<std::vector<double> >("Offset3", offsets3,
true);
for (auto it = possibleHKLs.begin(); it != possibleHKLs.end(); ++it) {
V3D hkl = *it;
if (crossTerms) {
......@@ -244,15 +243,15 @@ void PredictSatellitePeaks::exec_peaks() {
OutPeaks->setInstrument(instrument);
OutPeaks->mutableSample().setOrientedLattice(&lattice);
vector<vector<int>> AlreadyDonePeaks;
vector<vector<int> > AlreadyDonePeaks;
int seqNum = 0;
HKLFilterWavelength lambdaFilter(DblMatrix(3, 3, true), 0.1, 100.);
OutPeaks->mutableRun().addProperty<std::vector<double>>("Offset1", offsets1,
true);
OutPeaks->mutableRun().addProperty<std::vector<double>>("Offset2", offsets2,
true);
OutPeaks->mutableRun().addProperty<std::vector<double>>("Offset3", offsets3,
true);
OutPeaks->mutableRun().addProperty<std::vector<double> >("Offset1", offsets1,
true);
OutPeaks->mutableRun().addProperty<std::vector<double> >("Offset2", offsets2,
true);
OutPeaks->mutableRun().addProperty<std::vector<double> >("Offset3", offsets3,
true);
std::vector<Peak> peaks = Peaks->getPeaks();
for (auto it = peaks.begin(); it != peaks.end(); ++it) {
auto peak = *it;
......@@ -267,11 +266,9 @@ void PredictSatellitePeaks::exec_peaks() {
includePeaksInRange, includeOrderZero, seqNum,
AlreadyDonePeaks);
predictOffsets(Peaks, OutPeaks, 1, offsets2, maxOrder, hkl, lambdaFilter,
includePeaksInRange, includeOrderZero, seqNum,
AlreadyDonePeaks);
includePeaksInRange, false, seqNum, AlreadyDonePeaks);
predictOffsets(Peaks, OutPeaks, 2, offsets3, maxOrder, hkl, lambdaFilter,
includePeaksInRange, includeOrderZero, seqNum,
AlreadyDonePeaks);
includePeaksInRange, false, seqNum, AlreadyDonePeaks);
}
}
setProperty("SatellitePeaks", OutPeaks);
......@@ -282,7 +279,7 @@ void PredictSatellitePeaks::predictOffsets(
boost::shared_ptr<Mantid::API::IPeaksWorkspace> &OutPeaks, int iVector,
V3D offsets, int &maxOrder, V3D &hkl, HKLFilterWavelength &lambdaFilter,
bool &includePeaksInRange, bool &includeOrderZero, int &seqNum,
vector<vector<int>> &AlreadyDonePeaks) {
vector<vector<int> > &AlreadyDonePeaks) {
if (offsets == V3D(0, 0, 0))
return;
const Kernel::DblMatrix &UB = Peaks->sample().getOrientedLattice().getUB();
......@@ -311,9 +308,10 @@ void PredictSatellitePeaks::predictOffsets(
if (!peak->findDetector(tracer))
continue;
vector<int> SavPk{RunNumber, boost::math::iround(1000.0 * satelliteHKL[0]),
boost::math::iround(1000.0 * satelliteHKL[1]),
boost::math::iround(1000.0 * satelliteHKL[2])};
vector<int> SavPk{ RunNumber,
boost::math::iround(1000.0 * satelliteHKL[0]),
boost::math::iround(1000.0 * satelliteHKL[1]),
boost::math::iround(1000.0 * satelliteHKL[2]) };
bool foundPeak =
binary_search(AlreadyDonePeaks.begin(), AlreadyDonePeaks.end(), SavPk);
......@@ -342,7 +340,7 @@ void PredictSatellitePeaks::predictOffsetsWithCrossTerms(
V3D offsets2, V3D offsets3, int &maxOrder, V3D &hkl,
HKLFilterWavelength &lambdaFilter, bool &includePeaksInRange,
bool &includeOrderZero, int &seqNum,
vector<vector<int>> &AlreadyDonePeaks) {
vector<vector<int> > &AlreadyDonePeaks) {
if (offsets1 == V3D(0, 0, 0) && offsets2 == V3D(0, 0, 0) &&
offsets3 == V3D(0, 0, 0))
return;
......@@ -387,10 +385,10 @@ void PredictSatellitePeaks::predictOffsetsWithCrossTerms(
if (!peak->findDetector(tracer))
continue;
vector<int> SavPk{RunNumber,
boost::math::iround(1000.0 * satelliteHKL[0]),
boost::math::iround(1000.0 * satelliteHKL[1]),
boost::math::iround(1000.0 * satelliteHKL[2])};
vector<int> SavPk{ RunNumber,
boost::math::iround(1000.0 * satelliteHKL[0]),
boost::math::iround(1000.0 * satelliteHKL[1]),
boost::math::iround(1000.0 * satelliteHKL[2]) };
bool foundPeak = binary_search(AlreadyDonePeaks.begin(),
AlreadyDonePeaks.end(), SavPk);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment