44 return "Takes a workspace group of Polarised SANS run periods and returns a string (e.g '11, 10, 01, 00') of their "
45 "corresponding spin states in Wildes notation.";
56 "InputWorkspace",
"",
Direction::Input, std::make_shared<Mantid::API::PolSANSWorkspaceValidator>()),
57 "A Polarised SANS run from either LARMOR or ZOOM (group workspace with 4 periods).");
59 "Name of the log contained in the InputWorkspace which holds the flipper current (can be inferred if "
60 "data is from LARMOR or ZOOM).",
63 "Expected average current for the spin slipper over all periods. Used to determine if a particular "
64 "period has the flipper active or not (can be inferred if data is from LARMOR or ZOOM).",
67 "A comma-seperated string of the spin states of each of the run periods e.g '11, 10, 01, 00'",
72 const std::string &spinFlipperLogName =
"") {
73 if (spinFlipperLogName !=
"" && !
workspace->run().hasProperty(spinFlipperLogName)) {
74 errorList[
"InputWorkspace"] =
75 "All input workspaces must contain the provided spin flipper log: " + spinFlipperLogName +
".";
80 std::map<std::string, std::string> helpMessages;
84 const auto groupItem = std::dynamic_pointer_cast<API::MatrixWorkspace>(ws);
86 if (!helpMessages.empty()) {
92 const auto firstItem = std::dynamic_pointer_cast<API::MatrixWorkspace>(wsGroup->getItem(0));
93 const auto instrument = firstItem->getInstrument()->getName();
95 if (instrument ==
"LARMOR") {
100 }
else if (instrument ==
"ZOOM") {
105 helpMessages[
"InputWorkspace"] =
"Sub workspaces must be data from either LARMOR or ZOOM when SpinFlipperLogName "
106 "or SpinFlipperAverageCurrent are not provided";
124 std::vector<std::string> spinStatesOrder;
127 const auto groupItem = std::dynamic_pointer_cast<API::MatrixWorkspace>(ws);
133 const auto sfLogValues = sfLog->filteredValuesAsVector();
134 const double rfState =
135 std::accumulate(sfLogValues.cbegin(), sfLogValues.cend(), 0.0) /
static_cast<double>(sfLogValues.size());
136 const double heState = *std::max_element(groupItem->readY(0).cbegin(), groupItem->readY(0).cend()) - averageTrans;
140 spinStatesOrder.push_back(
"10");
142 spinStatesOrder.push_back(
"11");
146 spinStatesOrder.push_back(
"01");
148 spinStatesOrder.push_back(
"00");
153 const std::string spinStates =
Kernel::Strings::join(spinStatesOrder.cbegin(), spinStatesOrder.cend(),
",");
154 std::stringstream msg;
155 msg <<
"Determined the following spin state order for " << wsGroup->getName() <<
": " << spinStates;
161 const auto workspaces = wsGroup->getAllItems();
164 std::accumulate(workspaces.cbegin(), workspaces.cend(), 0.0, [](
double total,
const API::Workspace_sptr ws) {
165 const auto groupItem = std::dynamic_pointer_cast<API::MatrixWorkspace>(ws);
166 return total + *std::max_element(groupItem->readY(0).cbegin(), groupItem->readY(0).cend());
169 return total /
static_cast<double>(workspaces.size());
#define DECLARE_ALGORITHM(classname)
IPeaksWorkspace_sptr workspace
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
std::string getPropertyValue(const std::string &name) const override
Get the value of a property as a string.
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
bool isDefault(const std::string &name) const
A property class for workspaces.
DetermineSpinStateOrder : Takes a workspace group of Polarised SANS run periods and returns a string ...
std::string m_spinFlipperLogName
double averageTransmission(Mantid::API::WorkspaceGroup_const_sptr const &wsGroup) const
double m_rfStateCondition
std::map< std::string, std::string > validateInputs() override
Method checking errors on ALL the inputs, before execution.
void exec() override
Execute the algorithm.
const std::vector< std::string > seeAlso() const override
Function to return all of the seeAlso algorithms related to this algorithm.
const std::string summary() const override
Algorithm's summary for use in the GUI and help.
const std::string category() const override
Algorithm's category for identification.
int version() const override
Algorithm's version for identification.
void init() override
Initialize the algorithm's properties.
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
The Logger class is in charge of the publishing messages from the framework through various channels.
void notice(const std::string &msg)
Logs at notice level.
A specialised Property class for holding a series of time-value pairs.
std::shared_ptr< Workspace > Workspace_sptr
shared pointer to Mantid::API::Workspace
std::shared_ptr< const WorkspaceGroup > WorkspaceGroup_const_sptr
shared pointer to Mantid::API::WorkspaceGroup, pointer to const version
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
void validateGroupItem(API::MatrixWorkspace_sptr const &workspace, std::map< std::string, std::string > &errorList, const std::string &spinFlipperLogName="")
Kernel::Logger g_log("DetermineSpinStateOrder")
DLLExport std::string join(ITERATOR_TYPE begin, ITERATOR_TYPE end, const std::string &separator, typename std::enable_if<!(std::is_same< typename std::iterator_traits< ITERATOR_TYPE >::iterator_category, std::random_access_iterator_tag >::value)>::type *=nullptr)
Join a set or vector of (something that turns into a string) together into one string,...
Helper class which provides the Collimation Length for SANS instruments.
constexpr double EMPTY_DBL() noexcept
Returns what we consider an "empty" double within a property.
Describes the direction (within an algorithm) of a Property.
@ Input
An input workspace.
@ Output
An output workspace.