35 std::make_shared<InstrumentValidator>()),
36 "Name of the input workspace to generate log correct from.");
39 "Name of the output workspace containing the corrections.");
42 "Name of the output time correction file.");
54 if (outwsname == dataWS->getName()) {
56 errmsg <<
"It is not allowed to use the same name by both input matrix "
57 "workspace and output table workspace.";
59 throw runtime_error(errmsg.str());
62 const auto &detectorInfo = dataWS->detectorInfo();
76 if (!filename.empty()) {
87 <<
"Source position = " << detectorInfo.
sourcePosition() <<
", L1 = " << detectorInfo.
l1() <<
"; "
88 <<
"Number of detector/pixels = " << detectorInfo.
size() <<
".\n";
98 std::vector<double> corrections(detectorInfo.
size());
99 const double l1 = detectorInfo.
l1();
112 const std::vector<double> &corrections)
const {
113 auto tablews = std::make_shared<TableWorkspace>();
115 tablews->addColumn(
"int",
"DetectorID");
116 tablews->addColumn(
"double",
"Correction");
117 tablews->addColumn(
"double",
"L2");
119 const auto &detectorIds = detectorInfo.
detectorIDs();
128 TableRow newrow = tablews->appendRow();
129 newrow << detid << correction <<
l2;
139 const std::vector<double> &corrections)
const {
141 ofile.open(filename.c_str());
143 if (ofile.is_open()) {
145 const auto &detectorIds = detectorInfo.
detectorIDs();
154 g_log.
error() <<
"Unable to open file " << filename <<
" to write!\n";
#define DECLARE_ALGORITHM(classname)
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.
@ OptionalSave
to specify a file to write to but an empty string is
TableRow represents a row in a TableWorkspace.
A property class for workspaces.
CreateLogTimeCorrection : Create correction file and workspace to correct event time against recorded...
DataObjects::TableWorkspace_sptr generateCorrectionTable(const Geometry::DetectorInfo &detectorInfo, const std::vector< double > &corrections) const
Write L2 map and correction map to a TableWorkspace.
std::vector< double > calculateCorrections(const Geometry::DetectorInfo &detectorInfo) const
Calculate the log time correction for each pixel, i.e., correcton from event time at detector to time...
void writeCorrectionToFile(const std::string &filename, const Geometry::DetectorInfo &detectorInfo, const std::vector< double > &corrections) const
Write correction map to a text file.
void logGeometryInformation(const Geometry::DetectorInfo &detectorInfo) const
Log geometry information.
void exec() override
Implement abstract Algorithm methods.
Geometry::DetectorInfo is an intermediate step towards a DetectorInfo that is part of Instrument-2....
double l2(const size_t index) const
Returns L2 (distance from sample to spectrum).
Kernel::V3D samplePosition() const
Returns the sample position.
const std::vector< detid_t > & detectorIDs() const
Returns a sorted vector of all detector IDs.
double l1() const
Returns L1 (distance from source to sample).
Kernel::V3D sourcePosition() const
Returns the source position.
size_t size() const
Returns the size of the DetectorInfo, i.e., the number of detectors in the instrument.
bool isMonitor(const size_t index) const
Returns true if the detector is a monitor.
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.
void information(const std::string &msg)
Logs at information level.
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
std::shared_ptr< TableWorkspace > TableWorkspace_sptr
shared pointer to Mantid::DataObjects::TableWorkspace
Helper class which provides the Collimation Length for SANS instruments.
int32_t detid_t
Typedef for a detector ID.
@ Input
An input workspace.
@ Output
An output workspace.