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) {
145 "A 2D workspace with X values of time of flight");
148 "Name of the output table workspace with Log info");
151 "Workspace of Peaks");
153 declareProperty(
"PeakIndex", 0,
"Index of peak in PeaksWorkspace to integrate");
155 declareProperty(
"PeakQspan", .06,
"Max magnitude of Q of Peak to Q of Peak Center, where mod(Q)=1/d");
157 declareProperty(
"CalculateVariances",
true,
"Calc (co)variances given parameter values versus fit (co)Variances ");
159 declareProperty(
"Ties",
"",
"Tie parameters(Background,Intensity, Mrow,...) to values/formulas.");
180 seconds1 = time(
nullptr);
184 g_log.
debug(
"------------------Start Peak Integrate-------------------");
187 g_log.
error(
"Negative PeakQspans are not allowed. Use .17/G where G is the "
188 "max unit cell length");
189 throw std::runtime_error(
"Negative PeakQspans are not allowed in IntegratePeakTimeSlices");
195 throw std::runtime_error(
"Improper Input Workspace in IntegratePeakTimeSlices");
202 throw std::runtime_error(
"Improper Peaks Input");
207 Peak const &peak = peaksW->getPeak(indx);
211 std::shared_ptr<const Geometry::IComponent> panel_const =
214 std::shared_ptr<Geometry::IComponent> panel = std::const_pointer_cast<Geometry::IComponent>(panel_const);
216 if (!panel || !panel_const) {
218 throw std::runtime_error(
"Cannot get panel for a peak");
222 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;
253 size_t wsIndx = (it->second);
263 const auto &
X = inpWkSpace->x(wsIndx);
266 dChan = max<int>(dChan, MinTimeSpan);
272 double neighborRadius;
274 neighborRadius = min<double>(MaxNeighborhoodRadius, NeighborhoodRadiusDivPeakRadius * R);
277 Nneighbors = min<int>(Nneighbors,
static_cast<int>(inpWkSpace->getNumberHistograms()) - 2);
288 g_log.
error(
"Not enough neighboring pixels to fit ");
289 throw std::runtime_error(
"Not enough neighboring pixels to fit ");
293 double MaxCounts = -1;
296 for (
int dir = 1; dir > -2; dir -= 2) {
298 for (
int t = 0; t < dChan && !done; t++)
299 if (dir < 0 && t == 0) {
302 }
else if (Chan + dir * t < 0 || Chan + dir * t >=
static_cast<int>(
X.size()))
313 XXX->setCurrentRadius(R);
315 SetUpData1(Data, inpWkSpace, Chan + dir * t, Chan + dir * t, R, CenterDet->getPos(), spec_idList);
320 MaxChan = Chan + dir * t;
337 g_log.
debug() <<
" largest Channel,Radius,m_cellWidth,m_cellHeight = " << Chan <<
" " << R <<
" " <<
m_cellWidth
341 g_log.
error(
"Not enough rows and cols or time channels ");
342 throw std::runtime_error(
"Not enough rows and cols or time channels ");
356 int LastTableRow = -1;
357 auto origAttributeList = std::make_shared<DataModeHandler>();
358 auto lastAttributeList = std::make_shared<DataModeHandler>();
360 for (
int dir = 1; dir >= -1; dir -= 2) {
363 for (
int chan = 0; chan < dChan && !done; chan++)
364 if (dir < 0 && chan == 0) {
367 lastAttributeList = origAttributeList;
368 if (TabWS->rowCount() > 0)
371 }
else if (Chan + dir * chan < 0 || Chan + dir * chan >=
static_cast<int>(
X.size()))
375 int xchan = Chan + dir * chan;
377 size_t topIndex = xchan + 1;
378 if (topIndex >=
X.size())
379 topIndex =
X.size() - 1;
381 time = (
X[xchan] +
X[topIndex]) / 2.0;
391 g_log.
debug() <<
" A:chan=" << xchan <<
" time=" << time <<
" Radius=" << Radius <<
"row= " << lastRow
392 <<
" col=" << lastCol <<
'\n';
394 SetUpData(Data, inpWkSpace, panel, xchan, xchan, lastCol, lastRow, Cent, neighborRadius, Radius, spec_idList);
403 std::vector<double> params;
404 std::vector<double> errs;
405 std::vector<std::string> names;
411 Fit(Data, chisqOverDOF, done, names, params, errs, lastRow, lastCol, neighborRadius);
416 if (
isGoodFit(params, errs, names, chisqOverDOF)) {
417 LastTableRow =
UpdateOutputWS(TabWS, dir, xchan, params, errs, names, chisqOverDOF,
424 TotSliceVariance, chisqOverDOF, ncells);
428 if (dir == 1 && chan == 0)
429 origAttributeList = lastAttributeList;
444 int chanMin, chanMax;
445 if ((dir == 1 && chan == 0) || lastAttributeList->CellHeight <= 0) {
458 chanMin = std::min<int>(xchan, xchan - dir);
459 chanMax = chanMin + 1;
460 if (lastAttributeList->case4)
463 auto XXX = std::make_shared<DataModeHandler>(*lastAttributeList);
485 Fit(Data, chisqOverDOF, done, names, params, errs, lastRow, lastCol, neighborRadius);
489 if (!done &&
isGoodFit(params, errs, names, chisqOverDOF)) {
491 if (LastTableRow >= 0 && LastTableRow <
static_cast<int>(TabWS->rowCount()))
492 TabWS->removeRow(LastTableRow);
496 LastTableRow =
UpdateOutputWS(TabWS, dir, (chanMin + chanMax) / 2.0, params, errs, names, chisqOverDOF,
499 if (lastAttributeList->lastISAWVariance > 0 && lastAttributeList->CellHeight > 0) {
500 TotIntensity -= lastAttributeList->lastISAWIntensity;
501 TotVariance -= lastAttributeList->lastISAWVariance;
508 updatePeakInformation(params, errs, names, TotVariance, TotIntensity, TotSliceIntensity, TotSliceVariance,
513 if (dir == 1 && (chan == 0 || chan == 1)) {
520 auto XXX = std::make_shared<DataModeHandler>();
521 lastAttributeList = XXX;
534 throw std::runtime_error(
"Inconsistency found in algorithm "
535 "execution. The index for the parameter "
536 "Mrow is negative.");
539 lastRow = boost::math::iround(params[i]);
542 lastCol = boost::math::iround(params[i]);
556 }
catch (std::exception &EE1) {
557 std::cout <<
"Error in main reason=" << EE1.what() <<
'\n';
559 throw std::runtime_error(
" Error IntegratePeakTimeSlices:" + std::string(EE1.what()));
560 }
catch (std::string &mess) {
561 throw std::runtime_error(
"Error IntegratePeakTimeSlices:" + mess);
564 throw std::runtime_error(
"Error IntegratePeakTimeSlices:");
575 seconds2 = time(
nullptr);
576 double dif = difftime(seconds2, seconds1);
577 g_log.
debug() <<
"Finished Integr peak number " << indx <<
" in " << dif <<
" seconds\n";
579 }
catch (std::exception &ss) {
581 std::cout <<
"Error occurred XX " << ss.what() <<
'\n';
582 throw std::runtime_error(ss.what());
596 const Kernel::V3D &Center,
double &Radius,
int *&ArryofID) {
599 int MaxN = ArryofID[0];
605 comp->getBoundingBox(box);
607 double minx = Center.
X() - Radius;
608 double miny = Center.
Y() - Radius;
609 double minz = Center.
Z() - Radius;
610 double maxx = Center.
X() + Radius;
611 double maxy = Center.
Y() + Radius;
612 double maxz = Center.
Z() + Radius;
614 if (box.
xMin() >= maxx)
617 if (box.
xMax() <= minx)
621 if (box.
yMin() >= maxy)
624 if (box.
yMax() <= miny)
627 if (box.
zMin() >= maxz)
630 if (box.
zMax() <= minz)
634 auto det = std::dynamic_pointer_cast<Geometry::Detector>(comp);
637 V3D pos = det->getPos() - Center;
638 if (pos.
X() * pos.
X() + pos.
Y() * pos.
Y() + pos.
Z() * pos.
Z() < Radius * Radius) {
639 ArryofID[N] = det->getID();
646 auto Assembly = std::dynamic_pointer_cast<const Geometry::ICompAssembly>(comp);
653 for (
int i = 0; i < Assembly->nelements() && b; i++)
668 const V3D &oldCenter,
double NewRadius,
double &neighborRadius) {
669 double DD = (CentPos - oldCenter).norm();
670 bool changed =
false;
671 if (DD + NewRadius > neighborRadius) {
672 auto NN = int(NStdDevPeakSpan * NeighborhoodRadiusDivPeakRadius * NewRadius /
m_cellWidth * NStdDevPeakSpan *
673 NeighborhoodRadiusDivPeakRadius * NewRadius /
m_cellHeight);
680 neighborRadius = NeighborhoodRadiusDivPeakRadius * NewRadius;
686 neighborRadius -= DD;
704 double Q = 0, ScatAngle = 0, dScatAngle = 0, DetSpan = 0;
711 ScatAngle = acos(pos.
Z() / pos.
norm());
713 dScatAngle = 2 * dQ / Q * tan(ScatAngle / 2);
715 DetSpan = pos.
norm() * dScatAngle;
717 DetSpan =
fabs(DetSpan);
723 }
catch (std::exception &s) {
724 std::cout <<
"err in getNRowsCols, reason=" << s.what() <<
'\n';
744 const int specNum,
int &Centerchan) {
748 double time = peak.
getTOF();
749 double dtime = dQ / Q * time;
752 Centerchan = chanCenter;
755 int dchan = abs(chanCenter - chanLeft);
757 if (abs(chanRight - chanCenter) > dchan)
758 dchan = abs(chanRight - chanCenter);
760 dchan = max<int>(3, dchan);
782 int &NCOLS,
double &pixWidthx,
double &pixHeighty,
787 V3D detPos = det->getPos();
789 center.
setX(detPos.
X());
790 center.
setY(detPos.
Y());
791 center.
setZ(detPos.
Z());
793 std::shared_ptr<const Detector> dett = std::dynamic_pointer_cast<const Detector>(det);
795 pixWidthx = dett->getWidth();
796 pixHeighty = dett->getHeight();
799 V3D yaxis0(0.0, 1.0, 0.0);
808 xvec.
setX(xaxis0.
X());
809 xvec.
setY(xaxis0.
Y());
810 xvec.
setZ(xaxis0.
Z());
811 yvec.
setX(yaxis0.
X());
812 yvec.
setY(yaxis0.
Y());
813 yvec.
setZ(yaxis0.
Z());
818 throw std::invalid_argument(
"No instrument for peak");
819 std::shared_ptr<const IComponent> panel = inst->getComponentByName(peak.
getBankName());
821 std::shared_ptr<const RectangularDetector> ddet = std::dynamic_pointer_cast<const RectangularDetector>(panel);
824 std::pair<int, int> CR = ddet->getXYForDetectorID(det->getID());
827 pixWidthx = ddet->xstep();
828 pixHeighty = ddet->ystep();
830 NROWS = ddet->ypixels();
831 NCOLS = ddet->xpixels();
840 std::shared_ptr<const Component> compPanel = std::dynamic_pointer_cast<const Component>(panel);
841 std::shared_ptr<IComponent> panel1(compPanel->base()->clone());
850 panel1->getBoundingBox(B);
852 NROWS = boost::math::iround((B.
yMax() - B.
yMin()) / pixHeighty);
853 NCOLS = boost::math::iround((B.
xMax() - B.
xMin()) / pixWidthx);
866 const double col, std::vector<double> &StatBase) {
868 StatBase[
ISSIxx] += col * col * intensity;
869 StatBase[
ISSIyy] += intensity * row * row;
870 StatBase[
ISSIxy] += intensity * row * col;
871 StatBase[
ISSxx] += col * col;
872 StatBase[
ISSyy] += row * row;
873 StatBase[
ISSxy] += row * col;
874 StatBase[
ISSIx] += intensity * col;
875 StatBase[
ISSIy] += intensity * row;
876 StatBase[
ISSx] += col;
877 StatBase[
ISSy] += row;
894 std::vector<double> Res(7);
917 if (sigy * NstdY < 7 && sigy * NstdY >= 0)
919 x = probs[std::lround(sigy * NstdY)];
928 if (sigx * NstdX < 7 && sigx * NstdX > 0)
930 x1 = probs[std::lround(sigx * NstdX)];
967 if (Rx * Rx < 4 * Varx || Ry * Ry < 4 * Vary) {
971 return std::vector<double>();
981 double col = Mx / Den;
982 double row = My / Den;
983 std::vector<double>
Result(7);
1004 auto nBoundaryCells =
static_cast<int>(statBase[
INBoundary]);
1007 if (nBoundaryCells > 0) {
1008 double TotBoundaryIntensities = statBase[
ITotBoundary];
1009 b = TotBoundaryIntensities / nBoundaryCells;
1012 auto nCells =
static_cast<int>(statBase[
ISS1]);
1015 while (Den <= 0 && b != 0) {
1026 Varx = statBase[
INCol] / 7;
1027 Vary = statBase[
INRows] / 7;
1035 Ry * Ry < 4 * std::max(Vary,
VaryHW))
1057 double Mx = 0, My = 0, Sxx = 0, Syy = 0, Sxy = 0;
1059 double RangeX = statBase[
INCol] / 2;
1060 double RangeY = statBase[
INRows] / 2;
1062 while (!done && ntimes < 29) {
1063 Mx = statBase[
ISSIx] - b * statBase[
ISSx];
1064 My = statBase[
ISSIy] - b * statBase[
ISSy];
1065 Sxx = (statBase[
ISSIxx] - b * statBase[
ISSxx] - Mx * Mx / Den) / Den;
1066 Syy = (statBase[
ISSIyy] - b * statBase[
ISSyy] - My * My / Den) / Den;
1067 Sxy = (statBase[
ISSIxy] - b * statBase[
ISSxy] - Mx * My / Den) / Den;
1071 if (Sxx <= RangeX / 12 || Syy <= RangeY / 12 || Sxy * Sxy / Sxx / Syy > .9) {
1074 if (ntimes + 1 == 29)
1113 if (Rx * Rx > 4 * Vx)
1118 if (Ry * Ry > 4 * Vy)
1124 double NewRadius = 1.4 * max<double>(MinRowColSpan * max<double>(
CellWidth,
CellHeight), 4.5 * DD);
1125 NewRadius = mult * min<double>(
baseRCRadius, NewRadius);
1144 const std::vector<double> &counts) {
1145 double minCount, maxCount;
1146 const auto &
X = xvals;
1147 const auto &
Y = yvals;
1148 const auto &C = counts;
1151 auto N =
static_cast<int>(
X.size());
1158 minCount = maxCount = C[0];
1162 double lowX, lowY, highX, highY;
1163 lowX = highX =
X[0];
1164 lowY = highY =
Y[0];
1166 for (
int i = 1; i < N; i++) {
1169 else if (
X[i] > highX)
1174 else if (
Y[i] > highY)
1177 if (C[i] > maxCount) {
1182 }
else if (C[i] < minCount) {
1185 }
else if (C[i] == maxCount)
1192 if (minCount == maxCount)
1198 double dCount = std::max(.51, (maxCount - minCount) / 6.2);
1199 double CountUp = (maxCount + minCount) / 2 + dCount;
1200 double CountLow = (maxCount + minCount) / 2 - dCount;
1201 double dSpanx = (highX - lowX) / 6.;
1202 double dSpany = (highY - lowY) / 6.0;
1208 double offset = std::max(.2, (maxCount - minCount) / 20);
1209 double TotR_max = 0;
1210 double TotR_min = 0;
1215 for (
int i = 0; i < N; i++) {
1216 if (C[i] > maxCount - offset) {
1219 TotR_max += C[i] * sqrt((
X[i] - MaxX) * (
X[i] - MaxX) + (
Y[i] - MaxY) * (
Y[i] - MaxY));
1221 if (C[i] < minCount + offset)
1227 TotR_min += C[i] * sqrt((
X[i] - MaxX) * (
X[i] - MaxX) + (
Y[i] - MaxY) * (
Y[i] - MaxY));
1230 if (
fabs(MaxY -
Y[i]) < 1.2 &&
fabs(MaxX -
X[i]) > 1.2 && C[i] >= CountLow && C[i] <= CountUp &&
1231 fabs(MaxX -
X[i]) < dSpanx) {
1232 TotRx0 += (C[i] - minCount) * (
X[i] - MaxX) * (
X[i] - MaxX);
1233 TotCx += C[i] - minCount;
1236 if (
fabs(MaxX -
X[i]) < 1.2 &&
fabs(MaxY -
Y[i]) > 1.2 && C[i] >= CountLow && C[i] <= CountUp &&
1237 fabs(MaxY -
Y[i]) < dSpany) {
1238 TotRy0 += (C[i] - minCount) * (
Y[i] - MaxY) * (
Y[i] - MaxY);
1239 TotCy += C[i] - minCount;
1243 if (nMax + nMin == N)
1249 double AvR = .5 * (TotR_max / TotMax + TotR_min / TotMin);
1257 double TotR = 0, nR = -1, nRx = -1, nRy = -1;
1258 double MidVal = (TotMax / nMax + TotMin / nMin) / 2.0;
1259 double TotRx = 0, TotRy = 0;
1260 while ((nR <= 0 || nRy <= 0 || nRx <= 0) && offset < MidVal) {
1268 for (
int i = 0; i < N; i++)
1269 if (C[i] < MidVal + offset && C[i] > MidVal - offset) {
1270 double X1 =
X[i] - MaxX;
1271 double Y1 =
Y[i] - MaxY;
1272 TotR += sqrt(X1 * X1 + Y1 * Y1);
1274 if ((X1 >= -1.2 && X1 <= 1.2) &&
fabs(Y1) > 1.2 &&
fabs(Y1) < dSpany) {
1278 if ((Y1 >= -1.2 && Y1 <= 1.2) &&
fabs(X1) > 1.2 &&
fabs(X1) < dSpanx) {
1286 double AvR = TotR / nR;
1290 VarxHW = (TotRx / nRx) * (TotRx / nRx) / .8326 / .8326;
1292 VarxHW = TotRx0 * TotRx0 / TotCx / TotCx / .8326 / .8326;
1299 VaryHW = (TotRy / nRy) * (TotRy / nRy) / .8326 / .8326;
1301 VaryHW = TotRy0 * TotRy0 / TotCy / TotCy / .8326 / .8326;
1327 const std::shared_ptr<Geometry::IComponent> &comp,
const int chanMin,
1328 const int chanMax,
double CentX,
double CentY,
Kernel::V3D &CentNghbr,
1329 double &neighborRadius,
1330 double Radius,
string &spec_idList) {
1334 int NBadEdgeCells =
getProperty(
"NBadEdgePixels");
1338 NBadEdgeCells,
m_NROWS - NBadEdgeCells);
1344 SetUpData1(Data, inpWkSpace, chanMin, chanMax, Radius, CentPos1, spec_idList);
1360 double DD = (CentPos - CentNghbr).norm();
1362 if (DD + NewRadius > neighborRadius) {
1363 auto NN = int(NStdDevPeakSpan * NeighborhoodRadiusDivPeakRadius * NewRadius /
m_cellWidth * NStdDevPeakSpan *
1364 NeighborhoodRadiusDivPeakRadius * NewRadius /
m_cellHeight);
1372 neighborRadius = NeighborhoodRadiusDivPeakRadius * NewRadius;
1373 CentNghbr = CentPos;
1377 neighborRadius -= DD;
1382 NBadEdgeCells,
m_NROWS - NBadEdgeCells);
1387 SetUpData1(Data, inpWkSpace, chanMin, chanMax, NewRadius, CentPos, spec_idList);
1403 const int chanMax,
double Radius,
const Kernel::V3D &CentPos,
1404 string &spec_idList) {
1410 std::shared_ptr<Workspace2D> ws = std::dynamic_pointer_cast<Workspace2D>(Data);
1413 spec_idList.clear();
1416 StatBase.emplace_back(0);
1418 std::vector<double> yvalB;
1419 std::vector<double> errB;
1420 std::vector<double> xvalB;
1421 std::vector<double> YvalB;
1423 double TotBoundaryIntensities = 0;
1424 int nBoundaryCells = 0;
1425 double TotBoundaryVariances = 0;
1428 double minRow = 20000, maxRow = -1, minCol = 20000, maxCol = -1;
1432 std::vector<double> xRef;
1436 size_t workspaceIndex;
1440 throw std::runtime_error(
"No workspaceIndex for detID=" +
std::to_string(DetID));
1444 V3D pixPos = Det->getPos();
1449 V3D dist = pixPos - CentPos;
1453 spec_idList +=
std::to_string(inpWkSpace->getSpectrum(workspaceIndex).getSpectrumNo());
1458 double row =
m_ROW + R1a;
1463 double col =
m_COL + C1a;
1465 if (row > NBadEdges && col > NBadEdges && (
m_NROWS < 0 || row <
m_NROWS - NBadEdges) &&
1467 const auto &histogram = inpWkSpace->y(workspaceIndex);
1469 const auto &histoerrs = inpWkSpace->e(workspaceIndex);
1470 double intensity = 0;
1471 double variance = 0;
1472 for (
int chan = chanMin; chan <= chanMax; chan++) {
1473 intensity += histogram[chan];
1474 variance += histoerrs[chan] * histoerrs[chan];
1477 yvalB.emplace_back(intensity);
1480 errB.emplace_back(
sigma);
1481 xvalB.emplace_back(col);
1482 YvalB.emplace_back(row);
1484 xRef.emplace_back(
static_cast<double>(jj));
1487 updateStats(intensity, variance, row, col, StatBase);
1489 if ((pixPos - CentPos).norm() > BoundaryRadius) {
1490 TotBoundaryIntensities += intensity;
1493 TotBoundaryVariances += variance;
1519 auto pX = Kernel::make_cow<HistogramData::HistogramX>(std::move(xRef));
1524 ws->setCounts(0, yvalB);
1525 ws->setCountStandardDeviations(0, errB);
1526 ws->setCounts(1, xvalB);
1527 ws->setCounts(2, YvalB);
1532 StatBase[
INRows] = maxRow - minRow + 1;
1533 StatBase[
INCol] = maxCol - minCol + 1;
1561 if (sgn * (
X[0] - time) >= 0)
1564 if (sgn * (time -
X[
X.size() - 1u]) >= 0)
1565 return static_cast<int>(
X.size()) - 1;
1567 size_t end =
X.size() - 1u;
1568 for (
size_t i = 0; i < end; i++) {
1569 if (sgn * (time -
X[i]) >= 0 && sgn * (
X[i + 1u] - time) >= 0)
1570 return static_cast<int>(i);
1587 Varx = params[
IVXX];
1588 Vary = params[
IVYY];
1597 return Rx * Rx < NStdDevPeakSpan * NStdDevPeakSpan * std::max(Varx,
VarxHW) ||
1598 Ry * Ry < NStdDevPeakSpan * NStdDevPeakSpan * std::max(Vary,
VaryHW);
1608 std::ostringstream fun_str;
1610 fun_str <<
"name=BivariateNormal,";
1613 fun_str <<
"CalcVariances=1";
1615 fun_str <<
"CalcVariances=-1";
1621 for (
int i = 0; i < NN; i++) {
1625 return fun_str.str();
1639 const auto it = std::find(nameList.cbegin(), nameList.cend(), oneName);
1640 if (it != nameList.cend()) {
1641 return static_cast<int>(std::distance(nameList.cbegin(), it));
1700 double &Varyy,
const std::vector<double> &StatBase) {
1739 double back = TotBoundaryIntensities / nBoundaryCells;
1740 double backVar = std::max(nBoundaryCells / 50.0, TotBoundaryVariances) / nBoundaryCells / nBoundaryCells;
1741 double IntensVar = Variance + ncells * ncells * backVar;
1743 double relError = .25;
1752 double NSigs = NStdDevPeakSpan;
1754 NSigs = std::max(NStdDevPeakSpan,
1759 str << max<double>(0.0,
back_calc - NSigs * (1 + relError) * sqrt(backVar)) <<
"<Background<"
1760 << (back + NSigs * (1.8 + relError) * sqrt(backVar)) <<
","
1761 << max<double>(0.0,
Intensity_calc - NSigs * (1 + relError) * sqrt(IntensVar)) <<
"<Intensity<"
1764 double min = max<double>(0.0,
back_calc - NSigs * (1 + relError) * sqrt(backVar));
1765 double maxx = back + NSigs * (1.8 + relError) * sqrt(backVar);
1766 Bounds.emplace_back(min, maxx);
1767 Bounds.emplace_back(max<double>(0.0,
Intensity_calc - NSigs * (1 + relError) * sqrt(IntensVar)),
1769 double relErr1 = relError * .75;
1771 double minn = std::max(
MinCol - .5, (1 - relErr1) * val);
1772 maxx = std::min((1 + relErr1) * val,
MaxCol + .5);
1774 str <<
"," << minn <<
"<"
1777 Bounds.emplace_back(minn, maxx);
1781 minn = std::max(
MinRow - .5, (1 - relErr1) * val);
1782 maxx = std::min((1 + relErr1) * val,
MaxRow + .5);
1783 str <<
"," << minn <<
"<"
1786 Bounds.emplace_back(minn, maxx);
1790 double valmin = val;
1791 double valmax = val;
1793 valmin = std::min(val,
VarxHW);
1794 valmax = std::max(val,
VarxHW);
1798 str <<
"," << (1 - relErr1) * valmin <<
"<"
1800 <<
"<" << (1 + relErr1) * valmax;
1801 Bounds.emplace_back((1 - relErr1) * valmin, (1 + relErr1) * valmax);
1807 valmin = std::min(val,
VaryHW);
1808 valmax = std::max(val,
VaryHW);
1810 str <<
"," << (1 - relErr1) * valmin <<
"<"
1812 <<
"<" << (1 + relErr1) * valmax;
1813 Bounds.emplace_back((1 - relErr1) * valmin, (1 + relErr1) * valmax);
1834 std::vector<string> &names, std::vector<double> ¶ms, std::vector<double> &errs,
1835 double lastRow,
double lastCol,
double neighborRadius) {
1838 std::vector<std::pair<double, double>> Bounds;
1843 std::string SSS(
" Fit string ");
1848 fit_alg->setPropertyValue(
"Function", fun_str);
1850 fit_alg->setProperty(
"InputWorkspace", Data);
1851 fit_alg->setProperty(
"WorkspaceIndex", 0);
1852 fit_alg->setProperty(
"StartX", 0.0);
1853 fit_alg->setProperty(
"EndX", 0.0 +
static_cast<double>(
m_NeighborIDs[1]));
1854 fit_alg->setProperty(
"MaxIterations", 5000);
1855 fit_alg->setProperty(
"CreateOutput",
true);
1857 fit_alg->setProperty(
"Output",
"out");
1859 fit_alg->setProperty(
"MaxIterations", 50);
1862 if (tie.length() >
static_cast<size_t>(0))
1863 fit_alg->setProperty(
"Ties", tie);
1864 if (Constraints.length() >
static_cast<size_t>(0))
1865 fit_alg->setProperty(
"Constraints", Constraints);
1867 fit_alg->executeAsChildAlg();
1869 chisqOverDOF = fit_alg->getProperty(
"OutputChi2overDoF");
1870 std::string outputStatus = fit_alg->getProperty(
"OutputStatus");
1871 g_log.
debug() <<
"Chisq/OutputStatus=" << chisqOverDOF <<
"/" << outputStatus <<
'\n';
1877 for (
int prm = 0; prm < static_cast<int>(RRes->rowCount()) - 1; prm++) {
1878 names.emplace_back(RRes->getRef<
string>(
"Name", prm));
1879 params.emplace_back(RRes->getRef<
double>(
"Value", prm));
1880 double error = RRes->getRef<
double>(
"Error", prm);
1881 errs.emplace_back(
error);
1883 if (names.size() < 5) {
1887 double Varxx, Varxy, Varyy;
1890 params.emplace_back(Varxx);
1891 params.emplace_back(Varyy);
1892 params.emplace_back(Varxy);
1893 errs.emplace_back(0);
1894 errs.emplace_back(0);
1895 errs.emplace_back(0);
1898 }
catch (std::exception &Ex1)
1901 g_log.
error() <<
"Bivariate Error for PeakNum=" <<
static_cast<int>(
getProperty(
"PeakIndex")) <<
":"
1902 << std::string(Ex1.what()) <<
'\n';
1905 g_log.
error() <<
"Bivariate Error A for peakNum=" <<
static_cast<int>(
getProperty(
"PeakIndex")) <<
'\n';
1910 g_log.
debug() <<
" Thru Algorithm: chiSq=" << setw(7) << chisqOverDOF <<
'\n';
1911 g_log.
debug() <<
" Row,Col Radius=" << lastRow <<
"," << lastCol <<
"," << neighborRadius <<
'\n';
1913 double sqrtChisq = -1;
1914 if (chisqOverDOF >= 0)
1915 sqrtChisq = (chisqOverDOF);
1919 sqrtChisq =
SQRT(sqrtChisq);
1921 for (
size_t kk = 0; kk < params.size(); kk++) {
1922 g_log.
debug() <<
" Parameter " << setw(8) << names[kk] <<
" " << setw(8) << params[kk];
1924 g_log.
debug() <<
"(" << setw(8) << (errs[kk] * sqrtChisq) <<
")";
1925 if (Bounds.size() > kk) {
1926 pair<double, double> upLow = Bounds[kk];
1927 g_log.
debug() <<
" Bounds(" << upLow.first <<
"," << upLow.second <<
")";
1933 g_log.
debug() <<
"IsawIntensity= " << intensity <<
'\n';
1954 std::vector<string> &names, std::vector<double> ¶ms, std::vector<double> &errs,
1955 double lastRow,
double lastCol,
double neighborRadius) {
1959 if (background <= 0) {
1968 double minChiSqOverDOF = -1;
1969 double Bestparams[7];
1970 std::string Bestnames[7];
1971 for (
int i = 0; i < N; i++) {
1972 Fit(Data, chisqOverDOF, done, names, params, errs, lastRow, lastCol, neighborRadius);
1973 g_log.
debug() <<
"-----------------------" << i <<
"--------------------------\n";
1974 if ((minChiSqOverDOF < 0 || chisqOverDOF < minChiSqOverDOF) && (chisqOverDOF > 0) && !done) {
1975 for (
int j = 0; j < NParams; j++) {
1979 minChiSqOverDOF = chisqOverDOF;
1983 background = background / 2;
1989 for (
int j = 0; j < NParams; j++)
1993 for (
int i = 0; i < NParams; i++) {
1995 if (k >= 0 && k < NParams)
1999 Fit(Data, chisqOverDOF, done, names, params, errs, lastRow, lastCol, neighborRadius);
2013 std::vector<std::string>
const &names,
double chisqOverDOF) {
2016 throw std::runtime_error(
"Irrecoverable inconsistency found. The index for the "
2017 "parameter 'Background' is lower than zero.");
2021 throw std::runtime_error(
"Irrecoverable inconsistency found. The index for the "
2022 "parameter 'Intensity' is lower than zero.");
2024 if (chisqOverDOF < 0) {
2026 g_log.
debug() <<
" Bad Slice- negative chiSq= " << chisqOverDOF <<
'\n';
2031 int NBadEdgeCells =
getProperty(
"NBadEdgePixels");
2032 NBadEdgeCells =
static_cast<int>(.6 * NBadEdgeCells);
2042 g_log.
debug() <<
" Bad Slice. Negative Counts= "
2050 if ((x < MinGoodRatioFitvsExpIntenisites || x > MaxGoodRatioFitvsExpIntenisites) &&
2054 g_log.
debug() <<
" Bad Slice. Fitted Intensity & Observed "
2055 "Intensity(-back) too different. ratio="
2061 bool GoodNums =
true;
2062 bool paramBad =
false;
2063 auto BadParamNum =
static_cast<size_t>(-1);
2064 for (
size_t i = 0; i < errs.size(); i++)
2065 if (errs[i] != errs[i]) {
2069 }
else if (errs[i] < 0) {
2073 }
else if (params[i] != params[i]) {
2080 std::string
obj =
" parameter ";
2083 g_log.
debug() <<
" Bad Slice." <<
obj << BadParamNum <<
" is not a number\n";
2089 std::string Err(
"back ground is negative");
2090 if (params[Ibk] < -.002)
2094 Err =
"Intensity is negative";
2095 if (params[IIntensity] < 0)
2099 double IsawVariance =
m_AttributeValues->CalcISAWIntensityVariance(params.data(), errs.data(), chisqOverDOF);
2101 Err =
"Isaw Variance is negative";
2102 if (IsawVariance > 0) {
2105 if (IsawIntensity * IsawIntensity / IsawVariance < MinGoodIoverSigI * MinGoodIoverSigI)
2120 double maxPeakHeightTheoretical =
2126 if (maxPeakHeightTheoretical < 2 * AvHeight || AvHeight < 0 || maxPeakHeightTheoretical < 0) {
2128 g_log.
debug() <<
" Bad Slice. Peak too small= " << maxPeakHeightTheoretical <<
"/" << AvHeight <<
'\n';
2133 if (maxPeakHeightTheoretical < 1 && (params[
IVXX] > Nrows * Nrows / 4 || params[
IVYY] > Nrows * Nrows / 4)) {
2141 g_log.
debug() <<
" Bad Slice. Too steep of an exponential\n";
2156 double Varx, Vary, Cov;
2169 Varx = ParameterValues[
IVXX];
2170 Vary = ParameterValues[
IVYY];
2171 Cov = ParameterValues[
IVXY];
2176 if (Varx < MinVariationInXYvalues || Vary < MinVariationInXYvalues)
2179 if (Cov * Cov > MaxCorrCoeffinXY * Varx * Vary)
2198 const double ChiSqOverDOF,
const double TotVariance,
2201 double B = TotVariance / ncells;
2202 if (B < ChiSqOverDOF)
2205 double Variance = TotVariance + (backError * backError * B) * ncells * ncells + background * ncells;
2207 return SQRT(Variance);
2217 TabWS->addColumn(
"double",
"Time");
2218 TabWS->addColumn(
"double",
"Channel");
2219 TabWS->addColumn(
"double",
"Background");
2220 TabWS->addColumn(
"double",
"Intensity");
2221 TabWS->addColumn(
"double",
"Mcol");
2222 TabWS->addColumn(
"double",
"Mrow");
2223 TabWS->addColumn(
"double",
"SScol");
2224 TabWS->addColumn(
"double",
"SSrow");
2225 TabWS->addColumn(
"double",
"SSrc");
2226 TabWS->addColumn(
"double",
"NCells");
2227 TabWS->addColumn(
"double",
"ChiSqrOverDOF");
2228 TabWS->addColumn(
"double",
"TotIntensity");
2229 TabWS->addColumn(
"double",
"BackgroundError");
2230 TabWS->addColumn(
"double",
"FitIntensityError");
2231 TabWS->addColumn(
"double",
"ISAWIntensity");
2232 TabWS->addColumn(
"double",
"ISAWIntensityError");
2233 TabWS->addColumn(
"double",
"TotalBoundary");
2234 TabWS->addColumn(
"double",
"NBoundaryCells");
2235 TabWS->addColumn(
"double",
"Start Row");
2236 TabWS->addColumn(
"double",
"End Row");
2237 TabWS->addColumn(
"double",
"Start Col");
2238 TabWS->addColumn(
"double",
"End Col");
2239 TabWS->addColumn(
"double",
"TotIntensityError");
2240 TabWS->addColumn(
"str",
"SpecIDs");
2261 std::vector<double>
const ¶ms, std::vector<double>
const &errs,
2262 std::vector<std::string>
const &names,
const double Chisq,
2263 const double time,
string spec_idList) {
2272 if (Ibk < 0 || IIntensity < 0 || IVx < 0 || IVy < 0 || IVxy < 0 || Irow < 0 || Icol < 0) {
2273 throw std::runtime_error(
"Inconsistency found when updating output "
2274 "workspace. None of the indices for the "
2275 "parameters 'Background', 'Intensity', 'SScol', "
2276 "'SSrow', 'SSrc', 'Mrow', 'Mcol' can be "
2280 int newRowIndex = 0;
2283 newRowIndex =
static_cast<int>(TabWS->rowCount());
2285 auto TableRow =
static_cast<int>(TabWS->insertRow(newRowIndex));
2290 TabWS->getRef<
double>(std::string(
"Background"),
TableRow) = params[Ibk];
2291 TabWS->getRef<
double>(std::string(
"Channel"),
TableRow) = chan;
2293 TabWS->getRef<
double>(std::string(
"Intensity"),
TableRow) = params[IIntensity];
2294 TabWS->getRef<
double>(std::string(
"FitIntensityError"),
TableRow) = errs[IIntensity] * sqrt(chisq);
2295 TabWS->getRef<
double>(std::string(
"Mcol"),
TableRow) = params[Icol];
2296 TabWS->getRef<
double>(std::string(
"Mrow"),
TableRow) = params[Irow];
2298 TabWS->getRef<
double>(std::string(
"SScol"),
TableRow) = params[IVx];
2299 TabWS->getRef<
double>(std::string(
"SSrow"),
TableRow) = params[IVy];
2301 TabWS->getRef<
double>(std::string(
"SSrc"),
TableRow) = params[IVxy];
2302 TabWS->getRef<
double>(std::string(
"NCells"),
TableRow) = ncells;
2303 TabWS->getRef<
double>(std::string(
"ChiSqrOverDOF"),
TableRow) = chisq;
2306 TabWS->getRef<
double>(std::string(
"BackgroundError"),
TableRow) = errs[Ibk] *
SQRT(chisq);
2313 TabWS->getRef<
double>(std::string(
"ISAWIntensityError"),
TableRow) =
2314 sqrt(
m_AttributeValues->CalcISAWIntensityVariance(params.data(), errs.data(), Chisq));
2320 TabWS->getRef<
double>(std::string(
"Time"),
TableRow) = time;
2326 TabWS->getRef<
double>(std::string(
"End Row"),
TableRow) =
2330 TabWS->getRef<
double>(std::string(
"End Col"),
TableRow) =
2333 TabWS->getRef<
string>(std::string(
"SpecIDs"),
TableRow) = std::move(spec_idList);
2353 std::vector<std::string>
const &names,
double &TotVariance,
2354 double &TotIntensity,
double const TotSliceIntensity,
2355 double const TotSliceVariance,
double const chisqdivDOF,
2363 double intensity = 0;
2365 err =
m_AttributeValues->CalcISAWIntensityVariance(params.data(), errs.data(), chisqdivDOF);
2368 TotIntensity += intensity;
2371 g_log.
debug() <<
"TotIntensity/TotVariance=" << TotIntensity <<
"/" << TotVariance <<
'\n';
2405 double alpha = .5 * (r - 1.0);
2406 alpha = std::min(1.0, alpha);
2429 double IntensityBackError = errs[
IBACK] * sqrt(B);
2431 ExperimVar += IntensityBackError * IntensityBackError * ncells * ncells + params[
IBACK] * ncells;
2434 double alpha = .5 * (r - 1.0);
2435 alpha = std::min(1.0, alpha);
2453 int maxCol = minCol +
static_cast<int>(
StatBase[
INCol]) - 1;
2456 if (params[
IVXX] <= 0 || params[
IVYY] <= 0)
2462 double NstdX = 4 * min<double>(params[
IXMEAN] - minCol, maxCol - params[
IXMEAN]) / sqrt(params[
IVXX]);
2464 double NstdY = 4 * min<double>(params[
IYMEAN] - minRow, maxRow - params[
IYMEAN]) / sqrt(params[
IVYY]);
2471 if (sgn * NstdX < 9) {
2472 auto xx =
static_cast<int>(sgn * NstdX);
2473 double a = probs[xx];
2477 P = a + (b - a) * (sgn * NstdX - xx);
2490 if (sgn * NstdY < 9) {
2491 auto xx =
static_cast<int>(sgn * NstdY);
2492 double a = probs[xx];
2496 P = a + (b - a) * (sgn * NstdY - xx);
2505 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< 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.