80 auto mustBePositive = std::make_shared<BoundedValidator<double>>();
81 auto mustBePositiveInt = std::make_shared<BoundedValidator<int>>();
82 mustBePositive->setLower(0);
83 mustBePositiveInt->setLower(0);
86 std::vector<std::string> errorTypes = {ZERO, SQRT, SQRT_OR_ONE, ONE_IF_ZERO, CUSTOM};
87 declareProperty(
"SetError", ZERO, std::make_shared<StringListValidator>(errorTypes),
88 "How to reset the uncertainties");
89 declareProperty(
"SetErrorTo", 1.000, mustBePositive,
"The error value to set when using custom mode");
93 "Which error values in the input workspace should be "
94 "replaced when using custom mode");
98 "How many decimal places of ``IfEqualTo`` are taken into "
99 "account for matching when using custom mode");
105 auto inputEventWorkspace = std::dynamic_pointer_cast<const DataObjects::EventWorkspace>(inputWorkspace);
108 bool zeroError = (errorType == ZERO);
109 bool takeSqrt = ((errorType == SQRT) || (errorType == SQRT_OR_ONE));
110 bool resetOne = ((errorType == ONE_IF_ZERO) || (errorType == SQRT_OR_ONE));
111 bool customError = (errorType == CUSTOM);
116 double tolerance = resetOne ? 1E-10 : std::pow(10.0, -1. * precision);
121 const int64_t numHists =
static_cast<int64_t
>(inputWorkspace->getNumberHistograms());
122 if (inputEventWorkspace) {
123 if (inputWorkspace == outputWorkspace && errorType == SQRT &&
131 for (int64_t i = 0; i < numHists; ++i) {
134 outputWorkspace->setSharedX(i, inputWorkspace->sharedX(i));
135 outputWorkspace->setSharedY(i, inputWorkspace->sharedY(i));
136 outputWorkspace->setSharedE(i, inputWorkspace->sharedE(i));
140 }
else if (inputWorkspace != outputWorkspace) {
141 outputWorkspace = inputWorkspace->clone();
144 const auto &spectrumInfo = inputWorkspace->spectrumInfo();
145 Progress prog(
this, 0.0, 1.0, numHists);
147 for (int64_t i = 0; i < numHists; ++i) {
150 if (errorType == ONE_IF_ZERO || customError) {
152 outputWorkspace->mutableE(i) = 0.0;
155 if ((!zeroError) && (!(spectrumInfo.hasDetectors(i) && spectrumInfo.isMasked(i)))) {
156 auto &E = outputWorkspace->mutableE(i);
158 const auto &
Y = outputWorkspace->y(i);
159 std::transform(
Y.begin(),
Y.end(), E.begin(), SqrtError(resetOne ? 1. : 0.));