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();
114 for (
size_t i = 0; i < numHist; i++) {
117 detIDs.insert(temp.begin(), temp.end());
132 for (
size_t i = 0; i < numHist; i++) {
144 if (detectorIDs.empty()) {
148 const auto it = std::find_if_not(detectorIDs.cbegin(), detectorIDs.cend(),
149 [
this](
const auto detectorID) { return this->containsDetID(detectorID); });
150 return it == detectorIDs.cend();
154 if (detectorIDs.empty()) {
158 const auto it = std::find_if_not(detectorIDs.cbegin(), detectorIDs.cend(),
159 [
this](
const auto detectorID) { return this->containsDetID(detectorID); });
160 return it == detectorIDs.cend();
172 if (this->
contains(detectorID) && this->
getValue(detectorID) != LIVE_VALUE) {
183 }
catch (std::out_of_range &) {
193 if (detectorIDs.empty()) {
197 const auto it = std::find_if_not(detectorIDs.cbegin(), detectorIDs.cend(),
198 [
this](
const auto detectorID) { return this->isMasked(detectorID); });
199 return it == detectorIDs.cend();
206 return (this->
dataY(wkspIndex)[0] != LIVE_VALUE);
216 double value(LIVE_VALUE);
231 for (
auto detectorID : detectorIDs) {
237 double value(LIVE_VALUE);
260 throw std::logic_error(
"MaskWorkspace has no instrument");
266 const size_t N_detectors(detectors.
size());
267 if (N_spectra == N_detectors - N_monitors) {
269 for (
const auto &det : detids) {
277 "MaskWorkspace::combineToDetectorMasks: not implemented for the case of multiple detectors per spectrum.");
280 for (
size_t ns = 0; ns < N_spectra; ++ns) {
283 for (
const auto &det_idx : spectrumDef)
296bool isMaskedSpectrum(
const Mantid::SpectrumDefinition &spectrumDef,
299 spectrumDef.cbegin(), spectrumDef.cend(),
300 [&detectorInfo](
const std::pair<size_t, size_t> &detIndex) { return detectorInfo.isMasked(detIndex); });
311 throw std::logic_error(
"MaskWorkspace has no instrument");
317 const size_t N_detectors(detectors.
size());
318 if (N_spectra == N_detectors - N_monitors) {
320 for (
const auto &det : detids) {
328 "MaskWorkspace::combineFromDetectorMasks: not implemented for the case of multiple detectors per spectrum.");
331 for (
size_t ns = 0; ns < N_spectra; ++ns) {
333 if (isMaskedSpectrum(spectrumDef, detectors)) {
343 throw std::logic_error(
"MaskWorkspace has no instrument");
349 const size_t N_detectors(detectors.
size());
350 if (N_spectra == N_detectors - N_monitors) {
352 auto maskConsistent = [&](
const auto &det) {
return isMasked(det) == detectors.
isMasked(detectors.
indexOf(det)); };
354 return std::all_of(detids.begin(), detids.end(), maskConsistent);
359 "MaskWorkspace::isConsistentWithDetectorMasks: not implemented for the case of multiple detectors per spectrum.");
362 for (
size_t ns = 0; ns < N_spectra; ++ns) {
364 if (
isMaskedIndex(ns) != isMaskedSpectrum(spectrumDef, detectors))
375 std::ostringstream os;
390 hasinst = inst->getNumberDetectors() > 0;
405IPropertyManager::getValue<Mantid::DataObjects::MaskWorkspace_sptr>(
const std::string &
name)
const {
410 std::string message =
411 "Attempt to assign property " +
name +
" to incorrect type. Expected shared_ptr<MaskWorkspace>.";
412 throw std::runtime_error(message);
418IPropertyManager::getValue<Mantid::DataObjects::MaskWorkspace_const_sptr>(
const std::string &
name)
const {
420 dynamic_cast<PropertyWithValue<Mantid::DataObjects::MaskWorkspace_sptr> *
>(getPointerToProperty(
name));
422 return prop->operator()();
424 std::string message =
425 "Attempt to assign property " +
name +
" to incorrect type. Expected const shared_ptr<MaskWorkspace>.";
426 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 toString() const override
Return human-readable string.
bool containsDetID(const detid_t detectorID) const override
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 containsDetIDs(const std::set< detid_t > &detectorIDs) const override
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.
bool contains(const detid_t detectorID) const
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.