Mantid
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
Mantid::API::MultiPeriodGroupWorker Class Reference

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 &)
 
MultiPeriodGroupWorkeroperator= (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...
 

Detailed Description

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.

Member Typedef Documentation

◆ VecWSGroupType

Convenience typdef for workspace names.

Definition at line 33 of file MultiPeriodGroupWorker.h.

Constructor & Destructor Documentation

◆ MultiPeriodGroupWorker() [1/3]

Mantid::API::MultiPeriodGroupWorker::MultiPeriodGroupWorker ( )
default

Constructor.

◆ MultiPeriodGroupWorker() [2/3]

Mantid::API::MultiPeriodGroupWorker::MultiPeriodGroupWorker ( std::string  workspacePropertyName)

Constructor.

Parameters
workspacePropertyName: Property name to treat as source of multiperiod workspaces.

Definition at line 28 of file MultiPeriodGroupWorker.cpp.

◆ ~MultiPeriodGroupWorker()

virtual Mantid::API::MultiPeriodGroupWorker::~MultiPeriodGroupWorker ( )
virtualdefault

◆ MultiPeriodGroupWorker() [3/3]

Mantid::API::MultiPeriodGroupWorker::MultiPeriodGroupWorker ( const MultiPeriodGroupWorker )
private

Member Function Documentation

◆ copyInputWorkspaceProperties()

void Mantid::API::MultiPeriodGroupWorker::copyInputWorkspaceProperties ( IAlgorithm targetAlg,
IAlgorithm sourceAlg,
const int &  periodNumber 
) const
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.

Parameters
targetAlgThe spawned algorithm to set the properties on.
sourceAlgAlgorithm being executed with multiperiod group workspaces.
periodNumberThe 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().

◆ createFormattedInputWorkspaceNames()

std::string Mantid::API::MultiPeriodGroupWorker::createFormattedInputWorkspaceNames ( const size_t &  periodIndex,
const VecWSGroupType vecWorkspaceGroups 
) const
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.

Parameters
periodIndex: zero based index denoting the period.
vecWorkspaceGroups: Vector of workspace groups
Returns
comma separated string of input workspaces.

Definition at line 127 of file MultiPeriodGroupWorker.cpp.

Referenced by processGroups().

◆ findMultiPeriodGroups()

MultiPeriodGroupWorker::VecWSGroupType Mantid::API::MultiPeriodGroupWorker::findMultiPeriodGroups ( Algorithm const *const  sourceAlg) const

◆ operator=()

MultiPeriodGroupWorker & Mantid::API::MultiPeriodGroupWorker::operator= ( const MultiPeriodGroupWorker )
private

◆ processGroups()

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.

Parameters
sourceAlg: Source algorithm
vecMultiPeriodGroups: Vector of pre-identified multiperiod groups.
Returns
true - if all the workspace members are executed.

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().

◆ tryAddInputWorkspaceToInputGroups()

void Mantid::API::MultiPeriodGroupWorker::tryAddInputWorkspaceToInputGroups ( const Workspace_sptr ws,
MultiPeriodGroupWorker::VecWSGroupType vecMultiPeriodWorkspaceGroups,
MultiPeriodGroupWorker::VecWSGroupType vecWorkspaceGroups 
) const
private

Try ot add a workspace to the group of input workspaces.

Try to add the input workspace to the multiperiod input group list.

Parameters
wscandidate workspace
vecMultiPeriodWorkspaceGroupsVector of multi period workspace groups.
vecWorkspaceGroupsVector of non-multi period workspace groups.

Definition at line 38 of file MultiPeriodGroupWorker.cpp.

Referenced by findMultiPeriodGroups().

◆ useCustomWorkspaceProperty()

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().

◆ validateMultiPeriodGroupInputs()

void Mantid::API::MultiPeriodGroupWorker::validateMultiPeriodGroupInputs ( const VecWSGroupType vecMultiPeriodGroups) const
private

Validate the input group workspace.

Validate the multiperiods workspace groups.

Gives the opportunity to exit processing if things don't look right.

Parameters
vecMultiPeriodGroups: vector of multiperiod groups.

Definition at line 247 of file MultiPeriodGroupWorker.cpp.

References getName(), and Mantid::Kernel::Property::value().

Referenced by findMultiPeriodGroups().

Member Data Documentation

◆ m_workspacePropertyName

std::string Mantid::API::MultiPeriodGroupWorker::m_workspacePropertyName
private

Workspace property name.

Definition at line 67 of file MultiPeriodGroupWorker.h.

Referenced by findMultiPeriodGroups(), processGroups(), and useCustomWorkspaceProperty().


The documentation for this class was generated from the following files: