32 "Workspace with detectors in the positions to be put into the detector "
35 std::initializer_list<std::string> exts = {
".dat",
".txt"};
37 declareProperty(std::make_unique<FileProperty>(
"InputFilename",
"",
FileProperty::Load, exts),
38 "Path to a detector dot dat file. Must be of type .dat or .txt");
40 declareProperty(std::make_unique<FileProperty>(
"OutputFilename",
"",
FileProperty::Save, exts),
41 "Path to the modified detector dot dat file. Must be of type .dat or "
58 throw std::runtime_error(
"No instrument in the Workspace. Cannot modify detector dot dat file");
62 in.open(inputFilename.c_str());
67 out.open(outputFilename.c_str());
76 out << str <<
" and modified by MANTID algorithm ModifyDetectorDotDatFile \n";
81 std::istringstream header2(str);
90 if (
detectorCount < 1 || numColumns < 5 || numColumns > 1000) {
93 throw Exception::FileError(
"Incompatible file format found when reading line 2 in the input file", inputFilename);
108 const auto &detectorInfo = ws->detectorInfo();
112 while (getline(in, str)) {
114 std::istringstream istr(str);
121 if (str.empty() || str[0] ==
'#') {
128 istr >> detID >> offset >> dump >> code >> dump;
135 V3D pos = detectorInfo.position(detectorInfo.indexOf(detID));
140 std::streampos width = istr.tellg();
142 std::ostringstream oss;
143 oss << std::fixed << std::right;
144 oss.precision(pOffset);
145 oss << std::setw(wDet) << detID << std::setw(wOff) << offset;
146 oss.precision(pOther);
147 oss << std::setw(wRad) <<
l2 << std::setw(wCode) << code << std::setw(wAng) << theta << std::setw(wAng);
150 std::string prefix = oss.str();
151 std::string suffix = str.substr(width, std::string::npos);
152 out << prefix << suffix <<
"\n";
153 }
catch (std::out_of_range &) {
#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.
@ Save
to specify a file to write to, the file may or may not exist
@ Load
allowed here which will be passed to the algorithm
A property class for workspaces.
Modifies an ISIS detector dot data file, so that the detector positions are as in the given workspace...
void exec() override
Run the algorithm.
Records the filename and the description of failure.
void getSpherical(double &R, double &theta, double &phi) const noexcept
Return the vector's position in spherical coordinates.
std::shared_ptr< Workspace > Workspace_sptr
shared pointer to Mantid::API::Workspace
std::shared_ptr< ExperimentInfo > ExperimentInfo_sptr
Shared pointer to ExperimentInfo.
std::shared_ptr< const Instrument > Instrument_const_sptr
Shared pointer to an const instrument object.
int32_t detid_t
Typedef for a detector ID.
@ Input
An input workspace.