Mantid
Loading...
Searching...
No Matches
SaveGSASInstrumentFile.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2013 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7#pragma once
8
11#include "MantidDataHandling/DllConfig.h"
13
14namespace Mantid {
15namespace DataHandling {
16
17class ChopperConfiguration;
18
23class MANTID_DATAHANDLING_DLL SaveGSASInstrumentFile final : public API::Algorithm {
24public:
27 const std::string name() const override { return "SaveGSASInstrumentFile"; }
29 const std::string summary() const override {
30 return "Generate a GSAS instrument file from either a table workspace "
31 "containing profile parameters or a Fullprof's instrument "
32 "resolution file (.irf file). ";
33 }
34
36 int version() const override { return (1); }
37 const std::vector<std::string> seeAlso() const override { return {"LoadGSASInstrumentFile", "SaveGSS"}; }
39 const std::string category() const override { return "Diffraction\\DataHandling"; }
40
41private:
43 void init() override;
45 void exec() override;
46
48 void processProperties();
49
51 void initConstants(const std::map<unsigned int, std::map<std::string, double>> &profmap);
52
54 std::shared_ptr<ChopperConfiguration>
55 setupInstrumentConstants(const std::map<unsigned int, std::map<std::string, double>> &profmap);
56
58 std::shared_ptr<ChopperConfiguration> setupPG3Constants(int intfrequency);
60 std::shared_ptr<ChopperConfiguration> setupNOMConstants(int intfrequency);
61
63 void parseProfileTableWorkspace(const API::ITableWorkspace_sptr &ws,
64 std::map<unsigned int, std::map<std::string, double>> &profilemap);
65
67 void convertToGSAS(const std::vector<unsigned int> &outputbankids, const std::string &gsasinstrfilename,
68 const std::map<unsigned int, std::map<std::string, double>> &bankprofilemap);
69
71 void buildGSASTabulatedProfile(const std::map<unsigned int, std::map<std::string, double>> &bankprofilemap,
72 unsigned int bankid);
73
75 void writePRMHeader(const std::vector<unsigned int> &banks, const std::string &prmfilename);
76
78 void writePRMSingleBank(const std::map<unsigned int, std::map<std::string, double>> &bankprofilemap,
79 unsigned int bankid, const std::string &prmfilename);
80
82 double calL2FromDtt1(double difc, double L1, double twotheta);
83
85 double calTOF(double n, double ep, double eq, double er, double tp, double tq, double tr, double dsp);
86
89 double aaba(double n, double ea1, double ea2, double ta1, double ta2, double dsp);
90
92 double getValueFromMap(const std::map<std::string, double> &profilemap, const std::string &parname);
93
95 double getProfileParameterValue(const std::map<std::string, double> &profilemap, const std::string &paramname);
96
98 void loadFullprofResolutionFile(const std::string &irffilename);
99
101 double calDspRange(double dtt1, double zero, double tof);
102
103 // TODO Replace it with gsl's erfc()
104 double erfc(double xx);
105
108 // DataObjects::TableWorkspace_sptr m_inpWS;
109
111 std::string m_instrument;
113 double m_L1;
115 double m_L2;
117 double m_2theta;
121 std::string m_id_line;
123 std::string m_sample;
124
126 std::vector<unsigned int> m_vecBankID2File;
127
129 std::string m_gsasFileName;
130
132 std::shared_ptr<ChopperConfiguration> m_configuration;
133
135 std::map<unsigned int, std::map<std::string, double>> m_profileMap;
136
137 //
138 std::vector<double> m_gdsp;
139 std::vector<double> m_gdt;
140 std::vector<double> m_galpha;
141 std::vector<double> m_gbeta;
142
143 std::map<unsigned int, double> m_bank_mndsp;
144 std::map<unsigned int, double> m_bank_mxtof;
145};
146
147} // namespace DataHandling
148} // namespace Mantid
static std::unique_ptr< QThreadPool > tp
Base class from which all concrete algorithm classes should be derived.
Definition Algorithm.h:76
SaveGSASInstrumentFile : Convert Fullprof"s instrument resolution file (.irf) to GSAS"s instrument f...
API::ITableWorkspace_sptr m_inpWS
Input workspace.
std::map< unsigned int, std::map< std::string, double > > m_profileMap
Profile parameter map.
std::shared_ptr< ChopperConfiguration > m_configuration
Chopper configuration.
const std::string summary() const override
Summary of algorithms purpose.
int version() const override
Algorithm's version.
const std::vector< std::string > seeAlso() const override
Function to return all of the seeAlso (these are not validated) algorithms related to this algorithm....
const std::string name() const override
Algorithm's name.
std::vector< unsigned int > m_vecBankID2File
Banks IDs to process.
const std::string category() const override
Algorithm's category for identification.
std::shared_ptr< ITableWorkspace > ITableWorkspace_sptr
shared pointer to Mantid::API::ITableWorkspace
Helper class which provides the Collimation Length for SANS instruments.