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) {
117 std::ostringstream os;
118 os <<
"SpecialWorkspace2D: " << this->
getName() <<
" Detector ID = " << detectorID
119 <<
" Size(Map) = " << this->
detID_to_WI.size() <<
'\n';
120 throw std::invalid_argument(os.str());
122 return this->
dataY(it->second)[0];
141 return this->
dataY(it->second)[0];
143 g_log.
debug() <<
"getValue(" << detectorID <<
"->" << (it->second) <<
", " << defaultValue
144 <<
") index out of range\n";
161 std::stringstream msg;
162 msg <<
"SpecialWorkspace2D::setValue(): Input Detector ID = " << detectorID <<
" Is Invalid";
163 throw std::invalid_argument(msg.str());
181 for (
auto detectorID : detectorIDs) {
195 throw std::invalid_argument(
"SpecialWorkspace2D::getDetectorIDs(): Invalid workspaceIndex given.");
205 const unsigned int operatortype) {
209 throw std::invalid_argument(
"Two SpecialWorkspace2D objects are not compatible!");
212 switch (operatortype) {
223 throw std::invalid_argument(
"Invalid Operator");
235 switch (operatortype) {
240 g_log.
error() <<
"Operator " << operatortype <<
" Is Not Valid In BinaryOperation(operatortype)\n";
241 throw std::invalid_argument(
"Invalid Operator");
252 double y1 = this->
dataY(i)[0];
253 double y2 = ws->dataY(i)[0];
255 if (y1 < 1.0E-10 || y2 < 1.0E-10) {
256 this->
dataY(i)[0] = 0.0;
258 this->
dataY(i)[0] += y2;
269 double y1 = this->
dataY(i)[0];
270 double y2 = ws->dataY(i)[0];
276 this->
dataY(i)[0] = max;
294 double y1 = this->
dataY(i)[0];
295 double y2 = ws->dataY(i)[0];
296 if (y1 < 1.0E-10 && y2 < 1.0E-10) {
297 this->
dataY(i)[0] = 0.0;
298 }
else if (y1 > 1.0E-10 && y2 > 1.0E-10) {
299 this->
dataY(i)[0] = 0.0;
301 this->
dataY(i)[0] = 1.0;
312 double y1 = this->
dataY(i)[0];
314 this->
dataY(i)[0] = 1.0;
316 this->
dataY(i)[0] = 0.0;
330 size_t numhist2 = ws->getNumberHistograms();
331 if (numhist1 != numhist2) {
332 g_log.
debug() <<
"2 Workspaces have different number of histograms: " << numhist1 <<
" vs. " << numhist2 <<
'\n';
337 for (
size_t ispec = 0; ispec < numhist1; ispec++) {
339 set<detid_t> ids2 = ws->getSpectrum(ispec).getDetectorIDs();
341 if (ids1.size() != ids2.size()) {
342 g_log.
debug() <<
"Spectra " << ispec <<
": 2 Workspaces have different number of detectors " << ids1.size()
343 <<
" vs. " << ids2.size() <<
'\n';
345 }
else if (ids1.empty()) {
346 g_log.
debug() <<
"Spectra " << ispec <<
": 2 Workspaces both have 0 detectors. \n";
348 }
else if (*ids1.begin() != *ids2.begin()) {
349 g_log.
debug() <<
"Spectra " << ispec <<
": 2 Workspaces have different Detector ID " << *ids1.begin() <<
" vs. "
350 << *ids2.begin() <<
'\n';
364 throw std::invalid_argument(
"Incompatible number of histograms");
371 const MantidVec &inx = sourcews->readX(ispec);
372 const MantidVec &iny = sourcews->readY(ispec);
373 const MantidVec &ine = sourcews->readE(ispec);
379 if (inx.size() != outx.size() || iny.size() != outy.size() || ine.size() != oute.size()) {
380 throw std::invalid_argument(
"X, Y, E size different within spectrum");
384 for (
size_t i = 0; i < inx.size(); i++) {
387 for (
size_t i = 0; i < iny.size(); i++) {
405IPropertyManager::getValue<Mantid::DataObjects::SpecialWorkspace2D_sptr>(
const std::string &
name)
const {
411 std::string message =
412 "Attempt to assign property " +
name +
" to incorrect type. Expected shared_ptr<SpecialWorkspace2D>.";
413 throw std::runtime_error(message);
419IPropertyManager::getValue<Mantid::DataObjects::SpecialWorkspace2D_const_sptr>(
const std::string &
name)
const {
421 dynamic_cast<PropertyWithValue<Mantid::DataObjects::SpecialWorkspace2D_sptr> *
>(getPointerToProperty(
name));
423 return prop->operator()();
425 std::string message =
426 "Attempt to assign property " +
name +
" to incorrect type. Expected const shared_ptr<SpecialWorkspace2D>.";
427 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.
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.
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