32using namespace Kernel;
35using HistogramData::BinEdges;
36using HistogramData::Counts;
44 : m_numberOfTubes{0}, m_numberOfPixelsPerTube{0}, m_numberOfChannels{0}, m_numberOfHistograms{0},
45 m_monitorElasticPeakPosition{0}, m_wavelength{0.0}, m_channelWidth{0.0}, m_timeOfFlightDelay{0.0},
46 m_monitorCounts{0}, m_chopper_speed{0.0}, m_chopper_ratio{0}, m_l1{0.0}, m_l2{0.0}, m_t1{0.0},
47 m_supportedInstruments{
"TOFTOF",
"DNS"} {}
61 const std::vector<std::string> exts{
".nxs",
".hdf",
".hd5"};
63 "File path of the Data file to load");
66 "The name to use for the output workspace");
104 if (descriptor.
isEntry(
"/Scan/wavelength") && descriptor.
isEntry(
"/Scan/title") && descriptor.
isEntry(
"/Scan/mode")) {
116 std::string pmaddress =
"instrument/detector/pixel_mask";
122 std::vector<int> masked_detectors(pmdata(), pmdata() + pmdata.
size());
124 g_log.
debug() <<
"Number of masked detectors: " << masked_detectors.size() <<
'\n';
127 std::vector<size_t> indicesToMask;
128 for (
auto masked_detector : masked_detectors) {
129 g_log.
debug() <<
"List of masked detectors: ";
133 indicesToMask.emplace_back(detInfo.indexOf(masked_detector));
134 }
catch (std::out_of_range &) {
135 g_log.
warning() <<
"Invalid detector ID " << masked_detector <<
". Found while running LoadMLZ\n";
140 for (
const auto index : indicesToMask)
141 detInfo.setMasked(
index,
true);
152 throw std::runtime_error(
"Cannot set the instrument name from the Nexus file!");
159 std::string message =
"The instrument " +
m_instrumentName +
" is not valid for this loader!";
160 throw std::runtime_error(message);
191 m_localWorkspace->getAxis(0)->unit() = UnitFactory::Instance().create(
"TOF");
216 std::string monitorName;
218 monitorName =
"monitor";
220 monitorName =
"Monitor";
222 std::string message(
"Cannot find monitor/Monitor in the Nexus file!");
224 throw std::runtime_error(message);
232 time_of_flight_data.
load();
265 std::string runNum = entry.
getString(
"entry_identifier");
266 std::string run_num = boost::lexical_cast<std::string>(runNum);
269 std::string start_time = entry.
getString(
"start_time");
272 std::string end_time = entry.
getString(
"end_time");
278 runDetails.
addProperty<
double>(
"Ei", ei,
"meV",
true);
280 int duration = entry.
getInt(
"duration");
281 runDetails.
addProperty(
"duration", duration,
"Seconds",
true);
283 std::string mode = entry.
getString(
"mode");
286 std::string title = entry.
getString(
"title");
292 double temperature = entry.
getFloat(
"sample/temperature");
293 runDetails.
addProperty(
"temperature", temperature,
"K",
true);
303 double full_channels =
305 runDetails.
addProperty(
"full_channels", full_channels);
308 std::string proposal_title = entry.
getString(
"proposal");
309 runDetails.
addProperty(
"proposal_title", proposal_title);
312 std::string proposal_number = entry.
getString(
"proposal_number");
313 runDetails.
addProperty(
"proposal_number", proposal_number);
316 std::string user_name = entry.
getString(
"user2/name");
317 runDetails.
addProperty(
"experiment_team", user_name);
326 setPar->setProperty(
"ParameterName",
"Efixed");
327 setPar->setProperty(
"ParameterType",
"Number");
331 g_log.
warning(
"Cannot set the instrument parameter Efixed.");
346 std::string description = boost::lexical_cast<std::string>(entry.
getFloat(
"sample/description"));
371 BinEdges edges(std::move(detectorTofBins));
378 int *data_p = &data(
static_cast<int>(i),
static_cast<int>(j), 0);
402 g_log.
warning(
"Cannot load the instrument definition.");
std::map< DeltaEMode::Type, std::string > index
#define DECLARE_NEXUS_FILELOADER_ALGORITHM(classname)
DECLARE_NEXUS_FILELOADER_ALGORITHM should be used in place of the standard DECLARE_ALGORITHM macro wh...
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
std::string getPropertyValue(const std::string &name) const override
Get the value of a property as a string.
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.
void progress(double p, const std::string &msg="", double estimatedTime=0.0, int progressPrecision=0)
Sends ProgressNotification.
@ Load
allowed here which will be passed to the algorithm
void addProperty(Kernel::Property *prop, bool overwrite=false)
Add data to the object in the form of a property.
Helper class for reporting progress from algorithms.
This class stores information regarding an experimental run as a series of log entries.
A property class for workspaces.
LoadMLZ : Loads MLZ nexus or hdf file into a Mantid workspace.
size_t m_numberOfChannels
double m_timeOfFlightDelay
void loadExperimentDetails(const Nexus::NXEntry &entry)
Load data about the Experiment.
std::string m_instrumentAddress
Name of the instrument address.
API::MatrixWorkspace_sptr m_localWorkspace
void exec() override
Execute the algorithm.
void loadDataIntoTheWorkSpace(const Nexus::NXEntry &entry)
Loads all the spectra into the workspace, including that from the monitor.
int confidence(Nexus::NexusDescriptor &descriptor) const override
Returns a confidence value that this algorithm can load a file.
std::string m_instrumentName
Name of the instrument.
void loadRunDetails(Nexus::NXEntry &entry)
Load information about the run.
const std::string name() const override
Algorithm's name for identification.
void loadTimeDetails(const Nexus::NXEntry &entry)
Load the time details from the nexus file.
int version() const override
Algorithm's version for identification.
void initInstrumentSpecific()
Function to do specific instrument stuff.
size_t m_numberOfHistograms
void maskDetectors(const Nexus::NXEntry &entry)
Loads Masked detectors from the /Scan/instrument/Detector/pixel_mask.
int m_monitorElasticPeakPosition
void initWorkspace(const Nexus::NXEntry &entry)
Creates the workspace and initialises member variables with the corresponding values.
void loadInstrumentDetails(const Nexus::NXEntry &)
Set the instrument name along with its address on the nexus file.
size_t m_numberOfPixelsPerTube
void init() override
Initialize the algorithm's properties.
void runLoadInstrument()
Run the Child Algorithm LoadInstrument.
std::vector< std::string > m_supportedInstruments
const std::string category() const override
Algorithm's category for identification.
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
void debug(const std::string &msg)
Logs at debug level.
void error(const std::string &msg)
Logs at error level.
void warning(const std::string &msg)
Logs at warning level.
OptionalBool : Tri-state bool.
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
The base class for a Nexus class (group).
float getFloat(const std::string &name) const
Returns a float.
std::string getString(const std::string &name) const
Returns a string.
bool containsGroup(const std::string &query) const
Returns whether an individual group (or group) is present.
NXFloat openNXFloat(const std::string &name) const
Creates and opens a float dataset.
NXClass openNXGroup(const std::string &name) const
Creates and opens an arbitrary (non-standard) class (group).
NXInt openNXInt(const std::string &name) const
Creates and opens an integer dataset.
bool containsDataSet(const std::string &query) const
Returns whether an individual dataset is present.
int32_t getInt(const std::string &name) const
Returns a int.
Templated class implementation of NXDataSet.
void load()
Read all of the datablock in.
std::size_t size() const
Returns the size of the data buffer.
dimsize_t dim0() const
Returns the number of elements along the first dimension.
dimsize_t dim2() const
Returns the number of elements along the third dimension.
dimsize_t dim1() const
Returns the number of elements along the second dimension.
Implements NXdata Nexus class.
NXInt openIntData()
Opens data of int type.
Implements NXentry Nexus class.
NXData openNXData(const std::string &name) const
Opens a NXData.
Implements NXroot Nexus class.
NXEntry openFirstEntry()
Open the first NXentry in the file.
bool isEntry(const std::string &entryName, const std::string &groupClass) const noexcept
Checks if a full-address entry exists for a particular groupClass in a Nexus dataset.
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
std::string getStringFromNexusAddress(const Mantid::Nexus::NXEntry &, const std::string &)
double calculateEnergy(double)
Calculate Neutron Energy from wavelength: .
double calculateTOF(double, double)
Calculate TOF from distance.
std::string findInstrumentNexusAddress(const Mantid::Nexus::NXEntry &)
Finds the address for the instrument name in the nexus file Usually of the form: entry0/<NXinstrument...
std::string to_string(const wide_integer< Bits, Signed > &n)
@ Output
An output workspace.