Mantid
|
MultiPeriodGroupWorker : Multiperiod group logic relating to determining a valid multiperiod group, and processing a multiperiod group, as well as combining and returning the output. More...
#include <MultiPeriodGroupWorker.h>
Public Types | |
using | VecWSGroupType = std::vector< WorkspaceGroup_sptr > |
Convenience typdef for workspace names. More... | |
Public Member Functions | |
VecWSGroupType | findMultiPeriodGroups (Algorithm const *const sourceAlg) const |
Check groups. More... | |
MultiPeriodGroupWorker ()=default | |
Constructor. More... | |
MultiPeriodGroupWorker (std::string workspacePropertyName) | |
Constructor. More... | |
bool | processGroups (Algorithm *const sourceAlg, const VecWSGroupType &vecMultiPeriodGroups) const |
Process groups. More... | |
bool | useCustomWorkspaceProperty () const |
Flag to indicate use of a custom workspace property. More... | |
virtual | ~MultiPeriodGroupWorker ()=default |
Private Member Functions | |
void | copyInputWorkspaceProperties (IAlgorithm *targetAlg, IAlgorithm *sourceAlg, const int &periodNumber) const |
Copy input workspace properties to spawned algorithm. More... | |
std::string | createFormattedInputWorkspaceNames (const size_t &periodIndex, const VecWSGroupType &vecWorkspaceGroups) const |
Create an input workspace string from the workspace groups. More... | |
MultiPeriodGroupWorker (const MultiPeriodGroupWorker &) | |
MultiPeriodGroupWorker & | operator= (const MultiPeriodGroupWorker &) |
void | tryAddInputWorkspaceToInputGroups (const Workspace_sptr &ws, VecWSGroupType &vecMultiPeriodWorkspaceGroups, VecWSGroupType &vecWorkspaceGroups) const |
Try ot add a workspace to the group of input workspaces. More... | |
void | validateMultiPeriodGroupInputs (const VecWSGroupType &vecMultiPeriodGroups) const |
Validate the input group workspace. More... | |
Private Attributes | |
std::string | m_workspacePropertyName |
Workspace property name. More... | |
MultiPeriodGroupWorker : Multiperiod group logic relating to determining a valid multiperiod group, and processing a multiperiod group, as well as combining and returning the output.
Determines if the input workspaces are multiperiod group workspaces Processes the multiperiod group workspaces period by period running a new instance of the target algorithm for each one, then regrouping the results
Definition at line 30 of file MultiPeriodGroupWorker.h.
using Mantid::API::MultiPeriodGroupWorker::VecWSGroupType = std::vector<WorkspaceGroup_sptr> |
Convenience typdef for workspace names.
Definition at line 33 of file MultiPeriodGroupWorker.h.
|
default |
Constructor.
Mantid::API::MultiPeriodGroupWorker::MultiPeriodGroupWorker | ( | std::string | workspacePropertyName | ) |
Constructor.
workspacePropertyName | : Property name to treat as source of multiperiod workspaces. |
Definition at line 28 of file MultiPeriodGroupWorker.cpp.
|
virtualdefault |
|
private |
|
private |
Copy input workspace properties to spawned algorithm.
1) Looks for input workspace properties that are of type WorkspaceGroup.
2) If a multiperiod workspace has been set to that property then .. 3) Extracts the individual period workspace from that WorkspaceGroup 4) Manually sets that individual period workspace as the corresponding property on the targetAlgorithm. Copy input workspaces assuming we are working with multi-period groups workspace inputs.
targetAlg | The spawned algorithm to set the properties on. |
sourceAlg | Algorithm being executed with multiperiod group workspaces. |
periodNumber | The relevant period number used to index into the group workspaces |
Definition at line 151 of file MultiPeriodGroupWorker.cpp.
References Mantid::Kernel::IPropertyManager::getProperties(), Mantid::Kernel::Direction::Input, and Mantid::Kernel::IPropertyManager::setProperty().
Referenced by processGroups().
|
private |
Create an input workspace string from the workspace groups.
Creates a list of input workspaces as a string for a given period using all nested workspaces at that period within all group workspaces.
This requires a little explanation, because this is the reason that this algorithm needs a customised overriden checkGroups and processGroups method:
Say you have two multiperiod group workspaces A and B and an output workspace C. A contains matrix workspaces A_1 and A_2, and B contains matrix workspaces B_1 and B2. Because this is multiperiod data. A_1 and B_1 share the same period, as do A_2 and B_2. So merging must be with respect to workspaces of equivalent periods. Therefore, merging must be A_1 + B_1 = C_1 and A_2 + B_2 = C_2. This method constructs the inputs for a nested call to MultiPeriodGroupAlgorithm in this manner.
periodIndex | : zero based index denoting the period. |
vecWorkspaceGroups | : Vector of workspace groups |
Definition at line 127 of file MultiPeriodGroupWorker.cpp.
Referenced by processGroups().
MultiPeriodGroupWorker::VecWSGroupType Mantid::API::MultiPeriodGroupWorker::findMultiPeriodGroups | ( | Algorithm const *const | sourceAlg | ) | const |
Check groups.
Definition at line 52 of file MultiPeriodGroupWorker.cpp.
References Mantid::API::Algorithm::findWorkspaces(), Mantid::API::Algorithm::getProperty(), Mantid::Kernel::Direction::Input, Mantid::Kernel::SingletonHolder< T >::Instance(), Mantid::API::Algorithm::isInitialized(), m_workspacePropertyName, tryAddInputWorkspaceToInputGroups(), useCustomWorkspaceProperty(), validateMultiPeriodGroupInputs(), and workspace.
|
private |
bool Mantid::API::MultiPeriodGroupWorker::processGroups | ( | Algorithm *const | sourceAlg, |
const VecWSGroupType & | vecMultiPeriodGroups | ||
) | const |
Process groups.
Process WorkspaceGroup inputs.
Overriden from Algorithm base class.
This should be called after checkGroups(), which sets up required members. It goes through each member of the group(s), creates and sets an algorithm for each and executes them one by one.
If there are several group input workspaces, then the member of each group is executed pair-wise.
sourceAlg | : Source algorithm |
vecMultiPeriodGroups | : Vector of pre-identified multiperiod groups. |
Definition at line 185 of file MultiPeriodGroupWorker.cpp.
References copyInputWorkspaceProperties(), Mantid::API::Algorithm::copyNonWorkspaceProperties(), Mantid::API::Algorithm::createChildAlgorithm(), createFormattedInputWorkspaceNames(), Mantid::API::Algorithm::getProperty(), Mantid::Kernel::SingletonHolder< T >::Instance(), Mantid::API::Algorithm::isLogging(), m_workspacePropertyName, Mantid::API::Algorithm::name(), Mantid::Kernel::IPropertyManager::setProperty(), Mantid::Kernel::Strings::toString(), useCustomWorkspaceProperty(), Mantid::Kernel::Property::value(), and Mantid::API::Algorithm::version().
|
private |
Try ot add a workspace to the group of input workspaces.
Try to add the input workspace to the multiperiod input group list.
ws | candidate workspace |
vecMultiPeriodWorkspaceGroups | Vector of multi period workspace groups. |
vecWorkspaceGroups | Vector of non-multi period workspace groups. |
Definition at line 38 of file MultiPeriodGroupWorker.cpp.
Referenced by findMultiPeriodGroups().
bool Mantid::API::MultiPeriodGroupWorker::useCustomWorkspaceProperty | ( | ) | const |
Flag to indicate use of a custom workspace property.
Definition at line 105 of file MultiPeriodGroupWorker.cpp.
References m_workspacePropertyName.
Referenced by findMultiPeriodGroups(), and processGroups().
|
private |
Validate the input group workspace.
Validate the multiperiods workspace groups.
Gives the opportunity to exit processing if things don't look right.
vecMultiPeriodGroups | : vector of multiperiod groups. |
Definition at line 247 of file MultiPeriodGroupWorker.cpp.
References getName(), and Mantid::Kernel::Property::value().
Referenced by findMultiPeriodGroups().
|
private |
Workspace property name.
Definition at line 67 of file MultiPeriodGroupWorker.h.
Referenced by findMultiPeriodGroups(), processGroups(), and useCustomWorkspaceProperty().