54 "An input MDEventWorkspace. Must be in Q_sample/Q_lab frame. Must have an axis as DeltaE");
57 "SampleLog variable name that contains the temperature or a number");
60 "The output MDEventWorkspace with detailed balance applied");
75 if (input_ws->getName() == output_ws_name) {
80 output_ws = input_ws->clone();
87 output_ws->refreshCache();
90 output_ws->clearMDMasking();
108 std::map<std::string, std::string> output;
115 if (dim_error !=
"") {
116 output[
"InputWorkspace"] = dim_error;
121 output[
"Temperature"] = kerror;
134 std::string errormsg(
"");
137 size_t numdims = inputws->getNumDims();
142 std::string qdimstr(
"Not Q3D or |Q|");
150 for (
size_t i = 0; i < numdims; ++i) {
151 if (inputws->getDimension(i)->getName() ==
"|Q|") {
160 if (qdim == 1 && inputws->getDimension(1)->getName() ==
"DeltaE") {
163 }
else if (qdim == 3 && inputws->getDimension(3)->getName() ==
"DeltaE") {
168 g_log.
error() <<
"Coordiate system = " << coordsys <<
" does not meet requirement: \n";
169 for (
size_t i = 0; i < numdims; ++i) {
170 g_log.
error() << i <<
"-th dim: " << inputws->getDimension(i)->getName() <<
"\n";
172 errormsg +=
"Q Dimension (" + qdimstr +
173 ") is neither Q3D nor |Q|. Or DeltaE is found in proper place (2nd or 4th dimension).";
183template <
typename MDE,
size_t nd>
187 std::vector<API::IMDNode *> boxes;
189 auto numBoxes = int(boxes.size());
195 for (
int i = 0; i < numBoxes; ++i) {
198 if (box && !box->getIsMasked()) {
200 std::vector<MDE> &events = box->
getEvents();
202 for (
auto it = events.begin(); it != events.end(); ++it) {
209 float factor =
static_cast<float>(M_PI) *
210 (
static_cast<float>(1.) - exp(-it->getCenter(
mDeltaEIndex) *
214 auto intensity = it->getSignal() * factor;
215 it->setSignal(intensity);
218 auto error2 = it->getErrorSquared() * factor * factor;
220 it->setErrorSquared(error2);
224 box->releaseEvents();
242 std::string temperature_error(
"");
247 temperature = boost::lexical_cast<float>(Tstring);
255 uint16_t numexpinfo = mdws->getNumExperimentInfo();
257 for (uint16_t i = 0; i < numexpinfo; ++i) {
258 if (temperature < 0) {
261 if (expinfo->run().hasProperty(Tstring)) {
265 std::stringstream errss;
266 errss <<
"ExperimentInfo" << i <<
" has " << Tstring <<
", which is not a valid double-valuesd log";
267 temperature_error += errss.str() +
"\n";
273 std::stringstream errss;
274 errss <<
"ExperimentInfo " << i <<
" does not have tempertaure log " << Tstring;
275 temperature_error += errss.str() +
"\n";
283 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.
MDBoxBase< MDE, nd > * getBox()
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.
A specialised Property class for holding a series of time-value pairs.
ApplyDetailedBalance : Perform the And boolean operation on two MDHistoWorkspaces.
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.
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.
@ Input
An input workspace.
@ Output
An output workspace.