69 if (attName ==
"WorkspaceIndex") {
70 size_t wi{
static_cast<size_t>(attValue.
asInt())};
71 if (!
m_vQ.empty() && wi <
m_vQ.size()) {
74 qAttr.setDouble(
m_vQ.at(wi));
80 else if (attName ==
"Q") {
98 double startX,
double endX) {
126 std::vector<double> qs;
131 const std::shared_ptr<Kernel::Unit> &unit_ptr = axis_ptr->
unit();
132 if (unit_ptr->unitID() ==
"MomentumTransfer") {
133 qs = axis_ptr->getValues();
138 const auto &spectrumInfo =
workspace.spectrumInfo();
139 size_t numHist =
workspace.getNumberHistograms();
140 for (
size_t wi = 0; wi < numHist; wi++) {
141 if (spectrumInfo.hasDetectors(wi)) {
142 const auto detID = spectrumInfo.detector(wi).getID();
144 double usignTheta = 0.5 * spectrumInfo.twoTheta(wi);
148 g_log.
debug(
"Cannot populate Q values from workspace");
Mantid::API::IFunction::Attribute Attr
IPeaksWorkspace_sptr workspace
#define UNUSED_ARG(x)
Function arguments are sometimes unused in certain implmentations but are required for documentation ...
const std::shared_ptr< Kernel::Unit > & unit() const
The unit for this axis.
static Kernel::Logger g_log
Logger instance.
Attribute is a non-fitting parameter.
int asInt() const
Returns int value if attribute is a int, throws exception otherwise.
virtual Attribute getAttribute(const std::string &name) const
Return a value of attribute attName.
void declareAttribute(const std::string &name, const API::IFunction::Attribute &defaultValue)
Declare a single attribute.
virtual void setAttribute(const std::string &name, const Attribute &)
Set a value to attribute attName.
void setAttributeValue(const std::string &attName, const T &value)
Set an attribute value.
Base MatrixWorkspace Abstract Class.
Class to represent a numeric axis of a workspace.
std::vector< double > extractQValues(const Mantid::API::MatrixWorkspace &workspace)
Extract Q values from vertical dimension of the workspace, or compute them.
void setMatrixWorkspace(std::shared_ptr< const Mantid::API::MatrixWorkspace > workspace, size_t wi, double startX, double endX) override
Learn the Q values from the workspace, if possible, and update attribute Q accordingly.
virtual void setAttribute(const std::string &attName, const Mantid::API::IFunction::Attribute &attValue) override
Update attributes WorkspaceIndex and Q according to certain precedence rules.
std::vector< double > m_vQ
virtual void declareAttributes() override
declare commonattributes Q and WorkspaceIndex.
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.
static double convertToElasticQ(const double theta, const double efixed)
Convert to ElasticQ from Energy.
constexpr int EMPTY_INT() noexcept
Returns what we consider an "empty" integer within a property.
constexpr double EMPTY_DBL() noexcept
Returns what we consider an "empty" double within a property.