27bool compareMomentum(
const std::array<double, 4> &v1,
const std::array<double, 4> &v2) {
return (v1[3] < v2[3]); }
31const std::string LOG_CHARGE_NAME(
"proton_charge");
35 : m_hmin(0.0f), m_hmax(0.0f), m_kmin(0.0f), m_kmax(0.0f), m_lmin(0.0f), m_lmax(0.0f), m_dEmin(0.f), m_dEmax(0.f),
36 m_Ei(0.), m_ki(0.), m_kfmin(0.), m_kfmax(0.), m_hIntegrated(true), m_kIntegrated(true), m_lIntegrated(true),
37 m_dEIntegrated(true), m_UB(3, 3, true), m_W(3, 3, true), m_hIdx(-1), m_kIdx(-1), m_lIdx(-1), m_eIdx(-1),
38 m_samplePos(), m_beamDir(), m_numExptInfos(0), m_diffraction(true), m_accumulate(false) {}
46 const size_t nalgs =
history.size();
47 const auto &lastAlgorithm =
history.getAlgorithmHistory(nalgs - 1);
50 if (lastAlgorithm->name() ==
"ConvertToMD") {
52 emode = lastAlgorithm->getPropertyValue(
"dEAnalysisMode");
54 if ((lastAlgorithm->name() ==
"Load" || lastAlgorithm->name() ==
"LoadMD") && nalgs > 1) {
55 const auto &penultimateAlgorithm =
history.getAlgorithmHistory(nalgs - 2);
56 if (penultimateAlgorithm->name() ==
"ConvertToMD") {
57 return penultimateAlgorithm->getPropertyValue(
"dEAnalysisMode");
60 throw std::invalid_argument(
"The last algorithm in the history of the "
61 "input workspace is not ConvertToMD");
74 binMD->setPropertyValue(
"AxisAligned",
"1");
75 for (
auto prop : props) {
76 const auto &propName = prop->name();
77 if (propName !=
"FluxWorkspace" && propName !=
"SolidAngleWorkspace" &&
78 propName !=
"TemporaryNormalizationWorkspace" && propName !=
"OutputNormalizationWorkspace" &&
79 propName !=
"SkipSafetyCheck") {
80 binMD->setPropertyValue(propName, prop->value());
83 binMD->executeAsChildAlg();
85 return std::dynamic_pointer_cast<MDHistoWorkspace>(outputWS);
94 std::shared_ptr<IMDHistoWorkspace>
tmp = this->
getProperty(
"TemporaryNormalizationWorkspace");
95 m_normWS = std::dynamic_pointer_cast<MDHistoWorkspace>(
tmp);
114 const auto ¤tRun =
m_inputWS->getExperimentInfo(expInfoIndex)->run();
116 std::vector<coord_t> otherDimValues;
118 for (
size_t i = lastCol; i <
m_inputWS->getNumDims(); i++) {
119 const auto dimension =
m_inputWS->getDimension(i);
120 auto dimMin =
static_cast<float>(dimension->getMinimum());
121 auto dimMax =
static_cast<float>(dimension->getMaximum());
124 auto value =
static_cast<coord_t>(dimProp->firstValue());
125 otherDimValues.emplace_back(
value);
128 if (value < dimMin || value > dimMax) {
129 skipNormalization =
true;
133 return otherDimValues;
152 for (
size_t row = 0; row < nrm1; row++)
154 const auto dimen =
m_normWS->getDimension(row);
155 const auto dimMin(dimen->getMinimum()), dimMax(dimen->getMaximum());
162 skipNormalization =
true;
171 skipNormalization =
true;
180 skipNormalization =
true;
190 skipNormalization =
true;
193 for (
size_t col = lastCol; col < ncm1; col++)
196 double val = otherDimValues.at(col - lastCol);
197 if (val > dimMax || val < dimMin) {
198 skipNormalization =
true;
212 m_hX = std::vector<double>(hDim.getNBoundaries());
213 for (
size_t i = 0; i <
m_hX.size(); ++i) {
214 m_hX[i] = hDim.getX(i);
219 m_kX = std::vector<double>(kDim.getNBoundaries());
220 for (
size_t i = 0; i <
m_kX.size(); ++i) {
221 m_kX[i] = kDim.getX(i);
226 m_lX = std::vector<double>(lDim.getNBoundaries());
227 for (
size_t i = 0; i <
m_lX.size(); ++i) {
228 m_lX[i] = lDim.getX(i);
234 m_eX = std::vector<double>(eDim.getNBoundaries());
235 for (
size_t i = 0; i <
m_eX.size(); ++i) {
236 double temp =
m_Ei - eDim.getX(i);
237 temp = std::max(temp, 0.);
238 m_eX[i] = std::sqrt(energyToK * temp);
275 const auto ¤tExptInfo = *(
m_inputWS->getExperimentInfo(expInfoIndex));
276 const auto &spectrumInfo = currentExptInfo.spectrumInfo();
278 currentExptInfo,
"RUBW_MATRIX"));
279 Qtransform = currentExptInfo.run().getGoniometerMatrix() * Qtransform;
281 const double protonCharge = currentExptInfo.run().getProtonCharge();
294 uint16_t expInfoIndex) {
295 const auto ¤tExptInfo = *(
m_inputWS->getExperimentInfo(expInfoIndex));
296 std::vector<double> lowValues = getLogValues<VectorDoubleProperty>(currentExptInfo,
"MDNorm_low");
297 std::vector<double> highValues = getLogValues<VectorDoubleProperty>(currentExptInfo,
"MDNorm_high");
303 const double protonCharge = currentExptInfo.run().getProtonCharge();
304 const double protonChargeBkgd =
307 const auto &spectrumInfo = currentExptInfo.spectrumInfo();
309 calculateNormInner(spectrumInfo, otherValues, protonCharge, protonChargeBkgd, Qtransform, lowValues, highValues);
320 const auto ¤tExptInfo = *(
m_inputWS->getExperimentInfo(expInfoIndex));
321 const auto &spectrumInfo = currentExptInfo.spectrumInfo();
322 bool isMDNorm =
false;
323 std::vector<double> lowValues, highValues;
326 UBWSymm = getLogValues<VectorDoubleProperty>(
327 currentExptInfo,
"RUBW_MATRIX");
330 throw std::runtime_error(
"Continuous rotation and background workspace not yet implemented.");
334 lowValues = getLogValues<VectorDoubleProperty>(currentExptInfo,
"MDNorm_low");
335 highValues = getLogValues<VectorDoubleProperty>(currentExptInfo,
"MDNorm_high");
336 if ((lowValues.size() != spectrumInfo.size()) || (highValues.size() != spectrumInfo.size())) {
337 g_log.
warning() <<
"Incompatible detector and spectrum size. Using original data limits.\n";
338 const auto &binBoundaries = currentExptInfo.run().getBinBoundaries();
339 const double runEmin = binBoundaries.front();
340 const double runEmax = binBoundaries.back();
341 lowValues.assign(spectrumInfo.size(), runEmin);
342 highValues.assign(spectrumInfo.size(), runEmax);
347 const Run &run = currentExptInfo.run();
349 throw std::runtime_error(
"Wokspace does not contain the proton charge log. Cannot continue.");
353 double progressEnd = 0.3 + 0.7 * (expInfoIndex + 1) /
m_numExptInfos;
354 double normfac = 1.0;
355 if (
auto *factor = run.
hasProperty(
"NormalizationFactor")
358 normfac = (*factor)();
360 std::istringstream tosplit;
363 tosplit.str((*logTimesStr)());
365 throw std::runtime_error(
"useLogTimes property needs to be defined for Continuous Normalization");
367 std::vector<TimeSeriesProperty<double> *> logs;
368 std::vector<size_t> movingGonioIndex;
371 std::vector<Types::Core::DateAndTime> protonTimes = protonlog->
timesAsVector();
374 for (std::string
name; std::getline(tosplit,
name,
',');) {
378 movingGonioIndex.push_back(logs.size() - 1);
383 if (protonlog->
units().find(
"picoCoulomb") != std::string::npos) {
387 if (movingGonioIndex.size() == 1) {
391 const auto &gonioAxLog = logs[movingGonioIndex[0]];
392 std::vector<double> filteredVals = gonioAxLog->filteredValuesAsVector(&timeroi);
393 const auto &[min, max] = std::minmax_element(filteredVals.begin(), filteredVals.end());
394 std::vector<double> gonioCharge(
static_cast<int>((*max - *min) /
GONIOBINSTEP) + 1, 0.0);
395 for (
size_t n = 0;
n < protonCharge.size();
n++) {
396 double logval = gonioAxLog->getSingleValue(protonTimes[
n]);
397 if (std::isnan(logval) || logval > *max || logval < *min) {
400 auto idx =
static_cast<size_t>(floor((logval - *min) /
GONIOBINSTEP));
401 gonioCharge[idx] += protonCharge[
n];
403 m_progress->resetNumSteps(
static_cast<int64_t
>(gonioCharge.size()), progressStart, progressEnd);
404 for (
size_t n = 0;
n < gonioCharge.size();
n++) {
408 auto nn =
static_cast<double>(
n);
413 calculateNormInner(spectrumInfo, otherValues, gonioCharge[
n] / normfac, 0., Qtransform, lowValues, highValues);
421 double chargeSum = 0.0;
423 bool skipIter =
false;
424 m_progress->resetNumSteps(
static_cast<int64_t
>(protonCharge.size()), progressStart, progressEnd);
425 for (
size_t n = 0;
n < protonCharge.size();
n++) {
426 chargeSum += protonCharge[
n];
428 size_t index =
static_cast<int>(floor(
static_cast<double>(
n - i0) / 2.)) + i0;
431 double logval = logs[gAx]->getSingleValue(protonTimes[
index]);
432 if (std::isnan(logval)) {
442 calculateNormInner(spectrumInfo, otherValues, chargeSum / normfac, 0., Qtrans, lowValues, highValues);
459 const double protonCharge,
const double protonChargeBkgd,
461 const std::vector<double> &highValues) {
463 const auto ndets =
static_cast<int64_t
>(spectrumInfo.
size());
467 bool thread_safe =
true;
471 fluxDetToIdx = integrFlux->getDetectorIDToWorkspaceIndexMap();
474 if (solidAngleWS !=
nullptr) {
476 solidAngDetToIdx = solidAngleWS->getDetectorIDToWorkspaceIndexMap();
482 throw std::runtime_error(
"N points are different");
485 bool isMDNorm = !lowValues.empty();
496 for (int64_t i = 0; i < ndets; i++) {
503 double phi = spectrumInfo.
phi(i);
510 if (
auto index = fluxDetToIdx.find(detID);
index != fluxDetToIdx.end()) {
511 wsIdx =
index->second;
518 std::vector<std::array<double, 4>> intersections;
519 std::vector<coord_t> pos, posNew;
526 if (intersections.empty())
530 double solid = protonCharge;
531 double bkgdSolid = protonChargeBkgd;
533 double solid_angle_factor = solidAngleWS->y(solidAngDetToIdx.at(detID))[0];
534 solid = solid_angle_factor * protonCharge;
535 bkgdSolid = solid_angle_factor * protonChargeBkgd;
540 std::vector<double> yValues;
543 std::vector<double> xValues(intersections.size());
544 yValues.resize(intersections.size());
545 auto x = xValues.begin();
546 for (
auto it = intersections.begin(); it != intersections.end(); ++it, ++
x) {
557 pos.resize(vmdDims + otherValues.size() + 1);
558 std::copy(otherValues.begin(), otherValues.end(), pos.begin() + vmdDims);
559 pos.emplace_back(1.f);
560 for (
auto it = intersections.begin() + 1; it != intersections.end(); ++it) {
561 const auto &curIntSec = *it;
562 const auto &prevIntSec = *(it - 1);
565 : (curIntSec[3] * curIntSec[3] - prevIntSec[3] * prevIntSec[3]) / energyToK;
570 std::transform(curIntSec.data(), curIntSec.data() + vmdDims, prevIntSec.data(), pos.begin(),
571 [](
const double rhs,
const double lhs) { return static_cast<coord_t>(0.5 * (rhs + lhs)); });
575 pos[3] =
static_cast<coord_t>(
m_Ei - pos[3] * pos[3] / energyToK);
578 size_t linIndex =
m_normWS->getLinearIndexAtCoord(posNew.data());
579 if (linIndex ==
static_cast<size_t>(-1))
584 auto k =
static_cast<size_t>(std::distance(intersections.begin(), it));
585 delta = (yValues[k] - yValues[k - 1]);
608 std::vector<double> &yValues)
const {
609 assert(xValues.size() == yValues.size());
612 const auto &xData = integrFlux.
x(sp);
613 const double xStart = xData.front();
614 const double xEnd = xData.back();
619 const auto &yData = integrFlux.
y(sp);
620 size_t spSize = yData.size();
622 const double yMin = 0.0;
623 const double yMax = yData.back();
625 size_t nData = xValues.size();
627 if (xValues[nData - 1] < xStart) {
628 std::fill(yValues.begin(), yValues.end(), yMin);
633 if (xValues[0] > xEnd) {
634 std::fill(yValues.begin(), yValues.end(), yMax);
640 while (i < nData - 1 && xValues[i] < xStart) {
645 for (; i < nData; i++) {
647 if (j >= spSize - 1) {
650 double xi = xValues[i];
651 while (j < spSize - 1 && xi > xData[j])
654 if (xi == xData[j]) {
655 yValues[i] = yData[j];
656 }
else if (j == spSize - 1) {
661 double x0 = xData[j - 1];
662 double x1 = xData[j];
663 double y0 = yData[j - 1];
664 double y1 = yData[j];
665 yValues[i] = y0 + (y1 - y0) * (xi - x0) / (x1 - x0);
689 double kfmin, kfmax, kimin, kimax;
690 bool isMDNorm = !std::isnan(lowvalue);
692 qout =
V3D(sin(theta) * cos(phi), sin(theta) * sin(phi), cos(theta));
693 qin =
V3D(0., 0., 1.);
695 kimin = kfmin = lowvalue;
696 kimax = kfmax = highvalue;
698 kimin = kimax = std::sqrt(energyToK *
m_Ei);
699 kfmin = std::sqrt(energyToK * (
m_Ei - highvalue));
700 kfmax = std::sqrt(energyToK * (
m_Ei - lowvalue));
704 qin = qout =
V3D(-sin(theta) * cos(phi), -sin(theta) * sin(phi), 1. - cos(theta));
708 qout =
V3D(sin(theta) * cos(phi), sin(theta) * sin(phi), cos(theta));
709 qin =
V3D(0., 0., 1.);
710 kimin = kimax =
m_ki;
716 qout = transform * qout;
717 qin = transform * qin;
722 double hStart = qin.
X() * kimin - qout.
X() * kfmin, hEnd = qin.
X() * kimax - qout.
X() * kfmax;
723 double kStart = qin.
Y() * kimin - qout.
Y() * kfmin, kEnd = qin.
Y() * kimax - qout.
Y() * kfmax;
724 double lStart = qin.
Z() * kimin - qout.
Z() * kfmin, lEnd = qin.
Z() * kimax - qout.
Z() * kfmax;
726 auto hNBins =
m_hX.size();
727 auto kNBins =
m_kX.size();
728 auto lNBins =
m_lX.size();
729 auto eNBins =
m_eX.size();
730 intersections.clear();
731 intersections.reserve(hNBins + kNBins + lNBins + eNBins + 8);
734 if (
fabs(hStart - hEnd) > eps) {
735 double fmom = (kfmax - kfmin) / (hEnd - hStart);
736 double fk = (kEnd - kStart) / (hEnd - hStart);
737 double fl = (lEnd - lStart) / (hEnd - hStart);
739 for (
size_t i = 0; i < hNBins; i++) {
741 if ((hi >=
m_hmin) && (hi <=
m_hmax) && ((hStart - hi) * (hEnd - hi) < 0)) {
744 double ki = fk * (hi - hStart) + kStart;
745 double li = fl * (hi - hStart) + lStart;
747 double momi = fmom * (hi - hStart) + kfmin;
748 intersections.push_back({{hi, ki, li, momi}});
754 double momhMin = fmom * (
m_hmin - hStart) + kfmin;
755 if ((momhMin - kfmin) * (momhMin - kfmax) < 0)
758 double khmin = fk * (
m_hmin - hStart) + kStart;
759 double lhmin = fl * (
m_hmin - hStart) + lStart;
761 intersections.push_back({{
m_hmin, khmin, lhmin, momhMin}});
764 double momhMax = fmom * (
m_hmax - hStart) + kfmin;
765 if ((momhMax - kfmin) * (momhMax - kfmax) <= 0) {
767 double khmax = fk * (
m_hmax - hStart) + kStart;
768 double lhmax = fl * (
m_hmax - hStart) + lStart;
770 intersections.push_back({{
m_hmax, khmax, lhmax, momhMax}});
777 if (
fabs(kStart - kEnd) > eps) {
778 double fmom = (kfmax - kfmin) / (kEnd - kStart);
779 double fh = (hEnd - hStart) / (kEnd - kStart);
780 double fl = (lEnd - lStart) / (kEnd - kStart);
782 for (
size_t i = 0; i < kNBins; i++) {
784 if ((ki >=
m_kmin) && (ki <=
m_kmax) && ((kStart - ki) * (kEnd - ki) < 0)) {
787 double hi = fh * (ki - kStart) + hStart;
788 double li = fl * (ki - kStart) + lStart;
790 double momi = fmom * (ki - kStart) + kfmin;
791 intersections.push_back({{hi, ki, li, momi}});
797 double momkMin = fmom * (
m_kmin - kStart) + kfmin;
798 if ((momkMin - kfmin) * (momkMin - kfmax) < 0) {
800 double hkmin = fh * (
m_kmin - kStart) + hStart;
801 double lkmin = fl * (
m_kmin - kStart) + lStart;
803 intersections.push_back({{hkmin,
m_kmin, lkmin, momkMin}});
806 double momkMax = fmom * (
m_kmax - kStart) + kfmin;
807 if ((momkMax - kfmin) * (momkMax - kfmax) <= 0) {
809 double hkmax = fh * (
m_kmax - kStart) + hStart;
810 double lkmax = fl * (
m_kmax - kStart) + lStart;
812 intersections.push_back({{hkmax,
m_kmax, lkmax, momkMax}});
819 if (
fabs(lStart - lEnd) > eps) {
820 double fmom = (kfmax - kfmin) / (lEnd - lStart);
821 double fh = (hEnd - hStart) / (lEnd - lStart);
822 double fk = (kEnd - kStart) / (lEnd - lStart);
824 for (
size_t i = 0; i < lNBins; i++) {
826 if ((li >=
m_lmin) && (li <=
m_lmax) && ((lStart - li) * (lEnd - li) < 0)) {
829 double hi = fh * (li - lStart) + hStart;
830 double ki = fk * (li - lStart) + kStart;
832 double momi = fmom * (li - lStart) + kfmin;
833 intersections.push_back({{hi, ki, li, momi}});
839 double momlMin = fmom * (
m_lmin - lStart) + kfmin;
840 if ((momlMin - kfmin) * (momlMin - kfmax) <= 0) {
842 double hlmin = fh * (
m_lmin - lStart) + hStart;
843 double klmin = fk * (
m_lmin - lStart) + kStart;
845 intersections.push_back({{hlmin, klmin,
m_lmin, momlMin}});
848 double momlMax = fmom * (
m_lmax - lStart) + kfmin;
849 if ((momlMax - kfmin) * (momlMax - kfmax) < 0) {
851 double hlmax = fh * (
m_lmax - lStart) + hStart;
852 double klmax = fk * (
m_lmax - lStart) + kStart;
854 intersections.push_back({{hlmax, klmax,
m_lmax, momlMax}});
862 for (
size_t i = 0; i < eNBins; i++) {
863 double kfi =
m_eX[i];
864 if ((kfi - kfmin) * (kfi - kfmax) <= 0) {
865 double h = qin.
X() * kimin - qout.
X() * kfi;
866 double k = qin.
Y() * kimin - qout.
Y() * kfi;
867 double l = qin.
Z() * kimin - qout.
Z() * kfi;
869 intersections.push_back({{h, k, l, kfi}});
878 intersections.push_back({{hStart, kStart, lStart, kfmin}});
882 intersections.push_back({{hEnd, kEnd, lEnd, kfmax}});
886 std::stable_sort(intersections.begin(), intersections.end(), compareMomentum);
const std::vector< double > & rhs
double value
The value of the point.
std::map< DeltaEMode::Type, std::string > index
#define PARALLEL_START_INTERRUPT_REGION
Begins a block to skip processing is the algorithm has been interupted Note the end of the block if n...
#define PARALLEL_END_INTERRUPT_REGION
Ends a block to skip processing is the algorithm has been interupted Note the start of the block if n...
#define PRAGMA_OMP(expression)
#define PARALLEL_CHECK_INTERRUPT_REGION
Adds a check after a Parallel region to see if it was interupted.
std::vector< history_type > history
history information
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.
const std::vector< Kernel::Property * > & getProperties() const override
Get the list of managed properties.
const std::string name() const override=0
function to return a name of the algorithm, must be overridden in all algorithms
bool hasProperty(const std::string &name) const
Does the property exist on the object.
const Kernel::TimeROI & getTimeROI() const
Kernel::Property * getProperty(const std::string &name) const
Returns the named property as a pointer.
Kernel::TimeSeriesProperty< T > * getTimeSeriesProperty(const std::string &name) const
Returns a property as a time series property.
Base MatrixWorkspace Abstract Class.
const HistogramData::HistogramX & x(const size_t index) const
const HistogramData::HistogramY & y(const size_t index) const
This class stores information regarding an experimental run as a series of log entries.
const Geometry::Goniometer & getGoniometer() const
Return reference to the first const Goniometer object for this run.
API::SpectrumInfo is an intermediate step towards a SpectrumInfo that is part of Instrument-2....
bool isMonitor(const size_t index) const
Returns true if the detector(s) associated with the spectrum are monitors.
bool hasDetectors(const size_t index) const
Returns true if the spectrum is associated with detectors in the instrument.
detid_t firstDetectorID(const size_t index) const
Returns the detector ID of the first detector of the spectrum with given index.
double twoTheta(const size_t index) const
Returns the scattering angle 2 theta in radians (angle w.r.t.
bool isMasked(const size_t index) const
Returns true if the detector(s) associated with the spectrum are masked.
double phi(const size_t index) const
Returns the angle of the spectrum position about the lab-frame z axis, atan2(y, x),...
size_t size() const
Returns the size of the SpectrumInfo, i.e., the number of spectra.
std::unique_ptr< MDHistoWorkspace > clone() const
Returns a clone of the workspace.
Class to represent a particular goniometer setting, which is described by the rotation matrix.
void setRotationAngle(const std::string &name, double value)
Set rotation angle for an axis using motor name.
size_t getNumberAxes() const
const Kernel::DblMatrix & getR() const
Return global rotation matrix.
Crystallographic symmetry operations are composed of a rotational component, which is represented by ...
Kernel::V3D transformHKL(const Kernel::V3D &hkl) const
Transforms an index triplet hkl.
void warning(const std::string &msg)
Logs at warning level.
T Invert()
LU inversion routine.
void multiplyPoint(const std::vector< T > &in, std::vector< T > &out) const
Multiply M*Vec.
size_t numRows() const
Return the number of rows in the matrix.
void setColumn(const size_t nCol, const std::vector< T > &newCol)
size_t numCols() const
Return the number of columns in the matrix.
The concrete, templated class for properties.
virtual const std::string & units() const
Returns the units of the property, if any, as a string.
TimeROI : Object that holds information about when the time measurement was active.
A specialised Property class for holding a series of time-value pairs.
std::vector< TYPE > valuesAsVector() const
Return the time series's values (unfiltered) as a vector<TYPE>
std::vector< Types::Core::DateAndTime > timesAsVector() const override
Return the time series's times as a vector<DateAndTime>
constexpr double X() const noexcept
Get x.
constexpr double Y() const noexcept
Get y.
constexpr double Z() const noexcept
Get z.
std::vector< std::atomic< signal_t > > m_bkgdSignalArray
API::IMDEventWorkspace_sptr m_inputWS
Input workspace.
bool m_hIntegrated
flag for integrated h,k,l, dE dimensions
void createNormalizationWS(const DataObjects::MDHistoWorkspace &dataWS)
Create & cached the normalization workspace.
bool m_diffraction
Flag indicating if the input workspace is from diffraction.
API::IMDEventWorkspace_sptr m_backgroundWS
Input background workspace.
static constexpr double CHARGEBINSIZE
void calcIntegralsForIntersections(const std::vector< double > &xValues, const API::MatrixWorkspace &integrFlux, size_t sp, std::vector< double > &yValues) const
Linearly interpolate between the points in integrFlux at xValues and save the results in yValues.
void cacheDimensionXValues()
Stores the X values from each H,K,L,E dimension as member variables Energy dimension is transformed t...
Mantid::Kernel::DblMatrix m_W
W matrix.
void findIntegratedDimensions(const std::vector< coord_t > &otherDimValues, bool &skipNormalization)
Checks the normalization workspace against the indices of the original dimensions.
void calculateNormalization(const std::vector< coord_t > &otherValues, uint16_t expInfoIndex)
Computed the normalization for the input workspace (for MDNormSCD/MDNormDirectSC).
DataObjects::MDHistoWorkspace_sptr m_normWS
Normalization workspace.
Kernel::V3D m_samplePos
Sample position.
std::vector< coord_t > getValuesFromOtherDimensions(bool &skipNormalization, uint16_t expInfoIndex=0) const
Retrieve logged values from non-HKL dimensions.
void calculateNormInner(const API::SpectrumInfo &spectrumInfo, const std::vector< coord_t > &otherValues, const double protonCharge, const double protonChargeBkgd, const DblMatrix &Qtransform, const std::vector< double > &lowValues=std::vector< double >(), const std::vector< double > &highValues=std::vector< double >())
std::vector< std::atomic< signal_t > > m_signalArray
internal array to accumulate signals to avoid copying (serial) each loop
bool m_accumulate
Flag to accumulate normalization.
std::vector< double > m_eX
DataObjects::MDHistoWorkspace_sptr binInputWS()
Runs the BinMD algorithm on the input to provide the output workspace All slicing algorithm propertie...
void calculateIntersections(std::vector< std::array< double, 4 > > &intersections, const double theta, const double phi, const DblMatrix &transform, double lowvalue=std::nan(""), double highvalue=0)
Calculate the points of intersection for the given detector with cuboid surrounding the detector posi...
uint16_t m_numExptInfos
number of experiment infos
DataObjects::MDHistoWorkspace_sptr m_bkgdNormWS
Mantid::Kernel::Matrix< coord_t > m_transformation
matrix for transforming from intersections to positions in the normalization workspace
Kernel::V3D m_beamDir
Beam direction.
Mantid::Kernel::DblMatrix m_UB
UB matrix.
coord_t m_hmin
limits for h,k,l, dE dimensions
size_t m_hIdx
index of h,k,l, dE dimensions in the output workspaces
std::vector< double > m_kX
std::vector< double > m_hX
cached X values along dimensions h,k,l. dE
std::unique_ptr< API::Progress > m_progress
Progress bar.
Mantid::Kernel::DblMatrix calQTransform(const Kernel::DblMatrix &R, const Mantid::Geometry::SymmetryOperation &so, bool doInvert=true)
Calculate QTransform = (R * UB * SymmetryOperation * m_W)^-1.
void calculateNormContinuous(const std::vector< coord_t > &otherValues, uint16_t expInfoIndex, const Geometry::SymmetryOperation *so=nullptr)
Computes the normalization for the input workspace for the case of a continous rotation.
static constexpr double STATIONARYANGLIM
std::vector< double > m_lX
static constexpr double MINPROTONCHARGE
std::string inputEnergyMode() const
Currently looks for the ConvertToMD algorithm in the history.
static constexpr double GONIOBINSTEP
std::string m_convention
ki-kf for Inelastic convention; kf-ki for Crystallography convention
double m_Ei
cached values for incident energy and momentum, final momentum min/max
std::shared_ptr< Workspace > Workspace_sptr
shared pointer to Mantid::API::Workspace
std::shared_ptr< const MatrixWorkspace > MatrixWorkspace_const_sptr
shared pointer to the matrix workspace base class (const version)
std::shared_ptr< MDHistoWorkspace > MDHistoWorkspace_sptr
A shared pointer to a MDHistoWorkspace.
std::enable_if< std::is_pointer< Arg >::value, bool >::type threadSafe(Arg workspace)
Thread-safety check Checks the workspace to ensure it is suitable for multithreaded access.
void AtomicOp(std::atomic< T > &f, T d, BinaryOp op)
Uses std::compare_exchange_weak to update the atomic value f = op(f, d) Used to improve parallel scal...
Mantid::Kernel::Matrix< double > DblMatrix
Kernel::PropertyWithValue< std::vector< double > > VectorDoubleProperty
static constexpr double NeutronMass
Mass of the neutron in kg.
static constexpr double h
Planck constant in J*s.
static constexpr double meV
1 meV in Joules.
float coord_t
Typedef for the data type to use for coordinate axes in MD objects such as MDBox, MDEventWorkspace,...
std::unordered_map< detid_t, size_t > detid2index_map
Map with key = detector ID, value = workspace index.