26#include "MantidHistogramData/BinEdges.h"
28#include <boost/math/special_functions/round.hpp>
56#define IIntensities 14
59#define ITotBoundary 17
61#define IVarBoundary 19
81const double probs[9] = {.5f, .5987f, .6915f, .7734f, .8413f, .8944f, .9322f, .9599f, .9772f};
83const int MinRowColSpan = 6;
84const int MaxRowColSpan = 36;
85const int MinTimeSpan = 3;
86const double NeighborhoodRadiusDivPeakRadius = 1.5;
87const double MaxNeighborhoodRadius = 10;
88const double NStdDevPeakSpan = 2;
89const double MaxGoodRatioFitvsExpIntenisites = 2.5;
90const double MinGoodRatioFitvsExpIntenisites = .25;
91const double MinGoodIoverSigI = 3.0;
92const double MinVariationInXYvalues = .6;
93const double MaxCorrCoeffinXY = .9;
97 :
Algorithm(), m_R0(-1), m_ROW(0.), m_COL(0.), m_cellWidth(0.), m_cellHeight(0.), m_NROWS(0), m_NCOLS(0) {
144 "A 2D workspace with X values of time of flight");
147 "Name of the output table workspace with Log info");
150 "Workspace of Peaks");
152 declareProperty(
"PeakIndex", 0,
"Index of peak in PeaksWorkspace to integrate");
154 declareProperty(
"PeakQspan", .06,
"Max magnitude of Q of Peak to Q of Peak Center, where mod(Q)=1/d");
156 declareProperty(
"CalculateVariances",
true,
"Calc (co)variances given parameter values versus fit (co)Variances ");
158 declareProperty(
"Ties",
"",
"Tie parameters(Background,Intensity, Mrow,...) to values/formulas.");
179 seconds1 = time(
nullptr);
183 g_log.
debug(
"------------------Start Peak Integrate-------------------");
186 g_log.
error(
"Negative PeakQspans are not allowed. Use .17/G where G is the "
187 "max unit cell length");
188 throw std::runtime_error(
"Negative PeakQspans are not allowed in IntegratePeakTimeSlices");
194 throw std::runtime_error(
"Improper Input Workspace in IntegratePeakTimeSlices");
201 throw std::runtime_error(
"Improper Peaks Input");
206 Peak &peak = peaksW->getPeak(indx);
210 std::shared_ptr<const Geometry::IComponent> panel_const =
213 std::shared_ptr<Geometry::IComponent> panel = std::const_pointer_cast<Geometry::IComponent>(panel_const);
215 if (!panel || !panel_const) {
217 throw std::runtime_error(
"Cannot get panel for a peak");
221 panel->getBoundingBox(box);
225 g_log.
error(
"Detector pixel is NOT inside the Peaks Bank");
226 throw std::runtime_error(
"Detector pixel is NOT inside the Peaks Bank");
231 g_log.
debug() <<
" Peak Index " << indx <<
'\n';
233 double TotVariance = 0;
234 double TotIntensity = 0;
235 double lastRow =
m_ROW;
236 double Row0 = lastRow;
237 double lastCol =
m_COL;
238 double Col0 = lastCol;
252 size_t wsIndx = (it->second);
262 const auto &
X = inpWkSpace->x(wsIndx);
265 dChan = max<int>(dChan, MinTimeSpan);
271 double neighborRadius;
273 neighborRadius = min<double>(MaxNeighborhoodRadius, NeighborhoodRadiusDivPeakRadius * R);
276 Nneighbors = min<int>(Nneighbors,
static_cast<int>(inpWkSpace->getNumberHistograms()) - 2);
287 g_log.
error(
"Not enough neighboring pixels to fit ");
288 throw std::runtime_error(
"Not enough neighboring pixels to fit ");
292 double MaxCounts = -1;
295 for (
int dir = 1; dir > -2; dir -= 2) {
297 for (
int t = 0; t < dChan && !done; t++)
298 if (dir < 0 && t == 0) {
301 }
else if (Chan + dir * t < 0 || Chan + dir * t >=
static_cast<int>(
X.size()))
312 XXX->setCurrentRadius(R);
314 SetUpData1(Data, inpWkSpace, Chan + dir * t, Chan + dir * t, R, CenterDet->getPos(), spec_idList);
319 MaxChan = Chan + dir * t;
336 g_log.
debug() <<
" largest Channel,Radius,m_cellWidth,m_cellHeight = " << Chan <<
" " << R <<
" " <<
m_cellWidth
340 g_log.
error(
"Not enough rows and cols or time channels ");
341 throw std::runtime_error(
"Not enough rows and cols or time channels ");
355 int LastTableRow = -1;
356 auto origAttributeList = std::make_shared<DataModeHandler>();
357 auto lastAttributeList = std::make_shared<DataModeHandler>();
359 for (
int dir = 1; dir >= -1; dir -= 2) {
362 for (
int chan = 0; chan < dChan && !done; chan++)
363 if (dir < 0 && chan == 0) {
366 lastAttributeList = origAttributeList;
367 if (TabWS->rowCount() > 0)
370 }
else if (Chan + dir * chan < 0 || Chan + dir * chan >=
static_cast<int>(
X.size()))
374 int xchan = Chan + dir * chan;
376 size_t topIndex = xchan + 1;
377 if (topIndex >=
X.size())
378 topIndex =
X.size() - 1;
380 time = (
X[xchan] +
X[topIndex]) / 2.0;
390 g_log.
debug() <<
" A:chan=" << xchan <<
" time=" << time <<
" Radius=" << Radius <<
"row= " << lastRow
391 <<
" col=" << lastCol <<
'\n';
393 SetUpData(Data, inpWkSpace, panel, xchan, xchan, lastCol, lastRow, Cent, neighborRadius, Radius, spec_idList);
402 std::vector<double> params;
403 std::vector<double> errs;
404 std::vector<std::string> names;
410 Fit(Data, chisqOverDOF, done, names, params, errs, lastRow, lastCol, neighborRadius);
415 if (
isGoodFit(params, errs, names, chisqOverDOF)) {
416 LastTableRow =
UpdateOutputWS(TabWS, dir, xchan, params, errs, names, chisqOverDOF,
423 TotSliceVariance, chisqOverDOF, ncells);
427 if (dir == 1 && chan == 0)
428 origAttributeList = lastAttributeList;
443 int chanMin, chanMax;
444 if ((dir == 1 && chan == 0) || lastAttributeList->CellHeight <= 0) {
457 chanMin = std::min<int>(xchan, xchan - dir);
458 chanMax = chanMin + 1;
459 if (lastAttributeList->case4)
462 auto XXX = std::make_shared<DataModeHandler>(*lastAttributeList);
484 Fit(Data, chisqOverDOF, done, names, params, errs, lastRow, lastCol, neighborRadius);
488 if (!done &&
isGoodFit(params, errs, names, chisqOverDOF)) {
490 if (LastTableRow >= 0 && LastTableRow <
static_cast<int>(TabWS->rowCount()))
491 TabWS->removeRow(LastTableRow);
495 LastTableRow =
UpdateOutputWS(TabWS, dir, (chanMin + chanMax) / 2.0, params, errs, names, chisqOverDOF,
498 if (lastAttributeList->lastISAWVariance > 0 && lastAttributeList->CellHeight > 0) {
499 TotIntensity -= lastAttributeList->lastISAWIntensity;
500 TotVariance -= lastAttributeList->lastISAWVariance;
507 updatePeakInformation(params, errs, names, TotVariance, TotIntensity, TotSliceIntensity, TotSliceVariance,
512 if (dir == 1 && (chan == 0 || chan == 1)) {
519 auto XXX = std::make_shared<DataModeHandler>();
520 lastAttributeList = XXX;
533 throw std::runtime_error(
"Inconsistency found in algorithm "
534 "execution. The index for the parameter "
535 "Mrow is negative.");
538 lastRow = boost::math::iround(params[i]);
541 lastCol = boost::math::iround(params[i]);
555 }
catch (std::exception &EE1) {
556 std::cout <<
"Error in main reason=" << EE1.what() <<
'\n';
558 throw std::runtime_error(
" Error IntegratePeakTimeSlices:" + std::string(EE1.what()));
559 }
catch (std::string &mess) {
560 throw std::runtime_error(
"Error IntegratePeakTimeSlices:" + mess);
563 throw std::runtime_error(
"Error IntegratePeakTimeSlices:");
574 seconds2 = time(
nullptr);
575 double dif = difftime(seconds2, seconds1);
576 g_log.
debug() <<
"Finished Integr peak number " << indx <<
" in " << dif <<
" seconds\n";
578 }
catch (std::exception &ss) {
580 std::cout <<
"Error occurred XX " << ss.what() <<
'\n';
581 throw std::runtime_error(ss.what());
595 const Kernel::V3D &Center,
double &Radius,
int *&ArryofID) {
598 int MaxN = ArryofID[0];
604 comp->getBoundingBox(box);
606 double minx = Center.
X() - Radius;
607 double miny = Center.
Y() - Radius;
608 double minz = Center.
Z() - Radius;
609 double maxx = Center.
X() + Radius;
610 double maxy = Center.
Y() + Radius;
611 double maxz = Center.
Z() + Radius;
613 if (box.
xMin() >= maxx)
616 if (box.
xMax() <= minx)
620 if (box.
yMin() >= maxy)
623 if (box.
yMax() <= miny)
626 if (box.
zMin() >= maxz)
629 if (box.
zMax() <= minz)
633 auto det = std::dynamic_pointer_cast<Geometry::Detector>(comp);
636 V3D pos = det->getPos() - Center;
637 if (pos.
X() * pos.
X() + pos.
Y() * pos.
Y() + pos.
Z() * pos.
Z() < Radius * Radius) {
638 ArryofID[N] = det->getID();
645 auto Assembly = std::dynamic_pointer_cast<const Geometry::ICompAssembly>(comp);
652 for (
int i = 0; i < Assembly->nelements() && b; i++)
667 const V3D &oldCenter,
double NewRadius,
double &neighborRadius) {
668 double DD = (CentPos - oldCenter).norm();
669 bool changed =
false;
670 if (DD + NewRadius > neighborRadius) {
671 auto NN = int(NStdDevPeakSpan * NeighborhoodRadiusDivPeakRadius * NewRadius /
m_cellWidth * NStdDevPeakSpan *
672 NeighborhoodRadiusDivPeakRadius * NewRadius /
m_cellHeight);
679 neighborRadius = NeighborhoodRadiusDivPeakRadius * NewRadius;
685 neighborRadius -= DD;
703 double Q = 0, ScatAngle = 0, dScatAngle = 0, DetSpan = 0;
710 ScatAngle = acos(pos.
Z() / pos.
norm());
712 dScatAngle = 2 * dQ / Q * tan(ScatAngle / 2);
714 DetSpan = pos.
norm() * dScatAngle;
716 DetSpan =
fabs(DetSpan);
722 }
catch (std::exception &s) {
723 std::cout <<
"err in getNRowsCols, reason=" << s.what() <<
'\n';
743 const int specNum,
int &Centerchan) {
747 double time = peak.
getTOF();
748 double dtime = dQ / Q * time;
751 Centerchan = chanCenter;
754 int dchan = abs(chanCenter - chanLeft);
756 if (abs(chanRight - chanCenter) > dchan)
757 dchan = abs(chanRight - chanCenter);
759 dchan = max<int>(3, dchan);
781 int &NCOLS,
double &pixWidthx,
double &pixHeighty,
786 V3D detPos = det->getPos();
788 center.
setX(detPos.
X());
789 center.
setY(detPos.
Y());
790 center.
setZ(detPos.
Z());
792 std::shared_ptr<const Detector> dett = std::dynamic_pointer_cast<const Detector>(det);
794 pixWidthx = dett->getWidth();
795 pixHeighty = dett->getHeight();
798 V3D yaxis0(0.0, 1.0, 0.0);
807 xvec.
setX(xaxis0.
X());
808 xvec.
setY(xaxis0.
Y());
809 xvec.
setZ(xaxis0.
Z());
810 yvec.
setX(yaxis0.
X());
811 yvec.
setY(yaxis0.
Y());
812 yvec.
setZ(yaxis0.
Z());
817 throw std::invalid_argument(
"No instrument for peak");
818 std::shared_ptr<const IComponent> panel = inst->getComponentByName(peak.
getBankName());
820 std::shared_ptr<const RectangularDetector> ddet = std::dynamic_pointer_cast<const RectangularDetector>(panel);
823 std::pair<int, int> CR = ddet->getXYForDetectorID(det->getID());
826 pixWidthx = ddet->xstep();
827 pixHeighty = ddet->ystep();
829 NROWS = ddet->ypixels();
830 NCOLS = ddet->xpixels();
842 std::shared_ptr<const Component> compPanel = std::dynamic_pointer_cast<const Component>(panel);
843 std::shared_ptr<IComponent> panel1(compPanel->base()->clone());
852 panel1->getBoundingBox(B);
854 NROWS = boost::math::iround((B.
yMax() - B.
yMin()) / pixHeighty);
855 NCOLS = boost::math::iround((B.
xMax() - B.
xMin()) / pixWidthx);
868 const double col, std::vector<double> &StatBase) {
870 StatBase[
ISSIxx] += col * col * intensity;
871 StatBase[
ISSIyy] += intensity * row * row;
872 StatBase[
ISSIxy] += intensity * row * col;
873 StatBase[
ISSxx] += col * col;
874 StatBase[
ISSyy] += row * row;
875 StatBase[
ISSxy] += row * col;
876 StatBase[
ISSIx] += intensity * col;
877 StatBase[
ISSIy] += intensity * row;
878 StatBase[
ISSx] += col;
879 StatBase[
ISSy] += row;
896 std::vector<double> Res(7);
919 if (sigy * NstdY < 7 && sigy * NstdY >= 0)
921 x = probs[std::lround(sigy * NstdY)];
930 if (sigx * NstdX < 7 && sigx * NstdX > 0)
932 x1 = probs[std::lround(sigx * NstdX)];
969 if (Rx * Rx < 4 * Varx || Ry * Ry < 4 * Vary) {
973 return std::vector<double>();
983 double col = Mx / Den;
984 double row = My / Den;
985 std::vector<double> Result(7);
1006 double TotBoundaryIntensities = statBase[
ITotBoundary];
1007 auto nBoundaryCells =
static_cast<int>(statBase[
INBoundary]);
1010 if (nBoundaryCells > 0)
1011 b = TotBoundaryIntensities / nBoundaryCells;
1013 auto nCells =
static_cast<int>(statBase[
ISS1]);
1016 while (Den <= 0 && b != 0) {
1027 Varx = statBase[
INCol] / 7;
1028 Vary = statBase[
INRows] / 7;
1036 Ry * Ry < 4 * std::max(Vary,
VaryHW))
1058 double Mx, My, Sxx, Syy, Sxy;
1060 double RangeX = statBase[
INCol] / 2;
1061 double RangeY = statBase[
INRows] / 2;
1063 while (!done && ntimes < 29) {
1064 Mx = statBase[
ISSIx] - b * statBase[
ISSx];
1065 My = statBase[
ISSIy] - b * statBase[
ISSy];
1066 Sxx = (statBase[
ISSIxx] - b * statBase[
ISSxx] - Mx * Mx / Den) / Den;
1067 Syy = (statBase[
ISSIyy] - b * statBase[
ISSyy] - My * My / Den) / Den;
1068 Sxy = (statBase[
ISSIxy] - b * statBase[
ISSxy] - Mx * My / Den) / Den;
1072 if (Sxx <= RangeX / 12 || Syy <= RangeY / 12 || Sxy * Sxy / Sxx / Syy > .9) {
1075 if (ntimes + 1 == 29)
1114 if (Rx * Rx > 4 * Vx)
1119 if (Ry * Ry > 4 * Vy)
1125 double NewRadius = 1.4 * max<double>(MinRowColSpan * max<double>(
CellWidth,
CellHeight), 4.5 * DD);
1126 NewRadius = mult * min<double>(
baseRCRadius, NewRadius);
1145 const std::vector<double> &counts) {
1146 double minCount, maxCount;
1147 const auto &
X = xvals;
1148 const auto &
Y = yvals;
1149 const auto &C = counts;
1152 auto N =
static_cast<int>(
X.size());
1159 minCount = maxCount = C[0];
1163 double lowX, lowY, highX, highY;
1164 lowX = highX =
X[0];
1165 lowY = highY =
Y[0];
1167 for (
int i = 1; i < N; i++) {
1170 else if (
X[i] > highX)
1175 else if (
Y[i] > highY)
1178 if (C[i] > maxCount) {
1183 }
else if (C[i] < minCount) {
1186 }
else if (C[i] == maxCount)
1193 if (minCount == maxCount)
1199 double dCount = std::max(.51, (maxCount - minCount) / 6.2);
1200 double CountUp = (maxCount + minCount) / 2 + dCount;
1201 double CountLow = (maxCount + minCount) / 2 - dCount;
1202 double dSpanx = (highX - lowX) / 6.;
1203 double dSpany = (highY - lowY) / 6.0;
1209 double offset = std::max(.2, (maxCount - minCount) / 20);
1210 double TotR_max = 0;
1211 double TotR_min = 0;
1216 for (
int i = 0; i < N; i++) {
1217 if (C[i] > maxCount - offset) {
1220 TotR_max += C[i] * sqrt((
X[i] - MaxX) * (
X[i] - MaxX) + (
Y[i] - MaxY) * (
Y[i] - MaxY));
1222 if (C[i] < minCount + offset)
1228 TotR_min += C[i] * sqrt((
X[i] - MaxX) * (
X[i] - MaxX) + (
Y[i] - MaxY) * (
Y[i] - MaxY));
1231 if (
fabs(MaxY -
Y[i]) < 1.2 &&
fabs(MaxX -
X[i]) > 1.2 && C[i] >= CountLow && C[i] <= CountUp &&
1232 fabs(MaxX -
X[i]) < dSpanx) {
1233 TotRx0 += (C[i] - minCount) * (
X[i] - MaxX) * (
X[i] - MaxX);
1234 TotCx += C[i] - minCount;
1237 if (
fabs(MaxX -
X[i]) < 1.2 &&
fabs(MaxY -
Y[i]) > 1.2 && C[i] >= CountLow && C[i] <= CountUp &&
1238 fabs(MaxY -
Y[i]) < dSpany) {
1239 TotRy0 += (C[i] - minCount) * (
Y[i] - MaxY) * (
Y[i] - MaxY);
1240 TotCy += C[i] - minCount;
1244 if (nMax + nMin == N)
1250 double AvR = .5 * (TotR_max / TotMax + TotR_min / TotMin);
1258 double TotR = 0, nR = -1, nRx = -1, nRy = -1;
1259 double MidVal = (TotMax / nMax + TotMin / nMin) / 2.0;
1260 double TotRx = 0, TotRy = 0;
1261 while ((nR <= 0 || nRy <= 0 || nRx <= 0) && offset < MidVal) {
1269 for (
int i = 0; i < N; i++)
1270 if (C[i] < MidVal + offset && C[i] > MidVal - offset) {
1271 double X1 =
X[i] - MaxX;
1272 double Y1 =
Y[i] - MaxY;
1273 TotR += sqrt(X1 * X1 + Y1 * Y1);
1275 if ((X1 >= -1.2 && X1 <= 1.2) &&
fabs(Y1) > 1.2 &&
fabs(Y1) < dSpany) {
1279 if ((Y1 >= -1.2 && Y1 <= 1.2) &&
fabs(X1) > 1.2 &&
fabs(X1) < dSpanx) {
1287 double AvR = TotR / nR;
1291 VarxHW = (TotRx / nRx) * (TotRx / nRx) / .8326 / .8326;
1293 VarxHW = TotRx0 * TotRx0 / TotCx / TotCx / .8326 / .8326;
1300 VaryHW = (TotRy / nRy) * (TotRy / nRy) / .8326 / .8326;
1302 VaryHW = TotRy0 * TotRy0 / TotCy / TotCy / .8326 / .8326;
1328 const std::shared_ptr<Geometry::IComponent> &comp,
const int chanMin,
1329 const int chanMax,
double CentX,
double CentY,
Kernel::V3D &CentNghbr,
1330 double &neighborRadius,
1331 double Radius,
string &spec_idList) {
1335 int NBadEdgeCells =
getProperty(
"NBadEdgePixels");
1339 NBadEdgeCells,
m_NROWS - NBadEdgeCells);
1345 SetUpData1(Data, inpWkSpace, chanMin, chanMax, Radius, CentPos1, spec_idList);
1361 double DD = (CentPos - CentNghbr).norm();
1363 if (DD + NewRadius > neighborRadius) {
1364 auto NN = int(NStdDevPeakSpan * NeighborhoodRadiusDivPeakRadius * NewRadius /
m_cellWidth * NStdDevPeakSpan *
1365 NeighborhoodRadiusDivPeakRadius * NewRadius /
m_cellHeight);
1373 neighborRadius = NeighborhoodRadiusDivPeakRadius * NewRadius;
1374 CentNghbr = CentPos;
1378 neighborRadius -= DD;
1383 NBadEdgeCells,
m_NROWS - NBadEdgeCells);
1388 SetUpData1(Data, inpWkSpace, chanMin, chanMax, NewRadius, CentPos, spec_idList);
1404 const int chanMax,
double Radius,
const Kernel::V3D &CentPos,
1405 string &spec_idList) {
1411 std::shared_ptr<Workspace2D> ws = std::dynamic_pointer_cast<Workspace2D>(Data);
1414 spec_idList.clear();
1417 StatBase.emplace_back(0);
1419 std::vector<double> yvalB;
1420 std::vector<double> errB;
1421 std::vector<double> xvalB;
1422 std::vector<double> YvalB;
1424 double TotBoundaryIntensities = 0;
1425 int nBoundaryCells = 0;
1426 double TotBoundaryVariances = 0;
1429 double minRow = 20000, maxRow = -1, minCol = 20000, maxCol = -1;
1433 std::vector<double> xRef;
1437 size_t workspaceIndex;
1441 throw std::runtime_error(
"No workspaceIndex for detID=" +
std::to_string(DetID));
1445 V3D pixPos = Det->getPos();
1450 V3D dist = pixPos - CentPos;
1454 spec_idList +=
std::to_string(inpWkSpace->getSpectrum(workspaceIndex).getSpectrumNo());
1459 double row =
m_ROW + R1a;
1464 double col =
m_COL + C1a;
1466 if (row > NBadEdges && col > NBadEdges && (
m_NROWS < 0 || row <
m_NROWS - NBadEdges) &&
1468 auto &histogram = inpWkSpace->y(workspaceIndex);
1470 auto &histoerrs = inpWkSpace->e(workspaceIndex);
1471 double intensity = 0;
1472 double variance = 0;
1473 for (
int chan = chanMin; chan <= chanMax; chan++) {
1474 intensity += histogram[chan];
1475 variance += histoerrs[chan] * histoerrs[chan];
1478 yvalB.emplace_back(intensity);
1481 errB.emplace_back(
sigma);
1482 xvalB.emplace_back(col);
1483 YvalB.emplace_back(row);
1485 xRef.emplace_back(
static_cast<double>(jj));
1488 updateStats(intensity, variance, row, col, StatBase);
1490 if ((pixPos - CentPos).norm() > BoundaryRadius) {
1491 TotBoundaryIntensities += intensity;
1494 TotBoundaryVariances += variance;
1520 auto pX = Kernel::make_cow<HistogramData::HistogramX>(std::move(xRef));
1525 ws->setCounts(0, yvalB);
1526 ws->setCountStandardDeviations(0, errB);
1527 ws->setCounts(1, xvalB);
1528 ws->setCounts(2, YvalB);
1533 StatBase[
INRows] = maxRow - minRow + 1;
1534 StatBase[
INCol] = maxCol - minCol + 1;
1562 if (sgn * (
X[0] - time) >= 0)
1565 if (sgn * (time -
X[
X.size() - 1u]) >= 0)
1566 return static_cast<int>(
X.size()) - 1;
1568 size_t end =
X.size() - 1u;
1569 for (
size_t i = 0; i < end; i++) {
1570 if (sgn * (time -
X[i]) >= 0 && sgn * (
X[i + 1u] - time) >= 0)
1571 return static_cast<int>(i);
1588 Varx = params[
IVXX];
1589 Vary = params[
IVYY];
1598 return Rx * Rx < NStdDevPeakSpan * NStdDevPeakSpan * std::max(Varx,
VarxHW) ||
1599 Ry * Ry < NStdDevPeakSpan * NStdDevPeakSpan * std::max(Vary,
VaryHW);
1609 std::ostringstream fun_str;
1611 fun_str <<
"name=BivariateNormal,";
1614 fun_str <<
"CalcVariances=1";
1616 fun_str <<
"CalcVariances=-1";
1622 for (
int i = 0; i < NN; i++) {
1626 return fun_str.str();
1640 for (
size_t i = 0; i < nameList.size(); i++)
1641 if (oneName == nameList[i])
1642 return static_cast<int>(i);
1701 double &Varyy,
const std::vector<double> &StatBase) {
1740 double back = TotBoundaryIntensities / nBoundaryCells;
1741 double backVar = std::max(nBoundaryCells / 50.0, TotBoundaryVariances) / nBoundaryCells / nBoundaryCells;
1742 double IntensVar = Variance + ncells * ncells * backVar;
1744 double relError = .25;
1753 double NSigs = NStdDevPeakSpan;
1755 NSigs = std::max(NStdDevPeakSpan,
1760 str << max<double>(0.0,
back_calc - NSigs * (1 + relError) * sqrt(backVar)) <<
"<Background<"
1761 << (back + NSigs * (1.8 + relError) * sqrt(backVar)) <<
","
1762 << max<double>(0.0,
Intensity_calc - NSigs * (1 + relError) * sqrt(IntensVar)) <<
"<Intensity<"
1765 double min = max<double>(0.0,
back_calc - NSigs * (1 + relError) * sqrt(backVar));
1766 double maxx = back + NSigs * (1.8 + relError) * sqrt(backVar);
1767 Bounds.emplace_back(min, maxx);
1768 Bounds.emplace_back(max<double>(0.0,
Intensity_calc - NSigs * (1 + relError) * sqrt(IntensVar)),
1770 double relErr1 = relError * .75;
1772 double minn = std::max(
MinCol - .5, (1 - relErr1) * val);
1773 maxx = std::min((1 + relErr1) * val,
MaxCol + .5);
1775 str <<
"," << minn <<
"<"
1778 Bounds.emplace_back(minn, maxx);
1782 minn = std::max(
MinRow - .5, (1 - relErr1) * val);
1783 maxx = std::min((1 + relErr1) * val,
MaxRow + .5);
1784 str <<
"," << minn <<
"<"
1787 Bounds.emplace_back(minn, maxx);
1791 double valmin = val;
1792 double valmax = val;
1794 valmin = std::min(val,
VarxHW);
1795 valmax = std::max(val,
VarxHW);
1799 str <<
"," << (1 - relErr1) * valmin <<
"<"
1801 <<
"<" << (1 + relErr1) * valmax;
1802 Bounds.emplace_back((1 - relErr1) * valmin, (1 + relErr1) * valmax);
1808 valmin = std::min(val,
VaryHW);
1809 valmax = std::max(val,
VaryHW);
1811 str <<
"," << (1 - relErr1) * valmin <<
"<"
1813 <<
"<" << (1 + relErr1) * valmax;
1814 Bounds.emplace_back((1 - relErr1) * valmin, (1 + relErr1) * valmax);
1835 std::vector<string> &names, std::vector<double> ¶ms, std::vector<double> &errs,
1836 double lastRow,
double lastCol,
double neighborRadius) {
1839 std::vector<std::pair<double, double>> Bounds;
1844 std::string SSS(
" Fit string ");
1849 fit_alg->setPropertyValue(
"Function", fun_str);
1851 fit_alg->setProperty(
"InputWorkspace", Data);
1852 fit_alg->setProperty(
"WorkspaceIndex", 0);
1853 fit_alg->setProperty(
"StartX", 0.0);
1854 fit_alg->setProperty(
"EndX", 0.0 +
static_cast<double>(
m_NeighborIDs[1]));
1855 fit_alg->setProperty(
"MaxIterations", 5000);
1856 fit_alg->setProperty(
"CreateOutput",
true);
1858 fit_alg->setProperty(
"Output",
"out");
1860 fit_alg->setProperty(
"MaxIterations", 50);
1863 if (tie.length() >
static_cast<size_t>(0))
1864 fit_alg->setProperty(
"Ties", tie);
1865 if (Constraints.length() >
static_cast<size_t>(0))
1866 fit_alg->setProperty(
"Constraints", Constraints);
1868 fit_alg->executeAsChildAlg();
1870 chisqOverDOF = fit_alg->getProperty(
"OutputChi2overDoF");
1871 std::string outputStatus = fit_alg->getProperty(
"OutputStatus");
1872 g_log.
debug() <<
"Chisq/OutputStatus=" << chisqOverDOF <<
"/" << outputStatus <<
'\n';
1878 for (
int prm = 0; prm < static_cast<int>(RRes->rowCount()) - 1; prm++) {
1879 names.emplace_back(RRes->getRef<
string>(
"Name", prm));
1880 params.emplace_back(RRes->getRef<
double>(
"Value", prm));
1881 double error = RRes->getRef<
double>(
"Error", prm);
1882 errs.emplace_back(
error);
1884 if (names.size() < 5) {
1888 double Varxx, Varxy, Varyy;
1891 params.emplace_back(Varxx);
1892 params.emplace_back(Varyy);
1893 params.emplace_back(Varxy);
1894 errs.emplace_back(0);
1895 errs.emplace_back(0);
1896 errs.emplace_back(0);
1899 }
catch (std::exception &Ex1)
1902 g_log.
error() <<
"Bivariate Error for PeakNum=" <<
static_cast<int>(
getProperty(
"PeakIndex")) <<
":"
1903 << std::string(Ex1.what()) <<
'\n';
1906 g_log.
error() <<
"Bivariate Error A for peakNum=" <<
static_cast<int>(
getProperty(
"PeakIndex")) <<
'\n';
1911 g_log.
debug() <<
" Thru Algorithm: chiSq=" << setw(7) << chisqOverDOF <<
'\n';
1912 g_log.
debug() <<
" Row,Col Radius=" << lastRow <<
"," << lastCol <<
"," << neighborRadius <<
'\n';
1914 double sqrtChisq = -1;
1915 if (chisqOverDOF >= 0)
1916 sqrtChisq = (chisqOverDOF);
1920 sqrtChisq =
SQRT(sqrtChisq);
1922 for (
size_t kk = 0; kk < params.size(); kk++) {
1923 g_log.
debug() <<
" Parameter " << setw(8) << names[kk] <<
" " << setw(8) << params[kk];
1925 g_log.
debug() <<
"(" << setw(8) << (errs[kk] * sqrtChisq) <<
")";
1926 if (Bounds.size() > kk) {
1927 pair<double, double> upLow = Bounds[kk];
1928 g_log.
debug() <<
" Bounds(" << upLow.first <<
"," << upLow.second <<
")";
1934 g_log.
debug() <<
"IsawIntensity= " << intensity <<
'\n';
1955 std::vector<string> &names, std::vector<double> ¶ms, std::vector<double> &errs,
1956 double lastRow,
double lastCol,
double neighborRadius) {
1960 if (background <= 0) {
1969 double minChiSqOverDOF = -1;
1970 double Bestparams[7];
1971 std::string Bestnames[7];
1972 for (
int i = 0; i < N; i++) {
1973 Fit(Data, chisqOverDOF, done, names, params, errs, lastRow, lastCol, neighborRadius);
1974 g_log.
debug() <<
"-----------------------" << i <<
"--------------------------\n";
1975 if ((minChiSqOverDOF < 0 || chisqOverDOF < minChiSqOverDOF) && (chisqOverDOF > 0) && !done) {
1976 for (
int j = 0; j < NParams; j++) {
1980 minChiSqOverDOF = chisqOverDOF;
1984 background = background / 2;
1990 for (
int j = 0; j < NParams; j++)
1994 for (
int i = 0; i < NParams; i++) {
1996 if (k >= 0 && k < NParams)
2000 Fit(Data, chisqOverDOF, done, names, params, errs, lastRow, lastCol, neighborRadius);
2014 std::vector<std::string>
const &names,
double chisqOverDOF) {
2017 throw std::runtime_error(
"Irrecoverable inconsistency found. The index for the "
2018 "parameter 'Background' is lower than zero.");
2022 throw std::runtime_error(
"Irrecoverable inconsistency found. The index for the "
2023 "parameter 'Intensity' is lower than zero.");
2025 if (chisqOverDOF < 0) {
2027 g_log.
debug() <<
" Bad Slice- negative chiSq= " << chisqOverDOF <<
'\n';
2032 int NBadEdgeCells =
getProperty(
"NBadEdgePixels");
2033 NBadEdgeCells =
static_cast<int>(.6 * NBadEdgeCells);
2043 g_log.
debug() <<
" Bad Slice. Negative Counts= "
2051 if ((x < MinGoodRatioFitvsExpIntenisites || x > MaxGoodRatioFitvsExpIntenisites) &&
2055 g_log.
debug() <<
" Bad Slice. Fitted Intensity & Observed "
2056 "Intensity(-back) too different. ratio="
2062 bool GoodNums =
true;
2063 bool paramBad =
false;
2064 auto BadParamNum =
static_cast<size_t>(-1);
2065 for (
size_t i = 0; i < errs.size(); i++)
2066 if (errs[i] != errs[i]) {
2070 }
else if (errs[i] < 0) {
2074 }
else if (params[i] != params[i]) {
2081 std::string
obj =
" parameter ";
2084 g_log.
debug() <<
" Bad Slice." <<
obj << BadParamNum <<
" is not a number\n";
2090 std::string Err(
"back ground is negative");
2091 if (params[Ibk] < -.002)
2095 Err =
"Intensity is negative";
2096 if (params[IIntensity] < 0)
2100 double IsawVariance =
m_AttributeValues->CalcISAWIntensityVariance(params.data(), errs.data(), chisqOverDOF);
2102 Err =
"Isaw Variance is negative";
2103 if (IsawVariance > 0) {
2106 if (IsawIntensity * IsawIntensity / IsawVariance < MinGoodIoverSigI * MinGoodIoverSigI)
2121 double maxPeakHeightTheoretical =
2127 if (maxPeakHeightTheoretical < 2 * AvHeight || AvHeight < 0 || maxPeakHeightTheoretical < 0) {
2129 g_log.
debug() <<
" Bad Slice. Peak too small= " << maxPeakHeightTheoretical <<
"/" << AvHeight <<
'\n';
2134 if (maxPeakHeightTheoretical < 1 && (params[
IVXX] > Nrows * Nrows / 4 || params[
IVYY] > Nrows * Nrows / 4)) {
2142 g_log.
debug() <<
" Bad Slice. Too steep of an exponential\n";
2157 double Varx, Vary, Cov;
2170 Varx = ParameterValues[
IVXX];
2171 Vary = ParameterValues[
IVYY];
2172 Cov = ParameterValues[
IVXY];
2177 if (Varx < MinVariationInXYvalues || Vary < MinVariationInXYvalues)
2180 if (Cov * Cov > MaxCorrCoeffinXY * Varx * Vary)
2199 const double ChiSqOverDOF,
const double TotVariance,
2202 double B = TotVariance / ncells;
2203 if (B < ChiSqOverDOF)
2206 double Variance = TotVariance + (backError * backError * B) * ncells * ncells + background * ncells;
2208 return SQRT(Variance);
2218 TabWS->addColumn(
"double",
"Time");
2219 TabWS->addColumn(
"double",
"Channel");
2220 TabWS->addColumn(
"double",
"Background");
2221 TabWS->addColumn(
"double",
"Intensity");
2222 TabWS->addColumn(
"double",
"Mcol");
2223 TabWS->addColumn(
"double",
"Mrow");
2224 TabWS->addColumn(
"double",
"SScol");
2225 TabWS->addColumn(
"double",
"SSrow");
2226 TabWS->addColumn(
"double",
"SSrc");
2227 TabWS->addColumn(
"double",
"NCells");
2228 TabWS->addColumn(
"double",
"ChiSqrOverDOF");
2229 TabWS->addColumn(
"double",
"TotIntensity");
2230 TabWS->addColumn(
"double",
"BackgroundError");
2231 TabWS->addColumn(
"double",
"FitIntensityError");
2232 TabWS->addColumn(
"double",
"ISAWIntensity");
2233 TabWS->addColumn(
"double",
"ISAWIntensityError");
2234 TabWS->addColumn(
"double",
"TotalBoundary");
2235 TabWS->addColumn(
"double",
"NBoundaryCells");
2236 TabWS->addColumn(
"double",
"Start Row");
2237 TabWS->addColumn(
"double",
"End Row");
2238 TabWS->addColumn(
"double",
"Start Col");
2239 TabWS->addColumn(
"double",
"End Col");
2240 TabWS->addColumn(
"double",
"TotIntensityError");
2241 TabWS->addColumn(
"str",
"SpecIDs");
2262 std::vector<double>
const ¶ms, std::vector<double>
const &errs,
2263 std::vector<std::string>
const &names,
const double Chisq,
2264 const double time,
string spec_idList) {
2273 if (Ibk < 0 || IIntensity < 0 || IVx < 0 || IVy < 0 || IVxy < 0 || Irow < 0 || Icol < 0) {
2274 throw std::runtime_error(
"Inconsistency found when updating output "
2275 "workspace. None of the indices for the "
2276 "parameters 'Background', 'Intensity', 'SScol', "
2277 "'SSrow', 'SSrc', 'Mrow', 'Mcol' can be "
2281 int newRowIndex = 0;
2284 newRowIndex =
static_cast<int>(TabWS->rowCount());
2286 auto TableRow =
static_cast<int>(TabWS->insertRow(newRowIndex));
2291 TabWS->getRef<
double>(std::string(
"Background"),
TableRow) = params[Ibk];
2292 TabWS->getRef<
double>(std::string(
"Channel"),
TableRow) = chan;
2294 TabWS->getRef<
double>(std::string(
"Intensity"),
TableRow) = params[IIntensity];
2295 TabWS->getRef<
double>(std::string(
"FitIntensityError"),
TableRow) = errs[IIntensity] * sqrt(chisq);
2296 TabWS->getRef<
double>(std::string(
"Mcol"),
TableRow) = params[Icol];
2297 TabWS->getRef<
double>(std::string(
"Mrow"),
TableRow) = params[Irow];
2299 TabWS->getRef<
double>(std::string(
"SScol"),
TableRow) = params[IVx];
2300 TabWS->getRef<
double>(std::string(
"SSrow"),
TableRow) = params[IVy];
2302 TabWS->getRef<
double>(std::string(
"SSrc"),
TableRow) = params[IVxy];
2303 TabWS->getRef<
double>(std::string(
"NCells"),
TableRow) = ncells;
2304 TabWS->getRef<
double>(std::string(
"ChiSqrOverDOF"),
TableRow) = chisq;
2307 TabWS->getRef<
double>(std::string(
"BackgroundError"),
TableRow) = errs[Ibk] *
SQRT(chisq);
2314 TabWS->getRef<
double>(std::string(
"ISAWIntensityError"),
TableRow) =
2315 sqrt(
m_AttributeValues->CalcISAWIntensityVariance(params.data(), errs.data(), Chisq));
2321 TabWS->getRef<
double>(std::string(
"Time"),
TableRow) = time;
2327 TabWS->getRef<
double>(std::string(
"End Row"),
TableRow) =
2331 TabWS->getRef<
double>(std::string(
"End Col"),
TableRow) =
2334 TabWS->getRef<
string>(std::string(
"SpecIDs"),
TableRow) = std::move(spec_idList);
2354 std::vector<std::string>
const &names,
double &TotVariance,
2355 double &TotIntensity,
double const TotSliceIntensity,
2356 double const TotSliceVariance,
double const chisqdivDOF,
2364 double intensity = 0;
2366 err =
m_AttributeValues->CalcISAWIntensityVariance(params.data(), errs.data(), chisqdivDOF);
2369 TotIntensity += intensity;
2372 g_log.
debug() <<
"TotIntensity/TotVariance=" << TotIntensity <<
"/" << TotVariance <<
'\n';
2406 double alpha = .5 * (r - 1.0);
2407 alpha = std::min(1.0, alpha);
2430 double IntensityBackError = errs[
IBACK] * sqrt(B);
2432 ExperimVar += IntensityBackError * IntensityBackError * ncells * ncells + params[
IBACK] * ncells;
2435 double alpha = .5 * (r - 1.0);
2436 alpha = std::min(1.0, alpha);
2457 if (params[
IVXX] <= 0 || params[
IVYY] <= 0)
2472 if (sgn * NstdX < 9) {
2473 auto xx =
static_cast<int>(sgn * NstdX);
2474 double a = probs[xx];
2478 P = a + (b - a) * (sgn * NstdX - xx);
2491 if (sgn * NstdY < 9) {
2492 auto xx =
static_cast<int>(sgn * NstdY);
2493 double a = probs[xx];
2497 P = a + (b - a) * (sgn * NstdY - xx);
2506 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.
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...
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
void Fit(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.
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.
void PreFit(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.
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.
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.
std::string getBankName() const
Find the name of the bank that is the parent of the detector.
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.
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.
int getDetectorID() const
Get the ID of the detector at the center of the peak
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< TableWorkspace > TableWorkspace_sptr
shared pointer to Mantid::DataObjects::TableWorkspace
std::shared_ptr< PeaksWorkspace > PeaksWorkspace_sptr
Typedef for a shared pointer to a peaks workspace.
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.