80 std::vector<IPeaksWorkspace_sptr> runWS;
82 if (
auto pw = std::dynamic_pointer_cast<PeaksWorkspace>(ws)) {
83 std::vector<int> badPeaks;
85 for (
int i =
int(pw->getNumberPeaks()) - 1; i >= 0; --i) {
86 const std::vector<Peak> &peaks = pw->getPeaks();
87 if (
edgePixel(compInfo, peaks[i].getBankName(), peaks[i].getCol(), peaks[i].getRow(), edge)) {
88 badPeaks.emplace_back(i);
91 pw->removePeaks(std::move(badPeaks));
93 runWS.emplace_back(ws);
95 int maxOrder = ws->mutableSample().getOrientedLattice().getMaxOrder();
96 DblMatrix modHKL = ws->mutableSample().getOrientedLattice().getModHKL();
99 for (
int i = 0; i < ws->getNumberPeaks(); i++) {
100 IPeak &peak = ws->getPeak(i);
107 std::vector<std::pair<std::string, bool>> criteria;
109 criteria.emplace_back(
"runnumber",
true);
113 for (
int i = 0; i < ws->getNumberPeaks(); i++) {
114 IPeak &peak = ws->getPeak(i);
118 cloneWS->copyExperimentInfoFrom(ws.get());
119 runWS.emplace_back(cloneWS);
120 runWS[
count]->addPeak(peak);
122 AnalysisDataService::Instance().addOrReplace(
std::to_string(run) + ws->getName(), runWS[
count]);
124 runWS[
count]->addPeak(peak);
129 for (
auto &i_run : runWS) {
131 AnalysisDataService::Instance().addOrReplace(
"_peaks", peakWS);
132 const DblMatrix UB = peakWS->sample().getOrientedLattice().getUB();
133 auto ol = peakWS->sample().getOrientedLattice();
134 DblMatrix modUB = peakWS->mutableSample().getOrientedLattice().getModUB();
135 bool crossTerms = peakWS->mutableSample().getOrientedLattice().getCrossTerm();
136 std::vector<double> lat(6);
149 fit_alg->setProperty(
"Function", std::static_pointer_cast<IFunction>(latticeFunction));
150 fit_alg->setProperty(
"Ties",
"ZeroShift=0.0");
151 fit_alg->setProperty(
"InputWorkspace", peakWS);
152 fit_alg->setProperty(
"CostFunction",
"Unweighted least squares");
153 fit_alg->setProperty(
"CreateOutput",
true);
154 fit_alg->executeAsChildAlg();
156 double chisq = fit_alg->getProperty(
"OutputChi2overDoF");
163 g_log.
error(
"Can't locate CalculateUMatrix algorithm");
167 ub_alg->setProperty(
"PeaksWorkspace", peakWS);
168 ub_alg->setProperty(
"a", refinedCell.
a());
169 ub_alg->setProperty(
"b", refinedCell.
b());
170 ub_alg->setProperty(
"c", refinedCell.
c());
171 ub_alg->setProperty(
"alpha", refinedCell.
alpha());
172 ub_alg->setProperty(
"beta", refinedCell.
beta());
173 ub_alg->setProperty(
"gamma", refinedCell.
gamma());
174 ub_alg->executeAsChildAlg();
175 DblMatrix UBnew = peakWS->mutableSample().getOrientedLattice().getUB();
176 auto o_lattice = std::make_unique<OrientedLattice>();
177 o_lattice->setUB(UBnew);
179 o_lattice->setModUB(modUB);
182 o_lattice->setModHKL(modHKL);
184 o_lattice->set(refinedCell.
a(), refinedCell.
b(), refinedCell.
c(), refinedCell.
alpha(), refinedCell.
beta(),
185 refinedCell.
gamma());
190 g_log.
notice() << i_run->getName() <<
" " << *o_lattice <<
"\n";
192 i_run->mutableSample().setOrientedLattice(std::move(o_lattice));
199 alg->setPropertyValue(
"PeaksWorkspace", i_run->getName());
200 alg->setProperty(
"Tolerance",
tolerance);
201 alg->executeAsChildAlg();
203 AnalysisDataService::Instance().remove(
"_peaks");
205 std::string outputdir =
getProperty(
"OutputDirectory");
206 if (outputdir.back() !=
'/')
210 savePks_alg->setPropertyValue(
"InputWorkspace", i_run->getName());
211 savePks_alg->setProperty(
"Filename", outputdir +
"ls" + i_run->getName() +
".integrate");
212 savePks_alg->executeAsChildAlg();
213 g_log.
notice() <<
"See output file: " << outputdir +
"ls" + i_run->getName() +
".integrate" <<
"\n";
216 saveUB_alg->setPropertyValue(
"InputWorkspace", i_run->getName());
217 saveUB_alg->setProperty(
"Filename", outputdir +
"ls" + i_run->getName() +
".mat");
218 saveUB_alg->executeAsChildAlg();
220 g_log.
notice() <<
"See output file: " << outputdir +
"ls" + i_run->getName() +
".mat" <<
"\n";
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.
MANTID_GEOMETRY_DLL bool edgePixel(ComponentInfo const &info, const std::string &bankName, int col, int row, int Edge)
Function to find peaks near detector edge.