21Kernel::Logger
g_log(
"SpecialWorkspace2D");
35 this->initialize(inst->getNumberDetectors(!includeMonitors), 1, 1);
38 this->setInstrument(inst);
44 buildDetectorIDMapping();
53 this->
initialize(parent->getNumberHistograms(), 1, 1);
67 if ((XLength != 1) || (YLength != 1))
68 throw std::invalid_argument(
"SpecialWorkspace2D must have 'spectra' of length 1 only.");
74 if (
histogram.xMode() != HistogramData::Histogram::XMode::Points)
75 throw std::runtime_error(
"SpecialWorkspace2D can only be initialized with XMode::Points");
77 throw std::runtime_error(
"SpecialWorkspace2D can only be initialized with length 1");
85 std::ostringstream os;
86 os <<
"Title: " <<
getTitle() <<
"\n";
95 for (
auto det : dets) {
112 std::ostringstream os;
113 os <<
"SpecialWorkspace2D: " << this->
getName() <<
" Detector ID = " << detectorID
114 <<
" Size(Map) = " << this->
detID_to_WI.size() <<
'\n';
115 throw std::invalid_argument(os.str());
117 return this->
dataY(it->second)[0];
136 return this->
dataY(it->second)[0];
138 g_log.
debug() <<
"getValue(" << detectorID <<
"->" << (it->second) <<
", " << defaultValue
139 <<
") index out of range\n";
156 std::stringstream msg;
157 msg <<
"SpecialWorkspace2D::setValue(): Input Detector ID = " << detectorID <<
" Is Invalid";
158 throw std::invalid_argument(msg.str());
176 for (
auto detectorID : detectorIDs) {
190 throw std::invalid_argument(
"SpecialWorkspace2D::getDetectorIDs(): Invalid workspaceIndex given.");
200 const unsigned int operatortype) {
204 throw std::invalid_argument(
"Two SpecialWorkspace2D objects are not compatible!");
207 switch (operatortype) {
218 throw std::invalid_argument(
"Invalid Operator");
230 switch (operatortype) {
235 g_log.
error() <<
"Operator " << operatortype <<
" Is Not Valid In BinaryOperation(operatortype)\n";
236 throw std::invalid_argument(
"Invalid Operator");
247 double y1 = this->
dataY(i)[0];
248 double y2 = ws->dataY(i)[0];
250 if (y1 < 1.0E-10 || y2 < 1.0E-10) {
251 this->
dataY(i)[0] = 0.0;
253 this->
dataY(i)[0] += y2;
264 double y1 = this->
dataY(i)[0];
265 double y2 = ws->dataY(i)[0];
271 this->
dataY(i)[0] = max;
289 double y1 = this->
dataY(i)[0];
290 double y2 = ws->dataY(i)[0];
291 if (y1 < 1.0E-10 && y2 < 1.0E-10) {
292 this->
dataY(i)[0] = 0.0;
293 }
else if (y1 > 1.0E-10 && y2 > 1.0E-10) {
294 this->
dataY(i)[0] = 0.0;
296 this->
dataY(i)[0] = 1.0;
307 double y1 = this->
dataY(i)[0];
309 this->
dataY(i)[0] = 1.0;
311 this->
dataY(i)[0] = 0.0;
325 size_t numhist2 = ws->getNumberHistograms();
326 if (numhist1 != numhist2) {
327 g_log.
debug() <<
"2 Workspaces have different number of histograms: " << numhist1 <<
" vs. " << numhist2 <<
'\n';
332 for (
size_t ispec = 0; ispec < numhist1; ispec++) {
334 set<detid_t> ids2 = ws->getSpectrum(ispec).getDetectorIDs();
336 if (ids1.size() != ids2.size()) {
337 g_log.
debug() <<
"Spectra " << ispec <<
": 2 Workspaces have different number of detectors " << ids1.size()
338 <<
" vs. " << ids2.size() <<
'\n';
340 }
else if (ids1.empty()) {
341 g_log.
debug() <<
"Spectra " << ispec <<
": 2 Workspaces both have 0 detectors. \n";
343 }
else if (*ids1.begin() != *ids2.begin()) {
344 g_log.
debug() <<
"Spectra " << ispec <<
": 2 Workspaces have different Detector ID " << *ids1.begin() <<
" vs. "
345 << *ids2.begin() <<
'\n';
359 throw std::invalid_argument(
"Incompatible number of histograms");
366 const MantidVec &inx = sourcews->readX(ispec);
367 const MantidVec &iny = sourcews->readY(ispec);
368 const MantidVec &ine = sourcews->readE(ispec);
374 if (inx.size() != outx.size() || iny.size() != outy.size() || ine.size() != oute.size()) {
375 throw std::invalid_argument(
"X, Y, E size different within spectrum");
379 for (
size_t i = 0; i < inx.size(); i++) {
382 for (
size_t i = 0; i < iny.size(); i++) {
400IPropertyManager::getValue<Mantid::DataObjects::SpecialWorkspace2D_sptr>(
const std::string &
name)
const {
406 std::string message =
407 "Attempt to assign property " +
name +
" to incorrect type. Expected shared_ptr<SpecialWorkspace2D>.";
408 throw std::runtime_error(message);
414IPropertyManager::getValue<Mantid::DataObjects::SpecialWorkspace2D_const_sptr>(
const std::string &
name)
const {
416 dynamic_cast<PropertyWithValue<Mantid::DataObjects::SpecialWorkspace2D_sptr> *
>(getPointerToProperty(
name));
418 return prop->operator()();
420 std::string message =
421 "Attempt to assign property " +
name +
" to incorrect type. Expected const shared_ptr<SpecialWorkspace2D>.";
422 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.
void buildDetectorIDMapping()
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