17void calculateFromOffset(API::Progress &progress, DataObjects::SpecialWorkspace2D &outputWs,
18 const DataObjects::OffsetsWorkspace *
const offsetsWS,
19 const Geometry::DetectorInfo &detectorInfo) {
20 const auto &detectorIDs = detectorInfo.detectorIDs();
21 const bool haveOffset = (offsetsWS !=
nullptr);
22 const double l1 = detectorInfo.l1();
24 for (
size_t i = 0; i < detectorInfo.size(); ++i) {
25 if ((!detectorInfo.isMasked(i)) && (!detectorInfo.isMonitor(i))) {
27 const double offset = (haveOffset) ? offsetsWS->getValue(detectorIDs[i], 0.) : 0.;
32 outputWs.setValue(detectorIDs[i],
difc);
35 progress.report(
"Calculate DIFC");
41void calculateFromTable(API::Progress &progress, DataObjects::SpecialWorkspace2D &outputWs,
42 const API::ITableWorkspace &calibWs) {
43 API::ConstColumnVector<double> difcCol = calibWs.getVector(
"difc");
44 API::ConstColumnVector<int> detIDs = calibWs.getVector(
"detid");
46 const size_t numRows = detIDs.size();
47 for (
size_t i = 0; i < numRows; ++i) {
48 outputWs.setValue(detIDs[i], difcCol[i]);
49 progress.report(
"Calculate DIFC");
87 "Name of the workspace to have DIFC calculated from");
89 "Workspace containing DIFC for each pixel");
92 "Optional: A TableWorkspace containing the DIFC values, "
93 "which will be copied. This property cannot be set in "
94 "conjunction with property OffsetsWorkspace.");
97 "Optional: A OffsetsWorkspace containing the calibration "
98 "offsets. This property cannot be set in conjunction with "
99 "property CalibrationWorkspace.");
103 std::map<std::string, std::string> result;
108 if ((
bool(offsetsWS)) && (
bool(calibrationWS))) {
109 std::string msg =
"Only specify calibration one way";
110 result[
"OffsetsWorkspace"] = msg;
111 result[
"CalibrationWorkspace"] = msg;
127 if ((!
bool(inputWs == outputWs)) ||
130 (!
bool(std::dynamic_pointer_cast<SpecialWorkspace2D>(outputWs)))) {
132 std::dynamic_pointer_cast<MatrixWorkspace>(std::make_shared<SpecialWorkspace2D>(inputWs->getInstrument()));
133 outputWs->setTitle(
"DIFC workspace");
138 std::dynamic_pointer_cast<DataObjects::SpecialWorkspace2D>(outputWs);
142 calculateFromTable(
progress, *outputSpecialWs, *calibWs);
146 const auto &detectorInfo = inputWs->detectorInfo();
147 calculateFromOffset(
progress, *outputSpecialWs, offsetsWs.get(), detectorInfo);
#define DECLARE_ALGORITHM(classname)
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
void progress(double p, const std::string &msg="", double estimatedTime=0.0, int progressPrecision=0)
Sends ProgressNotification.
Base MatrixWorkspace Abstract Class.
Helper class for reporting progress from algorithms.
A property class for workspaces.
CalculateDIFC : Calculate the DIFC for every pixel.
const std::string summary() const override
Algorithm's summary for use in the GUI and help.
const std::string category() const override
Algorithm's category for identification.
int version() const override
Algorithm's version for identification.
std::map< std::string, std::string > validateInputs() override
Cross-check properties with each other.
void init() override
Initialize the algorithm's properties.
void exec() override
Execute the algorithm.
An OffsetsWorkspace is a specialized Workspace2D where the Y value at each pixel is the offset to be ...
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
std::shared_ptr< const ITableWorkspace > ITableWorkspace_const_sptr
shared pointer to Mantid::API::ITableWorkspace (const version)
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
std::shared_ptr< const OffsetsWorkspace > OffsetsWorkspace_const_sptr
shared pointer to a const OffsetsWorkspace
std::shared_ptr< SpecialWorkspace2D > SpecialWorkspace2D_sptr
shared pointer to the SpecialWorkspace2D class
MANTID_GEOMETRY_DLL double tofToDSpacingFactor(const double l1, const double l2, const double twoTheta, const double offset)
Calculate and return conversion factor from tof to d-spacing.
std::shared_ptr< const Instrument > Instrument_const_sptr
Shared pointer to an const instrument object.
Helper class which provides the Collimation Length for SANS instruments.
Describes the direction (within an algorithm) of a Property.
@ Input
An input workspace.
@ Output
An output workspace.