30constexpr double EMPTY_FLT() noexcept {
return std::numeric_limits<float>::max() / 2; }
39 "Input MDEventWorkspace. Either QSample (or QLab) frame plus DeltaE, or just Qmod plus DeltaE");
41 auto mustBePositive = std::make_shared<BoundedValidator<double>>();
42 mustBePositive->setLower(0.0);
43 mustBePositive->setLowerExclusive(
true);
46 "Depletion rate exponent");
49 "The output MDEventWorkspace with the correction applied");
55 std::map<std::string, std::string> output;
58 if (workspace_error !=
"")
59 output[
"InputWorkspace"] = workspace_error;
63 output[
"ExponentFactor"] =
"ExponentFactor should be positive";
73 if (dimensionError !=
"")
74 return dimensionError;
78 uint16_t nRuns(inputws->getNumExperimentInfo());
80 for (uint16_t i = 0; i < inputws->getNumExperimentInfo(); i++) {
81 const auto expInfo = inputws->getExperimentInfo(i);
84 }
catch (std::runtime_error &e) {
94 std::string errormsg(
"");
96 size_t numdims = inputws->getNumDims();
101 std::string qdimstr(
"Not Q3D or |Q|");
102 if (coordsys == SpecialCoordinateSystem::QLab || coordsys == SpecialCoordinateSystem::QSample) {
108 for (
size_t i = 0; i < numdims; ++i) {
109 if (inputws->getDimension(i)->getName() ==
"|Q|") {
118 bool qModCase = (qdim == 1) && (inputws->getDimension(1)->getName() ==
"DeltaE");
119 bool qVecCase = (qdim == 3) && (inputws->getDimension(3)->getName() ==
"DeltaE");
120 if (!qModCase && !qVecCase) {
121 g_log.
error() <<
"Coordinate system = " << coordsys <<
" does not meet requirement: \n";
122 for (
size_t i = 0; i < numdims; ++i) {
123 g_log.
error() << i <<
"-th dim: " << inputws->getDimension(i)->getName() <<
"\n";
125 errormsg +=
"Q Dimension (" + qdimstr +
126 ") is neither Q3D nor |Q|. Or DeltaE is found in an improper place (2nd or 4th dimension).";
134template <
typename MDE,
size_t nd>
137 float c =
static_cast<float>(cDouble);
142 std::vector<API::IMDNode *> boxes;
144 auto numBoxes = int(boxes.size());
149 for (
int i = 0; i < numBoxes; ++i) {
152 if (box && !box->getIsMasked()) {
153 std::vector<MDE> &events = box->
getEvents();
154 for (
auto it = events.begin(); it != events.end(); ++it) {
156 float Ef = Ei - it->getCenter(deltaEIndex);
157 float correction(exp(c * Ef));
159 it->setSignal(it->getSignal() * correction);
160 it->setErrorSquared(it->getErrorSquared() * correction * correction);
164 box->releaseEvents();
180 if (inputWs->getName() == outputWsName)
183 outputWs = inputWs->clone();
189 outputWs->refreshCache();
192 outputWs->clearMDMasking();
#define DECLARE_ALGORITHM(classname)
#define CALL_MDEVENT_FUNCTION(funcname, workspace)
Macro that makes it possible to call a templated method for a MDEventWorkspace using a IMDEventWorksp...
#define PARALLEL_START_INTERRUPT_REGION
Begins a block to skip processing is the algorithm has been interupted Note the end of the block if n...
#define PARALLEL_END_INTERRUPT_REGION
Ends a block to skip processing is the algorithm has been interupted Note the start of the block if n...
#define PRAGMA_OMP(expression)
#define PARALLEL_CHECK_INTERRUPT_REGION
Adds a check after a Parallel region to see if it was interupted.
std::string getPropertyValue(const std::string &name) const override
Get the value of a property as a string.
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
virtual void getBoxes(std::vector< IMDNode * > &boxes, size_t maxDepth, bool leafOnly)=0
Fill a vector with all the boxes who are the childred of this one up to a certain depth.
A property class for workspaces.
Templated super-class of a multi-dimensional event "box".
Templated class for a multi-dimensional event "box".
std::vector< MDE > & getEvents()
Get vector of events to change.
std::shared_ptr< MDEventWorkspace< MDE, nd > > sptr
Typedef for a shared pointer of this kind of event workspace.
MDBoxBase< MDE, nd > * getBox()
size_t getNumDims() const override
bool isFileBacked() const override
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
void error(const std::string &msg)
Logs at error level.
The concrete, templated class for properties.
std::map< std::string, std::string > validateInputs() override
Verify the input properties meets certain requirements.
std::string checkInputMDDimensions()
Verify the input Workspace dimensions are either QSample (or QLab) frame plus DeltaE,...
void correctForTransmission(typename MDEventWorkspace< MDE, nd >::sptr ws)
Apply the transmission correction to each event.
std::vector< float > mEfixedValues
Value of Efixed for each run.
void exec() override
Run the algorithm.
std::string checkInputWorkspace()
Verify the input workspace meets certain requirements.
std::shared_ptr< IMDEventWorkspace > IMDEventWorkspace_sptr
Shared pointer to Mantid::API::IMDEventWorkspace.
SpecialCoordinateSystem
Special coordinate systems for Q3D.
constexpr double EMPTY_FLT() noexcept
constexpr double EMPTY_DBL() noexcept
Returns what we consider an "empty" double within a property.
@ Input
An input workspace.
@ Output
An output workspace.