21using namespace Kernel;
23using namespace Geometry;
28 "Name of the workspace giving the instrument");
30 "Name of the workspace receiving the instrument");
51 auto Name1 = inst1->getName();
52 auto Name2 = inst2->getName();
58 const auto &givParams = inst1->makeLegacyParameterMap();
59 for (
const auto &item : *givParams) {
64 auto *pOldDet =
dynamic_cast<IDetector *
>(oldComponent);
66 detid_t detID = pOldDet->getID();
67 targComp = inst2->getBaseDetector(detID);
69 g_log.
warning() <<
"Target instrument does not have detector with ID " << detID <<
'\n';
73 std::string source_name = oldComponent->
getFullName();
74 size_t nameStart = source_name.find(Name1);
75 std::string targ_name = source_name.replace(nameStart, nameStart + Name1.size(), Name2);
77 auto spTargComp = inst2->getComponentByName(targ_name);
79 g_log.
warning() <<
"Target instrument does not have component with full name: " << targ_name <<
'\n';
90 targMap.
add(targComp, param);
118 throw std::invalid_argument(
"Input workspace has no instrument");
122 throw std::invalid_argument(
"Output workspace has no instrument");
129 if (baseInstRec != baseInstGiv) {
131 g_log.
warning() <<
"The base instrument in the output workspace is not the "
132 "same as the base instrument in the input workspace.\n";
137 const std::map<std::string, Parallel::StorageMode> &storageModes)
const {
138 const auto in = storageModes.at(
"InputWorkspace");
139 const auto out = storageModes.at(
"InputWorkspace");
142 if (in == Parallel::StorageMode::MasterOnly && in != out)
143 return Parallel::ExecutionMode::Invalid;
144 return Parallel::getCorrespondingExecutionMode(out);
#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.
A property class for workspaces.
void checkProperties()
Retrieves the properties and checks that they have valid values.
void exec() override
Execution code.
void init() override
Initialisation code.
API::MatrixWorkspace_sptr m_givingWorkspace
The giving workspace.
bool m_different_instrument_sp
indicates that source workspace instrument and target workspace instrument have different share point...
API::MatrixWorkspace_sptr m_receivingWorkspace
The receiving workspace.
Parallel::ExecutionMode getParallelExecutionMode(const std::map< std::string, Parallel::StorageMode > &storageModes) const override
Get correct execution mode based on input storage modes for an MPI run.
base class for Geometric IComponent
virtual IComponent const * getBaseComponent() const =0
Returns const pointer to base component if this component is parametrized.
virtual std::string getFullName() const =0
Get the IComponent full path name.
Interface class for detector objects.
std::string asString() const
Returns a string with all component names, parameter names and values.
void add(const std::string &type, const IComponent *comp, const std::string &name, const std::string &value, const std::string *const pDescription=nullptr, const std::string &visible="true")
Method for adding a parameter providing its value as a string.
void warning(const std::string &msg)
Logs at warning level.
std::shared_ptr< Parameter > Parameter_sptr
Typedef for the shared pointer.
std::shared_ptr< const Instrument > Instrument_const_sptr
Shared pointer to an const instrument object.
int32_t detid_t
Typedef for a detector ID.
@ InOut
Both an input & output workspace.
@ Input
An input workspace.