Mantid
Loading...
Searching...
No Matches
MergeRuns.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2008 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7#pragma once
8
12#include "MantidAlgorithms/DllConfig.h"
15
16#include <boost/optional.hpp>
17
18namespace Mantid {
19namespace API {
20class WorkspaceGroup;
21}
22namespace HistogramData {
23class HistogramX;
24}
25namespace Algorithms {
51namespace MergeRunsParameter {
53static const std::string SUM_MERGE = "sample_logs_sum";
54static const std::string TIME_SERIES_MERGE = "sample_logs_time_series";
55static const std::string LIST_MERGE = "sample_logs_list";
56static const std::string WARN_MERGE = "sample_logs_warn";
57static const std::string WARN_MERGE_TOLERANCES = "sample_logs_warn_tolerances";
58static const std::string FAIL_MERGE = "sample_logs_fail";
59static const std::string FAIL_MERGE_TOLERANCES = "sample_logs_fail_tolerances";
60} // namespace MergeRunsParameter
61
62class MANTID_ALGORITHMS_DLL MergeRuns : public API::MultiPeriodGroupAlgorithm {
63public:
65 const std::string name() const override { return "MergeRuns"; }
67 const std::string summary() const override {
68 return "Combines the data contained in an arbitrary number of input "
69 "workspaces.";
70 }
71
73 int version() const override { return 1; }
74 const std::vector<std::string> seeAlso() const override { return {"ConjoinWorkspaces"}; }
76 const std::string category() const override { return "Transforms\\Merging"; }
77 // Overriden MultiPeriodGroupAlgorithm method.
78 bool useCustomInputPropertyName() const override;
79
80protected:
83 void fillHistory() override;
84
85private:
86 // Overridden Algorithm methods
87 void init() override;
88 void exec() override;
89 void execEvent();
90 void execHistogram(const std::vector<std::string> &inputs);
91 void buildAdditionTables();
92 // Overriden MultiPeriodGroupAlgorithm method.
93 std::string fetchInputPropertyName() const override;
94
98 using AdditionTable = std::vector<std::pair<int, int>>;
100 template <typename Container> void copyHistoryFromInputWorkspaces(const Container &workspaces) {
101 API::Workspace_sptr outWS = this->getProperty("OutputWorkspace");
102
103 // this is not a child algorithm. Add the history algorithm to the
104 // WorkspaceHistory object.
105 if (!isChild()) {
106 // Loop over the input workspaces, making the call that copies their
107 // history to the output ones
108 // (Protection against copy to self is in
109 // WorkspaceHistory::copyAlgorithmHistory)
110 for (auto inWS = workspaces.begin(); inWS != workspaces.end(); ++inWS) {
111 outWS->history().addHistory((*inWS)->getHistory());
112 }
113 // Add the history for the current algorithm to all the output workspaces
114 outWS->history().addHistory(m_history);
115 }
116 // this is a child algorithm, but we still want to keep the history.
117 else if (isRecordingHistoryForChild() && m_parentHistory) {
118 m_parentHistory->addChildHistory(m_history);
119 }
120 }
121
122 // Methods called by exec()
124 bool validateInputsForEventWorkspaces(const std::vector<std::string> &inputWorkspaces);
125 boost::optional<std::vector<double>> checkRebinning();
126 static std::vector<double> calculateRebinParams(const std::vector<double> &bins1, const std::vector<double> &bins2);
127 static void noOverlapParams(const HistogramData::HistogramX &X1, const HistogramData::HistogramX &X2,
128 std::vector<double> &params);
129 static void intersectionParams(const HistogramData::HistogramX &X1, size_t &i, const HistogramData::HistogramX &X2,
130 std::vector<double> &params);
131 static void inclusionParams(const HistogramData::HistogramX &X1, size_t &i, const HistogramData::HistogramX &X2,
132 std::vector<double> &params);
133 API::MatrixWorkspace_sptr rebinInput(const API::MatrixWorkspace_sptr &workspace, const std::vector<double> &params);
134 API::MatrixWorkspace_sptr buildScanningOutputWorkspace(const API::MatrixWorkspace_sptr &outWS,
135 const API::MatrixWorkspace_sptr &addee);
137 std::unique_ptr<API::Progress> m_progress;
138
140 std::vector<Mantid::DataObjects::EventWorkspace_sptr> m_inEventWS;
142 std::list<API::MatrixWorkspace_sptr> m_inMatrixWS;
144 std::vector<AdditionTable> m_tables;
146 size_t m_outputSize = 0;
147
148 std::vector<SpectrumDefinition> buildScanIntervals(const std::vector<SpectrumDefinition> &addeeSpecDefs,
149 const Geometry::DetectorInfo &addeeDetInfo,
150 const Geometry::DetectorInfo &newOutDetInfo);
151};
152
153} // namespace Algorithms
154} // namespace Mantid
IPeaksWorkspace_sptr workspace
Definition: IndexPeaks.cpp:114
std::map< std::string, std::string > validateInputs() override
Perform validation of ALL the input properties of the algorithm.
Definition: Algorithm.cpp:324
MutliPeriodGroupAlgorithm : Abstract algorithm.
const std::string name() const override
Algorithm's name for identification overriding a virtual method.
Definition: MergeRuns.h:65
const std::string category() const override
Algorithm's category for identification overriding a virtual method.
Definition: MergeRuns.h:76
void copyHistoryFromInputWorkspaces(const Container &workspaces)
Copy the history from the input workspaces to the output workspaces.
Definition: MergeRuns.h:100
std::vector< Mantid::DataObjects::EventWorkspace_sptr > m_inEventWS
List of input EVENT workspaces.
Definition: MergeRuns.h:140
std::unique_ptr< API::Progress > m_progress
Progress reporting.
Definition: MergeRuns.h:137
int version() const override
Algorithm's version for identification overriding a virtual method.
Definition: MergeRuns.h:73
const std::string summary() const override
Summary of algorithms purpose.
Definition: MergeRuns.h:67
std::vector< AdditionTable > m_tables
Addition tables for event workspaces.
Definition: MergeRuns.h:144
const std::vector< std::string > seeAlso() const override
Function to return all of the seeAlso algorithms related to this algorithm.
Definition: MergeRuns.h:74
std::list< API::MatrixWorkspace_sptr > m_inMatrixWS
List of input matrix workspace.
Definition: MergeRuns.h:142
std::vector< std::pair< int, int > > AdditionTable
An addition table is a list of pairs: First int = workspace index in the EW being added,...
Definition: MergeRuns.h:98
Models a Container is used to hold a sample in the beam.
Definition: Container.h:24
Geometry::DetectorInfo is an intermediate step towards a DetectorInfo that is part of Instrument-2....
Definition: DetectorInfo.h:49
std::shared_ptr< Workspace > Workspace_sptr
shared pointer to Mantid::API::Workspace
Definition: Workspace_fwd.h:20
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
static const std::string FAIL_MERGE_TOLERANCES
Definition: MergeRuns.h:59
static const std::string WARN_MERGE_TOLERANCES
Definition: MergeRuns.h:57
static const std::string WARN_MERGE
Definition: MergeRuns.h:56
static const std::string FAIL_MERGE
Definition: MergeRuns.h:58
static const std::string SUM_MERGE
MergeRuns parameter names of the paramter file for sample log merging.
Definition: MergeRuns.h:53
static const std::string TIME_SERIES_MERGE
Definition: MergeRuns.h:54
static const std::string LIST_MERGE
Definition: MergeRuns.h:55
Helper class which provides the Collimation Length for SANS instruments.