26#include "MantidHistogramData/BinEdges.h"
27#include "MantidHistogramData/CountStandardDeviations.h"
28#include "MantidHistogramData/Counts.h"
29#include "MantidHistogramData/Points.h"
31#include <boost/math/special_functions/round.hpp>
59#define IIntensities 14
62#define ITotBoundary 17
64#define IVarBoundary 19
84const double probs[9] = {.5f, .5987f, .6915f, .7734f, .8413f, .8944f, .9322f, .9599f, .9772f};
86const int MinRowColSpan = 6;
87const int MaxRowColSpan = 36;
88const int MinTimeSpan = 3;
89const double NeighborhoodRadiusDivPeakRadius = 1.5;
90const double MaxNeighborhoodRadius = 10;
91const double NStdDevPeakSpan = 2;
92const double MaxGoodRatioFitvsExpIntenisites = 2.5;
93const double MinGoodRatioFitvsExpIntenisites = .25;
94const double MinGoodIoverSigI = 3.0;
95const double MinVariationInXYvalues = .6;
96const double MaxCorrCoeffinXY = .9;
100 :
Algorithm(), m_R0(-1), m_ROW(0.), m_COL(0.), m_cellWidth(0.), m_cellHeight(0.), m_NROWS(0), m_NCOLS(0) {
148 "A 2D workspace with X values of time of flight");
151 "Name of the output table workspace with Log info");
154 "Workspace of Peaks");
156 declareProperty(
"PeakIndex", 0,
"Index of peak in PeaksWorkspace to integrate");
158 declareProperty(
"PeakQspan", .06,
"Max magnitude of Q of Peak to Q of Peak Center, where mod(Q)=1/d");
160 declareProperty(
"CalculateVariances",
true,
"Calc (co)variances given parameter values versus fit (co)Variances ");
162 declareProperty(
"Ties",
"",
"Tie parameters(Background,Intensity, Mrow,...) to values/formulas.");
183 seconds1 = time(
nullptr);
187 g_log.
debug(
"------------------Start Peak Integrate-------------------");
190 g_log.
error(
"Negative PeakQspans are not allowed. Use .17/G where G is the "
191 "max unit cell length");
192 throw std::runtime_error(
"Negative PeakQspans are not allowed in IntegratePeakTimeSlices");
198 throw std::runtime_error(
"Improper Input Workspace in IntegratePeakTimeSlices");
205 throw std::runtime_error(
"Improper Peaks Input");
210 Peak const &peak = peaksW->getPeak(indx);
214 std::shared_ptr<const Geometry::IComponent> panel_const =
217 std::shared_ptr<Geometry::IComponent> panel = std::const_pointer_cast<Geometry::IComponent>(panel_const);
219 if (!panel || !panel_const) {
221 throw std::runtime_error(
"Cannot get panel for a peak");
225 panel->getBoundingBox(box);
228 g_log.
error(
"Detector pixel is NOT inside the Peaks Bank");
229 throw std::runtime_error(
"Detector pixel is NOT inside the Peaks Bank");
234 g_log.
debug() <<
" Peak Index " << indx <<
'\n';
236 double TotVariance = 0;
237 double TotIntensity = 0;
238 double lastRow =
m_ROW;
239 double Row0 = lastRow;
240 double lastCol =
m_COL;
241 double Col0 = lastCol;
256 size_t wsIndx = (it->second);
266 const auto &
X = inpWkSpace->x(wsIndx);
269 dChan = max<int>(dChan, MinTimeSpan);
275 double neighborRadius;
277 neighborRadius = min<double>(MaxNeighborhoodRadius, NeighborhoodRadiusDivPeakRadius * R);
280 Nneighbors = min<int>(Nneighbors,
static_cast<int>(inpWkSpace->getNumberHistograms()) - 2);
291 g_log.
error(
"Not enough neighboring pixels to fit ");
292 throw std::runtime_error(
"Not enough neighboring pixels to fit ");
296 double MaxCounts = -1;
299 for (
int dir = 1; dir > -2; dir -= 2) {
301 for (
int t = 0; t < dChan && !done; t++)
302 if (dir < 0 && t == 0) {
305 }
else if (Chan + dir * t < 0 || Chan + dir * t >=
static_cast<int>(
X.size()))
316 XXX->setCurrentRadius(R);
318 SetUpData1(Data, inpWkSpace, Chan + dir * t, Chan + dir * t, R, CenterDet->getPos(), spec_idList);
323 MaxChan = Chan + dir * t;
340 g_log.
debug() <<
" largest Channel,Radius,m_cellWidth,m_cellHeight = " << Chan <<
" " << R <<
" " <<
m_cellWidth
344 g_log.
error(
"Not enough rows and cols or time channels ");
345 throw std::runtime_error(
"Not enough rows and cols or time channels ");
359 int LastTableRow = -1;
360 auto origAttributeList = std::make_shared<DataModeHandler>();
361 auto lastAttributeList = std::make_shared<DataModeHandler>();
363 for (
int dir = 1; dir >= -1; dir -= 2) {
366 for (
int chan = 0; chan < dChan && !done; chan++)
367 if (dir < 0 && chan == 0) {
370 lastAttributeList = origAttributeList;
371 if (TabWS->rowCount() > 0)
374 }
else if (Chan + dir * chan < 0 || Chan + dir * chan >=
static_cast<int>(
X.size()))
378 int xchan = Chan + dir * chan;
380 size_t topIndex = xchan + 1;
381 if (topIndex >=
X.size())
382 topIndex =
X.size() - 1;
384 time = (
X[xchan] +
X[topIndex]) / 2.0;
394 g_log.
debug() <<
" A:chan=" << xchan <<
" time=" << time <<
" Radius=" << Radius <<
"row= " << lastRow
395 <<
" col=" << lastCol <<
'\n';
397 SetUpData(Data, inpWkSpace, panel, xchan, xchan, lastCol, lastRow, Cent, neighborRadius, Radius, spec_idList);
406 std::vector<double> params;
407 std::vector<double> errs;
408 std::vector<std::string> names;
414 Fit(Data, chisqOverDOF, done, names, params, errs, lastRow, lastCol, neighborRadius);
419 if (
isGoodFit(params, errs, names, chisqOverDOF)) {
420 LastTableRow =
UpdateOutputWS(TabWS, dir, xchan, params, errs, names, chisqOverDOF,
427 TotSliceVariance, chisqOverDOF, ncells);
431 if (dir == 1 && chan == 0)
432 origAttributeList = lastAttributeList;
447 int chanMin, chanMax;
448 if ((dir == 1 && chan == 0) || lastAttributeList->CellHeight <= 0) {
461 chanMin = std::min<int>(xchan, xchan - dir);
462 chanMax = chanMin + 1;
463 if (lastAttributeList->case4)
466 auto XXX = std::make_shared<DataModeHandler>(*lastAttributeList);
488 Fit(Data, chisqOverDOF, done, names, params, errs, lastRow, lastCol, neighborRadius);
492 if (!done &&
isGoodFit(params, errs, names, chisqOverDOF)) {
494 if (LastTableRow >= 0 && LastTableRow <
static_cast<int>(TabWS->rowCount()))
495 TabWS->removeRow(LastTableRow);
499 LastTableRow =
UpdateOutputWS(TabWS, dir, (chanMin + chanMax) / 2.0, params, errs, names, chisqOverDOF,
502 if (lastAttributeList->lastISAWVariance > 0 && lastAttributeList->CellHeight > 0) {
503 TotIntensity -= lastAttributeList->lastISAWIntensity;
504 TotVariance -= lastAttributeList->lastISAWVariance;
511 updatePeakInformation(params, errs, names, TotVariance, TotIntensity, TotSliceIntensity, TotSliceVariance,
516 if (dir == 1 && (chan == 0 || chan == 1)) {
523 auto XXX = std::make_shared<DataModeHandler>();
524 lastAttributeList = XXX;
537 throw std::runtime_error(
"Inconsistency found in algorithm "
538 "execution. The index for the parameter "
539 "Mrow is negative.");
542 lastRow = boost::math::iround(params[i]);
545 lastCol = boost::math::iround(params[i]);
559 }
catch (std::exception &EE1) {
560 std::cout <<
"Error in main reason=" << EE1.what() <<
'\n';
562 throw std::runtime_error(
" Error IntegratePeakTimeSlices:" + std::string(EE1.what()));
563 }
catch (std::string &mess) {
564 throw std::runtime_error(
"Error IntegratePeakTimeSlices:" + mess);
567 throw std::runtime_error(
"Error IntegratePeakTimeSlices:");
578 seconds2 = time(
nullptr);
579 double dif = difftime(seconds2, seconds1);
580 g_log.
debug() <<
"Finished Integr peak number " << indx <<
" in " << dif <<
" seconds\n";
582 }
catch (std::exception &ss) {
584 std::cout <<
"Error occurred XX " << ss.what() <<
'\n';
585 throw std::runtime_error(ss.what());
599 const Kernel::V3D &Center,
double &Radius,
int *&ArryofID) {
602 int MaxN = ArryofID[0];
608 comp->getBoundingBox(box);
610 double minx = Center.
X() - Radius;
611 double miny = Center.
Y() - Radius;
612 double minz = Center.
Z() - Radius;
613 double maxx = Center.
X() + Radius;
614 double maxy = Center.
Y() + Radius;
615 double maxz = Center.
Z() + Radius;
617 if (box.
xMin() >= maxx)
620 if (box.
xMax() <= minx)
624 if (box.
yMin() >= maxy)
627 if (box.
yMax() <= miny)
630 if (box.
zMin() >= maxz)
633 if (box.
zMax() <= minz)
637 auto det = std::dynamic_pointer_cast<Geometry::Detector>(comp);
640 V3D pos = det->getPos() - Center;
641 if (pos.
X() * pos.
X() + pos.
Y() * pos.
Y() + pos.
Z() * pos.
Z() < Radius * Radius) {
642 ArryofID[N] = det->getID();
649 auto Assembly = std::dynamic_pointer_cast<const Geometry::ICompAssembly>(comp);
656 for (
int i = 0; i < Assembly->nelements() && b; i++)
671 const V3D &oldCenter,
double NewRadius,
double &neighborRadius) {
672 double DD = (CentPos - oldCenter).norm();
673 bool changed =
false;
674 if (DD + NewRadius > neighborRadius) {
675 auto NN = int(NStdDevPeakSpan * NeighborhoodRadiusDivPeakRadius * NewRadius /
m_cellWidth * NStdDevPeakSpan *
676 NeighborhoodRadiusDivPeakRadius * NewRadius /
m_cellHeight);
683 neighborRadius = NeighborhoodRadiusDivPeakRadius * NewRadius;
689 neighborRadius -= DD;
707 double Q = 0, ScatAngle = 0, dScatAngle = 0, DetSpan = 0;
714 ScatAngle = acos(pos.
Z() / pos.
norm());
716 dScatAngle = 2 * dQ / Q * tan(ScatAngle / 2);
718 DetSpan = pos.
norm() * dScatAngle;
720 DetSpan =
fabs(DetSpan);
726 }
catch (std::exception &s) {
727 std::cout <<
"err in getNRowsCols, reason=" << s.what() <<
'\n';
747 const int specNum,
int &Centerchan) {
751 double time = peak.
getTOF();
752 double dtime = dQ / Q * time;
755 Centerchan = chanCenter;
758 int dchan = abs(chanCenter - chanLeft);
760 if (abs(chanRight - chanCenter) > dchan)
761 dchan = abs(chanRight - chanCenter);
763 dchan = max<int>(3, dchan);
785 int &NCOLS,
double &pixWidthx,
double &pixHeighty,
790 V3D detPos = det->getPos();
792 center.
setX(detPos.
X());
793 center.
setY(detPos.
Y());
794 center.
setZ(detPos.
Z());
796 std::shared_ptr<const Detector> dett = std::dynamic_pointer_cast<const Detector>(det);
798 pixWidthx = dett->getWidth();
799 pixHeighty = dett->getHeight();
802 V3D yaxis0(0.0, 1.0, 0.0);
811 xvec.
setX(xaxis0.
X());
812 xvec.
setY(xaxis0.
Y());
813 xvec.
setZ(xaxis0.
Z());
814 yvec.
setX(yaxis0.
X());
815 yvec.
setY(yaxis0.
Y());
816 yvec.
setZ(yaxis0.
Z());
821 throw std::invalid_argument(
"No instrument for peak");
822 std::shared_ptr<const IComponent> panel = inst->getComponentByName(peak.
getBankName());
824 std::shared_ptr<const RectangularDetector> ddet = std::dynamic_pointer_cast<const RectangularDetector>(panel);
830 std::pair<int, int> CR = ddet->getXYForDetectorID(det->getID());
833 pixWidthx = ddet->xstep();
834 pixHeighty = ddet->ystep();
836 NROWS = ddet->ypixels();
837 NCOLS = ddet->xpixels();
846 std::shared_ptr<const Component> compPanel = std::dynamic_pointer_cast<const Component>(panel);
847 std::shared_ptr<IComponent> panel1(compPanel->base()->clone());
856 panel1->getBoundingBox(B);
858 NROWS = boost::math::iround((B.
yMax() - B.
yMin()) / pixHeighty);
859 NCOLS = boost::math::iround((B.
xMax() - B.
xMin()) / pixWidthx);
872 const double col, std::vector<double> &StatBase) {
877 StatBase[
ISSxx] += col * col;
878 StatBase[
ISSyy] += row * row;
879 StatBase[
ISSxy] += row * col;
882 StatBase[
ISSx] += col;
883 StatBase[
ISSy] += row;
900 std::vector<double> Res(7);
923 if (sigy * NstdY < 7 && sigy * NstdY >= 0)
925 x = probs[std::lround(sigy * NstdY)];
934 if (sigx * NstdX < 7 && sigx * NstdX > 0)
936 x1 = probs[std::lround(sigx * NstdX)];
973 if (Rx * Rx < 4 * Varx || Ry * Ry < 4 * Vary) {
977 return std::vector<double>();
987 double col = Mx / Den;
988 double row = My / Den;
989 std::vector<double>
Result(7);
1010 auto nBoundaryCells =
static_cast<int>(statBase[
INBoundary]);
1013 if (nBoundaryCells > 0) {
1014 double TotBoundaryIntensities = statBase[
ITotBoundary];
1015 b = TotBoundaryIntensities / nBoundaryCells;
1018 auto nCells =
static_cast<int>(statBase[
ISS1]);
1021 while (Den <= 0 && b != 0) {
1032 Varx = statBase[
INCol] / 7;
1033 Vary = statBase[
INRows] / 7;
1041 Ry * Ry < 4 * std::max(Vary,
VaryHW))
1063 double Mx = 0, My = 0, Sxx = 0, Syy = 0, Sxy = 0;
1065 double RangeX = statBase[
INCol] / 2;
1066 double RangeY = statBase[
INRows] / 2;
1068 while (!done && ntimes < 29) {
1069 Mx = statBase[
ISSIx] - b * statBase[
ISSx];
1070 My = statBase[
ISSIy] - b * statBase[
ISSy];
1071 Sxx = (statBase[
ISSIxx] - b * statBase[
ISSxx] - Mx * Mx / Den) / Den;
1072 Syy = (statBase[
ISSIyy] - b * statBase[
ISSyy] - My * My / Den) / Den;
1073 Sxy = (statBase[
ISSIxy] - b * statBase[
ISSxy] - Mx * My / Den) / Den;
1077 if (Sxx <= RangeX / 12 || Syy <= RangeY / 12 || Sxy * Sxy / Sxx / Syy > .9) {
1080 if (ntimes + 1 == 29)
1119 if (Rx * Rx > 4 * Vx)
1124 if (Ry * Ry > 4 * Vy)
1130 double NewRadius = 1.4 * max<double>(MinRowColSpan * max<double>(
CellWidth,
CellHeight), 4.5 * DD);
1131 NewRadius = mult * min<double>(
baseRCRadius, NewRadius);
1150 const std::vector<double> &counts) {
1151 double minCount, maxCount;
1152 const auto &
X = xvals;
1153 const auto &
Y = yvals;
1154 const auto &C = counts;
1157 auto N =
static_cast<int>(
X.size());
1164 minCount = maxCount = C[0];
1168 double lowX, lowY, highX, highY;
1169 lowX = highX =
X[0];
1170 lowY = highY =
Y[0];
1172 for (
int i = 1; i < N; i++) {
1175 else if (
X[i] > highX)
1180 else if (
Y[i] > highY)
1183 if (C[i] > maxCount) {
1188 }
else if (C[i] < minCount) {
1191 }
else if (C[i] == maxCount)
1198 if (minCount == maxCount)
1204 double dCount = std::max(.51, (maxCount - minCount) / 6.2);
1205 double CountUp = (maxCount + minCount) / 2 + dCount;
1206 double CountLow = (maxCount + minCount) / 2 - dCount;
1207 double dSpanx = (highX - lowX) / 6.;
1208 double dSpany = (highY - lowY) / 6.0;
1214 double offset = std::max(.2, (maxCount - minCount) / 20);
1215 double TotR_max = 0;
1216 double TotR_min = 0;
1221 for (
int i = 0; i < N; i++) {
1222 if (C[i] > maxCount - offset) {
1225 TotR_max += C[i] * sqrt((
X[i] - MaxX) * (
X[i] - MaxX) + (
Y[i] - MaxY) * (
Y[i] - MaxY));
1227 if (C[i] < minCount + offset)
1233 TotR_min += C[i] * sqrt((
X[i] - MaxX) * (
X[i] - MaxX) + (
Y[i] - MaxY) * (
Y[i] - MaxY));
1236 if (
fabs(MaxY -
Y[i]) < 1.2 &&
fabs(MaxX -
X[i]) > 1.2 && C[i] >= CountLow && C[i] <= CountUp &&
1237 fabs(MaxX -
X[i]) < dSpanx) {
1238 TotRx0 += (C[i] - minCount) * (
X[i] - MaxX) * (
X[i] - MaxX);
1239 TotCx += C[i] - minCount;
1242 if (
fabs(MaxX -
X[i]) < 1.2 &&
fabs(MaxY -
Y[i]) > 1.2 && C[i] >= CountLow && C[i] <= CountUp &&
1243 fabs(MaxY -
Y[i]) < dSpany) {
1244 TotRy0 += (C[i] - minCount) * (
Y[i] - MaxY) * (
Y[i] - MaxY);
1245 TotCy += C[i] - minCount;
1249 if (nMax + nMin == N)
1255 double AvR = .5 * (TotR_max / TotMax + TotR_min / TotMin);
1263 double TotR = 0, nR = -1, nRx = -1, nRy = -1;
1264 double MidVal = (TotMax / nMax + TotMin / nMin) / 2.0;
1265 double TotRx = 0, TotRy = 0;
1266 while ((nR <= 0 || nRy <= 0 || nRx <= 0) && offset < MidVal) {
1274 for (
int i = 0; i < N; i++)
1275 if (C[i] < MidVal + offset && C[i] > MidVal - offset) {
1276 double X1 =
X[i] - MaxX;
1277 double Y1 =
Y[i] - MaxY;
1278 TotR += sqrt(X1 * X1 + Y1 * Y1);
1280 if ((X1 >= -1.2 && X1 <= 1.2) &&
fabs(Y1) > 1.2 &&
fabs(Y1) < dSpany) {
1284 if ((Y1 >= -1.2 && Y1 <= 1.2) &&
fabs(X1) > 1.2 &&
fabs(X1) < dSpanx) {
1292 double AvR = TotR / nR;
1296 VarxHW = (TotRx / nRx) * (TotRx / nRx) / .8326 / .8326;
1298 VarxHW = TotRx0 * TotRx0 / TotCx / TotCx / .8326 / .8326;
1305 VaryHW = (TotRy / nRy) * (TotRy / nRy) / .8326 / .8326;
1307 VaryHW = TotRy0 * TotRy0 / TotCy / TotCy / .8326 / .8326;
1333 const std::shared_ptr<Geometry::IComponent> &comp,
const int chanMin,
1334 const int chanMax,
double CentX,
double CentY,
Kernel::V3D &CentNghbr,
1335 double &neighborRadius,
1336 double Radius,
string &spec_idList) {
1340 int NBadEdgeCells =
getProperty(
"NBadEdgePixels");
1344 NBadEdgeCells,
m_NROWS - NBadEdgeCells);
1350 SetUpData1(Data, inpWkSpace, chanMin, chanMax, Radius, CentPos1, spec_idList);
1366 double DD = (CentPos - CentNghbr).norm();
1368 if (DD + NewRadius > neighborRadius) {
1369 auto NN = int(NStdDevPeakSpan * NeighborhoodRadiusDivPeakRadius * NewRadius /
m_cellWidth * NStdDevPeakSpan *
1370 NeighborhoodRadiusDivPeakRadius * NewRadius /
m_cellHeight);
1378 neighborRadius = NeighborhoodRadiusDivPeakRadius * NewRadius;
1379 CentNghbr = CentPos;
1383 neighborRadius -= DD;
1388 NBadEdgeCells,
m_NROWS - NBadEdgeCells);
1393 SetUpData1(Data, inpWkSpace, chanMin, chanMax, NewRadius, CentPos, spec_idList);
1409 const int chanMax,
double Radius,
const Kernel::V3D &CentPos,
1410 string &spec_idList) {
1416 std::shared_ptr<Workspace2D> ws = std::dynamic_pointer_cast<Workspace2D>(Data);
1419 spec_idList.clear();
1422 StatBase.emplace_back(0);
1424 std::vector<double> yvalB;
1425 std::vector<double> errB;
1426 std::vector<double> xvalB;
1427 std::vector<double> YvalB;
1429 double TotBoundaryIntensities = 0;
1430 int nBoundaryCells = 0;
1431 double TotBoundaryVariances = 0;
1434 double minRow = 20000, maxRow = -1, minCol = 20000, maxCol = -1;
1438 std::vector<double> xRef;
1442 size_t workspaceIndex;
1446 throw std::runtime_error(
"No workspaceIndex for detID=" +
std::to_string(DetID));
1450 V3D pixPos = Det->getPos();
1455 V3D dist = pixPos - CentPos;
1459 spec_idList +=
std::to_string(inpWkSpace->getSpectrum(workspaceIndex).getSpectrumNo());
1464 double row =
m_ROW + R1a;
1469 double col =
m_COL + C1a;
1471 if (row > NBadEdges && col > NBadEdges && (
m_NROWS < 0 || row <
m_NROWS - NBadEdges) &&
1473 const auto &histogram = inpWkSpace->y(workspaceIndex);
1475 const auto &histoerrs = inpWkSpace->e(workspaceIndex);
1477 double variance = 0;
1478 for (
int chan = chanMin; chan <= chanMax; chan++) {
1480 variance += histoerrs[chan] * histoerrs[chan];
1486 errB.emplace_back(
sigma);
1487 xvalB.emplace_back(col);
1488 YvalB.emplace_back(row);
1490 xRef.emplace_back(
static_cast<double>(jj));
1495 if ((pixPos - CentPos).norm() > BoundaryRadius) {
1499 TotBoundaryVariances += variance;
1525 auto pX = Kernel::make_cow<HistogramData::HistogramX>(std::move(xRef));
1530 ws->setHistogram(0, Points(pX), Counts(yvalB), CountStandardDeviations(errB));
1531 ws->setHistogram(1, Points(pX), Counts(xvalB));
1532 ws->setHistogram(2, Points(pX), Counts(YvalB));
1537 StatBase[
INRows] = maxRow - minRow + 1;
1538 StatBase[
INCol] = maxCol - minCol + 1;
1566 if (sgn * (
X[0] - time) >= 0)
1569 if (sgn * (time -
X[
X.size() - 1u]) >= 0)
1570 return static_cast<int>(
X.size()) - 1;
1572 size_t end =
X.size() - 1u;
1573 for (
size_t i = 0; i < end; i++) {
1574 if (sgn * (time -
X[i]) >= 0 && sgn * (
X[i + 1u] - time) >= 0)
1575 return static_cast<int>(i);
1592 Varx = params[
IVXX];
1593 Vary = params[
IVYY];
1602 return Rx * Rx < NStdDevPeakSpan * NStdDevPeakSpan * std::max(Varx,
VarxHW) ||
1603 Ry * Ry < NStdDevPeakSpan * NStdDevPeakSpan * std::max(Vary,
VaryHW);
1613 std::ostringstream fun_str;
1615 fun_str <<
"name=BivariateNormal,";
1618 fun_str <<
"CalcVariances=1";
1620 fun_str <<
"CalcVariances=-1";
1626 for (
int i = 0; i < NN; i++) {
1630 return fun_str.str();
1644 const auto it = std::find(nameList.cbegin(), nameList.cend(), oneName);
1645 if (it != nameList.cend()) {
1646 return static_cast<int>(std::distance(nameList.cbegin(), it));
1705 double &Varyy,
const std::vector<double> &StatBase) {
1744 double back = TotBoundaryIntensities / nBoundaryCells;
1745 double backVar = std::max(nBoundaryCells / 50.0, TotBoundaryVariances) / nBoundaryCells / nBoundaryCells;
1746 double IntensVar = Variance + ncells * ncells * backVar;
1748 double relError = .25;
1757 double NSigs = NStdDevPeakSpan;
1759 NSigs = std::max(NStdDevPeakSpan,
1764 str << max<double>(0.0,
back_calc - NSigs * (1 + relError) * sqrt(backVar)) <<
"<Background<"
1765 << (back + NSigs * (1.8 + relError) * sqrt(backVar)) <<
","
1766 << max<double>(0.0,
Intensity_calc - NSigs * (1 + relError) * sqrt(IntensVar)) <<
"<Intensity<"
1769 double min = max<double>(0.0,
back_calc - NSigs * (1 + relError) * sqrt(backVar));
1770 double maxx = back + NSigs * (1.8 + relError) * sqrt(backVar);
1771 Bounds.emplace_back(min, maxx);
1772 Bounds.emplace_back(max<double>(0.0,
Intensity_calc - NSigs * (1 + relError) * sqrt(IntensVar)),
1774 double relErr1 = relError * .75;
1776 double minn = std::max(
MinCol - .5, (1 - relErr1) * val);
1777 maxx = std::min((1 + relErr1) * val,
MaxCol + .5);
1779 str <<
"," << minn <<
"<"
1782 Bounds.emplace_back(minn, maxx);
1786 minn = std::max(
MinRow - .5, (1 - relErr1) * val);
1787 maxx = std::min((1 + relErr1) * val,
MaxRow + .5);
1788 str <<
"," << minn <<
"<"
1791 Bounds.emplace_back(minn, maxx);
1795 double valmin = val;
1796 double valmax = val;
1798 valmin = std::min(val,
VarxHW);
1799 valmax = std::max(val,
VarxHW);
1803 str <<
"," << (1 - relErr1) * valmin <<
"<"
1805 <<
"<" << (1 + relErr1) * valmax;
1806 Bounds.emplace_back((1 - relErr1) * valmin, (1 + relErr1) * valmax);
1812 valmin = std::min(val,
VaryHW);
1813 valmax = std::max(val,
VaryHW);
1815 str <<
"," << (1 - relErr1) * valmin <<
"<"
1817 <<
"<" << (1 + relErr1) * valmax;
1818 Bounds.emplace_back((1 - relErr1) * valmin, (1 + relErr1) * valmax);
1839 std::vector<string> &names, std::vector<double> ¶ms, std::vector<double> &errs,
1840 double lastRow,
double lastCol,
double neighborRadius) {
1843 std::vector<std::pair<double, double>> Bounds;
1848 std::string SSS(
" Fit string ");
1853 fit_alg->setPropertyValue(
"Function", fun_str);
1855 fit_alg->setProperty(
"InputWorkspace", Data);
1856 fit_alg->setProperty(
"WorkspaceIndex", 0);
1857 fit_alg->setProperty(
"StartX", 0.0);
1858 fit_alg->setProperty(
"EndX", 0.0 +
static_cast<double>(
m_NeighborIDs[1]));
1859 fit_alg->setProperty(
"MaxIterations", 5000);
1860 fit_alg->setProperty(
"CreateOutput",
true);
1862 fit_alg->setProperty(
"Output",
"out");
1864 fit_alg->setProperty(
"MaxIterations", 50);
1867 if (tie.length() >
static_cast<size_t>(0))
1868 fit_alg->setProperty(
"Ties", tie);
1869 if (Constraints.length() >
static_cast<size_t>(0))
1870 fit_alg->setProperty(
"Constraints", Constraints);
1872 fit_alg->executeAsChildAlg();
1874 chisqOverDOF = fit_alg->getProperty(
"OutputChi2overDoF");
1875 std::string outputStatus = fit_alg->getProperty(
"OutputStatus");
1876 g_log.
debug() <<
"Chisq/OutputStatus=" << chisqOverDOF <<
"/" << outputStatus <<
'\n';
1882 for (
int prm = 0; prm < static_cast<int>(RRes->rowCount()) - 1; prm++) {
1883 names.emplace_back(RRes->getRef<
string>(
"Name", prm));
1884 params.emplace_back(RRes->getRef<
double>(
"Value", prm));
1885 double error = RRes->getRef<
double>(
"Error", prm);
1886 errs.emplace_back(
error);
1888 if (names.size() < 5) {
1892 double Varxx, Varxy, Varyy;
1895 params.emplace_back(Varxx);
1896 params.emplace_back(Varyy);
1897 params.emplace_back(Varxy);
1898 errs.emplace_back(0);
1899 errs.emplace_back(0);
1900 errs.emplace_back(0);
1903 }
catch (std::exception &Ex1)
1906 g_log.
error() <<
"Bivariate Error for PeakNum=" <<
static_cast<int>(
getProperty(
"PeakIndex")) <<
":"
1907 << std::string(Ex1.what()) <<
'\n';
1910 g_log.
error() <<
"Bivariate Error A for peakNum=" <<
static_cast<int>(
getProperty(
"PeakIndex")) <<
'\n';
1915 g_log.
debug() <<
" Thru Algorithm: chiSq=" << setw(7) << chisqOverDOF <<
'\n';
1916 g_log.
debug() <<
" Row,Col Radius=" << lastRow <<
"," << lastCol <<
"," << neighborRadius <<
'\n';
1918 double sqrtChisq = -1;
1919 if (chisqOverDOF >= 0)
1920 sqrtChisq = (chisqOverDOF);
1924 sqrtChisq =
SQRT(sqrtChisq);
1926 for (
size_t kk = 0; kk < params.size(); kk++) {
1927 g_log.
debug() <<
" Parameter " << setw(8) << names[kk] <<
" " << setw(8) << params[kk];
1929 g_log.
debug() <<
"(" << setw(8) << (errs[kk] * sqrtChisq) <<
")";
1930 if (Bounds.size() > kk) {
1931 pair<double, double> upLow = Bounds[kk];
1932 g_log.
debug() <<
" Bounds(" << upLow.first <<
"," << upLow.second <<
")";
1959 std::vector<string> &names, std::vector<double> ¶ms, std::vector<double> &errs,
1960 double lastRow,
double lastCol,
double neighborRadius) {
1973 double minChiSqOverDOF = -1;
1974 double Bestparams[7];
1975 std::string Bestnames[7];
1976 for (
int i = 0; i < N; i++) {
1977 Fit(Data, chisqOverDOF, done, names, params, errs, lastRow, lastCol, neighborRadius);
1978 g_log.
debug() <<
"-----------------------" << i <<
"--------------------------\n";
1979 if ((minChiSqOverDOF < 0 || chisqOverDOF < minChiSqOverDOF) && (chisqOverDOF > 0) && !done) {
1980 for (
int j = 0; j < NParams; j++) {
1984 minChiSqOverDOF = chisqOverDOF;
1994 for (
int j = 0; j < NParams; j++)
1998 for (
int i = 0; i < NParams; i++) {
2000 if (k >= 0 && k < NParams)
2004 Fit(Data, chisqOverDOF, done, names, params, errs, lastRow, lastCol, neighborRadius);
2018 std::vector<std::string>
const &names,
double chisqOverDOF) {
2021 throw std::runtime_error(
"Irrecoverable inconsistency found. The index for the "
2022 "parameter 'Background' is lower than zero.");
2026 throw std::runtime_error(
"Irrecoverable inconsistency found. The index for the "
2027 "parameter 'Intensity' is lower than zero.");
2029 if (chisqOverDOF < 0) {
2031 g_log.
debug() <<
" Bad Slice- negative chiSq= " << chisqOverDOF <<
'\n';
2036 int NBadEdgeCells =
getProperty(
"NBadEdgePixels");
2037 NBadEdgeCells =
static_cast<int>(.6 * NBadEdgeCells);
2047 g_log.
debug() <<
" Bad Slice. Negative Counts= "
2055 if ((x < MinGoodRatioFitvsExpIntenisites || x > MaxGoodRatioFitvsExpIntenisites) &&
2059 g_log.
debug() <<
" Bad Slice. Fitted Intensity & Observed "
2060 "Intensity(-back) too different. ratio="
2066 bool GoodNums =
true;
2067 bool paramBad =
false;
2068 auto BadParamNum =
static_cast<size_t>(-1);
2069 for (
size_t i = 0; i < errs.size(); i++)
2070 if (errs[i] != errs[i]) {
2074 }
else if (errs[i] < 0) {
2078 }
else if (params[i] != params[i]) {
2085 std::string
obj =
" parameter ";
2088 g_log.
debug() <<
" Bad Slice." <<
obj << BadParamNum <<
" is not a number\n";
2094 std::string Err(
"back ground is negative");
2095 if (params[Ibk] < -.002)
2099 Err =
"Intensity is negative";
2100 if (params[IIntensity] < 0)
2104 double IsawVariance =
m_AttributeValues->CalcISAWIntensityVariance(params.data(), errs.data(), chisqOverDOF);
2106 Err =
"Isaw Variance is negative";
2107 if (IsawVariance > 0) {
2110 if (IsawIntensity * IsawIntensity / IsawVariance < MinGoodIoverSigI * MinGoodIoverSigI)
2125 double maxPeakHeightTheoretical =
2131 if (maxPeakHeightTheoretical < 2 * AvHeight || AvHeight < 0 || maxPeakHeightTheoretical < 0) {
2133 g_log.
debug() <<
" Bad Slice. Peak too small= " << maxPeakHeightTheoretical <<
"/" << AvHeight <<
'\n';
2138 if (maxPeakHeightTheoretical < 1 && (params[
IVXX] > Nrows * Nrows / 4 || params[
IVYY] > Nrows * Nrows / 4)) {
2146 g_log.
debug() <<
" Bad Slice. Too steep of an exponential\n";
2161 double Varx, Vary, Cov;
2174 Varx = ParameterValues[
IVXX];
2175 Vary = ParameterValues[
IVYY];
2176 Cov = ParameterValues[
IVXY];
2181 if (Varx < MinVariationInXYvalues || Vary < MinVariationInXYvalues)
2184 if (Cov * Cov > MaxCorrCoeffinXY * Varx * Vary)
2203 const double ChiSqOverDOF,
const double TotVariance,
2206 double B = TotVariance / ncells;
2207 if (B < ChiSqOverDOF)
2210 double Variance = TotVariance + (backError * backError * B) * ncells * ncells +
background * ncells;
2212 return SQRT(Variance);
2222 TabWS->addColumn(
"double",
"Time");
2223 TabWS->addColumn(
"double",
"Channel");
2224 TabWS->addColumn(
"double",
"Background");
2225 TabWS->addColumn(
"double",
"Intensity");
2226 TabWS->addColumn(
"double",
"Mcol");
2227 TabWS->addColumn(
"double",
"Mrow");
2228 TabWS->addColumn(
"double",
"SScol");
2229 TabWS->addColumn(
"double",
"SSrow");
2230 TabWS->addColumn(
"double",
"SSrc");
2231 TabWS->addColumn(
"double",
"NCells");
2232 TabWS->addColumn(
"double",
"ChiSqrOverDOF");
2233 TabWS->addColumn(
"double",
"TotIntensity");
2234 TabWS->addColumn(
"double",
"BackgroundError");
2235 TabWS->addColumn(
"double",
"FitIntensityError");
2236 TabWS->addColumn(
"double",
"ISAWIntensity");
2237 TabWS->addColumn(
"double",
"ISAWIntensityError");
2238 TabWS->addColumn(
"double",
"TotalBoundary");
2239 TabWS->addColumn(
"double",
"NBoundaryCells");
2240 TabWS->addColumn(
"double",
"Start Row");
2241 TabWS->addColumn(
"double",
"End Row");
2242 TabWS->addColumn(
"double",
"Start Col");
2243 TabWS->addColumn(
"double",
"End Col");
2244 TabWS->addColumn(
"double",
"TotIntensityError");
2245 TabWS->addColumn(
"str",
"SpecIDs");
2266 std::vector<double>
const ¶ms, std::vector<double>
const &errs,
2267 std::vector<std::string>
const &names,
const double Chisq,
2268 const double time,
string spec_idList) {
2277 if (Ibk < 0 || IIntensity < 0 || IVx < 0 || IVy < 0 || IVxy < 0 || Irow < 0 || Icol < 0) {
2278 throw std::runtime_error(
"Inconsistency found when updating output "
2279 "workspace. None of the indices for the "
2280 "parameters 'Background', 'Intensity', 'SScol', "
2281 "'SSrow', 'SSrc', 'Mrow', 'Mcol' can be "
2285 int newRowIndex = 0;
2288 newRowIndex =
static_cast<int>(TabWS->rowCount());
2290 auto TableRow =
static_cast<int>(TabWS->insertRow(newRowIndex));
2295 TabWS->getRef<
double>(std::string(
"Background"),
TableRow) = params[Ibk];
2296 TabWS->getRef<
double>(std::string(
"Channel"),
TableRow) = chan;
2298 TabWS->getRef<
double>(std::string(
"Intensity"),
TableRow) = params[IIntensity];
2299 TabWS->getRef<
double>(std::string(
"FitIntensityError"),
TableRow) = errs[IIntensity] * sqrt(chisq);
2300 TabWS->getRef<
double>(std::string(
"Mcol"),
TableRow) = params[Icol];
2301 TabWS->getRef<
double>(std::string(
"Mrow"),
TableRow) = params[Irow];
2303 TabWS->getRef<
double>(std::string(
"SScol"),
TableRow) = params[IVx];
2304 TabWS->getRef<
double>(std::string(
"SSrow"),
TableRow) = params[IVy];
2306 TabWS->getRef<
double>(std::string(
"SSrc"),
TableRow) = params[IVxy];
2307 TabWS->getRef<
double>(std::string(
"NCells"),
TableRow) = ncells;
2308 TabWS->getRef<
double>(std::string(
"ChiSqrOverDOF"),
TableRow) = chisq;
2311 TabWS->getRef<
double>(std::string(
"BackgroundError"),
TableRow) = errs[Ibk] *
SQRT(chisq);
2318 TabWS->getRef<
double>(std::string(
"ISAWIntensityError"),
TableRow) =
2319 sqrt(
m_AttributeValues->CalcISAWIntensityVariance(params.data(), errs.data(), Chisq));
2325 TabWS->getRef<
double>(std::string(
"Time"),
TableRow) = time;
2331 TabWS->getRef<
double>(std::string(
"End Row"),
TableRow) =
2335 TabWS->getRef<
double>(std::string(
"End Col"),
TableRow) =
2338 TabWS->getRef<
string>(std::string(
"SpecIDs"),
TableRow) = std::move(spec_idList);
2358 std::vector<std::string>
const &names,
double &TotVariance,
2359 double &TotIntensity,
double const TotSliceIntensity,
2360 double const TotSliceVariance,
double const chisqdivDOF,
2370 err =
m_AttributeValues->CalcISAWIntensityVariance(params.data(), errs.data(), chisqdivDOF);
2376 g_log.
debug() <<
"TotIntensity/TotVariance=" << TotIntensity <<
"/" << TotVariance <<
'\n';
2410 double alpha = .5 * (r - 1.0);
2411 alpha = std::min(1.0, alpha);
2434 double IntensityBackError = errs[
IBACK] * sqrt(B);
2436 ExperimVar += IntensityBackError * IntensityBackError * ncells * ncells + params[
IBACK] * ncells;
2439 double alpha = .5 * (r - 1.0);
2440 alpha = std::min(1.0, alpha);
2458 int maxCol = minCol +
static_cast<int>(
StatBase[
INCol]) - 1;
2461 if (params[
IVXX] <= 0 || params[
IVYY] <= 0)
2467 double NstdX = 4 * min<double>(params[
IXMEAN] - minCol, maxCol - params[
IXMEAN]) / sqrt(params[
IVXX]);
2469 double NstdY = 4 * min<double>(params[
IYMEAN] - minRow, maxRow - params[
IYMEAN]) / sqrt(params[
IVYY]);
2476 if (sgn * NstdX < 9) {
2477 auto xx =
static_cast<int>(sgn * NstdX);
2478 double a = probs[xx];
2482 P = a + (b - a) * (sgn * NstdX - xx);
2495 if (sgn * NstdY < 9) {
2496 auto xx =
static_cast<int>(sgn * NstdY);
2497 double a = probs[xx];
2501 P = a + (b - a) * (sgn * NstdY - xx);
2510 r = std::max(r, 1.0);
#define DECLARE_ALGORITHM(classname)
#define UNUSED_ARG(x)
Function arguments are sometimes unused in certain implmentations but are required for documentation ...
double obj
the value of the quadratic function
Base class from which all concrete algorithm classes should be derived.
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
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.
void deprecatedDate(const std::string &)
The date the algorithm was deprecated on.
Helper class for reporting progress from algorithms.
TableRow represents a row in a TableWorkspace.
A property class for workspaces.
Integrates each time slice using the BivariateNormal formula, adding the results to the peak object.
void setHeightHalfWidthInfo(const MantidVec &xvals, const MantidVec &yvals, const MantidVec &counts)
For edge peaks, the sample standard deviations do not work.
double CalcISAWIntensity(const double *params)
Calculates the Intensity designed for Edge Peaks.
double CalcISAWIntensityVariance(const double *params, const double *errs, double chiSqOvDOF)
Calculates the Error in the Intensity designed for Edge Peaks.
std::vector< double > InitValues(double Varx, double Vary, double b)
Returns init values with background and variances replaced by arguments.
bool isEdgePeak(const double *params, int nparams)
Determines if a Peak is an edge peak.
Kernel::V3D currentPosition
bool CalcVariances()
Determines whether the Variances can be calculated.
double getNewRCRadius()
Calculates the new radius for neighborhoods so as to include almost all of a peak.
void CalcVariancesFromData(double background, double meanx, double meany, double &Varxx, double &Varxy, double &Varyy, const std::vector< double > &StatBase)
Utility method to calculate variances from data given background and means.
double HalfWidthAtHalfHeightRadius
double CalcSampleIntensityMultiplier(const double *params) const
For Edge Peaks.
std::vector< double > GetParams(double b)
Calculates the initial values of the parameters given background b.
bool IsEnoughData(const double *ParameterValues, Kernel::Logger &)
Calculates if there is enough data to for there to be a peak.
std::string CalcConstraints(std::vector< std::pair< double, double > > &Bounds, bool CalcVariances)
Calculates the string form of the constraints to be sent to the Fit Algorithm and also saves it in a ...
bool setStatBase(std::vector< double > const &StatBase)
Sets the Accumulated data values into this class, then updates other information like initial values.
std::vector< double > StatBase
~IntegratePeakTimeSlices() override
Destructor.
void SetUpData1(API::MatrixWorkspace_sptr &Data, API::MatrixWorkspace_const_sptr const &inpWkSpace, const int chanMin, const int chanMax, double Radius, const Kernel::V3D &CentPos, std::string &spec_idList)
Prepares the data for futher analysis adding meta data and marking data on the edges of detectors.
void FindPlane(Kernel::V3D ¢er, Kernel::V3D &xvec, Kernel::V3D &yvec, double &ROW, double &COL, int &NROWS, int &NCOLS, double &pixWidthx, double &pixHeighty, DataObjects::Peak const &peak) const
For NonFlat banks, this determines the data of a small planar region approximating the instrument clo...
void Fit(const API::MatrixWorkspace_sptr &Data, double &chisqOverDOF, bool &done, std::vector< std::string > &names, std::vector< double > ¶ms, std::vector< double > &errs, double lastRow, double lastCol, double neighborRadius)
Sets up data for the Fit Algorithm call and invokes it.
int CalculateTimeChannelSpan(Geometry::IPeak const &peak, const double dQ, const Mantid::HistogramData::HistogramX &X, const int specNum, int &Centerchan)
Calculates the span of channels needed to encompass all data around the peak with Q values within dQ ...
std::string m_AttributeNames[20]
double m_COL
for Describing the Column(or 0) describing the center of the
double CalculatePositionSpan(DataObjects::Peak const &peak, const double dQ)
Calculates the span in rows and columns needed to include all data within dQ of the specified peak.
IntegratePeakTimeSlices()
Default constructor.
std::array< double, 7 > m_ParameterValues
double CalculateIsawIntegrateError(const double background, const double backError, const double ChiSqOverDOF, const double TotVariance, const int ncells)
Calculates the error in integration closest to the latest ISAW calculations.
void exec() override
Executes this algorithm.
std::string CalculateFunctionProperty_Fit()
Calculates the string for the Function Property of the Fit Algorithm.
Mantid::detid2index_map m_wi_to_detid_map
Kernel::V3D m_center
for Describing the Plane at the Peak
Kernel::V3D m_yvec
for Describing the Plane at the Peak
std::string m_ParameterNames[7]
Kernel::V3D m_xvec
for Describing the Plane at the Peak
void SetUpData(API::MatrixWorkspace_sptr &Data, API::MatrixWorkspace_const_sptr const &inpWkSpace, const std::shared_ptr< Geometry::IComponent > &comp, const int chanMin, const int chanMax, double CentX, double CentY, Kernel::V3D &CentNghbr, double &neighborRadius, double Radius, std::string &spec_idList)
Initial phase at converting Detector data to workspace data that will be sent to the Fit Function,...
std::shared_ptr< DataModeHandler > m_AttributeValues
void init() override
Virtual method - must be overridden by concrete algorithm.
double m_ROW
for Describing the Row(or 0) describing the center of the Peak
double m_cellHeight
for Describing the Plane at the Peak
bool getNeighborPixIDs(const std::shared_ptr< Geometry::IComponent > &comp, const Kernel::V3D &Center, double &Radius, int *&ArryofID)
Finds all neighbors within a given Radius of the Center on the given component.
int findNameInVector(std::string const &oneName, std::vector< std::string > const &nameList)
Utility to find a name in a vector of strings.
double m_R0
for Weak Peaks, these can be set using info from close
void updateStats(const double intensity, const double variance, const double row, const double col, std::vector< double > &StatBase)
Updates the cumulative statistics for the data being considered.
void InitializeColumnNamesInTableWorkspace(DataObjects::TableWorkspace_sptr &TabWS)
Initializes the column names in the output table workspace.
bool updateNeighbors(const std::shared_ptr< Geometry::IComponent > &comp, const Kernel::V3D &CentPos, const Kernel::V3D &oldCenter, double NewRadius, double &neighborRadius)
Checks and updates if needed the list of m_NeighborIDs.
int UpdateOutputWS(DataObjects::TableWorkspace_sptr &TabWS, const int dir, const double chan, std::vector< double > const ¶ms, std::vector< double > const &errs, std::vector< std::string > const &names, const double Chisq, const double time, std::string spec_idList)
Updates the information in the output OutputWorkspace.
void PreFit(const API::MatrixWorkspace_sptr &Data, double &chisqOverDOF, bool &done, std::vector< std::string > &names, std::vector< double > ¶ms, std::vector< double > &errs, double lastRow, double lastCol, double neighborRadius)
Tests several starting points in the Marquardt algorithm then calls Fit.
bool isGoodFit(std::vector< double > const ¶ms, std::vector< double > const &errs, std::vector< std::string > const &names, double chisqOverDOF)
Determines if the list of parameters and errors represent a "good" fit.
int findTimeChannel(const Mantid::HistogramData::HistogramX &X, const double time)
Finds the time channel with the given time in.
void updatePeakInformation(std::vector< double > const ¶ms, std::vector< double > const &errs, std::vector< std::string > const &names, double &TotVariance, double &TotIntensity, double const TotSliceIntensity, double const TotSliceVariance, double const chisqdivDOF, const int ncells)
Updates m_AttributeValues with this peak information from this time slice.
A generic fitting algorithm.
Structure describing a single-crystal peak.
int getCol() const override
For RectangularDetectors only, returns the column (x) of the pixel of the detector or -1 if not found...
Geometry::Instrument_const_sptr getInstrument() const
Return a shared ptr to the instrument for this peak.
int getRow() const override
For RectangularDetectors only, returns the row (y) of the pixel of the detector or -1 if not found.
Mantid::Kernel::V3D getQLabFrame() const override
Return the Q change (of the lattice, k_i - k_f) for this peak.
int getDetectorID() const override
Get the ID of the detector at the center of the peak
Geometry::IDetector_const_sptr getDetector() const
Return a shared ptr to the detector at center of peak.
virtual Mantid::Kernel::V3D getDetPos() const
Return the detector position vector.
const std::string & getBankName() const
Find the name of the bank that is the parent of the detector.
A simple structure that defines an axis-aligned cuboid shaped bounding box for a geometrical object.
bool isPointInside(const Kernel::V3D &point) const
Is the given point within the bounding box?
double xMax() const
Return the maximum value of X.
double zMin() const
Return the minimum value of Z.
double zMax() const
Return the maximum value of Z.
double yMax() const
Return the maximum value of Y.
double xMin() const
Return the minimum value of X.
double yMin() const
Return the minimum value of Y.
Structure describing a single-crystal peak.
virtual double getTOF() const =0
virtual Mantid::Kernel::V3D getQLabFrame() const =0
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
The Logger class is in charge of the publishing messages from the framework through various channels.
void debug(const std::string &msg)
Logs at debug level.
void error(const std::string &msg)
Logs at error level.
void report()
Increments the loop counter by 1, then sends the progress notification on behalf of its algorithm.
void inverse()
Inverse a quaternion (in the sense of rotation inversion)
void rotate(V3D &) const
Rotate a vector.
std::vector< double > getRotation(bool check_normalisation=false, bool throw_on_errors=false) const
returns the rotation matrix defined by this quaternion as an 9-point
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
constexpr double scalar_prod(const V3D &v) const noexcept
Calculates the cross product.
constexpr double X() const noexcept
Get x.
double normalize()
Make a normalized vector (return norm value)
constexpr double Y() const noexcept
Get y.
void setZ(const double zz) noexcept
Set is z position.
double norm() const noexcept
void setX(const double xx) noexcept
Set is x position.
void setY(const double yy) noexcept
Set is y position.
constexpr double Z() const noexcept
Get z.
std::shared_ptr< ITableWorkspace > ITableWorkspace_sptr
shared pointer to Mantid::API::ITableWorkspace
std::shared_ptr< const MatrixWorkspace > MatrixWorkspace_const_sptr
shared pointer to the matrix workspace base class (const version)
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.
std::shared_ptr< TableWorkspace > TableWorkspace_sptr
shared pointer to Mantid::DataObjects::TableWorkspace
std::shared_ptr< const IComponent > IComponent_const_sptr
Typdef of a shared pointer to a const IComponent.
std::shared_ptr< const Mantid::Geometry::IDetector > IDetector_const_sptr
Shared pointer to IDetector (const version)
std::shared_ptr< const Instrument > Instrument_const_sptr
Shared pointer to an const instrument object.
std::string to_string(const wide_integer< Bits, Signed > &n)
@ Input
An input workspace.
@ Output
An output workspace.