Mantid
Loading...
Searching...
No Matches
LoadISISNexus2.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//----------------------------------------------------------------------
17#include "MantidHistogramData/HistogramX.h"
20#include "MantidNexus/NexusFile.h"
21
22#include <boost/scoped_ptr.hpp>
23
24#include <climits>
25
26//----------------------------------------------------------------------
27// Forward declaration
28//----------------------------------------------------------------------
29namespace Mantid {
30namespace DataHandling {
31
59class MANTID_DATAHANDLING_DLL LoadISISNexus2 : public API::IFileLoader<Nexus::NexusDescriptor> {
60public:
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"}; }
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."; }
72
74 int confidence(Nexus::NexusDescriptor &descriptor) const override;
75
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) {}
81
82 int64_t first;
83 int64_t last;
84 bool isMonitor;
85 std::string monName;
86 };
87
88private:
90 void init() override;
92 void exec() override;
93 // Validate the optional input properties
94 bool checkOptionalProperties(bool bseparateMonitors, bool bexcludeMonitor);
95
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(Nexus::NXInt &data, int64_t blocksize, int64_t period, int64_t start, int64_t &hist, int64_t &spec_num,
111 DataObjects::Workspace2D_sptr &local_workspace);
112
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 &);
117
118 // build the list of spectra numbers to load and include in the spectra list
119 void buildSpectraInd2SpectraNumMap(bool range_supplied, bool hasSpectraList,
120 const DataBlockComposite &dataBlockComposite);
121
123 void checkOverlappingSpectraRange();
124
126 std::string m_filename;
128 std::string m_instrument_name;
130 std::string m_samplename;
131 // the description of the data block in the file to load.
132 // the description of single time-range data block, obtained from detectors
134 // the description of single time-range data block, obtained from monitors
136 // description of the block to be loaded may include monitors and detectors
137 // with the same time binning if the detectors and monitors are loaded
138 // together
139 // in single workspace or equal to the detectorBlock if monitors are excluded
140 // or monBlockInfo if only monitors are loaded.
144 // Is there a VMS block
149 std::map<int64_t, specnum_t> m_wsInd2specNum_map;
155 std::vector<SpectraBlock> m_spectraBlocks;
157 std::shared_ptr<HistogramData::HistogramX> m_tof_data;
159 std::vector<specnum_t> m_spec;
163 std::map<specnum_t, std::string> m_monitors;
165 boost::scoped_ptr<API::ISISRunLogs> m_logCreator;
167 std::shared_ptr<API::Progress> m_progress;
169 static double dblSqrt(double in);
170 // Handle to the NeXus file
171 boost::scoped_ptr<Nexus::File> m_nexusFile;
172
173 bool findSpectraDetRangeInFile(const Nexus::NXEntry &entry, std::vector<specnum_t> &spectrum_index, int64_t ndets,
174 int64_t n_vms_compat_spectra, const std::map<specnum_t, std::string> &monitors,
175 bool excludeMonitors, bool separateMonitors);
176
178 bool isMultipleTimeRegimeFile(const Nexus::NXEntry &entry) const;
179};
180
181} // namespace DataHandling
182} // 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.
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.
boost::scoped_ptr< API::ISISRunLogs > m_logCreator
A pointer to the ISISRunLogs creator.
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.
Templated class implementation of NXDataSet.
Implements NXentry Nexus class.
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:14
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