No Matches
Go to the documentation of this file.
1// Mantid Repository :
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
10// Includes
12#include "MantidAPI/Algorithm.h"
20#include <nexus/NeXusFile.hpp>
22#include <boost/scoped_ptr.hpp>
24#include <climits>
27// Forward declaration
29namespace Mantid {
30namespace DataHandling {
59class MANTID_DATAHANDLING_DLL LoadISISNexus2 : public API::IFileLoader<Kernel::NexusDescriptor> {
64 const std::string name() const override { return "LoadISISNexus"; }
66 int version() const override { return 2; }
67 const std::vector<std::string> seeAlso() const override { return {"LoadEventNexus", "SaveISISNexus"}; }
69 const std::string category() const override { return "DataHandling\\Nexus"; }
71 const std::string summary() const override { return "Loads a file in ISIS NeXus format."; }
74 int confidence(Kernel::NexusDescriptor &descriptor) const override;
77 struct SpectraBlock {
79 SpectraBlock(int64_t f, int64_t l, bool is_mon, const std::string &monname)
80 : first(f), last(l), isMonitor(is_mon), monName(monname) {}
82 int64_t first;
83 int64_t last;
84 bool isMonitor;
85 std::string monName;
86 };
90 void init() override;
92 void exec() override;
93 // Validate the optional input properties
94 bool checkOptionalProperties(bool bseparateMonitors, bool bexcludeMonitor);
97 size_t prepareSpectraBlocks(std::map<specnum_t, std::string> &monitors, DataBlockComposite &LoadBlock);
99 void runLoadInstrument(DataObjects::Workspace2D_sptr &);
101 void loadRunDetails(DataObjects::Workspace2D_sptr &local_workspace, Mantid::NeXus::NXEntry &entry);
103 void loadSampleData(DataObjects::Workspace2D_sptr &, const Mantid::NeXus::NXEntry &entry);
105 void loadLogs(DataObjects::Workspace2D_sptr &ws);
106 // Load a given period into the workspace
107 void loadPeriodData(int64_t period, Mantid::NeXus::NXEntry &entry, DataObjects::Workspace2D_sptr &local_workspace,
108 bool update_spectra2det_mapping = false);
109 // Load a data block
110 void loadBlock(Mantid::NeXus::NXDataSetTyped<int> &data, int64_t blocksize, int64_t period, int64_t start,
111 int64_t &hist, int64_t &spec_num, DataObjects::Workspace2D_sptr &local_workspace);
113 // Create period logs
114 void createPeriodLogs(int64_t period, DataObjects::Workspace2D_sptr &local_workspace);
115 // Validate multi-period logs
116 void validateMultiPeriodLogs(const Mantid::API::MatrixWorkspace_sptr &);
118 // build the list of spectra numbers to load and include in the spectra list
119 void buildSpectraInd2SpectraNumMap(bool range_supplied, bool hasSpectraList, DataBlockComposite &dataBlockComposite);
122 void checkOverlappingSpectraRange();
125 std::string m_filename;
127 std::string m_instrument_name;
129 std::string m_samplename;
130 // the description of the data block in the file to load.
131 // the description of single time-range data block, obtained from detectors
133 // the description of single time-range data block, obtained from monitors
135 // description of the block to be loaded may include monitors and detectors
136 // with the same time binning if the detectors and monitors are loaded
137 // together
138 // in single workspace or equal to the detectorBlock if monitors are excluded
139 // or monBlockInfo if only monitors are loaded.
143 // Is there a VMS block
148 std::map<int64_t, specnum_t> m_wsInd2specNum_map;
154 std::vector<SpectraBlock> m_spectraBlocks;
156 std::shared_ptr<HistogramData::HistogramX> m_tof_data;
158 std::vector<specnum_t> m_spec;
162 std::map<specnum_t, std::string> m_monitors;
164 boost::scoped_ptr<ISISRunLogs> m_logCreator;
166 std::shared_ptr<API::Progress> m_progress;
168 static double dblSqrt(double in);
169 // Handle to the NeXus file
170 // clang-format off
171 boost::scoped_ptr< ::NeXus::File> m_nexusFile;
172 // clang-format on
174 bool findSpectraDetRangeInFile(NeXus::NXEntry &entry, std::vector<specnum_t> &spectrum_index, int64_t ndets,
175 int64_t n_vms_compat_spectra, std::map<specnum_t, std::string> &monitors,
176 bool excludeMonitors, bool separateMonitors);
179 bool isMultipleTimeRegimeFile(const NeXus::NXEntry &entry) const;
182} // namespace DataHandling
183} // 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
A minimal class to hold the mapping between the spectrum number and its related detector ID numbers f...
DataBlockComposite: The DataBlockComposite handles a collection of DataBlocks.
Loads a file in a NeXus format and stores it in a 2D workspace.
int64_t m_entrynumber
The number of the input entry.
const std::vector< std::string > seeAlso() const override
Function to return all of the seeAlso (these are not validated) algorithms related to this algorithm....
std::string m_filename
The name and path of the input file.
boost::scoped_ptr< ISISRunLogs > m_logCreator
A pointer to the ISISRunLogs creator.
const specnum_t * m_spec_end
Pointer to one-past-the-end of spectrum number array (m_spec)
int version() const override
Algorithm's version for identification overriding a virtual method.
std::map< int64_t, specnum_t > m_wsInd2specNum_map
map of workspace Index to spectra Number (spectraID)
std::map< specnum_t, std::string > m_monitors
Monitors, map spectrum index to monitor group name.
const std::string summary() const override
Summary of algorithms purpose.
bool m_have_detector
Is there a detector block.
std::shared_ptr< API::Progress > m_progress
Progress reporting object.
std::string m_instrument_name
The instrument name from Nexus.
std::shared_ptr< HistogramData::HistogramX > m_tof_data
Time channels.
const std::string name() const override
Algorithm's name for identification overriding a virtual method.
std::vector< specnum_t > m_spec
Spectra numbers.
boost::scoped_ptr< ::NeXus::File > m_nexusFile
API::SpectrumDetectorMapping m_spec2det_map
spectra Number to detector ID (multi)map
const std::string category() const override
Algorithm's category for identification overriding a virtual method.
std::vector< SpectraBlock > m_spectraBlocks
List of disjoint data blocks to load.
bool m_load_selected_spectra
if true, a spectra list or range of spectra is supplied
std::string m_samplename
The sample name read from Nexus.
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 NXentry Nexus class.
Definition: NexusClasses.h:898
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
Helper class which provides the Collimation Length for SANS instruments.
int32_t specnum_t
Typedef for a spectrum Number.
Definition: IDTypes.h:16
SpectraBlock(int64_t f, int64_t l, bool is_mon, const std::string &monname)
Constructor - initialize the block.
int64_t last
last spectrum number of the block
bool isMonitor
is the data in a monitor group
int64_t first
first spectrum number of the block