35 auto ws_valid = std::make_shared<CompositeValidator>();
43 "An input Matrix Workspace (2DMatrix or Event workspace) ");
49 Q_modes.assign(1,
"ERROR IN LOADING Q-converters");
52 declareProperty(
"QDimensions", Q_modes[0], std::make_shared<StringListValidator>(Q_modes),
53 "String, describing available analysis modes, registered "
54 "with MD Transformation factory."
55 "There are 3 modes currently available and described in "
56 "details on *MD Transformation factory* page."
57 "The modes names are **CopyToMD**, **|Q|** and **Q3D**",
62 std::make_shared<StringListValidator>(dE_modes),
63 "You can analyze neutron energy transfer in **Direct**, "
64 "**Indirect** or **Elastic** mode."
65 "The analysis mode has to correspond to experimental set up. "
66 "Selecting inelastic mode increases"
67 "the number of the target workspace dimensions by one. See "
68 "*MD Transformation factory* for further details.",
74 "Selects Q-dimensions of the output workspace in **Q3D** case. "
75 " **AutoSelect**: Choose the target coordinate frame as the function of "
76 "goniometer and UB matrix values set on the input workspace."
77 " **Q (lab frame)**: Wave-vector converted into the lab frame."
78 " **Q (sample frame)**: Wave-vector converted into the frame of the "
79 "sample (taking out the goniometer rotation)."
80 " **HKL**: Use the sample's UB matrix to convert Wave-vector to "
81 "crystal's HKL indices."
82 "See *MD Transformation factory* **(Q3D)** for more details about "
85 std::vector<std::string> QScales = QSclAndFrames.
getQScalings();
87 "This property to normalize three momentums obtained in **Q3D** mode."
88 " See *MD Transformation factory* "
89 "for description and available scaling modes. The value can be modified "
90 "depending on the target coordinate "
91 "system, defined by the property **OutputDimensions**. ");
95 std::make_unique<Kernel::VisibleWhenProperty>(
"QDimensions",
IS_EQUAL_TO,
"Q3D"));
98 "List(comma separated) of additional to **Q** and **DeltaE** variables "
99 "which form additional "
100 "(orthogonal) to **Q** dimensions in the target workspace (e.g. "
101 "Temperature or Magnetic field). "
102 "These variables had to be logged during experiment and the names of "
103 "these variables have to coincide "
104 "with the log names for the records of these variables in the source "
111 "The name of the table workspace where the part of the detectors "
112 "transformation into reciprocal space, "
113 "calculated by :ref:`algm-PreprocessDetectorsToMD` algorithm is stored. "
114 "If the workspace is not found in analysis "
115 "data service, :ref:`algm-PreprocessDetectorsToMD` used to calculate it. "
116 "If found, the algorithm uses existing "
117 "workspace. The field is useful if one expects to analyze number of "
118 "different experiments obtained on "
119 "the same instrument."
120 ".. warning:: Dangerous if one uses number of workspaces with modified "
121 "derived instrument one after another."
122 " *In this case this property has to be set to* **\"-\"** *sting (minus "
123 "without quotes) or empty (possible from script only) "
124 "to force the workspace recalculation each time the algorithm is "
129 "if PreprocessDetectorWS is used to build the workspace with "
130 "preprocessed detectors at first algorithm call,"
131 "and the input workspaces instruments are different by just different "
132 "masked detectors, setting this "
133 "option to true forces :ref:`algm-PreprocessDetectorsToMD` update only "
134 "the detectors masks for all subsequent "
135 "calls to this algorithm."
136 ".. warning:: *This is temporary solution necessary until Mantid masks "
137 "spectra by 0 rather then by NaN.*");
141 "Correct the weights of events or signals and errors transformed into "
142 "reciprocal space by multiplying them "
143 "by the Lorentz multiplier:\n :math:`sin(\\theta)^2/\\lambda^4`. "
144 "Currently works in Q3D Elastic case only "
145 "and is ignored in any other case.");
147 "Enabling this property forces the algorithm to ignore bins with zero "
148 "signal for an input matrix workspace. Input event workspaces are not "
150 "This violates the data normalization but may substantially accelerate "
151 "calculations in situations when the normalization is not important "
152 "(e.g. peak finding).");
157 "Defines the first projection vector of the target Q "
158 "coordinate system in **Q3D** mode - Default (1,0,0)");
163 "Defines the second projection vector of the target Q "
164 "coordinate system in **Q3D** mode - Default (0,1,0).");
169 "Defines the third projection vector of the target Q "
170 "coordinate system in **Q3D** mode. - Default (0,0,1)");
173 "Do not add events to MD workspace that are closer to the origin "
174 "in QSample radius than this value. Needed for 3D"
175 "views to remove noise. ");
192 const std::string &dEModeRequested,
bool updateMasks,
193 const std::string &OutWSName) {
199 bool storeInDataService(
true);
200 std::string tOutWSName(OutWSName);
201 if (tOutWSName ==
"-" || tOutWSName.empty())
203 storeInDataService =
false;
204 tOutWSName =
"ServiceTableWS";
206 storeInDataService =
true;
213 size_t nHist = InWS2D->getNumberHistograms();
214 size_t nDetMap = TargTableWS->
rowCount();
215 if (nHist == nDetMap) {
218 std::string currentWSInstrumentName = InWS2D->getInstrument()->getName();
219 std::string oldInstrName = TargTableWS->getLogs()->getPropertyValueAsType<std::string>(
"InstrumentName");
221 if (oldInstrName == currentWSInstrumentName) {
226 bool hasEi = InWS2D->run().hasProperty(
"Ei");
227 bool hasEfix = InWS2D->run().hasProperty(
"eFixed");
228 if (hasEi || hasEfix) {
232 Ei = InWS2D->run().getPropertyValueAsType<
double>(
"Ei");
234 Ei = InWS2D->run().getPropertyValueAsType<
double>(
"eFixed");
236 TargTableWS->logs()->addProperty<
double>(
"Ei", Ei,
true);
240 throw(std::invalid_argument(
"Input neutron's energy has to be present at the workspace as "
241 "Ei or eFixed number log in Direct inelastic mode"));
267 if (storeInDataService)
276 auto m_Ei = TargTableWS->getLogs()->getPropertyValueAsType<
double>(
"Ei");
280 throw(std::invalid_argument(
"Input neutron's energy has to be defined in inelastic mode "));
283 auto *eFixed = TargTableWS->getColDataArray<
float>(
"eFixed");
285 throw(std::invalid_argument(
"Input neutron's energy has to be defined in inelastic mode "));
287 auto NDetectors = TargTableWS->getLogs()->getPropertyValueAsType<uint32_t>(
"ActualDetectorsNum");
288 for (uint32_t i = 0; i < NDetectors; i++)
289 if (
isNaN(*(eFixed + i)))
290 throw(std::invalid_argument(
"Undefined eFixed energy for detector N: " +
std::to_string(i)));
305 throw(std::runtime_error(
"Can not create child ChildAlgorithm to preprocess detectors"));
310 throw std::runtime_error(
"Bad program logic: an algorithm workspace "
311 "property is not castable to a matrix workspace");
319 *pTargWSProp = std::const_pointer_cast<MatrixWorkspace>(InWS2D);
321 childAlg->setProperty(
"OutputWorkspace", OutWSName);
322 childAlg->setProperty(
"GetMaskState",
true);
323 childAlg->setProperty(
"UpdateMasksInfo",
true);
324 childAlg->setProperty(
"OutputWorkspace", OutWSName);
330 childAlg->setProperty(
"GetEFixed",
true);
333 if (!childAlg->isExecuted())
334 throw(std::runtime_error(
"Can not properly execute child algorithm PreprocessDetectorsToMD"));
336 TargTableWS = childAlg->getProperty(
"OutputWorkspace");
338 throw(std::runtime_error(
"Can not retrieve results of child algorithm PreprocessDetectorsToMD"));
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
Kernel::Property * getPointerToProperty(const std::string &name) const override
Get a property by name.
virtual std::shared_ptr< Algorithm > createChildAlgorithm(const std::string &name, const double startProgress=-1., const double endProgress=-1., const bool enableLogging=true, const int &version=-1)
Create a Child Algorithm.
A validator which checks that a workspace has a valid instrument.
A property class for workspaces.
A validator which checks that the unit of the workspace referred to by a WorkspaceProperty is the exp...
TableWorkspace is an implementation of Workspace in which the data are organised in columns of same s...
size_t rowCount() const override
Number of rows in the workspace.
Support for a property that holds an array of values.
void setPropertySettings(const std::string &name, std::unique_ptr< IPropertySettings > settings)
The concrete, templated class for properties.
void setAutoTrim(const bool &setting)
Sets if the property is set to automatically trim string unput values of whitespace.
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
bool isNaN(T val)
Template to check if a variable equal to NaN.
DataObjects::TableWorkspace_sptr runPreprocessDetectorsToMDChildUpdatingMasks(const Mantid::API::MatrixWorkspace_const_sptr &InWS2D, const std::string &OutWSName, const std::string &dEModeRequested, Kernel::DeltaEMode::Type &Emode)
DataObjects::TableWorkspace_const_sptr preprocessDetectorsPositions(const Mantid::API::MatrixWorkspace_const_sptr &InWS2D, const std::string &dEModeRequested, bool updateMasks, const std::string &OutWSName)
The method responsible for analyzing input workspace parameters and preprocessing detectors positions...
const std::string category() const override
Algorithm's category for identification.
void init() override
Initialize the algorithm's properties.
std::shared_ptr< const MatrixWorkspace > MatrixWorkspace_const_sptr
shared pointer to the matrix workspace base class (const version)
std::shared_ptr< Algorithm > Algorithm_sptr
Typedef for a shared pointer to an Algorithm.
std::shared_ptr< TableWorkspace > TableWorkspace_sptr
shared pointer to Mantid::DataObjects::TableWorkspace
std::shared_ptr< const TableWorkspace > TableWorkspace_const_sptr
shared pointer to Mantid::DataObjects::TableWorkspace (const version)
std::string to_string(const wide_integer< Bits, Signed > &n)
static const std::vector< std::string > availableTypes()
Returns the string list of available modes.
static Type fromString(const std::string &modeStr)
Returns the emode from the given string.
Type
Define the available energy transfer modes It is important to assign enums proper numbers,...
@ InOut
Both an input & output workspace.
@ Input
An input workspace.