55 "An input MDEventWorkspace. Must be in Q_sample/Q_lab frame. Must have an axis as DeltaE");
58 "SampleLog variable name that contains the temperature or a number");
60 auto mustBePositive = std::make_shared<BoundedValidator<double>>();
61 mustBePositive->setLower(0.0);
62 mustBePositive->setLowerExclusive(
true);
65 "The temperature to which to rescale the intensity");
69 "The output MDEventWorkspace with detailed balance applied");
90 if (input_ws->getName() == output_ws_name) {
95 output_ws = input_ws->clone();
102 output_ws->refreshCache();
105 output_ws->clearMDMasking();
123 std::map<std::string, std::string> output;
130 if (dim_error !=
"") {
131 output[
"InputWorkspace"] = dim_error;
136 output[
"Temperature"] = kerror;
149 std::string errormsg(
"");
152 size_t numdims = inputws->getNumDims();
157 std::string qdimstr(
"Not Q3D or |Q|");
165 for (
size_t i = 0; i < numdims; ++i) {
166 if (inputws->getDimension(i)->getName() ==
"|Q|") {
175 if (qdim == 1 && inputws->getDimension(1)->getName() ==
"DeltaE") {
178 }
else if (qdim == 3 && inputws->getDimension(3)->getName() ==
"DeltaE") {
183 g_log.
error() <<
"Coordiate system = " << coordsys <<
" does not meet requirement: \n";
184 for (
size_t i = 0; i < numdims; ++i) {
185 g_log.
error() << i <<
"-th dim: " << inputws->getDimension(i)->getName() <<
"\n";
187 errormsg +=
"Q Dimension (" + qdimstr +
188 ") is neither Q3D nor |Q|. Or DeltaE is found in proper place (2nd or 4th dimension).";
198template <
typename MDE,
size_t nd>
202 std::vector<API::IMDNode *> boxes;
204 auto numBoxes = int(boxes.size());
210 for (
int i = 0; i < numBoxes; ++i) {
213 if (box && !box->getIsMasked()) {
215 std::vector<MDE> &events = box->
getEvents();
217 for (
auto it = events.begin(); it != events.end(); ++it) {
228 -
static_cast<float>(M_PI) * std::expm1f(-
static_cast<float>(it->getCenter(
mDeltaEIndex)) *
231 float de =
static_cast<float>(it->getCenter(
mDeltaEIndex));
232 if (std::fabs(de) < 1e-10) {
241 auto intensity = it->getSignal() * factor;
242 it->setSignal(intensity);
245 auto error2 = it->getErrorSquared() * factor * factor;
247 it->setErrorSquared(error2);
251 box->releaseEvents();
269 std::string temperature_error(
"");
274 temperature = boost::lexical_cast<float>(Tstring);
282 uint16_t numexpinfo = mdws->getNumExperimentInfo();
284 for (uint16_t i = 0; i < numexpinfo; ++i) {
285 if (temperature < 0) {
288 if (expinfo->run().hasProperty(Tstring)) {
292 std::stringstream errss;
293 errss <<
"ExperimentInfo" << i <<
" has " << Tstring <<
", which is not a valid double-valuesd log";
294 temperature_error += errss.str() +
"\n";
300 std::stringstream errss;
301 errss <<
"ExperimentInfo " << i <<
" does not have tempertaure log " << Tstring;
302 temperature_error += errss.str() +
"\n";
310 return temperature_error;
#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.
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
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.
bool isFileBacked() const override
MDBoxBase< MDE, nd > * getBox()
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.
A specialised Property class for holding a series of time-value pairs.
TimeSeriesPropertyStatistics getStatistics(const Kernel::TimeROI *roi=nullptr) const override
Return a TimeSeriesPropertyStatistics object.
ApplyDetailedBalance : Convert to chi'' of an MDEvent workspace.
std::string checkInputMDDimension()
Check input workspace dimension.
std::string getTemperature(const API::IMDEventWorkspace_sptr &mdws)
Get temperature.
const std::string summary() const override
Summary.
void applyDetailedBalance(typename Mantid::DataObjects::MDEventWorkspace< MDE, nd >::sptr ws)
Apply detailed balance to each MDEvent.
double mFinalTemperature
temperature to convert to
void init() override
Initialize the proeprties.
void exec() override
Run the algorithm.
std::map< uint16_t, double > mExpinfoTemperatureMean
map of temperature retrieved from sample logs
size_t mDeltaEIndex
index of the MD dimension index for DeltaE
const std::string category() const override
category
int version() const override
Algorithm's version for identification.
std::map< std::string, std::string > validateInputs() override
Validate inputs.
std::shared_ptr< IMDEventWorkspace > IMDEventWorkspace_sptr
Shared pointer to Mantid::API::IMDEventWorkspace.
std::shared_ptr< const ExperimentInfo > ExperimentInfo_const_sptr
Shared pointer to const ExperimentInfo.
SpecialCoordinateSystem
Special coordinate systems for Q3D.
static constexpr double meVtoKelvin
1 meV in Kelvin.
constexpr double EMPTY_DBL() noexcept
Returns what we consider an "empty" double within a property.
@ Input
An input workspace.
@ Output
An output workspace.