35 return "Combine a per-pixel calibration with a grouped spectrum calibration";
44 "OffsetsWorkspace generated from cross-correlation. This is the source of DIFCpixel.");
47 "DiffCal table generated from calibrating grouped spectra. This is the source of DIFCgroup.");
50 "Workspace where conversion from d-spacing to time-of-flight for each spectrum is determined from. This is the "
51 "source of DIFCarb.");
54 "DiffCal table generated from calibrating grouped spectra");
57 "MaskedWorkspace for PixelCalibration");
63 alg->setLoggingOffset(1);
64 alg->setProperty(
"InputWorkspace", table);
65 alg->setProperty(
"OutputWorkspace", table);
66 alg->setProperty(
"Columns",
"detid");
67 alg->executeAsChildAlg();
69 return alg->getProperty(
"OutputWorkspace");
72bool findColumn(
const std::vector<std::string> &columnNames,
const std::string &name) {
73 return std::find(columnNames.begin(), columnNames.end(), name) != columnNames.end();
77 const std::vector<std::string> columnNames = ws->getColumnNames();
79 std::stringstream
error;
93 std::map<std::string, std::string> results;
99 if (!groupedResult.empty())
100 results[
"GroupedCalibration"] =
"The GroupedCalibration Workspace is missing [ " + groupedResult +
"]";
103 if (!pixelResult.empty())
104 results[
"PixelCalibration"] =
"The PixelCalibration Workspace is missing [ " + pixelResult +
"]";
111 size_t end = ws->rowCount() - 1;
112 while (end >= start) {
113 size_t currentPosition = start + ((end - start) / 2);
116 if (currentRow.
Int(0) > detid) {
117 end = currentPosition - 1;
118 }
else if (currentRow.
Int(0) < detid) {
119 start = currentPosition + 1;
121 return std::make_shared<Mantid::API::TableRow>(currentRow);
156 outputWorkspace->addColumn(
"int",
"detid");
157 outputWorkspace->addColumn(
"double",
"difc");
158 outputWorkspace->addColumn(
"double",
"difa");
159 outputWorkspace->addColumn(
"double",
"tzero");
163 int detid = groupedCalibrationRow.
Int(0);
164 bool prevDifValsExist =
false;
166 if (!(maskWorkspace && maskWorkspace->isMasked(detid))) {
167 std::shared_ptr<Mantid::API::TableRow> pixelCalibrationRow =
binarySearchForRow(pixelCalibrationWS, detid);
168 if (pixelCalibrationRow) {
169 double difcPD = groupedCalibrationRow.
Double(1);
170 double difcArb = calibrationWS->spectrumInfo().diffractometerConstants(
172 double difcPrev = pixelCalibrationRow->Double(1);
173 double difaPrev = pixelCalibrationRow->Double(2);
175 double difcNew = (difcPD / difcArb) * difcPrev;
176 double difaNew = ((difcPD / difcArb) * (difcPD / difcArb)) * difaPrev;
178 double tzeroNew = pixelCalibrationRow->Double(3);
181 newRow << detid << difcNew << difaNew << tzeroNew;
182 prevDifValsExist =
true;
186 if (!prevDifValsExist) {
190 }
while (groupedCalibrationRow.
next());
#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.
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.
TableRow represents a row in a TableWorkspace.
bool next()
Steps to the next row in the TableWorkspace if there is one.
double & Double(size_t col)
Returns a reference to the element in position col if its type is double.
int & Int(size_t col)
Returns a reference to the element in position col if its type is int.
A property class for workspaces.
CombineDiffCal : Calibrate groups of pixels after cross correlation so that diffraction peaks can be ...
API::ITableWorkspace_sptr sortTableWorkspace(DataObjects::TableWorkspace_sptr &table)
sort the calibration table according increasing values in column "detid"
void exec() override
Execute the algorithm.
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
Method checking errors on ALL the inputs, before execution.
const std::string summary() const override
Algorithm's summary for use in the GUI and help.
void init() override
Initialize the algorithm's properties.
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
std::shared_ptr< ITableWorkspace > ITableWorkspace_sptr
shared pointer to Mantid::API::ITableWorkspace
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
bool findColumn(const std::vector< std::string > &columnNames, const std::string &name)
std::string generateErrorString(const DataObjects::TableWorkspace_sptr &ws)
void addRowFromGroupedCalibration(const DataObjects::TableWorkspace_sptr &ws, Mantid::API::TableRow row)
std::shared_ptr< Mantid::API::TableRow > binarySearchForRow(const API::ITableWorkspace_sptr &ws, int detid)
std::shared_ptr< TableWorkspace > TableWorkspace_sptr
shared pointer to Mantid::DataObjects::TableWorkspace
std::shared_ptr< MaskWorkspace > MaskWorkspace_sptr
shared pointer to the MaskWorkspace class
Describes the direction (within an algorithm) of a Property.
@ Input
An input workspace.
@ Output
An output workspace.