Mantid
Loading...
Searching...
No Matches
CorelliCalibrationDatabase.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2014 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 "MantidAlgorithms/DllConfig.h"
14
15namespace Mantid {
16namespace Algorithms {
17
18namespace CorelliCalibration {
19static const std::vector<std::string> calibrationTableColumnNames{
20 "ComponentName", "Xposition", "Yposition", "Zposition",
21 "XdirectionCosine", "YdirectionCosine", "ZdirectionCosine", "RotationAngle"};
22static const std::vector<std::string> calibrationTableColumnTypes{"str", "double", "double", "double",
23 "double", "double", "double", "double"};
24
27 double x;
28 double y;
29 double z;
30 double xCosine;
31 double yCosine;
32 double zCosine;
33 double rotAngle;
34
35 bool equalTo(const ComponentPosition &otherpos, double abstol) {
36 if (fabs(x - otherpos.x) >= abstol || fabs(y - otherpos.y) >= abstol || fabs(z - otherpos.z) >= abstol ||
37 fabs(xCosine - otherpos.xCosine) >= abstol || fabs(yCosine - otherpos.yCosine) >= abstol ||
38 fabs(zCosine - otherpos.zCosine) >= abstol || fabs(rotAngle - otherpos.rotAngle) >= abstol) {
39 return false;
40 }
41 return true;
42 }
43};
44
47class MANTID_ALGORITHMS_DLL CalibrationTableHandler {
48public:
50 static DataObjects::TableWorkspace_sptr loadComponentCalibrationTable(const std::string &filename,
51 const std::string &tablewsname);
52
55 static bool isValidCalibrationTableWorkspace(const DataObjects::TableWorkspace_sptr &calibws, std::string &errormsg);
56
59 static DataObjects::TableWorkspace_sptr createCalibrationTableWorkspace(const std::string &wsname, bool iscomponent);
60
62 ComponentPosition getComponentCalibratedPosition(const std::string &component);
63
65 static void appendCalibration(const DataObjects::TableWorkspace_sptr &tablews, const std::string &datestamp,
66 const ComponentPosition &pos);
67
69 static ComponentPosition getLatestCalibratedPosition(const DataObjects::TableWorkspace_sptr &componentcaltable);
70
73 static ComponentPosition getCalibratedPosition(const DataObjects::TableWorkspace_sptr &componentcaltable,
74 size_t rownumber);
75
78
80 void setCalibrationTable(const DataObjects::TableWorkspace_sptr &calibws);
81
83 std::vector<std::string> getComponentNames();
86
88 DataObjects::TableWorkspace_sptr saveCompomentDatabase(const std::string &datestamp, const std::string &component,
89 const std::string &filename);
91 void saveCalibrationTable(const std::string &filename);
92
93private:
96};
97
98} // namespace CorelliCalibration
99
102class MANTID_ALGORITHMS_DLL CorelliCalibrationDatabase final : public API::Algorithm {
103public:
104 const std::string name() const override { return "CorelliCalibrationDatabase"; };
105 int version() const override { return 1; };
106 const std::string category() const override { return "Diffraction\\Calibration"; };
107
109 const std::vector<std::string> seeAlso() const override {
110 return {"CorelliPowderCalibrationCreate", "CorelliCalibrationApply"};
111 };
112
113 const std::string summary() const override {
114 return "Save calibrated components' positions and orientations to "
115 "database.";
116 };
117
119 static inline std::string corelliComponentDatabaseName(const std::string &componentname,
120 const std::string &directory);
122 static inline std::string corelliCalibrationDatabaseName(const std::string &datestamp, const std::string &directory);
123
124 static std::string convertTimeStamp(const std::string &run_start_time);
125
127 static inline bool isFileExist(const std::string &filepath);
128
130 static inline std::string joinPath(const std::string &directory, const std::string &basename);
131
133 static std::vector<std::string> retrieveInstrumentComponents(const API::MatrixWorkspace_sptr &ws);
134
135private:
136 std::map<std::string, std::string> validateInputs() override;
137 void init() override;
138 void exec() override;
139
141 void updateComponentDatabaseFiles(const std::string &calibdbdir,
142 std::map<std::string, DataObjects::TableWorkspace_sptr> &calibwsmap);
144 void loadNonCalibratedComponentDatabase(const std::string &calibddir,
145 std::map<std::string, DataObjects::TableWorkspace_sptr> &calibwsmap);
147 void createOutputCalibrationTable(std::map<std::string, DataObjects::TableWorkspace_sptr> &calibwsmap,
148 const std::vector<std::string> &orderedcomponents);
149 // Create the summary CSV file
150 void saveCalibrationTable(const std::string &calibdbdir);
153 void setComponentMap(const std::vector<std::string> &componentnames,
154 std::map<std::string, DataObjects::TableWorkspace_sptr> &compmap);
155
163 std::string mDateStamp;
164};
165
166} // namespace Algorithms
167} // namespace Mantid
#define fabs(x)
Definition: Matrix.cpp:22
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:85
CorelliCalibrationDatabase: blablabla TODO.
const std::vector< std::string > seeAlso() const override
Extra help info.
const std::string category() const override
function to return a category of the algorithm.
DataObjects::TableWorkspace_sptr mInputCalibrationTableWS
Input calibration worksapce.
const std::string summary() const override
function returns a summary message that will be displayed in the default GUI, and in the help.
int version() const override
function to return a version of the algorithm, must be overridden in all algorithms
DataObjects::TableWorkspace_sptr mOutputWS
Output calibration worksapce (merged with previous calibrated data)
API::MatrixWorkspace_sptr mInputWS
Input workspace where the calibration is from.
const std::string name() const override
function to return a name of the algorithm, must be overridden in all algorithms
Class containing static and member methods to work with calibration table workspaces.
DataObjects::TableWorkspace_sptr getCalibrationWorkspace()
Get calibration workspace.
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
static const std::vector< std::string > calibrationTableColumnTypes
static const std::vector< std::string > calibrationTableColumnNames
std::shared_ptr< TableWorkspace > TableWorkspace_sptr
shared pointer to Mantid::DataObjects::TableWorkspace
Helper class which provides the Collimation Length for SANS instruments.
Load a single-component database file to a table workspace of history of positions for the component.
Structure to handle all the calibration component positions.
bool equalTo(const ComponentPosition &otherpos, double abstol)