Mantid
Loading...
Searching...
No Matches
LoadNexusProcessed.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2007 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
9//----------------------------------------------------------------------
10// Includes
11//----------------------------------------------------------------------
15#include "MantidDataHandling/DllConfig.h"
16#include "MantidHistogramData/BinEdges.h"
20#include <map>
21#include <vector>
22
23namespace NeXus {
24class File;
25}
26
27namespace Mantid {
28
29namespace DataHandling {
43class MANTID_DATAHANDLING_DLL LoadNexusProcessed : public API::IFileLoader<Kernel::NexusDescriptor> {
44
45public:
51 const std::string name() const override { return "LoadNexusProcessed"; }
53 const std::string summary() const override {
54 return "The LoadNexusProcessed algorithm will read the given Nexus "
55 "Processed data file containing a Mantid Workspace. The data is "
56 "placed in the named workspace. LoadNexusProcessed may be invoked "
57 "by LoadNexus if it is given a Nexus file of this type.";
58 }
59
61 int version() const override { return 1; };
62 const std::vector<std::string> seeAlso() const override { return {"LoadNexus"}; }
64 const std::string category() const override { return "DataHandling\\Nexus"; }
65
67 int confidence(Kernel::NexusDescriptor &descriptor) const override;
68
69protected:
71 void readInstrumentGroup(Mantid::NeXus::NXEntry &mtd_entry, API::MatrixWorkspace &local_workspace);
72
73private:
74 virtual void readSpectraToDetectorMapping(Mantid::NeXus::NXEntry &mtd_entry, Mantid::API::MatrixWorkspace &ws);
75
77 std::map<std::string, std::string> validateInputs() override;
79 void init() override;
81 void exec() override;
82
84 std::string buildWorkspaceName(const std::string &name, const std::string &baseName, size_t wsIndex);
85
87 void correctForWorkspaceNameClash(std::string &wsName);
88
90 std::vector<std::string> extractWorkspaceNames(Mantid::NeXus::NXRoot &root, size_t nWorkspaceEntries);
91
93 std::string loadWorkspaceName(Mantid::NeXus::NXRoot &root, const std::string &entry_name);
94
97 const std::string &) { /*do nothing*/
98 return false;
99 }
101 API::Workspace_sptr loadEntry(Mantid::NeXus::NXRoot &root, const std::string &entry_name, const double &progressStart,
102 const double &progressRange);
103
104 API::Workspace_sptr loadTableEntry(const Mantid::NeXus::NXEntry &entry);
105
107 template <typename ColumnType, typename NexusType>
108 void loadNumericColumn(const Mantid::NeXus::NXData &tableData, const std::string &dataSetName,
109 const API::ITableWorkspace_sptr &tableWs, const std::string &columnType);
110
112 template <typename Type>
113 void loadVectorColumn(const Mantid::NeXus::NXData &tableData, const std::string &dataSetName,
114 const API::ITableWorkspace_sptr &tableWs, const std::string &columnType);
115
117 void loadV3DColumn(Mantid::NeXus::NXDouble &data, const API::ITableWorkspace_sptr &tableWs);
118
119 API::Workspace_sptr loadPeaksEntry(Mantid::NeXus::NXEntry &entry);
120
121 API::Workspace_sptr loadLeanElasticPeaksEntry(Mantid::NeXus::NXEntry &entry);
122
124 const double &progressStart, const double &progressRange);
126 const double &progressStart, const double &progressRange,
127 const Mantid::NeXus::NXEntry &mtd_entry, const int xlength,
128 std::string &workspaceType);
129
133 bool addSampleProperty(Mantid::NeXus::NXMainClass &sample_entry, const std::string &entryName,
134 API::Sample &sampleDetails);
136 void getWordsInString(const std::string &words3, std::string &w1, std::string &w2, std::string &w3);
138 void getWordsInString(const std::string &words4, std::string &w1, std::string &w2, std::string &w3, std::string &w4);
139
141 void readBinMasking(const Mantid::NeXus::NXData &wksp_cls, const API::MatrixWorkspace_sptr &local_workspace);
142
147 bool hasXErrors, int blocksize, int nchannels, int &hist,
148 const API::MatrixWorkspace_sptr &local_workspace);
149
154 bool hasXErrors, int blocksize, int nchannels, int &hist, int &wsIndex,
155 const API::MatrixWorkspace_sptr &local_workspace);
159 bool hasXErrors, Mantid::NeXus::NXDouble &xbins, int blocksize, int nchannels, int &hist, int &wsIndex,
160 const API::MatrixWorkspace_sptr &local_workspace);
161
163 void loadNonSpectraAxis(const API::MatrixWorkspace_sptr &local_workspace, Mantid::NeXus::NXData &data);
164
166 void checkOptionalProperties(const std::size_t numberofspectra);
167
169 std::size_t calculateWorkspaceSize(const std::size_t numberofspectra, bool gen_filtered_list = false);
170
172 Mantid::API::Workspace_sptr doAccelleratedMultiPeriodLoading(Mantid::NeXus::NXRoot &root,
173 const std::string &entryName,
174 Mantid::API::MatrixWorkspace_sptr &tempMatrixWorkspace,
175 const size_t nWorkspaceEntries, const size_t p);
176
178 void applyLogFiltering(const Mantid::API::Workspace_sptr &local_workspace);
179
183 HistogramData::BinEdges m_xbins;
186
188 bool m_list;
191
196
198 std::vector<int> m_spec_list;
201 std::vector<int> m_filtered_spec_idxs;
202
203 // Handle to the NeXus file
204 std::unique_ptr<::NeXus::File> m_nexusFile;
205};
208
209} // namespace DataHandling
210} // namespace Mantid
Defines an interface to an algorithm that loads a file so that it can take part in the automatic sele...
Definition: IFileLoader.h:19
Base MatrixWorkspace Abstract Class.
This class stores information about the sample used in particular run.
Definition: Sample.h:33
Base Workspace Abstract Class.
Definition: Workspace.h:30
Loads a workspace from a NeXus Processed entry in a NeXus file.
int m_spec_min
The value of the spectrum_min property.
bool m_interval
Flag set if interval of spectra to write is set.
const std::string summary() const override
Summary of algorithms purpose.
~LoadNexusProcessed() override
Destructor.
const std::vector< std::string > seeAlso() const override
Function to return all of the seeAlso (these are not validated) algorithms related to this algorithm....
HistogramData::BinEdges m_xbins
The cached x binning if we have bins.
int m_spec_max
The value of the spectrum_max property.
bool addSampleProperty(Mantid::NeXus::NXMainClass &sample_entry, const std::string &entryName, API::Sample &sampleDetails)
Add a property to the sample object.
bool m_list
Flag set if list of spectra to save is specifed.
virtual bool loadNexusGeometry(Mantid::API::Workspace &, const int, Kernel::Logger &, const std::string &)
Load nexus geometry and apply to workspace.
std::vector< int > m_filtered_spec_idxs
list of spectra filtered by min/max/list, currently used only when loading data into event_workspace
bool m_shared_bins
Does the current workspace have uniform binning.
std::vector< int > m_spec_list
The value of the spectrum_list property.
const std::string category() const override
Algorithm's category for identification overriding a virtual method.
MantidVec m_axis1vals
Numeric values for the second axis, if applicable.
const std::string name() const override
Algorithm's name for identification overriding a virtual method.
int version() const override
Algorithm's version for identification overriding a virtual method.
std::unique_ptr<::NeXus::File > m_nexusFile
void readSampleGroup(Mantid::NeXus::NXEntry &mtd_entry, API::MatrixWorkspace_sptr local_workspace)
Read the data from the sample group.
The Logger class is in charge of the publishing messages from the framework through various channels.
Definition: Logger.h:52
Defines a wrapper around a file whose internal structure can be accessed using the NeXus API.
Templated class implementation of NXDataSet.
Definition: NexusClasses.h:203
Implements NXdata Nexus class.
Definition: NexusClasses.h:795
Implements NXentry Nexus class.
Definition: NexusClasses.h:898
Main class is the one that can contain auxiliary classes.
Definition: NexusClasses.h:773
Implements NXroot Nexus class.
Definition: NexusClasses.h:922
void getWordsInString(const std::string &words3, std::string &w1, std::string &w2, std::string &w3)
If the first string contains exactly three words separated by spaces these words will be copied into ...
std::shared_ptr< ITableWorkspace > ITableWorkspace_sptr
shared pointer to Mantid::API::ITableWorkspace
std::shared_ptr< Workspace > Workspace_sptr
shared pointer to Mantid::API::Workspace
Definition: Workspace_fwd.h:20
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
bool UDlesserExecCount(const Mantid::NeXus::NXClassInfo &elem1, const Mantid::NeXus::NXClassInfo &elem2)
to sort the algorithmhistory vector
Helper class which provides the Collimation Length for SANS instruments.
std::vector< double > MantidVec
typedef for the data storage used in Mantid matrix workspaces
Definition: cow_ptr.h:172
Information about a Nexus class.
Definition: NexusClasses.h:53