LoadILLTOF2.h 3 KB
Newer Older
1
2
// Mantid Repository : https://github.com/mantidproject/mantid
//
3
// Copyright © 2019 ISIS Rutherford Appleton Laboratory UKRI,
4
5
6
//     NScD Oak Ridge National Laboratory, European Spallation Source
//     & Institut Laue - Langevin
// SPDX - License - Identifier: GPL - 3.0 +
7
#pragma once
8
9

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

namespace Mantid {
namespace DataHandling {
/**
17
 Loads an ILL IN4/5/6/Panther NeXus file into a Mantid workspace.
18
19
20
21
22
23
24
25
26
27
28
29
30
31
 */
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
32
  const std::vector<std::string> seeAlso() const override {
Nick Draper's avatar
Nick Draper committed
33
    return {"LoadNexus"};
Nick Draper's avatar
Nick Draper committed
34
  }
35
  /// Algorithm's category for identification
Antti Soininen's avatar
Antti Soininen committed
36
37
38
  const std::string category() const override {
    return "DataHandling\\Nexus;ILL\\Direct";
  }
39
40
41
42
43
44
45
46
47
48
49

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

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

  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;
86
  std::string m_monitorName;
87
88
89
90
91
92

  LoadHelper m_loader;
};

} // namespace DataHandling
} // namespace Mantid