18using Mantid::Types::Core::DateAndTime;
31 "Optional: An GroupingWorkspace workspace giving the grouping info.");
35 "Optional: An OffsetsWorkspace workspace giving the detector calibration "
40 "Optional: An Workspace workspace giving which detectors are masked.");
42 declareProperty(std::make_unique<FileProperty>(
"Filename",
"",
FileProperty::Save,
".cal"),
43 "Path to the .cal file that will be created.");
45 auto offsetprecision = std::make_shared<BoundedValidator<int>>();
46 offsetprecision->setLower(7);
47 offsetprecision->setUpper(11);
48 declareProperty(
"OffsetPrecision", 7, offsetprecision,
"Precision of offsets (between 7 and 11 decimal).");
83 inst = groupWS->getInstrument();
86 bool doOffsets =
false;
89 inst = offsetsWS->getInstrument();
95 inst = maskWS->getInstrument();
97 g_log.
warning() <<
"Mask workspace " << maskWS->getName() <<
" has no instrument associated with."
101 g_log.
information() <<
"Status: doGroup = " << doGroup <<
" doOffsets = " << doOffsets <<
" doMask = " << doMask
105 throw std::invalid_argument(
"You must give at least one of the grouping, "
106 "offsets or masking workspaces.");
109 std::ofstream fout(calFileName.c_str());
110 fout <<
"# Calibration file for instrument " << inst->getName() <<
" written on "
111 << DateAndTime::getCurrentTime().toISO8601String() <<
".\n";
112 fout <<
"# Format: number UDET offset select group\n";
116 inst->getDetectors(allDetectors);
119 detid2det_map::const_iterator it;
120 for (it = allDetectors.begin(); it != allDetectors.end(); ++it) {
121 detid_t detectorID = it->first;
127 offset = offsetsWS->getValue(detectorID, 0.0);
132 group =
static_cast<int64_t
>(groupWS->getValue(detectorID, 0.0));
136 if (doMask && (maskWS->isMasked(detectorID)))
140 fout << std::fixed << std::setw(9) << number << std::fixed << std::setw(15) << detectorID << std::fixed
141 << std::setprecision(
m_precision) << std::setw(15) << offset << std::fixed << std::setw(8) << selected
142 << std::fixed << std::setw(8) << group <<
"\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.
@ Save
to specify a file to write to, the file may or may not exist
A property class for workspaces.
Algorithm to save a 5-column ascii .cal file from to 3 workspaces: a GroupingWorkspace,...
void saveCalFile(const std::string &calFileName, const Mantid::DataObjects::GroupingWorkspace_sptr &groupWS, const Mantid::DataObjects::OffsetsWorkspace_sptr &offsetsWS, const Mantid::DataObjects::MaskWorkspace_sptr &maskWS)
Reads the calibration file.
int m_precision
Offset precision.
void exec() override
Run the algorithm.
void warning(const std::string &msg)
Logs at warning level.
void information(const std::string &msg)
Logs at information level.
std::shared_ptr< GroupingWorkspace > GroupingWorkspace_sptr
shared pointer to the GroupingWorkspace class
std::shared_ptr< MaskWorkspace > MaskWorkspace_sptr
shared pointer to the MaskWorkspace class
std::shared_ptr< OffsetsWorkspace > OffsetsWorkspace_sptr
shared pointer to the OffsetsWorkspace class
std::shared_ptr< const Instrument > Instrument_const_sptr
Shared pointer to an const instrument object.
int32_t detid_t
Typedef for a detector ID.
std::map< detid_t, Geometry::IDetector_const_sptr > detid2det_map
Typedef of a map from detector ID to detector shared pointer.
@ Input
An input workspace.