27const double LIVE_VALUE = 0.;
33const double DEAD_VALUE = 1.;
36const double ERROR_VALUE = 0.;
46 this->
init(numvectors, 1, 1);
74 for (std::size_t i = 0; i < nHist; ++i) {
75 this->
dataY(i)[0] = LIVE_VALUE;
76 this->
dataE(i)[0] = ERROR_VALUE;
89 for (
size_t i = 0; i < numWksp; i++) {
96 numMasked += ids.size();
98 std::stringstream errss;
99 errss <<
"No instrument is associated with mask workspace " << this->
getName();
100 throw std::runtime_error(errss.str());
119 for (
size_t i = 0; i < numHist; i++) {
122 detIDs.insert(temp.begin(), temp.end());
138 for (
size_t i = 0; i < numHist; i++) {
154 std::stringstream msg;
156 msg <<
"There is no instrument associated with workspace \'" << this->
getName() <<
"\'";
158 msg <<
"There is no proper instrument associated with workspace \'" << this->
getName()
159 <<
"\'. Number of detectors = " << this->
getInstrument()->getNumberDetectors();
160 throw std::runtime_error(msg.str());
164 if (this->
getValue(detectorID, LIVE_VALUE) != LIVE_VALUE) {
175 }
catch (std::out_of_range &) {
185 if (detectorIDs.empty()) {
189 const auto it = std::find_if_not(detectorIDs.cbegin(), detectorIDs.cend(),
190 [
this](
const auto detectorID) { return this->isMasked(detectorID); });
191 return it == detectorIDs.cend();
198 return (this->
dataY(wkspIndex)[0] != LIVE_VALUE);
208 double value(LIVE_VALUE);
220 for (
auto detectorID : detectorIDs) {
226 double value(LIVE_VALUE);
249 throw std::logic_error(
"MaskWorkspace has no instrument");
255 const size_t N_detectors(detectors.
size());
256 if (N_spectra == N_detectors - N_monitors) {
258 for (
const auto &det : detids) {
266 "MaskWorkspace::combineToDetectorMasks: not implemented for the case of multiple detectors per spectrum.");
269 for (
size_t ns = 0; ns < N_spectra; ++ns) {
272 for (
const auto &det_idx : spectrumDef)
285bool isMaskedSpectrum(
const Mantid::SpectrumDefinition &spectrumDef,
288 spectrumDef.cbegin(), spectrumDef.cend(),
289 [&detectorInfo](
const std::pair<size_t, size_t> &detIndex) { return detectorInfo.isMasked(detIndex); });
300 throw std::logic_error(
"MaskWorkspace has no instrument");
306 const size_t N_detectors(detectors.
size());
307 if (N_spectra == N_detectors - N_monitors) {
309 for (
const auto &det : detids) {
317 "MaskWorkspace::combineFromDetectorMasks: not implemented for the case of multiple detectors per spectrum.");
320 for (
size_t ns = 0; ns < N_spectra; ++ns) {
322 if (isMaskedSpectrum(spectrumDef, detectors)) {
332 throw std::logic_error(
"MaskWorkspace has no instrument");
338 const size_t N_detectors(detectors.
size());
339 if (N_spectra == N_detectors - N_monitors) {
341 for (
const auto &det : detids) {
349 "MaskWorkspace::isConsistentWithDetectorMasks: not implemented for the case of multiple detectors per spectrum.");
352 for (
size_t ns = 0; ns < N_spectra; ++ns) {
354 if (
isMaskedIndex(ns) != isMaskedSpectrum(spectrumDef, detectors))
365 std::ostringstream os;
380 hasinst = inst->getNumberDetectors() > 0;
395IPropertyManager::getValue<Mantid::DataObjects::MaskWorkspace_sptr>(
const std::string &
name)
const {
400 std::string message =
401 "Attempt to assign property " +
name +
" to incorrect type. Expected shared_ptr<MaskWorkspace>.";
402 throw std::runtime_error(message);
408IPropertyManager::getValue<Mantid::DataObjects::MaskWorkspace_const_sptr>(
const std::string &
name)
const {
410 dynamic_cast<PropertyWithValue<Mantid::DataObjects::MaskWorkspace_sptr> *
>(getPointerToProperty(
name));
412 return prop->operator()();
414 std::string message =
415 "Attempt to assign property " +
name +
" to incorrect type. Expected const shared_ptr<MaskWorkspace>.";
416 throw std::runtime_error(message);
double value
The value of the point.
#define DLLExport
Definitions of the DLLImport compiler directives for MSVC.
#define DECLARE_WORKSPACE(classname)
Geometry::DetectorInfo & mutableDetectorInfo()
Return a non-const reference to the DetectorInfo object.
const SpectrumInfo & spectrumInfo() const
Return a reference to the SpectrumInfo object.
const Geometry::DetectorInfo & detectorInfo() const
Return a const reference to the DetectorInfo object.
Geometry::Instrument_const_sptr getInstrument() const
Returns the parameterized instrument.
virtual MantidVec & dataE(const std::size_t index)
Deprecated, use mutableE() instead. Returns the error data.
virtual MantidVec & dataY(const std::size_t index)
Deprecated, use mutableY() instead. Returns the y data.
API::SpectrumInfo is an intermediate step towards a SpectrumInfo that is part of Instrument-2....
const SpectrumDefinition & spectrumDefinition(const size_t index) const
Returns a const reference to the SpectrumDefinition of the spectrum.
const std::string & getName() const override
Get the workspace name.
const std::string toString() const override
Return human-readable string.
void clearMask()
Clear original incorrect mask.
void setMaskedIndex(const std::size_t wkspIndex, const bool mask=true)
const std::string id() const override
Gets the name of the workspace type.
bool isMaskedIndex(const std::size_t wkspIndex) const
Use this method with MaskWorkspace that doesn't have an instrument.
void copyFrom(std::shared_ptr< const SpecialWorkspace2D > sourcews) override
Copy the set up from another workspace.
bool hasInstrument() const
Check whether any instrument associated.
bool isConsistentWithDetectorMasks() const
Test consistency between the values from this workspace and its own detectors' mask flags.
void setMasked(const detid_t detectorID, const bool mask=true) override
Mask an individual pixel.
void combineFromDetectorMasks()
Ensure that this workspace's values include the values from its own detectors' mask flags.
bool isMasked(const detid_t detectorID) const override
void combineToDetectorMasks()
Ensure that this mask workspace's detectors mask flags include the workspace values.
std::set< detid_t > getMaskedDetectors() const
MaskWorkspace::getMaskedDetectors.
std::set< std::size_t > getMaskedWkspIndices() const
MaskWorkspace::getMaskedWkspIndices.
std::size_t getNumberMasked() const override
double getValue(const detid_t detectorID) const
Return the special value (Y) in the workspace at the given detector ID.
const std::string toString() const override
Return human-readable string.
void init(const size_t &NVectors, const size_t &XLength, const size_t &YLength) override
Sets the size of the workspace and initializes arrays to zero.
std::set< detid_t > getDetectorIDs(const std::size_t workspaceIndex) const
Return the detector ID at the given workspace index (i.e., spectrum/histogram index)
virtual void copyFrom(std::shared_ptr< const SpecialWorkspace2D > sourcews)
Duplicate SpecialWorkspace2D.
void setValue(const detid_t detectorID, const double value, const double error=0.)
Set the special value (Y) in the workspace at the given detector ID.
std::size_t getNumberHistograms() const override
Returns the histogram number.
std::size_t size() const override
get pseudo size
Geometry::DetectorInfo is an intermediate step towards a DetectorInfo that is part of Instrument-2....
bool isMasked(const size_t index) const
Returns true if the detector is masked.
void setMasked(const size_t index, bool masked)
Set the mask flag of the detector with given index. Not thread safe.
void clearMaskFlags()
Sets all mask flags to false (unmasked).
size_t indexOf(const detid_t id) const
Returns the index of the detector with the given detector ID.
size_t size() const
Returns the size of the DetectorInfo, i.e., the number of detectors in the instrument.
Marks code as not implemented yet.
The concrete, templated class for properties.
std::shared_ptr< const MatrixWorkspace > MatrixWorkspace_const_sptr
shared pointer to the matrix workspace base class (const version)
std::shared_ptr< const MaskWorkspace > MaskWorkspace_const_sptr
shared pointer to a const MaskWorkspace
std::shared_ptr< MaskWorkspace > MaskWorkspace_sptr
shared pointer to the MaskWorkspace class
std::shared_ptr< const Instrument > Instrument_const_sptr
Shared pointer to an const instrument object.