PDCalibration.h 3.13 KB
Newer Older
1
2
3
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2015 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
Peterson, Peter's avatar
Peterson, Peter committed
8
9

#include "MantidAPI/Algorithm.h"
10
#include "MantidAPI/ITableWorkspace_fwd.h"
Zhou, Wenduo's avatar
Zhou, Wenduo committed
11
12
13
#include "MantidAPI/MatrixWorkspace_fwd.h"
#include "MantidAlgorithms/DllConfig.h"
#include "MantidDataObjects/TableWorkspace.h"
Peterson, Peter's avatar
Peterson, Peter committed
14
#include "MantidGeometry/IDTypes.h"
15
16
#include <map>

Peterson, Peter's avatar
Peterson, Peter committed
17
18
19
20
namespace Mantid {
namespace Algorithms {

/** PDCalibration : TODO: DESCRIPTION
21
 */
Peterson, Peter's avatar
Peterson, Peter committed
22
23
24
class MANTID_ALGORITHMS_DLL PDCalibration : public API::Algorithm {
public:
  PDCalibration();
Whitfield, Ross's avatar
Whitfield, Ross committed
25
  ~PDCalibration();
Peterson, Peter's avatar
Peterson, Peter committed
26

Whitfield, Ross's avatar
Whitfield, Ross committed
27
28
  const std::string name() const override;
  int version() const override;
Zhou, Wenduo's avatar
Zhou, Wenduo committed
29
  const std::vector<std::string> seeAlso() const override { return {}; }
Whitfield, Ross's avatar
Whitfield, Ross committed
30
31
  const std::string category() const override;
  const std::string summary() const override;
Peterson, Peter's avatar
Peterson, Peter committed
32
33

private:
34
35
  class FittedPeaks; // forward declare of private inner class

Whitfield, Ross's avatar
Whitfield, Ross committed
36
  void init() override;
37
  std::map<std::string, std::string> validateInputs() override;
Whitfield, Ross's avatar
Whitfield, Ross committed
38
  void exec() override;
Peterson, Peter's avatar
Peterson, Peter committed
39
  API::MatrixWorkspace_sptr loadAndBin();
40
  API::MatrixWorkspace_sptr rebin(API::MatrixWorkspace_sptr wksp);
David Fairbrother's avatar
David Fairbrother committed
41
  API::MatrixWorkspace_sptr load(const std::string &filename);
42
43
  void createCalTableFromExisting();
  void createCalTableNew();
44
  void createInformationWorkspaces();
Samuel Jones's avatar
Samuel Jones committed
45
46
47
48
49
50
  std::tuple<double, double, double> getDSpacingToTof(const std::set<detid_t> &detIds);
  std::vector<double> dSpacingWindows(const std::vector<double> &centres, const double widthMax);
  std::vector<double> getTOFminmax(const double difc, const double difa, const double tzero);
  void setCalibrationValues(const detid_t detid, const double difc, const double difa, const double tzero);
  void fitDIFCtZeroDIFA_LM(const std::vector<double> &d, const std::vector<double> &tof,
                           const std::vector<double> &height2, double &difc, double &t0, double &difa);
51
52
  API::MatrixWorkspace_sptr calculateResolutionTable();

Zhou, Wenduo's avatar
Zhou, Wenduo committed
53
  /// NEW: convert peak positions in dSpacing to peak centers workspace
54
  std::pair<API::MatrixWorkspace_sptr, API::MatrixWorkspace_sptr>
Samuel Jones's avatar
Samuel Jones committed
55
  createTOFPeakCenterFitWindowWorkspaces(const API::MatrixWorkspace_sptr &dataws, const double peakWindowMaxInDSpacing);
Zhou, Wenduo's avatar
Zhou, Wenduo committed
56

Samuel Jones's avatar
Samuel Jones committed
57
  API::ITableWorkspace_sptr sortTableWorkspace(API::ITableWorkspace_sptr &table);
58
59
60
61
62
63

  API::MatrixWorkspace_sptr m_uncalibratedWS{nullptr};
  API::ITableWorkspace_sptr m_calibrationTable{nullptr};
  API::ITableWorkspace_sptr m_peakPositionTable{nullptr};
  API::ITableWorkspace_sptr m_peakWidthTable{nullptr};
  API::ITableWorkspace_sptr m_peakHeightTable{nullptr};
64
65
  std::vector<double> m_peaksInDspacing;
  std::map<detid_t, size_t> m_detidToRow;
Jose Borreguero's avatar
Jose Borreguero committed
66
  double m_tofMin{0.}; // first bin boundary when rebinning in TOF (user input)
67
  double m_tofMax{0.}; // last bin boundary when rebinning in TOF (user input)
68
69
70
71
  double m_tzeroMin{0.};
  double m_tzeroMax{0.};
  double m_difaMin{0.};
  double m_difaMax{0.};
Peterson, Peter's avatar
Peterson, Peter committed
72
  bool m_hasDasIds{false};
73
  size_t m_numberMaxParams{0};
Peterson, Peter's avatar
Peterson, Peter committed
74
75
76
77
};

} // namespace Algorithms
} // namespace Mantid