Mantid
Loading...
Searching...
No Matches
LoadNexusMonitors2.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2015 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
11#include "MantidDataHandling/DllConfig.h"
13#include <boost/scoped_array.hpp>
14// clang-format off
15#include <nexus/NeXusFile.hpp>
16#include <nexus/NeXusException.hpp>
17// clang-format on
18
19namespace Mantid {
20
21namespace HistogramData {
22class Counts;
23class BinEdges;
24} // namespace HistogramData
25namespace DataHandling {
26
43namespace LoadNexusMonitorsAlg {
44// spectrum is implicit in the structure as index + 1 - TODO was spectrumNo
46 std::string name{""};
50 bool hasEvent{false};
51 bool hasHisto{false};
52};
53} // namespace LoadNexusMonitorsAlg
54
55class MANTID_DATAHANDLING_DLL LoadNexusMonitors2 : public API::ParallelAlgorithm {
56public:
58 const std::string name() const override { return "LoadNexusMonitors"; }
59
61 const std::string summary() const override { return "Load all monitors from a NeXus file into a workspace."; }
62
64 int version() const override { return 2; }
65 const std::vector<std::string> seeAlso() const override { return {"LoadNexus"}; }
66
68 const std::string category() const override { return "DataHandling\\Nexus"; }
69
70protected:
72 void init() override;
73
75 void exec() override;
76
77private:
79 void fixUDets(::NeXus::File &file);
80
82 void runLoadLogs(const std::string &filename, const API::MatrixWorkspace_sptr &localWorkspace);
83
85 bool canOpenAsNeXus(const std::string &fname);
86
88 void splitMutiPeriodHistrogramData(const size_t numPeriods);
89
90 size_t getMonitorInfo(NeXus::File &file, size_t &numPeriods);
91
92 bool createOutputWorkspace(std::vector<bool> &loadMonitorFlags);
93
94 void readEventMonitorEntry(NeXus::File &file, size_t ws_index);
95
96 void readHistoMonitorEntry(NeXus::File &file, size_t ws_index, size_t numPeriods);
97
98private:
99 std::vector<LoadNexusMonitorsAlg::MonitorInfo> m_monitorInfo;
100 std::vector<HistogramData::BinEdges> m_multiPeriodBinEdges;
101 std::vector<HistogramData::Counts> m_multiPeriodCounts;
102 std::string m_filename;
104 size_t m_monitor_count{0};
105 std::string m_top_entry_name;
106};
107
108} // namespace DataHandling
109} // namespace Mantid
Base class for algorithms that can run in parallel on all MPI ranks but not in a distributed fashion.
int version() const override
Algorithm's version for identification overriding a virtual method.
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::vector< LoadNexusMonitorsAlg::MonitorInfo > m_monitorInfo
std::string m_filename
The name and path of the input file.
std::vector< HistogramData::BinEdges > m_multiPeriodBinEdges
std::string m_top_entry_name
name of top level NXentry to use
const std::string name() const override
Algorithm's name for identification.
const std::string summary() const override
Summary of algorithms purpose.
API::MatrixWorkspace_sptr m_workspace
The workspace being filled out.
const std::string category() const override
Algorithm's category for identification overriding a virtual method.
std::vector< HistogramData::Counts > m_multiPeriodCounts
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
Helper class which provides the Collimation Length for SANS instruments.
int32_t detid_t
Typedef for a detector ID.
Definition: SpectrumInfo.h:21
int32_t specnum_t
Typedef for a spectrum Number.
Definition: IDTypes.h:16
std::string name
name of the group in the nexus file - TODO was