LoadILLTOF2.h 3.13 KB
Newer Older
1
2
// Mantid Repository : https://github.com/mantidproject/mantid
//
3
// Copyright © 2019 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

#include "MantidAPI/IFileLoader.h"
#include "MantidGeometry/IDTypes.h"
11
#include "MantidKernel/NexusDescriptor.h"
12
#include "MantidNexus/LoadHelper.h"
LamarMoore's avatar
LamarMoore committed
13
#include "MantidNexus/NexusClasses.h"
14
15
16
17

namespace Mantid {
namespace DataHandling {
/**
18
 Loads an ILL IN4/5/6/Panther NeXus file into a Mantid workspace.
19
20
21
22
23
24
25
26
27
28
29
30
31
32
 */
class DLLExport LoadILLTOF2 : public API::IFileLoader<Kernel::NexusDescriptor> {
public:
  /// Constructor
  LoadILLTOF2();
  /// Algorithm's name
  const std::string name() const override { return "LoadILLTOF"; }
  /// Summary of algorithms purpose
  const std::string summary() const override {
    return "Loads an ILL TOF NeXus file.";
  }

  /// Algorithm's version
  int version() const override { return 2; }
Nick Draper's avatar
Nick Draper committed
33
  const std::vector<std::string> seeAlso() const override {
Nick Draper's avatar
Nick Draper committed
34
    return {"LoadNexus"};
Nick Draper's avatar
Nick Draper committed
35
  }
36
  /// Algorithm's category for identification
Antti Soininen's avatar
Antti Soininen committed
37
38
39
  const std::string category() const override {
    return "DataHandling\\Nexus;ILL\\Direct";
  }
40
41
42
43
44
45
46
47
48
49
50

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

private:
  // Initialisation code
  void init() override;
  // Execution code
  void exec() override;

  void loadInstrumentDetails(NeXus::NXEntry &);
Antti Soininen's avatar
Antti Soininen committed
51
  std::vector<std::vector<int>> getMonitorInfo(NeXus::NXEntry &firstEntry);
52
  void initWorkSpace(NeXus::NXEntry &entry,
Antti Soininen's avatar
Antti Soininen committed
53
                     const std::vector<std::vector<int>> &);
54
  void initInstrumentSpecific();
55
  void addAllNexusFieldsAsProperties(const std::string &filename);
56
57
58
59
60
  void addEnergyToRun();
  void addFacility();
  void addPulseInterval();

  void loadTimeDetails(NeXus::NXEntry &entry);
Antti Soininen's avatar
Antti Soininen committed
61
  void loadDataIntoTheWorkSpace(NeXus::NXEntry &entry,
62
63
                                const std::vector<std::vector<int>> &,
                                bool convertToTOF);
Antti Soininen's avatar
Antti Soininen committed
64
  void loadSpectra(size_t &spec, const size_t numberOfTubes,
Antti Soininen's avatar
Antti Soininen committed
65
                   const std::vector<Mantid::detid_t> &detectorIDs,
66
                   const NeXus::NXInt &data, Mantid::API::Progress &progress);
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87

  void runLoadInstrument();

  /// Calculate error for y
  static double calculateError(double in) { return sqrt(in); }

  API::MatrixWorkspace_sptr m_localWorkspace;

  std::string m_instrumentName = ""; ///< Name of the instrument
  std::string m_instrumentPath = ""; ///< Name of the instrument path

  // Variables describing the data in the detector
  size_t m_numberOfTubes = 0;         // number of tubes - X
  size_t m_numberOfPixelsPerTube = 0; // number of pixels per tube - Y
  size_t m_numberOfChannels = 0;      // time channels - Z
  size_t m_numberOfHistograms = 0;

  /* Values parsed from the nexus file */
  double m_wavelength = 0;
  double m_channelWidth = 0;
  double m_timeOfFlightDelay = 0;
88
  std::string m_monitorName;
89

90
  Nexus::LoadHelper m_loader;
91
92
93
94
};

} // namespace DataHandling
} // namespace Mantid