32#include <nexus/NeXusFile.hpp>
33#include <nexus/NeXusException.hpp>
38using namespace Kernel;
40using Geometry::Instrument;
45 : m_filename(), m_entrynumber(0), m_numberOfSpectra(0), m_numberOfPeriods(0), m_list(false), m_interval(false),
46 m_spec_list(), m_spec_min(0), m_spec_max(
EMPTY_INT()) {}
51 "The name of the Nexus file to load");
54 "The name of the workspace to be created as the output of the\n"
55 "algorithm. For multiperiod files, one workspace will be\n"
56 "generated for each period");
58 auto mustBePositive = std::make_shared<BoundedValidator<specnum_t>>();
59 mustBePositive->setLower(0);
61 "Index number of the first spectrum to read\n");
63 "Index of last spectrum to read\n"
64 "(default the last spectrum)");
67 "Array, or comma separated list, of indexes of spectra to\n"
68 "load. If a range and a list of spectra are both supplied,\n"
69 "all the specified spectra will be loaded.");
71 "Determines whether the spectra are automatically grouped\n"
72 "together based on the groupings in the NeXus file, only\n"
73 "for single period data (default no). Version 1 only.");
75 auto mustBeNonNegative = std::make_shared<BoundedValidator<int64_t>>();
76 mustBeNonNegative->setLower(0);
77 declareProperty(
"EntryNumber",
static_cast<int64_t
>(0), mustBeNonNegative,
78 "0 indicates that every entry is loaded, into a separate "
79 "workspace within a group. "
80 "A positive number identifies one entry to be loaded, into "
83 std::vector<std::string> FieldOptions{
"Transverse",
"Longitudinal"};
84 declareProperty(
"MainFieldDirection",
"Transverse", std::make_shared<StringListValidator>(FieldOptions),
85 "Output the main field direction if specified in Nexus file "
86 "(run/instrument/detector/orientation, default "
87 "longitudinal). Version 1 only.",
91 declareProperty(
"FirstGoodData", 0.0,
"First good data in units of micro-seconds (default to 0.0)",
96 "A vector of time zero values");
100 "TableWorkspace containing time zero values per spectra.");
102 declareProperty(
"CorrectTime",
true,
"Boolean flag controlling whether time should be corrected by timezero.",
107 "Table or a group of tables containing detector dead times. Version 1 "
112 "Table or a group of tables with information about the "
113 "detector grouping stored in the file (if any). Version 1 only.");
133 throw std::invalid_argument(
"Inconsistent properties defined");
141 g_log.
error(
"Invalid Spectrum min/max properties");
142 throw std::invalid_argument(
"Inconsistent properties defined");
158 }
catch (std::invalid_argument &) {
160 }
catch (std::runtime_error &) {
161 g_log.
information(
"Unable to successfully run LoadInstrument Child Algorithm");
167 if (!loadInst->isExecuted()) {
168 auto inst = std::make_shared<Geometry::Instrument>();
170 localWorkspace->setInstrument(inst);
190 logAlg->setProperty(
"Workspace", ws);
199 alg->setProperty(
"LogType",
"Number");
200 alg->setProperty(
"NumberType",
"Int");
201 alg->setProperty(
"LogName", logName);
203 alg->executeAsChildAlg();
212 alg->setProperty(
"LogType",
"String");
213 alg->setProperty(
"LogName", logName);
214 alg->setProperty(
"LogText", logString);
215 alg->executeAsChildAlg();
#define UNUSED_ARG(x)
Function arguments are sometimes unused in certain implmentations but are required for documentation ...
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.
@ Load
allowed here which will be passed to the algorithm
A property class for workspaces.
void init() override
Overwrites Algorithm method.
specnum_t m_spec_min
The value of the spectrum_min property.
void runLoadInstrument(const DataObjects::Workspace2D_sptr &)
Run the Child Algorithm LoadInstrument.
std::string m_instrument_name
The instrument name from Nexus.
bool m_interval
Have the spectrum_min/max properties been set?
bool m_list
Has the spectrum_list property been set?
specnum_t m_spec_max
The value of the spectrum_max property.
void checkOptionalProperties()
Validates the optional 'spectra to read' properties, if they have been set.
std::vector< specnum_t > m_spec_list
The value of the spectrum_list property.
Mantid::API::Algorithm_sptr createSampleLogAlgorithm(DataObjects::Workspace2D_sptr &ws)
Create Algorithm to add a sample log to a workspace.
LoadMuonNexus()
Default constructor.
int confidence(Kernel::NexusDescriptor &descriptor) const override
Returns a confidence value that this algorithm can load a file.
void addToSampleLog(const std::string &logName, const int logNumber, DataObjects::Workspace2D_sptr &ws)
Function to add a single int as a sample log to a workspace.
specnum_t m_numberOfSpectra
The number of spectra in the raw file.
Support for a property that holds an array of values.
void error(const std::string &msg)
Logs at error level.
void information(const std::string &msg)
Logs at information level.
Defines a wrapper around a file whose internal structure can be accessed using the NeXus API.
OptionalBool : Tri-state bool.
Kernel::Logger g_log("ExperimentInfo")
static logger object
std::shared_ptr< Algorithm > Algorithm_sptr
Typedef for a shared pointer to an Algorithm.
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
std::shared_ptr< Workspace2D > Workspace2D_sptr
shared pointer to Mantid::DataObjects::Workspace2D
constexpr int EMPTY_INT() noexcept
Returns what we consider an "empty" integer within a property.
int32_t specnum_t
Typedef for a spectrum Number.
std::string to_string(const wide_integer< Bits, Signed > &n)
@ Input
An input workspace.
@ Output
An output workspace.