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#include "MantidKernel/System.h"
14
15namespace Mantid {
16namespace DataHandling {
17
18class ChopperConfiguration;
19
24class MANTID_DATAHANDLING_DLL SaveGSASInstrumentFile final : public API::Algorithm {
25public:
28 const std::string name() const override { return "SaveGSASInstrumentFile"; }
30 const std::string summary() const override {
31 return "Generate a GSAS instrument file from either a table workspace "
32 "containing profile parameters or a Fullprof's instrument "
33 "resolution file (.irf file). ";
34 }
35
37 int version() const override { return (1); }
38 const std::vector<std::string> seeAlso() const override { return {"LoadGSASInstrumentFile", "SaveGSS"}; }
40 const std::string category() const override { return "Diffraction\\DataHandling"; }
41
42private:
44 void init() override;
46 void exec() override;
47
49 void processProperties();
50
52 void initConstants(const std::map<unsigned int, std::map<std::string, double>> &profmap);
53
55 std::shared_ptr<ChopperConfiguration>
56 setupInstrumentConstants(const std::map<unsigned int, std::map<std::string, double>> &profmap);
57
59 std::shared_ptr<ChopperConfiguration> setupPG3Constants(int intfrequency);
61 std::shared_ptr<ChopperConfiguration> setupNOMConstants(int intfrequency);
62
64 void parseProfileTableWorkspace(const API::ITableWorkspace_sptr &ws,
65 std::map<unsigned int, std::map<std::string, double>> &profilemap);
66
68 void convertToGSAS(const std::vector<unsigned int> &outputbankids, const std::string &gsasinstrfilename,
69 const std::map<unsigned int, std::map<std::string, double>> &bankprofilemap);
70
72 void buildGSASTabulatedProfile(const std::map<unsigned int, std::map<std::string, double>> &bankprofilemap,
73 unsigned int bankid);
74
76 void writePRMHeader(const std::vector<unsigned int> &banks, const std::string &prmfilename);
77
79 void writePRMSingleBank(const std::map<unsigned int, std::map<std::string, double>> &bankprofilemap,
80 unsigned int bankid, const std::string &prmfilename);
81
83 double calL2FromDtt1(double difc, double L1, double twotheta);
84
86 double calTOF(double n, double ep, double eq, double er, double tp, double tq, double tr, double dsp);
87
90 double aaba(double n, double ea1, double ea2, double ta1, double ta2, double dsp);
91
93 double getValueFromMap(const std::map<std::string, double> &profilemap, const std::string &parname);
94
96 double getProfileParameterValue(const std::map<std::string, double> &profilemap, const std::string &paramname);
97
99 void loadFullprofResolutionFile(const std::string &irffilename);
100
102 double calDspRange(double dtt1, double zero, double tof);
103
104 // TODO Replace it with gsl's erfc()
105 double erfc(double xx);
106
109 // DataObjects::TableWorkspace_sptr m_inpWS;
110
112 std::string m_instrument;
114 double m_L1;
116 double m_L2;
118 double m_2theta;
122 std::string m_id_line;
124 std::string m_sample;
125
127 std::vector<unsigned int> m_vecBankID2File;
128
130 std::string m_gsasFileName;
131
133 std::shared_ptr<ChopperConfiguration> m_configuration;
134
136 std::map<unsigned int, std::map<std::string, double>> m_profileMap;
137
138 //
139 std::vector<double> m_gdsp;
140 std::vector<double> m_gdt;
141 std::vector<double> m_galpha;
142 std::vector<double> m_gbeta;
143
144 std::map<unsigned int, double> m_bank_mndsp;
145 std::map<unsigned int, double> m_bank_mxtof;
146};
147
148} // namespace DataHandling
149} // namespace Mantid
static std::unique_ptr< QThreadPool > tp
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:85
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.