20double radToDeg(
const double rad) {
21 const double radToDegFactor = 180 / M_PI;
22 return rad * radToDegFactor;
35 return "Save scattering angles two-theta and phi for each workspace in a "
36 "GroupWorkspace of focused banks";
51 "A GroupWorkspace where every sub-workspace is a "
52 "single-spectra focused run corresponding to a particular "
55 const static std::vector<std::string> exts{
".txt",
".new"};
57 "The name of the file to save to");
62 std::ofstream outFile(filename.c_str());
69 outFile << std::fixed << std::setprecision(10);
72 for (
int i = 0; i < inputWS->getNumberOfEntries(); ++i) {
73 const auto ws = inputWS->getItem(i);
74 const auto matrixWS = std::dynamic_pointer_cast<MatrixWorkspace>(ws);
75 const auto &instrument = matrixWS->getInstrument();
76 const auto &samplePosition = instrument->getSample()->getPos();
77 const auto &sourcePosition = instrument->getSource()->getPos();
78 const auto &detector = matrixWS->getDetector(0);
79 const auto &detectorPosition = detector->getPos();
81 const auto beamVector = samplePosition - sourcePosition;
82 const auto detectorVector = detectorPosition - samplePosition;
84 const auto twoTheta = radToDeg(beamVector.angle(detectorVector));
85 const auto phi = radToDeg(detector->getPhi());
86 const auto group = matrixWS->getSpectrum(0).getSpectrumNo();
88 outFile <<
"bank : " << i <<
" "
89 <<
"group: " << group <<
" " <<
twoTheta <<
" " << phi <<
'\n';
101 std::map<std::string, std::string> issues;
104 for (
const auto &ws : *inputWS) {
105 const auto matrixWS = std::dynamic_pointer_cast<MatrixWorkspace>(ws);
107 if (matrixWS->getNumberHistograms() != 1) {
108 issues[
PROP_INPUT_WS] =
"The workspace " + matrixWS->getName() +
109 " has the wrong number of histograms. It "
110 "should contain data for a single focused "
116 "The workspace " + ws->getName() +
" is of the wrong type. It should be a MatrixWorkspace";
#define DECLARE_ALGORITHM(classname)
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
@ Save
to specify a file to write to, the file may or may not exist
A property class for workspaces.
std::map< std::string, std::string > validateInputs() override
Perform validation of ALL the input properties of the algorithm.
void init() override
Virtual method - must be overridden by concrete algorithm.
void exec() override
Virtual method - must be overridden by concrete algorithm.
const std::string summary() const override
function returns a summary message that will be displayed in the default GUI, and in the help.
const std::vector< std::string > seeAlso() const override
Function to return all of the seeAlso (these are not validated) algorithms related to this algorithm....
int version() const override
function to return a version of the algorithm, must be overridden in all algorithms
const std::string category() const override
function to return a category of the algorithm.
static const std::string PROP_FILENAME
static const std::string PROP_INPUT_WS
Records the filename and the description of failure.
void error(const std::string &msg)
Logs at error level.
std::shared_ptr< WorkspaceGroup > WorkspaceGroup_sptr
shared pointer to Mantid::API::WorkspaceGroup
@ Input
An input workspace.