LoadILLTOF2.h 2.97 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

#include "MantidAPI/IFileLoader.h"
10
#include "MantidDataHandling/LoadHelper.h"
11
#include "MantidGeometry/IDTypes.h"
12
#include "MantidKernel/NexusDescriptor.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
 */
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
Samuel Jones's avatar
Samuel Jones committed
27
  const std::string summary() const override { return "Loads an ILL TOF NeXus file."; }
28
29
30

  /// Algorithm's version
  int version() const override { return 2; }
Samuel Jones's avatar
Samuel Jones committed
31
  const std::vector<std::string> seeAlso() const override { return {"LoadNexus"}; }
32
  /// Algorithm's category for identification
Samuel Jones's avatar
Samuel Jones committed
33
  const std::string category() const override { return "DataHandling\\Nexus;ILL\\Direct"; }
34
35
36
37
38
39
40
41
42
43
44

  /// 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
45
  std::vector<std::vector<int>> getMonitorInfo(NeXus::NXEntry &firstEntry);
Samuel Jones's avatar
Samuel Jones committed
46
  void initWorkSpace(NeXus::NXEntry &entry, const std::vector<std::vector<int>> &);
47
  void initInstrumentSpecific();
48
  void addAllNexusFieldsAsProperties(const std::string &filename);
49
50
51
52
53
  void addEnergyToRun();
  void addFacility();
  void addPulseInterval();

  void loadTimeDetails(NeXus::NXEntry &entry);
Samuel Jones's avatar
Samuel Jones committed
54
55
  void loadDataIntoTheWorkSpace(NeXus::NXEntry &entry, const std::vector<std::vector<int>> &, bool convertToTOF);
  void loadSpectra(size_t &spec, const size_t numberOfTubes, const std::vector<Mantid::detid_t> &detectorIDs,
56
                   const NeXus::NXInt &data, Mantid::API::Progress &progress);
57
58
59
60
61
62
63
64

  void runLoadInstrument();

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

  API::MatrixWorkspace_sptr m_localWorkspace;

65
66
  std::string m_instrumentName; ///< Name of the instrument
  std::string m_instrumentPath; ///< Name of the instrument path
67
68

  // Variables describing the data in the detector
69
70
71
72
  size_t m_numberOfTubes;         // number of tubes - X
  size_t m_numberOfPixelsPerTube; // number of pixels per tube - Y
  size_t m_numberOfChannels;      // time channels - Z
  size_t m_numberOfHistograms;
73
74

  /* Values parsed from the nexus file */
75
76
77
  double m_wavelength;
  double m_channelWidth;
  double m_timeOfFlightDelay;
78
  std::string m_monitorName;
79
80
81
82
83
84

  LoadHelper m_loader;
};

} // namespace DataHandling
} // namespace Mantid