13#include "MantidAlgorithms/DllConfig.h"
17#include <unsupported/Eigen/AutoDiff>
20namespace PolarizationCorrectionsHelpers {
22 const std::string &spinStateOrder,
23 const std::string &targetSpinState);
26namespace FlipperConfigurations {
27static const std::string
OFF_ON =
"01";
28static const std::string
ON_OFF =
"10";
30static const std::string
ON_ON =
"11";
31static const std::string
OFF =
"0";
32static const std::string
ON =
"1";
35namespace SpinStateConfigurationsFredrikze {
40static const std::string
PARA =
"p";
41static const std::string
ANTI =
"a";
44namespace SpinStateConfigurationsWildes {
49static const std::string
MINUS =
"-";
50static const std::string
PLUS =
"+";
53namespace SpinStatesORSO {
57static const std::string
PP =
"pp";
58static const std::string
PM =
"pm";
59static const std::string
MP =
"mp";
60static const std::string
MM =
"mm";
61static const std::string
PO =
"po";
62static const std::string
MO =
"mo";
64static const std::string
LOG_NAME =
"spin_state_ORSO";
68 const std::string &spinState);
75 using DerType = Eigen::Matrix<double, N, 1>;
77 using ADScalar = Eigen::AutoDiffScalar<DerType>;
95 std::array<ADScalar, N>
x;
96 for (
size_t i = 0; i < N; ++i) {
97 x[i] =
ADScalar(values[i], DerType::Unit(N, i));
100 const auto &derivatives =
y.derivatives();
101 return {
y.value(), std::sqrt((derivatives.array().square() * errors.array().square()).sum()), derivatives};
104 template <std::same_as<API::MatrixWorkspace_sptr>... Ts>
109 template <std::same_as<API::MatrixWorkspace_sptr>... Ts>
117 template <std::same_as<API::MatrixWorkspace_sptr>... Ts>
119 const auto firstWs = std::get<0>(std::forward_as_tuple(args...));
122 if (outWs->id() ==
"EventWorkspace") {
126 const size_t numSpec = outWs->getNumberHistograms();
127 const size_t specSize = outWs->blocksize();
132 const bool specOverBins = numSpec > specSize;
135 for (int64_t i = 0; i < static_cast<int64_t>(numSpec); i++) {
136 auto &yOut = outWs->mutableY(i);
137 auto &eOut = outWs->mutableE(i);
140 for (int64_t j = 0; j < static_cast<int64_t>(specSize); ++j) {
142 yOut[j] = result.
value;
143 eOut[j] = result.error;
147 if (outputWorkspaceDistribution.has_value()) {
148 outWs->setDistribution(outputWorkspaceDistribution.value());
154 const std::string &algName)
const {
155 auto conversionAlg = API::AlgorithmManager::Instance().create(algName);
156 conversionAlg->initialize();
157 conversionAlg->setChild(
true);
158 conversionAlg->setProperty(
"InputWorkspace",
workspace);
159 conversionAlg->setProperty(
"OutputWorkspace",
workspace->getName());
160 conversionAlg->execute();
161 return conversionAlg->getProperty(
"OutputWorkspace");
IPeaksWorkspace_sptr workspace
#define PARALLEL_FOR_IF(condition)
Empty definitions - to enable set your complier to enable openMP.
AutoDevResult evaluate(const InputArray &values, const InputArray &errors) const
API::MatrixWorkspace_sptr runWorkspaceConversionAlg(const API::MatrixWorkspace_sptr &workspace, const std::string &algName) const
API::MatrixWorkspace_sptr evaluateWorkspaces(Ts... args) const
API::MatrixWorkspace_sptr evaluateWorkspacesImpl(std::optional< bool > outputWorkspaceDistribution, Ts... args) const
Types::InputArray InputArray
ErrorTypeHelper< N > Types
API::MatrixWorkspace_sptr evaluateWorkspaces(const bool outputWorkspaceDistribution, Ts... args) const
ErrorPropagation(Func func)
API::MatrixWorkspace_sptr convertToWorkspace2D(const API::MatrixWorkspace_sptr &workspace) const
Eigen::Matrix< double, N, 1 > DerType
Eigen::AutoDiffScalar< DerType > ADScalar
std::shared_ptr< WorkspaceGroup > WorkspaceGroup_sptr
shared pointer to Mantid::API::WorkspaceGroup
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
auto makeErrorPropagation(Func &&func)
static const std::string ON_OFF
static const std::string OFF_ON
static const std::string OFF_OFF
static const std::string ON_ON
static const std::string OFF
static const std::string ON
MANTID_ALGORITHMS_DLL API::MatrixWorkspace_sptr workspaceForSpinState(const API::WorkspaceGroup_sptr &group, const std::string &spinStateOrder, const std::string &targetSpinState)
Returns the workspace in the group associated with the given targetSpinState according to the order d...
static const std::string PARA_PARA
static const std::string ANTI
static const std::string PARA_ANTI
static const std::string ANTI_ANTI
static const std::string PARA
static const std::string ANTI_PARA
static const std::string MINUS_MINUS
static const std::string PLUS_MINUS
static const std::string PLUS_PLUS
static const std::string MINUS_PLUS
static const std::string PLUS
static const std::string MINUS
static const std::string LOG_NAME
static const std::string MO
static const std::string PO
static const std::string PM
MANTID_ALGORITHMS_DLL void addORSOLogForSpinState(const Mantid::API::MatrixWorkspace_sptr &ws, const std::string &spinState)
static const std::string MM
MANTID_ALGORITHMS_DLL const std::string & getORSONotationForSpinState(const std::string &spinState)
static const std::string PP
static const std::string MP
std::enable_if< std::is_pointer< Arg >::value, bool >::type threadSafe(Arg workspace)
Thread-safety check Checks the workspace to ensure it is suitable for multithreaded access.
Eigen::Array< double, N, 1 > derivatives