LoadMuonNexus.h 4.18 KB
Newer Older
1
2
3
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2007 ISIS Rutherford Appleton Laboratory UKRI,
4
5
//   NScD Oak Ridge National Laboratory, European Spallation Source,
//   Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6
// SPDX - License - Identifier: GPL - 3.0 +
7
#pragma once
8
9
10
11

//----------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------
12
#include "MantidAPI/IFileLoader.h"
13
#include "MantidDataObjects/Workspace2D.h"
14
#include "MantidKernel/NexusDescriptor.h"
Peterson, Peter's avatar
Peterson, Peter committed
15
#include "MantidKernel/System.h"
16

17
18
19
//----------------------------------------------------------------------
// Forward declaration
//----------------------------------------------------------------------
20
class MuonNexusReader;
21

22
23
24
25
namespace Mantid {
namespace DataHandling {
/** @class LoadMuonNexus LoadMuonNexus.h DataHandling/LoadMuonNexus.h

26
It is a base class for loaders for versions 1 and 2 of the muon nexus file
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
format.
It implements property initialization and some common for both versions methods.

Required Properties:
<UL>
<LI> Filename - The name of and path to the input NeXus file </LI>
<LI> OutputWorkspace - The name of the workspace in which to store the imported
data
     (a multiperiod file will store higher periods in workspaces called
OutputWorkspace_PeriodNo)
     [ not yet implemented for Nexus ]</LI>
</UL>

Optional Properties: (note that these options are not available if reading a
multiperiod file)
<UL>
<LI> spectrum_min  - The spectrum to start loading from</LI>
<LI> spectrum_max  - The spectrum to load to</LI>
<LI> spectrum_list - An ArrayProperty of spectra to load</LI>
<LI> auto_group - Determines whether the spectra are automatically grouped
together based on the groupings in the NeXus file. </LI>
</UL>
*/
Samuel Jones's avatar
Samuel Jones committed
50
class DLLExport LoadMuonNexus : public API::IFileLoader<Kernel::NexusDescriptor> {
51
52
53
54
public:
  /// Default constructor
  LoadMuonNexus();
  /// Algorithm's name for identification overriding a virtual method
55
  const std::string name() const override { return "LoadMuonNexus"; }
56
  /// Summary of algorithms purpose
57
  const std::string summary() const override {
58
59
60
61
62
63
64
    return "The LoadMuonNexus algorithm will read the given NeXus Muon data "
           "file Version 1 and use the results to populate the named "
           "workspace. LoadMuonNexus may be invoked by LoadNexus if it is "
           "given a NeXus file of this type.";
  }

  /// Algorithm's version for identification overriding a virtual method
65
  int version() const override { return 1; }
66
  /// Algorithm's category for identification overriding a virtual method
Samuel Jones's avatar
Samuel Jones committed
67
  const std::string category() const override { return "DataHandling\\Nexus;Muon\\DataHandling"; }
68
69

  /// Returns a confidence value that this algorithm can load a file
70
  int confidence(Kernel::NexusDescriptor &descriptor) const override;
71
72
73
74

protected:
  virtual void runLoadInstrumentFromNexus(DataObjects::Workspace2D_sptr) {}
  void checkOptionalProperties();
David Fairbrother's avatar
David Fairbrother committed
75
  void runLoadInstrument(const DataObjects::Workspace2D_sptr &);
76
77
78
79
80
81
82
83
84
85
86
87

  /// The name and path of the input file
  std::string m_filename;
  /// The first top-level entry name in the file
  std::string m_entry_name;
  /// The instrument name from Nexus
  std::string m_instrument_name;
  /// The sample name read from Nexus
  std::string m_samplename;
  /// The number of the input entry
  int64_t m_entrynumber;
  /// The number of spectra in the raw file
88
  specnum_t m_numberOfSpectra;
89
90
  /// The number of periods in the raw file
  int64_t m_numberOfPeriods;
91
92
  /// The different pieces of information about periods
  std::vector<std::string> m_periodInformation;
93
94
95
96
97
  /// Has the spectrum_list property been set?
  bool m_list;
  /// Have the spectrum_min/max properties been set?
  bool m_interval;
  /// The value of the spectrum_list property
98
  std::vector<specnum_t> m_spec_list;
99
  /// The value of the spectrum_min property
100
  specnum_t m_spec_min;
101
  /// The value of the spectrum_max property
102
  specnum_t m_spec_max;
103
  /// The group which each detector belongs to in order
104
  std::vector<detid_t> m_groupings;
105
106
107

private:
  /// Overwrites Algorithm method.
108
  void init() override;
109
110
111
};

} // namespace DataHandling
112
} // namespace Mantid