-
Notifications
You must be signed in to change notification settings - Fork 122
/
LoadNexusMonitors2.h
129 lines (107 loc) · 4.1 KB
/
LoadNexusMonitors2.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#ifndef MANTID_DATAHANDLING_LOADNEXUSMONITORS2_H_
#define MANTID_DATAHANDLING_LOADNEXUSMONITORS2_H_
#include "MantidAPI/ParallelAlgorithm.h"
#include "MantidAPI/MatrixWorkspace_fwd.h"
#include "MantidGeometry/IDTypes.h"
#include <boost/scoped_array.hpp>
// clang-format off
#include <nexus/NeXusFile.hpp>
#include <nexus/NeXusException.hpp>
// clang-format on
namespace Mantid {
namespace HistogramData {
class Counts;
class BinEdges;
}
namespace DataHandling {
/**
* Load Monitors from NeXus files.
*
* Required Properties:
* <UL>
* <LI> Filename - The name of and path to the input NeXus file </LI>
* <LI> Workspace - The name of the workspace to output</LI>
* </UL>
*
* @author Michael Reuter, SNS
* @author Michael Hart, ISIS
* @date December 4, 2015
*
* Copyright © 2015 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge
* National Laboratory & European Spallation Source
*
* This file is part of Mantid.
*
* Mantid is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* Mantid is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* File change history is stored at: <https://github.com/mantidproject/mantid>
*/
namespace LoadNexusMonitorsAlg {
// spectrum is implicit in the structure as index + 1 - TODO was spectrumNo
struct MonitorInfo {
std::string name{""}; ///< name of the group in the nexus file - TODO was
/// monitorName
detid_t detNum{0}; ///< detector number for monitor - TODO was monIndex
specnum_t specNum{0};
bool hasEvent{false};
bool hasHisto{false};
};
}
class DLLExport LoadNexusMonitors2 : public API::ParallelAlgorithm {
public:
/// Algorithm's name for identification
const std::string name() const override { return "LoadNexusMonitors"; }
/// Summary of algorithms purpose
const std::string summary() const override {
return "Load all monitors from a NeXus file into a workspace.";
}
/// Algorithm's version for identification overriding a virtual method
int version() const override { return 2; }
const std::vector<std::string> seeAlso() const override {
return {"LoadNexus"};
}
/// Algorithm's category for identification overriding a virtual method
const std::string category() const override { return "DataHandling\\Nexus"; }
protected:
/// Initialise algorithm
void init() override;
/// Execute algorithm
void exec() override;
private:
/// Fix the detector numbers if the defaults are not correct
void fixUDets(::NeXus::File &file);
/// Load the logs
void runLoadLogs(const std::string filename,
API::MatrixWorkspace_sptr localWorkspace);
/// is it possible to open the file?
bool canOpenAsNeXus(const std::string &fname);
/// split multi period histogram workspace into a workspace group
void splitMutiPeriodHistrogramData(const size_t numPeriods);
size_t getMonitorInfo(NeXus::File &file, size_t &numPeriods);
bool createOutputWorkspace(std::vector<bool> &loadMonitorFlags);
void readEventMonitorEntry(NeXus::File &file, size_t ws_index);
void readHistoMonitorEntry(NeXus::File &file, size_t ws_index,
size_t numPeriods);
private:
std::vector<LoadNexusMonitorsAlg::MonitorInfo> m_monitorInfo;
std::vector<HistogramData::BinEdges> m_multiPeriodBinEdges;
std::vector<HistogramData::Counts> m_multiPeriodCounts;
std::string m_filename; ///< The name and path of the input file
API::MatrixWorkspace_sptr m_workspace; ///< The workspace being filled out
size_t m_monitor_count{0}; ///< Number of monitors
std::string m_top_entry_name; ///< name of top level NXentry to use
};
} // namespace DataHandling
} // namespace Mantid
#endif // MANTID_DATAHANDLING_LOADNEXUSMONITORS2_H_