Mantid
Loading...
Searching...
No Matches
MDNormBase.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2026 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7#pragma once
8
10#include "MantidAPI/Run.h"
15#include "MantidMDAlgorithms/DllConfig.h"
16
17namespace Mantid::MDAlgorithms {
18
20
21template <typename PropertyType> auto getLogValues(const API::ExperimentInfo &exptInfo, const std::string &logName) {
22 if (auto *prop = dynamic_cast<PropertyType *>(exptInfo.getLog(logName))) {
23 return (*prop)();
24 }
25 throw std::runtime_error("Log property missing or wrong type: " + logName + ". Cannot continue.");
26}
27
32class MANTID_MDALGORITHMS_DLL MDNormBase : public API::Algorithm {
33public:
34 MDNormBase();
35 // @return a string with the character that identifies each dimension in order (01234)
36 static std::string getDimensionChars() { return "012345"; }
37
38 // Parameters for continuous rotation processing when useLogTimes=True in ConvertToMD
39 static constexpr double CHARGEBINSIZE = 1.0; // Proton charge bin size in uA.hr for useLogTimes normalization
40 static constexpr double GONIOBINSTEP = 0.25; // Bin size in angle in degrees for useLogTimes normalization
41 static constexpr double MINPROTONCHARGE = 0.1; // Proton charge below which an angle will be ignored as no data
42 static constexpr double STATIONARYANGLIM = 0.1; // Angle size (degrees) below which a gonio is considered stationary
43
44protected:
45 std::string inputEnergyMode() const;
47 void createNormalizationWS(const DataObjects::MDHistoWorkspace &dataWS);
48 std::vector<coord_t> getValuesFromOtherDimensions(bool &skipNormalization, uint16_t expInfoIndex = 0) const;
49 void findIntegratedDimensions(const std::vector<coord_t> &otherDimValues, bool &skipNormalization);
50 void cacheDimensionXValues();
51 void calculateNormalization(const std::vector<coord_t> &otherValues, uint16_t expInfoIndex);
52 void calculateNormalization(const std::vector<coord_t> &otherValues, const Geometry::SymmetryOperation &so,
53 uint16_t expInfoIndex);
54 void calculateNormContinuous(const std::vector<coord_t> &otherValues, uint16_t expInfoIndex,
55 const Geometry::SymmetryOperation *so = nullptr);
56 void calculateNormInner(const API::SpectrumInfo &spectrumInfo, const std::vector<coord_t> &otherValues,
57 const double protonCharge, const double protonChargeBkgd, const DblMatrix &Qtransform,
58 const std::vector<double> &lowValues = std::vector<double>(),
59 const std::vector<double> &highValues = std::vector<double>());
60
61 void calcIntegralsForIntersections(const std::vector<double> &xValues, const API::MatrixWorkspace &integrFlux,
62 size_t sp, std::vector<double> &yValues) const;
63 void calculateIntersections(std::vector<std::array<double, 4>> &intersections, const double theta, const double phi,
64 const DblMatrix &transform, double lowvalue = std::nan(""), double highvalue = 0);
66 bool doInvert = true);
67
76 coord_t m_hmin, m_hmax, m_kmin, m_kmax, m_lmin, m_lmax, m_dEmin, m_dEmax;
78 double m_Ei, m_ki, m_kfmin, m_kfmax;
80 bool m_hIntegrated, m_kIntegrated, m_lIntegrated, m_dEIntegrated;
88 size_t m_hIdx, m_kIdx, m_lIdx, m_eIdx;
90 std::vector<double> m_hX, m_kX, m_lX, m_eX;
96 std::string m_convention;
104 std::unique_ptr<API::Progress> m_progress;
106 std::vector<std::atomic<signal_t>> m_signalArray;
107 std::vector<std::atomic<signal_t>> m_bkgdSignalArray;
108};
109
110} // namespace Mantid::MDAlgorithms
Base class from which all concrete algorithm classes should be derived.
Definition Algorithm.h:76
This class is shared by a few Workspace types and holds information related to a particular experimen...
Kernel::Property * getLog(const std::string &log) const
Access a log for this experiment.
Base MatrixWorkspace Abstract Class.
API::SpectrumInfo is an intermediate step towards a SpectrumInfo that is part of Instrument-2....
Crystallographic symmetry operations are composed of a rotational component, which is represented by ...
Class for 3D vectors.
Definition V3D.h:34
Base class for the three MDNorm, MDNormDirectSC and MDNormSCD algorithms with the common normalizatio...
Definition MDNormBase.h:32
std::vector< std::atomic< signal_t > > m_bkgdSignalArray
Definition MDNormBase.h:107
API::IMDEventWorkspace_sptr m_inputWS
Input workspace.
Definition MDNormBase.h:69
bool m_diffraction
Flag indicating if the input workspace is from diffraction.
Definition MDNormBase.h:100
static std::string getDimensionChars()
Definition MDNormBase.h:36
API::IMDEventWorkspace_sptr m_backgroundWS
Input background workspace.
Definition MDNormBase.h:74
Mantid::Kernel::DblMatrix m_W
W matrix.
Definition MDNormBase.h:84
DataObjects::MDHistoWorkspace_sptr m_normWS
Normalization workspace.
Definition MDNormBase.h:71
Kernel::V3D m_samplePos
Sample position.
Definition MDNormBase.h:92
std::vector< std::atomic< signal_t > > m_signalArray
internal array to accumulate signals to avoid copying (serial) each loop
Definition MDNormBase.h:106
bool m_accumulate
Flag to accumulate normalization.
Definition MDNormBase.h:102
std::vector< double > m_eX
Definition MDNormBase.h:90
uint16_t m_numExptInfos
number of experiment infos
Definition MDNormBase.h:98
DataObjects::MDHistoWorkspace_sptr m_bkgdNormWS
Definition MDNormBase.h:72
Mantid::Kernel::Matrix< coord_t > m_transformation
matrix for transforming from intersections to positions in the normalization workspace
Definition MDNormBase.h:86
Kernel::V3D m_beamDir
Beam direction.
Definition MDNormBase.h:94
Mantid::Kernel::DblMatrix m_UB
UB matrix.
Definition MDNormBase.h:82
std::unique_ptr< API::Progress > m_progress
Progress bar.
Definition MDNormBase.h:104
std::string m_convention
ki-kf for Inelastic convention; kf-ki for Crystallography convention
Definition MDNormBase.h:96
double m_Ei
cached values for incident energy and momentum, final momentum min/max
Definition MDNormBase.h:78
std::shared_ptr< IMDEventWorkspace > IMDEventWorkspace_sptr
Shared pointer to Mantid::API::IMDEventWorkspace.
std::shared_ptr< MDHistoWorkspace > MDHistoWorkspace_sptr
A shared pointer to a MDHistoWorkspace.
auto getLogValues(const API::ExperimentInfo &exptInfo, const std::string &logName)
Definition MDNormBase.h:21
float coord_t
Typedef for the data type to use for coordinate axes in MD objects such as MDBox, MDEventWorkspace,...
Definition MDTypes.h:27