30using namespace Kernel;
33using HistogramData::BinEdges;
34using HistogramData::Counts;
42 : m_numberOfTubes{0}, m_numberOfPixelsPerTube{0}, m_numberOfChannels{0}, m_numberOfHistograms{0},
43 m_monitorElasticPeakPosition{0}, m_wavelength{0.0}, m_channelWidth{0.0}, m_timeOfFlightDelay{0.0},
44 m_monitorCounts{0}, m_chopper_speed{0.0}, m_chopper_ratio{0}, m_l1{0.0}, m_l2{0.0}, m_t1{0.0},
45 m_supportedInstruments{
"TOFTOF",
"DNS"} {}
59 const std::vector<std::string> exts{
".nxs",
".hdf",
".hd5"};
61 "File path of the Data file to load");
64 "The name to use for the output workspace");
115 std::string pmpath =
"instrument/detector/pixel_mask";
121 std::vector<int> masked_detectors(pmdata(), pmdata() + pmdata.
size());
123 g_log.
debug() <<
"Number of masked detectors: " << masked_detectors.size() <<
'\n';
126 std::vector<size_t> indicesToMask;
127 for (
auto masked_detector : masked_detectors) {
128 g_log.
debug() <<
"List of masked detectors: ";
132 indicesToMask.emplace_back(detInfo.indexOf(masked_detector));
133 }
catch (std::out_of_range &) {
134 g_log.
warning() <<
"Invalid detector ID " << masked_detector <<
". Found while running LoadMLZ\n";
139 for (
const auto index : indicesToMask)
140 detInfo.setMasked(
index,
true);
151 throw std::runtime_error(
"Cannot set the instrument name from the Nexus file!");
158 std::string message =
"The instrument " +
m_instrumentName +
" is not valid for this loader!";
159 throw std::runtime_error(message);
215 std::string monitorName;
217 monitorName =
"monitor";
219 monitorName =
"Monitor";
221 std::string message(
"Cannot find monitor/Monitor in the Nexus file!");
223 throw std::runtime_error(message);
231 time_of_flight_data.
load();
264 std::string runNum = entry.
getString(
"entry_identifier");
265 std::string run_num = boost::lexical_cast<std::string>(runNum);
268 std::string start_time = entry.
getString(
"start_time");
271 std::string end_time = entry.
getString(
"end_time");
277 runDetails.
addProperty<
double>(
"Ei", ei,
"meV",
true);
279 int duration = entry.
getInt(
"duration");
280 runDetails.
addProperty(
"duration", duration,
"Seconds",
true);
282 std::string mode = entry.
getString(
"mode");
285 std::string title = entry.
getString(
"title");
291 double temperature = entry.
getFloat(
"sample/temperature");
292 runDetails.
addProperty(
"temperature", temperature,
"K",
true);
302 double full_channels =
304 runDetails.
addProperty(
"full_channels", full_channels);
307 std::string proposal_title = entry.
getString(
"proposal");
308 runDetails.
addProperty(
"proposal_title", proposal_title);
311 std::string proposal_number = entry.
getString(
"proposal_number");
312 runDetails.
addProperty(
"proposal_number", proposal_number);
315 std::string user_name = entry.
getString(
"user2/name");
316 runDetails.
addProperty(
"experiment_team", user_name);
325 setPar->setProperty(
"ParameterName",
"Efixed");
326 setPar->setProperty(
"ParameterType",
"Number");
330 g_log.
warning(
"Cannot set the instrument parameter Efixed.");
345 std::string description = boost::lexical_cast<std::string>(entry.
getFloat(
"sample/description"));
370 BinEdges edges(std::move(detectorTofBins));
377 int *data_p = &data(
static_cast<int>(i),
static_cast<int>(j), 0);
401 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.
void loadDataIntoTheWorkSpace(NeXus::NXEntry &entry)
Loads all the spectra into the workspace, including that from the monitor.
size_t m_numberOfChannels
double m_timeOfFlightDelay
void loadTimeDetails(const NeXus::NXEntry &entry)
Load the time details from the nexus file.
API::MatrixWorkspace_sptr m_localWorkspace
void exec() override
Execute the algorithm.
void loadInstrumentDetails(const NeXus::NXEntry &)
Set the instrument name along with its path on the nexus file.
std::string m_instrumentName
Name of the instrument.
const std::string name() const override
Algorithm's name for identification.
std::string m_instrumentPath
Name of the instrument path.
void loadExperimentDetails(const NeXus::NXEntry &entry)
Load data about the Experiment.
int version() const override
Algorithm's version for identification.
void maskDetectors(const NeXus::NXEntry &entry)
Loads Masked detectors from the /Scan/instrument/Detector/pixel_mask.
void initInstrumentSpecific()
Function to do specific instrument stuff.
void loadRunDetails(NeXus::NXEntry &entry)
Load information about the run.
void initWorkSpace(NeXus::NXEntry &entry)
Creates the workspace and initialises member variables with the corresponding values.
size_t m_numberOfHistograms
int m_monitorElasticPeakPosition
int confidence(Kernel::NexusDescriptor &descriptor) const override
Returns a confidence value that this algorithm can load a 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.
Defines a wrapper around a file whose internal structure can be accessed using the NeXus API.
bool pathExists(const std::string &path) const
Query if a path exists.
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).
int getInt(const std::string &name) const
Returns a int.
NXInt openNXInt(const std::string &name) const
Creates and opens an integer dataset.
NXClass openNXGroup(const std::string &name) const
Creates and opens an arbitrary (non-standard) class (group).
bool containsGroup(const std::string &query) const
Returns whether an individual group (or group) is present.
bool containsDataSet(const std::string &query) const
Returns whether an individual dataset is present.
float getFloat(const std::string &name) const
Returns a float.
NXFloat openNXFloat(const std::string &name) const
Creates and opens a float dataset.
std::string getString(const std::string &name) const
Returns a string.
Templated class implementation of NXDataSet.
void load(const int blocksize=1, int i=-1, int j=-1, int k=-1, int l=-1) override
Implementation of the virtual NXDataSet::load(...) method.
int size() const
Returns the size of the data buffer.
int dim2() const
Returns the number of elements along the third dimension.
int dim0() const
Returns the number of elements along the first dimension.
int 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.
Kernel::Logger g_log("ExperimentInfo")
static logger object
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
double calculateEnergy(double)
Calculate Neutron Energy from wavelength: .
std::string getStringFromNexusPath(const Mantid::NeXus::NXEntry &, const std::string &)
std::string findInstrumentNexusPath(const Mantid::NeXus::NXEntry &)
Finds the path for the instrument name in the nexus file Usually of the form: entry0/<NXinstrument cl...
double calculateTOF(double, double)
Calculate TOF from distance.
std::string to_string(const wide_integer< Bits, Signed > &n)
@ Output
An output workspace.