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);
827 std::pair<int, int> CR = ddet->getXYForDetectorID(det->getID());
830 pixWidthx = ddet->xstep();
831 pixHeighty = ddet->ystep();
833 NROWS = ddet->ypixels();
834 NCOLS = ddet->xpixels();
843 std::shared_ptr<const Component> compPanel = std::dynamic_pointer_cast<const Component>(panel);
844 std::shared_ptr<IComponent> panel1(compPanel->base()->clone());
853 panel1->getBoundingBox(B);
855 NROWS = boost::math::iround((B.
yMax() - B.
yMin()) / pixHeighty);
856 NCOLS = boost::math::iround((B.
xMax() - B.
xMin()) / pixWidthx);
869 const double col, std::vector<double> &StatBase) {
874 StatBase[
ISSxx] += col * col;
875 StatBase[
ISSyy] += row * row;
876 StatBase[
ISSxy] += row * col;
879 StatBase[
ISSx] += col;
880 StatBase[
ISSy] += row;
897 std::vector<double> Res(7);
920 if (sigy * NstdY < 7 && sigy * NstdY >= 0)
922 x = probs[std::lround(sigy * NstdY)];
931 if (sigx * NstdX < 7 && sigx * NstdX > 0)
933 x1 = probs[std::lround(sigx * NstdX)];
970 if (Rx * Rx < 4 * Varx || Ry * Ry < 4 * Vary) {
974 return std::vector<double>();
984 double col = Mx / Den;
985 double row = My / Den;
986 std::vector<double>
Result(7);
1007 auto nBoundaryCells =
static_cast<int>(statBase[
INBoundary]);
1010 if (nBoundaryCells > 0) {
1011 double TotBoundaryIntensities = statBase[
ITotBoundary];
1012 b = TotBoundaryIntensities / nBoundaryCells;
1015 auto nCells =
static_cast<int>(statBase[
ISS1]);
1018 while (Den <= 0 && b != 0) {
1029 Varx = statBase[
INCol] / 7;
1030 Vary = statBase[
INRows] / 7;
1038 Ry * Ry < 4 * std::max(Vary,
VaryHW))
1060 double Mx = 0, My = 0, Sxx = 0, Syy = 0, Sxy = 0;
1062 double RangeX = statBase[
INCol] / 2;
1063 double RangeY = statBase[
INRows] / 2;
1065 while (!done && ntimes < 29) {
1066 Mx = statBase[
ISSIx] - b * statBase[
ISSx];
1067 My = statBase[
ISSIy] - b * statBase[
ISSy];
1068 Sxx = (statBase[
ISSIxx] - b * statBase[
ISSxx] - Mx * Mx / Den) / Den;
1069 Syy = (statBase[
ISSIyy] - b * statBase[
ISSyy] - My * My / Den) / Den;
1070 Sxy = (statBase[
ISSIxy] - b * statBase[
ISSxy] - Mx * My / Den) / Den;
1074 if (Sxx <= RangeX / 12 || Syy <= RangeY / 12 || Sxy * Sxy / Sxx / Syy > .9) {
1077 if (ntimes + 1 == 29)
1116 if (Rx * Rx > 4 * Vx)
1121 if (Ry * Ry > 4 * Vy)
1127 double NewRadius = 1.4 * max<double>(MinRowColSpan * max<double>(
CellWidth,
CellHeight), 4.5 * DD);
1128 NewRadius = mult * min<double>(
baseRCRadius, NewRadius);
1147 const std::vector<double> &counts) {
1148 double minCount, maxCount;
1149 const auto &
X = xvals;
1150 const auto &
Y = yvals;
1151 const auto &C = counts;
1154 auto N =
static_cast<int>(
X.size());
1161 minCount = maxCount = C[0];
1165 double lowX, lowY, highX, highY;
1166 lowX = highX =
X[0];
1167 lowY = highY =
Y[0];
1169 for (
int i = 1; i < N; i++) {
1172 else if (
X[i] > highX)
1177 else if (
Y[i] > highY)
1180 if (C[i] > maxCount) {
1185 }
else if (C[i] < minCount) {
1188 }
else if (C[i] == maxCount)
1195 if (minCount == maxCount)
1201 double dCount = std::max(.51, (maxCount - minCount) / 6.2);
1202 double CountUp = (maxCount + minCount) / 2 + dCount;
1203 double CountLow = (maxCount + minCount) / 2 - dCount;
1204 double dSpanx = (highX - lowX) / 6.;
1205 double dSpany = (highY - lowY) / 6.0;
1211 double offset = std::max(.2, (maxCount - minCount) / 20);
1212 double TotR_max = 0;
1213 double TotR_min = 0;
1218 for (
int i = 0; i < N; i++) {
1219 if (C[i] > maxCount - offset) {
1222 TotR_max += C[i] * sqrt((
X[i] - MaxX) * (
X[i] - MaxX) + (
Y[i] - MaxY) * (
Y[i] - MaxY));
1224 if (C[i] < minCount + offset)
1230 TotR_min += C[i] * sqrt((
X[i] - MaxX) * (
X[i] - MaxX) + (
Y[i] - MaxY) * (
Y[i] - MaxY));
1233 if (
fabs(MaxY -
Y[i]) < 1.2 &&
fabs(MaxX -
X[i]) > 1.2 && C[i] >= CountLow && C[i] <= CountUp &&
1234 fabs(MaxX -
X[i]) < dSpanx) {
1235 TotRx0 += (C[i] - minCount) * (
X[i] - MaxX) * (
X[i] - MaxX);
1236 TotCx += C[i] - minCount;
1239 if (
fabs(MaxX -
X[i]) < 1.2 &&
fabs(MaxY -
Y[i]) > 1.2 && C[i] >= CountLow && C[i] <= CountUp &&
1240 fabs(MaxY -
Y[i]) < dSpany) {
1241 TotRy0 += (C[i] - minCount) * (
Y[i] - MaxY) * (
Y[i] - MaxY);
1242 TotCy += C[i] - minCount;
1246 if (nMax + nMin == N)
1252 double AvR = .5 * (TotR_max / TotMax + TotR_min / TotMin);
1260 double TotR = 0, nR = -1, nRx = -1, nRy = -1;
1261 double MidVal = (TotMax / nMax + TotMin / nMin) / 2.0;
1262 double TotRx = 0, TotRy = 0;
1263 while ((nR <= 0 || nRy <= 0 || nRx <= 0) && offset < MidVal) {
1271 for (
int i = 0; i < N; i++)
1272 if (C[i] < MidVal + offset && C[i] > MidVal - offset) {
1273 double X1 =
X[i] - MaxX;
1274 double Y1 =
Y[i] - MaxY;
1275 TotR += sqrt(X1 * X1 + Y1 * Y1);
1277 if ((X1 >= -1.2 && X1 <= 1.2) &&
fabs(Y1) > 1.2 &&
fabs(Y1) < dSpany) {
1281 if ((Y1 >= -1.2 && Y1 <= 1.2) &&
fabs(X1) > 1.2 &&
fabs(X1) < dSpanx) {
1289 double AvR = TotR / nR;
1293 VarxHW = (TotRx / nRx) * (TotRx / nRx) / .8326 / .8326;
1295 VarxHW = TotRx0 * TotRx0 / TotCx / TotCx / .8326 / .8326;
1302 VaryHW = (TotRy / nRy) * (TotRy / nRy) / .8326 / .8326;
1304 VaryHW = TotRy0 * TotRy0 / TotCy / TotCy / .8326 / .8326;
1330 const std::shared_ptr<Geometry::IComponent> &comp,
const int chanMin,
1331 const int chanMax,
double CentX,
double CentY,
Kernel::V3D &CentNghbr,
1332 double &neighborRadius,
1333 double Radius,
string &spec_idList) {
1337 int NBadEdgeCells =
getProperty(
"NBadEdgePixels");
1341 NBadEdgeCells,
m_NROWS - NBadEdgeCells);
1347 SetUpData1(Data, inpWkSpace, chanMin, chanMax, Radius, CentPos1, spec_idList);
1363 double DD = (CentPos - CentNghbr).norm();
1365 if (DD + NewRadius > neighborRadius) {
1366 auto NN = int(NStdDevPeakSpan * NeighborhoodRadiusDivPeakRadius * NewRadius /
m_cellWidth * NStdDevPeakSpan *
1367 NeighborhoodRadiusDivPeakRadius * NewRadius /
m_cellHeight);
1375 neighborRadius = NeighborhoodRadiusDivPeakRadius * NewRadius;
1376 CentNghbr = CentPos;
1380 neighborRadius -= DD;
1385 NBadEdgeCells,
m_NROWS - NBadEdgeCells);
1390 SetUpData1(Data, inpWkSpace, chanMin, chanMax, NewRadius, CentPos, spec_idList);
1406 const int chanMax,
double Radius,
const Kernel::V3D &CentPos,
1407 string &spec_idList) {
1413 std::shared_ptr<Workspace2D> ws = std::dynamic_pointer_cast<Workspace2D>(Data);
1416 spec_idList.clear();
1419 StatBase.emplace_back(0);
1421 std::vector<double> yvalB;
1422 std::vector<double> errB;
1423 std::vector<double> xvalB;
1424 std::vector<double> YvalB;
1426 double TotBoundaryIntensities = 0;
1427 int nBoundaryCells = 0;
1428 double TotBoundaryVariances = 0;
1431 double minRow = 20000, maxRow = -1, minCol = 20000, maxCol = -1;
1435 std::vector<double> xRef;
1439 size_t workspaceIndex;
1443 throw std::runtime_error(
"No workspaceIndex for detID=" +
std::to_string(DetID));
1447 V3D pixPos = Det->getPos();
1452 V3D dist = pixPos - CentPos;
1456 spec_idList +=
std::to_string(inpWkSpace->getSpectrum(workspaceIndex).getSpectrumNo());
1461 double row =
m_ROW + R1a;
1466 double col =
m_COL + C1a;
1468 if (row > NBadEdges && col > NBadEdges && (
m_NROWS < 0 || row <
m_NROWS - NBadEdges) &&
1470 const auto &histogram = inpWkSpace->y(workspaceIndex);
1472 const auto &histoerrs = inpWkSpace->e(workspaceIndex);
1474 double variance = 0;
1475 for (
int chan = chanMin; chan <= chanMax; chan++) {
1477 variance += histoerrs[chan] * histoerrs[chan];
1483 errB.emplace_back(
sigma);
1484 xvalB.emplace_back(col);
1485 YvalB.emplace_back(row);
1487 xRef.emplace_back(
static_cast<double>(jj));
1492 if ((pixPos - CentPos).norm() > BoundaryRadius) {
1496 TotBoundaryVariances += variance;
1522 auto pX = Kernel::make_cow<HistogramData::HistogramX>(std::move(xRef));
1527 ws->setHistogram(0, Points(pX), Counts(yvalB), CountStandardDeviations(errB));
1528 ws->setHistogram(1, Points(pX), Counts(xvalB));
1529 ws->setHistogram(2, Points(pX), Counts(YvalB));
1534 StatBase[
INRows] = maxRow - minRow + 1;
1535 StatBase[
INCol] = maxCol - minCol + 1;
1563 if (sgn * (
X[0] - time) >= 0)
1566 if (sgn * (time -
X[
X.size() - 1u]) >= 0)
1567 return static_cast<int>(
X.size()) - 1;
1569 size_t end =
X.size() - 1u;
1570 for (
size_t i = 0; i < end; i++) {
1571 if (sgn * (time -
X[i]) >= 0 && sgn * (
X[i + 1u] - time) >= 0)
1572 return static_cast<int>(i);
1589 Varx = params[
IVXX];
1590 Vary = params[
IVYY];
1599 return Rx * Rx < NStdDevPeakSpan * NStdDevPeakSpan * std::max(Varx,
VarxHW) ||
1600 Ry * Ry < NStdDevPeakSpan * NStdDevPeakSpan * std::max(Vary,
VaryHW);
1610 std::ostringstream fun_str;
1612 fun_str <<
"name=BivariateNormal,";
1615 fun_str <<
"CalcVariances=1";
1617 fun_str <<
"CalcVariances=-1";
1623 for (
int i = 0; i < NN; i++) {
1627 return fun_str.str();
1641 const auto it = std::find(nameList.cbegin(), nameList.cend(), oneName);
1642 if (it != nameList.cend()) {
1643 return static_cast<int>(std::distance(nameList.cbegin(), it));
1702 double &Varyy,
const std::vector<double> &StatBase) {
1741 double back = TotBoundaryIntensities / nBoundaryCells;
1742 double backVar = std::max(nBoundaryCells / 50.0, TotBoundaryVariances) / nBoundaryCells / nBoundaryCells;
1743 double IntensVar = Variance + ncells * ncells * backVar;
1745 double relError = .25;
1754 double NSigs = NStdDevPeakSpan;
1756 NSigs = std::max(NStdDevPeakSpan,
1761 str << max<double>(0.0,
back_calc - NSigs * (1 + relError) * sqrt(backVar)) <<
"<Background<"
1762 << (back + NSigs * (1.8 + relError) * sqrt(backVar)) <<
","
1763 << max<double>(0.0,
Intensity_calc - NSigs * (1 + relError) * sqrt(IntensVar)) <<
"<Intensity<"
1766 double min = max<double>(0.0,
back_calc - NSigs * (1 + relError) * sqrt(backVar));
1767 double maxx = back + NSigs * (1.8 + relError) * sqrt(backVar);
1768 Bounds.emplace_back(min, maxx);
1769 Bounds.emplace_back(max<double>(0.0,
Intensity_calc - NSigs * (1 + relError) * sqrt(IntensVar)),
1771 double relErr1 = relError * .75;
1773 double minn = std::max(
MinCol - .5, (1 - relErr1) * val);
1774 maxx = std::min((1 + relErr1) * val,
MaxCol + .5);
1776 str <<
"," << minn <<
"<"
1779 Bounds.emplace_back(minn, maxx);
1783 minn = std::max(
MinRow - .5, (1 - relErr1) * val);
1784 maxx = std::min((1 + relErr1) * val,
MaxRow + .5);
1785 str <<
"," << minn <<
"<"
1788 Bounds.emplace_back(minn, maxx);
1792 double valmin = val;
1793 double valmax = val;
1795 valmin = std::min(val,
VarxHW);
1796 valmax = std::max(val,
VarxHW);
1800 str <<
"," << (1 - relErr1) * valmin <<
"<"
1802 <<
"<" << (1 + relErr1) * valmax;
1803 Bounds.emplace_back((1 - relErr1) * valmin, (1 + relErr1) * valmax);
1809 valmin = std::min(val,
VaryHW);
1810 valmax = std::max(val,
VaryHW);
1812 str <<
"," << (1 - relErr1) * valmin <<
"<"
1814 <<
"<" << (1 + relErr1) * valmax;
1815 Bounds.emplace_back((1 - relErr1) * valmin, (1 + relErr1) * valmax);
1836 std::vector<string> &names, std::vector<double> ¶ms, std::vector<double> &errs,
1837 double lastRow,
double lastCol,
double neighborRadius) {
1840 std::vector<std::pair<double, double>> Bounds;
1845 std::string SSS(
" Fit string ");
1850 fit_alg->setPropertyValue(
"Function", fun_str);
1852 fit_alg->setProperty(
"InputWorkspace", Data);
1853 fit_alg->setProperty(
"WorkspaceIndex", 0);
1854 fit_alg->setProperty(
"StartX", 0.0);
1855 fit_alg->setProperty(
"EndX", 0.0 +
static_cast<double>(
m_NeighborIDs[1]));
1856 fit_alg->setProperty(
"MaxIterations", 5000);
1857 fit_alg->setProperty(
"CreateOutput",
true);
1859 fit_alg->setProperty(
"Output",
"out");
1861 fit_alg->setProperty(
"MaxIterations", 50);
1864 if (tie.length() >
static_cast<size_t>(0))
1865 fit_alg->setProperty(
"Ties", tie);
1866 if (Constraints.length() >
static_cast<size_t>(0))
1867 fit_alg->setProperty(
"Constraints", Constraints);
1869 fit_alg->executeAsChildAlg();
1871 chisqOverDOF = fit_alg->getProperty(
"OutputChi2overDoF");
1872 std::string outputStatus = fit_alg->getProperty(
"OutputStatus");
1873 g_log.
debug() <<
"Chisq/OutputStatus=" << chisqOverDOF <<
"/" << outputStatus <<
'\n';
1879 for (
int prm = 0; prm < static_cast<int>(RRes->rowCount()) - 1; prm++) {
1880 names.emplace_back(RRes->getRef<
string>(
"Name", prm));
1881 params.emplace_back(RRes->getRef<
double>(
"Value", prm));
1882 double error = RRes->getRef<
double>(
"Error", prm);
1883 errs.emplace_back(
error);
1885 if (names.size() < 5) {
1889 double Varxx, Varxy, Varyy;
1892 params.emplace_back(Varxx);
1893 params.emplace_back(Varyy);
1894 params.emplace_back(Varxy);
1895 errs.emplace_back(0);
1896 errs.emplace_back(0);
1897 errs.emplace_back(0);
1900 }
catch (std::exception &Ex1)
1903 g_log.
error() <<
"Bivariate Error for PeakNum=" <<
static_cast<int>(
getProperty(
"PeakIndex")) <<
":"
1904 << std::string(Ex1.what()) <<
'\n';
1907 g_log.
error() <<
"Bivariate Error A for peakNum=" <<
static_cast<int>(
getProperty(
"PeakIndex")) <<
'\n';
1912 g_log.
debug() <<
" Thru Algorithm: chiSq=" << setw(7) << chisqOverDOF <<
'\n';
1913 g_log.
debug() <<
" Row,Col Radius=" << lastRow <<
"," << lastCol <<
"," << neighborRadius <<
'\n';
1915 double sqrtChisq = -1;
1916 if (chisqOverDOF >= 0)
1917 sqrtChisq = (chisqOverDOF);
1921 sqrtChisq =
SQRT(sqrtChisq);
1923 for (
size_t kk = 0; kk < params.size(); kk++) {
1924 g_log.
debug() <<
" Parameter " << setw(8) << names[kk] <<
" " << setw(8) << params[kk];
1926 g_log.
debug() <<
"(" << setw(8) << (errs[kk] * sqrtChisq) <<
")";
1927 if (Bounds.size() > kk) {
1928 pair<double, double> upLow = Bounds[kk];
1929 g_log.
debug() <<
" Bounds(" << upLow.first <<
"," << upLow.second <<
")";
1956 std::vector<string> &names, std::vector<double> ¶ms, std::vector<double> &errs,
1957 double lastRow,
double lastCol,
double neighborRadius) {
1970 double minChiSqOverDOF = -1;
1971 double Bestparams[7];
1972 std::string Bestnames[7];
1973 for (
int i = 0; i < N; i++) {
1974 Fit(Data, chisqOverDOF, done, names, params, errs, lastRow, lastCol, neighborRadius);
1975 g_log.
debug() <<
"-----------------------" << i <<
"--------------------------\n";
1976 if ((minChiSqOverDOF < 0 || chisqOverDOF < minChiSqOverDOF) && (chisqOverDOF > 0) && !done) {
1977 for (
int j = 0; j < NParams; j++) {
1981 minChiSqOverDOF = chisqOverDOF;
1991 for (
int j = 0; j < NParams; j++)
1995 for (
int i = 0; i < NParams; i++) {
1997 if (k >= 0 && k < NParams)
2001 Fit(Data, chisqOverDOF, done, names, params, errs, lastRow, lastCol, neighborRadius);
2015 std::vector<std::string>
const &names,
double chisqOverDOF) {
2018 throw std::runtime_error(
"Irrecoverable inconsistency found. The index for the "
2019 "parameter 'Background' is lower than zero.");
2023 throw std::runtime_error(
"Irrecoverable inconsistency found. The index for the "
2024 "parameter 'Intensity' is lower than zero.");
2026 if (chisqOverDOF < 0) {
2028 g_log.
debug() <<
" Bad Slice- negative chiSq= " << chisqOverDOF <<
'\n';
2033 int NBadEdgeCells =
getProperty(
"NBadEdgePixels");
2034 NBadEdgeCells =
static_cast<int>(.6 * NBadEdgeCells);
2044 g_log.
debug() <<
" Bad Slice. Negative Counts= "
2052 if ((x < MinGoodRatioFitvsExpIntenisites || x > MaxGoodRatioFitvsExpIntenisites) &&
2056 g_log.
debug() <<
" Bad Slice. Fitted Intensity & Observed "
2057 "Intensity(-back) too different. ratio="
2063 bool GoodNums =
true;
2064 bool paramBad =
false;
2065 auto BadParamNum =
static_cast<size_t>(-1);
2066 for (
size_t i = 0; i < errs.size(); i++)
2067 if (errs[i] != errs[i]) {
2071 }
else if (errs[i] < 0) {
2075 }
else if (params[i] != params[i]) {
2082 std::string
obj =
" parameter ";
2085 g_log.
debug() <<
" Bad Slice." <<
obj << BadParamNum <<
" is not a number\n";
2091 std::string Err(
"back ground is negative");
2092 if (params[Ibk] < -.002)
2096 Err =
"Intensity is negative";
2097 if (params[IIntensity] < 0)
2101 double IsawVariance =
m_AttributeValues->CalcISAWIntensityVariance(params.data(), errs.data(), chisqOverDOF);
2103 Err =
"Isaw Variance is negative";
2104 if (IsawVariance > 0) {
2107 if (IsawIntensity * IsawIntensity / IsawVariance < MinGoodIoverSigI * MinGoodIoverSigI)
2122 double maxPeakHeightTheoretical =
2128 if (maxPeakHeightTheoretical < 2 * AvHeight || AvHeight < 0 || maxPeakHeightTheoretical < 0) {
2130 g_log.
debug() <<
" Bad Slice. Peak too small= " << maxPeakHeightTheoretical <<
"/" << AvHeight <<
'\n';
2135 if (maxPeakHeightTheoretical < 1 && (params[
IVXX] > Nrows * Nrows / 4 || params[
IVYY] > Nrows * Nrows / 4)) {
2143 g_log.
debug() <<
" Bad Slice. Too steep of an exponential\n";
2158 double Varx, Vary, Cov;
2171 Varx = ParameterValues[
IVXX];
2172 Vary = ParameterValues[
IVYY];
2173 Cov = ParameterValues[
IVXY];
2178 if (Varx < MinVariationInXYvalues || Vary < MinVariationInXYvalues)
2181 if (Cov * Cov > MaxCorrCoeffinXY * Varx * Vary)
2200 const double ChiSqOverDOF,
const double TotVariance,
2203 double B = TotVariance / ncells;
2204 if (B < ChiSqOverDOF)
2207 double Variance = TotVariance + (backError * backError * B) * ncells * ncells +
background * ncells;
2209 return SQRT(Variance);
2219 TabWS->addColumn(
"double",
"Time");
2220 TabWS->addColumn(
"double",
"Channel");
2221 TabWS->addColumn(
"double",
"Background");
2222 TabWS->addColumn(
"double",
"Intensity");
2223 TabWS->addColumn(
"double",
"Mcol");
2224 TabWS->addColumn(
"double",
"Mrow");
2225 TabWS->addColumn(
"double",
"SScol");
2226 TabWS->addColumn(
"double",
"SSrow");
2227 TabWS->addColumn(
"double",
"SSrc");
2228 TabWS->addColumn(
"double",
"NCells");
2229 TabWS->addColumn(
"double",
"ChiSqrOverDOF");
2230 TabWS->addColumn(
"double",
"TotIntensity");
2231 TabWS->addColumn(
"double",
"BackgroundError");
2232 TabWS->addColumn(
"double",
"FitIntensityError");
2233 TabWS->addColumn(
"double",
"ISAWIntensity");
2234 TabWS->addColumn(
"double",
"ISAWIntensityError");
2235 TabWS->addColumn(
"double",
"TotalBoundary");
2236 TabWS->addColumn(
"double",
"NBoundaryCells");
2237 TabWS->addColumn(
"double",
"Start Row");
2238 TabWS->addColumn(
"double",
"End Row");
2239 TabWS->addColumn(
"double",
"Start Col");
2240 TabWS->addColumn(
"double",
"End Col");
2241 TabWS->addColumn(
"double",
"TotIntensityError");
2242 TabWS->addColumn(
"str",
"SpecIDs");
2263 std::vector<double>
const ¶ms, std::vector<double>
const &errs,
2264 std::vector<std::string>
const &names,
const double Chisq,
2265 const double time,
string spec_idList) {
2274 if (Ibk < 0 || IIntensity < 0 || IVx < 0 || IVy < 0 || IVxy < 0 || Irow < 0 || Icol < 0) {
2275 throw std::runtime_error(
"Inconsistency found when updating output "
2276 "workspace. None of the indices for the "
2277 "parameters 'Background', 'Intensity', 'SScol', "
2278 "'SSrow', 'SSrc', 'Mrow', 'Mcol' can be "
2282 int newRowIndex = 0;
2285 newRowIndex =
static_cast<int>(TabWS->rowCount());
2287 auto TableRow =
static_cast<int>(TabWS->insertRow(newRowIndex));
2292 TabWS->getRef<
double>(std::string(
"Background"),
TableRow) = params[Ibk];
2293 TabWS->getRef<
double>(std::string(
"Channel"),
TableRow) = chan;
2295 TabWS->getRef<
double>(std::string(
"Intensity"),
TableRow) = params[IIntensity];
2296 TabWS->getRef<
double>(std::string(
"FitIntensityError"),
TableRow) = errs[IIntensity] * sqrt(chisq);
2297 TabWS->getRef<
double>(std::string(
"Mcol"),
TableRow) = params[Icol];
2298 TabWS->getRef<
double>(std::string(
"Mrow"),
TableRow) = params[Irow];
2300 TabWS->getRef<
double>(std::string(
"SScol"),
TableRow) = params[IVx];
2301 TabWS->getRef<
double>(std::string(
"SSrow"),
TableRow) = params[IVy];
2303 TabWS->getRef<
double>(std::string(
"SSrc"),
TableRow) = params[IVxy];
2304 TabWS->getRef<
double>(std::string(
"NCells"),
TableRow) = ncells;
2305 TabWS->getRef<
double>(std::string(
"ChiSqrOverDOF"),
TableRow) = chisq;
2308 TabWS->getRef<
double>(std::string(
"BackgroundError"),
TableRow) = errs[Ibk] *
SQRT(chisq);
2315 TabWS->getRef<
double>(std::string(
"ISAWIntensityError"),
TableRow) =
2316 sqrt(
m_AttributeValues->CalcISAWIntensityVariance(params.data(), errs.data(), Chisq));
2322 TabWS->getRef<
double>(std::string(
"Time"),
TableRow) = time;
2328 TabWS->getRef<
double>(std::string(
"End Row"),
TableRow) =
2332 TabWS->getRef<
double>(std::string(
"End Col"),
TableRow) =
2335 TabWS->getRef<
string>(std::string(
"SpecIDs"),
TableRow) = std::move(spec_idList);
2355 std::vector<std::string>
const &names,
double &TotVariance,
2356 double &TotIntensity,
double const TotSliceIntensity,
2357 double const TotSliceVariance,
double const chisqdivDOF,
2367 err =
m_AttributeValues->CalcISAWIntensityVariance(params.data(), errs.data(), chisqdivDOF);
2373 g_log.
debug() <<
"TotIntensity/TotVariance=" << TotIntensity <<
"/" << TotVariance <<
'\n';
2407 double alpha = .5 * (r - 1.0);
2408 alpha = std::min(1.0, alpha);
2431 double IntensityBackError = errs[
IBACK] * sqrt(B);
2433 ExperimVar += IntensityBackError * IntensityBackError * ncells * ncells + params[
IBACK] * ncells;
2436 double alpha = .5 * (r - 1.0);
2437 alpha = std::min(1.0, alpha);
2455 int maxCol = minCol +
static_cast<int>(
StatBase[
INCol]) - 1;
2458 if (params[
IVXX] <= 0 || params[
IVYY] <= 0)
2464 double NstdX = 4 * min<double>(params[
IXMEAN] - minCol, maxCol - params[
IXMEAN]) / sqrt(params[
IVXX]);
2466 double NstdY = 4 * min<double>(params[
IYMEAN] - minRow, maxRow - params[
IYMEAN]) / sqrt(params[
IVYY]);
2473 if (sgn * NstdX < 9) {
2474 auto xx =
static_cast<int>(sgn * NstdX);
2475 double a = probs[xx];
2479 P = a + (b - a) * (sgn * NstdX - xx);
2492 if (sgn * NstdY < 9) {
2493 auto xx =
static_cast<int>(sgn * NstdY);
2494 double a = probs[xx];
2498 P = a + (b - a) * (sgn * NstdY - xx);
2507 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.