21double radToDeg(
const double rad) {
22 const double radToDegFactor = 180 / M_PI;
23 return rad * radToDegFactor;
36 return "Save scattering angles two-theta and phi for each workspace in a "
37 "GroupWorkspace of focused banks";
52 "A GroupWorkspace where every sub-workspace is a "
53 "single-spectra focused run corresponding to a particular "
56 const static std::vector<std::string> exts{
".txt",
".new"};
58 "The name of the file to save to");
63 std::ofstream outFile(filename.c_str());
70 outFile << std::fixed << std::setprecision(10);
73 for (
int i = 0; i < inputWS->getNumberOfEntries(); ++i) {
74 const auto ws = inputWS->getItem(i);
75 const auto matrixWS = std::dynamic_pointer_cast<MatrixWorkspace>(ws);
76 const auto &instrument = matrixWS->getInstrument();
77 const auto &samplePosition = instrument->getSample()->getPos();
78 const auto &sourcePosition = instrument->getSource()->getPos();
79 const auto &detector = matrixWS->getDetector(0);
80 const auto &detectorPosition = detector->getPos();
82 const auto beamVector = samplePosition - sourcePosition;
83 const auto detectorVector = detectorPosition - samplePosition;
85 const auto twoTheta = radToDeg(beamVector.angle(detectorVector));
86 const auto phi = radToDeg(matrixWS->spectrumInfo().phi(0));
87 const auto group = matrixWS->getSpectrum(0).getSpectrumNo();
89 outFile <<
"bank : " << i <<
" "
90 <<
"group: " <<
group <<
" " <<
twoTheta <<
" " << phi <<
'\n';
102 std::map<std::string, std::string> issues;
105 for (
const auto &ws : *inputWS) {
106 const auto matrixWS = std::dynamic_pointer_cast<MatrixWorkspace>(ws);
108 if (matrixWS->getNumberHistograms() != 1) {
109 issues[
PROP_INPUT_WS] =
"The workspace " + matrixWS->getName() +
110 " has the wrong number of histograms. It "
111 "should contain data for a single focused "
117 "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.