21Kernel::Logger
g_log(
"SpecialWorkspace2D");
36 this->initialize(inst->getNumberDetectors(!includeMonitors), 1, 1);
39 this->setInstrument(inst);
46 for (
size_t wi = 0; wi < getNumberHistograms(); wi++) {
47 auto &dets = getSpectrum(wi).getDetectorIDs();
48 for (
auto det : dets) {
49 detID_to_WI[det] = wi;
61 this->
initialize(parent->getNumberHistograms(), 1, 1);
67 for (
auto det : dets) {
81 if ((XLength != 1) || (YLength != 1))
82 throw std::invalid_argument(
"SpecialWorkspace2D must have 'spectra' of length 1 only.");
88 if (
histogram.xMode() != HistogramData::Histogram::XMode::Points)
89 throw std::runtime_error(
"SpecialWorkspace2D can only be initialized with XMode::Points");
91 throw std::runtime_error(
"SpecialWorkspace2D can only be initialized with length 1");
99 std::ostringstream os;
100 os <<
"Title: " <<
getTitle() <<
"\n";
116 std::ostringstream os;
117 os <<
"SpecialWorkspace2D: " << this->
getName() <<
" Detector ID = " << detectorID
118 <<
" Size(Map) = " << this->
detID_to_WI.size() <<
'\n';
119 throw std::invalid_argument(os.str());
121 return this->
dataY(it->second)[0];
140 return this->
dataY(it->second)[0];
142 g_log.
debug() <<
"getValue(" << detectorID <<
"->" << (it->second) <<
", " << defaultValue
143 <<
") index out of range\n";
160 std::stringstream msg;
161 msg <<
"SpecialWorkspace2D::setValue(): Input Detector ID = " << detectorID <<
" Is Invalid";
162 throw std::invalid_argument(msg.str());
180 for (
auto detectorID : detectorIDs) {
194 throw std::invalid_argument(
"SpecialWorkspace2D::getDetectorIDs(): Invalid workspaceIndex given.");
204 const unsigned int operatortype) {
208 throw std::invalid_argument(
"Two SpecialWorkspace2D objects are not compatible!");
211 switch (operatortype) {
222 throw std::invalid_argument(
"Invalid Operator");
234 switch (operatortype) {
239 g_log.
error() <<
"Operator " << operatortype <<
" Is Not Valid In BinaryOperation(operatortype)\n";
240 throw std::invalid_argument(
"Invalid Operator");
251 double y1 = this->
dataY(i)[0];
252 double y2 = ws->dataY(i)[0];
254 if (y1 < 1.0E-10 || y2 < 1.0E-10) {
255 this->
dataY(i)[0] = 0.0;
257 this->
dataY(i)[0] += y2;
268 double y1 = this->
dataY(i)[0];
269 double y2 = ws->dataY(i)[0];
275 this->
dataY(i)[0] = max;
293 double y1 = this->
dataY(i)[0];
294 double y2 = ws->dataY(i)[0];
295 if (y1 < 1.0E-10 && y2 < 1.0E-10) {
296 this->
dataY(i)[0] = 0.0;
297 }
else if (y1 > 1.0E-10 && y2 > 1.0E-10) {
298 this->
dataY(i)[0] = 0.0;
300 this->
dataY(i)[0] = 1.0;
311 double y1 = this->
dataY(i)[0];
313 this->
dataY(i)[0] = 1.0;
315 this->
dataY(i)[0] = 0.0;
329 size_t numhist2 = ws->getNumberHistograms();
330 if (numhist1 != numhist2) {
331 g_log.
debug() <<
"2 Workspaces have different number of histograms: " << numhist1 <<
" vs. " << numhist2 <<
'\n';
336 for (
size_t ispec = 0; ispec < numhist1; ispec++) {
338 set<detid_t> ids2 = ws->getSpectrum(ispec).getDetectorIDs();
340 if (ids1.size() != ids2.size()) {
341 g_log.
debug() <<
"Spectra " << ispec <<
": 2 Workspaces have different number of detectors " << ids1.size()
342 <<
" vs. " << ids2.size() <<
'\n';
344 }
else if (ids1.empty()) {
345 g_log.
debug() <<
"Spectra " << ispec <<
": 2 Workspaces both have 0 detectors. \n";
347 }
else if (*ids1.begin() != *ids2.begin()) {
348 g_log.
debug() <<
"Spectra " << ispec <<
": 2 Workspaces have different Detector ID " << *ids1.begin() <<
" vs. "
349 << *ids2.begin() <<
'\n';
363 throw std::invalid_argument(
"Incompatible number of histograms");
370 const MantidVec &inx = sourcews->readX(ispec);
371 const MantidVec &iny = sourcews->readY(ispec);
372 const MantidVec &ine = sourcews->readE(ispec);
378 if (inx.size() != outx.size() || iny.size() != outy.size() || ine.size() != oute.size()) {
379 throw std::invalid_argument(
"X, Y, E size different within spectrum");
383 for (
size_t i = 0; i < inx.size(); i++) {
386 for (
size_t i = 0; i < iny.size(); i++) {
404IPropertyManager::getValue<Mantid::DataObjects::SpecialWorkspace2D_sptr>(
const std::string &name)
const {
410 std::string message =
411 "Attempt to assign property " + name +
" to incorrect type. Expected shared_ptr<SpecialWorkspace2D>.";
412 throw std::runtime_error(message);
418IPropertyManager::getValue<Mantid::DataObjects::SpecialWorkspace2D_const_sptr>(
const std::string &name)
const {
420 dynamic_cast<PropertyWithValue<Mantid::DataObjects::SpecialWorkspace2D_sptr> *
>(getPointerToProperty(name));
422 return prop->operator()();
424 std::string message =
425 "Attempt to assign property " + name +
" to incorrect type. Expected const shared_ptr<SpecialWorkspace2D>.";
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)
const std::set< detid_t > & getDetectorIDs() const
Get a const reference to the detector IDs set.
void rebuildSpectraMapping(const bool includeMonitors=true, const specnum_t specNumOffset=1)
Build the default spectra mapping, most likely wanted after an instrument update.
void initialize(const std::size_t &NVectors, const std::size_t &XLength, const std::size_t &YLength)
Initialize the workspace.
virtual MantidVec & dataX(const std::size_t index)
Deprecated, use mutableX() instead. Returns the x data.
virtual MantidVec & dataE(const std::size_t index)
Deprecated, use mutableE() instead. Returns the error data.
HistogramData::Histogram histogram(const size_t index) const
Returns the Histogram at the given workspace index.
const std::string getTitle() const override
Gets MatrixWorkspace title (same as Run object run_title property)
virtual MantidVec & dataY(const std::size_t index)
Deprecated, use mutableY() instead. Returns the y data.
const std::string & getName() const override
Get the workspace name.
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 binaryNOT()
NOT operator.
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.
bool isCompatible(const std::shared_ptr< const SpecialWorkspace2D > &ws)
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)
void binaryOR(const std::shared_ptr< const SpecialWorkspace2D > &ws)
OR operator.
std::map< detid_t, std::size_t > detID_to_WI
Map with key = detector ID, and value = workspace index.
void binaryOperation(const std::shared_ptr< const SpecialWorkspace2D > &ws, const unsigned int operatortype)
Return the result of operator & @ parameter @ return.
virtual void copyFrom(std::shared_ptr< const SpecialWorkspace2D > sourcews)
Duplicate SpecialWorkspace2D.
void binaryXOR(const std::shared_ptr< const SpecialWorkspace2D > &ws)
Excluded Or operator.
SpecialWorkspace2D()=default
void binaryAND(const std::shared_ptr< const SpecialWorkspace2D > &ws)
AND operator.
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.
void init(const std::size_t &NVectors, const std::size_t &XLength, const std::size_t &YLength) override
Called by initialize()
Histogram1D & getSpectrum(const size_t index) override
Return the underlying ISpectrum ptr at the given workspace index.
void debug(const std::string &msg)
Logs at debug level.
void error(const std::string &msg)
Logs at error level.
The concrete, templated class for properties.
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
Kernel::Logger g_log("ExperimentInfo")
static logger object
std::shared_ptr< const MatrixWorkspace > MatrixWorkspace_const_sptr
shared pointer to the matrix workspace base class (const version)
std::shared_ptr< const SpecialWorkspace2D > SpecialWorkspace2D_const_sptr
shared pointer to a const SpecialWorkspace2D
std::shared_ptr< SpecialWorkspace2D > SpecialWorkspace2D_sptr
shared pointer to the SpecialWorkspace2D class
std::shared_ptr< const Instrument > Instrument_const_sptr
Shared pointer to an const instrument object.
std::vector< double > MantidVec
typedef for the data storage used in Mantid matrix workspaces