diff --git a/Framework/API/inc/MantidAPI/IEventWorkspace.h b/Framework/API/inc/MantidAPI/IEventWorkspace.h index 2e4e611768c6e136c3452326eefddbc14a0c6974..d5e415fcc35b4e5eb41029f2d04196339d561bde 100644 --- a/Framework/API/inc/MantidAPI/IEventWorkspace.h +++ b/Framework/API/inc/MantidAPI/IEventWorkspace.h @@ -42,6 +42,9 @@ public: /// Returns a clone of the workspace IEventWorkspace_uptr clone() const { return IEventWorkspace_uptr(doClone()); } + IEventList &getSpectrum(const size_t index) override = 0; + const IEventList &getSpectrum(const size_t index) const override = 0; + /// Return the workspace typeID const std::string id() const override { return "IEventWorkspace"; } virtual std::size_t getNumberEvents() const = 0; @@ -54,7 +57,6 @@ public: virtual Mantid::Kernel::DateAndTime getTimeAtSampleMin(double tofOffset = 0) const = 0; virtual EventType getEventType() const = 0; - virtual IEventList *getEventListPtr(const std::size_t workspace_index) = 0; void generateHistogram(const std::size_t index, const MantidVec &X, MantidVec &Y, MantidVec &E, bool skipError = false) const override = 0; diff --git a/Framework/API/inc/MantidAPI/ISpectrum.h b/Framework/API/inc/MantidAPI/ISpectrum.h index 50a2237e8b6af658095b45995dec354dcdc14897..502a36efa4456b269532157b0f3ad65f460645d0 100644 --- a/Framework/API/inc/MantidAPI/ISpectrum.h +++ b/Framework/API/inc/MantidAPI/ISpectrum.h @@ -124,6 +124,13 @@ public: virtual void resetHasDx(); protected: + // Copy and move are not public since this is an abstract class, but protected + // such that derived classes can implement copy and move. + ISpectrum(const ISpectrum &) = default; + ISpectrum(ISpectrum &&) = default; + ISpectrum &operator=(const ISpectrum &) = default; + ISpectrum &operator=(ISpectrum &&) = default; + /// The spectrum number of this spectrum specnum_t m_specNo; diff --git a/Framework/API/inc/MantidAPI/MatrixWorkspace.h b/Framework/API/inc/MantidAPI/MatrixWorkspace.h index 2f7149a96084ef9ba61c6c067550231ed658662f..838ca45472b509d7ed070a00ef7a2aa048d9d3a7 100644 --- a/Framework/API/inc/MantidAPI/MatrixWorkspace.h +++ b/Framework/API/inc/MantidAPI/MatrixWorkspace.h @@ -173,68 +173,68 @@ public: //---------------------------------------------------------------------- /// Return the underlying ISpectrum ptr at the given workspace index. - virtual ISpectrum *getSpectrum(const size_t index) = 0; + virtual ISpectrum &getSpectrum(const size_t index) = 0; /// Return the underlying ISpectrum ptr (const version) at the given workspace /// index. - virtual const ISpectrum *getSpectrum(const size_t index) const = 0; + virtual const ISpectrum &getSpectrum(const size_t index) const = 0; // Methods for getting read-only access to the data. // Just passes through to the virtual dataX/Y/E function (const version) /// Returns a read-only (i.e. const) reference to the specified X array /// @param index :: workspace index to retrieve. const MantidVec &readX(std::size_t const index) const { - return getSpectrum(index)->dataX(); + return getSpectrum(index).dataX(); } /// Returns a read-only (i.e. const) reference to the specified Y array /// @param index :: workspace index to retrieve. const MantidVec &readY(std::size_t const index) const { - return getSpectrum(index)->dataY(); + return getSpectrum(index).dataY(); } /// Returns a read-only (i.e. const) reference to the specified E array /// @param index :: workspace index to retrieve. const MantidVec &readE(std::size_t const index) const { - return getSpectrum(index)->dataE(); + return getSpectrum(index).dataE(); } /// Returns a read-only (i.e. const) reference to the specified X error array /// @param index :: workspace index to retrieve. const MantidVec &readDx(size_t const index) const { - return getSpectrum(index)->dataDx(); + return getSpectrum(index).dataDx(); } /// Returns the x data virtual MantidVec &dataX(const std::size_t index) { invalidateCommonBinsFlag(); - return getSpectrum(index)->dataX(); + return getSpectrum(index).dataX(); } /// Returns the y data virtual MantidVec &dataY(const std::size_t index) { - return getSpectrum(index)->dataY(); + return getSpectrum(index).dataY(); } /// Returns the error data virtual MantidVec &dataE(const std::size_t index) { - return getSpectrum(index)->dataE(); + return getSpectrum(index).dataE(); } /// Returns the x error data virtual MantidVec &dataDx(const std::size_t index) { - return getSpectrum(index)->dataDx(); + return getSpectrum(index).dataDx(); } /// Returns the x data const virtual const MantidVec &dataX(const std::size_t index) const { - return getSpectrum(index)->dataX(); + return getSpectrum(index).dataX(); } /// Returns the y data const virtual const MantidVec &dataY(const std::size_t index) const { - return getSpectrum(index)->dataY(); + return getSpectrum(index).dataY(); } /// Returns the error const virtual const MantidVec &dataE(const std::size_t index) const { - return getSpectrum(index)->dataE(); + return getSpectrum(index).dataE(); } /// Returns the error const virtual const MantidVec &dataDx(const std::size_t index) const { - return getSpectrum(index)->dataDx(); + return getSpectrum(index).dataDx(); } virtual double getXMin() const; @@ -243,48 +243,48 @@ public: /// Returns a pointer to the x data virtual Kernel::cow_ptr<MantidVec> refX(const std::size_t index) const { - return getSpectrum(index)->ptrX(); + return getSpectrum(index).ptrX(); } /// Returns a pointer to the dX (X Error) data virtual Kernel::cow_ptr<MantidVec> refDx(const std::size_t index) const { - return getSpectrum(index)->ptrDx(); + return getSpectrum(index).ptrDx(); } /// Set the specified X array to point to the given existing array virtual void setX(const std::size_t index, const MantidVec &X) { - getSpectrum(index)->setX(X); + getSpectrum(index).setX(X); invalidateCommonBinsFlag(); } /// Set the specified X array to point to the given existing array virtual void setX(const std::size_t index, const MantidVecPtr &X) { - getSpectrum(index)->setX(X); + getSpectrum(index).setX(X); invalidateCommonBinsFlag(); } /// Set the specified X array to point to the given existing array virtual void setX(const std::size_t index, const MantidVecPtr::ptr_type &X) { - getSpectrum(index)->setX(X); + getSpectrum(index).setX(X); invalidateCommonBinsFlag(); } /// Set the specified Dx (X Error) array to point to the given existing array virtual void setDx(const std::size_t index, const MantidVec &Dx) { - getSpectrum(index)->setDx(Dx); + getSpectrum(index).setDx(Dx); invalidateCommonBinsFlag(); } /// Set the specified Dx (X Error) array to point to the given existing array virtual void setDx(const std::size_t index, const MantidVecPtr &Dx) { - getSpectrum(index)->setDx(Dx); + getSpectrum(index).setDx(Dx); invalidateCommonBinsFlag(); } /// Set the specified Dx (X Error) array to point to the given existing array virtual void setDx(const std::size_t index, const MantidVecPtr::ptr_type &Dx) { - getSpectrum(index)->setDx(Dx); + getSpectrum(index).setDx(Dx); invalidateCommonBinsFlag(); } @@ -292,7 +292,7 @@ public: @param index :: the workspace index to set. @param Y :: Y vector */ virtual void setData(const std::size_t index, const MantidVecPtr &Y) { - getSpectrum(index)->setData(Y); + getSpectrum(index).setData(Y); } /** Sets the data in the workspace @@ -301,7 +301,7 @@ public: @param E :: Error vector */ virtual void setData(const std::size_t index, const MantidVecPtr &Y, const MantidVecPtr &E) { - getSpectrum(index)->setData(Y, E); + getSpectrum(index).setData(Y, E); } /** Sets the data in the workspace @@ -310,7 +310,7 @@ public: @param E :: Error vector */ virtual void setData(const std::size_t index, const MantidVecPtr::ptr_type &Y, const MantidVecPtr::ptr_type &E) { - getSpectrum(index)->setData(Y, E); + getSpectrum(index).setData(Y, E); } /** @@ -318,7 +318,7 @@ public: * @param index: the workspace index */ virtual bool hasDx(const std::size_t index) const { - return getSpectrum(index)->hasDx(); + return getSpectrum(index).hasDx(); } /// Generate the histogram or rebin the existing histogram. diff --git a/Framework/API/src/GeometryInfoFactory.cpp b/Framework/API/src/GeometryInfoFactory.cpp index f97d88257763468aa00cdc9cf19544a2744e105a..5766e92be102c6b1835f586f58f1e6026b5bd087 100644 --- a/Framework/API/src/GeometryInfoFactory.cpp +++ b/Framework/API/src/GeometryInfoFactory.cpp @@ -23,7 +23,7 @@ GeometryInfo GeometryInfoFactory::create(const size_t index) const { // current (2016) instrument code there are memory allocations when getting // the detector, so this additional allocation may be negligible, but we want // this class to be future proof. GeometryInfo should be kept small. - return {*this, *(m_workspace.getSpectrum(index))}; + return {*this, m_workspace.getSpectrum(index)}; } const Geometry::Instrument &GeometryInfoFactory::getInstrument() const { diff --git a/Framework/API/src/IFunction.cpp b/Framework/API/src/IFunction.cpp index c8c3ab22b20e017e469541c13aef6cfa72bba8db..91ba17f63ff30dc2a13c184a71ffa03dbdebf081 100644 --- a/Framework/API/src/IFunction.cpp +++ b/Framework/API/src/IFunction.cpp @@ -715,7 +715,7 @@ void IFunction::setMatrixWorkspace( const Geometry::ParameterMap ¶mMap = workspace->instrumentParameters(); Geometry::IDetector_const_sptr det; - size_t numDetectors = workspace->getSpectrum(wi)->getDetectorIDs().size(); + size_t numDetectors = workspace->getSpectrum(wi).getDetectorIDs().size(); if (numDetectors > 1) { // If several detectors are on this workspace index, just use the ID of // the first detector @@ -723,7 +723,7 @@ void IFunction::setMatrixWorkspace( // and not the group. Ask Roman. Instrument_const_sptr inst = workspace->getInstrument(); det = inst->getDetector( - *workspace->getSpectrum(wi)->getDetectorIDs().begin()); + *workspace->getSpectrum(wi).getDetectorIDs().begin()); } else // Get the detector (single) at this workspace index det = workspace->getDetector(wi); diff --git a/Framework/API/src/MatrixWorkspace.cpp b/Framework/API/src/MatrixWorkspace.cpp index 112208b5b39b470abd65653ef9786c7b538dfe4c..a67675e74fe81984e9da88ab94bb3614b178007b 100644 --- a/Framework/API/src/MatrixWorkspace.cpp +++ b/Framework/API/src/MatrixWorkspace.cpp @@ -183,18 +183,18 @@ const std::string MatrixWorkspace::getTitle() const { void MatrixWorkspace::updateSpectraUsing(const SpectrumDetectorMapping &map) { for (size_t j = 0; j < getNumberHistograms(); ++j) { - auto spec = getSpectrum(j); + auto &spec = getSpectrum(j); try { if (map.indexIsSpecNumber()) - spec->setDetectorIDs( - map.getDetectorIDsForSpectrumNo(spec->getSpectrumNo())); + spec.setDetectorIDs( + map.getDetectorIDsForSpectrumNo(spec.getSpectrumNo())); else - spec->setDetectorIDs(map.getDetectorIDsForSpectrumIndex(j)); + spec.setDetectorIDs(map.getDetectorIDsForSpectrumIndex(j)); } catch (std::out_of_range &e) { // Get here if the spectrum number is not in the map. - spec->clearDetectorIDs(); + spec.clearDetectorIDs(); g_log.debug(e.what()); - g_log.debug() << "Spectrum number " << spec->getSpectrumNo() + g_log.debug() << "Spectrum number " << spec.getSpectrumNo() << " not in map.\n"; } } @@ -227,9 +227,9 @@ void MatrixWorkspace::rebuildSpectraMapping(const bool includeMonitors) { const specnum_t specNo = specnum_t(index + 1); if (index < this->getNumberHistograms()) { - ISpectrum *spec = getSpectrum(index); - spec->setSpectrumNo(specNo); - spec->setDetectorID(detId); + auto &spec = getSpectrum(index); + spec.setSpectrumNo(specNo); + spec.setDetectorID(detId); } index++; @@ -428,7 +428,7 @@ bool MatrixWorkspace::hasGroupedDetectors() const { // Loop through the workspace index for (size_t workspaceIndex = 0; workspaceIndex < this->getNumberHistograms(); workspaceIndex++) { - auto detList = getSpectrum(workspaceIndex)->getDetectorIDs(); + auto detList = getSpectrum(workspaceIndex).getDetectorIDs(); if (detList.size() > 1) { retVal = true; break; @@ -456,7 +456,7 @@ detid2index_map MatrixWorkspace::getDetectorIDToWorkspaceIndexMap( // Loop through the workspace index for (size_t workspaceIndex = 0; workspaceIndex < this->getNumberHistograms(); ++workspaceIndex) { - auto detList = getSpectrum(workspaceIndex)->getDetectorIDs(); + auto detList = getSpectrum(workspaceIndex).getDetectorIDs(); if (throwIfMultipleDets) { if (detList.size() > 1) { @@ -509,8 +509,7 @@ std::vector<size_t> MatrixWorkspace::getDetectorIDToWorkspaceIndexVector( for (size_t workspaceIndex = 0; workspaceIndex < getNumberHistograms(); ++workspaceIndex) { // Get the list of detectors from the WS index - const std::set<detid_t> &detList = - this->getSpectrum(workspaceIndex)->getDetectorIDs(); + const auto &detList = this->getSpectrum(workspaceIndex).getDetectorIDs(); if (throwIfMultipleDets && (detList.size() > 1)) throw std::runtime_error( @@ -552,7 +551,7 @@ std::vector<size_t> MatrixWorkspace::getIndicesFromSpectra( auto iter = spectraList.cbegin(); while (iter != spectraList.cend()) { for (size_t i = 0; i < this->getNumberHistograms(); ++i) { - if (this->getSpectrum(i)->getSpectrumNo() == *iter) { + if (this->getSpectrum(i).getSpectrumNo() == *iter) { indexList.push_back(i); break; } @@ -572,7 +571,7 @@ std::vector<size_t> MatrixWorkspace::getIndicesFromSpectra( size_t MatrixWorkspace::getIndexFromSpectrumNumber(const specnum_t specNo) const { for (size_t i = 0; i < this->getNumberHistograms(); ++i) { - if (this->getSpectrum(i)->getSpectrumNo() == specNo) + if (this->getSpectrum(i).getSpectrumNo() == specNo) return i; } throw std::runtime_error("Could not find spectrum number in any spectrum."); @@ -594,7 +593,7 @@ std::vector<size_t> MatrixWorkspace::getIndicesFromDetectorIDs( const std::vector<detid_t> &detIdList) const { std::map<detid_t, std::set<size_t>> detectorIDtoWSIndices; for (size_t i = 0; i < getNumberHistograms(); ++i) { - auto detIDs = getSpectrum(i)->getDetectorIDs(); + auto detIDs = getSpectrum(i).getDetectorIDs(); for (auto detID : detIDs) { detectorIDtoWSIndices[detID].insert(i); } @@ -632,9 +631,9 @@ std::vector<specnum_t> MatrixWorkspace::getSpectraFromDetectorIDs( // Go through every histogram for (size_t i = 0; i < this->getNumberHistograms(); i++) { - if (this->getSpectrum(i)->hasDetectorID(detId)) { + if (this->getSpectrum(i).hasDetectorID(detId)) { foundDet = true; - foundSpecNum = this->getSpectrum(i)->getSpectrumNo(); + foundSpecNum = this->getSpectrum(i).getSpectrumNo(); break; } } @@ -752,14 +751,7 @@ requested workspace index does not have any associated detectors */ Geometry::IDetector_const_sptr MatrixWorkspace::getDetector(const size_t workspaceIndex) const { - const ISpectrum *spec = this->getSpectrum(workspaceIndex); - if (!spec) - throw Kernel::Exception::NotFoundError("MatrixWorkspace::getDetector(): " - "NULL spectrum found at the given " - "workspace index.", - ""); - - const auto &dets = spec->getDetectorIDs(); + const auto &dets = getSpectrum(workspaceIndex).getDetectorIDs(); Instrument_const_sptr localInstrument = getInstrument(); if (!localInstrument) { g_log.debug() << "No instrument defined.\n"; @@ -999,15 +991,12 @@ void MatrixWorkspace::maskWorkspaceIndex(const std::size_t index) { "MatrixWorkspace::maskWorkspaceIndex,index"); } - ISpectrum *spec = this->getSpectrum(index); - if (!spec) - throw std::invalid_argument( - "MatrixWorkspace::maskWorkspaceIndex() got a null Spectrum."); + auto &spec = this->getSpectrum(index); // Virtual method clears the spectrum as appropriate - spec->clearData(); + spec.clearData(); - const auto dets = spec->getDetectorIDs(); + const auto dets = spec.getDetectorIDs(); for (auto detId : dets) { try { if (const Geometry::Detector *det = @@ -1613,7 +1602,7 @@ void MatrixWorkspace::saveSpectraMapNexus( std::size_t nDetectors = 0; for (auto index : spec) { nDetectors += - this->getSpectrum(static_cast<size_t>(index))->getDetectorIDs().size(); + this->getSpectrum(static_cast<size_t>(index)).getDetectorIDs().size(); } if (nDetectors < 1) { @@ -1643,11 +1632,11 @@ void MatrixWorkspace::saveSpectraMapNexus( // Workspace index int si = spec[i]; // Spectrum there - const ISpectrum *spectrum = this->getSpectrum(si); - spectra[i] = int32_t(spectrum->getSpectrumNo()); + const auto &spectrum = this->getSpectrum(si); + spectra[i] = int32_t(spectrum.getSpectrumNo()); // The detectors in this spectrum - const auto &detectorgroup = spectrum->getDetectorIDs(); + const auto &detectorgroup = spectrum.getDetectorIDs(); const int ndet1 = static_cast<int>(detectorgroup.size()); detector_index[i + 1] = int32_t( diff --git a/Framework/API/src/SpectraAxis.cpp b/Framework/API/src/SpectraAxis.cpp index 4c49ffce0ef3be6704db45bfe8c1bad92cf1c91a..b7e55234a2ffcf4182c75f82a0d61436267af1a3 100644 --- a/Framework/API/src/SpectraAxis.cpp +++ b/Framework/API/src/SpectraAxis.cpp @@ -67,7 +67,7 @@ double SpectraAxis::operator()(const std::size_t &index, "SpectraAxis: Index out of range."); } - return static_cast<double>(m_parentWS->getSpectrum(index)->getSpectrumNo()); + return static_cast<double>(m_parentWS->getSpectrum(index).getSpectrumNo()); } /** Sets the axis value at a given position @@ -115,7 +115,7 @@ specnum_t SpectraAxis::spectraNo(const std::size_t &index) const { "SpectraAxis: Index out of range."); } - return m_parentWS->getSpectrum(index)->getSpectrumNo(); + return m_parentWS->getSpectrum(index).getSpectrumNo(); } /** Returns a map where spectra is the key and index is the value @@ -129,7 +129,7 @@ spec2index_map SpectraAxis::getSpectraIndexMap() const { throw std::runtime_error("getSpectraIndexMap(), zero elements"); spec2index_map map; for (size_t i = 0; i < nel; ++i) { - map.emplace(m_parentWS->getSpectrum(i)->getSpectrumNo(), i); + map.emplace(m_parentWS->getSpectrum(i).getSpectrumNo(), i); } return map; } @@ -165,12 +165,12 @@ std::string SpectraAxis::label(const std::size_t &index) const { /// returns min value defined on axis double SpectraAxis::getMin() const { - return m_parentWS->getSpectrum(0)->getSpectrumNo(); + return m_parentWS->getSpectrum(0).getSpectrumNo(); } /// returns max value defined on axis double SpectraAxis::getMax() const { - return m_parentWS->getSpectrum(length() - 1)->getSpectrumNo(); + return m_parentWS->getSpectrum(length() - 1).getSpectrumNo(); } } // namespace API diff --git a/Framework/API/src/SpectrumDetectorMapping.cpp b/Framework/API/src/SpectrumDetectorMapping.cpp index f9bb4e3b4f2c18387fc40e718cebad4d889138e8..cd4452dad90efa5b6646c93d46f80e8334bafad8 100644 --- a/Framework/API/src/SpectrumDetectorMapping.cpp +++ b/Framework/API/src/SpectrumDetectorMapping.cpp @@ -16,15 +16,15 @@ SpectrumDetectorMapping::SpectrumDetectorMapping( } for (size_t i = 0; i < workspace->getNumberHistograms(); ++i) { - auto spectrum = workspace->getSpectrum(i); + auto &spectrum = workspace->getSpectrum(i); int index; if (m_indexIsSpecNo) - index = spectrum->getSpectrumNo(); + index = spectrum.getSpectrumNo(); else index = static_cast<int>(i); - m_mapping[index] = spectrum->getDetectorIDs(); + m_mapping[index] = spectrum.getDetectorIDs(); } } diff --git a/Framework/API/src/WorkspaceFactory.cpp b/Framework/API/src/WorkspaceFactory.cpp index 33afa07c9f2de7e6c6937b3bd51a0b42df1b4a42..93671a3f16da44f14b02f3940c1ffa055657137c 100644 --- a/Framework/API/src/WorkspaceFactory.cpp +++ b/Framework/API/src/WorkspaceFactory.cpp @@ -111,10 +111,10 @@ void WorkspaceFactoryImpl::initializeFromParent( // Same number of histograms = copy over the spectra data if (parent->getNumberHistograms() == child->getNumberHistograms()) { for (size_t wi = 0; wi < parent->getNumberHistograms(); wi++) { - ISpectrum *childSpec = child->getSpectrum(wi); - const ISpectrum *parentSpec = parent->getSpectrum(wi); + auto &childSpec = child->getSpectrum(wi); + const auto &parentSpec = parent->getSpectrum(wi); // Copy spectrum number and detector IDs - childSpec->copyInfoFrom(*parentSpec); + childSpec.copyInfoFrom(parentSpec); } } diff --git a/Framework/API/test/CompositeFunctionTest.h b/Framework/API/test/CompositeFunctionTest.h index 822fa68de83220be90626f4a63aacb68166cee5e..ae84a9fa779b91095f42aab6a97f7bd020744c8e 100644 --- a/Framework/API/test/CompositeFunctionTest.h +++ b/Framework/API/test/CompositeFunctionTest.h @@ -65,14 +65,14 @@ public: std::size_t getNumberHistograms() const override { return m_spectra.size(); } /// Return the underlying ISpectrum ptr at the given workspace index. - ISpectrum *getSpectrum(const size_t index) override { - return &m_spectra[index]; + ISpectrum &getSpectrum(const size_t index) override { + return m_spectra[index]; } /// Return the underlying ISpectrum ptr (const version) at the given workspace /// index. - const ISpectrum *getSpectrum(const size_t index) const override { - return &m_spectra[index]; + const ISpectrum &getSpectrum(const size_t index) const override { + return m_spectra[index]; } const std::string id(void) const override { return ""; } void init(const size_t &, const size_t &, const size_t &) override {} diff --git a/Framework/API/test/FunctionTest.h b/Framework/API/test/FunctionTest.h index ee0a7cb900c9f806e782ebfc0148f99a02603419..07a0dbc32e4c4d2be15e344e0ecfdae71c7c3f14 100644 --- a/Framework/API/test/FunctionTest.h +++ b/Framework/API/test/FunctionTest.h @@ -64,14 +64,14 @@ public: std::size_t getNumberHistograms() const override { return m_spectra.size(); } /// Return the underlying ISpectrum ptr at the given workspace index. - ISpectrum *getSpectrum(const size_t index) override { - return &m_spectra[index]; + ISpectrum &getSpectrum(const size_t index) override { + return m_spectra[index]; } /// Return the underlying ISpectrum ptr (const version) at the given workspace /// index. - const ISpectrum *getSpectrum(const size_t index) const override { - return &m_spectra[index]; + const ISpectrum &getSpectrum(const size_t index) const override { + return m_spectra[index]; } const std::string id(void) const override { return ""; } void init(const size_t &, const size_t &, const size_t &) override {} diff --git a/Framework/API/test/GeometryInfoTest.h b/Framework/API/test/GeometryInfoTest.h index 60012d514af496afefa5eee3c84597fd3d1e8279..026839bfd14a12d289b897e2b515c400691394eb 100644 --- a/Framework/API/test/GeometryInfoTest.h +++ b/Framework/API/test/GeometryInfoTest.h @@ -44,48 +44,41 @@ public: void test_constructor() { TS_ASSERT_THROWS_NOTHING( - GeometryInfo(*m_factory, *(m_workspace.getSpectrum(0)))); + GeometryInfo(*m_factory, m_workspace.getSpectrum(0))); } void test_isMonitor() { TS_ASSERT_EQUALS( - GeometryInfo(*m_factory, *(m_workspace.getSpectrum(0))).isMonitor(), + GeometryInfo(*m_factory, m_workspace.getSpectrum(0)).isMonitor(), false); TS_ASSERT_EQUALS( - GeometryInfo(*m_factory, *(m_workspace.getSpectrum(1))).isMonitor(), + GeometryInfo(*m_factory, m_workspace.getSpectrum(1)).isMonitor(), false); TS_ASSERT_EQUALS( - GeometryInfo(*m_factory, *(m_workspace.getSpectrum(2))).isMonitor(), + GeometryInfo(*m_factory, m_workspace.getSpectrum(2)).isMonitor(), false); TS_ASSERT_EQUALS( - GeometryInfo(*m_factory, *(m_workspace.getSpectrum(3))).isMonitor(), - true); + GeometryInfo(*m_factory, m_workspace.getSpectrum(3)).isMonitor(), true); TS_ASSERT_EQUALS( - GeometryInfo(*m_factory, *(m_workspace.getSpectrum(4))).isMonitor(), - true); + GeometryInfo(*m_factory, m_workspace.getSpectrum(4)).isMonitor(), true); } void test_isMasked() { GeometryInfoFactory factory(m_workspace); TS_ASSERT_EQUALS( - GeometryInfo(*m_factory, *(m_workspace.getSpectrum(0))).isMasked(), - true); + GeometryInfo(*m_factory, m_workspace.getSpectrum(0)).isMasked(), true); TS_ASSERT_EQUALS( - GeometryInfo(*m_factory, *(m_workspace.getSpectrum(1))).isMasked(), - false); + GeometryInfo(*m_factory, m_workspace.getSpectrum(1)).isMasked(), false); TS_ASSERT_EQUALS( - GeometryInfo(*m_factory, *(m_workspace.getSpectrum(2))).isMasked(), - false); + GeometryInfo(*m_factory, m_workspace.getSpectrum(2)).isMasked(), false); TS_ASSERT_EQUALS( - GeometryInfo(*m_factory, *(m_workspace.getSpectrum(3))).isMasked(), - true); + GeometryInfo(*m_factory, m_workspace.getSpectrum(3)).isMasked(), true); TS_ASSERT_EQUALS( - GeometryInfo(*m_factory, *(m_workspace.getSpectrum(4))).isMasked(), - false); + GeometryInfo(*m_factory, m_workspace.getSpectrum(4)).isMasked(), false); } void test_getL1() { - auto info = GeometryInfo(*m_factory, *(m_workspace.getSpectrum(0))); + auto info = GeometryInfo(*m_factory, m_workspace.getSpectrum(0)); TS_ASSERT_EQUALS(info.getL1(), 20.0); } @@ -93,48 +86,48 @@ public: double x2 = 5.0 * 5.0; double y2 = 2.0 * 2.0 * 0.05 * 0.05; TS_ASSERT_EQUALS( - GeometryInfo(*m_factory, *(m_workspace.getSpectrum(0))).getL2(), + GeometryInfo(*m_factory, m_workspace.getSpectrum(0)).getL2(), sqrt(x2 + 1 * 1 * y2)); TS_ASSERT_EQUALS( - GeometryInfo(*m_factory, *(m_workspace.getSpectrum(1))).getL2(), + GeometryInfo(*m_factory, m_workspace.getSpectrum(1)).getL2(), sqrt(x2 + 0 * 0 * y2)); TS_ASSERT_EQUALS( - GeometryInfo(*m_factory, *(m_workspace.getSpectrum(2))).getL2(), + GeometryInfo(*m_factory, m_workspace.getSpectrum(2)).getL2(), sqrt(x2 + 1 * 1 * y2)); TS_ASSERT_EQUALS( - GeometryInfo(*m_factory, *(m_workspace.getSpectrum(3))).getL2(), -9.0); + GeometryInfo(*m_factory, m_workspace.getSpectrum(3)).getL2(), -9.0); TS_ASSERT_EQUALS( - GeometryInfo(*m_factory, *(m_workspace.getSpectrum(4))).getL2(), -2.0); + GeometryInfo(*m_factory, m_workspace.getSpectrum(4)).getL2(), -2.0); } void test_getTwoTheta() { TS_ASSERT_DELTA( - GeometryInfo(*m_factory, *(m_workspace.getSpectrum(0))).getTwoTheta(), + GeometryInfo(*m_factory, m_workspace.getSpectrum(0)).getTwoTheta(), 0.0199973, 1e-6); TS_ASSERT_DELTA( - GeometryInfo(*m_factory, *(m_workspace.getSpectrum(1))).getTwoTheta(), - 0.0, 1e-6); + GeometryInfo(*m_factory, m_workspace.getSpectrum(1)).getTwoTheta(), 0.0, + 1e-6); TS_ASSERT_DELTA( - GeometryInfo(*m_factory, *(m_workspace.getSpectrum(2))).getTwoTheta(), + GeometryInfo(*m_factory, m_workspace.getSpectrum(2)).getTwoTheta(), 0.0199973, 1e-6); } // Legacy test via the workspace method detectorTwoTheta(), which might be // removed at some point. void test_getTwoThetaLegacy() { - auto info = GeometryInfo(*m_factory, *(m_workspace.getSpectrum(2))); + auto info = GeometryInfo(*m_factory, m_workspace.getSpectrum(2)); auto det = info.getDetector(); TS_ASSERT_EQUALS(info.getTwoTheta(), m_workspace.detectorTwoTheta(*det)); } void test_getSignedTwoTheta() { - TS_ASSERT_DELTA(GeometryInfo(*m_factory, *(m_workspace.getSpectrum(0))) + TS_ASSERT_DELTA(GeometryInfo(*m_factory, m_workspace.getSpectrum(0)) .getSignedTwoTheta(), -0.0199973, 1e-6); - TS_ASSERT_DELTA(GeometryInfo(*m_factory, *(m_workspace.getSpectrum(1))) + TS_ASSERT_DELTA(GeometryInfo(*m_factory, m_workspace.getSpectrum(1)) .getSignedTwoTheta(), 0.0, 1e-6); - TS_ASSERT_DELTA(GeometryInfo(*m_factory, *(m_workspace.getSpectrum(2))) + TS_ASSERT_DELTA(GeometryInfo(*m_factory, m_workspace.getSpectrum(2)) .getSignedTwoTheta(), 0.0199973, 1e-6); } @@ -142,7 +135,7 @@ public: // Legacy test via the workspace method detectorSignedTwoTheta(), which might // be removed at some point. void test_getSignedTwoThetaLegacy() { - auto info = GeometryInfo(*m_factory, *(m_workspace.getSpectrum(2))); + auto info = GeometryInfo(*m_factory, m_workspace.getSpectrum(2)); auto det = info.getDetector(); TS_ASSERT_EQUALS(info.getSignedTwoTheta(), m_workspace.detectorSignedTwoTheta(*det)); diff --git a/Framework/API/test/IMDWorkspaceTest.h b/Framework/API/test/IMDWorkspaceTest.h index cf412a40b3baad77c62f6c8a62decefb5a7bcb1f..70eb6df9e6e058abc0490f1a8f8a756601de7b15 100644 --- a/Framework/API/test/IMDWorkspaceTest.h +++ b/Framework/API/test/IMDWorkspaceTest.h @@ -33,8 +33,8 @@ public: IMDWorkspaceTest() { workspace.setTitle("workspace"); workspace.initialize(2, 4, 3); - workspace.getSpectrum(0)->setSpectrumNo(1); - workspace.getSpectrum(1)->setSpectrumNo(2); + workspace.getSpectrum(0).setSpectrumNo(1); + workspace.getSpectrum(1).setSpectrumNo(2); for (int i = 0; i < 4; ++i) { workspace.dataX(0)[i] = i; workspace.dataX(1)[i] = i + 4; diff --git a/Framework/API/test/MatrixWorkspaceMDIteratorTest.h b/Framework/API/test/MatrixWorkspaceMDIteratorTest.h index 540be6fdd83702cbf0d24faa980ea52c57950c0b..529f977705a839f4f05b73b8ed14446e989dcd57 100644 --- a/Framework/API/test/MatrixWorkspaceMDIteratorTest.h +++ b/Framework/API/test/MatrixWorkspaceMDIteratorTest.h @@ -41,7 +41,7 @@ public: new Detector("pixel", static_cast<detid_t>(i), inst.get()); inst->add(det); inst->markAsDetector(det); - ws->getSpectrum(i)->addDetectorID(static_cast<detid_t>(i)); + ws->getSpectrum(i).addDetectorID(static_cast<detid_t>(i)); } ws->replaceAxis(1, ax1); diff --git a/Framework/API/test/MatrixWorkspaceTest.h b/Framework/API/test/MatrixWorkspaceTest.h index 884662da98612a0e0d6c73ffa8391ccc2851e818..e79cd7976c3d87b89d576be59432a5e16cedbe56 100644 --- a/Framework/API/test/MatrixWorkspaceTest.h +++ b/Framework/API/test/MatrixWorkspaceTest.h @@ -55,7 +55,7 @@ boost::shared_ptr<MatrixWorkspace> makeWorkspaceWithDetectors(size_t numSpectra, Detector *det = new Detector("pixel", static_cast<detid_t>(i), inst.get()); inst->add(det); inst->markAsDetector(det); - ws2->getSpectrum(i)->addDetectorID(static_cast<detid_t>(i)); + ws2->getSpectrum(i).addDetectorID(static_cast<detid_t>(i)); } return ws2; } @@ -113,7 +113,7 @@ public: WorkspaceTester ws; ws.initialize(10, 1, 1); for (size_t i = 0; i < 10; i++) - ws.getSpectrum(i)->setDetectorID(detid_t(i * 10)); + ws.getSpectrum(i).setDetectorID(detid_t(i * 10)); std::vector<detid_t> dets; dets.push_back(60); dets.push_back(20); @@ -131,9 +131,8 @@ public: const size_t nhist(10); testWS.initialize(nhist, 1, 1); for (size_t i = 0; i < testWS.getNumberHistograms(); i++) { - TS_ASSERT_EQUALS(testWS.getSpectrum(i)->getSpectrumNo(), - specnum_t(i + 1)); - TS_ASSERT(testWS.getSpectrum(i)->hasDetectorID(detid_t(i))); + TS_ASSERT_EQUALS(testWS.getSpectrum(i).getSpectrumNo(), specnum_t(i + 1)); + TS_ASSERT(testWS.getSpectrum(i).hasDetectorID(detid_t(i))); } } @@ -146,23 +145,23 @@ public: TS_ASSERT_THROWS_NOTHING( testWS.updateSpectraUsing(SpectrumDetectorMapping(specs, detids, 4))); - TS_ASSERT(testWS.getSpectrum(0)->hasDetectorID(10)); - TS_ASSERT(testWS.getSpectrum(1)->hasDetectorID(20)); - TS_ASSERT(testWS.getSpectrum(1)->hasDetectorID(99)); - TS_ASSERT(testWS.getSpectrum(2)->hasDetectorID(30)); + TS_ASSERT(testWS.getSpectrum(0).hasDetectorID(10)); + TS_ASSERT(testWS.getSpectrum(1).hasDetectorID(20)); + TS_ASSERT(testWS.getSpectrum(1).hasDetectorID(99)); + TS_ASSERT(testWS.getSpectrum(2).hasDetectorID(30)); } void testDetectorMappingCopiedWhenAWorkspaceIsCopied() { boost::shared_ptr<MatrixWorkspace> parent = boost::make_shared<WorkspaceTester>(); parent->initialize(1, 1, 1); - parent->getSpectrum(0)->setSpectrumNo(99); - parent->getSpectrum(0)->setDetectorID(999); + parent->getSpectrum(0).setSpectrumNo(99); + parent->getSpectrum(0).setDetectorID(999); MatrixWorkspace_sptr copied = WorkspaceFactory::Instance().create(parent); // Has it been copied? - TS_ASSERT_EQUALS(copied->getSpectrum(0)->getSpectrumNo(), 99); - TS_ASSERT(copied->getSpectrum(0)->hasDetectorID(999)); + TS_ASSERT_EQUALS(copied->getSpectrum(0).getSpectrumNo(), 99); + TS_ASSERT(copied->getSpectrum(0).hasDetectorID(999)); } void testGetMemorySize() { TS_ASSERT_THROWS_NOTHING(ws->getMemorySize()); } @@ -201,11 +200,8 @@ public: void testGetSpectrum() { WorkspaceTester ws; ws.initialize(4, 1, 1); - ISpectrum *spec = NULL; - TS_ASSERT_THROWS_NOTHING(spec = ws.getSpectrum(0)); - TS_ASSERT(spec); - TS_ASSERT_THROWS_NOTHING(spec = ws.getSpectrum(3)); - TS_ASSERT(spec); + TS_ASSERT_THROWS_NOTHING(ws.getSpectrum(0)); + TS_ASSERT_THROWS_NOTHING(ws.getSpectrum(3)); } /** Get a detector sptr for each spectrum */ @@ -227,16 +223,16 @@ public: } // Now a detector group - ISpectrum *spec = workspace->getSpectrum(0); - spec->addDetectorID(1); - spec->addDetectorID(2); + auto &spec = workspace->getSpectrum(0); + spec.addDetectorID(1); + spec.addDetectorID(2); IDetector_const_sptr det; TS_ASSERT_THROWS_NOTHING(det = workspace->getDetector(0)); TS_ASSERT(det); // Now an empty (no detector) pixel - spec = workspace->getSpectrum(1); - spec->clearDetectorIDs(); + auto &spec2 = workspace->getSpectrum(1); + spec2.clearDetectorIDs(); IDetector_const_sptr det2; TS_ASSERT_THROWS_ANYTHING(det2 = workspace->getDetector(1)); TS_ASSERT(!det2); @@ -396,8 +392,8 @@ public: std::vector<int> spec; for (int i = 0; i < 100; i++) { // Give some funny numbers, so it is not the default - ws->getSpectrum(size_t(i))->setSpectrumNo(i * 11); - ws->getSpectrum(size_t(i))->setDetectorID(99 - i); + ws->getSpectrum(size_t(i)).setSpectrumNo(i * 11); + ws->getSpectrum(size_t(i)).setDetectorID(99 - i); spec.push_back(i); } // Save that to the NXS file @@ -529,7 +525,7 @@ public: TS_ASSERT(!inst->isDetectorMasked(1)); TS_ASSERT(!inst->isDetectorMasked(19)); // Mask then check that it returns as masked - TS_ASSERT(ws->getSpectrum(19)->hasDetectorID(19)); + TS_ASSERT(ws->getSpectrum(19).hasDetectorID(19)); ws->maskWorkspaceIndex(19); TS_ASSERT(inst->isDetectorMasked(19)); } @@ -571,7 +567,7 @@ public: auto ws = makeWorkspaceWithDetectors(5, 1); TS_ASSERT_EQUALS(ws->hasGroupedDetectors(), false); - ws->getSpectrum(0)->addDetectorID(3); + ws->getSpectrum(0).addDetectorID(3); TS_ASSERT_EQUALS(ws->hasGroupedDetectors(), true); } @@ -601,7 +597,7 @@ public: TS_ASSERT_EQUALS(idmap[i], i); } - ws->getSpectrum(2)->addDetectorID(99); // Set a second ID on one spectrum + ws->getSpectrum(2).addDetectorID(99); // Set a second ID on one spectrum TS_ASSERT_THROWS(ws->getDetectorIDToWorkspaceIndexMap(true), std::runtime_error); detid2index_map idmap2 = ws->getDetectorIDToWorkspaceIndexMap(); @@ -638,9 +634,9 @@ public: Detector *det = new Detector("pixel", detid, inst.get()); inst->add(det); inst->markAsDetector(det); - ws->getSpectrum(i)->addDetectorID(detid); + ws->getSpectrum(i).addDetectorID(detid); } - ws->getSpectrum(66)->clearDetectorIDs(); + ws->getSpectrum(66).clearDetectorIDs(); TS_ASSERT_THROWS_NOTHING( out = ws->getDetectorIDToWorkspaceIndexVector(offset)); diff --git a/Framework/API/test/SpectrumDetectorMappingTest.h b/Framework/API/test/SpectrumDetectorMappingTest.h index 6fd166b6656895d6b7d156f6ba31cfb744c18e4a..47c1b572d0362d83989ee1bb17a3f546a7b89a71 100644 --- a/Framework/API/test/SpectrumDetectorMappingTest.h +++ b/Framework/API/test/SpectrumDetectorMappingTest.h @@ -27,9 +27,9 @@ public: auto ws = boost::make_shared<WorkspaceTester>(); ws->init(3, 1, 1); // Override some of the default detector numbers to make it more interesting - ws->getSpectrum(0)->setDetectorIDs(std::set<detid_t>()); + ws->getSpectrum(0).setDetectorIDs(std::set<detid_t>()); int detids[] = {10, 20}; - ws->getSpectrum(2)->setDetectorIDs(std::set<detid_t>(detids, detids + 2)); + ws->getSpectrum(2).setDetectorIDs(std::set<detid_t>(detids, detids + 2)); SpectrumDetectorMapping map(ws.get()); TS_ASSERT(map.getDetectorIDsForSpectrumNo(1).empty()); diff --git a/Framework/API/test/WorkspaceFactoryTest.h b/Framework/API/test/WorkspaceFactoryTest.h index 589a547511d4885b01d48c03a83fbf44d74f87a6..75d5d2ba0ee689bef64ab176d25adde69d53da30 100644 --- a/Framework/API/test/WorkspaceFactoryTest.h +++ b/Framework/API/test/WorkspaceFactoryTest.h @@ -67,9 +67,9 @@ public: void testCreateFromParent() { MatrixWorkspace_sptr ws_child(new Workspace1DTest); ws_child->initialize(3, 1, 1); - ws_child->getSpectrum(0)->setSpectrumNo(123); - ws_child->getSpectrum(1)->setDetectorID(456); - ws_child->getSpectrum(2)->dataY()[0] = 789; + ws_child->getSpectrum(0).setSpectrumNo(123); + ws_child->getSpectrum(1).setDetectorID(456); + ws_child->getSpectrum(2).dataY()[0] = 789; ws_child->mutableRun().addProperty("Ei", 12.0); ws_child->mutableSample().setName("MySample"); @@ -80,9 +80,9 @@ public: TS_ASSERT_THROWS_NOTHING(child = WorkspaceFactory::Instance().create(ws_child)); TS_ASSERT_EQUALS(child->id(), "Workspace1DTest"); - TS_ASSERT_EQUALS(child->getSpectrum(0)->getSpectrumNo(), 123); - TS_ASSERT_EQUALS(*child->getSpectrum(1)->getDetectorIDs().begin(), 456); - TS_ASSERT_DIFFERS(child->getSpectrum(2)->dataY()[0], 789); + TS_ASSERT_EQUALS(child->getSpectrum(0).getSpectrumNo(), 123); + TS_ASSERT_EQUALS(*child->getSpectrum(1).getDetectorIDs().begin(), 456); + TS_ASSERT_DIFFERS(child->getSpectrum(2).dataY()[0], 789); // run/logs double ei(0.0); diff --git a/Framework/API/test/WorkspaceOpOverloadsTest.h b/Framework/API/test/WorkspaceOpOverloadsTest.h index 24f2210689a4a87a5e927af8a57748952c3b3a58..810c0db760616bb4679ab3d234a13b14c195018a 100644 --- a/Framework/API/test/WorkspaceOpOverloadsTest.h +++ b/Framework/API/test/WorkspaceOpOverloadsTest.h @@ -55,10 +55,10 @@ public: { auto ws = boost::make_shared<WorkspaceTester>(); ws->init(2, 2, 1); - ws->getSpectrum(0)->dataX()[0] = -2.0; - ws->getSpectrum(0)->dataX()[1] = -1.0; - ws->getSpectrum(1)->dataX()[0] = -2.5; - ws->getSpectrum(1)->dataX()[1] = -1.5; + ws->getSpectrum(0).dataX()[0] = -2.0; + ws->getSpectrum(0).dataX()[1] = -1.0; + ws->getSpectrum(1).dataX()[0] = -2.5; + ws->getSpectrum(1).dataX()[1] = -1.5; TS_ASSERT(!WorkspaceHelpers::commonBoundaries(ws)); } @@ -119,21 +119,21 @@ public: { auto ws1 = boost::make_shared<WorkspaceTester>(); ws1->init(2, 2, 1); - ws1->getSpectrum(1)->dataX()[0] = -2.5; - ws1->getSpectrum(1)->dataX()[1] = -1.5; + ws1->getSpectrum(1).dataX()[0] = -2.5; + ws1->getSpectrum(1).dataX()[1] = -1.5; auto ws2 = boost::make_shared<WorkspaceTester>(); ws2->init(2, 2, 1); - ws2->getSpectrum(1)->dataX()[0] = -2.7; - ws2->getSpectrum(1)->dataX()[1] = -1.7; + ws2->getSpectrum(1).dataX()[0] = -2.7; + ws2->getSpectrum(1).dataX()[1] = -1.7; TS_ASSERT(WorkspaceHelpers::matchingBins(ws1, ws2, true)); TS_ASSERT(!WorkspaceHelpers::matchingBins(ws1, ws2)); - ws1->getSpectrum(0)->dataX()[0] = -2.0; - ws1->getSpectrum(0)->dataX()[1] = -1.0; - ws2->getSpectrum(0)->dataX()[0] = -3.0; - ws2->getSpectrum(0)->dataX()[1] = -4.0; + ws1->getSpectrum(0).dataX()[0] = -2.0; + ws1->getSpectrum(0).dataX()[1] = -1.0; + ws2->getSpectrum(0).dataX()[0] = -3.0; + ws2->getSpectrum(0).dataX()[1] = -4.0; TS_ASSERT(!WorkspaceHelpers::matchingBins(ws1, ws2, true)); } @@ -144,7 +144,7 @@ public: // By default the X vectors are different ones TS_ASSERT(!WorkspaceHelpers::sharedXData(ws)); // Force both X spectra to point to the same underlying vector - ws->getSpectrum(1)->setX(ws->getSpectrum(0)->ptrX()); + ws->getSpectrum(1).setX(ws->getSpectrum(0).ptrX()); TS_ASSERT(WorkspaceHelpers::sharedXData(ws)); } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/EventWorkspaceAccess.h b/Framework/Algorithms/inc/MantidAlgorithms/EventWorkspaceAccess.h index 9cdec8650e8f4e011a944c328c61f51d1e24fb7c..a3d6ff6cadfac59f5c1c7cbef93ea239a8b426d5 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/EventWorkspaceAccess.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/EventWorkspaceAccess.h @@ -9,7 +9,7 @@ struct EventWorkspaceAccess { static decltype( std::mem_fn((DataObjects::EventList & (DataObjects::EventWorkspace::*)(const std::size_t)) & - DataObjects::EventWorkspace::getEventList)) eventList; + DataObjects::EventWorkspace::getSpectrum)) eventList; }; } } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/SumSpectra.h b/Framework/Algorithms/inc/MantidAlgorithms/SumSpectra.h index a6e781afe36434678ba8292457c5199ac3f063da..57fc7be2625dc8875f8ec56c3e02bf599d23cf11 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/SumSpectra.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/SumSpectra.h @@ -83,7 +83,7 @@ private: size_t &numMasked, size_t &numZeros); /// Handle logic for Workspace2D workspaces void doWorkspace2D(API::MatrixWorkspace_const_sptr localworkspace, - API::ISpectrum *outSpec, API::Progress &progress, + API::ISpectrum &outSpec, API::Progress &progress, size_t &numSpectra, size_t &numMasked, size_t &numZeros); // Overridden Algorithm methods diff --git a/Framework/Algorithms/src/AlignDetectors.cpp b/Framework/Algorithms/src/AlignDetectors.cpp index 1efc17ce3659f37e8b61055885d4708b80fbe2f6..8c0ac6d5fcc0321550f70784a59d1982f12ca731 100644 --- a/Framework/Algorithms/src/AlignDetectors.cpp +++ b/Framework/Algorithms/src/AlignDetectors.cpp @@ -329,8 +329,8 @@ void AlignDetectors::exec() { PARALLEL_START_INTERUPT_REGION try { // Get the input spectrum number at this workspace index - auto inSpec = inputWS->getSpectrum(size_t(i)); - auto toDspacing = converter.getConversionFunc(inSpec->getDetectorIDs()); + auto &inSpec = inputWS->getSpectrum(size_t(i)); + auto toDspacing = converter.getConversionFunc(inSpec.getDetectorIDs()); // Get references to the x data MantidVec &xOut = outputWS->dataX(i); @@ -339,13 +339,13 @@ void AlignDetectors::exec() { // because in the case // where the input & output workspaces are the same, it might move if the // vectors were shared. - const MantidVec &xIn = inSpec->readX(); + const MantidVec &xIn = inSpec.readX(); std::transform(xIn.begin(), xIn.end(), xOut.begin(), toDspacing); // Copy the Y&E data - outputWS->dataY(i) = inSpec->readY(); - outputWS->dataE(i) = inSpec->readE(); + outputWS->dataY(i) = inSpec.readY(); + outputWS->dataE(i) = inSpec.readE(); } catch (Exception::NotFoundError &) { // Zero the data in this case @@ -388,8 +388,8 @@ void AlignDetectors::execEvent() { PARALLEL_START_INTERUPT_REGION auto toDspacing = converter.getConversionFunc( - outputWS->getSpectrum(size_t(i))->getDetectorIDs()); - outputWS->getEventList(i).convertTof(toDspacing); + outputWS->getSpectrum(size_t(i)).getDetectorIDs()); + outputWS->getSpectrum(i).convertTof(toDspacing); progress.report(); PARALLEL_END_INTERUPT_REGION diff --git a/Framework/Algorithms/src/AppendSpectra.cpp b/Framework/Algorithms/src/AppendSpectra.cpp index 77546f29a75c6b9a88a0423d397bb34ae626980e..34dae96925fb9341e83e5ac645bfaa329dbe2c1b 100644 --- a/Framework/Algorithms/src/AppendSpectra.cpp +++ b/Framework/Algorithms/src/AppendSpectra.cpp @@ -141,7 +141,7 @@ void AppendSpectra::fixSpectrumNumbers(API::MatrixWorkspace_const_sptr ws1, // change the axis by adding the maximum existing spectrum number to the // current value for (size_t i = 0; i < output->getNumberHistograms(); i++) - output->getSpectrum(i)->setSpectrumNo(specnum_t(i)); + output->getSpectrum(i).setSpectrumNo(specnum_t(i)); } void AppendSpectra::combineLogs(const API::Run &lhs, const API::Run &rhs, diff --git a/Framework/Algorithms/src/BinaryOperation.cpp b/Framework/Algorithms/src/BinaryOperation.cpp index 53064a962e493e3182f016c6a64d8eb280309422..6b0529bc3774f5d997c89583dfd608708d3f3679 100644 --- a/Framework/Algorithms/src/BinaryOperation.cpp +++ b/Framework/Algorithms/src/BinaryOperation.cpp @@ -498,7 +498,7 @@ void BinaryOperation::doSingleValue() { for (int64_t i = 0; i < numHists; ++i) { PARALLEL_START_INTERUPT_REGION m_out->setX(i, m_lhs->refX(i)); - performEventBinaryOperation(m_eout->getEventList(i), rhsY, rhsE); + performEventBinaryOperation(m_eout->getSpectrum(i), rhsY, rhsE); m_progress->report(this->name()); PARALLEL_END_INTERUPT_REGION } @@ -547,7 +547,7 @@ void BinaryOperation::doSingleColumn() { // m_out->setX(i, m_lhs->refX(i)); //unnecessary - that was copied before. if (propagateSpectraMask(m_lhs, m_rhs, i, m_out)) { - performEventBinaryOperation(m_eout->getEventList(i), rhsY, rhsE); + performEventBinaryOperation(m_eout->getSpectrum(i), rhsY, rhsE); } m_progress->report(this->name()); PARALLEL_END_INTERUPT_REGION @@ -596,7 +596,7 @@ void BinaryOperation::doSingleSpectrum() { // -------- The rhs is ALSO an EventWorkspace -------- // Pull out the single eventList on the right - const EventList &rhs_spectrum = m_erhs->getEventList(0); + const EventList &rhs_spectrum = m_erhs->getSpectrum(0); // Now loop over the spectra of the left hand side calling the virtual // function @@ -608,7 +608,7 @@ void BinaryOperation::doSingleSpectrum() { // before. // Perform the operation on the event list on the output (== lhs) - performEventBinaryOperation(m_eout->getEventList(i), rhs_spectrum); + performEventBinaryOperation(m_eout->getSpectrum(i), rhs_spectrum); m_progress->report(this->name()); PARALLEL_END_INTERUPT_REGION } @@ -630,7 +630,7 @@ void BinaryOperation::doSingleSpectrum() { // m_out->setX(i,m_lhs->refX(i)); //unnecessary - that was copied // before. // Perform the operation on the event list on the output (== lhs) - performEventBinaryOperation(m_eout->getEventList(i), rhsX, rhsY, rhsE); + performEventBinaryOperation(m_eout->getSpectrum(i), rhsX, rhsY, rhsE); m_progress->report(this->name()); PARALLEL_END_INTERUPT_REGION } @@ -712,12 +712,12 @@ void BinaryOperation::do2D(bool mismatchedSpectra) { } // Reach here? Do the division // Perform the operation on the event list on the output (== lhs) - performEventBinaryOperation(m_eout->getEventList(i), - m_erhs->getEventList(rhs_wi)); + performEventBinaryOperation(m_eout->getSpectrum(i), + m_erhs->getSpectrum(rhs_wi)); // Free up memory on the RHS if that is possible if (m_ClearRHSWorkspace) - const_cast<EventList &>(m_erhs->getEventList(rhs_wi)).clear(); + const_cast<EventList &>(m_erhs->getSpectrum(rhs_wi)).clear(); PARALLEL_END_INTERUPT_REGION } PARALLEL_CHECK_INTERUPT_REGION @@ -744,13 +744,13 @@ void BinaryOperation::do2D(bool mismatchedSpectra) { } // Reach here? Do the division - performEventBinaryOperation(m_eout->getEventList(i), + performEventBinaryOperation(m_eout->getSpectrum(i), m_rhs->readX(rhs_wi), m_rhs->readY(rhs_wi), m_rhs->readE(rhs_wi)); // Free up memory on the RHS if that is possible if (m_ClearRHSWorkspace) - const_cast<EventList &>(m_erhs->getEventList(rhs_wi)).clear(); + const_cast<EventList &>(m_erhs->getSpectrum(rhs_wi)).clear(); PARALLEL_END_INTERUPT_REGION } @@ -793,7 +793,7 @@ void BinaryOperation::do2D(bool mismatchedSpectra) { // Free up memory on the RHS if that is possible if (m_ClearRHSWorkspace) - const_cast<EventList &>(m_erhs->getEventList(rhs_wi)).clear(); + const_cast<EventList &>(m_erhs->getSpectrum(rhs_wi)).clear(); PARALLEL_END_INTERUPT_REGION } @@ -1002,8 +1002,7 @@ BinaryOperation::buildBinaryOperationTable( bool done = false; // List of detectors on lhs side - const std::set<detid_t> &lhsDets = - lhs->getSpectrum(lhsWI)->getDetectorIDs(); + const auto &lhsDets = lhs->getSpectrum(lhsWI).getDetectorIDs(); // ----------------- Matching Workspace Indices and Detector IDs // -------------------------------------- @@ -1013,8 +1012,7 @@ BinaryOperation::buildBinaryOperationTable( if (rhsWI < rhs_nhist) // don't go out of bounds { // Get the detector IDs at that workspace index. - const std::set<detid_t> &rhsDets = - rhs->getSpectrum(rhsWI)->getDetectorIDs(); + const auto &rhsDets = rhs->getSpectrum(rhsWI).getDetectorIDs(); // Checks that lhsDets is a subset of rhsDets if (std::includes(rhsDets.begin(), rhsDets.end(), lhsDets.begin(), @@ -1062,8 +1060,7 @@ BinaryOperation::buildBinaryOperationTable( // match the detector ID. // NOTE: This can be SUPER SLOW! for (rhsWI = 0; rhsWI < static_cast<int64_t>(rhs_nhist); rhsWI++) { - const std::set<detid_t> &rhsDets = - rhs->getSpectrum(rhsWI)->getDetectorIDs(); + const auto &rhsDets = rhs->getSpectrum(rhsWI).getDetectorIDs(); // Checks that lhsDets is a subset of rhsDets if (std::includes(rhsDets.begin(), rhsDets.end(), lhsDets.begin(), diff --git a/Framework/Algorithms/src/ChangePulsetime.cpp b/Framework/Algorithms/src/ChangePulsetime.cpp index 888a723c75732303ebf572327d8b9b8983d20215..3fb6fa3d349259b2108ab3c2cae36b0cb07dd12e 100644 --- a/Framework/Algorithms/src/ChangePulsetime.cpp +++ b/Framework/Algorithms/src/ChangePulsetime.cpp @@ -78,7 +78,7 @@ void ChangePulsetime::exec() { wi = workspaceIndices[i]; // Call the method on the event list - out_ws->getEventList(wi).addPulsetime(timeOffset); + out_ws->getSpectrum(wi).addPulsetime(timeOffset); prog.report(name()); } diff --git a/Framework/Algorithms/src/CompareWorkspaces.cpp b/Framework/Algorithms/src/CompareWorkspaces.cpp index fad3d10c75ffb8d711013e19ca0de650eccc1e8e..75b61a33fcba7d44e74008c28db44500c37c14fe 100644 --- a/Framework/Algorithms/src/CompareWorkspaces.cpp +++ b/Framework/Algorithms/src/CompareWorkspaces.cpp @@ -449,8 +449,8 @@ bool CompareWorkspaces::compareEventWorkspaces( if (!mismatchedEvent || checkallspectra) // This guard will avoid checking unnecessarily { - const EventList &el1 = ews1.getEventList(i); - const EventList &el2 = ews2.getEventList(i); + const EventList &el1 = ews1.getSpectrum(i); + const EventList &el2 = ews2.getSpectrum(i); bool printdetail = (i == wsindex2print); if (printdetail) { g_log.information() << "Spectrum " << i @@ -727,23 +727,23 @@ bool CompareWorkspaces::checkSpectraMap(MatrixWorkspace_const_sptr ws1, } for (size_t i = 0; i < ws1->getNumberHistograms(); i++) { - const ISpectrum *spec1 = ws1->getSpectrum(i); - const ISpectrum *spec2 = ws2->getSpectrum(i); - if (spec1->getSpectrumNo() != spec2->getSpectrumNo()) { + const auto &spec1 = ws1->getSpectrum(i); + const auto &spec2 = ws2->getSpectrum(i); + if (spec1.getSpectrumNo() != spec2.getSpectrumNo()) { recordMismatch("Spectrum number mismatch"); return false; } - if (spec1->getDetectorIDs().size() != spec2->getDetectorIDs().size()) { + if (spec1.getDetectorIDs().size() != spec2.getDetectorIDs().size()) { std::ostringstream out; out << "Number of detector IDs mismatch: " - << spec1->getDetectorIDs().size() << " vs " - << spec2->getDetectorIDs().size() << " at workspace index " << i; + << spec1.getDetectorIDs().size() << " vs " + << spec2.getDetectorIDs().size() << " at workspace index " << i; recordMismatch(out.str()); return false; } - auto it2 = spec2->getDetectorIDs().cbegin(); - for (auto it1 = spec1->getDetectorIDs().cbegin(); - it1 != spec1->getDetectorIDs().cend(); ++it1, ++it2) { + auto it2 = spec2.getDetectorIDs().cbegin(); + for (auto it1 = spec1.getDetectorIDs().cbegin(); + it1 != spec1.getDetectorIDs().cend(); ++it1, ++it2) { if (*it1 != *it2) { recordMismatch("Detector IDs mismatch"); return false; diff --git a/Framework/Algorithms/src/ConjoinWorkspaces.cpp b/Framework/Algorithms/src/ConjoinWorkspaces.cpp index 863f1f71003cfb82614b180d27c6042cfeca30ff..9d185bf89a2d839ce27d7cb796f75c3a5bf3c9ba 100644 --- a/Framework/Algorithms/src/ConjoinWorkspaces.cpp +++ b/Framework/Algorithms/src/ConjoinWorkspaces.cpp @@ -120,10 +120,10 @@ void ConjoinWorkspaces::checkForOverlap(API::MatrixWorkspace_const_sptr ws1, std::set<detid_t> detectors; const size_t &nhist1 = ws1->getNumberHistograms(); for (size_t i = 0; i < nhist1; ++i) { - const ISpectrum *spec = ws1->getSpectrum(i); - const specnum_t spectrum = spec->getSpectrumNo(); + const auto &spec = ws1->getSpectrum(i); + const specnum_t spectrum = spec.getSpectrumNo(); spectra.insert(spectrum); - const auto &dets = spec->getDetectorIDs(); + const auto &dets = spec.getDetectorIDs(); for (auto const &det : dets) { detectors.insert(det); } @@ -133,8 +133,8 @@ void ConjoinWorkspaces::checkForOverlap(API::MatrixWorkspace_const_sptr ws1, // sure that there's no overlap const size_t &nhist2 = ws2->getNumberHistograms(); for (size_t j = 0; j < nhist2; ++j) { - const ISpectrum *spec = ws2->getSpectrum(j); - const specnum_t spectrum = spec->getSpectrumNo(); + const auto &spec = ws2->getSpectrum(j); + const specnum_t spectrum = spec.getSpectrumNo(); if (checkSpectra) { if (spectrum > 0 && spectra.find(spectrum) != spectra.end()) { g_log.error() @@ -144,7 +144,7 @@ void ConjoinWorkspaces::checkForOverlap(API::MatrixWorkspace_const_sptr ws1, "The input workspaces have overlapping spectrum numbers"); } } - const auto &dets = spec->getDetectorIDs(); + const auto &dets = spec.getDetectorIDs(); for (const auto &det : dets) { if (detectors.find(det) != detectors.end()) { g_log.error() << "The input workspaces have common detectors: " << (det) @@ -200,8 +200,8 @@ void ConjoinWorkspaces::fixSpectrumNumbers(API::MatrixWorkspace_const_sptr ws1, for (size_t i = ws1->getNumberHistograms(); i < output->getNumberHistograms(); i++) { specnum_t origid; - origid = output->getSpectrum(i)->getSpectrumNo(); - output->getSpectrum(i)->setSpectrumNo(origid + ws1max); + origid = output->getSpectrum(i).getSpectrumNo(); + output->getSpectrum(i).setSpectrumNo(origid + ws1max); } } diff --git a/Framework/Algorithms/src/ConvertDiffCal.cpp b/Framework/Algorithms/src/ConvertDiffCal.cpp index 76ab3a042adb2bdf0750d83374e48435db811739..0592436714e7a29569020364fd3591e310d325b3 100644 --- a/Framework/Algorithms/src/ConvertDiffCal.cpp +++ b/Framework/Algorithms/src/ConvertDiffCal.cpp @@ -73,7 +73,7 @@ void ConvertDiffCal::init() { * @return The proper detector id. */ detid_t getDetID(OffsetsWorkspace_const_sptr offsetsWS, const size_t index) { - auto detIDs = offsetsWS->getSpectrum(index)->getDetectorIDs(); + auto detIDs = offsetsWS->getSpectrum(index).getDetectorIDs(); if (detIDs.size() != 1) { std::stringstream msg; msg << "Encountered spectrum with multiple detector ids (size=" diff --git a/Framework/Algorithms/src/ConvertSpectrumAxis.cpp b/Framework/Algorithms/src/ConvertSpectrumAxis.cpp index eee10d7ac3f5237d7c2987426cfea1690dbd8be8..194b42442bab0c30335e283e66443ccdd311e4fb 100644 --- a/Framework/Algorithms/src/ConvertSpectrumAxis.cpp +++ b/Framework/Algorithms/src/ConvertSpectrumAxis.cpp @@ -173,7 +173,7 @@ void ConvertSpectrumAxis::exec() { outputWS->dataE(currentIndex) = inputWS->dataE(it->second); // We can keep the spectrum numbers etc. outputWS->getSpectrum(currentIndex) - ->copyInfoFrom(*inputWS->getSpectrum(it->second)); + .copyInfoFrom(inputWS->getSpectrum(it->second)); ++currentIndex; } setProperty("OutputWorkspace", outputWS); diff --git a/Framework/Algorithms/src/ConvertSpectrumAxis2.cpp b/Framework/Algorithms/src/ConvertSpectrumAxis2.cpp index 6ac62a97179206766ad7b1979e357b2eef27e5fb..cb0ccd8071afc7849195d2a7f63b7e05989fd790 100644 --- a/Framework/Algorithms/src/ConvertSpectrumAxis2.cpp +++ b/Framework/Algorithms/src/ConvertSpectrumAxis2.cpp @@ -238,7 +238,7 @@ MatrixWorkspace_sptr ConvertSpectrumAxis2::createOutputWorkspace( outputWorkspace->dataE(currentIndex) = inputWS->dataE(it->second); // We can keep the spectrum numbers etc. outputWorkspace->getSpectrum(currentIndex) - ->copyInfoFrom(*inputWS->getSpectrum(it->second)); + .copyInfoFrom(inputWS->getSpectrum(it->second)); ++currentIndex; progress.report("Creating output workspace..."); diff --git a/Framework/Algorithms/src/ConvertToEventWorkspace.cpp b/Framework/Algorithms/src/ConvertToEventWorkspace.cpp index b029e1ab90916d3d01d3ca1de2720d4421db35df..20a475d6e24979c4eca374080e3cf24bbc7fe18d 100644 --- a/Framework/Algorithms/src/ConvertToEventWorkspace.cpp +++ b/Framework/Algorithms/src/ConvertToEventWorkspace.cpp @@ -78,13 +78,13 @@ void ConvertToEventWorkspace::exec() { size_t wi = size_t(iwi); // The input spectrum (a histogram) - const ISpectrum *inSpec = inWS->getSpectrum(wi); + const auto &inSpec = inWS->getSpectrum(wi); // The output event list - EventList &el = outWS->getEventList(wi); + EventList &el = outWS->getSpectrum(wi); // This method fills in the events - el.createFromHistogram(inSpec, GenerateZeros, GenerateMultipleEvents, + el.createFromHistogram(&inSpec, GenerateZeros, GenerateMultipleEvents, MaxEventsPerBin); prog.report("Converting"); diff --git a/Framework/Algorithms/src/ConvertToMatrixWorkspace.cpp b/Framework/Algorithms/src/ConvertToMatrixWorkspace.cpp index 2bda2b7ff3e7d42b05e1098e351061351b48026b..6072d165fff6128fe8940bf41d1a61b521e6145a 100644 --- a/Framework/Algorithms/src/ConvertToMatrixWorkspace.cpp +++ b/Framework/Algorithms/src/ConvertToMatrixWorkspace.cpp @@ -51,13 +51,13 @@ void ConvertToMatrixWorkspace::exec() { PARALLEL_FOR2(inputWorkspace, outputWorkspace) for (int64_t i = 0; i < static_cast<int64_t>(numHists); ++i) { PARALLEL_START_INTERUPT_REGION - const ISpectrum *inSpec = inputWorkspace->getSpectrum(i); - ISpectrum *outSpec = outputWorkspace->getSpectrum(i); + const auto &inSpec = inputWorkspace->getSpectrum(i); + auto &outSpec = outputWorkspace->getSpectrum(i); - outSpec->copyInfoFrom(*inSpec); - outSpec->setX(inSpec->ptrX()); - outSpec->dataY() = inSpec->dataY(); - outSpec->dataE() = inSpec->dataE(); + outSpec.copyInfoFrom(inSpec); + outSpec.setX(inSpec.ptrX()); + outSpec.dataY() = inSpec.dataY(); + outSpec.dataE() = inSpec.dataE(); prog.report("Binning"); diff --git a/Framework/Algorithms/src/ConvertUnits.cpp b/Framework/Algorithms/src/ConvertUnits.cpp index 81cd07e4d7b6a25bfe445776fef53e0fe1791c5e..87b7512c36da010544f68bd6cd9ef887a70e5a1d 100644 --- a/Framework/Algorithms/src/ConvertUnits.cpp +++ b/Framework/Algorithms/src/ConvertUnits.cpp @@ -309,16 +309,16 @@ void ConvertUnits::convertQuickly(API::MatrixWorkspace_sptr outputWS, } // Convert the events themselves if necessary. Inefficiently. if (m_inputEvents) { - eventWS->getEventList(k).convertUnitsQuickly(factor, power); + eventWS->getSpectrum(k).convertUnitsQuickly(factor, power); // std::vector<double> tofs; - // eventWS->getEventList(k).getTofs(tofs); + // eventWS->getSpectrum(k).getTofs(tofs); // std::vector<double>::iterator tofIt; // for (tofIt = tofs.begin(); tofIt != tofs.end(); ++tofIt) // { // *tofIt = factor * std::pow(*tofIt,power); // } - // eventWS->getEventList(k).setTofs(tofs); + // eventWS->getSpectrum(k).setTofs(tofs); } prog.report("Convert to " + m_outputUnit->unitID()); PARALLEL_END_INTERUPT_REGION @@ -488,14 +488,14 @@ void ConvertUnits::convertViaTOF(Kernel::Unit_const_sptr fromUnit, // EventWorkspace part, modifying the EventLists. if (m_inputEvents) { - eventWS->getEventList(i) + eventWS->getSpectrum(i) .convertUnitsViaTof(localFromUnit, localOutputUnit); // std::vector<double> tofs; - // eventWS->getEventList(i).getTofs(tofs); + // eventWS->getSpectrum(i).getTofs(tofs); // localFromUnit->toTOF(tofs,emptyVec,l1,l2,twoTheta,emode,efixed,delta); // localOutputUnit->fromTOF(tofs,emptyVec,l1,l2,twoTheta,emode,efixed,delta); - // eventWS->getEventList(i).setTofs(tofs); + // eventWS->getSpectrum(i).setTofs(tofs); } // Clear unit memory delete localFromUnit; @@ -598,7 +598,7 @@ void ConvertUnits::reverse(API::MatrixWorkspace_sptr WS) { for (int j = 0; j < m_numberOfSpectra_i; ++j) { PARALLEL_START_INTERUPT_REGION if (m_inputEvents) { - eventWS->getEventList(j).reverse(); + eventWS->getSpectrum(j).reverse(); } else { std::reverse(WS->dataX(j).begin(), WS->dataX(j).end()); std::reverse(WS->dataY(j).begin(), WS->dataY(j).end()); diff --git a/Framework/Algorithms/src/ConvertUnitsUsingDetectorTable.cpp b/Framework/Algorithms/src/ConvertUnitsUsingDetectorTable.cpp index 430dbee95c0f792b1d84b959eba934a16e2afe35..f2507393017f989164cc392a4a03ecddb12b7337 100644 --- a/Framework/Algorithms/src/ConvertUnitsUsingDetectorTable.cpp +++ b/Framework/Algorithms/src/ConvertUnitsUsingDetectorTable.cpp @@ -375,7 +375,7 @@ void ConvertUnitsUsingDetectorTable::convertViaTOF( twoTheta, emode, efixed, delta); // EventWorkspace part, modifying the EventLists. if (m_inputEvents) { - eventWS->getEventList(wsid) + eventWS->getSpectrum(wsid) .convertUnitsViaTof(localFromUnit, localOutputUnit); } // Clear unit memory @@ -474,7 +474,7 @@ void ConvertUnitsUsingDetectorTable::convertQuickly( } // Convert the events themselves if necessary. Inefficiently. if (m_inputEvents) { - eventWS->getEventList(k).convertUnitsQuickly(factor, power); + eventWS->getSpectrum(k).convertUnitsQuickly(factor, power); } prog.report("Convert to " + m_outputUnit->unitID()); PARALLEL_END_INTERUPT_REGION @@ -559,7 +559,7 @@ void ConvertUnitsUsingDetectorTable::reverse(API::MatrixWorkspace_sptr WS) { for (int j = 0; j < m_numberOfSpectra_i; ++j) { PARALLEL_START_INTERUPT_REGION if (m_inputEvents) { - eventWS->getEventList(j).reverse(); + eventWS->getSpectrum(j).reverse(); } else { std::reverse(WS->dataX(j).begin(), WS->dataX(j).end()); std::reverse(WS->dataY(j).begin(), WS->dataY(j).end()); diff --git a/Framework/Algorithms/src/CorelliCrossCorrelate.cpp b/Framework/Algorithms/src/CorelliCrossCorrelate.cpp index 82af81d9e772cb6543186b2fca832b39e4f7def5..ebd216206de83860d1ad504ebe0133e3ec5dedf7 100644 --- a/Framework/Algorithms/src/CorelliCrossCorrelate.cpp +++ b/Framework/Algorithms/src/CorelliCrossCorrelate.cpp @@ -200,14 +200,14 @@ void CorelliCrossCorrelate::exec() { for (int64_t i = 0; i < numHistograms; ++i) { PARALLEL_START_INTERUPT_REGION - EventList *evlist = outputWS->getEventListPtr(i); + auto &evlist = outputWS->getSpectrum(i); IDetector_const_sptr detector = inputWS->getDetector(i); // Switch to weighted if needed. - if (evlist->getEventType() == TOF) - evlist->switchTo(WEIGHTED); + if (evlist.getEventType() == TOF) + evlist.switchTo(WEIGHTED); - std::vector<WeightedEvent> &events = evlist->getWeightedEvents(); + std::vector<WeightedEvent> &events = evlist.getWeightedEvents(); // Skip if empty. if (events.empty()) diff --git a/Framework/Algorithms/src/CorrectKiKf.cpp b/Framework/Algorithms/src/CorrectKiKf.cpp index 071e48e5197380964b2c77b7617b47ee7bfacfd8..f25311b55182f1eac9a9de173823b52005982c44 100644 --- a/Framework/Algorithms/src/CorrectKiKf.cpp +++ b/Framework/Algorithms/src/CorrectKiKf.cpp @@ -271,20 +271,20 @@ void CorrectKiKf::execEvent() { efixed = efixedProp; // Do the correction - EventList *evlist = outputWS->getEventListPtr(i); - switch (evlist->getEventType()) { + auto &evlist = outputWS->getSpectrum(i); + switch (evlist.getEventType()) { case TOF: // Switch to weights if needed. - evlist->switchTo(WEIGHTED); + evlist.switchTo(WEIGHTED); /* no break */ // Fall through case WEIGHTED: - correctKiKfEventHelper(evlist->getWeightedEvents(), efixed, emodeStr); + correctKiKfEventHelper(evlist.getWeightedEvents(), efixed, emodeStr); break; case WEIGHTED_NOTIME: - correctKiKfEventHelper(evlist->getWeightedEventsNoTime(), efixed, + correctKiKfEventHelper(evlist.getWeightedEventsNoTime(), efixed, emodeStr); break; } diff --git a/Framework/Algorithms/src/CreateSampleWorkspace.cpp b/Framework/Algorithms/src/CreateSampleWorkspace.cpp index a00680beef994a681696ce3d872b1de3c568a01e..7c9c36c665eb11cf46b92e3125fcb937f367aa3f 100644 --- a/Framework/Algorithms/src/CreateSampleWorkspace.cpp +++ b/Framework/Algorithms/src/CreateSampleWorkspace.cpp @@ -313,8 +313,8 @@ MatrixWorkspace_sptr CreateSampleWorkspace::createHistogramWorkspace( for (size_t wi = 0; wi < static_cast<size_t>(numPixels); wi++) { retVal->setX(wi, x); retVal->setData(wi, y, e); - retVal->getSpectrum(wi)->setDetectorID(detid_t(start_at_pixelID + wi)); - retVal->getSpectrum(wi)->setSpectrumNo(specnum_t(wi + 1)); + retVal->getSpectrum(wi).setDetectorID(detid_t(start_at_pixelID + wi)); + retVal->getSpectrum(wi).setSpectrumNo(specnum_t(wi + 1)); } return retVal; @@ -364,7 +364,7 @@ EventWorkspace_sptr CreateSampleWorkspace::createEventWorkspace( const double hourInSeconds = 60 * 60; for (int wi = 0; wi < numPixels; wi++) { - EventList &el = retVal->getEventList(workspaceIndex); + EventList &el = retVal->getSpectrum(workspaceIndex); el.setSpectrumNo(wi + 1); el.setDetectorID(wi + start_at_pixelID); diff --git a/Framework/Algorithms/src/CrossCorrelate.cpp b/Framework/Algorithms/src/CrossCorrelate.cpp index 9b706ad4c7251b10eaf024e5451898ddaf778165..8328f4f1d0df1854d546f9fd42d1a638800992fd 100644 --- a/Framework/Algorithms/src/CrossCorrelate.cpp +++ b/Framework/Algorithms/src/CrossCorrelate.cpp @@ -174,7 +174,7 @@ void CrossCorrelate::exec() { PARALLEL_START_INTERUPT_REGION size_t wsIndex = indexes[i]; // Get the ws index from the table // Copy spectra info from input Workspace - out->getSpectrum(i)->copyInfoFrom(*inputWS->getSpectrum(wsIndex)); + out->getSpectrum(i).copyInfoFrom(inputWS->getSpectrum(wsIndex)); out->dataX(i) = XX; // Get temp references diff --git a/Framework/Algorithms/src/DetectorDiagnostic.cpp b/Framework/Algorithms/src/DetectorDiagnostic.cpp index ff77fd151ca28ec31f21fe04be367f631d569744..bb2274ffde51b65d8974e6f0a36a83256e71a5a5 100644 --- a/Framework/Algorithms/src/DetectorDiagnostic.cpp +++ b/Framework/Algorithms/src/DetectorDiagnostic.cpp @@ -562,11 +562,11 @@ DetectorDiagnostic::makeMap(API::MatrixWorkspace_sptr countsWS) { } for (size_t i = 0; i < countsWS->getNumberHistograms(); i++) { - detid_t d = (*((countsWS->getSpectrum(i))->getDetectorIDs().begin())); + detid_t d = (*(countsWS->getSpectrum(i).getDetectorIDs().begin())); std::vector<boost::shared_ptr<const Mantid::Geometry::IComponent>> anc = instrument->getDetector(d)->getAncestors(); // std::vector<boost::shared_ptr<const IComponent> > - // anc=(*(countsWS->getSpectrum(i)->getDetectorIDs().begin()))->getAncestors(); + // anc=(*(countsWS->getSpectrum(i)->getDetectorIDs().begin())).getAncestors(); if (anc.size() < static_cast<size_t>(m_parents)) { g_log.warning("Too many levels up. Will ignore LevelsUp"); m_parents = 0; @@ -637,7 +637,7 @@ DetectorDiagnostic::calculateMedian(const API::MatrixWorkspace_sptr input, if (checkForMask) { const std::set<detid_t> &detids = - input->getSpectrum(hists[i])->getDetectorIDs(); + input->getSpectrum(hists[i]).getDetectorIDs(); if (instrument->isDetectorMasked(detids)) continue; if (instrument->isMonitor(detids)) diff --git a/Framework/Algorithms/src/DetectorEfficiencyCor.cpp b/Framework/Algorithms/src/DetectorEfficiencyCor.cpp index 7631828646858a4a0fc552bde53dd05da08515fa..bf0792c3ab54b874919cd08b45dfa30c296ccf87 100644 --- a/Framework/Algorithms/src/DetectorEfficiencyCor.cpp +++ b/Framework/Algorithms/src/DetectorEfficiencyCor.cpp @@ -204,7 +204,7 @@ void DetectorEfficiencyCor::correctForEfficiency(int64_t spectraIn) { // get a pointer to the detectors that created the spectrum const std::set<detid_t> &dets = - m_inputWS->getSpectrum(spectraIn)->getDetectorIDs(); + m_inputWS->getSpectrum(spectraIn).getDetectorIDs(); const double ndets(static_cast<double>(dets.size())); // We correct each pixel // so make sure we // average the diff --git a/Framework/Algorithms/src/DetectorEfficiencyVariation.cpp b/Framework/Algorithms/src/DetectorEfficiencyVariation.cpp index 08648a5cd5d6aa36ad3c6f4ea5780abe8f46da40..72f00737b6b36a6b0ca0eb3933fc63c142847860 100644 --- a/Framework/Algorithms/src/DetectorEfficiencyVariation.cpp +++ b/Framework/Algorithms/src/DetectorEfficiencyVariation.cpp @@ -230,7 +230,7 @@ int DetectorEfficiencyVariation::doDetectorTests( if (checkForMask) { const std::set<detid_t> &detids = - counts1->getSpectrum(i)->getDetectorIDs(); + counts1->getSpectrum(i).getDetectorIDs(); if (instrument->isMonitor(detids)) continue; if (instrument->isDetectorMasked(detids)) { diff --git a/Framework/Algorithms/src/DiffractionFocussing.cpp b/Framework/Algorithms/src/DiffractionFocussing.cpp index d8e902325f473bb41f2a6d676b40cc6f78e196bc..4948d83806fd7e2e4aaf5f6d0115f4689ca88f0f 100644 --- a/Framework/Algorithms/src/DiffractionFocussing.cpp +++ b/Framework/Algorithms/src/DiffractionFocussing.cpp @@ -145,9 +145,9 @@ void DiffractionFocussing::exec() { outE.assign(tmpE.begin(), tmpE.end()); outY.assign(tmpY.begin(), tmpY.end()); outX.assign(tmpX.begin(), tmpX.end()); - API::ISpectrum *inSpec = tmpW->getSpectrum(i); - outputW->getSpectrum(hist)->setSpectrumNo(inSpec->getSpectrumNo()); - inSpec->setSpectrumNo(-1); + auto &inSpec = tmpW->getSpectrum(i); + outputW->getSpectrum(hist).setSpectrumNo(inSpec.getSpectrumNo()); + inSpec.setSpectrumNo(-1); } progress(1.); diff --git a/Framework/Algorithms/src/DiffractionFocussing2.cpp b/Framework/Algorithms/src/DiffractionFocussing2.cpp index e0abe33fdbaf4024304db7a4c2bd92005e11e8ad..20ce22cba7d8ec4a4b3ed38ba52d2db7ede7a087 100644 --- a/Framework/Algorithms/src/DiffractionFocussing2.cpp +++ b/Framework/Algorithms/src/DiffractionFocussing2.cpp @@ -196,15 +196,15 @@ void DiffractionFocussing2::exec() { out->dataX(static_cast<int64_t>(dif)) = Xout; // This is the output spectrum - ISpectrum *outSpec = out->getSpectrum(outWorkspaceIndex); + auto &outSpec = out->getSpectrum(outWorkspaceIndex); // Also set the spectrum number to the group number - outSpec->setSpectrumNo(group); - outSpec->clearDetectorIDs(); + outSpec.setSpectrumNo(group); + outSpec.clearDetectorIDs(); // Get the references to Y and E output and rebin - MantidVec &Yout = outSpec->dataY(); - MantidVec &Eout = outSpec->dataE(); + MantidVec &Yout = outSpec.dataY(); + MantidVec &Eout = outSpec.dataE(); // Initialize the group's weight vector here and the dummy vector used for // accumulating errors. @@ -216,13 +216,13 @@ void DiffractionFocussing2::exec() { for (size_t i = 0; i < groupSize; i++) { size_t inWorkspaceIndex = indices[i]; // This is the input spectrum - const ISpectrum *inSpec = m_matrixInputW->getSpectrum(inWorkspaceIndex); + const auto &inSpec = m_matrixInputW->getSpectrum(inWorkspaceIndex); // Get reference to its old X,Y,and E. - const MantidVec &Xin = inSpec->readX(); - const MantidVec &Yin = inSpec->readY(); - const MantidVec &Ein = inSpec->readE(); + const MantidVec &Xin = inSpec.readX(); + const MantidVec &Yin = inSpec.readY(); + const MantidVec &Ein = inSpec.readE(); - outSpec->addDetectorIDs(inSpec->getDetectorIDs()); + outSpec.addDetectorIDs(inSpec.getDetectorIDs()); try { VectorHelper::rebinHistogram(Xin, Yin, Ein, Xout, Yout, Eout, true); } catch (...) { @@ -366,7 +366,7 @@ void DiffractionFocussing2::execEvent() { totalHistProcess += static_cast<int>(indices.size()); for (auto index : indices) { - size_required[iGroup] += m_eventW->getEventList(index).getNumberEvents(); + size_required[iGroup] += m_eventW->getSpectrum(index).getNumberEvents(); } prog->report(1, "Pre-counting"); } @@ -418,7 +418,7 @@ void DiffractionFocussing2::execEvent() { if (group == 1) { // Accumulate the chunk - numEventsInChunk += eventW->getEventList(wi).getNumberEvents(); + numEventsInChunk += eventW->getSpectrum(wi).getNumberEvents(); } } */ @@ -431,7 +431,7 @@ void DiffractionFocussing2::execEvent() { for (int i = wiChunk * chunkSize; i < max; i++) { // Accumulate the chunk size_t wi = indices[i]; - chunkEL += m_eventW->getEventList(wi); + chunkEL += m_eventW->getSpectrum(wi); } // Rejoin the chunk with the rest. @@ -453,7 +453,7 @@ void DiffractionFocussing2::execEvent() { const std::vector<size_t> &indices = this->m_wsIndices[group]; for (auto wi : indices) { // In workspace index iGroup, put what was in the OLD workspace index wi - out->getOrAddEventList(iGroup) += m_eventW->getEventList(wi); + out->getOrAddEventList(iGroup) += m_eventW->getSpectrum(wi); prog->reportIncrement(1, "Appending Lists"); @@ -461,7 +461,7 @@ void DiffractionFocussing2::execEvent() { // one! if (inPlace) { boost::const_pointer_cast<EventWorkspace>(m_eventW) - ->getEventList(wi) + ->getSpectrum(wi) .clear(); } } @@ -512,8 +512,7 @@ void DiffractionFocussing2::execEvent() { * @return Group number if successful otherwise return -1 */ int DiffractionFocussing2::validateSpectrumInGroup(size_t wi) { - const std::set<detid_t> &dets = - m_matrixInputW->getSpectrum(wi)->getDetectorIDs(); + const auto &dets = m_matrixInputW->getSpectrum(wi).getDetectorIDs(); if (dets.empty()) // Not in group { g_log.debug() << wi << " <- this workspace index is empty!\n"; @@ -584,13 +583,9 @@ void DiffractionFocussing2::determineRebinParameters() { continue; // the spectrum is the real thing we want to work with - const ISpectrum *spec = m_matrixInputW->getSpectrum(wi); - if (spec == nullptr) { - groupAtWorkspaceIndex[wi] = -1; - continue; - } + const auto &spec = m_matrixInputW->getSpectrum(wi); if (checkForMask) { - if (instrument->isDetectorMasked(spec->getDetectorIDs())) { + if (instrument->isDetectorMasked(spec.getDetectorIDs())) { groupAtWorkspaceIndex[wi] = -1; continue; } @@ -604,7 +599,7 @@ void DiffractionFocussing2::determineRebinParameters() { } const double min = (gpit->second).first; const double max = (gpit->second).second; - const MantidVec &X = spec->readX(); + const MantidVec &X = spec.readX(); double temp = X.front(); if (temp < (min)) // New Xmin found (gpit->second).first = temp; diff --git a/Framework/Algorithms/src/EQSANSTofStructure.cpp b/Framework/Algorithms/src/EQSANSTofStructure.cpp index 688d59d668d16444cfde8aa7e13886de98b31107..71844e0682a2f09cc7066dd92efb03abda09e53b 100644 --- a/Framework/Algorithms/src/EQSANSTofStructure.cpp +++ b/Framework/Algorithms/src/EQSANSTofStructure.cpp @@ -157,8 +157,7 @@ void EQSANSTofStructure::execEvent( PARALLEL_START_INTERUPT_REGION // Get the pointer to the output event list - EventList *outEL = inputWS->getEventListPtr(ispec); - std::vector<TofEvent> &events = outEL->getEvents(); + std::vector<TofEvent> &events = inputWS->getSpectrum(ispec).getEvents(); std::vector<TofEvent>::iterator it; std::vector<TofEvent> clean_events; diff --git a/Framework/Algorithms/src/EditInstrumentGeometry.cpp b/Framework/Algorithms/src/EditInstrumentGeometry.cpp index ae5aee674f466b0b96a4a859208eaf85872b3485..f608ea66039740049c7d49bd87131041b58a8f34 100644 --- a/Framework/Algorithms/src/EditInstrumentGeometry.cpp +++ b/Framework/Algorithms/src/EditInstrumentGeometry.cpp @@ -194,10 +194,9 @@ void EditInstrumentGeometry::exec() { { size_t numHist = workspace->getNumberHistograms(); for (size_t i = 0; i < numHist; ++i) { - specids.push_back(workspace->getSpectrum(i)->getSpectrumNo()); + specids.push_back(workspace->getSpectrum(i).getSpectrumNo()); g_log.information() << "Add spectrum " - << workspace->getSpectrum(i)->getSpectrumNo() - << ".\n"; + << workspace->getSpectrum(i).getSpectrumNo() << ".\n"; } } @@ -338,27 +337,13 @@ void EditInstrumentGeometry::exec() { detector->setPos(pos); // Add new detector to spectrum and instrument - API::ISpectrum *spectrum = workspace->getSpectrum(i); - if (!spectrum) { - // Error! - delete detector; + auto &spectrum = workspace->getSpectrum(i); + // Good and do some debug output + g_log.debug() << "Orignal spectrum " << spectrum.getSpectrumNo() << "has " + << spectrum.getDetectorIDs().size() << " detectors. \n"; - stringstream errss; - errss << "Spectrum Number " << specids[i] - << " does not exist! Skip setting " - "detector parameters to this " - "spectrum. "; - g_log.error(errss.str()); - throw runtime_error(errss.str()); - } else { - // Good and do some debug output - g_log.debug() << "Orignal spectrum " << spectrum->getSpectrumNo() - << "has " << spectrum->getDetectorIDs().size() - << " detectors. \n"; - } - - spectrum->clearDetectorIDs(); - spectrum->addDetectorID(newdetid); + spectrum.clearDetectorIDs(); + spectrum.addDetectorID(newdetid); instrument->add(detector); instrument->markAsDetector(detector); diff --git a/Framework/Algorithms/src/EventWorkspaceAccess.cpp b/Framework/Algorithms/src/EventWorkspaceAccess.cpp index 9627182d96117c9bf689e8e6c9e73fff3498f494..fb312a4401e65bac32c7b63f8cbf773367af3174 100644 --- a/Framework/Algorithms/src/EventWorkspaceAccess.cpp +++ b/Framework/Algorithms/src/EventWorkspaceAccess.cpp @@ -4,14 +4,14 @@ namespace Mantid { namespace Algorithms { ///@cond Doxygen has problems for decltype for some reason. -/// Returns std::mem_fn object refering to EventWorkspace::getEventList(). -decltype(std::mem_fn((DataObjects::EventList & - (DataObjects::EventWorkspace::*)(const std::size_t)) & - DataObjects::EventWorkspace::getEventList)) - EventWorkspaceAccess::eventList = - std::mem_fn((DataObjects::EventList & - (DataObjects::EventWorkspace::*)(const std::size_t)) & - DataObjects::EventWorkspace::getEventList); +/// Returns std::mem_fn object refering to EventWorkspace::getSpectrum(). +decltype(std::mem_fn( + (DataObjects::EventList & + (DataObjects::EventWorkspace::*)(const std::size_t)) & + DataObjects::EventWorkspace::getSpectrum)) EventWorkspaceAccess::eventList = + std::mem_fn((DataObjects::EventList & + (DataObjects::EventWorkspace::*)(const std::size_t)) & + DataObjects::EventWorkspace::getSpectrum); ///@endcond } } diff --git a/Framework/Algorithms/src/ExtractMaskToTable.cpp b/Framework/Algorithms/src/ExtractMaskToTable.cpp index 14a1521f75eeb3493d1e89a6513bd54dcd4f2a71..c6f889c50fa7ac165551f5a3d45e48b26137308c 100644 --- a/Framework/Algorithms/src/ExtractMaskToTable.cpp +++ b/Framework/Algorithms/src/ExtractMaskToTable.cpp @@ -259,13 +259,7 @@ std::vector<detid_t> ExtractMaskToTable::extractMaskFromMaskWorkspace() { if (maskws->readY(i)[0] < 1.0E-9) continue; - // Get spectrum - const API::ISpectrum *spec = maskws->getSpectrum(i); - if (!spec) - throw runtime_error( - "Unable to get spectrum reference from mask workspace."); - - const set<detid_t> detidset = spec->getDetectorIDs(); + const auto &detidset = maskws->getSpectrum(i).getDetectorIDs(); std::copy(detidset.cbegin(), detidset.cend(), std::inserter(maskeddetids, maskeddetids.end())); } diff --git a/Framework/Algorithms/src/ExtractSpectra.cpp b/Framework/Algorithms/src/ExtractSpectra.cpp index 07a7fd50f440d4cc83b9b1917a1e62268d744900..d430a67ea23673f9dbec3c2c232bbb52d5dc1d2b 100644 --- a/Framework/Algorithms/src/ExtractSpectra.cpp +++ b/Framework/Algorithms/src/ExtractSpectra.cpp @@ -195,7 +195,7 @@ void ExtractSpectra::execHistogram() { } // Copy spectrum number & detectors outputWorkspace->getSpectrum(j) - ->copyInfoFrom(*m_inputWorkspace->getSpectrum(i)); + .copyInfoFrom(m_inputWorkspace->getSpectrum(i)); if (!m_commonBoundaries) this->cropRagged(outputWorkspace, static_cast<int>(i), j); @@ -302,7 +302,7 @@ void ExtractSpectra::execEvent() { for (int j = 0; j < static_cast<int>(m_workspaceIndexList.size()); ++j) { PARALLEL_START_INTERUPT_REGION auto i = m_workspaceIndexList[j]; - const EventList &el = eventW->getEventList(i); + const EventList &el = eventW->getSpectrum(i); // The output event list EventList &outEL = outputWorkspace->getOrAddEventList(j); // // left side of the crop - will erase 0 -> endLeft @@ -373,7 +373,7 @@ void ExtractSpectra::execEvent() { } // When cropping in place, you can clear out old memory from the input one! if (inPlace) { - eventW->getEventList(i).clear(); + eventW->getSpectrum(i).clear(); } prog.report(); PARALLEL_END_INTERUPT_REGION diff --git a/Framework/Algorithms/src/FilterByLogValue.cpp b/Framework/Algorithms/src/FilterByLogValue.cpp index b84cf23f80dbb4262e8cfad8a01733fdd4c37a80..2b05109df56b4747a757580b9b6b22148ca5b752 100644 --- a/Framework/Algorithms/src/FilterByLogValue.cpp +++ b/Framework/Algorithms/src/FilterByLogValue.cpp @@ -194,7 +194,7 @@ void FilterByLogValue::exec() { PARALLEL_START_INTERUPT_REGION // this is the input event list - EventList &input_el = inputWS->getEventList(i); + EventList &input_el = inputWS->getSpectrum(i); // Perform the filtering in place. input_el.filterInPlace(splitter); @@ -233,12 +233,10 @@ void FilterByLogValue::exec() { PARALLEL_START_INTERUPT_REGION // Get the output event list (should be empty) - EventList *output_el = outputWS->getEventListPtr(i); - std::vector<EventList *> outputs; - outputs.push_back(output_el); + std::vector<EventList *> outputs{&outputWS->getSpectrum(i)}; // and this is the input event list - const EventList &input_el = inputWS->getEventList(i); + const EventList &input_el = inputWS->getSpectrum(i); // Perform the filtering (using the splitting function and just one // output) diff --git a/Framework/Algorithms/src/FilterByTime.cpp b/Framework/Algorithms/src/FilterByTime.cpp index e9eaadedfb6fdf949aaf3d274d9504a03a6fc007..08a31acc47efc5921501677930611d0ede9ea80a 100644 --- a/Framework/Algorithms/src/FilterByTime.cpp +++ b/Framework/Algorithms/src/FilterByTime.cpp @@ -142,9 +142,9 @@ void FilterByTime::exec() { PARALLEL_START_INTERUPT_REGION // Get the output event list (should be empty) - EventList &output_el = outputWS->getEventList(i); + EventList &output_el = outputWS->getSpectrum(i); // and this is the input event list - const EventList &input_el = inputWS->getEventList(i); + const EventList &input_el = inputWS->getSpectrum(i); // Perform the filtering input_el.filterByPulseTime(start, stop, output_el); diff --git a/Framework/Algorithms/src/FilterByXValue.cpp b/Framework/Algorithms/src/FilterByXValue.cpp index 6c251240524886f178372c44440b9b9dd7f58f22..fa7d147573a52988836ec5aa9e72f33e0a85d378 100644 --- a/Framework/Algorithms/src/FilterByXValue.cpp +++ b/Framework/Algorithms/src/FilterByXValue.cpp @@ -95,7 +95,7 @@ void FilterByXValue::exec() { for (int spec = 0; spec < numSpec; ++spec) { PARALLEL_START_INTERUPT_REGION - EventList &events = outputWS->getEventList(spec); + EventList &events = outputWS->getSpectrum(spec); // Sort to make getting the tof min/max faster (& since maskTof will sort // anyway) events.sortTof(); diff --git a/Framework/Algorithms/src/FilterEvents.cpp b/Framework/Algorithms/src/FilterEvents.cpp index 21697fe4b2aae4a8b034eacbd814d782758ee60d..e389db859da503b2e9a838f21b0f9e411393840f 100644 --- a/Framework/Algorithms/src/FilterEvents.cpp +++ b/Framework/Algorithms/src/FilterEvents.cpp @@ -372,7 +372,7 @@ void FilterEvents::examineEventWS() { m_vecSkip[i] = true; ++numskipspec; - const EventList &elist = m_eventWS->getEventList(i); + const EventList &elist = m_eventWS->getSpectrum(i); numeventsskip += elist.getNumberEvents(); msgss << i; if (numskipspec % 10 == 0) @@ -772,7 +772,7 @@ void FilterEvents::setupCustomizedTOFCorrection() { // It is assumed that there is one detector per spectra. // If there are more than 1 spectrum, it is very likely to have problem // with correction factor - const DataObjects::EventList events = m_eventWS->getEventList(i); + const DataObjects::EventList events = m_eventWS->getSpectrum(i); auto detids = events.getDetectorIDs(); if (detids.size() != 1) { // Check whether there are more than 1 detector per spectra. @@ -843,7 +843,6 @@ void FilterEvents::setupCustomizedTOFCorrection() { */ void FilterEvents::filterEventsBySplitters(double progressamount) { size_t numberOfSpectra = m_eventWS->getNumberHistograms(); - std::map<int, DataObjects::EventWorkspace_sptr>::iterator wsiter; // Loop over the histograms (detector spectra) to do split from 1 event list // to N event list @@ -860,17 +859,15 @@ void FilterEvents::filterEventsBySplitters(double progressamount) { // Get the output event lists (should be empty) to be a map std::map<int, DataObjects::EventList *> outputs; PARALLEL_CRITICAL(build_elist) { - for (wsiter = m_outputWS.begin(); wsiter != m_outputWS.end(); - ++wsiter) { - int index = wsiter->first; - DataObjects::EventList *output_el = - wsiter->second->getEventListPtr(iws); - outputs.emplace(index, output_el); + for (auto &ws : m_outputWS) { + int index = ws.first; + auto &output_el = ws.second->getSpectrum(iws); + outputs.emplace(index, &output_el); } } // Get a holder on input workspace's event list of this spectrum - const DataObjects::EventList &input_el = m_eventWS->getEventList(iws); + const DataObjects::EventList &input_el = m_eventWS->getSpectrum(iws); // Perform the filtering (using the splitting function and just one // output) @@ -904,9 +901,9 @@ void FilterEvents::filterEventsBySplitters(double progressamount) { double numws = static_cast<double>(m_outputWS.size()); double outwsindex = 0.; - for (wsiter = m_outputWS.begin(); wsiter != m_outputWS.end(); ++wsiter) { - int wsindex = wsiter->first; - DataObjects::EventWorkspace_sptr opws = wsiter->second; + for (auto &ws : m_outputWS) { + int wsindex = ws.first; + DataObjects::EventWorkspace_sptr opws = ws.second; // Generate a list of splitters for current output workspace Kernel::TimeSplitterType splitters = generateSplitters(wsindex); @@ -944,7 +941,6 @@ void FilterEvents::filterEventsBySplitters(double progressamount) { void FilterEvents::filterEventsByVectorSplitters(double progressamount) { size_t numberOfSpectra = m_eventWS->getNumberHistograms(); // FIXME : consider to use vector to index workspace and event list - std::map<int, DataObjects::EventWorkspace_sptr>::iterator wsiter; // Loop over the histograms (detector spectra) to do split from 1 event list // to N event list @@ -960,17 +956,15 @@ void FilterEvents::filterEventsByVectorSplitters(double progressamount) { // Get the output event lists (should be empty) to be a map map<int, DataObjects::EventList *> outputs; PARALLEL_CRITICAL(build_elist) { - for (wsiter = m_outputWS.begin(); wsiter != m_outputWS.end(); - ++wsiter) { - int index = wsiter->first; - DataObjects::EventList *output_el = - wsiter->second->getEventListPtr(iws); - outputs.emplace(index, output_el); + for (auto &ws : m_outputWS) { + int index = ws.first; + auto &output_el = ws.second->getSpectrum(iws); + outputs.emplace(index, &output_el); } } // Get a holder on input workspace's event list of this spectrum - const DataObjects::EventList &input_el = m_eventWS->getEventList(iws); + const DataObjects::EventList &input_el = m_eventWS->getSpectrum(iws); bool printdetail = false; if (m_useDBSpectrum) diff --git a/Framework/Algorithms/src/FindCenterOfMassPosition2.cpp b/Framework/Algorithms/src/FindCenterOfMassPosition2.cpp index 1423a3275d15acc3d302eb88c3e4ebe1242594b0..a38c4cba1bd9088c1690fa3484ce07df0f140eed 100644 --- a/Framework/Algorithms/src/FindCenterOfMassPosition2.cpp +++ b/Framework/Algorithms/src/FindCenterOfMassPosition2.cpp @@ -93,7 +93,7 @@ void FindCenterOfMassPosition2::exec() { for (int i = 0; i < numSpec; i++) { double sum_i(0), err_i(0); progress.report("Integrating events"); - const EventList &el = inputEventWS->getEventList(i); + const EventList &el = inputEventWS->getSpectrum(i); el.integrate(0, 0, true, sum_i, err_i); y_values[i] = sum_i; e_values[i] = err_i; diff --git a/Framework/Algorithms/src/FindDeadDetectors.cpp b/Framework/Algorithms/src/FindDeadDetectors.cpp index 52533fed11aaed7e065d7432108eeb18edee94de..81584e6a1d975fac9a589c44e8c6059b5cf839c4 100644 --- a/Framework/Algorithms/src/FindDeadDetectors.cpp +++ b/Framework/Algorithms/src/FindDeadDetectors.cpp @@ -91,18 +91,18 @@ void FindDeadDetectors::exec() { iprogress_step = 1; for (int64_t i = 0; i < int64_t(numSpec); ++i) { // Spectrum in the integratedWorkspace - ISpectrum *spec = integratedWorkspace->getSpectrum(i); - double &y = spec->dataY()[0]; + auto &spec = integratedWorkspace->getSpectrum(i); + double &y = spec.dataY()[0]; if (y > deadThreshold) { y = liveValue; } else { ++countSpec; y = deadValue; - const specnum_t specNo = spec->getSpectrumNo(); + const specnum_t specNo = spec.getSpectrumNo(); // Write the spectrum number to file file << i << " " << specNo; // Get the list of detectors for this spectrum and iterate over - const auto &dets = spec->getDetectorIDs(); + const auto &dets = spec.getDetectorIDs(); for (const auto &det : dets) { // Write the detector ID to file, log & the FoundDead output property file << " " << det; diff --git a/Framework/Algorithms/src/FindDetectorsOutsideLimits.cpp b/Framework/Algorithms/src/FindDetectorsOutsideLimits.cpp index 99201624a7732d2059fc461df0eef9e649c20636..a0a63afe420abdbf9300bceeeb96e633fe76873d 100644 --- a/Framework/Algorithms/src/FindDetectorsOutsideLimits.cpp +++ b/Framework/Algorithms/src/FindDetectorsOutsideLimits.cpp @@ -133,7 +133,7 @@ void FindDetectorsOutsideLimits::exec() { if (checkForMask) { const std::set<detid_t> &detids = - countsWS->getSpectrum(i)->getDetectorIDs(); + countsWS->getSpectrum(i).getDetectorIDs(); if (instrument->isMonitor(detids)) { continue; // do include or exclude from mask } diff --git a/Framework/Algorithms/src/GeneralisedSecondDifference.cpp b/Framework/Algorithms/src/GeneralisedSecondDifference.cpp index ea27a73ff49de47b0b9c94bc931b776dd2fbb215..42940c07149270a74efaaecd5c22145ff2c9e02c 100644 --- a/Framework/Algorithms/src/GeneralisedSecondDifference.cpp +++ b/Framework/Algorithms/src/GeneralisedSecondDifference.cpp @@ -106,7 +106,7 @@ void GeneralisedSecondDifference::exec() { for (int i = spec_min; i <= spec_max; i++) { int out_index = i - spec_min; out->getSpectrum(out_index) - ->setSpectrumNo(inputWS->getSpectrum(i)->getSpectrumNo()); + .setSpectrumNo(inputWS->getSpectrum(i).getSpectrumNo()); const MantidVec &refX = inputWS->readX(i); const MantidVec &refY = inputWS->readY(i); const MantidVec &refE = inputWS->readE(i); diff --git a/Framework/Algorithms/src/GenerateEventsFilter.cpp b/Framework/Algorithms/src/GenerateEventsFilter.cpp index 5f81abaca99e94492e20ea2fc9bb6154fd30b65b..2dc5f8940043b0298a61a183e22709bc6b979362 100644 --- a/Framework/Algorithms/src/GenerateEventsFilter.cpp +++ b/Framework/Algorithms/src/GenerateEventsFilter.cpp @@ -1910,7 +1910,7 @@ DateAndTime GenerateEventsFilter::findRunEnd() { norunendset = false; for (size_t i = 0; i < m_dataWS->getNumberHistograms(); ++i) { - const DataObjects::EventList &evlist = m_dataWS->getEventList(i); + const DataObjects::EventList &evlist = m_dataWS->getSpectrum(i); if (evlist.getNumberEvents() > 0) { // If event list is empty, the returned value may not make any sense DateAndTime lastpulse = evlist.getPulseTimeMax(); diff --git a/Framework/Algorithms/src/GeneratePeaks.cpp b/Framework/Algorithms/src/GeneratePeaks.cpp index 10ffd9f314bb523b6f1e9757d9c5e9af270a2595..2b9d4bcabd422cb33d531e3b010ded30e5aed2ca 100644 --- a/Framework/Algorithms/src/GeneratePeaks.cpp +++ b/Framework/Algorithms/src/GeneratePeaks.cpp @@ -800,7 +800,7 @@ GeneratePeaks::createDataWorkspace(std::vector<double> binparameters) { specnum_t wsindex = spiter->second; g_log.debug() << "Build WorkspaceIndex-Spectrum " << wsindex << " , " << specid << "\n"; - ws->getSpectrum(wsindex)->setSpectrumNo(specid); + ws->getSpectrum(wsindex).setSpectrumNo(specid); } return ws; diff --git a/Framework/Algorithms/src/GetAllEi.cpp b/Framework/Algorithms/src/GetAllEi.cpp index f52c43761fec5dae8da3cbe3312587260f13b545..dc8bf8cc68bd24a801dfebb983a7c40b50c04b19 100644 --- a/Framework/Algorithms/src/GetAllEi.cpp +++ b/Framework/Algorithms/src/GetAllEi.cpp @@ -237,8 +237,8 @@ void GetAllEi::exec() { auto lastChopper = pInstrument->getChopperPoint(nChoppers-1); ///<--------------------------------------------------- */ - auto baseSpectrum = inputWS->getSpectrum(det1WSIndex); - std::pair<double, double> TOF_range = baseSpectrum->getXDataRange(); + auto &baseSpectrum = inputWS->getSpectrum(det1WSIndex); + std::pair<double, double> TOF_range = baseSpectrum.getXDataRange(); double Period = (0.5 * 1.e+6) / chopSpeed; // 0.5 because some choppers open twice. @@ -262,9 +262,9 @@ void GetAllEi::exec() { printDebugModeInfo(guess_opening, TOF_range, destUnit); } std::pair<double, double> Mon1_Erange = - monitorWS->getSpectrum(0)->getXDataRange(); + monitorWS->getSpectrum(0).getXDataRange(); std::pair<double, double> Mon2_Erange = - monitorWS->getSpectrum(1)->getXDataRange(); + monitorWS->getSpectrum(1).getXDataRange(); double eMin = std::max(Mon1_Erange.first, Mon2_Erange.first); double eMax = std::min(Mon1_Erange.second, Mon2_Erange.second); g_log.debug() << boost::str( @@ -877,11 +877,11 @@ GetAllEi::buildWorkspaceToFit(const API::MatrixWorkspace_sptr &inputWS, wsIndex0 = inputWS->getIndexFromSpectrumNumber(specNum1); specnum_t specNum2 = getProperty("Monitor2SpecID"); size_t wsIndex1 = inputWS->getIndexFromSpectrumNumber(specNum2); - auto pSpectr1 = inputWS->getSpectrum(wsIndex0); - auto pSpectr2 = inputWS->getSpectrum(wsIndex1); + auto &pSpectr1 = inputWS->getSpectrum(wsIndex0); + auto &pSpectr2 = inputWS->getSpectrum(wsIndex1); // assuming equally binned ws. // auto bins = inputWS->dataX(wsIndex0); - auto bins = pSpectr1->dataX(); + auto bins = pSpectr1.dataX(); size_t XLength = bins.size(); size_t YLength = inputWS->dataY(wsIndex0).size(); auto working_ws = @@ -905,14 +905,14 @@ GetAllEi::buildWorkspaceToFit(const API::MatrixWorkspace_sptr &inputWS, Error2[i] = inputWS->dataE(wsIndex1)[i]; } // copy detector mapping - API::ISpectrum *spectrum = working_ws->getSpectrum(0); - spectrum->setSpectrumNo(specNum1); - spectrum->clearDetectorIDs(); - spectrum->addDetectorIDs(pSpectr1->getDetectorIDs()); - spectrum = working_ws->getSpectrum(1); - spectrum->setSpectrumNo(specNum2); - spectrum->clearDetectorIDs(); - spectrum->addDetectorIDs(pSpectr2->getDetectorIDs()); + auto &spectrum1 = working_ws->getSpectrum(0); + spectrum1.setSpectrumNo(specNum1); + spectrum1.clearDetectorIDs(); + spectrum1.addDetectorIDs(pSpectr1.getDetectorIDs()); + auto &spectrum2 = working_ws->getSpectrum(1); + spectrum2.setSpectrumNo(specNum2); + spectrum2.clearDetectorIDs(); + spectrum2.addDetectorIDs(pSpectr2.getDetectorIDs()); if (inputWS->getAxis(0)->unit()->caption() != "Energy") { API::IAlgorithm_sptr conv = createChildAlgorithm("ConvertUnits"); diff --git a/Framework/Algorithms/src/GetDetOffsetsMultiPeaks.cpp b/Framework/Algorithms/src/GetDetOffsetsMultiPeaks.cpp index a20368f7a36a32a2eecf5448cb599b0abd6f2a37..54d57661136760440dc3fb7b0266e81d99605ef2 100644 --- a/Framework/Algorithms/src/GetDetOffsetsMultiPeaks.cpp +++ b/Framework/Algorithms/src/GetDetOffsetsMultiPeaks.cpp @@ -495,8 +495,7 @@ void GetDetOffsetsMultiPeaks::calculateDetectorsOffsets() { calculatePeakOffset(wi, fittedpeakpositions, tofitpeakpositions); // Get the list of detectors in this pixel - const std::set<detid_t> &dets = - m_inputWS->getSpectrum(wi)->getDetectorIDs(); + const auto &dets = m_inputWS->getSpectrum(wi).getDetectorIDs(); // Most of the exec time is in FitSpectra, so this critical block should // not be a problem. @@ -584,7 +583,7 @@ FitPeakOffsetResult GetDetOffsetsMultiPeaks::calculatePeakOffset( fr.dev_resolution = 0.0; // Checks for empty and dead detectors - if ((m_isEvent) && (m_eventW->getEventList(wi).empty())) { + if ((m_isEvent) && (m_eventW->getSpectrum(wi).empty())) { // empty detector will be masked fr.offset = BAD_OFFSET; fr.fitoffsetstatus = "empty det"; @@ -858,7 +857,7 @@ int GetDetOffsetsMultiPeaks::fitSpectra( // throw if minD >= maxD std::stringstream ess; ess << "Stuff went wrong with wkspIndex=" << wi - << " specNum=" << inputW->getSpectrum(wi)->getSpectrumNo(); + << " specNum=" << inputW->getSpectrum(wi).getSpectrumNo(); throw std::runtime_error(ess.str()); } @@ -870,8 +869,8 @@ int GetDetOffsetsMultiPeaks::fitSpectra( } } std::stringstream dbss; - dbss << "D-RANGE[" << inputW->getSpectrum(wi)->getSpectrumNo() - << "]: " << minD << " -> " << maxD; + dbss << "D-RANGE[" << inputW->getSpectrum(wi).getSpectrumNo() << "]: " << minD + << " -> " << maxD; g_log.debug(dbss.str()); // Setup the fit windows diff --git a/Framework/Algorithms/src/GetDetectorOffsets.cpp b/Framework/Algorithms/src/GetDetectorOffsets.cpp index 0ea326b044381ad556b8a1666b8ff60c31f2eae9..67c7b69f03376473c4b082c9ea7bf0e30f6d4de7 100644 --- a/Framework/Algorithms/src/GetDetectorOffsets.cpp +++ b/Framework/Algorithms/src/GetDetectorOffsets.cpp @@ -131,7 +131,7 @@ void GetDetectorOffsets::exec() { } // Get the list of detectors in this pixel - const auto &dets = inputW->getSpectrum(wi)->getDetectorIDs(); + const auto &dets = inputW->getSpectrum(wi).getDetectorIDs(); // Most of the exec time is in FitSpectra, so this critical block should not // be a problem. diff --git a/Framework/Algorithms/src/GetEi.cpp b/Framework/Algorithms/src/GetEi.cpp index 51e9a04ddac9402dca39a0791315157c51f08638..f96495968fb08140688bb5fda8533a9578f9a10f 100644 --- a/Framework/Algorithms/src/GetEi.cpp +++ b/Framework/Algorithms/src/GetEi.cpp @@ -171,7 +171,7 @@ void GetEi::getGeometry(API::MatrixWorkspace_const_sptr WS, specnum_t mon0Spec, g_log.error() << "Error retrieving data for the first monitor\n"; throw std::bad_cast(); } - const auto &dets = WS->getSpectrum(monWI)->getDetectorIDs(); + const auto &dets = WS->getSpectrum(monWI).getDetectorIDs(); if (dets.size() != 1) { g_log.error() << "The detector for spectrum number " << mon0Spec @@ -193,7 +193,7 @@ void GetEi::getGeometry(API::MatrixWorkspace_const_sptr WS, specnum_t mon0Spec, g_log.error() << "Error retrieving data for the second monitor\n"; throw std::bad_cast(); } - const auto &dets2 = WS->getSpectrum(monWI)->getDetectorIDs(); + const auto &dets2 = WS->getSpectrum(monWI).getDetectorIDs(); if (dets2.size() != 1) { g_log.error() << "The detector for spectrum number " << mon1Spec << " was either not found or is a group, grouped monitors " diff --git a/Framework/Algorithms/src/He3TubeEfficiency.cpp b/Framework/Algorithms/src/He3TubeEfficiency.cpp index 2a5d047a8fed3ab265f8da5f167e04012b0a4e37..59eae15e3aa74d2a83df63c118623b22dafc20b6 100644 --- a/Framework/Algorithms/src/He3TubeEfficiency.cpp +++ b/Framework/Algorithms/src/He3TubeEfficiency.cpp @@ -445,17 +445,17 @@ void He3TubeEfficiency::execEvent() { } // Do the correction - DataObjects::EventList *evlist = outputWS->getEventListPtr(i); - switch (evlist->getEventType()) { + auto &evlist = outputWS->getSpectrum(i); + switch (evlist.getEventType()) { case API::TOF: // Switch to weights if needed. - evlist->switchTo(API::WEIGHTED); + evlist.switchTo(API::WEIGHTED); // Fall through case API::WEIGHTED: - eventHelper(evlist->getWeightedEvents(), exp_constant); + eventHelper(evlist.getWeightedEvents(), exp_constant); break; case API::WEIGHTED_NOTIME: - eventHelper(evlist->getWeightedEventsNoTime(), exp_constant); + eventHelper(evlist.getWeightedEventsNoTime(), exp_constant); break; } diff --git a/Framework/Algorithms/src/ImggTomographicReconstruction.cpp b/Framework/Algorithms/src/ImggTomographicReconstruction.cpp index d098fc72f0c6690c608fae26c0a6cd13c58292f5..556183edfa9d72b4dc036a7952adeeb8dc6eb4b1 100644 --- a/Framework/Algorithms/src/ImggTomographicReconstruction.cpp +++ b/Framework/Algorithms/src/ImggTomographicReconstruction.cpp @@ -301,8 +301,7 @@ ImggTomographicReconstruction::prepareInputData( for (int slice = 0; slice < static_cast<int>(wksg->size()); ++slice) { size_t startSlice = slice * oneSliceSize; for (size_t row = 0; row < ysize; ++row) { - const Mantid::API::ISpectrum *specRow = fwks->getSpectrum(row); - const auto &dataY = specRow->readY(); + const auto &dataY = fwks->getSpectrum(row).readY(); size_t startRow = startSlice + row * ysize; // MSVC will produce C4244 warnings in <xutility> (double=>float // converstion) @@ -397,13 +396,13 @@ ImggTomographicReconstruction::buildOutputWks(const std::vector<float> &dataVol, xsize + 1, xsize)); size_t startSlice = slice * oneSliceSize; for (size_t row = 0; row < ysize; ++row) { - Mantid::API::ISpectrum *specRow = sliceWS->getSpectrum(row); - auto &dataX = specRow->dataX(); + auto &specRow = sliceWS->getSpectrum(row); + auto &dataX = specRow.dataX(); std::fill(dataX.begin(), dataX.end(), static_cast<double>(row)); size_t startRow = startSlice + row * ysize; size_t endRow = startRow + xsize; - auto &dataY = specRow->dataY(); + auto &dataY = specRow.dataY(); std::transform(dataVol.begin() + startRow, dataVol.begin() + endRow, dataY.begin(), DoubleToFloatStd()); } diff --git a/Framework/Algorithms/src/IntegrateByComponent.cpp b/Framework/Algorithms/src/IntegrateByComponent.cpp index cc2eb4715a0265aa5e7a4566c7a5b127fcbd65aa..b46570ef03c2bd9fae2a0c644fb09eb6900c5cf8 100644 --- a/Framework/Algorithms/src/IntegrateByComponent.cpp +++ b/Framework/Algorithms/src/IntegrateByComponent.cpp @@ -92,9 +92,9 @@ void IntegrateByComponent::exec() { for (int i = 0; i < static_cast<int>(hists.size()); ++i) { // NOLINT PARALLEL_START_INTERUPT_REGION - const std::set<detid_t> &detids = + const auto &detids = integratedWS->getSpectrum(hists[i]) - ->getDetectorIDs(); // should be only one detector per spectrum + .getDetectorIDs(); // should be only one detector per spectrum if (instrument->isDetectorMasked(detids)) continue; if (instrument->isMonitor(detids)) @@ -135,7 +135,7 @@ void IntegrateByComponent::exec() { PARALLEL_START_INTERUPT_REGION const std::set<detid_t> &detids = integratedWS->getSpectrum(hists[i]) - ->getDetectorIDs(); // should be only one detector per spectrum + .getDetectorIDs(); // should be only one detector per spectrum if (instrument->isDetectorMasked(detids)) continue; if (instrument->isMonitor(detids)) @@ -207,7 +207,7 @@ IntegrateByComponent::makeMap(API::MatrixWorkspace_sptr countsWS, int parents) { } for (size_t i = 0; i < countsWS->getNumberHistograms(); i++) { - detid_t d = (*((countsWS->getSpectrum(i))->getDetectorIDs().begin())); + detid_t d = (*(countsWS->getSpectrum(i).getDetectorIDs().begin())); try { std::vector<boost::shared_ptr<const Mantid::Geometry::IComponent>> anc = instrument->getDetector(d)->getAncestors(); diff --git a/Framework/Algorithms/src/Integration.cpp b/Framework/Algorithms/src/Integration.cpp index ecf832721d8436d8832cbb973a1c801dcec760b6..667c89d733cdc300e76601ea18cb42e929e2af60 100644 --- a/Framework/Algorithms/src/Integration.cpp +++ b/Framework/Algorithms/src/Integration.cpp @@ -161,25 +161,25 @@ void Integration::exec() { } // This is the output - ISpectrum *outSpec = outputWorkspace->getSpectrum(outWI); + auto &outSpec = outputWorkspace->getSpectrum(outWI); // This is the input - const ISpectrum *inSpec = localworkspace->getSpectrum(i); + const auto &inSpec = localworkspace->getSpectrum(i); // Copy spectrum number, detector IDs - outSpec->copyInfoFrom(*inSpec); + outSpec.copyInfoFrom(inSpec); // Retrieve the spectrum into a vector - const MantidVec &X = inSpec->readX(); - const MantidVec &Y = inSpec->readY(); - const MantidVec &E = inSpec->readE(); + const MantidVec &X = inSpec.readX(); + const MantidVec &Y = inSpec.readY(); + const MantidVec &E = inSpec.readE(); // If doing partial bins, we want to set the bin boundaries to the specified // values // regardless of whether they're 'in range' for this spectrum // Have to do this here, ahead of the 'continue' a bit down from here. if (incPartBins) { - outSpec->dataX()[0] = minRange; - outSpec->dataX()[1] = maxRange; + outSpec.dataX()[0] = minRange; + outSpec.dataX()[1] = maxRange; } // Find the range [min,max] @@ -259,12 +259,12 @@ void Integration::exec() { sumE += eval * eval * fraction * fraction; } } else { - outSpec->dataX()[0] = lowit == X.end() ? *(lowit - 1) : *(lowit); - outSpec->dataX()[1] = *highit; + outSpec.dataX()[0] = lowit == X.end() ? *(lowit - 1) : *(lowit); + outSpec.dataX()[1] = *highit; } - outSpec->dataY()[0] = sumY; - outSpec->dataE()[0] = sqrt(sumE); // Propagate Gaussian error + outSpec.dataY()[0] = sumY; + outSpec.dataE()[0] = sqrt(sumE); // Propagate Gaussian error progress.report(); PARALLEL_END_INTERUPT_REGION diff --git a/Framework/Algorithms/src/MaskBins.cpp b/Framework/Algorithms/src/MaskBins.cpp index 894dc88288596e4c130a0ae6d9c0423b60cbe142..348d33ef83aa91275028b38cb6d3ecdcc1966e28 100644 --- a/Framework/Algorithms/src/MaskBins.cpp +++ b/Framework/Algorithms/src/MaskBins.cpp @@ -178,7 +178,7 @@ void MaskBins::execEvent() { for (int i = 0; i < static_cast<int>(this->spectra_list.size()); // NOLINT ++i) { PARALLEL_START_INTERUPT_REGION - outputWS->getEventList(this->spectra_list[i]).maskTof(m_startX, m_endX); + outputWS->getSpectrum(this->spectra_list[i]).maskTof(m_startX, m_endX); progress.report(); PARALLEL_END_INTERUPT_REGION } @@ -188,7 +188,7 @@ void MaskBins::execEvent() { PARALLEL_FOR1(outputWS) for (int64_t i = 0; i < int64_t(numHists); ++i) { PARALLEL_START_INTERUPT_REGION - outputWS->getEventList(i).maskTof(m_startX, m_endX); + outputWS->getSpectrum(i).maskTof(m_startX, m_endX); progress.report(); PARALLEL_END_INTERUPT_REGION } diff --git a/Framework/Algorithms/src/MaskDetectorsIf.cpp b/Framework/Algorithms/src/MaskDetectorsIf.cpp index 904f2493d27748b30d2aba436bace7f164a3b091..dafbb8613b912e3492487e0eb8620ca3abfdff5a 100644 --- a/Framework/Algorithms/src/MaskDetectorsIf.cpp +++ b/Framework/Algorithms/src/MaskDetectorsIf.cpp @@ -72,7 +72,7 @@ void MaskDetectorsIf::exec() { for (size_t i = 0; i < nspec; ++i) { // Get the list of udets contributing to this spectra - const auto &dets = inputW->getSpectrum(i)->getDetectorIDs(); + const auto &dets = inputW->getSpectrum(i).getDetectorIDs(); if (dets.empty()) continue; diff --git a/Framework/Algorithms/src/MaxMin.cpp b/Framework/Algorithms/src/MaxMin.cpp index 9fbab35482179ff0eb870c123a24cc2bcb043d5e..381a102f218a5be0e40770b45c1f50667540dade 100644 --- a/Framework/Algorithms/src/MaxMin.cpp +++ b/Framework/Algorithms/src/MaxMin.cpp @@ -95,7 +95,7 @@ void MaxMin::exec() { int newindex = i - MinSpec; // Copy over spectrum and detector number info outputWorkspace->getSpectrum(newindex) - ->copyInfoFrom(*localworkspace->getSpectrum(i)); + .copyInfoFrom(localworkspace->getSpectrum(i)); // Retrieve the spectrum into a vector const MantidVec &X = localworkspace->readX(i); diff --git a/Framework/Algorithms/src/MedianDetectorTest.cpp b/Framework/Algorithms/src/MedianDetectorTest.cpp index 5d420aa5c196e498096cdf3ad9f56a8b1254fe92..f361cba51f88bf7df35eb9d48f7f2be6fb0688ae 100644 --- a/Framework/Algorithms/src/MedianDetectorTest.cpp +++ b/Framework/Algorithms/src/MedianDetectorTest.cpp @@ -255,8 +255,7 @@ int MedianDetectorTest::maskOutliers( for (int j = 0; j < static_cast<int>(hists.size()); ++j) { // NOLINT const double value = countsWS->readY(hists[j])[0]; if ((value == 0.) && checkForMask) { - const std::set<detid_t> &detids = - countsWS->getSpectrum(hists[j])->getDetectorIDs(); + const auto &detids = countsWS->getSpectrum(hists[j]).getDetectorIDs(); if (instrument->isDetectorMasked(detids)) { numFailed -= 1; // it was already masked } @@ -333,8 +332,8 @@ int MedianDetectorTest::doDetectorTests( } if (checkForMask) { - const std::set<detid_t> &detids = - countsWS->getSpectrum(hists.at(i))->getDetectorIDs(); + const auto &detids = + countsWS->getSpectrum(hists.at(i)).getDetectorIDs(); if (instrument->isDetectorMasked(detids)) { maskWS->dataY(hists.at(i))[0] = deadValue; continue; diff --git a/Framework/Algorithms/src/MergeRuns.cpp b/Framework/Algorithms/src/MergeRuns.cpp index 35223d39d9de9fb77c886202081c68d51bf2db1a..f409544169e5399ceb864bbde2b474ad4b3d061c 100644 --- a/Framework/Algorithms/src/MergeRuns.cpp +++ b/Framework/Algorithms/src/MergeRuns.cpp @@ -168,7 +168,7 @@ void MergeRuns::buildAdditionTables() { table->reserve(nhist); for (int inWI = 0; inWI < static_cast<int>(nhist); inWI++) { // Get the set of detectors in the output - auto &inDets = ews->getEventList(inWI).getDetectorIDs(); + auto &inDets = ews->getSpectrum(inWI).getDetectorIDs(); bool done = false; @@ -177,7 +177,7 @@ void MergeRuns::buildAdditionTables() { int outWI = inWI; if (outWI < lhs_nhist) // don't go out of bounds { - auto &outDets = lhs->getEventList(outWI).getDetectorIDs(); + auto &outDets = lhs->getSpectrum(outWI).getDetectorIDs(); // Checks that inDets is a subset of outDets if (std::includes(outDets.begin(), outDets.end(), inDets.begin(), @@ -218,7 +218,7 @@ void MergeRuns::buildAdditionTables() { // NOTE: This can be SUPER SLOW! for (outWI = 0; outWI < lhs_nhist; outWI++) { std::set<detid_t> &outDets2 = - lhs->getEventList(outWI).getDetectorIDs(); + lhs->getSpectrum(outWI).getDetectorIDs(); // Another subset check if (std::includes(outDets2.begin(), outDets2.end(), inDets.begin(), inDets.end())) { @@ -282,11 +282,11 @@ void MergeRuns::execEvent() { int64_t inWI = WI.first; int64_t outWI = WI.second; if (outWI >= 0) { - outWS->getEventList(outWI) += addee->getEventList(inWI); + outWS->getSpectrum(outWI) += addee->getSpectrum(inWI); } else { // Add an entry to list outWS->getOrAddEventList(outWS->getNumberHistograms()) += - addee->getEventList(inWI); + addee->getSpectrum(inWI); } } diff --git a/Framework/Algorithms/src/ModeratorTzero.cpp b/Framework/Algorithms/src/ModeratorTzero.cpp index ec2fb521236d78e1952d13fb7407e38028092848..85a0ca797674ebba7568bf0e7c1ae2cd989f2b99 100644 --- a/Framework/Algorithms/src/ModeratorTzero.cpp +++ b/Framework/Algorithms/src/ModeratorTzero.cpp @@ -277,7 +277,7 @@ void ModeratorTzero::execEvent(const std::string &emode) { for (int i = 0; i < static_cast<int>(numHists); ++i) { PARALLEL_START_INTERUPT_REGION size_t wsIndex = static_cast<size_t>(i); - EventList &evlist = outputWS->getEventList(wsIndex); + EventList &evlist = outputWS->getSpectrum(wsIndex); if (evlist.getNumberEvents() > 0) // don't bother with empty lists { IDetector_const_sptr det; diff --git a/Framework/Algorithms/src/ModeratorTzeroLinear.cpp b/Framework/Algorithms/src/ModeratorTzeroLinear.cpp index b59d00260120e1590a2aa701ee0ab1d5c54d6228..9a53224659bc53fe17005fb86bbb1ee675f75894 100644 --- a/Framework/Algorithms/src/ModeratorTzeroLinear.cpp +++ b/Framework/Algorithms/src/ModeratorTzeroLinear.cpp @@ -197,7 +197,7 @@ void ModeratorTzeroLinear::execEvent() { for (int i = 0; i < static_cast<int>(numHists); ++i) { size_t wsIndex = static_cast<size_t>(i); PARALLEL_START_INTERUPT_REGION - EventList &evlist = outputWS->getEventList(wsIndex); + EventList &evlist = outputWS->getSpectrum(wsIndex); if (evlist.getNumberEvents() > 0) // don't bother with empty lists { // Calculate the time from sample to detector 'i' diff --git a/Framework/Algorithms/src/MultipleScatteringCylinderAbsorption.cpp b/Framework/Algorithms/src/MultipleScatteringCylinderAbsorption.cpp index 4132e551dcc4774025c7a0659bef309d4e4ca145..194f1c140170990d6bb7dcae9655d7b9f8c72705 100644 --- a/Framework/Algorithms/src/MultipleScatteringCylinderAbsorption.cpp +++ b/Framework/Algorithms/src/MultipleScatteringCylinderAbsorption.cpp @@ -181,7 +181,7 @@ void MultipleScatteringCylinderAbsorption::exec() { continue; const double tth_rad = out_WSevent->detectorTwoTheta(*det); - EventList &eventList = out_WSevent->getEventList(index); + EventList &eventList = out_WSevent->getSpectrum(index); vector<double> tof_vec, y_vec, err_vec; eventList.getTofs(tof_vec); eventList.getWeights(y_vec); diff --git a/Framework/Algorithms/src/MuonGroupDetectors.cpp b/Framework/Algorithms/src/MuonGroupDetectors.cpp index a2b2edca4ded9e948e77749802b8086241dee071..04cb7c705da057c0e121b888afa58599d5769461 100644 --- a/Framework/Algorithms/src/MuonGroupDetectors.cpp +++ b/Framework/Algorithms/src/MuonGroupDetectors.cpp @@ -105,7 +105,7 @@ void MuonGroupDetectors::exec() { throw std::invalid_argument("Some of the detector IDs were not found"); // We will be setting them anew - outWS->getSpectrum(groupIndex)->clearDetectorIDs(); + outWS->getSpectrum(groupIndex).clearDetectorIDs(); for (auto &wsIndex : wsIndices) { for (size_t i = 0; i < inWS->blocksize(); ++i) { @@ -120,14 +120,14 @@ void MuonGroupDetectors::exec() { // Detectors list of the group should contain all the detectors of it's // elements outWS->getSpectrum(groupIndex) - ->addDetectorIDs(inWS->getSpectrum(wsIndex)->getDetectorIDs()); + .addDetectorIDs(inWS->getSpectrum(wsIndex).getDetectorIDs()); } // Using the first detector X values outWS->dataX(groupIndex) = inWS->dataX(wsIndices.front()); outWS->getSpectrum(groupIndex) - ->setSpectrumNo(static_cast<specnum_t>(groupIndex + 1)); + .setSpectrumNo(static_cast<specnum_t>(groupIndex + 1)); } setProperty("OutputWorkspace", outWS); diff --git a/Framework/Algorithms/src/NormaliseToMonitor.cpp b/Framework/Algorithms/src/NormaliseToMonitor.cpp index ae329fed8b17141902a6f215482275f2900279b0..ea4dc9e164a4893c66523b295ced796981fd326c 100644 --- a/Framework/Algorithms/src/NormaliseToMonitor.cpp +++ b/Framework/Algorithms/src/NormaliseToMonitor.cpp @@ -613,7 +613,7 @@ void NormaliseToMonitor::normaliseBinByBin( if (inputEvent) { // ----------------------------------- EventWorkspace // --------------------------------------- - EventList &outEL = outputEvent->getEventList(i); + EventList &outEL = outputEvent->getSpectrum(i); outEL.divide(X, *Y, *E); } else { // ----------------------------------- Workspace2D diff --git a/Framework/Algorithms/src/PhaseQuadMuon.cpp b/Framework/Algorithms/src/PhaseQuadMuon.cpp index f4825d57ce1aed856575cc19bebbf31ddb20d43e..32bd0c0ec18a0e0657482417a9d1bf9e74bb65d4 100644 --- a/Framework/Algorithms/src/PhaseQuadMuon.cpp +++ b/Framework/Algorithms/src/PhaseQuadMuon.cpp @@ -123,9 +123,9 @@ PhaseQuadMuon::getExponentialDecay(const API::MatrixWorkspace_sptr &ws) { for (size_t h = 0; h < ws->getNumberHistograms(); h++) { - MantidVec X = ws->getSpectrum(h)->readX(); - MantidVec Y = ws->getSpectrum(h)->readY(); - MantidVec E = ws->getSpectrum(h)->readE(); + const auto &X = ws->getSpectrum(h).readX(); + const auto &Y = ws->getSpectrum(h).readY(); + const auto &E = ws->getSpectrum(h).readE(); double s, sx, sy; s = sx = sy = 0; @@ -240,7 +240,7 @@ PhaseQuadMuon::squash(const API::MatrixWorkspace_sptr &ws, imagE[i] = sqrt(imagE[i]); // Regain exponential decay - double X = ws->getSpectrum(0)->readX()[i]; + double X = ws->getSpectrum(0).readX()[i]; double e = exp(-(X - X0) / muLife); realY[i] /= e; imagY[i] /= e; diff --git a/Framework/Algorithms/src/Q1D2.cpp b/Framework/Algorithms/src/Q1D2.cpp index 2f9f158760772d2c578dffbc0e0ed096e16c8b48..c53738e6c72ffd999c884834900cf3e8a89df4ed 100644 --- a/Framework/Algorithms/src/Q1D2.cpp +++ b/Framework/Algorithms/src/Q1D2.cpp @@ -161,7 +161,7 @@ void Q1D2::exec() { det = m_dataWS->getDetector(i); } catch (Exception::NotFoundError &) { g_log.warning() << "Workspace index " << i << " (SpectrumIndex = " - << m_dataWS->getSpectrum(i)->getSpectrumNo() + << m_dataWS->getSpectrum(i).getSpectrumNo() << ") has no detector assigned to it - discarding\n"; // Catch if no detector. Next line tests whether this happened - test // placed @@ -259,9 +259,9 @@ void Q1D2::exec() { PARALLEL_CRITICAL(q1d_spectra_map) { progress.report("Computing I(Q)"); // Add up the detector IDs in the output spectrum at workspace index 0 - const ISpectrum *inSpec = m_dataWS->getSpectrum(i); - ISpectrum *outSpec = outputWS->getSpectrum(0); - outSpec->addDetectorIDs(inSpec->getDetectorIDs()); + const auto &inSpec = m_dataWS->getSpectrum(i); + auto &outSpec = outputWS->getSpectrum(0); + outSpec.addDetectorIDs(inSpec.getDetectorIDs()); } PARALLEL_END_INTERUPT_REGION @@ -346,8 +346,8 @@ Q1D2::setUpOutputWorkspace(const std::vector<double> &binParams) const { outputWS->setX(0, XOut); outputWS->setDistribution(true); - outputWS->getSpectrum(0)->clearDetectorIDs(); - outputWS->getSpectrum(0)->setSpectrumNo(1); + outputWS->getSpectrum(0).clearDetectorIDs(); + outputWS->getSpectrum(0).setSpectrumNo(1); return outputWS; } diff --git a/Framework/Algorithms/src/RRFMuon.cpp b/Framework/Algorithms/src/RRFMuon.cpp index 304af3fe1f2ea9520f5fc7884001f24bf39b3fd9..8c209553da5b9d1294b2131e056bbf4a52977f10 100644 --- a/Framework/Algorithms/src/RRFMuon.cpp +++ b/Framework/Algorithms/src/RRFMuon.cpp @@ -91,11 +91,11 @@ void RRFMuon::exec() { // Put results into output workspace // Real RRF polarization - outputWs->getSpectrum(0)->setSpectrumNo(1); + outputWs->getSpectrum(0).setSpectrumNo(1); outputWs->dataX(0) = inputWs->readX(0); outputWs->dataY(0) = rrfRe; // Imaginary RRF polarization - outputWs->getSpectrum(1)->setSpectrumNo(2); + outputWs->getSpectrum(1).setSpectrumNo(2); outputWs->dataX(1) = inputWs->readX(1); outputWs->dataY(1) = rrfIm; diff --git a/Framework/Algorithms/src/RadiusSum.cpp b/Framework/Algorithms/src/RadiusSum.cpp index 743bdcfab16b86290bc7f8cb8e1bb1205a0adce5..337def356f3c65520c65966f11fe1e340a730e15 100644 --- a/Framework/Algorithms/src/RadiusSum.cpp +++ b/Framework/Algorithms/src/RadiusSum.cpp @@ -135,7 +135,7 @@ std::vector<double> RadiusSum::processInstrumentRadiusSum() { if (bin_n < 0) continue; // not in the limits of min_radius and max_radius - auto refY = inputWS->getSpectrum(i)->readY(); + auto &refY = inputWS->getSpectrum(i).readY(); accumulator[bin_n] += std::accumulate(refY.begin(), refY.end(), 0.0); } catch (Kernel::Exception::NotFoundError &ex) { @@ -167,8 +167,8 @@ std::vector<double> RadiusSum::processNumericImageRadiusSum() { // or the center of the bin, if it is a histogram. g_log.debug() << "Define the X positions of the pixels\n"; - auto refX = inputWS->getSpectrum(0)->readX(); - auto refY = inputWS->getSpectrum(0)->readY(); + auto &refX = inputWS->getSpectrum(0).readX(); + auto &refY = inputWS->getSpectrum(0).readY(); std::vector<double> x_pos(refY.size()); if (refY.size() == refX.size()) { // non-histogram workspace X has n values @@ -183,7 +183,7 @@ std::vector<double> RadiusSum::processNumericImageRadiusSum() { for (size_t i = 0; i < inputWS->getNumberHistograms(); i++) { // pixel values - auto refY = inputWS->getSpectrum(i)->readY(); + auto &refY = inputWS->getSpectrum(i).readY(); // for every pixel for (size_t j = 0; j < refY.size(); j++) { diff --git a/Framework/Algorithms/src/ReadGroupsFromFile.cpp b/Framework/Algorithms/src/ReadGroupsFromFile.cpp index fb2ef667895773727f90319e7fa4de7756eb6abe..3a8825dd99028095b48d9f00c68fe33b1f00970f 100644 --- a/Framework/Algorithms/src/ReadGroupsFromFile.cpp +++ b/Framework/Algorithms/src/ReadGroupsFromFile.cpp @@ -112,27 +112,27 @@ void ReadGroupsFromFile::exec() { bool success = false; for (int64_t i = 0; i < nHist; i++) { - ISpectrum *spec = localWorkspace->getSpectrum(i); - const auto &dets = spec->getDetectorIDs(); + auto &spec = localWorkspace->getSpectrum(i); + const auto &dets = spec.getDetectorIDs(); if (dets.empty()) // Nothing { - spec->dataY()[0] = 0.0; + spec.dataY()[0] = 0.0; continue; } // Find the first detector ID in the list calmap::const_iterator it = calibration.find(*dets.begin()); if (it == calibration.end()) // Could not find the detector { - spec->dataY()[0] = 0.0; + spec.dataY()[0] = 0.0; continue; } if (showunselected) { if (((*it).second).second == 0) - spec->dataY()[0] = 0.0; + spec.dataY()[0] = 0.0; else - spec->dataY()[0] = static_cast<double>(((*it).second).first); + spec.dataY()[0] = static_cast<double>(((*it).second).first); } else - spec->dataY()[0] = static_cast<double>(((*it).second).first); + spec.dataY()[0] = static_cast<double>(((*it).second).first); if (!success) success = true; // At least one detector is found in the cal file } diff --git a/Framework/Algorithms/src/Rebin.cpp b/Framework/Algorithms/src/Rebin.cpp index b146c7a6c7445e9144a2ac8448f407b972798cba..30ef03fe9b5dd09fa19953ee0d382ef1656210fa 100644 --- a/Framework/Algorithms/src/Rebin.cpp +++ b/Framework/Algorithms/src/Rebin.cpp @@ -181,7 +181,7 @@ void Rebin::exec() { outputWS->setX(i, XValues_new); // Get a const event list reference. eventInputWS->dataY() doesn't work. - const EventList &el = eventInputWS->getEventList(i); + const EventList &el = eventInputWS->getSpectrum(i); MantidVec y_data, e_data; // The EventList takes care of histogramming. el.generateHistogram(*XValues_new, y_data, e_data); diff --git a/Framework/Algorithms/src/RebinByPulseTimes.cpp b/Framework/Algorithms/src/RebinByPulseTimes.cpp index fce9355eb4d9257196073111df03d062ad9d68d7..d1ee83f1ae0516496d7f5e3b24b3781559232955 100644 --- a/Framework/Algorithms/src/RebinByPulseTimes.cpp +++ b/Framework/Algorithms/src/RebinByPulseTimes.cpp @@ -62,10 +62,10 @@ void RebinByPulseTimes::doHistogramming(IEventWorkspace_sptr inWS, for (int i = 0; i < histnumber; ++i) { PARALLEL_START_INTERUPT_REGION - const IEventList *el = inWS->getEventListPtr(i); + const auto &el = inWS->getSpectrum(i); MantidVec y_data, e_data; // The EventList takes care of histogramming. - el->generateHistogramPulseTime(*XValues_new, y_data, e_data); + el.generateHistogramPulseTime(*XValues_new, y_data, e_data); // Set the X axis for each output histogram outputWS->setX(i, OutXValues_scaled); diff --git a/Framework/Algorithms/src/RebinByTimeAtSample.cpp b/Framework/Algorithms/src/RebinByTimeAtSample.cpp index 5a3a816bd913ce1ddb7f1bea47b68c350bbcb200..bc7b4ccf67923d480a89fbb9ec3ed627eba0b1eb 100644 --- a/Framework/Algorithms/src/RebinByTimeAtSample.cpp +++ b/Framework/Algorithms/src/RebinByTimeAtSample.cpp @@ -77,11 +77,11 @@ void RebinByTimeAtSample::doHistogramming(IEventWorkspace_sptr inWS, const double tofFactor = correction.factor; - const IEventList *el = inWS->getEventListPtr(i); + const auto &el = inWS->getSpectrum(i); MantidVec y_data, e_data; // The EventList takes care of histogramming. - el->generateHistogramTimeAtSample(*XValues_new, y_data, e_data, tofFactor, - tofOffset); + el.generateHistogramTimeAtSample(*XValues_new, y_data, e_data, tofFactor, + tofOffset); // Set the X axis for each output histogram outputWS->setX(i, OutXValues_scaled); diff --git a/Framework/Algorithms/src/RemoveLowResTOF.cpp b/Framework/Algorithms/src/RemoveLowResTOF.cpp index ba06cd33909d1e5218d20957d3c0922ff11d4b06..ede2da959788d55cccf01d78824f59a37eb60526 100644 --- a/Framework/Algorithms/src/RemoveLowResTOF.cpp +++ b/Framework/Algorithms/src/RemoveLowResTOF.cpp @@ -190,46 +190,45 @@ void RemoveLowResTOF::execEvent() { // do the actual work for (size_t workspaceIndex = 0; workspaceIndex < m_numberOfSpectra; workspaceIndex++) { - if (outW->getEventList(workspaceIndex).getNumberEvents() > 0) { + if (outW->getSpectrum(workspaceIndex).getNumberEvents() > 0) { double tmin = this->calcTofMin(workspaceIndex); if (tmin != tmin) { // Problematic g_log.warning() << "tmin for workspaceIndex " << workspaceIndex << " is nan. Clearing out data. " << "There are " - << outW->getEventList(workspaceIndex).getNumberEvents() + << outW->getSpectrum(workspaceIndex).getNumberEvents() << " of it. \n"; numClearedEventLists += 1; - numClearedEvents += - outW->getEventList(workspaceIndex).getNumberEvents(); - outW->getEventList(workspaceIndex).clear(false); + numClearedEvents += outW->getSpectrum(workspaceIndex).getNumberEvents(); + outW->getSpectrum(workspaceIndex).clear(false); if (m_outputLowResTOF) - lowW->getEventList(workspaceIndex).clear(false); + lowW->getSpectrum(workspaceIndex).clear(false); } else if (tmin > 0.) { // there might be events between 0 and tmin (i.e., low resolution) - outW->getEventList(workspaceIndex).maskTof(0., tmin); - if (outW->getEventList(workspaceIndex).getNumberEvents() == 0) + outW->getSpectrum(workspaceIndex).maskTof(0., tmin); + if (outW->getSpectrum(workspaceIndex).getNumberEvents() == 0) numClearedEventLists += 1; if (m_outputLowResTOF) { - double tmax = lowW->getEventList(workspaceIndex).getTofMax(); + double tmax = lowW->getSpectrum(workspaceIndex).getTofMax(); if (tmax != tmax) { g_log.warning() << "tmax for workspaceIndex " << workspaceIndex << " is nan. Clearing out data. \n"; - lowW->getEventList(workspaceIndex).clear(false); + lowW->getSpectrum(workspaceIndex).clear(false); } else { // There is possibility that tmin calculated is larger than TOF-MAX // of the spectrum if (tmax + DBL_MIN > tmin) - lowW->getEventList(workspaceIndex).maskTof(tmin, tmax + DBL_MIN); + lowW->getSpectrum(workspaceIndex).maskTof(tmin, tmax + DBL_MIN); } } } else { // do nothing if tmin <= 0. for outW if (m_outputLowResTOF) { // tmin = 0. no event will be in low resolution - lowW->getEventList(workspaceIndex).clear(false); + lowW->getSpectrum(workspaceIndex).clear(false); } } // } @@ -259,8 +258,7 @@ double RemoveLowResTOF::calcTofMin(const std::size_t workspaceIndex) { // Get a vector of detector IDs std::vector<detid_t> detNumbers; - const std::set<detid_t> &detSet = - m_inputWS->getSpectrum(workspaceIndex)->getDetectorIDs(); + const auto &detSet = m_inputWS->getSpectrum(workspaceIndex).getDetectorIDs(); detNumbers.assign(detSet.begin(), detSet.end()); double tmin = 0.; diff --git a/Framework/Algorithms/src/ResampleX.cpp b/Framework/Algorithms/src/ResampleX.cpp index ff847195ddce082aabafdc3d24d4afac1d078913..2e082e40c52fdabd60e2a6cb4e86da0516134297 100644 --- a/Framework/Algorithms/src/ResampleX.cpp +++ b/Framework/Algorithms/src/ResampleX.cpp @@ -142,7 +142,7 @@ string determineXMinMax(MatrixWorkspace_sptr inputWS, vector<double> &xmins, for (size_t i = 0; i < numSpectra; ++i) { // determine ranges if necessary if (updateXMins || updateXMaxs) { - const MantidVec &xvalues = inputWS->getSpectrum(i)->dataX(); + const MantidVec &xvalues = inputWS->getSpectrum(i).dataX(); if (updateXMins) { if (boost::math::isnan(xvalues.front())) { xmins.push_back(xmin_wksp); @@ -353,7 +353,7 @@ void ResampleX::exec() { g_log.debug() << "delta[wkspindex=" << wkspIndex << "] = " << delta << " xmin=" << xmins[wkspIndex] << " xmax=" << xmaxs[wkspIndex] << "\n"; - outputEventWS->getSpectrum(wkspIndex)->setX(xValues); + outputEventWS->getSpectrum(wkspIndex).setX(xValues); prog.report(name()); // Report progress PARALLEL_END_INTERUPT_REGION } @@ -392,7 +392,7 @@ void ResampleX::exec() { outputWS->setX(wkspIndex, xValues); // Get a const event list reference. inputEventWS->dataY() doesn't work. - const EventList &el = inputEventWS->getEventList(wkspIndex); + const EventList &el = inputEventWS->getSpectrum(wkspIndex); MantidVec y_data, e_data; // The EventList takes care of histogramming. el.generateHistogram(xValues, y_data, e_data); diff --git a/Framework/Algorithms/src/RingProfile.cpp b/Framework/Algorithms/src/RingProfile.cpp index bc3da670963a24703948950e3f61a3db53e92d0b..62aaba74f0179a00e82e25bf1f12390f998a4648 100644 --- a/Framework/Algorithms/src/RingProfile.cpp +++ b/Framework/Algorithms/src/RingProfile.cpp @@ -423,9 +423,7 @@ void RingProfile::processInstrumentRingProfile( g_log.debug() << "Bin for the index " << i << " = " << bin_n << " Pos = " << det->getPos() << '\n'; - // get the reference to the spectrum - auto spectrum_pt = inputWS->getSpectrum(i); - const MantidVec &refY = spectrum_pt->dataY(); + const MantidVec &refY = inputWS->getSpectrum(i).dataY(); // accumulate the values of this spectrum inside this bin for (size_t sp_ind = 0; sp_ind < inputWS->blocksize(); sp_ind++) output_bins[bin_n] += refY[sp_ind]; diff --git a/Framework/Algorithms/src/ScaleX.cpp b/Framework/Algorithms/src/ScaleX.cpp index 8d843d5cb373251d92d0908359b1743a940beee0..f6b8f8d3681105a1eac9aa484a9e90be9660ed35 100644 --- a/Framework/Algorithms/src/ScaleX.cpp +++ b/Framework/Algorithms/src/ScaleX.cpp @@ -190,12 +190,12 @@ void ScaleX::execEvent() { if ((i >= m_wi_min) && (i <= m_wi_max)) { auto factor = getScaleFactor(outputWS, i); if (op == "Multiply") { - outputWS->getEventList(i).scaleTof(factor); + outputWS->getSpectrum(i).scaleTof(factor); if (factor < 0) { - outputWS->getEventList(i).reverse(); + outputWS->getSpectrum(i).reverse(); } } else if (op == "Add") { - outputWS->getEventList(i).addTof(factor); + outputWS->getSpectrum(i).addTof(factor); } } m_progress->report("Scaling X"); @@ -234,8 +234,7 @@ double ScaleX::getScaleFactor(const API::MatrixWorkspace_const_sptr &inputWS, Geometry::IDetector_const_sptr det; auto inst = inputWS->getInstrument(); - auto *spec = inputWS->getSpectrum(index); - const auto &ids = spec->getDetectorIDs(); + const auto &ids = inputWS->getSpectrum(index).getDetectorIDs(); const size_t ndets(ids.size()); if (ndets > 0) { try { diff --git a/Framework/Algorithms/src/SmoothData.cpp b/Framework/Algorithms/src/SmoothData.cpp index b7f026bda78606b6158d07708f6d72e8b9c449d3..9d29d867e13152106b54091926e0a56565677705 100644 --- a/Framework/Algorithms/src/SmoothData.cpp +++ b/Framework/Algorithms/src/SmoothData.cpp @@ -165,8 +165,7 @@ void SmoothData::exec() { * @return Group number if successful otherwise return -1 */ int SmoothData::validateSpectrumInGroup(size_t wi) { - const std::set<detid_t> &dets = - inputWorkspace->getSpectrum(wi)->getDetectorIDs(); + const auto &dets = inputWorkspace->getSpectrum(wi).getDetectorIDs(); if (dets.empty()) // Not in group { g_log.debug() << wi << " <- this workspace index is empty!\n"; diff --git a/Framework/Algorithms/src/SmoothNeighbours.cpp b/Framework/Algorithms/src/SmoothNeighbours.cpp index 462e772d853ee64a93e3bcb643451254bbcc9d56..4eed0bb71f97b0aad8342fae578ff7d859ade392 100644 --- a/Framework/Algorithms/src/SmoothNeighbours.cpp +++ b/Framework/Algorithms/src/SmoothNeighbours.cpp @@ -355,7 +355,7 @@ void SmoothNeighbours::findNeighboursUbiqutious() { // We want to skip monitors try { // Get the list of detectors in this pixel - const auto &dets = inWS->getSpectrum(wi)->getDetectorIDs(); + const auto &dets = inWS->getSpectrum(wi).getDetectorIDs(); det = inst->getDetector(*dets.begin()); if (det->isMonitor()) continue; // skip monitor @@ -375,7 +375,7 @@ void SmoothNeighbours::findNeighboursUbiqutious() { continue; // skip missing detector } - specnum_t inSpec = inWS->getSpectrum(wi)->getSpectrumNo(); + specnum_t inSpec = inWS->getSpectrum(wi).getSpectrumNo(); // Step one - Get the number of specified neighbours SpectraDistanceMap insideGrid = @@ -409,7 +409,7 @@ void SmoothNeighbours::findNeighboursUbiqutious() { if (sum > 1) { // Get the list of detectors in this pixel const std::set<detid_t> &dets = - inWS->getSpectrum(neighWI)->getDetectorIDs(); + inWS->getSpectrum(neighWI).getDetectorIDs(); det = inst->getDetector(*dets.begin()); neighbParent = det->getParent(); neighbGParent = neighbParent->getParent(); @@ -625,14 +625,14 @@ void SmoothNeighbours::execWorkspace2D() { for (int outWIi = 0; outWIi < int(numberOfSpectra); outWIi++) { PARALLEL_START_INTERUPT_REGION - ISpectrum *outSpec = outWS->getSpectrum(outWIi); + auto &outSpec = outWS->getSpectrum(outWIi); // Reset the Y and E vectors - outSpec->clearData(); - MantidVec &outY = outSpec->dataY(); + outSpec.clearData(); + MantidVec &outY = outSpec.dataY(); // We will temporarily carry the squared error - MantidVec &outE = outSpec->dataE(); + MantidVec &outE = outSpec.dataE(); // tmp to carry the X Data. - MantidVec &outX = outSpec->dataX(); + MantidVec &outX = outSpec.dataX(); // Which are the neighbours? std::vector<weightedNeighbour> &neighbours = m_neighbours[outWIi]; @@ -642,11 +642,11 @@ void SmoothNeighbours::execWorkspace2D() { double weight = it->second; double weightSquared = weight * weight; - const ISpectrum *inSpec = inWS->getSpectrum(inWI); - inSpec->lockData(); - const MantidVec &inY = inSpec->readY(); - const MantidVec &inE = inSpec->readE(); - const MantidVec &inX = inSpec->readX(); + const auto &inSpec = inWS->getSpectrum(inWI); + inSpec.lockData(); + const MantidVec &inY = inSpec.readY(); + const MantidVec &inE = inSpec.readE(); + const MantidVec &inX = inSpec.readX(); for (size_t i = 0; i < YLength; i++) { // Add the weighted signal @@ -664,7 +664,7 @@ void SmoothNeighbours::execWorkspace2D() { outX[YLength] = inX[YLength]; } - inSpec->unlockData(); + inSpec.unlockData(); } //(each neighbour) // Now un-square the error, since we summed it in quadrature @@ -694,29 +694,21 @@ void SmoothNeighbours::setupNewInstrument(MatrixWorkspace_sptr outws) { size_t numberOfSpectra = outws->getNumberHistograms(); for (int outWIi = 0; outWIi < int(numberOfSpectra); outWIi++) { - ISpectrum *outSpec = outws->getSpectrum(outWIi); + auto &outSpec = outws->getSpectrum(outWIi); /* g_log.notice() << "[DBx555] Original spectrum number for wsindex " << outWIi - << " = " << outSpec->getSpectrumNo() << '\n'; - outSpec->setSpectrumNo(outWIi+1); + << " = " << outSpec.getSpectrumNo() << '\n'; + outSpec.setSpectrumNo(outWIi+1); */ // Reset detectors - outSpec->clearDetectorIDs(); - ; + outSpec.clearDetectorIDs(); // Which are the neighbours? - std::vector<weightedNeighbour> &neighbours = m_neighbours[outWIi]; - std::vector<weightedNeighbour>::iterator it; - for (it = neighbours.begin(); it != neighbours.end(); ++it) { - size_t inWI = it->first; - - const ISpectrum *inSpec = inWS->getSpectrum(inWI); - - auto thesedetids = inSpec->getDetectorIDs(); - outSpec->addDetectorIDs(thesedetids); - - } //(each neighbour) + for (const auto &neighbor : m_neighbours[outWIi]) { + const auto &inSpec = inWS->getSpectrum(neighbor.first); + outSpec.addDetectorIDs(inSpec.getDetectorIDs()); + } } return; @@ -745,44 +737,29 @@ void SmoothNeighbours::spreadPixels(MatrixWorkspace_sptr outws) { API::WorkspaceFactory::Instance().initializeFromParent(inWS, outws2, false); // Go through all the input workspace for (int outWIi = 0; outWIi < int(numberOfSpectra); outWIi++) { - ISpectrum *inSpec = inWS->getSpectrum(outWIi); - MantidVec &inX = inSpec->dataX(); - - auto thesedetids = inSpec->getDetectorIDs(); - ISpectrum *outSpec2 = outws2->getSpectrum(outWIi); - MantidVec &outX = outSpec2->dataX(); - outX = inX; - outSpec2->addDetectorIDs(thesedetids); + const auto &inSpec = inWS->getSpectrum(outWIi); + auto &outSpec2 = outws2->getSpectrum(outWIi); + outSpec2.dataX() = inSpec.dataX(); + outSpec2.addDetectorIDs(inSpec.getDetectorIDs()); // Zero the Y and E vectors - outSpec2->clearData(); - outSpec2->dataY().assign(YLength, 0.0); - outSpec2->dataE().assign(YLength, 0.0); + outSpec2.clearData(); + outSpec2.dataY().assign(YLength, 0.0); + outSpec2.dataE().assign(YLength, 0.0); } // Go through all the output workspace const size_t numberOfSpectra2 = outws->getNumberHistograms(); for (int outWIi = 0; outWIi < int(numberOfSpectra2); outWIi++) { - const ISpectrum *outSpec = outws->getSpectrum(outWIi); + const auto &outSpec = outws->getSpectrum(outWIi); // Which are the neighbours? - std::vector<weightedNeighbour> &neighbours = m_neighbours[outWIi]; - std::vector<weightedNeighbour>::iterator it; - for (it = neighbours.begin(); it != neighbours.end(); ++it) { - size_t inWI = it->first; - - ISpectrum *outSpec2 = outws2->getSpectrum(inWI); + for (const auto &neighbor : m_neighbours[outWIi]) { + auto &outSpec2 = outws2->getSpectrum(neighbor.first); // Reset the Y and E vectors - outSpec2->clearData(); - MantidVec &out2Y = outSpec2->dataY(); - MantidVec &out2E = outSpec2->dataE(); - MantidVec &out2X = outSpec2->dataX(); - const MantidVec &outY = outSpec->dataY(); - const MantidVec &outE = outSpec->dataE(); - const MantidVec &outX = outSpec->dataX(); - out2Y = outY; - out2E = outE; - out2X = outX; - } //(each neighbour) + outSpec2.dataY() = outSpec.dataY(); + outSpec2.dataE() = outSpec.dataE(); + outSpec2.dataX() = outSpec.dataX(); + } } this->setProperty("OutputWorkspace", outws2); return; @@ -827,7 +804,7 @@ void SmoothNeighbours::execEvent(Mantid::DataObjects::EventWorkspace_sptr ws) { // if(sum)outEL.copyInfoFrom(*ws->getSpectrum(inWI)); double weight = it->second; // Copy the event list - EventList tmpEL = ws->getEventList(inWI); + EventList tmpEL = ws->getSpectrum(inWI); // Scale it tmpEL *= weight; // Add it diff --git a/Framework/Algorithms/src/SofQWCentre.cpp b/Framework/Algorithms/src/SofQWCentre.cpp index a559412ad7bc8c010862bfc4fc32ed0534eb6601..dc593ba4f1bafe1fbec33da244e04d4bc035609f 100644 --- a/Framework/Algorithms/src/SofQWCentre.cpp +++ b/Framework/Algorithms/src/SofQWCentre.cpp @@ -224,7 +224,7 @@ void SofQWCentre::exec() { // Add this spectra-detector pair to the mapping specNumberMapping.push_back( - outputWorkspace->getSpectrum(qIndex)->getSpectrumNo()); + outputWorkspace->getSpectrum(qIndex).getSpectrumNo()); detIDMapping.push_back(det->getID()); // And add the data and it's error to that bin, taking into account diff --git a/Framework/Algorithms/src/SofQWNormalisedPolygon.cpp b/Framework/Algorithms/src/SofQWNormalisedPolygon.cpp index 494004903eaaf871044895689098cf06579190de..05cfb7d392cd2370aa73f75eedb1b82a843fc35c 100644 --- a/Framework/Algorithms/src/SofQWNormalisedPolygon.cpp +++ b/Framework/Algorithms/src/SofQWNormalisedPolygon.cpp @@ -130,7 +130,7 @@ void SofQWNormalisedPolygon::exec() { const double phiUpper = phi + phiHalfWidth; const double efixed = m_EmodeProperties.getEFixed(*detector); - const specnum_t specNo = inputWS->getSpectrum(i)->getSpectrumNo(); + const specnum_t specNo = inputWS->getSpectrum(i).getSpectrumNo(); std::stringstream logStream; for (size_t j = 0; j < nEnergyBins; ++j) { m_progress->report("Computing polygon intersections"); @@ -168,7 +168,7 @@ void SofQWNormalisedPolygon::exec() { // Add this spectra-detector pair to the mapping PARALLEL_CRITICAL(SofQWNormalisedPolygon_spectramap) { specNumberMapping.push_back( - outputWS->getSpectrum(qIndex - 1)->getSpectrumNo()); + outputWS->getSpectrum(qIndex - 1).getSpectrumNo()); detIDMapping.push_back(detector->getID()); } } @@ -290,7 +290,7 @@ void SofQWNormalisedPolygon::initAngularCachesNonPSD( m_thetaWidths[i] = std::fabs(2.0 * std::atan(boxWidth / l2)); if (g_log.is(Logger::Priority::PRIO_DEBUG)) { g_log.debug() << "Detector at spectrum =" - << workspace->getSpectrum(i)->getSpectrumNo() + << workspace->getSpectrum(i).getSpectrumNo() << ", width=" << m_thetaWidths[i] * 180.0 / M_PI << " degrees\n"; } @@ -319,7 +319,7 @@ void SofQWNormalisedPolygon::initAngularCachesPSD( m_progress->report("Calculating detector angular widths"); DetConstPtr detector = workspace->getDetector(i); g_log.debug() << "Current histogram: " << i << '\n'; - specnum_t inSpec = workspace->getSpectrum(i)->getSpectrumNo(); + specnum_t inSpec = workspace->getSpectrum(i).getSpectrumNo(); SpectraDistanceMap neighbours = workspace->getNeighboursExact(inSpec, numNeighbours, true); diff --git a/Framework/Algorithms/src/SofQWPolygon.cpp b/Framework/Algorithms/src/SofQWPolygon.cpp index f666539531d77f221a853d87c4fbfbff0a6b1a81..3c30f431b15b7175f7d6ef8fc98db391036ba823 100644 --- a/Framework/Algorithms/src/SofQWPolygon.cpp +++ b/Framework/Algorithms/src/SofQWPolygon.cpp @@ -118,7 +118,7 @@ void SofQWPolygon::exec() { // Add this spectra-detector pair to the mapping PARALLEL_CRITICAL(SofQWPolygon_spectramap) { specNumberMapping.push_back( - outputWS->getSpectrum(qIndex - 1)->getSpectrumNo()); + outputWS->getSpectrum(qIndex - 1).getSpectrumNo()); detIDMapping.push_back(det->getID()); } } diff --git a/Framework/Algorithms/src/SolidAngle.cpp b/Framework/Algorithms/src/SolidAngle.cpp index ae231f2a290ae48fdb4b9ac16fc5dba616129bf8..c9577562c902349f46b73795f50fa0377253c462 100644 --- a/Framework/Algorithms/src/SolidAngle.cpp +++ b/Framework/Algorithms/src/SolidAngle.cpp @@ -113,7 +113,7 @@ void SolidAngle::exec() { int i = j + m_MinSpec; try { // Copy over the spectrum number & detector IDs - outputWS->getSpectrum(j)->copyInfoFrom(*inputWS->getSpectrum(i)); + outputWS->getSpectrum(j).copyInfoFrom(inputWS->getSpectrum(i)); // Now get the detector to which this relates Geometry::IDetector_const_sptr det = inputWS->getDetector(i); // Solid angle should be zero if detector is masked ('dead') diff --git a/Framework/Algorithms/src/SpatialGrouping.cpp b/Framework/Algorithms/src/SpatialGrouping.cpp index a917f76d303f87395d1568c172122a0d83a6e310..41832893d72e4bd80f01cf83a8f53645b0bc7fea 100644 --- a/Framework/Algorithms/src/SpatialGrouping.cpp +++ b/Framework/Algorithms/src/SpatialGrouping.cpp @@ -73,8 +73,8 @@ void SpatialGrouping::exec() { // Make a map key = spectrum number, value = detector at that spectrum m_detectors.clear(); for (size_t i = 0; i < inputWorkspace->getNumberHistograms(); i++) { - const ISpectrum *spec = inputWorkspace->getSpectrum(i); - m_detectors[spec->getSpectrumNo()] = inputWorkspace->getDetector(i); + const auto &spec = inputWorkspace->getSpectrum(i); + m_detectors[spec.getSpectrumNo()] = inputWorkspace->getDetector(i); } // TODO: There is a confusion in this algorithm between detector IDs and @@ -172,8 +172,8 @@ void SpatialGrouping::exec() { // smap.getDetectors((*grpIt)[i]); size_t workspaceIndex = inputWorkspace->getIndexFromSpectrumNumber((*grpIt)[i]); - const std::set<detid_t> &detIds = - inputWorkspace->getSpectrum(workspaceIndex)->getDetectorIDs(); + const auto &detIds = + inputWorkspace->getSpectrum(workspaceIndex).getDetectorIDs(); for (auto detId : detIds) { xml << "," << detId; } diff --git a/Framework/Algorithms/src/SumEventsByLogValue.cpp b/Framework/Algorithms/src/SumEventsByLogValue.cpp index bd27762767e5749795b7f537bc690f1dbd1d7c58..efe90728cedc24bf202459d8f9293970c118d318 100644 --- a/Framework/Algorithms/src/SumEventsByLogValue.cpp +++ b/Framework/Algorithms/src/SumEventsByLogValue.cpp @@ -158,7 +158,7 @@ void SumEventsByLogValue::createTableOutput( PARALLEL_FOR1(m_inputWorkspace) for (int spec = 0; spec < numSpec; ++spec) { PARALLEL_START_INTERUPT_REGION - const IEventList &eventList = m_inputWorkspace->getEventList(spec); + const IEventList &eventList = m_inputWorkspace->getSpectrum(spec); filterEventList(eventList, minVal, maxVal, log, Y); prog.report(); PARALLEL_END_INTERUPT_REGION @@ -321,7 +321,7 @@ void SumEventsByLogValue::addMonitorCounts(ITableWorkspace_sptr outputWorkspace, const std::string monitorName = monitorWorkspace->getDetector(spec)->getName(); auto monitorCounts = outputWorkspace->addColumn("int", monitorName); - const IEventList &eventList = monitorWorkspace->getEventList(spec); + const IEventList &eventList = monitorWorkspace->getSpectrum(spec); // Accumulate things in a local vector before transferring to the table // workspace std::vector<int> Y(xLength); @@ -427,7 +427,7 @@ void SumEventsByLogValue::createBinnedOutput( PARALLEL_FOR1(m_inputWorkspace) for (int spec = 0; spec < numSpec; ++spec) { PARALLEL_START_INTERUPT_REGION - const IEventList &eventList = m_inputWorkspace->getEventList(spec); + const IEventList &eventList = m_inputWorkspace->getSpectrum(spec); const auto pulseTimes = eventList.getPulseTimes(); for (auto pulseTime : pulseTimes) { // Find the value of the log at the time of this event diff --git a/Framework/Algorithms/src/SumSpectra.cpp b/Framework/Algorithms/src/SumSpectra.cpp index 28c04ea55c0a09af308e17a9dcc52752e08f1e03..6b780134ce1b5001c0642c023c452f30a54f57d3 100644 --- a/Framework/Algorithms/src/SumSpectra.cpp +++ b/Framework/Algorithms/src/SumSpectra.cpp @@ -146,14 +146,14 @@ void SumSpectra::exec() { Progress progress(this, 0, 1, this->m_indices.size()); // This is the (only) output spectrum - ISpectrum *outSpec = outputWorkspace->getSpectrum(0); + auto &outSpec = outputWorkspace->getSpectrum(0); // Copy over the bin boundaries - outSpec->dataX() = localworkspace->readX(0); + outSpec.dataX() = localworkspace->readX(0); // Build a new spectra map - outSpec->setSpectrumNo(m_outSpecNum); - outSpec->clearDetectorIDs(); + outSpec.setSpectrumNo(m_outSpecNum); + outSpec.clearDetectorIDs(); if (localworkspace->id() == "RebinnedOutput") { this->doRebinnedOutput(outputWorkspace, progress, numSpectra, numMasked, @@ -164,7 +164,7 @@ void SumSpectra::exec() { } // Pointer to sqrt function - MantidVec &YError = outSpec->dataE(); + MantidVec &YError = outSpec.dataE(); typedef double (*uf)(double); uf rs = std::sqrt; // take the square root of all the accumulated squared errors - Assumes @@ -194,7 +194,7 @@ specnum_t SumSpectra::getOutputSpecNo(MatrixWorkspace_const_sptr localworkspace) { // initial value specnum_t specId = - localworkspace->getSpectrum(*(this->m_indices.begin()))->getSpectrumNo(); + localworkspace->getSpectrum(*(this->m_indices.begin())).getSpectrumNo(); // the total number of spectra int totalSpec = static_cast<int>(localworkspace->getNumberHistograms()); @@ -202,7 +202,7 @@ SumSpectra::getOutputSpecNo(MatrixWorkspace_const_sptr localworkspace) { specnum_t temp; for (const auto index : this->m_indices) { if (index < totalSpec) { - temp = localworkspace->getSpectrum(index)->getSpectrumNo(); + temp = localworkspace->getSpectrum(index).getSpectrumNo(); if (temp < specId) specId = temp; } @@ -223,12 +223,12 @@ SumSpectra::getOutputSpecNo(MatrixWorkspace_const_sptr localworkspace) { * spectra for event workspace. */ void SumSpectra::doWorkspace2D(MatrixWorkspace_const_sptr localworkspace, - ISpectrum *outSpec, Progress &progress, + ISpectrum &outSpec, Progress &progress, size_t &numSpectra, size_t &numMasked, size_t &numZeros) { // Get references to the output workspaces's data vectors - MantidVec &YSum = outSpec->dataY(); - MantidVec &YError = outSpec->dataE(); + MantidVec &YSum = outSpec.dataY(); + MantidVec &YError = outSpec.dataE(); MantidVec Weight; std::vector<size_t> nZeros; @@ -287,7 +287,7 @@ void SumSpectra::doWorkspace2D(MatrixWorkspace_const_sptr localworkspace, } // Map all the detectors onto the spectrum of the output - outSpec->addDetectorIDs(localworkspace->getSpectrum(i)->getDetectorIDs()); + outSpec.addDetectorIDs(localworkspace->getSpectrum(i).getDetectorIDs()); progress.report(); } @@ -338,9 +338,9 @@ void SumSpectra::doRebinnedOutput(MatrixWorkspace_sptr outputWorkspace, boost::dynamic_pointer_cast<RebinnedOutput>(outputWorkspace); // Get references to the output workspaces's data vectors - ISpectrum *outSpec = outputWorkspace->getSpectrum(0); - MantidVec &YSum = outSpec->dataY(); - MantidVec &YError = outSpec->dataE(); + auto &outSpec = outputWorkspace->getSpectrum(0); + MantidVec &YSum = outSpec.dataY(); + MantidVec &YError = outSpec.dataE(); MantidVec &FracSum = outWS->dataF(0); MantidVec Weight; std::vector<size_t> nZeros; @@ -404,7 +404,7 @@ void SumSpectra::doRebinnedOutput(MatrixWorkspace_sptr outputWorkspace, } // Map all the detectors onto the spectrum of the output - outSpec->addDetectorIDs(localworkspace->getSpectrum(i)->getDetectorIDs()); + outSpec.addDetectorIDs(localworkspace->getSpectrum(i).getDetectorIDs()); progress.report(); } @@ -440,7 +440,7 @@ void SumSpectra::execEvent(EventWorkspace_const_sptr localworkspace, Progress progress(this, 0, 1, indices.size()); // Get the pointer to the output event list - EventList &outEL = outputWorkspace->getEventList(0); + EventList &outEL = outputWorkspace->getSpectrum(0); outEL.setSpectrumNo(m_outSpecNum); outEL.clearDetectorIDs(); @@ -473,7 +473,7 @@ void SumSpectra::execEvent(EventWorkspace_const_sptr localworkspace, numSpectra++; // Add the event lists with the operator - const EventList &tOutEL = localworkspace->getEventList(i); + const EventList &tOutEL = localworkspace->getSpectrum(i); if (tOutEL.empty()) { ++numZeros; } diff --git a/Framework/Algorithms/src/UnaryOperation.cpp b/Framework/Algorithms/src/UnaryOperation.cpp index 520ef67eb6f579520f109f837200fe233219dd31..90392a3696d5a2dbc198013543ca28afca46fbb5 100644 --- a/Framework/Algorithms/src/UnaryOperation.cpp +++ b/Framework/Algorithms/src/UnaryOperation.cpp @@ -131,20 +131,20 @@ void UnaryOperation::execEvent() { PARALLEL_START_INTERUPT_REGION // switch to weighted events if needed, and use the appropriate helper // function - EventList *evlist = outputWS->getEventListPtr(i); - switch (evlist->getEventType()) { + auto &evlist = outputWS->getSpectrum(i); + switch (evlist.getEventType()) { case TOF: // Switch to weights if needed. - evlist->switchTo(WEIGHTED); + evlist.switchTo(WEIGHTED); /* no break */ // Fall through case WEIGHTED: - unaryOperationEventHelper(evlist->getWeightedEvents()); + unaryOperationEventHelper(evlist.getWeightedEvents()); break; case WEIGHTED_NOTIME: - unaryOperationEventHelper(evlist->getWeightedEventsNoTime()); + unaryOperationEventHelper(evlist.getWeightedEventsNoTime()); break; } diff --git a/Framework/Algorithms/src/UnwrapSNS.cpp b/Framework/Algorithms/src/UnwrapSNS.cpp index 7a324573df4c0eebf663b16a737975d3f7033963..5715dd8f6ed8b8fdcc1f347e0451f9fec17e020d 100644 --- a/Framework/Algorithms/src/UnwrapSNS.cpp +++ b/Framework/Algorithms/src/UnwrapSNS.cpp @@ -209,8 +209,7 @@ void UnwrapSNS::execEvent() { for (int workspaceIndex = 0; workspaceIndex < m_numberOfSpectra; workspaceIndex++) { // PARALLEL_START_INTERUPT_REGION - std::size_t numEvents = - outW->getEventList(workspaceIndex).getNumberEvents(); + std::size_t numEvents = outW->getSpectrum(workspaceIndex).getNumberEvents(); bool isMonitor; double Ld = this->calculateFlightpath(workspaceIndex, isMonitor); MantidVec time_bins; @@ -222,7 +221,7 @@ void UnwrapSNS::execEvent() { } if (numEvents > 0) { MantidVec times(numEvents); - outW->getEventList(workspaceIndex).getTofs(times); + outW->getSpectrum(workspaceIndex).getTofs(times); double filterVal = m_Tmin * Ld / m_LRef; for (size_t j = 0; j < numEvents; j++) { if (times[j] < filterVal) @@ -230,7 +229,7 @@ void UnwrapSNS::execEvent() { else break; // stop filtering } - outW->getEventList(workspaceIndex).setTofs(times); + outW->getSpectrum(workspaceIndex).setTofs(times); } m_progress->report(); // PARALLEL_END_INTERUPT_REGION diff --git a/Framework/Algorithms/src/VesuvioL1ThetaResolution.cpp b/Framework/Algorithms/src/VesuvioL1ThetaResolution.cpp index 07acb7c697bfbb7a9a8302e9d427d06500a62345..f8aeaa2ac27fc154b9c4ab4a00b9c709ed077825 100644 --- a/Framework/Algorithms/src/VesuvioL1ThetaResolution.cpp +++ b/Framework/Algorithms/src/VesuvioL1ThetaResolution.cpp @@ -210,7 +210,7 @@ void VesuvioL1ThetaResolution::exec() { << '\n'; // Set values in output workspace - const int specNo = m_instWorkspace->getSpectrum(i)->getSpectrumNo(); + const int specNo = m_instWorkspace->getSpectrum(i).getSpectrumNo(); m_outputWorkspace->dataX(0)[i] = specNo; m_outputWorkspace->dataX(1)[i] = specNo; m_outputWorkspace->dataX(2)[i] = specNo; @@ -230,9 +230,9 @@ void VesuvioL1ThetaResolution::exec() { m_l1DistributionWs->dataY(i) = y; - auto spec = m_l1DistributionWs->getSpectrum(i); - spec->setSpectrumNo(specNo); - spec->addDetectorID(det->getID()); + auto &spec = m_l1DistributionWs->getSpectrum(i); + spec.setSpectrumNo(specNo); + spec.addDetectorID(det->getID()); } // Process data for theta distribution @@ -245,9 +245,9 @@ void VesuvioL1ThetaResolution::exec() { m_thetaDistributionWs->dataY(i) = y; - auto spec = m_thetaDistributionWs->getSpectrum(i); - spec->setSpectrumNo(specNo); - spec->addDetectorID(det->getID()); + auto &spec = m_thetaDistributionWs->getSpectrum(i); + spec.setSpectrumNo(specNo); + spec.addDetectorID(det->getID()); } } diff --git a/Framework/Algorithms/src/WienerSmooth.cpp b/Framework/Algorithms/src/WienerSmooth.cpp index e0cd5c911ba41a928f74b6d9dcdaa318fadff73e..4334c5efcea8b6b90f5976601c8fc30e5a6fad6c 100644 --- a/Framework/Algorithms/src/WienerSmooth.cpp +++ b/Framework/Algorithms/src/WienerSmooth.cpp @@ -136,10 +136,10 @@ void WienerSmooth::exec() { // set the axis value if (isSpectra) { - auto inSpectrum = inputWS->getSpectrum(inIndex); - auto outSpectrum = outputWS->getSpectrum(outIndex); - outSpectrum->setSpectrumNo(inSpectrum->getSpectrumNo()); - outSpectrum->setDetectorIDs(inSpectrum->getDetectorIDs()); + auto &inSpectrum = inputWS->getSpectrum(inIndex); + auto &outSpectrum = outputWS->getSpectrum(outIndex); + outSpectrum.setSpectrumNo(inSpectrum.getSpectrumNo()); + outSpectrum.setDetectorIDs(inSpectrum.getDetectorIDs()); } else if (isNumeric) { outAxis->setValue(outIndex, inAxis->getValue(inIndex)); } else if (inTextAxis && outTextAxis) { @@ -428,4 +428,4 @@ WienerSmooth::copyInput(API::MatrixWorkspace_sptr inputWS, size_t wsIndex) { } } // namespace Algorithms -} // namespace Mantid \ No newline at end of file +} // namespace Mantid diff --git a/Framework/Algorithms/src/WorkspaceJoiners.cpp b/Framework/Algorithms/src/WorkspaceJoiners.cpp index f3350d9c309051586d17d6bfbbdf8f952923173a..627dce0694fa663c957464e6f07e55089af6cc08 100644 --- a/Framework/Algorithms/src/WorkspaceJoiners.cpp +++ b/Framework/Algorithms/src/WorkspaceJoiners.cpp @@ -56,14 +56,14 @@ WorkspaceJoiners::execWS2D(API::MatrixWorkspace_const_sptr ws1, PARALLEL_FOR2(ws1, output) for (int64_t i = 0; i < nhist1; ++i) { PARALLEL_START_INTERUPT_REGION - ISpectrum *outSpec = output->getSpectrum(i); - const ISpectrum *inSpec = ws1->getSpectrum(i); + auto &outSpec = output->getSpectrum(i); + const auto &inSpec = ws1->getSpectrum(i); // Copy X,Y,E - outSpec->setX(XValues); - outSpec->setData(inSpec->dataY(), inSpec->dataE()); + outSpec.setX(XValues); + outSpec.setData(inSpec.dataY(), inSpec.dataE()); // Copy the spectrum number/detector IDs - outSpec->copyInfoFrom(*inSpec); + outSpec.copyInfoFrom(inSpec); // Propagate binmasking, if needed if (ws1->hasMaskedBins(i)) { @@ -86,15 +86,15 @@ WorkspaceJoiners::execWS2D(API::MatrixWorkspace_const_sptr ws1, for (int64_t j = 0; j < nhist2; ++j) { PARALLEL_START_INTERUPT_REGION // The spectrum in the output workspace - ISpectrum *outSpec = output->getSpectrum(nhist1 + j); + auto &outSpec = output->getSpectrum(nhist1 + j); // Spectrum in the second workspace - const ISpectrum *inSpec = ws2->getSpectrum(j); + const auto &inSpec = ws2->getSpectrum(j); // Copy X,Y,E - outSpec->setX(XValues); - outSpec->setData(inSpec->dataY(), inSpec->dataE()); + outSpec.setX(XValues); + outSpec.setData(inSpec.dataY(), inSpec.dataE()); // Copy the spectrum number/detector IDs - outSpec->copyInfoFrom(*inSpec); + outSpec.copyInfoFrom(inSpec); // Propagate masking, if needed if (ws2->hasMaskedBins(j)) { @@ -153,10 +153,10 @@ MatrixWorkspace_sptr WorkspaceJoiners::execEvent() { for (int64_t i = 0; i < nhist1; ++i) { // Copy the events over output->getOrAddEventList(i) = - event_ws1->getEventList(i); // Should fire the copy constructor - ISpectrum *outSpec = output->getSpectrum(i); - const ISpectrum *inSpec = event_ws1->getSpectrum(i); - outSpec->copyInfoFrom(*inSpec); + event_ws1->getSpectrum(i); // Should fire the copy constructor + auto &outSpec = output->getSpectrum(i); + const auto &inSpec = event_ws1->getSpectrum(i); + outSpec.copyInfoFrom(inSpec); m_progress->report(); } @@ -168,10 +168,10 @@ MatrixWorkspace_sptr WorkspaceJoiners::execEvent() { int64_t output_wi = j + nhist1; // Copy the events over output->getOrAddEventList(output_wi) = - event_ws2->getEventList(j); // Should fire the copy constructor - ISpectrum *outSpec = output->getSpectrum(output_wi); - const ISpectrum *inSpec = event_ws2->getSpectrum(j); - outSpec->copyInfoFrom(*inSpec); + event_ws2->getSpectrum(j); // Should fire the copy constructor + auto &outSpec = output->getSpectrum(output_wi); + const auto &inSpec = event_ws2->getSpectrum(j); + outSpec.copyInfoFrom(inSpec); // Propagate spectrum masking. First workspace will have been done by the // factory @@ -259,9 +259,9 @@ void WorkspaceJoiners::getMinMax(MatrixWorkspace_const_sptr ws, specnum_t &min, specnum_t temp; size_t length = ws->getNumberHistograms(); // initial values - min = max = ws->getSpectrum(0)->getSpectrumNo(); + min = max = ws->getSpectrum(0).getSpectrumNo(); for (size_t i = 0; i < length; i++) { - temp = ws->getSpectrum(i)->getSpectrumNo(); + temp = ws->getSpectrum(i).getSpectrumNo(); // Adjust min/max if (temp < min) min = temp; diff --git a/Framework/Algorithms/test/AlignDetectorsTest.h b/Framework/Algorithms/test/AlignDetectorsTest.h index 420cd6cbe9e517b4a5d6a807c22d24f4006eb63c..581e901fad4c3623015e2138164751fff6e3b08c 100644 --- a/Framework/Algorithms/test/AlignDetectorsTest.h +++ b/Framework/Algorithms/test/AlignDetectorsTest.h @@ -76,12 +76,12 @@ public: TS_ASSERT_EQUALS(outWS->dataY(2)[50], inWS->dataY(1)[50]); for (size_t i = 0; i < outWS->getNumberHistograms(); i++) { - TS_ASSERT_EQUALS(outWS->getSpectrum(i)->getSpectrumNo(), - inWS->getSpectrum(i)->getSpectrumNo()); - TS_ASSERT_EQUALS(outWS->getSpectrum(i)->getDetectorIDs().size(), - inWS->getSpectrum(i)->getDetectorIDs().size()); - TS_ASSERT_EQUALS(*outWS->getSpectrum(i)->getDetectorIDs().begin(), - *inWS->getSpectrum(i)->getDetectorIDs().begin()); + TS_ASSERT_EQUALS(outWS->getSpectrum(i).getSpectrumNo(), + inWS->getSpectrum(i).getSpectrumNo()); + TS_ASSERT_EQUALS(outWS->getSpectrum(i).getDetectorIDs().size(), + inWS->getSpectrum(i).getDetectorIDs().size()); + TS_ASSERT_EQUALS(*outWS->getSpectrum(i).getDetectorIDs().begin(), + *inWS->getSpectrum(i).getDetectorIDs().begin()); } AnalysisDataService::Instance().remove(outputWS); @@ -106,7 +106,7 @@ public: TS_ASSERT(WS); // workspace is loaded size_t start_blocksize = WS->blocksize(); size_t num_events = WS->getNumberEvents(); - double a_tof = WS->getEventList(wkspIndex).getEvents()[0].tof(); + double a_tof = WS->getSpectrum(wkspIndex).getEvents()[0].tof(); // Start by init'ing the algorithm TS_ASSERT_THROWS_NOTHING(align.initialize()); @@ -127,7 +127,7 @@ public: TS_ASSERT_EQUALS(start_blocksize, WS->blocksize()); TS_ASSERT_EQUALS(num_events, WS->getNumberEvents()); // But a TOF changed. - TS_ASSERT_DIFFERS(a_tof, WS->getEventList(wkspIndex).getEvents()[0].tof()); + TS_ASSERT_DIFFERS(a_tof, WS->getSpectrum(wkspIndex).getEvents()[0].tof()); } void testExecEventWorkspace_differentOutputWS() { @@ -161,8 +161,8 @@ public: TS_ASSERT_EQUALS(outWS->blocksize(), WS->blocksize()); TS_ASSERT_EQUALS(outWS->getNumberEvents(), WS->getNumberEvents()); // But a TOF changed. - TS_ASSERT_DIFFERS(outWS->getEventList(wkspIndex).getEvents()[0].tof(), - WS->getEventList(wkspIndex).getEvents()[0].tof()); + TS_ASSERT_DIFFERS(outWS->getSpectrum(wkspIndex).getEvents()[0].tof(), + WS->getSpectrum(wkspIndex).getEvents()[0].tof()); } private: diff --git a/Framework/Algorithms/test/AppendSpectraTest.h b/Framework/Algorithms/test/AppendSpectraTest.h index 9982099e83cd427d8eadd518613c326257480557..c69cc55879796a3d213393f97bc8c89e4648c696 100644 --- a/Framework/Algorithms/test/AppendSpectraTest.h +++ b/Framework/Algorithms/test/AppendSpectraTest.h @@ -203,8 +203,8 @@ public: TS_ASSERT_EQUALS(out->blocksize(), numBins); for (size_t wi = 0; wi < out->getNumberHistograms(); wi++) { - TS_ASSERT_EQUALS(out->getSpectrum(wi)->getSpectrumNo(), specnum_t(wi)); - TS_ASSERT(!out->getSpectrum(wi)->getDetectorIDs().empty()); + TS_ASSERT_EQUALS(out->getSpectrum(wi).getSpectrumNo(), specnum_t(wi)); + TS_ASSERT(!out->getSpectrum(wi).getDetectorIDs().empty()); for (size_t x = 0; x < out->blocksize(); x++) TS_ASSERT_DELTA(out->readY(wi)[x], 2.0, 1e-5); } diff --git a/Framework/Algorithms/test/ApplyDetailedBalanceTest.h b/Framework/Algorithms/test/ApplyDetailedBalanceTest.h index 76258f56cf96f218bbea7c0cede926cf64febd16..504991dd06a6e7245776d699b6411c70dea0d7d3 100644 --- a/Framework/Algorithms/test/ApplyDetailedBalanceTest.h +++ b/Framework/Algorithms/test/ApplyDetailedBalanceTest.h @@ -118,7 +118,7 @@ public: for (size_t i = 0; i < 5; ++i) { double en = static_cast<double>(i) + 0.5; double w = M_PI * (1 - std::exp(-en * 11.604519 / temp)); - TS_ASSERT_DELTA(evout->getEventList(0).getEvent(i).m_weight, w, w * 1e-6); + TS_ASSERT_DELTA(evout->getSpectrum(0).getEvent(i).m_weight, w, w * 1e-6); } AnalysisDataService::Instance().remove(outputWSname); @@ -162,7 +162,7 @@ private: for (int i = 0; i < nspecs; i++) { ws2D->setX(i, xv); ws2D->setData(i, yv, ev); - ws2D->getSpectrum(i)->setSpectrumNo(i); + ws2D->getSpectrum(i).setSpectrumNo(i); } AnalysisDataService::Instance().add(inputWSname, ws2D); diff --git a/Framework/Algorithms/test/CalculateFlatBackgroundTest.h b/Framework/Algorithms/test/CalculateFlatBackgroundTest.h index 98f4eae9e5a1e9c903219fdd22d76e5b3944a6b4..82396334005c7b5bd44ed931ef67b6d26baee029 100644 --- a/Framework/Algorithms/test/CalculateFlatBackgroundTest.h +++ b/Framework/Algorithms/test/CalculateFlatBackgroundTest.h @@ -473,7 +473,7 @@ private: physicalPixel->setPos(detXPos, ypos, 0.0); testInst->add(physicalPixel); testInst->markAsMonitor(physicalPixel); - WS->getSpectrum(i)->addDetectorID(physicalPixel->getID()); + WS->getSpectrum(i).addDetectorID(physicalPixel->getID()); } } }; diff --git a/Framework/Algorithms/test/ChangeBinOffsetTest.h b/Framework/Algorithms/test/ChangeBinOffsetTest.h index be0961c9276fde317333c8c3564c74f88b3dac8b..fd043ebe9fb13ac8c4885d4e16cc0ec9d6530974 100644 --- a/Framework/Algorithms/test/ChangeBinOffsetTest.h +++ b/Framework/Algorithms/test/ChangeBinOffsetTest.h @@ -136,10 +136,10 @@ public: TS_ASSERT(WSO); std::size_t wkspIndex = 4348; // a good workspace index (with events) - TS_ASSERT_DELTA(WSI->getEventList(wkspIndex).getEvents()[0].tof() + 100, - WSO->getEventList(wkspIndex).getEvents()[0].tof(), 0.001); - TS_ASSERT_DELTA(WSI->getEventList(wkspIndex).dataX()[1] + 100., - WSO->getEventList(wkspIndex).dataX()[1], 0.001); + TS_ASSERT_DELTA(WSI->getSpectrum(wkspIndex).getEvents()[0].tof() + 100, + WSO->getSpectrum(wkspIndex).getEvents()[0].tof(), 0.001); + TS_ASSERT_DELTA(WSI->getSpectrum(wkspIndex).dataX()[1] + 100., + WSO->getSpectrum(wkspIndex).dataX()[1], 0.001); alg.setPropertyValue("IndexMin", "4349"); alg.setPropertyValue("IndexMax", "4350"); @@ -148,17 +148,17 @@ public: WSO = AnalysisDataService::Instance().retrieveWS<EventWorkspace>(outputSpace); TS_ASSERT(WSO); - TS_ASSERT_DELTA(WSI->getEventList(wkspIndex).getEvents()[0].tof(), - WSO->getEventList(wkspIndex).getEvents()[0].tof(), + TS_ASSERT_DELTA(WSI->getSpectrum(wkspIndex).getEvents()[0].tof(), + WSO->getSpectrum(wkspIndex).getEvents()[0].tof(), 0.001); // should be unchanged - TS_ASSERT_DELTA(WSI->getEventList(wkspIndex).dataX()[1], - WSO->getEventList(wkspIndex).dataX()[1], + TS_ASSERT_DELTA(WSI->getSpectrum(wkspIndex).dataX()[1], + WSO->getSpectrum(wkspIndex).dataX()[1], 0.001); // should be unchanged - TS_ASSERT_DELTA(WSI->getEventList(wkspIndex + 1).getEvents()[0].tof() + 100, - WSO->getEventList(wkspIndex + 1).getEvents()[0].tof(), + TS_ASSERT_DELTA(WSI->getSpectrum(wkspIndex + 1).getEvents()[0].tof() + 100, + WSO->getSpectrum(wkspIndex + 1).getEvents()[0].tof(), 0.001); // should change - TS_ASSERT_DELTA(WSI->getEventList(wkspIndex + 1).dataX()[1] + 100., - WSO->getEventList(wkspIndex + 1).dataX()[1], + TS_ASSERT_DELTA(WSI->getSpectrum(wkspIndex + 1).dataX()[1] + 100., + WSO->getSpectrum(wkspIndex + 1).dataX()[1], 0.001); // should change } diff --git a/Framework/Algorithms/test/ChangePulsetimeTest.h b/Framework/Algorithms/test/ChangePulsetimeTest.h index 0021b58c785f57fd69b396842f11ea57657fc467..a3892cc950cf7b2c49658ea7cf175934e4a48c1c 100644 --- a/Framework/Algorithms/test/ChangePulsetimeTest.h +++ b/Framework/Algorithms/test/ChangePulsetimeTest.h @@ -74,11 +74,11 @@ public: for (size_t wi = 10; wi < 20; wi++) { double secs; secs = DateAndTime::secondsFromDuration( - out_ws->getEventList(wi).getEvent(0).pulseTime() - + out_ws->getSpectrum(wi).getEvent(0).pulseTime() - DateAndTime("2010-01-01T00:00:00")); TS_ASSERT_DELTA(secs, 1000.0, 1e-5); secs = DateAndTime::secondsFromDuration( - out_ws->getEventList(wi).getEvent(2).pulseTime() - + out_ws->getSpectrum(wi).getEvent(2).pulseTime() - DateAndTime("2010-01-01T00:00:00")); TS_ASSERT_DELTA(secs, 1001.0, 1e-5); } @@ -87,11 +87,11 @@ public: if (WorkspaceIndexList != "") { double secs; secs = DateAndTime::secondsFromDuration( - out_ws->getEventList(0).getEvent(2).pulseTime() - + out_ws->getSpectrum(0).getEvent(2).pulseTime() - DateAndTime("2010-01-01T00:00:00")); TS_ASSERT_DELTA(secs, 1.0, 1e-5); secs = DateAndTime::secondsFromDuration( - out_ws->getEventList(30).getEvent(2).pulseTime() - + out_ws->getSpectrum(30).getEvent(2).pulseTime() - DateAndTime("2010-01-01T00:00:00")); TS_ASSERT_DELTA(secs, 1.0, 1e-5); } @@ -100,7 +100,7 @@ public: if (in_ws_name != out_ws_name) { double secs; secs = DateAndTime::secondsFromDuration( - in_ws->getEventList(0).getEvent(2).pulseTime() - + in_ws->getSpectrum(0).getEvent(2).pulseTime() - DateAndTime("2010-01-01T00:00:00")); TS_ASSERT_DELTA(secs, 1.0, 1e-5); } diff --git a/Framework/Algorithms/test/ChangeTimeZeroTest.h b/Framework/Algorithms/test/ChangeTimeZeroTest.h index 1ac7ea69f1aff0ce27abd3dd0638b7d0cdc5cb02..cff58f6fa4f61e1050c53eabe8d8228133944824 100644 --- a/Framework/Algorithms/test/ChangeTimeZeroTest.h +++ b/Framework/Algorithms/test/ChangeTimeZeroTest.h @@ -539,11 +539,11 @@ private: for (size_t workspaceIndex = 0; workspaceIndex < ws->getNumberHistograms(); ++workspaceIndex) { - auto eventList = ws->getEventListPtr(workspaceIndex); - auto eventListDuplicate = duplicateWs->getEventListPtr(workspaceIndex); + auto &eventList = ws->getSpectrum(workspaceIndex); + auto &eventListDuplicate = duplicateWs->getSpectrum(workspaceIndex); - auto events = eventList->getEvents(); - auto eventsDuplicate = eventListDuplicate->getEvents(); + auto &events = eventList.getEvents(); + auto &eventsDuplicate = eventListDuplicate.getEvents(); for (unsigned int i = 0; i < events.size(); ++i) { double secs = DateAndTime::secondsFromDuration( diff --git a/Framework/Algorithms/test/CheckWorkspacesMatchTest.h b/Framework/Algorithms/test/CheckWorkspacesMatchTest.h index af1130ab0eb4bea6cbc54f94bd6e20a0a928b703..9b88cf7eee652761e23cb4bf42bb5d0096f96126 100644 --- a/Framework/Algorithms/test/CheckWorkspacesMatchTest.h +++ b/Framework/Algorithms/test/CheckWorkspacesMatchTest.h @@ -706,7 +706,7 @@ public: Mantid::API::MatrixWorkspace_sptr ws2 = WorkspaceCreationHelper::Create2DWorkspace123(2, 2); - ws2->getSpectrum(0)->setSpectrumNo(1234); + ws2->getSpectrum(0).setSpectrumNo(1234); TS_ASSERT_THROWS_NOTHING(checker.setProperty("Workspace1", ws1)); TS_ASSERT_THROWS_NOTHING(checker.setProperty("Workspace2", ws2)); TS_ASSERT(checker.execute()); @@ -714,8 +714,8 @@ public: "Spectrum number mismatch"); ws2 = WorkspaceCreationHelper::Create2DWorkspace123(2, 2); - ws2->getSpectrum(0)->setDetectorID(99); - ws2->getSpectrum(1)->setDetectorID(98); + ws2->getSpectrum(0).setDetectorID(99); + ws2->getSpectrum(1).setDetectorID(98); TS_ASSERT_THROWS_NOTHING(checker.setProperty("Workspace1", ws1)); TS_ASSERT_THROWS_NOTHING(checker.setProperty("Workspace2", ws2)); TS_ASSERT(checker.execute()); diff --git a/Framework/Algorithms/test/ClearMaskFlagTest.h b/Framework/Algorithms/test/ClearMaskFlagTest.h index ed1a888769a1e586e9bc2933d55f23e8e9848891..0143143b614a48d27598cf7ff3fe33ed8e69a0b6 100644 --- a/Framework/Algorithms/test/ClearMaskFlagTest.h +++ b/Framework/Algorithms/test/ClearMaskFlagTest.h @@ -47,8 +47,8 @@ public: for (int j = 0; j < numspec; ++j) { space2D->setX(j, x); space2D->setData(j, vec, vec); - space2D->getSpectrum(j)->setSpectrumNo(j); - space2D->getSpectrum(j)->setDetectorID(j); + space2D->getSpectrum(j).setSpectrumNo(j); + space2D->getSpectrum(j).setDetectorID(j); } space->setInstrument(instr); diff --git a/Framework/Algorithms/test/CloneWorkspaceTest.h b/Framework/Algorithms/test/CloneWorkspaceTest.h index 73cc7f55414737caf9c18f179921d92831a60f1e..f0fe2074bd6973e4cb8b3caf7eab0a977c31e0b0 100644 --- a/Framework/Algorithms/test/CloneWorkspaceTest.h +++ b/Framework/Algorithms/test/CloneWorkspaceTest.h @@ -58,14 +58,14 @@ public: // been broken TSM_ASSERT_EQUALS("Dx vectors should be shared between spectra by default " "(after a LoadRaw)", - in->getSpectrum(0)->ptrDx(), in->getSpectrum(1)->ptrDx()) + in->getSpectrum(0).ptrDx(), in->getSpectrum(1).ptrDx()) MatrixWorkspace_const_sptr out = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>("out"); // Check sharing of the Dx vectors (which are unused in this case) has not // been broken TSM_ASSERT_EQUALS( "Dx vectors should remain shared between spectra after CloneWorkspace", - out->getSpectrum(0)->ptrDx(), out->getSpectrum(1)->ptrDx()) + out->getSpectrum(0).ptrDx(), out->getSpectrum(1).ptrDx()) // Best way to test this is to use the CheckWorkspacesMatch algorithm Mantid::Algorithms::CheckWorkspacesMatch checker; diff --git a/Framework/Algorithms/test/CompareWorkspacesTest.h b/Framework/Algorithms/test/CompareWorkspacesTest.h index 869ce1fb0a1b0965ceef3c9d9d28afff6d3a11f6..33ff0d8798c1e96deaa425da8d1fe154aa923a70 100644 --- a/Framework/Algorithms/test/CompareWorkspacesTest.h +++ b/Framework/Algorithms/test/CompareWorkspacesTest.h @@ -723,7 +723,7 @@ public: Mantid::API::MatrixWorkspace_sptr ws2 = WorkspaceCreationHelper::Create2DWorkspace123(2, 2); - ws2->getSpectrum(0)->setSpectrumNo(1234); + ws2->getSpectrum(0).setSpectrumNo(1234); TS_ASSERT_THROWS_NOTHING(checker.setProperty("Workspace1", ws1)); TS_ASSERT_THROWS_NOTHING(checker.setProperty("Workspace2", ws2)); @@ -737,8 +737,8 @@ public: "Spectrum number mismatch"); ws2 = WorkspaceCreationHelper::Create2DWorkspace123(2, 2); - ws2->getSpectrum(0)->setDetectorID(99); - ws2->getSpectrum(1)->setDetectorID(98); + ws2->getSpectrum(0).setDetectorID(99); + ws2->getSpectrum(1).setDetectorID(98); TS_ASSERT_THROWS_NOTHING(checker.setProperty("Workspace1", ws1)); TS_ASSERT_THROWS_NOTHING(checker.setProperty("Workspace2", ws2)); diff --git a/Framework/Algorithms/test/ConjoinWorkspacesTest.h b/Framework/Algorithms/test/ConjoinWorkspacesTest.h index a0c0a010b9f2797f869652aec2bdbe85c7abcab0..b4ad9f165c2c39bbb6cd30d3cd41531a44aa8b3b 100644 --- a/Framework/Algorithms/test/ConjoinWorkspacesTest.h +++ b/Framework/Algorithms/test/ConjoinWorkspacesTest.h @@ -164,12 +164,12 @@ public: // Adjust second workspace Mantid::specnum_t start = - ws1->getSpectrum(numPixels - 1)->getSpectrumNo() + 10; + ws1->getSpectrum(numPixels - 1).getSpectrumNo() + 10; for (int i = 0; i < 5; ++i) { - Mantid::API::ISpectrum *spec = ws2->getSpectrum(i); - spec->setSpectrumNo(start + i); - spec->clearDetectorIDs(); - spec->addDetectorID(start + i); + auto &spec = ws2->getSpectrum(i); + spec.setSpectrumNo(start + i); + spec.clearDetectorIDs(); + spec.addDetectorID(start + i); } TS_ASSERT_THROWS_NOTHING(conj.setProperty("InputWorkspace2", ws2)); @@ -182,11 +182,11 @@ public: TS_ASSERT(output); // Check the first spectrum has the correct ID TS_ASSERT_EQUALS(output->getNumberHistograms(), 15); - TS_ASSERT_EQUALS(output->getSpectrum(0)->getSpectrumNo(), - ws1->getSpectrum(0)->getSpectrumNo()); + TS_ASSERT_EQUALS(output->getSpectrum(0).getSpectrumNo(), + ws1->getSpectrum(0).getSpectrumNo()); // and the joining point - TS_ASSERT_EQUALS(output->getSpectrum(10)->getSpectrumNo(), start); - TS_ASSERT(!output->getSpectrum(11)->getDetectorIDs().empty()); + TS_ASSERT_EQUALS(output->getSpectrum(10).getSpectrumNo(), start); + TS_ASSERT(!output->getSpectrum(11).getDetectorIDs().empty()); AnalysisDataService::Instance().remove(ws1_name); } diff --git a/Framework/Algorithms/test/ConvertToEventWorkspaceTest.h b/Framework/Algorithms/test/ConvertToEventWorkspaceTest.h index ec8ea1df4a7f6047e11b6309db73a205671496fd..09c369422870f29c44c7a028593d2088b333ea86 100644 --- a/Framework/Algorithms/test/ConvertToEventWorkspaceTest.h +++ b/Framework/Algorithms/test/ConvertToEventWorkspaceTest.h @@ -100,11 +100,11 @@ public: // Event-specific checks TS_ASSERT_EQUALS(outWS->getNumberEvents(), GenerateMultipleEvents ? 1006 : 499); - TS_ASSERT_EQUALS(outWS->getEventList(1).getNumberEvents(), + TS_ASSERT_EQUALS(outWS->getSpectrum(1).getNumberEvents(), GenerateMultipleEvents ? 20 : 10); // Check a couple of events - EventList &el = outWS->getEventList(0); + EventList &el = outWS->getSpectrum(0); TS_ASSERT_EQUALS(el.getWeightedEventsNoTime().size(), GenerateMultipleEvents ? 26 : 9); WeightedEventNoTime ev; diff --git a/Framework/Algorithms/test/ConvertToMatrixWorkspaceTest.h b/Framework/Algorithms/test/ConvertToMatrixWorkspaceTest.h index 9539010e86b424886b6af7f10b4000537e113d03..dc1e43ce7640ce69287e9a2ce19b973bd4594266 100644 --- a/Framework/Algorithms/test/ConvertToMatrixWorkspaceTest.h +++ b/Framework/Algorithms/test/ConvertToMatrixWorkspaceTest.h @@ -86,15 +86,15 @@ public: TS_ASSERT_EQUALS(in->getInstrument()->isParametrized(), out->getInstrument()->isParametrized()); for (size_t i = 0; i < out->getNumberHistograms(); i++) { - const Mantid::API::ISpectrum *inSpec = in->getSpectrum(i); - const Mantid::API::ISpectrum *outSpec = out->getSpectrum(i); + const auto &inSpec = in->getSpectrum(i); + const auto &outSpec = out->getSpectrum(i); TSM_ASSERT_EQUALS("Failed on comparing Spectrum Number for Histogram: " + boost::lexical_cast<std::string>(i), - inSpec->getSpectrumNo(), outSpec->getSpectrumNo()); + inSpec.getSpectrumNo(), outSpec.getSpectrumNo()); TSM_ASSERT_EQUALS("Failed on comparing Detector ID for Histogram: " + boost::lexical_cast<std::string>(i), - *inSpec->getDetectorIDs().begin(), - *outSpec->getDetectorIDs().begin()); + *inSpec.getDetectorIDs().begin(), + *outSpec.getDetectorIDs().begin()); TSM_ASSERT_EQUALS("Failed on readX for Histogram: " + boost::lexical_cast<std::string>(i), in->readX(i), out->readX(i)); diff --git a/Framework/Algorithms/test/ConvertUnitsTest.h b/Framework/Algorithms/test/ConvertUnitsTest.h index f61f850520881a8620e60c71c936ea6b19deafef..6e5e4a8f01f62cec6f13ef21117416202858f3c2 100644 --- a/Framework/Algorithms/test/ConvertUnitsTest.h +++ b/Framework/Algorithms/test/ConvertUnitsTest.h @@ -49,8 +49,8 @@ public: space2D->setX(j, x); space2D->setData(j, a, e); // Just set the spectrum number to match the index - space2D->getSpectrum(j)->setSpectrumNo(j); - space2D->getSpectrum(j)->setDetectorID(j); + space2D->getSpectrum(j).setSpectrumNo(j); + space2D->getSpectrum(j).setDetectorID(j); } space2D->getAxis(0)->unit() = UnitFactory::Instance().create("TOF"); @@ -368,7 +368,7 @@ public: physicalPixel->setPos(-0.34732, -3.28797, -2.29022); testInst->add(physicalPixel); testInst->markAsDetector(physicalPixel); - ws->getSpectrum(0)->addDetectorID(physicalPixel->getID()); + ws->getSpectrum(0).addDetectorID(physicalPixel->getID()); ConvertUnits conv; conv.initialize(); @@ -428,7 +428,7 @@ public: TS_ASSERT(WS); // workspace is loaded size_t start_blocksize = WS->blocksize(); size_t num_events = WS->getNumberEvents(); - EventList el = WS->getEventList(wkspIndex); + EventList el = WS->getSpectrum(wkspIndex); double a_tof = el.getEvents()[0].tof(); double a_x = el.dataX()[1]; @@ -451,9 +451,9 @@ public: TS_ASSERT_EQUALS(start_blocksize, WS->blocksize()); TS_ASSERT_EQUALS(num_events, WS->getNumberEvents()); // But a TOF changed. - TS_ASSERT_DIFFERS(a_tof, WS->getEventList(wkspIndex).getEvents()[0].tof()); + TS_ASSERT_DIFFERS(a_tof, WS->getSpectrum(wkspIndex).getEvents()[0].tof()); // and a X changed - TS_ASSERT_DIFFERS(a_x, WS->getEventList(wkspIndex).dataX()[1]); + TS_ASSERT_DIFFERS(a_x, WS->getSpectrum(wkspIndex).dataX()[1]); // Check EMode has been set TS_ASSERT_EQUALS(Mantid::Kernel::DeltaEMode::Direct, WS->getEMode()); } @@ -517,7 +517,7 @@ public: return; TS_ASSERT_EQUALS(out->getNumberEvents(), 100 * 200); - EventList &el = out->getEventList(0); + EventList &el = out->getSpectrum(0); TS_ASSERT(el.getSortType() == sortType); if (sortType == TOF_SORT) { diff --git a/Framework/Algorithms/test/CopyDetectorMappingTest.h b/Framework/Algorithms/test/CopyDetectorMappingTest.h index d652eb1244874d2f3cce0bed87d015d8a72462f9..20885801e0533a956f77900edefd7e21e1f5bc24 100644 --- a/Framework/Algorithms/test/CopyDetectorMappingTest.h +++ b/Framework/Algorithms/test/CopyDetectorMappingTest.h @@ -30,7 +30,7 @@ public: detIDs.insert(9); detIDs.insert(6); detIDs.insert(2); - toMatch->getSpectrum(0)->setDetectorIDs(detIDs); + toMatch->getSpectrum(0).setDetectorIDs(detIDs); // Add workspaces to ADS AnalysisDataService::Instance().add("to_match", toMatch); @@ -52,7 +52,7 @@ public: TS_ASSERT_THROWS_NOTHING( result = boost::dynamic_pointer_cast<MatrixWorkspace>( AnalysisDataService::Instance().retrieve("to_remap"))); - auto resultDetIDs = result->getSpectrum(0)->getDetectorIDs(); + auto resultDetIDs = result->getSpectrum(0).getDetectorIDs(); TS_ASSERT(detIDs == resultDetIDs); // Clean up workspace diff --git a/Framework/Algorithms/test/CorelliCrossCorrelateTest.h b/Framework/Algorithms/test/CorelliCrossCorrelateTest.h index 406821384f24d86d23575ad7081f521ca4b2ae35..fc86f77e25d383818d0aba30296cece00b15e312 100644 --- a/Framework/Algorithms/test/CorelliCrossCorrelateTest.h +++ b/Framework/Algorithms/test/CorelliCrossCorrelateTest.h @@ -47,14 +47,14 @@ public: "CorelliCrossCorrelateTest_OutputWS"); DateAndTime startTime("2007-11-30T16:17:00"); - EventList *evlist = ws->getEventListPtr(0); + auto &evlist = ws->getSpectrum(0); // Add some events to the workspace. - evlist->addEventQuickly(TofEvent(10.0, startTime + 0.007)); - evlist->addEventQuickly(TofEvent(100.0, startTime + 0.012)); - evlist->addEventQuickly(TofEvent(1000.0, startTime + 0.012)); - evlist->addEventQuickly(TofEvent(10000.0, startTime + 0.012)); - evlist->addEventQuickly(TofEvent(1222.0, startTime + 0.03)); + evlist.addEventQuickly(TofEvent(10.0, startTime + 0.007)); + evlist.addEventQuickly(TofEvent(100.0, startTime + 0.012)); + evlist.addEventQuickly(TofEvent(1000.0, startTime + 0.012)); + evlist.addEventQuickly(TofEvent(10000.0, startTime + 0.012)); + evlist.addEventQuickly(TofEvent(1222.0, startTime + 0.03)); ws->getAxis(0)->setUnit("TOF"); @@ -94,7 +94,7 @@ public: if (!ws) return; - std::vector<WeightedEvent> &events = evlist->getWeightedEvents(); + std::vector<WeightedEvent> &events = evlist.getWeightedEvents(); TS_ASSERT_DELTA(events[0].weight(), -1.99392, 0.00001) TS_ASSERT_DELTA(events[1].weight(), -1.99392, 0.00001) diff --git a/Framework/Algorithms/test/CorrectKiKfTest.h b/Framework/Algorithms/test/CorrectKiKfTest.h index 9154b9b1b873a4fb5c586a0c544896cf582fbec3..377077a91241116552affdabadfaf50e4af158ec 100644 --- a/Framework/Algorithms/test/CorrectKiKfTest.h +++ b/Framework/Algorithms/test/CorrectKiKfTest.h @@ -170,11 +170,11 @@ public: return; TS_ASSERT_DELTA( - out_ws->getEventList(0).getEvent(0).weight(), - std::sqrt(3. / (3. - out_ws->getEventList(0).getEvent(0).tof())), 1e-7); + out_ws->getSpectrum(0).getEvent(0).weight(), + std::sqrt(3. / (3. - out_ws->getSpectrum(0).getEvent(0).tof())), 1e-7); TS_ASSERT_DELTA( - out_ws->getEventList(0).getEvent(3).weight(), - std::sqrt(3. / (3. - out_ws->getEventList(0).getEvent(3).tof())), 1e-7); + out_ws->getSpectrum(0).getEvent(3).weight(), + std::sqrt(3. / (3. - out_ws->getSpectrum(0).getEvent(3).tof())), 1e-7); TS_ASSERT_LESS_THAN( out_ws->getNumberEvents(), in_ws->getNumberEvents()); // Check that events with Ef<0 are dropped @@ -275,7 +275,7 @@ private: for (int i = 0; i < nspecs; i++) { ws2D->setX(i, xv); ws2D->setData(i, yv, ev); - ws2D->getSpectrum(i)->setSpectrumNo(i); + ws2D->getSpectrum(i).setSpectrumNo(i); } AnalysisDataService::Instance().add(inputWSname, ws2D); diff --git a/Framework/Algorithms/test/CountEventsInPulsesTest.h b/Framework/Algorithms/test/CountEventsInPulsesTest.h index feecada55cb57f42f72733a04efce40b4947b13f..566a8dd09b66039649dcc44b2ece0c16968d3542 100644 --- a/Framework/Algorithms/test/CountEventsInPulsesTest.h +++ b/Framework/Algorithms/test/CountEventsInPulsesTest.h @@ -93,8 +93,8 @@ public: // Meet the number in details for (size_t iw = 3; iw < 5; iw++) { /* Special Check - DataObjects::EventList events = outWS->getEventList(iw); - for (size_t ie = 0; ie < outWS->getEventList(iw).getNumberEvents(); ++ie) + DataObjects::EventList events = outWS->getSpectrum(iw); + for (size_t ie = 0; ie < outWS->getSpectrum(iw).getNumberEvents(); ++ie) { DataObjects::TofEvent event = events.getEvent(ie); std::cout << "Event " << ie << " : TOF = " << event.tof() << " Pulse @@ -169,7 +169,7 @@ public: TS_ASSERT_EQUALS(outWS->readX(0).size(), numpulses); for (size_t i = 0; i < 5; ++i) { - DataObjects::EventList events = eventWS->getEventList(i); + DataObjects::EventList events = eventWS->getSpectrum(i); std::cout << "WorkspaceIndex " << i << " Events Size = " << events.getNumberEvents() << std::endl; } @@ -227,7 +227,7 @@ public: TS_ASSERT_EQUALS(outWS->readX(0).size(), numpulses); for (size_t i = 0; i < 5; ++i) { - DataObjects::EventList events = eventWS->getEventList(i); + DataObjects::EventList events = eventWS->getSpectrum(i); std::cout << "WorkspaceIndex " << i << " Events Size = " << events.getNumberEvents() << std::endl; } @@ -286,7 +286,7 @@ public: detid_t detectorid = -99; std::set<detid_t> detectorids = - eventWS->getEventList(wsindex).getDetectorIDs(); + eventWS->getSpectrum(wsindex).getDetectorIDs(); std::set<detid_t>::iterator detiter; for (detiter = detectorids.begin(); detiter != detectorids.end(); ++detiter) { @@ -318,7 +318,7 @@ public: // 5. Add Events for (size_t iws = 3; iws < 5; ++iws) { - DataObjects::EventList *eventlist = eventWS->getEventListPtr(iws); + auto &eventlist = eventWS->getSpectrum(iws); for (size_t ip = 0; ip < numpulses - 1; ip++) { Kernel::DateAndTime pulsetime = @@ -330,7 +330,7 @@ public: for (size_t ie = 0; ie < numevents; ie++) { double tof = static_cast<double>(ie + 1) * dtof_ms; DataObjects::TofEvent newevent(tof, pulsetime); - eventlist->addEventQuickly(newevent); + eventlist.addEventQuickly(newevent); // std::cout << "Spec " << iws << " Pulse Time = " << pulsetime << // ".. Index " << ie << " TOF = " << tof << std::endl; diff --git a/Framework/Algorithms/test/CropWorkspaceTest.h b/Framework/Algorithms/test/CropWorkspaceTest.h index 9e146ee4c4ba77d85b76e9d75ef2db8d80ca6ac3..ee3b0c32cf86a13f62925173b466ff7bf39d53d3 100644 --- a/Framework/Algorithms/test/CropWorkspaceTest.h +++ b/Framework/Algorithms/test/CropWorkspaceTest.h @@ -135,11 +135,11 @@ public: TS_ASSERT_EQUALS(3, ws->getNumberHistograms()); // reduced histograms TS_ASSERT_EQUALS(30, ws->getNumberEvents()); - TS_ASSERT(40. <= ws->getEventList(0).getTofMin()); - TS_ASSERT(50. >= ws->getEventList(0).getTofMax()); + TS_ASSERT(40. <= ws->getSpectrum(0).getTofMin()); + TS_ASSERT(50. >= ws->getSpectrum(0).getTofMax()); - TS_ASSERT(40. <= ws->getEventList(2).getTofMin()); - TS_ASSERT(50. >= ws->getEventList(2).getTofMax()); + TS_ASSERT(40. <= ws->getSpectrum(2).getTofMin()); + TS_ASSERT(50. >= ws->getSpectrum(2).getTofMax()); } void testExec() { @@ -181,8 +181,8 @@ public: TS_ASSERT_EQUALS(output->readX(i)[3], input->readX(i + 2)[4]); TS_ASSERT_EQUALS(output->getAxis(1)->spectraNo(i), input->getAxis(1)->spectraNo(i + 2)); - TS_ASSERT_EQUALS(output->getSpectrum(i)->getDetectorIDs(), - input->getSpectrum(i + 2)->getDetectorIDs()); + TS_ASSERT_EQUALS(output->getSpectrum(i).getDetectorIDs(), + input->getSpectrum(i + 2).getDetectorIDs()); } } @@ -226,8 +226,8 @@ public: for (int i = 0; i < 5; ++i) { TS_ASSERT_EQUALS(output->getAxis(1)->spectraNo(i), input->getAxis(1)->spectraNo(i)); - TS_ASSERT_EQUALS(output->getSpectrum(i)->getDetectorIDs(), - input->getSpectrum(i)->getDetectorIDs()); + TS_ASSERT_EQUALS(output->getSpectrum(i).getDetectorIDs(), + input->getSpectrum(i).getDetectorIDs()); } } diff --git a/Framework/Algorithms/test/DetectorEfficiencyCorTest.h b/Framework/Algorithms/test/DetectorEfficiencyCorTest.h index 691ac42f4805d1e422d7bb03911c084167bbd520..424601c3437e44ce1d0d03898d4549c420c9bf3d 100644 --- a/Framework/Algorithms/test/DetectorEfficiencyCorTest.h +++ b/Framework/Algorithms/test/DetectorEfficiencyCorTest.h @@ -76,10 +76,10 @@ public: auto inputWS = createTestWorkspace(); // Make it point to both detectors - auto *spec0 = inputWS->getSpectrum(0); - spec0->clearDetectorIDs(); - spec0->addDetectorID(1); - spec0->addDetectorID(2); + auto &spec0 = inputWS->getSpectrum(0); + spec0.clearDetectorIDs(); + spec0.addDetectorID(1); + spec0.addDetectorID(2); Mantid::Algorithms::DetectorEfficiencyCor grouper; TS_ASSERT_THROWS_NOTHING(grouper.initialize()); diff --git a/Framework/Algorithms/test/DetectorEfficiencyVariationTest.h b/Framework/Algorithms/test/DetectorEfficiencyVariationTest.h index 1d4745154c317f7dc85d3b596214498042d2f0ea..2f883dff5fed0d5003bd33ec8ae46bd28ac2be4e 100644 --- a/Framework/Algorithms/test/DetectorEfficiencyVariationTest.h +++ b/Framework/Algorithms/test/DetectorEfficiencyVariationTest.h @@ -148,8 +148,8 @@ public: inputB->setData(j, forInputB, errors); // Just set the spectrum number to match the index, spectra numbers and // detector maps must be indentical for both - inputA->getSpectrum(j)->setSpectrumNo(j + 1); - inputB->getSpectrum(j)->setSpectrumNo(j + 1); + inputA->getSpectrum(j).setSpectrumNo(j + 1); + inputB->getSpectrum(j).setSpectrumNo(j + 1); } // Register the input workspaces to the ADS where they can be accessed by diff --git a/Framework/Algorithms/test/DiffractionFocussing2Test.h b/Framework/Algorithms/test/DiffractionFocussing2Test.h index d3527e04230c20f1d65b1f0911824c708e285487..aaef73401d7e193003a934cc18cafc74f5950610 100644 --- a/Framework/Algorithms/test/DiffractionFocussing2Test.h +++ b/Framework/Algorithms/test/DiffractionFocussing2Test.h @@ -129,7 +129,7 @@ public: xRef[4] = 1e6; // Set an X-axis inputW->setX(pix, axis); - inputW->getEventList(pix).addEventQuickly(TofEvent(1000.0)); + inputW->getSpectrum(pix).addEventQuickly(TofEvent(1000.0)); } // ------------ Create a grouping workspace by name ------------- @@ -191,7 +191,7 @@ public: TS_ASSERT_EQUALS(output->blocksize(), 4); TS_ASSERT_EQUALS(output->getAxis(1)->length(), numgroups); - TS_ASSERT_EQUALS(output->getSpectrum(0)->getSpectrumNo(), 1); + TS_ASSERT_EQUALS(output->getSpectrum(0).getSpectrumNo(), 1); // Events in these two banks alone if (preserveEvents) @@ -203,7 +203,7 @@ public: // Now let's test the grouping of detector UDETS to groups for (size_t wi = 0; wi < output->getNumberHistograms(); wi++) { // This is the list of the detectors (grouped) - auto mylist = output->getSpectrum(wi)->getDetectorIDs(); + auto mylist = output->getSpectrum(wi).getDetectorIDs(); // 1024 pixels in a bank TS_ASSERT_EQUALS(mylist.size(), bankWidthInPixels * bankWidthInPixels); } @@ -277,7 +277,7 @@ public: // Fill a whole bunch of events PARALLEL_FOR_NO_WSP_CHECK() for (int i = 0; i < static_cast<int>(ws->getNumberHistograms()); i++) { - EventList &el = ws->getEventList(i); + EventList &el = ws->getSpectrum(i); for (int j = 0; j < 20; j++) { el.addEventQuickly(TofEvent(double(j) * 1e-3)); } diff --git a/Framework/Algorithms/test/EditInstrumentGeometryTest.h b/Framework/Algorithms/test/EditInstrumentGeometryTest.h index 1db033238c7fcecb4b5db6d6cb1c1654d8317aa2..d5c7acee1bd3ebd33746d3a2006eeab9afa809ba 100644 --- a/Framework/Algorithms/test/EditInstrumentGeometryTest.h +++ b/Framework/Algorithms/test/EditInstrumentGeometryTest.h @@ -58,15 +58,11 @@ public: workspace = boost::dynamic_pointer_cast<Mantid::API::MatrixWorkspace>( Mantid::API::AnalysisDataService::Instance().retrieve("inputWS"))); - API::ISpectrum *spectrum1 = workspace->getSpectrum(0); Geometry::Instrument_const_sptr instrument = workspace->getInstrument(); - auto detids = spectrum1->getDetectorIDs(); + auto detids = workspace->getSpectrum(0).getDetectorIDs(); TS_ASSERT_EQUALS(detids.size(), 1); - detid_t detid = 0; - for (auto it = detids.begin(); it != detids.end(); ++it) { - detid = *it; - } + detid_t detid = *detids.rbegin(); Geometry::IDetector_const_sptr detector = instrument->getDetector(detid); double r, tth, phi; detector->getPos().getSpherical(r, tth, phi); @@ -168,15 +164,11 @@ public: void checkDetectorParameters(API::MatrixWorkspace_sptr workspace, size_t wsindex, double realr, double realtth, double realphi) { - API::ISpectrum *spectrum1 = workspace->getSpectrum(wsindex); Geometry::Instrument_const_sptr instrument = workspace->getInstrument(); - auto detids = spectrum1->getDetectorIDs(); + auto detids = workspace->getSpectrum(wsindex).getDetectorIDs(); TS_ASSERT_EQUALS(detids.size(), 1); - detid_t detid = 0; - for (auto it = detids.begin(); it != detids.end(); ++it) { - detid = *it; - } + detid_t detid = *detids.rbegin(); Geometry::IDetector_const_sptr detector = instrument->getDetector(detid); double r, tth, phi; detector->getPos().getSpherical(r, tth, phi); @@ -190,15 +182,11 @@ public: */ void checkDetectorID(API::MatrixWorkspace_sptr workspace, size_t wsindex, detid_t detid) { - API::ISpectrum *spectrum1 = workspace->getSpectrum(wsindex); Geometry::Instrument_const_sptr instrument = workspace->getInstrument(); - auto detids = spectrum1->getDetectorIDs(); + auto detids = workspace->getSpectrum(wsindex).getDetectorIDs(); TS_ASSERT_EQUALS(detids.size(), 1); - detid_t thisdetid = 0; - for (auto it = detids.begin(); it != detids.end(); ++it) { - thisdetid = *it; - } + detid_t thisdetid = *detids.rbegin(); TS_ASSERT_EQUALS(detid, thisdetid); diff --git a/Framework/Algorithms/test/ExponentialCorrectionTest.h b/Framework/Algorithms/test/ExponentialCorrectionTest.h index a1c1ee432b2c6e1c6c367e709a47b5df82ad11b3..8e331f08db243ea9ccfa22b1d9e01794fb241cff 100644 --- a/Framework/Algorithms/test/ExponentialCorrectionTest.h +++ b/Framework/Algorithms/test/ExponentialCorrectionTest.h @@ -152,7 +152,7 @@ public: for (size_t i = 0; i < 5; ++i) { double t = static_cast<double>(i) + 0.5; double w = 1. / 3. / std::exp(-2. * t); - TS_ASSERT_DELTA(evout->getEventList(0).getEvent(i).m_weight, w, w * 1e-6); + TS_ASSERT_DELTA(evout->getSpectrum(0).getEvent(i).m_weight, w, w * 1e-6); } AnalysisDataService::Instance().remove("test_ev_ec"); diff --git a/Framework/Algorithms/test/ExtractSingleSpectrumTest.h b/Framework/Algorithms/test/ExtractSingleSpectrumTest.h index e5d7a8fd7ba90cf25dc656cb2a7a4eb261d5e7c4..704ffca52c6e01c1f17c5d3c726bad0f6a773a27 100644 --- a/Framework/Algorithms/test/ExtractSingleSpectrumTest.h +++ b/Framework/Algorithms/test/ExtractSingleSpectrumTest.h @@ -79,8 +79,8 @@ public: TS_ASSERT_EQUALS(numEvents, eventsPerPixel); do_Spectrum_Tests(outputWS, 4, 4); TS_ASSERT_EQUALS(eventWS->blocksize(), 50); - TS_ASSERT_DELTA(outputWS->getEventList(0).getTofMin(), 4.5, 1e-08); - TS_ASSERT_DELTA(outputWS->getEventList(0).getTofMax(), 28.5, 1e-08); + TS_ASSERT_DELTA(outputWS->getSpectrum(0).getTofMin(), 4.5, 1e-08); + TS_ASSERT_DELTA(outputWS->getSpectrum(0).getTofMax(), 28.5, 1e-08); } private: @@ -109,17 +109,13 @@ private: void do_Spectrum_Tests(MatrixWorkspace_sptr outputWS, const specnum_t specID, const detid_t detID) { TS_ASSERT_EQUALS(outputWS->getNumberHistograms(), 1); - const Mantid::API::ISpectrum *spectrum(NULL); - TS_ASSERT_THROWS_NOTHING(spectrum = outputWS->getSpectrum(0)); - if (spectrum) { - TS_ASSERT_EQUALS(spectrum->getSpectrumNo(), specID); - auto detids = spectrum->getDetectorIDs(); - TS_ASSERT_EQUALS(detids.size(), 1); - const detid_t id = *(detids.begin()); - TS_ASSERT_EQUALS(id, detID); - } else { - TS_FAIL("No spectra/detectors associated with extracted histogram."); - } + TS_ASSERT_THROWS_NOTHING(outputWS->getSpectrum(0)); + const auto &spectrum = outputWS->getSpectrum(0); + TS_ASSERT_EQUALS(spectrum.getSpectrumNo(), specID); + auto detids = spectrum.getDetectorIDs(); + TS_ASSERT_EQUALS(detids.size(), 1); + const detid_t id = *(detids.begin()); + TS_ASSERT_EQUALS(id, detID); } }; diff --git a/Framework/Algorithms/test/ExtractSpectraTest.h b/Framework/Algorithms/test/ExtractSpectraTest.h index e11a573bd3da1228ea8698de09ed0b402756b4b8..4be098d963c672185a1c34fc1ce5ec20c7c262b4 100644 --- a/Framework/Algorithms/test/ExtractSpectraTest.h +++ b/Framework/Algorithms/test/ExtractSpectraTest.h @@ -458,7 +458,7 @@ private: ws->setInstrument( ComponentCreationHelper::createTestInstrumentCylindrical(1)); for (size_t i = 0; i < ws->getNumberHistograms(); ++i) { - ws->getSpectrum(i)->setDetectorID(detid_t(i + 1)); + ws->getSpectrum(i).setDetectorID(detid_t(i + 1)); } return ws; } @@ -487,7 +487,7 @@ private: ws = createInputWorkspaceHisto(); for (size_t i = 0; i < ws->getNumberHistograms(); ++i) { // Create a detector for each spectra - ws->getSpectrum(i)->setDetectorID(static_cast<detid_t>(i + 1)); + ws->getSpectrum(i).setDetectorID(static_cast<detid_t>(i + 1)); } } else if (workspaceType == "event") { ws = createInputWorkspaceEvent(); diff --git a/Framework/Algorithms/test/FilterByTime2Test.h b/Framework/Algorithms/test/FilterByTime2Test.h index a831a43d35902df1f9a9539e73305adfc64c6910..8408c283b5deb8b628d5bbf54bcf42b4d0a04ae0 100644 --- a/Framework/Algorithms/test/FilterByTime2Test.h +++ b/Framework/Algorithms/test/FilterByTime2Test.h @@ -155,8 +155,8 @@ public: int count = 0; for (size_t i = 0; i < outWS->getNumberHistograms(); i++) { - double diff = fabs(double(outWS->getEventList(i).getNumberEvents() - - outWS2->getEventList(i).getNumberEvents())); + double diff = fabs(double(outWS->getSpectrum(i).getNumberEvents() - + outWS2->getSpectrum(i).getNumberEvents())); // No more than 2 events difference because of rounding to 0.01 second TS_ASSERT_LESS_THAN(diff, 3); if (diff > 3) diff --git a/Framework/Algorithms/test/FilterEventsTest.h b/Framework/Algorithms/test/FilterEventsTest.h index 556a64624d35e77d70b464c47145e01cf94b270c..0c2a73caaddd3f9104d5e4c1cf99c52624b46cfd 100644 --- a/Framework/Algorithms/test/FilterEventsTest.h +++ b/Framework/Algorithms/test/FilterEventsTest.h @@ -65,7 +65,7 @@ public: TS_ASSERT_EQUALS(eventws->getNumberEvents(), 500); - DataObjects::EventList elist = eventws->getEventList(0); + DataObjects::EventList elist = eventws->getSpectrum(0); TS_ASSERT_EQUALS(elist.getNumberEvents(), 50); TS_ASSERT(elist.hasDetectorID(1)); @@ -129,7 +129,7 @@ public: AnalysisDataService::Instance().retrieve("FilteredWS01_0")); TS_ASSERT(filteredws0); TS_ASSERT_EQUALS(filteredws0->getNumberHistograms(), 10); - TS_ASSERT_EQUALS(filteredws0->getEventList(0).getNumberEvents(), 4); + TS_ASSERT_EQUALS(filteredws0->getSpectrum(0).getNumberEvents(), 4); TS_ASSERT_EQUALS(filteredws0->run().getProtonCharge(), 10); // Check Workspace group 1 @@ -137,7 +137,7 @@ public: boost::dynamic_pointer_cast<DataObjects::EventWorkspace>( AnalysisDataService::Instance().retrieve("FilteredWS01_1")); TS_ASSERT(filteredws1); - TS_ASSERT_EQUALS(filteredws1->getEventList(1).getNumberEvents(), 16); + TS_ASSERT_EQUALS(filteredws1->getSpectrum(1).getNumberEvents(), 16); TS_ASSERT_EQUALS(filteredws1->run().getProtonCharge(), 11); // Check Workspace group 2 @@ -145,10 +145,10 @@ public: boost::dynamic_pointer_cast<DataObjects::EventWorkspace>( AnalysisDataService::Instance().retrieve("FilteredWS01_2")); TS_ASSERT(filteredws2); - TS_ASSERT_EQUALS(filteredws2->getEventList(1).getNumberEvents(), 21); + TS_ASSERT_EQUALS(filteredws2->getSpectrum(1).getNumberEvents(), 21); TS_ASSERT_EQUALS(filteredws2->run().getProtonCharge(), 21); - DataObjects::EventList elist3 = filteredws2->getEventList(3); + DataObjects::EventList elist3 = filteredws2->getSpectrum(3); elist3.sortPulseTimeTOF(); DataObjects::TofEvent eventmin = elist3.getEvent(0); @@ -228,23 +228,23 @@ public: AnalysisDataService::Instance().retrieve("FilteredWS01_1")); TS_ASSERT(filteredws0); TS_ASSERT_EQUALS(filteredws0->getNumberHistograms(), 10); - TS_ASSERT_EQUALS(filteredws0->getEventList(0).getNumberEvents(), 4); + TS_ASSERT_EQUALS(filteredws0->getSpectrum(0).getNumberEvents(), 4); // 4.2 Workspace group 1 DataObjects::EventWorkspace_sptr filteredws1 = boost::dynamic_pointer_cast<DataObjects::EventWorkspace>( AnalysisDataService::Instance().retrieve("FilteredWS01_2")); TS_ASSERT(filteredws1); - TS_ASSERT_EQUALS(filteredws1->getEventList(1).getNumberEvents(), 16); + TS_ASSERT_EQUALS(filteredws1->getSpectrum(1).getNumberEvents(), 16); // 4.3 Workspace group 2 DataObjects::EventWorkspace_sptr filteredws2 = boost::dynamic_pointer_cast<DataObjects::EventWorkspace>( AnalysisDataService::Instance().retrieve("FilteredWS01_3")); TS_ASSERT(filteredws2); - TS_ASSERT_EQUALS(filteredws2->getEventList(1).getNumberEvents(), 21); + TS_ASSERT_EQUALS(filteredws2->getSpectrum(1).getNumberEvents(), 21); - DataObjects::EventList elist3 = filteredws2->getEventList(3); + DataObjects::EventList elist3 = filteredws2->getSpectrum(3); elist3.sortPulseTimeTOF(); DataObjects::TofEvent eventmin = elist3.getEvent(0); @@ -318,8 +318,8 @@ public: AnalysisDataService::Instance().retrieve("SplittedDataX_0")); TS_ASSERT(filteredws0); TS_ASSERT_EQUALS(filteredws0->getNumberHistograms(), 10); - TS_ASSERT_EQUALS(filteredws0->getEventList(0).getNumberEvents(), 15); - TS_ASSERT_EQUALS(filteredws0->getEventList(9).getNumberEvents(), 15); + TS_ASSERT_EQUALS(filteredws0->getSpectrum(0).getNumberEvents(), 15); + TS_ASSERT_EQUALS(filteredws0->getSpectrum(9).getNumberEvents(), 15); TS_ASSERT_EQUALS(filteredws0->run().getProtonCharge(), 5); // 4.2 Workspace group 1 @@ -327,11 +327,11 @@ public: boost::dynamic_pointer_cast<DataObjects::EventWorkspace>( AnalysisDataService::Instance().retrieve("SplittedDataX_1")); TS_ASSERT(filteredws1); - TS_ASSERT_EQUALS(filteredws1->getEventList(1).getNumberEvents(), 10); + TS_ASSERT_EQUALS(filteredws1->getSpectrum(1).getNumberEvents(), 10); TS_ASSERT_EQUALS(filteredws0->run().getProtonCharge(), 5); // 4.3 Some individual events - DataObjects::EventList elist3 = filteredws1->getEventList(3); + DataObjects::EventList elist3 = filteredws1->getSpectrum(3); elist3.sortPulseTimeTOF(); if (elist3.getNumberEvents() > 0) { @@ -398,7 +398,7 @@ public: } // Check individual events - EventList &ev0 = ws7->getEventList(0); + EventList &ev0 = ws7->getSpectrum(0); TS_ASSERT_EQUALS(ev0.getNumberEvents(), 1); std::vector<double> vectofs = ev0.getTofs(); TS_ASSERT_DELTA(vectofs[0], 272.0, 0.001); @@ -585,24 +585,24 @@ public: AnalysisDataService::Instance().retrieve("FilteredWS10_1")); TS_ASSERT(filteredws0); TS_ASSERT_EQUALS(filteredws0->getNumberHistograms(), 10); - TS_ASSERT_EQUALS(filteredws0->getEventList(0).getNumberEvents(), 3); + TS_ASSERT_EQUALS(filteredws0->getSpectrum(0).getNumberEvents(), 3); // Workspace 1 DataObjects::EventWorkspace_sptr filteredws1 = boost::dynamic_pointer_cast<DataObjects::EventWorkspace>( AnalysisDataService::Instance().retrieve("FilteredWS10_2")); TS_ASSERT(filteredws1); - TS_ASSERT_EQUALS(filteredws1->getEventList(1).getNumberEvents(), 16); + TS_ASSERT_EQUALS(filteredws1->getSpectrum(1).getNumberEvents(), 16); // Workspace 2 DataObjects::EventWorkspace_sptr filteredws2 = boost::dynamic_pointer_cast<DataObjects::EventWorkspace>( AnalysisDataService::Instance().retrieve("FilteredWS10_3")); TS_ASSERT(filteredws2); - TS_ASSERT_EQUALS(filteredws2->getEventList(1).getNumberEvents(), 27); + TS_ASSERT_EQUALS(filteredws2->getSpectrum(1).getNumberEvents(), 27); // Check spectrum 3 of workspace 2 - DataObjects::EventList elist3 = filteredws2->getEventList(3); + DataObjects::EventList elist3 = filteredws2->getSpectrum(3); elist3.sortPulseTimeTOF(); DataObjects::TofEvent eventmin = elist3.getEvent(0); @@ -656,7 +656,7 @@ public: "proton_charge"); for (size_t i = 0; i < eventWS->getNumberHistograms(); i++) { - DataObjects::EventList *elist = eventWS->getEventListPtr(i); + auto &elist = eventWS->getSpectrum(i); for (int64_t pid = 0; pid < static_cast<int64_t>(numpulses); pid++) { int64_t pulsetime_i64 = pid * pulsedt + runstart.totalNanoseconds(); @@ -665,7 +665,7 @@ public: for (size_t e = 0; e < 10; e++) { double tof = static_cast<double>(e * tofdt / 1000); DataObjects::TofEvent event(tof, pulsetime); - elist->addEventQuickly(event); + elist.addEventQuickly(event); } } // FOR each pulse } // For each bank @@ -714,11 +714,11 @@ public: // Add neutrons for (size_t i = 0; i < eventWS->getNumberHistograms(); i++) { - DataObjects::EventList *elist = eventWS->getEventListPtr(i); + auto &elist = eventWS->getSpectrum(i); for (size_t ievent = 0; ievent < fakeevlist.getNumberEvents(); ++ievent) { TofEvent tofevent = fakeevlist.getEvent(ievent); - elist->addEventQuickly(tofevent); + elist.addEventQuickly(tofevent); } // FOR each pulse } // For each bank @@ -762,11 +762,11 @@ public: // Add neutrons EventList fakeevlist = fake_uniform_time_sns_data(runstart_i64, pulsedt); for (size_t i = 0; i < eventWS->getNumberHistograms(); i++) { - DataObjects::EventList *elist = eventWS->getEventListPtr(i); + auto &elist = eventWS->getSpectrum(i); for (size_t ievent = 0; ievent < fakeevlist.getNumberEvents(); ++ievent) { TofEvent tofevent = fakeevlist.getEvent(ievent); - elist->addEventQuickly(tofevent); + elist.addEventQuickly(tofevent); } // FOR each pulse } // For each bank @@ -814,11 +814,11 @@ public: // Add neutrons for (size_t i = 0; i < eventWS->getNumberHistograms(); i++) { - DataObjects::EventList *elist = eventWS->getEventListPtr(i); + auto &elist = eventWS->getSpectrum(i); for (size_t ievent = 0; ievent < fakeevlist.getNumberEvents(); ++ievent) { TofEvent tofevent = fakeevlist.getEvent(ievent); - elist->addEventQuickly(tofevent); + elist.addEventQuickly(tofevent); } // FOR each pulse } // For each bank diff --git a/Framework/Algorithms/test/FindCenterOfMassPosition2Test.h b/Framework/Algorithms/test/FindCenterOfMassPosition2Test.h index ec12cb690b933c6fea2d2a7248b5f3d0e4628373..5ef588a6609794191e5d9bd6ccbc8a9cac847c2d 100644 --- a/Framework/Algorithms/test/FindCenterOfMassPosition2Test.h +++ b/Framework/Algorithms/test/FindCenterOfMassPosition2Test.h @@ -50,7 +50,7 @@ public: double dy = (center_y - (double)iy); Y[0] = exp(-(dx * dx + dy * dy)); E[0] = 1; - ws->getSpectrum(i)->setSpectrumNo(i); + ws->getSpectrum(i).setSpectrumNo(i); } } } diff --git a/Framework/Algorithms/test/FindCenterOfMassPositionTest.h b/Framework/Algorithms/test/FindCenterOfMassPositionTest.h index 67963a01dad47574bdf5d05b069cb3d9eeae44f5..7f0a52eae36ed6be76081b3dff5d0570b6b9b56d 100644 --- a/Framework/Algorithms/test/FindCenterOfMassPositionTest.h +++ b/Framework/Algorithms/test/FindCenterOfMassPositionTest.h @@ -49,7 +49,7 @@ public: double dy = (center_y - (double)iy); Y[0] = exp(-(dx * dx + dy * dy)); E[0] = 1; - ws->getSpectrum(i)->setSpectrumNo(i); + ws->getSpectrum(i).setSpectrumNo(i); } } } diff --git a/Framework/Algorithms/test/FindDeadDetectorsTest.h b/Framework/Algorithms/test/FindDeadDetectorsTest.h index ae8995834c1f3811fb32b753c77a7182154acbb5..2fc5082c90d001ddc62397746e489a59eb92a5fc 100644 --- a/Framework/Algorithms/test/FindDeadDetectorsTest.h +++ b/Framework/Algorithms/test/FindDeadDetectorsTest.h @@ -65,13 +65,13 @@ public: if (i == 19) { work_in->setData(i, yStrange, yTooDead); } - work_in->getSpectrum(i)->setSpectrumNo(i); + work_in->getSpectrum(i).setSpectrumNo(i); Mantid::Geometry::Detector *det = new Mantid::Geometry::Detector("", i, NULL); instr->add(det); instr->markAsDetector(det); - work_in->getSpectrum(i)->setDetectorID(i); + work_in->getSpectrum(i).setDetectorID(i); } FindDeadDetectors alg; diff --git a/Framework/Algorithms/test/FindDetectorsOutsideLimitsTest.h b/Framework/Algorithms/test/FindDetectorsOutsideLimitsTest.h index b598d777226d6359bef240829db22064bb16ca66..0f5972b44d8df0079ad89a49ce850907174b232d 100644 --- a/Framework/Algorithms/test/FindDetectorsOutsideLimitsTest.h +++ b/Framework/Algorithms/test/FindDetectorsOutsideLimitsTest.h @@ -65,13 +65,13 @@ public: if (i == 19) { work_in->setData(i, yStrange, yTooDead); } - work_in->getSpectrum(i)->setSpectrumNo(i); + work_in->getSpectrum(i).setSpectrumNo(i); Mantid::Geometry::Detector *det = new Mantid::Geometry::Detector("", i, NULL); instr->add(det); instr->markAsDetector(det); - work_in->getSpectrum(i)->setDetectorID(i); + work_in->getSpectrum(i).setDetectorID(i); } FindDetectorsOutsideLimits alg; @@ -156,7 +156,7 @@ public: DateAndTime run_start("2010-01-01T00:00:00"); // Add ten more at #10 so that it fails for (int i = 0; i < 10; i++) - work_in->getEventList(10) + work_in->getSpectrum(10) .addEventQuickly(TofEvent((i + 0.5), run_start + double(i))); AnalysisDataService::Instance().add("testdead_in", work_in); diff --git a/Framework/Algorithms/test/GenerateEventsFilterTest.h b/Framework/Algorithms/test/GenerateEventsFilterTest.h index 9a6dde818e56fb137a32cc5e46e0d53dbdcef841..13fe8810ab5ef502e75d1b1ba38312cc4f53b207 100644 --- a/Framework/Algorithms/test/GenerateEventsFilterTest.h +++ b/Framework/Algorithms/test/GenerateEventsFilterTest.h @@ -113,8 +113,8 @@ public: DataObjects::EventWorkspace_sptr eventWS = createEventWorkspace(); for (size_t i = 0; i < eventWS->getNumberHistograms(); ++i) std::cout << "Spectrum " << i << ": max pulse time = " - << eventWS->getEventList(i).getPulseTimeMax() << " = " - << eventWS->getEventList(i).getPulseTimeMin().totalNanoseconds() + << eventWS->getSpectrum(i).getPulseTimeMax() << " = " + << eventWS->getSpectrum(i).getPulseTimeMin().totalNanoseconds() << "\n"; int64_t timeinterval_ns = 15000; diff --git a/Framework/Algorithms/test/GetAllEiTest.h b/Framework/Algorithms/test/GetAllEiTest.h index 4d9b9afa458bebdb73d2c01e3d5bad3561094be6..571ec2a6eab9c7089c44548181e1cc8c0a7bd74f 100644 --- a/Framework/Algorithms/test/GetAllEiTest.h +++ b/Framework/Algorithms/test/GetAllEiTest.h @@ -318,10 +318,8 @@ public: true); auto det1 = tws->getDetector(0); auto det2 = tws->getDetector(4); - auto spec1 = tws->getSpectrum(0); - auto spec2 = tws->getSpectrum(4); - auto detID1 = spec1->getDetectorIDs(); - auto detID2 = spec2->getDetectorIDs(); + auto detID1 = tws->getSpectrum(0).getDetectorIDs(); + auto detID2 = tws->getSpectrum(4).getDetectorIDs(); m_getAllEi.initialize(); m_getAllEi.setProperty("Workspace", tws); @@ -342,15 +340,13 @@ public: TSM_ASSERT_EQUALS("Detector's ID for the first spectrum and new workspace " "should coincide", *(detID1.begin()), - (*wws->getSpectrum(0)->getDetectorIDs().begin())); + (*wws->getSpectrum(0).getDetectorIDs().begin())); TSM_ASSERT_EQUALS("Detector's ID for the second spectrum and new workspace " "should coincide", *(detID2.begin()), - (*wws->getSpectrum(1)->getDetectorIDs().begin())); - auto pSpec1 = wws->getSpectrum(0); - auto pSpec2 = wws->getSpectrum(1); - auto Xsp1 = pSpec1->dataX(); - auto Xsp2 = pSpec2->dataX(); + (*wws->getSpectrum(1).getDetectorIDs().begin())); + auto Xsp1 = wws->getSpectrum(0).dataX(); + auto Xsp2 = wws->getSpectrum(1).dataX(); size_t nSpectra = Xsp2.size(); TS_ASSERT_EQUALS(nSpectra, 101); TS_ASSERT(boost::math::isinf(Xsp1[nSpectra - 1])); diff --git a/Framework/Algorithms/test/He3TubeEfficiencyTest.h b/Framework/Algorithms/test/He3TubeEfficiencyTest.h index b7dce4d4162bd5cbe7816f2946b5011745f8636c..dba0f2b04fcb7189b53b58adc510d8be760a4fb5 100644 --- a/Framework/Algorithms/test/He3TubeEfficiencyTest.h +++ b/Framework/Algorithms/test/He3TubeEfficiencyTest.h @@ -75,13 +75,13 @@ public: boost::dynamic_pointer_cast<EventWorkspace>(result); // Monitor events should be untouched - EventList mon_ev = ev_result->getEventList(0); + EventList mon_ev = ev_result->getSpectrum(0); TS_ASSERT_DELTA(mon_ev.getEvent(1).m_weight, 1.0, 1e-6); // Check some detector events - EventList det1_ev = ev_result->getEventList(1); + EventList det1_ev = ev_result->getSpectrum(1); TS_ASSERT_DELTA(det1_ev.getEvent(1).m_weight, 1.098646, 1e-6); TS_ASSERT_DELTA(det1_ev.getEvent(1).m_errorSquared, 1.207024, 1e-6); - EventList det3_ev = ev_result->getEventList(3); + EventList det3_ev = ev_result->getSpectrum(3); TS_ASSERT_DELTA(det3_ev.getEvent(4).m_weight, 1.000036, 1e-6); AnalysisDataService::Instance().remove(inputEvWS); @@ -147,10 +147,10 @@ public: boost::dynamic_pointer_cast<EventWorkspace>(result); // Monitor should be untouched - EventList mon_ev = ev_result->getEventList(0); + EventList mon_ev = ev_result->getSpectrum(0); TS_ASSERT_DELTA(mon_ev.getEvent(1).m_weight, 1.0, 1e-6); // Check that detectors have no events - EventList det1_ev = ev_result->getEventList(1); + EventList det1_ev = ev_result->getSpectrum(1); TS_ASSERT_EQUALS(det1_ev.getNumberEvents(), 0); // Check that the total number of events is just the monitor TS_ASSERT_EQUALS(ev_result->getNumberEvents(), 5); @@ -185,7 +185,7 @@ private: for (int i = 0; i < nspecs; i++) { space2D->setX(i, x); space2D->setData(i, y, e); - space2D->getSpectrum(i)->setSpectrumNo(i); + space2D->getSpectrum(i).setSpectrumNo(i); } AnalysisDataService::Instance().add(inputWS, space2D); diff --git a/Framework/Algorithms/test/IntegrateByComponentTest.h b/Framework/Algorithms/test/IntegrateByComponentTest.h index 047e35dd6f041e1762b9c24f8ac7277040aafa11..18bfc9580e9ead8474643230f421cb230e9b1db0 100644 --- a/Framework/Algorithms/test/IntegrateByComponentTest.h +++ b/Framework/Algorithms/test/IntegrateByComponentTest.h @@ -246,7 +246,7 @@ private: Mantid::Geometry::ParameterMap &pmap = ws2D->instrumentParameters(); for (int i = 0; i < nSpectra; i++) { - ws2D->getSpectrum(i)->setDetectorID(i + 4); + ws2D->getSpectrum(i).setDetectorID(i + 4); if (mask && (i % 4 == 0)) { Mantid::Geometry::IDetector_const_sptr det = ws2D->getDetector(i); pmap.addBool(det.get(), "masked", true); diff --git a/Framework/Algorithms/test/IntegrationTest.h b/Framework/Algorithms/test/IntegrationTest.h index cefb6cae1c8405ef97f44aaab010e681de331cdc..ad09f6722adc7a9396ebae6fb11bebd419044873 100644 --- a/Framework/Algorithms/test/IntegrationTest.h +++ b/Framework/Algorithms/test/IntegrationTest.h @@ -264,9 +264,9 @@ public: TS_ASSERT_DELTA(Y[0], 20.0, 1e-6); TS_ASSERT_DELTA(E[0], sqrt(20.0), 1e-6); // Correct spectra etc? - specnum_t specNo = output2D->getSpectrum(i)->getSpectrumNo(); + specnum_t specNo = output2D->getSpectrum(i).getSpectrumNo(); TS_ASSERT_EQUALS(specNo, StartWorkspaceIndex + i); - TS_ASSERT(output2D->getSpectrum(i)->hasDetectorID(specNo)); + TS_ASSERT(output2D->getSpectrum(i).hasDetectorID(specNo)); } AnalysisDataService::Instance().remove(inName); diff --git a/Framework/Algorithms/test/LorentzCorrectionTest.h b/Framework/Algorithms/test/LorentzCorrectionTest.h index d7bdd849ebf2c7285099485c05ec89ecc949ff3e..111b3870adb8a01ebb3c23207283bf628a04c6cc 100644 --- a/Framework/Algorithms/test/LorentzCorrectionTest.h +++ b/Framework/Algorithms/test/LorentzCorrectionTest.h @@ -78,7 +78,7 @@ private: workspace->getAxis(0)->setUnit("Wavelength"); workspace->setYUnit("Counts"); workspace->setInstrument(instrument); - workspace->getSpectrum(0)->addDetectorID(det->getID()); + workspace->getSpectrum(0).addDetectorID(det->getID()); return workspace; } diff --git a/Framework/Algorithms/test/MaskBinsFromTableTest.h b/Framework/Algorithms/test/MaskBinsFromTableTest.h index 71fb96fa7da66da2c140bec39ce26869d0aa1c26..928b3c440b1d547499c35eea28fea6fa37b4065b 100644 --- a/Framework/Algorithms/test/MaskBinsFromTableTest.h +++ b/Framework/Algorithms/test/MaskBinsFromTableTest.h @@ -273,18 +273,8 @@ public: // Find out mapping between spectra/workspace indexes and detectors IDs for (size_t i = 0; i < 5; ++i) { - ISpectrum *spec = dataws->getSpectrum(i); - if (!spec) { - cout << "There is no spectrum mapping to workspace index " << i - << ".\n"; - return; - } else { - auto detidset = spec->getDetectorIDs(); - for (auto setiter = detidset.begin(); setiter != detidset.end(); - ++setiter) - cout << "WorkspaceIndex = " << i << ": Detector ID = " << *setiter - << ".\n"; - } + for (const auto &id : dataws->getSpectrum(i).getDetectorIDs()) + cout << "WorkspaceIndex = " << i << ": Detector ID = " << id << ".\n"; } // Generate a TableWorksapce diff --git a/Framework/Algorithms/test/MayersSampleCorrectionTest.h b/Framework/Algorithms/test/MayersSampleCorrectionTest.h index adab0a1e7eb9bfd19096516dc5a5244a6bfe2731..47fb04d34a8fa936745935a7e435edce87189485 100644 --- a/Framework/Algorithms/test/MayersSampleCorrectionTest.h +++ b/Framework/Algorithms/test/MayersSampleCorrectionTest.h @@ -124,9 +124,9 @@ private: // Spectrum-detector mapping for (int i = 0; i < nhist; ++i) { - auto *spectrum = testWS->getSpectrum(i); - spectrum->clearDetectorIDs(); - spectrum->addDetectorID(i + 1); + auto &spectrum = testWS->getSpectrum(i); + spectrum.clearDetectorIDs(); + spectrum.addDetectorID(i + 1); } // Sample properties - cylinder of vanadium diff --git a/Framework/Algorithms/test/MedianDetectorTestTest.h b/Framework/Algorithms/test/MedianDetectorTestTest.h index d1b4df1d73b477a8deb10f07180556cadbd99de4..fafc2d4202d625e1b22a784c4b7769e7f2756885 100644 --- a/Framework/Algorithms/test/MedianDetectorTestTest.h +++ b/Framework/Algorithms/test/MedianDetectorTestTest.h @@ -67,7 +67,7 @@ public: input = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>(m_IWSName); TS_ASSERT(input); - // TS_ASSERT(input->getInstrument()->isDetectorMasked(input->getSpectrum(THEMASKED)->getDetectorIDs())); + // TS_ASSERT(input->getInstrument()->isDetectorMasked(input->getSpectrum(THEMASKED).getDetectorIDs())); MatrixWorkspace_sptr outputMat = boost::dynamic_pointer_cast<MatrixWorkspace>(output); @@ -216,7 +216,7 @@ public: m_2DWS->setData(j, spectrum, errors); // Just set the spectrum number to match the index - m_2DWS->getSpectrum(j)->setSpectrumNo(j + 1); + m_2DWS->getSpectrum(j).setSpectrumNo(j + 1); } // Register the workspace in the data service diff --git a/Framework/Algorithms/test/MergeRunsTest.h b/Framework/Algorithms/test/MergeRunsTest.h index fa271b8eefb3893c1baf6ccf4855eb11f4b7dd4f..b8b770980d5ae9e0f016ac20e8d75ab98b871bec 100644 --- a/Framework/Algorithms/test/MergeRunsTest.h +++ b/Framework/Algorithms/test/MergeRunsTest.h @@ -290,10 +290,10 @@ public: // let's check on the setup TS_ASSERT_EQUALS(evg1->getNumberEvents(), 600); TS_ASSERT_EQUALS(evg1->getNumberHistograms(), 2); - TS_ASSERT(evg1->getEventList(0).hasDetectorID(0)); - TS_ASSERT(evg1->getEventList(0).hasDetectorID(1)); - TS_ASSERT(evg1->getEventList(0).hasDetectorID(2)); - TS_ASSERT(evg1->getEventList(1).hasDetectorID(3)); + TS_ASSERT(evg1->getSpectrum(0).hasDetectorID(0)); + TS_ASSERT(evg1->getSpectrum(0).hasDetectorID(1)); + TS_ASSERT(evg1->getSpectrum(0).hasDetectorID(2)); + TS_ASSERT(evg1->getSpectrum(1).hasDetectorID(3)); groups.clear(); groups.push_back(makeVector(2, 3, 4)); @@ -503,16 +503,16 @@ public: ev1->getNumberEvents() + evg1->getNumberEvents()); TS_ASSERT_EQUALS(output->getNumberHistograms(), 2); // 2 groups; 0-2 and 3-5 - TS_ASSERT_EQUALS(output->getEventList(0).getNumberEvents(), + TS_ASSERT_EQUALS(output->getSpectrum(0).getNumberEvents(), 600); // 300 + 3x100 - TS_ASSERT(output->getEventList(0).hasDetectorID(0)); - TS_ASSERT(output->getEventList(0).hasDetectorID(1)); - TS_ASSERT(output->getEventList(0).hasDetectorID(2)); + TS_ASSERT(output->getSpectrum(0).hasDetectorID(0)); + TS_ASSERT(output->getSpectrum(0).hasDetectorID(1)); + TS_ASSERT(output->getSpectrum(0).hasDetectorID(2)); - TS_ASSERT_EQUALS(output->getEventList(1).getNumberEvents(), 300); // 300 - TS_ASSERT(output->getEventList(1).hasDetectorID(3)); - TS_ASSERT(output->getEventList(1).hasDetectorID(4)); - TS_ASSERT(output->getEventList(1).hasDetectorID(5)); + TS_ASSERT_EQUALS(output->getSpectrum(1).getNumberEvents(), 300); // 300 + TS_ASSERT(output->getSpectrum(1).hasDetectorID(3)); + TS_ASSERT(output->getSpectrum(1).hasDetectorID(4)); + TS_ASSERT(output->getSpectrum(1).hasDetectorID(5)); EventTeardown(); } @@ -540,15 +540,15 @@ public: ev1->getNumberEvents() + evg1->getNumberEvents()); // Grouped pixel IDs: 0; 1; 2; 012; 345 TS_ASSERT_EQUALS(output->getNumberHistograms(), 5); - TS_ASSERT(output->getEventList(0).hasDetectorID(0)); - TS_ASSERT(output->getEventList(1).hasDetectorID(1)); - TS_ASSERT(output->getEventList(2).hasDetectorID(2)); - TS_ASSERT(output->getEventList(3).hasDetectorID(0)); - TS_ASSERT(output->getEventList(3).hasDetectorID(1)); - TS_ASSERT(output->getEventList(3).hasDetectorID(2)); - TS_ASSERT(output->getEventList(4).hasDetectorID(3)); - TS_ASSERT(output->getEventList(4).hasDetectorID(4)); - TS_ASSERT(output->getEventList(4).hasDetectorID(5)); + TS_ASSERT(output->getSpectrum(0).hasDetectorID(0)); + TS_ASSERT(output->getSpectrum(1).hasDetectorID(1)); + TS_ASSERT(output->getSpectrum(2).hasDetectorID(2)); + TS_ASSERT(output->getSpectrum(3).hasDetectorID(0)); + TS_ASSERT(output->getSpectrum(3).hasDetectorID(1)); + TS_ASSERT(output->getSpectrum(3).hasDetectorID(2)); + TS_ASSERT(output->getSpectrum(4).hasDetectorID(3)); + TS_ASSERT(output->getSpectrum(4).hasDetectorID(4)); + TS_ASSERT(output->getSpectrum(4).hasDetectorID(5)); EventTeardown(); } @@ -575,19 +575,19 @@ public: TS_ASSERT_EQUALS(output->getNumberEvents(), ev6->getNumberEvents() + evg2->getNumberEvents()); TS_ASSERT_EQUALS(output->getNumberHistograms(), 4); - TS_ASSERT_EQUALS(output->getEventList(0).getNumberEvents(), + TS_ASSERT_EQUALS(output->getSpectrum(0).getNumberEvents(), 400); // 4 lists were added - TS_ASSERT_EQUALS(output->getEventList(1).getNumberEvents(), 600); - TS_ASSERT_EQUALS(output->getEventList(2).getNumberEvents(), 100); - TS_ASSERT_EQUALS(output->getEventList(3).getNumberEvents(), 100); + TS_ASSERT_EQUALS(output->getSpectrum(1).getNumberEvents(), 600); + TS_ASSERT_EQUALS(output->getSpectrum(2).getNumberEvents(), 100); + TS_ASSERT_EQUALS(output->getSpectrum(3).getNumberEvents(), 100); // Groups are 3,4; 0,1,2; 15(from ev6); 5(unused in ev6) - TS_ASSERT(output->getEventList(0).hasDetectorID(3)); - TS_ASSERT(output->getEventList(0).hasDetectorID(4)); - TS_ASSERT(output->getEventList(1).hasDetectorID(0)); - TS_ASSERT(output->getEventList(1).hasDetectorID(1)); - TS_ASSERT(output->getEventList(1).hasDetectorID(2)); - TS_ASSERT(output->getEventList(2).hasDetectorID(15)); - TS_ASSERT(output->getEventList(3) + TS_ASSERT(output->getSpectrum(0).hasDetectorID(3)); + TS_ASSERT(output->getSpectrum(0).hasDetectorID(4)); + TS_ASSERT(output->getSpectrum(1).hasDetectorID(0)); + TS_ASSERT(output->getSpectrum(1).hasDetectorID(1)); + TS_ASSERT(output->getSpectrum(1).hasDetectorID(2)); + TS_ASSERT(output->getSpectrum(2).hasDetectorID(15)); + TS_ASSERT(output->getSpectrum(3) .hasDetectorID(5)); // Leftover from the ev1 workspace EventTeardown(); @@ -617,21 +617,21 @@ public: evg2->getNumberEvents()); TS_ASSERT_EQUALS(output->getNumberHistograms(), 3); - TS_ASSERT_EQUALS(output->getEventList(0).getNumberEvents(), + TS_ASSERT_EQUALS(output->getSpectrum(0).getNumberEvents(), 900); // 300 (evg1) + 3x100 (ev1) + 3x100 (evg2 had 012) - TS_ASSERT(output->getEventList(0).hasDetectorID(0)); - TS_ASSERT(output->getEventList(0).hasDetectorID(1)); - TS_ASSERT(output->getEventList(0).hasDetectorID(2)); + TS_ASSERT(output->getSpectrum(0).hasDetectorID(0)); + TS_ASSERT(output->getSpectrum(0).hasDetectorID(1)); + TS_ASSERT(output->getSpectrum(0).hasDetectorID(2)); - TS_ASSERT_EQUALS(output->getEventList(1).getNumberEvents(), + TS_ASSERT_EQUALS(output->getSpectrum(1).getNumberEvents(), 500); // 300 + 2x100 (evg2 had 3,4 only) - TS_ASSERT(output->getEventList(1).hasDetectorID(3)); - TS_ASSERT(output->getEventList(1).hasDetectorID(4)); - TS_ASSERT(output->getEventList(1).hasDetectorID(5)); + TS_ASSERT(output->getSpectrum(1).hasDetectorID(3)); + TS_ASSERT(output->getSpectrum(1).hasDetectorID(4)); + TS_ASSERT(output->getSpectrum(1).hasDetectorID(5)); // Leftover 15 from evg2 - TS_ASSERT_EQUALS(output->getEventList(2).getNumberEvents(), 100); // (evg2) - TS_ASSERT(output->getEventList(2).hasDetectorID(15)); + TS_ASSERT_EQUALS(output->getSpectrum(2).getNumberEvents(), 100); // (evg2) + TS_ASSERT(output->getSpectrum(2).hasDetectorID(15)); EventTeardown(); } diff --git a/Framework/Algorithms/test/ModeratorTzeroLinearTest.h b/Framework/Algorithms/test/ModeratorTzeroLinearTest.h index ebba8f5041a5acc74fb408bed82835cfa21eb094..51064e341df1f337976aff24972cd5b8269389fb 100644 --- a/Framework/Algorithms/test/ModeratorTzeroLinearTest.h +++ b/Framework/Algorithms/test/ModeratorTzeroLinearTest.h @@ -107,7 +107,7 @@ public: // Check a few values for (size_t ihist = 0; ihist < testWS->getNumberHistograms(); ++ihist) { - const EventList &evlist = testWS->getEventList(ihist); + const EventList &evlist = testWS->getSpectrum(ihist); const MantidVec &tofs_b = evlist.getTofs(); const MantidVec &xarray = evlist.readX(); for (size_t ibin = 0; ibin < xarray.size(); ibin += 400) { @@ -152,7 +152,7 @@ private: Mantid::Kernel::UnitFactory::Instance().create("TOF"); const size_t numHists = testWS->getNumberHistograms(); for (size_t ihist = 0; ihist < numHists; ++ihist) { - EventList &evlist = testWS->getEventList(ihist); + EventList &evlist = testWS->getSpectrum(ihist); MantidVecPtr xdata; xdata.access().resize(numBins + 1); for (int ibin = 0; ibin <= numBins; ++ibin) { diff --git a/Framework/Algorithms/test/ModeratorTzeroTest.h b/Framework/Algorithms/test/ModeratorTzeroTest.h index ce46398d6bcadf9c85673e9f5c65d8f064460e3b..58e29ce17747cad57d834a1209e49eb548195b30 100644 --- a/Framework/Algorithms/test/ModeratorTzeroTest.h +++ b/Framework/Algorithms/test/ModeratorTzeroTest.h @@ -150,7 +150,7 @@ public: double tofs_a[11] = {-37.5547, 1562.45, 3162.45, 4762.45, 6362.45, 7962.45, 9550.18, 11150, 12750, 14350, 15950}; for (size_t ihist = 0; ihist < testWS->getNumberHistograms(); ++ihist) { - EventList &evlist = testWS->getEventList(ihist); + EventList &evlist = testWS->getSpectrum(ihist); MantidVec tofs_b = evlist.getTofs(); MantidVec xarray = evlist.readX(); for (size_t ibin = 0; ibin < xarray.size(); ibin += jump) { @@ -182,7 +182,7 @@ public: double tofs_a[11] = {0.0, 1598.38, 3190.3, 4783.04, 6376.76, 7971.06, 9565.72, 11160.6, 12755.7, 14351, 15946.3}; for (size_t ihist = 0; ihist < testWS->getNumberHistograms(); ++ihist) { - EventList &evlist = testWS->getEventList(ihist); + EventList &evlist = testWS->getSpectrum(ihist); MantidVec tofs_b = evlist.getTofs(); MantidVec xarray = evlist.readX(); for (size_t ibin = 0; ibin < xarray.size(); ibin += jump) { @@ -215,7 +215,7 @@ public: double tofs_a[11] = {-10.8185, 1589.18, 3189.18, 4789.18, 6389.18, 7989.18, 9589.18, 11189.2, 12789.2, 14389.2, 15989.2}; for (size_t ihist = 0; ihist < testWS->getNumberHistograms(); ++ihist) { - EventList &evlist = testWS->getEventList(ihist); + EventList &evlist = testWS->getSpectrum(ihist); MantidVec tofs_b = evlist.getTofs(); MantidVec xarray = evlist.readX(); for (size_t ibin = 0; ibin < xarray.size(); ibin += jump) { @@ -267,7 +267,7 @@ private: const double rescaling_factor(4.0); const size_t numHists = testWS->getNumberHistograms(); for (size_t ihist = 0; ihist < numHists; ++ihist) { - EventList &evlist = testWS->getEventList(ihist); + EventList &evlist = testWS->getSpectrum(ihist); MantidVecPtr xdata; xdata.access().resize(numBins + 1); for (int ibin = 0; ibin <= numBins; ++ibin) { diff --git a/Framework/Algorithms/test/MultipleScatteringCylinderAbsorptionTest.h b/Framework/Algorithms/test/MultipleScatteringCylinderAbsorptionTest.h index f5c531362ae6c5422e2b43a650f92d3ebce051e4..778b8f4bcd990715e5479c63ea92aec6cd4c937c 100644 --- a/Framework/Algorithms/test/MultipleScatteringCylinderAbsorptionTest.h +++ b/Framework/Algorithms/test/MultipleScatteringCylinderAbsorptionTest.h @@ -137,7 +137,7 @@ public: false); wksp->getAxis(0) ->setUnit("Wavelength"); // cheat and set the units to Wavelength - wksp->getEventList(0) + wksp->getSpectrum(0) .convertTof(.09, 1.); // convert to be from 1->10 (about) const std::size_t NUM_EVENTS = wksp->getNumberEvents(); AnalysisDataService::Instance().add(outName, wksp); @@ -165,7 +165,7 @@ public: // do the final comparison - this is done by bounding std::vector<double> y_actual; - wksp->getEventList(0).getWeights(y_actual); + wksp->getSpectrum(0).getWeights(y_actual); for (size_t i = 0; i < y_actual.size(); ++i) { TS_ASSERT_LESS_THAN(1.19811, y_actual[i]); TS_ASSERT_LESS_THAN(y_actual[i], 3.3324); diff --git a/Framework/Algorithms/test/MuonGroupDetectorsTest.h b/Framework/Algorithms/test/MuonGroupDetectorsTest.h index d3c2723c6b95bc754508fa22f4baf7de94cf8838..0f7528d75fc9ce7d0fed4888bc3a8fc4b5addaf3 100644 --- a/Framework/Algorithms/test/MuonGroupDetectorsTest.h +++ b/Framework/Algorithms/test/MuonGroupDetectorsTest.h @@ -38,7 +38,7 @@ public: WorkspaceCreationHelper::Create2DWorkspace123(5, 3); for (size_t i = 0; i < inWS->getNumberHistograms(); ++i) - inWS->getSpectrum(i)->setDetectorID(static_cast<detid_t>( + inWS->getSpectrum(i).setDetectorID(static_cast<detid_t>( i + 1)); // To be consistent with how LoadMuonNexus works TableWorkspace_sptr grouping = createDetectorGroupingTable(); @@ -73,19 +73,19 @@ public: TS_ASSERT_DELTA(ws->readE(0)[2], 4.243, 0.001); TS_ASSERT_DELTA(ws->readE(1)[2], 5.196, 0.001); - TS_ASSERT_EQUALS(ws->getSpectrum(0)->getSpectrumNo(), 1); - TS_ASSERT_EQUALS(ws->getSpectrum(1)->getSpectrumNo(), 2); + TS_ASSERT_EQUALS(ws->getSpectrum(0).getSpectrumNo(), 1); + TS_ASSERT_EQUALS(ws->getSpectrum(1).getSpectrumNo(), 2); std::set<detid_t> d1; d1.insert(1); d1.insert(2); - TS_ASSERT_EQUALS(ws->getSpectrum(0)->getDetectorIDs(), d1); + TS_ASSERT_EQUALS(ws->getSpectrum(0).getDetectorIDs(), d1); std::set<detid_t> d2; d2.insert(3); d2.insert(4); d2.insert(5); - TS_ASSERT_EQUALS(ws->getSpectrum(1)->getDetectorIDs(), d2); + TS_ASSERT_EQUALS(ws->getSpectrum(1).getDetectorIDs(), d2); } // Remove workspace from the data service. diff --git a/Framework/Algorithms/test/NormaliseToMonitorTest.h b/Framework/Algorithms/test/NormaliseToMonitorTest.h index a4938cc93ed700243ad8e8b111d91d62945707d0..ddf1b0c52fd167466bc821cd9c3ffa45bdb89ae4 100644 --- a/Framework/Algorithms/test/NormaliseToMonitorTest.h +++ b/Framework/Algorithms/test/NormaliseToMonitorTest.h @@ -38,9 +38,9 @@ public: input->getAxis(0)->unit() = Mantid::Kernel::UnitFactory::Instance().create("Wavelength"); // Now need to set up a minimal instrument - input->getSpectrum(0)->setSpectrumNo(0); - input->getSpectrum(1)->setSpectrumNo(1); - input->getSpectrum(2)->setSpectrumNo(2); + input->getSpectrum(0).setSpectrumNo(0); + input->getSpectrum(1).setSpectrumNo(1); + input->getSpectrum(2).setSpectrumNo(2); boost::shared_ptr<Instrument> instr = boost::make_shared<Instrument>(); input->setInstrument(instr); Mantid::Geometry::Detector *mon = @@ -60,7 +60,7 @@ public: monWS->getAxis(0)->unit() = Mantid::Kernel::UnitFactory::Instance().create("Wavelength"); // Now need to set up a minimal instrument and spectra-detector map - input->getSpectrum(0)->setSpectrumNo(0); + input->getSpectrum(0).setSpectrumNo(0); monWS->setInstrument(input->getInstrument()); AnalysisDataService::Instance().addOrReplace("monWS", monWS); diff --git a/Framework/Algorithms/test/OneMinusExponentialCorTest.h b/Framework/Algorithms/test/OneMinusExponentialCorTest.h index 37c292dba131f4b646cc71fbcc7666d23115ae05..87155739a4789dd704af1f5aecb17413ea6eb79d 100644 --- a/Framework/Algorithms/test/OneMinusExponentialCorTest.h +++ b/Framework/Algorithms/test/OneMinusExponentialCorTest.h @@ -233,7 +233,7 @@ public: for (size_t i = 0; i < 5; ++i) { double t = static_cast<double>(i) + 0.5; double w = 0.5 / (1 - std::exp(-3. * t)); - TS_ASSERT_DELTA(evout->getEventList(0).getEvent(i).m_weight, w, 1e-6); + TS_ASSERT_DELTA(evout->getSpectrum(0).getEvent(i).m_weight, w, 1e-6); } AnalysisDataService::Instance().remove("test_ev_omec"); diff --git a/Framework/Algorithms/test/PhaseQuadMuonTest.h b/Framework/Algorithms/test/PhaseQuadMuonTest.h index 1a3bb63d0cf8d67e7bbcc2621bc874805b59b9bd..b3f39bc0d1f1fd480d9b1a3933f447227305736d 100644 --- a/Framework/Algorithms/test/PhaseQuadMuonTest.h +++ b/Framework/Algorithms/test/PhaseQuadMuonTest.h @@ -55,15 +55,15 @@ public: TS_ASSERT_EQUALS(outputWs->getNumberHistograms(), 2); TS_ASSERT_EQUALS( - outputWs->getSpectrum(0)->readX(), - inputWs->getSpectrum(0)->readX()); // Check outputWs X values - TS_ASSERT_EQUALS(outputWs->getSpectrum(1)->readX(), - inputWs->getSpectrum(1)->readX()); + outputWs->getSpectrum(0).readX(), + inputWs->getSpectrum(0).readX()); // Check outputWs X values + TS_ASSERT_EQUALS(outputWs->getSpectrum(1).readX(), + inputWs->getSpectrum(1).readX()); - auto specReY = outputWs->getSpectrum(0)->readY(); - auto specReE = outputWs->getSpectrum(0)->readE(); - auto specImY = outputWs->getSpectrum(1)->readY(); - auto specImE = outputWs->getSpectrum(1)->readE(); + auto specReY = outputWs->getSpectrum(0).readY(); + auto specReE = outputWs->getSpectrum(0).readE(); + auto specImY = outputWs->getSpectrum(1).readY(); + auto specImE = outputWs->getSpectrum(1).readE(); // Check real Y values TS_ASSERT_DELTA(specReY[0], -0.9982, 0.0001); TS_ASSERT_DELTA(specReY[20], -0.0252, 0.0001); diff --git a/Framework/Algorithms/test/PlusMinusTest.in.h b/Framework/Algorithms/test/PlusMinusTest.in.h index 603bdc16992a7f47488388d1c5725ce792ee8564..04ada377704bda3a5c77e0a1869b5df163dbc804 100644 --- a/Framework/Algorithms/test/PlusMinusTest.in.h +++ b/Framework/Algorithms/test/PlusMinusTest.in.h @@ -571,7 +571,7 @@ public: MatrixWorkspace_sptr work_in2 = WorkspaceCreationHelper::CreateEventWorkspace(3,10,50, 0.0, 1.0, 2, 100); //100 events per spectrum, but the spectra are at different pixel ids //First pixel id of rhs is 100 - TS_ASSERT( work_in2->getSpectrum(0)->hasDetectorID(100) ); + TS_ASSERT( work_in2->getSpectrum(0).hasDetectorID(100) ); MatrixWorkspace_sptr work_out = performTest(work_in1,work_in2, inplace!=0, true /*outputIsEvent*/, DO_PLUS ? 3.0 : -1.0, DO_PLUS ? 1.7320 : 1.7320); @@ -583,7 +583,7 @@ public: //But two detector IDs in each one for (int i=0; i<3; i++) { - auto detIT = work_out->getSpectrum(i)->getDetectorIDs().begin(); + auto detIT = work_out->getSpectrum(i).getDetectorIDs().begin(); TS_ASSERT_EQUALS( *detIT, 0+i ); if (DO_PLUS) { diff --git a/Framework/Algorithms/test/PolynomialCorrectionTest.h b/Framework/Algorithms/test/PolynomialCorrectionTest.h index 548b8c0cab8f7a097816cfd41719edeef4e274b0..769385b750e38a68456e8cf1a7dfa29ee592e9f7 100644 --- a/Framework/Algorithms/test/PolynomialCorrectionTest.h +++ b/Framework/Algorithms/test/PolynomialCorrectionTest.h @@ -152,7 +152,7 @@ public: for (size_t i = 0; i < 5; ++i) { double t = static_cast<double>(i) + 0.5; double w = 3.0 + t * 2.0 + t * t; - TS_ASSERT_DELTA(evout->getEventList(0).getEvent(i).m_weight, w, w * 1e-6); + TS_ASSERT_DELTA(evout->getSpectrum(0).getEvent(i).m_weight, w, w * 1e-6); } AnalysisDataService::Instance().remove("test_ev_polyc"); diff --git a/Framework/Algorithms/test/PowerLawCorrectionTest.h b/Framework/Algorithms/test/PowerLawCorrectionTest.h index ce81760e7a739e784239609805d911389f596b67..4f4927b4a9017f3fa0714859827ffd572a5f0425 100644 --- a/Framework/Algorithms/test/PowerLawCorrectionTest.h +++ b/Framework/Algorithms/test/PowerLawCorrectionTest.h @@ -111,7 +111,7 @@ public: TS_ASSERT(evout); // should be an event workspace for (size_t i = 0; i < 5; ++i) { double t = static_cast<double>(i) + 0.5; - TS_ASSERT_DELTA(evout->getEventList(0).getEvent(i).m_weight, 3. * t * t, + TS_ASSERT_DELTA(evout->getSpectrum(0).getEvent(i).m_weight, 3. * t * t, 1e-8); } diff --git a/Framework/Algorithms/test/RebinByTimeAtSampleTest.h b/Framework/Algorithms/test/RebinByTimeAtSampleTest.h index 29924057c6436ba1552226c12550bc1b9f1052fc..2bdce2739cc0643bc0fd9e32bba1de81d926c09d 100644 --- a/Framework/Algorithms/test/RebinByTimeAtSampleTest.h +++ b/Framework/Algorithms/test/RebinByTimeAtSampleTest.h @@ -33,7 +33,7 @@ createSinglePulseEventWorkspace(const V3D &sourcePosition, for (size_t i = 0; i < allSpectraTOF.size(); i++) { const double tof = allSpectraTOF[i]; uint64_t pulseTime(0); // Pulse time is always zero. Same pulse. - retVal->getEventList(pix) += TofEvent(tof, pulseTime); + retVal->getSpectrum(pix) += TofEvent(tof, pulseTime); } } diff --git a/Framework/Algorithms/test/RebinByTimeBaseTest.h b/Framework/Algorithms/test/RebinByTimeBaseTest.h index df0be466c80a31c79183ce7701f773f5e4e1399f..a4e499895176fcb8f7e8bcd741832d5acdce95db 100644 --- a/Framework/Algorithms/test/RebinByTimeBaseTest.h +++ b/Framework/Algorithms/test/RebinByTimeBaseTest.h @@ -48,7 +48,7 @@ createEventWorkspace(const int numberspectra, const int nDistrubutedEvents, uint64_t(((double)i + 0.5) * binWidth); // Stick an event with a // pulse_time in the middle of // each pulse_time bin. - retVal->getEventList(pix) += TofEvent(tof, pulseTime); + retVal->getSpectrum(pix) += TofEvent(tof, pulseTime); } } @@ -81,7 +81,6 @@ public: MOCK_CONST_METHOD1(getTimeAtSampleMax, DateAndTime(double)); MOCK_CONST_METHOD1(getTimeAtSampleMin, DateAndTime(double)); MOCK_CONST_METHOD0(getEventType, EventType()); - MOCK_METHOD1(getEventListPtr, IEventList *(const std::size_t)); MOCK_CONST_METHOD5(generateHistogram, void(const std::size_t, const Mantid::MantidVec &, Mantid::MantidVec &, Mantid::MantidVec &, bool)); @@ -90,9 +89,9 @@ public: MOCK_CONST_METHOD0(blocksize, std::size_t()); MOCK_CONST_METHOD0(size, std::size_t()); MOCK_CONST_METHOD0(getNumberHistograms, std::size_t()); - MOCK_METHOD1(getSpectrum, Mantid::API::ISpectrum *(const std::size_t)); + MOCK_METHOD1(getSpectrum, Mantid::API::IEventList &(const std::size_t)); MOCK_CONST_METHOD1(getSpectrum, - const Mantid::API::ISpectrum *(const std::size_t)); + const Mantid::API::IEventList &(const std::size_t)); MOCK_METHOD3(init, void(const size_t &, const size_t &, const size_t &)); MOCK_CONST_METHOD0(getSpecialCoordinateSystem, Mantid::Kernel::SpecialCoordinateSystem()); diff --git a/Framework/Algorithms/test/ReflectometryReductionOneAutoTest.h b/Framework/Algorithms/test/ReflectometryReductionOneAutoTest.h index 736cd334540bd4fc62f1f373ccef697689b4e9c0..800c0d97c2907c01082619ba64f045333514da99 100644 --- a/Framework/Algorithms/test/ReflectometryReductionOneAutoTest.h +++ b/Framework/Algorithms/test/ReflectometryReductionOneAutoTest.h @@ -444,8 +444,8 @@ public: // Add instrument to workspace tinyWS->setInstrument(instrument); - tinyWS->getSpectrum(0)->addDetectorID(det->getID()); - tinyWS->getSpectrum(1)->addDetectorID(monitor->getID()); + tinyWS->getSpectrum(0).addDetectorID(det->getID()); + tinyWS->getSpectrum(1).addDetectorID(monitor->getID()); // Now we can parameterize the instrument auto tinyInst = tinyWS->getInstrument(); diff --git a/Framework/Algorithms/test/ReflectometryReductionOneTest.h b/Framework/Algorithms/test/ReflectometryReductionOneTest.h index 68f09093ca9ceeb9f620e14dd3768f9fb09e5857..5d1eb6994816c431e0bfcb1454d28d5e1d551c75 100644 --- a/Framework/Algorithms/test/ReflectometryReductionOneTest.h +++ b/Framework/Algorithms/test/ReflectometryReductionOneTest.h @@ -45,9 +45,9 @@ public: const int monitorIndex = 0; specnum_t specId1 = - toConvert->getSpectrum(workspaceIndexToKeep1)->getSpectrumNo(); + toConvert->getSpectrum(workspaceIndexToKeep1).getSpectrumNo(); specnum_t monitorSpecId = - toConvert->getSpectrum(monitorIndex)->getSpectrumNo(); + toConvert->getSpectrum(monitorIndex).getSpectrumNo(); // Define one spectra to keep detectorIndexRange.push_back(static_cast<int>(workspaceIndexToKeep1)); @@ -177,7 +177,7 @@ public: // set the instrument to this workspace m_tinyReflWS->setInstrument(instrument); // set this detector ready for processing instructions - m_tinyReflWS->getSpectrum(0)->setDetectorID(det->getID()); + m_tinyReflWS->getSpectrum(0).setDetectorID(det->getID()); auto alg = AlgorithmManager::Instance().create("ReflectometryReductionOne"); alg->setRethrows(true); @@ -335,7 +335,7 @@ public: // set the instrument to this workspace m_tinyReflWS->setInstrument(instrument); // set this detector ready for processing instructions - m_tinyReflWS->getSpectrum(0)->setDetectorID(det->getID()); + m_tinyReflWS->getSpectrum(0).setDetectorID(det->getID()); auto alg = AlgorithmManager::Instance().create("ReflectometryReductionOne"); alg->setRethrows(true); diff --git a/Framework/Algorithms/test/RemoveBackgroundTest.h b/Framework/Algorithms/test/RemoveBackgroundTest.h index 9130e68fbc6fc5dffcaee17a8f562c3b895af1cc..dc37b2cf903ec75e08c4cf0bd4fdef55deab66d5 100644 --- a/Framework/Algorithms/test/RemoveBackgroundTest.h +++ b/Framework/Algorithms/test/RemoveBackgroundTest.h @@ -246,7 +246,7 @@ private: const MantidVec &Y = SourceWS->readY(0); const MantidVec &E = SourceWS->readE(0); cloneWS->setX(0, X); - cloneWS->getSpectrum(0)->setData(Y, E); + cloneWS->getSpectrum(0).setData(Y, E); return cloneWS; } diff --git a/Framework/Algorithms/test/RemoveLowResTOFTest.h b/Framework/Algorithms/test/RemoveLowResTOFTest.h index aa223ba44ed9a3142a5f4d8175987f48dd7f578d..b3a67a4138630bf9ab56571ecc586b31c5af0d07 100644 --- a/Framework/Algorithms/test/RemoveLowResTOFTest.h +++ b/Framework/Algorithms/test/RemoveLowResTOFTest.h @@ -38,7 +38,7 @@ private: 9)); // Make sure the detector IDs are ok for (int i = 0; i < NUMPIXELS; i++) - test_in->getSpectrum(i)->setDetectorID(i + 1); + test_in->getSpectrum(i).setDetectorID(i + 1); // Add it to the workspace AnalysisDataService::Instance().add(wsName, test_in); @@ -65,10 +65,10 @@ public: EventWorkspace_sptr ws = AnalysisDataService::Instance().retrieveWS<EventWorkspace>(name); size_t num_events = ws->getNumberEvents(); - double min_event0 = ws->getEventList(0).getTofMin(); - double max_event0 = ws->getEventList(0).getTofMax(); - double min_eventN = ws->getEventList(NUMPIXELS - 1).getTofMin(); - double max_eventN = ws->getEventList(NUMPIXELS - 1).getTofMax(); + double min_event0 = ws->getSpectrum(0).getTofMin(); + double max_event0 = ws->getSpectrum(0).getTofMax(); + double min_eventN = ws->getSpectrum(NUMPIXELS - 1).getTofMin(); + double max_eventN = ws->getSpectrum(NUMPIXELS - 1).getTofMax(); // run the algorithm RemoveLowResTOF algo; @@ -87,12 +87,12 @@ public: TS_ASSERT(num_events > ws->getNumberEvents()); // should drop events // pixel 0 shouldn't be adjusted - TS_ASSERT_EQUALS(min_event0, ws->getEventList(0).getTofMin()); - TS_ASSERT_EQUALS(max_event0, ws->getEventList(0).getTofMax()); + TS_ASSERT_EQUALS(min_event0, ws->getSpectrum(0).getTofMin()); + TS_ASSERT_EQUALS(max_event0, ws->getSpectrum(0).getTofMax()); // pixel NUMPIXELS - 1 should be moved - TS_ASSERT(min_eventN < ws->getEventList(NUMPIXELS - 1).getTofMin()); - TS_ASSERT_EQUALS(max_eventN, ws->getEventList(NUMPIXELS - 1).getTofMax()); + TS_ASSERT(min_eventN < ws->getSpectrum(NUMPIXELS - 1).getTofMin()); + TS_ASSERT_EQUALS(max_eventN, ws->getSpectrum(NUMPIXELS - 1).getTofMax()); } /** Test the functionality to output the removed low resolution TOF events to @@ -106,10 +106,10 @@ public: EventWorkspace_sptr ws = AnalysisDataService::Instance().retrieveWS<EventWorkspace>(name); size_t num_events = ws->getNumberEvents(); - double min_event0 = ws->getEventList(0).getTofMin(); - double max_event0 = ws->getEventList(0).getTofMax(); - double min_eventN = ws->getEventList(NUMPIXELS - 1).getTofMin(); - double max_eventN = ws->getEventList(NUMPIXELS - 1).getTofMax(); + double min_event0 = ws->getSpectrum(0).getTofMin(); + double max_event0 = ws->getSpectrum(0).getTofMax(); + double min_eventN = ws->getSpectrum(NUMPIXELS - 1).getTofMin(); + double max_eventN = ws->getSpectrum(NUMPIXELS - 1).getTofMax(); // run the algorithm RemoveLowResTOF algo; @@ -153,16 +153,16 @@ public: num_events); // pixel 0 shouldn't be adjusted - TS_ASSERT_EQUALS(min_event0, ws->getEventList(0).getTofMin()); - TS_ASSERT_EQUALS(max_event0, ws->getEventList(0).getTofMax()); - TS_ASSERT_EQUALS(lowresws->getEventList(0).getNumberEvents(), 0); + TS_ASSERT_EQUALS(min_event0, ws->getSpectrum(0).getTofMin()); + TS_ASSERT_EQUALS(max_event0, ws->getSpectrum(0).getTofMax()); + TS_ASSERT_EQUALS(lowresws->getSpectrum(0).getNumberEvents(), 0); // pixel NUMPIXELS - 1 should be moved - TS_ASSERT(min_eventN < ws->getEventList(NUMPIXELS - 1).getTofMin()); - TS_ASSERT_EQUALS(max_eventN, ws->getEventList(NUMPIXELS - 1).getTofMax()); + TS_ASSERT(min_eventN < ws->getSpectrum(NUMPIXELS - 1).getTofMin()); + TS_ASSERT_EQUALS(max_eventN, ws->getSpectrum(NUMPIXELS - 1).getTofMax()); TS_ASSERT_EQUALS(min_eventN, - lowresws->getEventList(NUMPIXELS - 1).getTofMin()); - TS_ASSERT(max_eventN > lowresws->getEventList(NUMPIXELS - 1).getTofMax()); + lowresws->getSpectrum(NUMPIXELS - 1).getTofMin()); + TS_ASSERT(max_eventN > lowresws->getSpectrum(NUMPIXELS - 1).getTofMax()); } }; diff --git a/Framework/Algorithms/test/RemoveMaskedSpectraTest.h b/Framework/Algorithms/test/RemoveMaskedSpectraTest.h index d077455a54a672b9162f5b17883ce07d5a1dd346..2d69771e100a8ffc016827924ed9827faa9605a6 100644 --- a/Framework/Algorithms/test/RemoveMaskedSpectraTest.h +++ b/Framework/Algorithms/test/RemoveMaskedSpectraTest.h @@ -90,7 +90,7 @@ private: } space->dataY(j).assign(nBins, double(j)); space->dataE(j).assign(nBins, sqrt(double(j))); - space->getSpectrum(j)->setDetectorID(detid_t(j + 1)); + space->getSpectrum(j).setDetectorID(detid_t(j + 1)); } return space; } diff --git a/Framework/Algorithms/test/RemovePromptPulseTest.h b/Framework/Algorithms/test/RemovePromptPulseTest.h index e71f25e348bd1ff123166cd0e9dfca9b14610f81..d1a442aa97eb3ed554ecb1da37f5b53984b91e4f 100644 --- a/Framework/Algorithms/test/RemovePromptPulseTest.h +++ b/Framework/Algorithms/test/RemovePromptPulseTest.h @@ -39,7 +39,7 @@ private: 9)); // Make sure the detector IDs are ok for (int i = 0; i < NUMPIXELS; i++) - test_in->getSpectrum(i)->setDetectorID(i + 1); + test_in->getSpectrum(i).setDetectorID(i + 1); // Add it to the workspace AnalysisDataService::Instance().add(wsName, test_in); diff --git a/Framework/Algorithms/test/ReplaceSpecialValuesTest.h b/Framework/Algorithms/test/ReplaceSpecialValuesTest.h index de33cbfce168c95043e8a49c3e0792c54a5d6d19..c4af4692414f8872ba8b06590c067824e8f055df 100644 --- a/Framework/Algorithms/test/ReplaceSpecialValuesTest.h +++ b/Framework/Algorithms/test/ReplaceSpecialValuesTest.h @@ -252,12 +252,12 @@ public: 1, 5, 10, 0, 1, 3), evout; AnalysisDataService::Instance().add("test_ev_rep", evin); - EventList *evlist = evin->getEventListPtr(0); - evlist->switchTo(WEIGHTED); - evlist->getWeightedEvents().at(0).m_weight = static_cast<float>(0.01); - evlist->getWeightedEvents().at(1).m_weight = + auto &evlist = evin->getSpectrum(0); + evlist.switchTo(WEIGHTED); + evlist.getWeightedEvents().at(0).m_weight = static_cast<float>(0.01); + evlist.getWeightedEvents().at(1).m_weight = std::numeric_limits<float>::infinity(); - evlist->getWeightedEvents().at(2).m_weight = + evlist.getWeightedEvents().at(2).m_weight = std::numeric_limits<float>::quiet_NaN(); Mantid::Algorithms::ReplaceSpecialValues alg; @@ -283,10 +283,10 @@ public: AnalysisDataService::Instance().retrieve("test_ev_rep_out"))); TS_ASSERT(evout); // should be an event workspace - TS_ASSERT_DELTA(evout->getEventList(0).getEvent(0).m_weight, 0.01, 1e-8); - TS_ASSERT_EQUALS(evout->getEventList(0).getEvent(1).m_weight, 9); - TS_ASSERT_EQUALS(evout->getEventList(0).getEvent(2).m_weight, 7); - TS_ASSERT_EQUALS(evout->getEventList(0).getEvent(3).m_weight, -11); + TS_ASSERT_DELTA(evout->getSpectrum(0).getEvent(0).m_weight, 0.01, 1e-8); + TS_ASSERT_EQUALS(evout->getSpectrum(0).getEvent(1).m_weight, 9); + TS_ASSERT_EQUALS(evout->getSpectrum(0).getEvent(2).m_weight, 7); + TS_ASSERT_EQUALS(evout->getSpectrum(0).getEvent(3).m_weight, -11); AnalysisDataService::Instance().remove("test_ev_rep"); AnalysisDataService::Instance().remove("test_ev_rep_out"); } diff --git a/Framework/Algorithms/test/SANSCollimationLengthEstimatorTest.h b/Framework/Algorithms/test/SANSCollimationLengthEstimatorTest.h index a3c717d32428a20955306ca07aab6bce69380637..4eac613b723ddef3b96317eb60677d28fb81fcb4 100644 --- a/Framework/Algorithms/test/SANSCollimationLengthEstimatorTest.h +++ b/Framework/Algorithms/test/SANSCollimationLengthEstimatorTest.h @@ -152,10 +152,10 @@ Mantid::API::MatrixWorkspace_sptr createTestWorkspace( // Link workspace with detector for (size_t i = 0; i < nhist; ++i) { const Mantid::specnum_t specID = static_cast<Mantid::specnum_t>(id + i); - auto *spec = ws2d->getSpectrum(i); - spec->setSpectrumNo(specID); - spec->clearDetectorIDs(); - spec->addDetectorID(id); + auto &spec = ws2d->getSpectrum(i); + spec.setSpectrumNo(specID); + spec.clearDetectorIDs(); + spec.addDetectorID(id); } return ws2d; } @@ -433,4 +433,4 @@ public: expectedCollimationLength); } }; -#endif \ No newline at end of file +#endif diff --git a/Framework/Algorithms/test/ScaleXTest.h b/Framework/Algorithms/test/ScaleXTest.h index cbae2ce74941b012eb7bd1c88a5cf079316b3d5c..04220222b3e957502cfca8519c7ecdab9107645b 100644 --- a/Framework/Algorithms/test/ScaleXTest.h +++ b/Framework/Algorithms/test/ScaleXTest.h @@ -166,13 +166,12 @@ public: else factor = instFactor; - auto inEvents = resultEventWS->getEventListPtr(i); - auto outEvents = resultEventWS->getEventListPtr(i); - TS_ASSERT_EQUALS(outEvents->getNumberEvents(), - inEvents->getNumberEvents()); + auto &inEvents = resultEventWS->getSpectrum(i); + auto &outEvents = resultEventWS->getSpectrum(i); + TS_ASSERT_EQUALS(outEvents.getNumberEvents(), inEvents.getNumberEvents()); - auto inTOFs = inEvents->getTofs(); - auto outTOFs = outEvents->getTofs(); + auto inTOFs = inEvents.getTofs(); + auto outTOFs = outEvents.getTofs(); TS_ASSERT_EQUALS(inTOFs.size(), outTOFs.size()); for (size_t j = 0; i < inTOFs.size(); ++j) { TS_ASSERT_DELTA(outTOFs[j], factor * inTOFs[j], 1e-12); diff --git a/Framework/Algorithms/test/SmoothNeighboursTest.h b/Framework/Algorithms/test/SmoothNeighboursTest.h index 2dab29faed28f25443c5bb139b8985b5d841c44f..41ba291083339d2c56ad390989bca371b0d54272 100644 --- a/Framework/Algorithms/test/SmoothNeighboursTest.h +++ b/Framework/Algorithms/test/SmoothNeighboursTest.h @@ -68,8 +68,8 @@ public: for (size_t j = 0; j < inWS->readE(0).size(); j++) { TS_ASSERT_LESS_THAN(outWS->readE(wi)[j], inWS->readE(wi)[j]); } - auto inDetIDs = inWS->getSpectrum(wi)->getDetectorIDs(); - auto outDetIDs = outWS->getSpectrum(wi)->getDetectorIDs(); + auto inDetIDs = inWS->getSpectrum(wi).getDetectorIDs(); + auto outDetIDs = outWS->getSpectrum(wi).getDetectorIDs(); TS_ASSERT_LESS_THAN(inDetIDs.size(), outDetIDs.size()); if (!inDetIDs.empty()) TS_ASSERT_EQUALS(outDetIDs.count(*inDetIDs.begin()), 1); @@ -93,13 +93,13 @@ public: } if (type == WEIGHTED_NOTIME) { for (size_t i = 0; i < in_ws->getNumberHistograms(); i++) { - EventList &el = in_ws->getEventList(i); + EventList &el = in_ws->getSpectrum(i); el.compressEvents(0.0, &el); } } // Multiply by 2 the workspace at index 4 - EventList &el = in_ws->getEventList(4); + EventList &el = in_ws->getSpectrum(4); el += el; // Register the workspace in the data service @@ -176,13 +176,13 @@ public: } if (type == WEIGHTED_NOTIME) { for (size_t i = 0; i < in_ws->getNumberHistograms(); i++) { - EventList &el = in_ws->getEventList(i); + EventList &el = in_ws->getSpectrum(i); el.compressEvents(0.0, &el); } } // Multiply by 2 the workspace at index 4 - EventList &el = in_ws->getEventList(4); + EventList &el = in_ws->getSpectrum(4); el += el; size_t nevents0 = in_ws->getNumberEvents(); diff --git a/Framework/Algorithms/test/SofQWNormalisedPolygonTest.h b/Framework/Algorithms/test/SofQWNormalisedPolygonTest.h index e0796234558590f698821b67234f14cd3c17b208..6553f1fa6555cd634ff433eaaba2ef6d38c6d3fc 100644 --- a/Framework/Algorithms/test/SofQWNormalisedPolygonTest.h +++ b/Framework/Algorithms/test/SofQWNormalisedPolygonTest.h @@ -76,11 +76,11 @@ public: expectedIDs[5] = s6; for (size_t i = 0; i < nspectra; ++i) { - const auto *spectrum = result->getSpectrum(i); - Mantid::specnum_t specNoActual = spectrum->getSpectrumNo(); + const auto &spectrum = result->getSpectrum(i); + Mantid::specnum_t specNoActual = spectrum.getSpectrumNo(); Mantid::specnum_t specNoExpected = static_cast<Mantid::specnum_t>(i + 1); TS_ASSERT_EQUALS(specNoExpected, specNoActual); - TS_ASSERT_EQUALS(expectedIDs[i], spectrum->getDetectorIDs()); + TS_ASSERT_EQUALS(expectedIDs[i], spectrum.getDetectorIDs()); } } }; diff --git a/Framework/Algorithms/test/SofQWPolygonTest.h b/Framework/Algorithms/test/SofQWPolygonTest.h index df89df41437fa492e75c53efd05ad40aba90630a..5aae55ce168b528a6ad8c81271d041efe42f581f 100644 --- a/Framework/Algorithms/test/SofQWPolygonTest.h +++ b/Framework/Algorithms/test/SofQWPolygonTest.h @@ -74,11 +74,11 @@ public: expectedIDs[5] = s6; for (size_t i = 0; i < nspectra; ++i) { - const auto *spectrum = result->getSpectrum(i); - Mantid::specnum_t specNoActual = spectrum->getSpectrumNo(); + const auto &spectrum = result->getSpectrum(i); + Mantid::specnum_t specNoActual = spectrum.getSpectrumNo(); Mantid::specnum_t specNoExpected = static_cast<Mantid::specnum_t>(i + 1); TS_ASSERT_EQUALS(specNoExpected, specNoActual); - TS_ASSERT_EQUALS(expectedIDs[i], spectrum->getDetectorIDs()); + TS_ASSERT_EQUALS(expectedIDs[i], spectrum.getDetectorIDs()); } } }; diff --git a/Framework/Algorithms/test/SolidAngleTest.h b/Framework/Algorithms/test/SolidAngleTest.h index d6c1f6980098d5a9ba76bb67ae7fcbbd8ad678d9..85ddef6e749d5865ae675c09c0716c5582aea21f 100644 --- a/Framework/Algorithms/test/SolidAngleTest.h +++ b/Framework/Algorithms/test/SolidAngleTest.h @@ -48,7 +48,7 @@ public: space2D->setX(j, x); space2D->setData(j, a, e); // Just set the spectrum number to match the index - space2D->getSpectrum(j)->setSpectrumNo(j + 1); + space2D->getSpectrum(j).setSpectrumNo(j + 1); } // Register the workspace in the data service diff --git a/Framework/Algorithms/test/SortEventsTest.h b/Framework/Algorithms/test/SortEventsTest.h index 6826a7d7e7312aa91415d54fbb964f980dbae86d..bc49c37416f0df28fbcef297716badfa0ce32e59 100644 --- a/Framework/Algorithms/test/SortEventsTest.h +++ b/Framework/Algorithms/test/SortEventsTest.h @@ -58,7 +58,7 @@ public: AnalysisDataService::Instance().retrieveWS<const EventWorkspace>( wsName); - std::vector<TofEvent> ve = outWS->getEventList(0).getEvents(); + std::vector<TofEvent> ve = outWS->getSpectrum(0).getEvents(); TS_ASSERT_EQUALS(ve.size(), NUMBINS); for (size_t i = 0; i < ve.size() - 1; i++) TS_ASSERT_LESS_THAN_EQUALS(ve[i].tof(), ve[i + 1].tof()); @@ -83,7 +83,7 @@ public: EventWorkspace_const_sptr outWS = AnalysisDataService::Instance().retrieveWS<const EventWorkspace>( wsName); - std::vector<TofEvent> ve = outWS->getEventList(0).getEvents(); + std::vector<TofEvent> ve = outWS->getSpectrum(0).getEvents(); TS_ASSERT_EQUALS(ve.size(), NUMBINS); for (size_t i = 0; i < ve.size() - 1; i++) TS_ASSERT_LESS_THAN_EQUALS(ve[i].pulseTime(), ve[i + 1].pulseTime()); @@ -107,7 +107,7 @@ public: EventWorkspace_const_sptr outWS = AnalysisDataService::Instance().retrieveWS<const EventWorkspace>( wsName); - std::vector<TofEvent> ve = outWS->getEventList(0).getEvents(); + std::vector<TofEvent> ve = outWS->getSpectrum(0).getEvents(); TS_ASSERT_EQUALS(ve.size(), NUMBINS); for (size_t i = 0; i < ve.size() - 1; i++) { bool less = true; diff --git a/Framework/Algorithms/test/SumSpectraTest.h b/Framework/Algorithms/test/SumSpectraTest.h index 68b23ae4ec18b49a3b0ca34608fc71d21a8115a4..8f0dab72fbfc089836f8e620437cd6002e30d9b1 100644 --- a/Framework/Algorithms/test/SumSpectraTest.h +++ b/Framework/Algorithms/test/SumSpectraTest.h @@ -80,11 +80,11 @@ public: } // Check the detectors mapped to the single spectra - const ISpectrum *spec = output2D->getSpectrum(0); - TS_ASSERT_EQUALS(spec->getSpectrumNo(), 2); - TS_ASSERT_EQUALS(spec->getDetectorIDs().size(), 2); - TS_ASSERT(spec->hasDetectorID(3)); - TS_ASSERT(spec->hasDetectorID(4)); + const auto &spec = output2D->getSpectrum(0); + TS_ASSERT_EQUALS(spec.getSpectrumNo(), 2); + TS_ASSERT_EQUALS(spec.getDetectorIDs().size(), 2); + TS_ASSERT(spec.hasDetectorID(3)); + TS_ASSERT(spec.hasDetectorID(4)); TS_ASSERT(output2D->run().hasProperty("NumAllSpectra")) TS_ASSERT(output2D->run().hasProperty("NumMaskSpectra")) @@ -144,16 +144,16 @@ public: TS_ASSERT_DELTA(e[99], std::sqrt(y[99]), 0.00001); // Check the detectors mapped to the single spectra - const ISpectrum *spec = output2D->getSpectrum(0); - TS_ASSERT_EQUALS(spec->getSpectrumNo(), 1); + const auto &spec = output2D->getSpectrum(0); + TS_ASSERT_EQUALS(spec.getSpectrumNo(), 1); // Spectra at workspace index 1 is masked, 8 & 9 are monitors - TS_ASSERT_EQUALS(spec->getDetectorIDs().size(), 7); - TS_ASSERT(spec->hasDetectorID(1)); - TS_ASSERT(spec->hasDetectorID(3)); - TS_ASSERT(spec->hasDetectorID(4)); - TS_ASSERT(spec->hasDetectorID(5)); - TS_ASSERT(spec->hasDetectorID(6)); - TS_ASSERT(spec->hasDetectorID(7)); + TS_ASSERT_EQUALS(spec.getDetectorIDs().size(), 7); + TS_ASSERT(spec.hasDetectorID(1)); + TS_ASSERT(spec.hasDetectorID(3)); + TS_ASSERT(spec.hasDetectorID(4)); + TS_ASSERT(spec.hasDetectorID(5)); + TS_ASSERT(spec.hasDetectorID(6)); + TS_ASSERT(spec.hasDetectorID(7)); TS_ASSERT(output2D->run().hasProperty("NumAllSpectra")) TS_ASSERT(output2D->run().hasProperty("NumMaskSpectra")) @@ -325,16 +325,16 @@ public: TS_ASSERT_DELTA(e[99], std::sqrt(double(nSignals)) * e0[99], 0.00001); // Check the detectors mapped to the single spectra - const ISpectrum *spec = output2D->getSpectrum(0); - TS_ASSERT_EQUALS(spec->getSpectrumNo(), 1); + const auto &spec = output2D->getSpectrum(0); + TS_ASSERT_EQUALS(spec.getSpectrumNo(), 1); // Spectra at workspace index 1 is masked, 8 & 9 are monitors - TS_ASSERT_EQUALS(spec->getDetectorIDs().size(), 7); - TS_ASSERT(spec->hasDetectorID(1)); - TS_ASSERT(spec->hasDetectorID(3)); - TS_ASSERT(spec->hasDetectorID(4)); - TS_ASSERT(spec->hasDetectorID(5)); - TS_ASSERT(spec->hasDetectorID(6)); - TS_ASSERT(spec->hasDetectorID(7)); + TS_ASSERT_EQUALS(spec.getDetectorIDs().size(), 7); + TS_ASSERT(spec.hasDetectorID(1)); + TS_ASSERT(spec.hasDetectorID(3)); + TS_ASSERT(spec.hasDetectorID(4)); + TS_ASSERT(spec.hasDetectorID(5)); + TS_ASSERT(spec.hasDetectorID(6)); + TS_ASSERT(spec.hasDetectorID(7)); } void testExecNoLimitsSpecialWeighted() { diff --git a/Framework/Algorithms/test/TOFSANSResolutionByPixelTest.h b/Framework/Algorithms/test/TOFSANSResolutionByPixelTest.h index cfb814bbdb1bd2830ff3270f2a76d7593c3f6877..7573edeff8365cb52d5e255b543010e7e460c457 100644 --- a/Framework/Algorithms/test/TOFSANSResolutionByPixelTest.h +++ b/Framework/Algorithms/test/TOFSANSResolutionByPixelTest.h @@ -173,10 +173,10 @@ Mantid::API::MatrixWorkspace_sptr createTestWorkspace( // Link workspace with detector for (size_t i = 0; i < nhist; ++i) { const Mantid::specnum_t specID = static_cast<Mantid::specnum_t>(id + i); - auto *spec = ws2d->getSpectrum(i); - spec->setSpectrumNo(specID); - spec->clearDetectorIDs(); - spec->addDetectorID(id); + auto &spec = ws2d->getSpectrum(i); + spec.setSpectrumNo(specID); + spec.clearDetectorIDs(); + spec.addDetectorID(id); } return ws2d; } diff --git a/Framework/Algorithms/test/UnwrapSNSTest.h b/Framework/Algorithms/test/UnwrapSNSTest.h index 93c8f0b02c574a6ec19325046d86cde83fa333e9..874ca566bd36e8da695fdedc5a111623b28a7f0d 100644 --- a/Framework/Algorithms/test/UnwrapSNSTest.h +++ b/Framework/Algorithms/test/UnwrapSNSTest.h @@ -57,10 +57,10 @@ public: EventWorkspace_sptr ws = AnalysisDataService::Instance().retrieveWS<EventWorkspace>(name); size_t num_events = ws->getNumberEvents(); - double min_event0 = ws->getEventList(0).getTofMin(); - double max_event0 = ws->getEventList(0).getTofMax(); - double min_eventN = ws->getEventList(NUMPIXELS - 1).getTofMin(); - double max_eventN = ws->getEventList(NUMPIXELS - 1).getTofMax(); + double min_event0 = ws->getSpectrum(0).getTofMin(); + double max_event0 = ws->getSpectrum(0).getTofMax(); + double min_eventN = ws->getSpectrum(NUMPIXELS - 1).getTofMin(); + double max_eventN = ws->getSpectrum(NUMPIXELS - 1).getTofMax(); // run the algorithm UnwrapSNS algo; @@ -80,16 +80,16 @@ public: ws->getNumberEvents()); // shouldn't drop events // pixel 0 shouldn't be adjusted - TS_ASSERT_EQUALS(min_event0, ws->getEventList(0).getTofMin()); - TS_ASSERT_EQUALS(max_event0, ws->getEventList(0).getTofMax()); + TS_ASSERT_EQUALS(min_event0, ws->getSpectrum(0).getTofMin()); + TS_ASSERT_EQUALS(max_event0, ws->getSpectrum(0).getTofMax()); // pixel NUMPIXELS - 1 should be moved - TS_ASSERT(min_eventN < ws->getEventList(NUMPIXELS - 1).getTofMin()); - TS_ASSERT(max_eventN < ws->getEventList(NUMPIXELS - 1).getTofMax()); + TS_ASSERT(min_eventN < ws->getSpectrum(NUMPIXELS - 1).getTofMin()); + TS_ASSERT(max_eventN < ws->getSpectrum(NUMPIXELS - 1).getTofMax()); - TS_ASSERT_EQUALS(ws->getEventList(0).dataX()[0], 0.0); - TS_ASSERT_EQUALS(ws->getEventList(0).dataX()[1], 2.0); - TS_ASSERT_EQUALS(ws->getEventList(0).dataX()[2], 4.0); + TS_ASSERT_EQUALS(ws->getSpectrum(0).dataX()[0], 0.0); + TS_ASSERT_EQUALS(ws->getSpectrum(0).dataX()[1], 2.0); + TS_ASSERT_EQUALS(ws->getSpectrum(0).dataX()[2], 4.0); } }; diff --git a/Framework/Algorithms/test/VesuvioL1ThetaResolutionTest.h b/Framework/Algorithms/test/VesuvioL1ThetaResolutionTest.h index cf16aced9b36482c2b3ba6a7135c1d2c1fc6ed64..73e411e2f247f4eeb31ce35bd62ab2c69cad0a59 100644 --- a/Framework/Algorithms/test/VesuvioL1ThetaResolutionTest.h +++ b/Framework/Algorithms/test/VesuvioL1ThetaResolutionTest.h @@ -188,12 +188,12 @@ private: TS_ASSERT_EQUALS(vAxis->getValue(vAxis->length() - 1), 198); } - auto firstSpecDetIDs = ws->getSpectrum(0)->getDetectorIDs(); + auto firstSpecDetIDs = ws->getSpectrum(0).getDetectorIDs(); TS_ASSERT_EQUALS(firstSpecDetIDs.size(), 1); TS_ASSERT_DIFFERS(firstSpecDetIDs.find(2101), firstSpecDetIDs.end()); auto lastSpecDetIDs = - ws->getSpectrum(ws->getNumberHistograms() - 1)->getDetectorIDs(); + ws->getSpectrum(ws->getNumberHistograms() - 1).getDetectorIDs(); TS_ASSERT_EQUALS(lastSpecDetIDs.size(), 1); TS_ASSERT_DIFFERS(lastSpecDetIDs.find(3232), lastSpecDetIDs.end()); } diff --git a/Framework/Algorithms/test/WorkspaceCreationHelperTest.h b/Framework/Algorithms/test/WorkspaceCreationHelperTest.h index a1c3804687da72b281ab281d8f95d8d425f72a42..f56173e6a3f265fb1237bd961ed00aa21cbe32b5 100644 --- a/Framework/Algorithms/test/WorkspaceCreationHelperTest.h +++ b/Framework/Algorithms/test/WorkspaceCreationHelperTest.h @@ -22,8 +22,8 @@ public: TS_ASSERT(ws->getInstrument()); TS_ASSERT_EQUALS(ws->getNumberHistograms(), 2 * 100); TS_ASSERT_EQUALS(ws->blocksize(), 20); - TS_ASSERT(ws->getSpectrum(0)->hasDetectorID(100)); - TS_ASSERT(ws->getSpectrum(1)->hasDetectorID(101)); + TS_ASSERT(ws->getSpectrum(0).hasDetectorID(100)); + TS_ASSERT(ws->getSpectrum(1).hasDetectorID(101)); TS_ASSERT_DELTA(ws->dataY(5)[0], 2.0, 1e-5); } @@ -33,8 +33,8 @@ public: TS_ASSERT(ws); TS_ASSERT(ws->getInstrument()); TS_ASSERT_EQUALS(ws->getNumberHistograms(), 2 * 100); - TS_ASSERT(ws->getSpectrum(0)->hasDetectorID(100)); - TS_ASSERT(ws->getSpectrum(1)->hasDetectorID(101)); + TS_ASSERT(ws->getSpectrum(0).hasDetectorID(100)); + TS_ASSERT(ws->getSpectrum(1).hasDetectorID(101)); } }; diff --git a/Framework/Algorithms/test/WorkspaceGroupTest.h b/Framework/Algorithms/test/WorkspaceGroupTest.h index de36ce346cda44fc91d660a930aa84cfd9911797..9f143f5a81b88cfcf3cde23db2ef91874804ae70 100644 --- a/Framework/Algorithms/test/WorkspaceGroupTest.h +++ b/Framework/Algorithms/test/WorkspaceGroupTest.h @@ -189,7 +189,7 @@ public: if (i % 2 == 0) { work_in1->setData(i, yDead, yDead); } - work_in1->getSpectrum(i)->setSpectrumNo(i); + work_in1->getSpectrum(i).setSpectrumNo(i); Mantid::Geometry::Detector *det = new Mantid::Geometry::Detector("", i, NULL); instr->add(det); @@ -200,7 +200,7 @@ public: if (i % 2 == 0) { work_in2->setData(i, yDead, yDead); } - work_in2->getSpectrum(i)->setSpectrumNo(i); + work_in2->getSpectrum(i).setSpectrumNo(i); } WorkspaceGroup_sptr wsSptr = WorkspaceGroup_sptr(new WorkspaceGroup); diff --git a/Framework/Crystal/src/AnvredCorrection.cpp b/Framework/Crystal/src/AnvredCorrection.cpp index 37feadb9225f1a3db4e28ec0b27109141061598e..a12ee8e256292302269f82d9e99c10b575f6fc12 100644 --- a/Framework/Crystal/src/AnvredCorrection.cpp +++ b/Framework/Crystal/src/AnvredCorrection.cpp @@ -188,13 +188,13 @@ void AnvredCorrection::exec() { MantidVec &E = correctionFactors->dataE(i); // Copy over bin boundaries - const ISpectrum *inSpec = m_inputWS->getSpectrum(i); - inSpec->lockData(); // for MRU-related thread safety + const auto &inSpec = m_inputWS->getSpectrum(i); + inSpec.lockData(); // for MRU-related thread safety - const MantidVec &Xin = inSpec->readX(); + const MantidVec &Xin = inSpec.readX(); correctionFactors->dataX(i) = Xin; - const MantidVec &Yin = inSpec->readY(); - const MantidVec &Ein = inSpec->readE(); + const MantidVec &Yin = inSpec.readY(); + const MantidVec &Ein = inSpec.readE(); // Get detector position IDetector_const_sptr det; @@ -247,7 +247,7 @@ void AnvredCorrection::exec() { } } - inSpec->unlockData(); + inSpec.unlockData(); prog.report(); @@ -325,7 +325,7 @@ void AnvredCorrection::execEvent() { // scattered beam double scattering = dir.angle(V3D(0.0, 0.0, 1.0)); - EventList el = eventW->getEventList(i); + EventList el = eventW->getSpectrum(i); el.switchTo(WEIGHTED_NOTIME); std::vector<WeightedEventNoTime> events = el.getWeightedEventsNoTime(); @@ -356,12 +356,12 @@ void AnvredCorrection::execEvent() { } correctionFactors->getOrAddEventList(i) += events; - auto &dets = eventW->getEventList(i).getDetectorIDs(); + auto &dets = eventW->getSpectrum(i).getDetectorIDs(); for (auto const &det : dets) correctionFactors->getOrAddEventList(i).addDetectorID(det); // When focussing in place, you can clear out old memory from the input one! if (inPlace) { - eventW->getEventList(i).clear(); + eventW->getSpectrum(i).clear(); } prog.report(); diff --git a/Framework/Crystal/src/CentroidPeaks.cpp b/Framework/Crystal/src/CentroidPeaks.cpp index bfa8bc791cb35f092fb0b7dcac2b145bc11ddcf2..9841a43d70aad2286c3a433ea428af1f90d34bfa 100644 --- a/Framework/Crystal/src/CentroidPeaks.cpp +++ b/Framework/Crystal/src/CentroidPeaks.cpp @@ -267,7 +267,7 @@ void CentroidPeaks::integrateEvent() { continue; it = wi_to_detid_map.find(findPixelID(bankName, icol, irow)); size_t workspaceIndex = (it->second); - EventList el = eventW->getEventList(workspaceIndex); + EventList el = eventW->getSpectrum(workspaceIndex); el.switchTo(WEIGHTED_NOTIME); std::vector<WeightedEventNoTime> events = el.getWeightedEventsNoTime(); diff --git a/Framework/Crystal/src/IntegratePeakTimeSlices.cpp b/Framework/Crystal/src/IntegratePeakTimeSlices.cpp index 04c836b33ade88820ed2876c0c0f239f1f487fba..f032f41de235f7878a2feb2008e2c0f41382ee8a 100644 --- a/Framework/Crystal/src/IntegratePeakTimeSlices.cpp +++ b/Framework/Crystal/src/IntegratePeakTimeSlices.cpp @@ -1611,7 +1611,7 @@ void IntegratePeakTimeSlices::SetUpData1( { spec_idList += std::to_string( - inpWkSpace->getSpectrum(workspaceIndex)->getSpectrumNo()); + inpWkSpace->getSpectrum(workspaceIndex).getSpectrumNo()); double R1 = dist.scalar_prod(m_yvec); double R1a = R1 / m_cellHeight; diff --git a/Framework/Crystal/src/LoadIsawSpectrum.cpp b/Framework/Crystal/src/LoadIsawSpectrum.cpp index 578dfb4c7093034b8e0ceb2524370cfe5bfafd27..eecb62af8e6f460b2e572cbab36f4722278b721a 100644 --- a/Framework/Crystal/src/LoadIsawSpectrum.cpp +++ b/Framework/Crystal/src/LoadIsawSpectrum.cpp @@ -145,15 +145,15 @@ void LoadIsawSpectrum::exec() { // Go through each point at this run / bank for (size_t i = 0; i < spectra.size(); i++) { - ISpectrum *outSpec = outWS->getSpectrum(i); - outSpec->clearDetectorIDs(); + auto &outSpec = outWS->getSpectrum(i); + outSpec.clearDetectorIDs(); for (int j = 0; j < detList[i]->xpixels(); j++) for (int k = 0; k < detList[i]->ypixels(); k++) - outSpec->addDetectorID( + outSpec.addDetectorID( static_cast<detid_t>(detList[i]->getDetectorIDAtXY(j, k))); - MantidVec &outY = outSpec->dataY(); - MantidVec &outE = outSpec->dataE(); - MantidVec &outX = outSpec->dataX(); + MantidVec &outY = outSpec.dataY(); + MantidVec &outE = outSpec.dataE(); + MantidVec &outX = outSpec.dataX(); // This is the scattered beam direction V3D dir = detList[i]->getPos() - samplePos; diff --git a/Framework/Crystal/src/NormaliseVanadium.cpp b/Framework/Crystal/src/NormaliseVanadium.cpp index 9e3b1cf24c18596db56286a2d8069fe5b9371799..38b21ec7888d08817984f9ee71c9c425fac46a00 100644 --- a/Framework/Crystal/src/NormaliseVanadium.cpp +++ b/Framework/Crystal/src/NormaliseVanadium.cpp @@ -78,13 +78,13 @@ void NormaliseVanadium::exec() { MantidVec &E = correctionFactors->dataE(i); // Copy over bin boundaries - const ISpectrum *inSpec = m_inputWS->getSpectrum(i); - inSpec->lockData(); // for MRU-related thread safety + const auto &inSpec = m_inputWS->getSpectrum(i); + inSpec.lockData(); // for MRU-related thread safety - const MantidVec &Xin = inSpec->readX(); + const MantidVec &Xin = inSpec.readX(); correctionFactors->dataX(i) = Xin; - const MantidVec &Yin = inSpec->readY(); - const MantidVec &Ein = inSpec->readE(); + const MantidVec &Yin = inSpec.readY(); + const MantidVec &Ein = inSpec.readE(); // Get detector position IDetector_const_sptr det; @@ -138,7 +138,7 @@ void NormaliseVanadium::exec() { E[j] = Ein[j] / normvalue; } - inSpec->unlockData(); + inSpec.unlockData(); prog.report(); diff --git a/Framework/Crystal/src/PeakIntegration.cpp b/Framework/Crystal/src/PeakIntegration.cpp index 0866419d2a6376ead199952b6cd1e24743f8a848..81b32e5a9101139fb5bf234e7115be417eb6dc32 100644 --- a/Framework/Crystal/src/PeakIntegration.cpp +++ b/Framework/Crystal/src/PeakIntegration.cpp @@ -348,7 +348,7 @@ int PeakIntegration::fitneighbours(int ipeak, std::string det_name, int x0, } } - outputW->getSpectrum(idet)->clearDetectorIDs(); + outputW->getSpectrum(idet).clearDetectorIDs(); // Find the pixel ID at that XY position on the rectangular detector int pixelID = peak.getDetectorID(); // det->getAtXY(x0,y0)->getID(); @@ -358,7 +358,7 @@ int PeakIntegration::fitneighbours(int ipeak, std::string det_name, int x0, size_t wi = wiEntry->second; // Set detectorIDs outputW->getSpectrum(idet) - ->addDetectorIDs(inputW->getSpectrum(wi)->getDetectorIDs()); + .addDetectorIDs(inputW->getSpectrum(wi).getDetectorIDs()); } return TOFmax - 1; diff --git a/Framework/Crystal/src/SCDCalibratePanels.cpp b/Framework/Crystal/src/SCDCalibratePanels.cpp index 51eb913cb83d8cdbc34a44065e7a5fc371ecb82b..25a57eef0a5add8670ceb9dfc26c2a712b7ee111 100644 --- a/Framework/Crystal/src/SCDCalibratePanels.cpp +++ b/Framework/Crystal/src/SCDCalibratePanels.cpp @@ -1265,9 +1265,9 @@ void SCDCalibratePanels::exec() { bank = boost::lexical_cast<int>(bankName.substr(k + 1)); if (bank != bankLast) { iSpectrum++; - ColWksp->getSpectrum(iSpectrum)->setSpectrumNo(specnum_t(bank)); - RowWksp->getSpectrum(iSpectrum)->setSpectrumNo(specnum_t(bank)); - TofWksp->getSpectrum(iSpectrum)->setSpectrumNo(specnum_t(bank)); + ColWksp->getSpectrum(iSpectrum).setSpectrumNo(specnum_t(bank)); + RowWksp->getSpectrum(iSpectrum).setSpectrumNo(specnum_t(bank)); + TofWksp->getSpectrum(iSpectrum).setSpectrumNo(specnum_t(bank)); bankLast = bank; icount = 0; } diff --git a/Framework/Crystal/test/CentroidPeaksTest.h b/Framework/Crystal/test/CentroidPeaksTest.h index 652a34cf58395e05473c93aeaf5ec39f8c75e733..6c5c98e99a84d3fb85929fc84ef407e109041b24 100644 --- a/Framework/Crystal/test/CentroidPeaksTest.h +++ b/Framework/Crystal/test/CentroidPeaksTest.h @@ -84,7 +84,7 @@ public: DateAndTime run_start("2010-01-01T00:00:00"); for (int pix = 0; pix < numPixels; pix++) { - EventList &el = retVal->getEventList(pix); + auto &el = retVal->getSpectrum(pix); el.setSpectrumNo(pix); el.setDetectorID(pix); // Background @@ -142,16 +142,6 @@ public: EventWorkspace_sptr in_ws = boost::dynamic_pointer_cast<EventWorkspace>(inputW); inputW->getAxis(0)->setUnit("TOF"); - /*if (type == WEIGHTED) - in_ws *= 2.0; - if (type == WEIGHTED_NOTIME) - { - for (size_t i =0; i<in_ws->getNumberHistograms(); i++) - { - EventList & el = in_ws->getEventList(i); - el.compressEvents(0.0, &el); - } - }*/ // Register the workspace in the data service // Create the peaks workspace diff --git a/Framework/Crystal/test/MaskPeaksWorkspaceTest.h b/Framework/Crystal/test/MaskPeaksWorkspaceTest.h index 53e8d768e2b55a716feb9bdd35f2e3346332a7a4..1ecb9896aa33cd82949d0669a7865ffb3b9fcc76 100644 --- a/Framework/Crystal/test/MaskPeaksWorkspaceTest.h +++ b/Framework/Crystal/test/MaskPeaksWorkspaceTest.h @@ -36,7 +36,7 @@ public: inputW *= 2.0; if (type == WEIGHTED_NOTIME) { for (size_t i = 0; i < inputW->getNumberHistograms(); i++) { - EventList &el = inputW->getEventList(i); + EventList &el = inputW->getSpectrum(i); el.compressEvents(0.0, &el); } } @@ -94,7 +94,7 @@ public: } if (type == WEIGHTED_NOTIME) { for (size_t i = 0; i < inputW->getNumberHistograms(); i++) { - EventList &el = inputW->getEventList(i); + EventList &el = inputW->getSpectrum(i); el.compressEvents(0.0, &el); } } diff --git a/Framework/Crystal/test/NormaliseVanadiumTest.h b/Framework/Crystal/test/NormaliseVanadiumTest.h index b6b439ea69cada1240ac9bbc13ae02f5e9acaa60..ad497728989f8c800e3a86159a0d7ecbdc524659 100644 --- a/Framework/Crystal/test/NormaliseVanadiumTest.h +++ b/Framework/Crystal/test/NormaliseVanadiumTest.h @@ -87,7 +87,7 @@ public: DateAndTime run_start("2010-01-01T00:00:00"); for (int pix = 0; pix < numPixels; pix++) { - EventList &el = retVal->getEventList(pix); + EventList &el = retVal->getSpectrum(pix); el.setSpectrumNo(pix); el.addDetectorID(pix); // Background diff --git a/Framework/Crystal/test/PeakIntegrationTest.h b/Framework/Crystal/test/PeakIntegrationTest.h index 08cbc9d2a575ec313c748e57c2c4a7a2d9687274..81790f1adcc1384b35950571e2fa9e782e2d59f0 100644 --- a/Framework/Crystal/test/PeakIntegrationTest.h +++ b/Framework/Crystal/test/PeakIntegrationTest.h @@ -87,7 +87,7 @@ public: DateAndTime run_start("2010-01-01T00:00:00"); for (int pix = 0; pix < numPixels; pix++) { - EventList &el = retVal->getEventList(pix); + EventList &el = retVal->getSpectrum(pix); el.setSpectrumNo(pix); el.setDetectorID(pix); // Background @@ -151,7 +151,7 @@ public: { for (size_t i =0; i<in_ws->getNumberHistograms(); i++) { - EventList & el = in_ws->getEventList(i); + EventList & el = in_ws->getSpectrum(i); el.compressEvents(0.0, &el); } }*/ diff --git a/Framework/CurveFitting/src/Algorithms/NormaliseByPeakArea.cpp b/Framework/CurveFitting/src/Algorithms/NormaliseByPeakArea.cpp index 8d2e6d9d5351b62c5b6362593a258ba47b099621..8f1846e602b80447ab8bb7ecadcee599dac3556f 100644 --- a/Framework/CurveFitting/src/Algorithms/NormaliseByPeakArea.cpp +++ b/Framework/CurveFitting/src/Algorithms/NormaliseByPeakArea.cpp @@ -258,7 +258,7 @@ double NormaliseByPeakArea::fitToMassPeak(const MatrixWorkspace_sptr &yspace, func->setParameter("Intensity", areaGuess); if (g_log.is(Logger::Priority::PRIO_DEBUG)) { g_log.debug() << "Starting values for peak fit on spectrum " - << yspace->getSpectrum(index)->getSpectrumNo() << ":\n" + << yspace->getSpectrum(index).getSpectrumNo() << ":\n" << "area=" << areaGuess << "\n" << "width=" << PEAK_WIDTH_GUESS << "\n" << "position=" << PEAK_POS_GUESS << "\n"; @@ -276,7 +276,7 @@ double NormaliseByPeakArea::fitToMassPeak(const MatrixWorkspace_sptr &yspace, double area = func->getParameter("Intensity"); if (g_log.is(Logger::Priority::PRIO_INFORMATION)) { g_log.information() << "Calculated peak area for spectrum " - << yspace->getSpectrum(index)->getSpectrumNo() << ": " + << yspace->getSpectrum(index).getSpectrumNo() << ": " << area << "\n"; } return area; diff --git a/Framework/CurveFitting/src/Algorithms/SplineBackground.cpp b/Framework/CurveFitting/src/Algorithms/SplineBackground.cpp index 50dd6d71033dd3f431e4cb0b8aa64248164c6004..3c99e0952182890db54fb22bac29218e6868e771 100644 --- a/Framework/CurveFitting/src/Algorithms/SplineBackground.cpp +++ b/Framework/CurveFitting/src/Algorithms/SplineBackground.cpp @@ -149,7 +149,7 @@ void SplineBackground::exec() { WorkspaceFactory::Instance().create(inWS, 1, X.size(), Y.size()); { outWS->getSpectrum(0) - ->setSpectrumNo(inWS->getSpectrum(spec)->getSpectrumNo()); + .setSpectrumNo(inWS->getSpectrum(spec).getSpectrumNo()); double yi, yerr; for (MantidVec::size_type i = 0; i < Y.size(); i++) { double xi = X[i]; diff --git a/Framework/CurveFitting/src/Algorithms/VesuvioCalculateGammaBackground.cpp b/Framework/CurveFitting/src/Algorithms/VesuvioCalculateGammaBackground.cpp index 65f5f1b82d5d8deb871e582051ee7089c5b13de6..aaa6c46a56fc6b89d467e5b56fe2aa4485a2a8b8 100644 --- a/Framework/CurveFitting/src/Algorithms/VesuvioCalculateGammaBackground.cpp +++ b/Framework/CurveFitting/src/Algorithms/VesuvioCalculateGammaBackground.cpp @@ -154,10 +154,10 @@ bool VesuvioCalculateGammaBackground::calculateBackground( m_correctedWS->dataE(outputIndex) = m_inputWS->readE(inputIndex); try { - const auto *inSpec = m_inputWS->getSpectrum(inputIndex); - const specnum_t spectrumNo(inSpec->getSpectrumNo()); - m_backgroundWS->getSpectrum(outputIndex)->copyInfoFrom(*inSpec); - m_correctedWS->getSpectrum(outputIndex)->copyInfoFrom(*inSpec); + const auto &inSpec = m_inputWS->getSpectrum(inputIndex); + const specnum_t spectrumNo(inSpec.getSpectrumNo()); + m_backgroundWS->getSpectrum(outputIndex).copyInfoFrom(inSpec); + m_correctedWS->getSpectrum(outputIndex).copyInfoFrom(inSpec); if (spectrumNo >= FORWARD_SCATTER_SPECMIN && spectrumNo <= FORWARD_SCATTER_SPECMAX) { @@ -288,7 +288,7 @@ void VesuvioCalculateGammaBackground::calculateBackgroundFromFoils( ctfoil.begin(), std::minus<double>()); } bool reversed = (m_reversed.count(m_inputWS->getSpectrum(inputIndex) - ->getSpectrumNo()) != 0); + .getSpectrumNo()) != 0); // This is quicker than the if within the loop if (reversed) { // The reversed ones should be (C0 - C1) diff --git a/Framework/CurveFitting/src/Algorithms/VesuvioCalculateMS.cpp b/Framework/CurveFitting/src/Algorithms/VesuvioCalculateMS.cpp index 3b62bea10d566f3e540630e40c255bfa8aa57442..c79b4dbcf04159969a998483422df2a988c17bd8 100644 --- a/Framework/CurveFitting/src/Algorithms/VesuvioCalculateMS.cpp +++ b/Framework/CurveFitting/src/Algorithms/VesuvioCalculateMS.cpp @@ -175,7 +175,7 @@ void VesuvioCalculateMS::exec() { // the output spectrum objects have references to where the data will be // stored - calculateMS(i, *totalsc->getSpectrum(i), *multsc->getSpectrum(i)); + calculateMS(i, totalsc->getSpectrum(i), multsc->getSpectrum(i)); } setProperty("TotalScatteringWS", totalsc); diff --git a/Framework/CurveFitting/test/Algorithms/EstimatePeakErrorsTest.h b/Framework/CurveFitting/test/Algorithms/EstimatePeakErrorsTest.h index 984e41edca2d3ecd5474a3ea962087d2ad9e9481..feb8651afaffce278e4f4ca6822da515b3fc8438 100644 --- a/Framework/CurveFitting/test/Algorithms/EstimatePeakErrorsTest.h +++ b/Framework/CurveFitting/test/Algorithms/EstimatePeakErrorsTest.h @@ -284,7 +284,7 @@ private: fun.function(x, y); ws->setX(0, x.toVector()); - ws->getSpectrum(0)->setData(y.toVector(), e); + ws->getSpectrum(0).setData(y.toVector(), e); assert(n == noise.size()); for (size_t i = 0; i < n; ++i) { ws->dataY(0)[i] += noiseLevel * noise[i]; diff --git a/Framework/CurveFitting/test/Algorithms/PlotPeakByLogValueTest.h b/Framework/CurveFitting/test/Algorithms/PlotPeakByLogValueTest.h index fbee7f47126041f58261986e7fc38cabdfbfbfd8..a75ec67609fe79e4a4d35aa7cdf2803034811cc4 100644 --- a/Framework/CurveFitting/test/Algorithms/PlotPeakByLogValueTest.h +++ b/Framework/CurveFitting/test/Algorithms/PlotPeakByLogValueTest.h @@ -562,7 +562,7 @@ private: auto ws = WorkspaceCreationHelper::Create2DWorkspaceFromFunction( PlotPeak_Expression(iWS), 3, 0, 10, 0.005); for (int i = 0; i < 3; ++i) { - ws->getSpectrum(i)->setSpectrumNo(0); + ws->getSpectrum(i).setSpectrumNo(0); } Kernel::TimeSeriesProperty<double> *logd = new Kernel::TimeSeriesProperty<double>("var"); diff --git a/Framework/CurveFitting/test/Algorithms/VesuvioCalculateGammaBackgroundTest.h b/Framework/CurveFitting/test/Algorithms/VesuvioCalculateGammaBackgroundTest.h index 03022d6892f0de2c2e38ae0c42dc276d0304c144..1559c851fa9a657ec5113d814142ee4bedce0716 100644 --- a/Framework/CurveFitting/test/Algorithms/VesuvioCalculateGammaBackgroundTest.h +++ b/Framework/CurveFitting/test/Algorithms/VesuvioCalculateGammaBackgroundTest.h @@ -26,7 +26,7 @@ public: using namespace Mantid::API; auto inputWS = createTestWorkspaceWithFoilChanger(); // specNo=1 // Put spectrum in forward scatter range - inputWS->getSpectrum(0)->setSpectrumNo(135); + inputWS->getSpectrum(0).setSpectrumNo(135); auto alg = runSuccessTestCase(inputWS); MatrixWorkspace_sptr backgroundWS = alg->getProperty("BackgroundWorkspace"); @@ -116,10 +116,10 @@ public: void test_Restricting_Correction_Range_Only_Gives_Output_For_Those_Spectra() { using namespace Mantid::API; auto inputWS = createTwoSpectrumWorkspaceWithFoilChanger(); - inputWS->getSpectrum(0)->setSpectrumNo(135); - inputWS->getSpectrum(1)->setSpectrumNo(135); - inputWS->getSpectrum(1)->clearDetectorIDs(); - inputWS->getSpectrum(1)->addDetectorID(1); + inputWS->getSpectrum(0).setSpectrumNo(135); + inputWS->getSpectrum(1).setSpectrumNo(135); + inputWS->getSpectrum(1).clearDetectorIDs(); + inputWS->getSpectrum(1).addDetectorID(1); auto alg = runSuccessTestCase(inputWS, "1"); MatrixWorkspace_sptr backgroundWS = alg->getProperty("BackgroundWorkspace"); diff --git a/Framework/CurveFitting/test/Algorithms/VesuvioCalculateMSTest.h b/Framework/CurveFitting/test/Algorithms/VesuvioCalculateMSTest.h index 3a5e10e74eadd1250021ba621031f403c6ede112..f64550c740a443b89f328cadb50eb31c5b10c0fc 100644 --- a/Framework/CurveFitting/test/Algorithms/VesuvioCalculateMSTest.h +++ b/Framework/CurveFitting/test/Algorithms/VesuvioCalculateMSTest.h @@ -217,7 +217,7 @@ private: instrument->markAsDetector(det2); // Group the detectors - ws2d->getSpectrum(0)->addDetectorID(2); + ws2d->getSpectrum(0).addDetectorID(2); } ws2d->setInstrument(instrument); diff --git a/Framework/CurveFitting/test/FitMWTest.h b/Framework/CurveFitting/test/FitMWTest.h index 0af78ea29e54304355a7b39fc9daf081a3488a9a..6b01bba13168c50577a18db00621dfd1fd140bae 100644 --- a/Framework/CurveFitting/test/FitMWTest.h +++ b/Framework/CurveFitting/test/FitMWTest.h @@ -618,7 +618,7 @@ public: API::MatrixWorkspace_sptr ws = createTestWorkspace(false); ws->setInstrument(instrument); - ws->getSpectrum(0)->setDetectorID(det->getID()); + ws->getSpectrum(0).setDetectorID(det->getID()); auto &pmap = ws->instrumentParameters(); diff --git a/Framework/CurveFitting/test/Functions/ComptonProfileTestHelpers.h b/Framework/CurveFitting/test/Functions/ComptonProfileTestHelpers.h index 1260001b866d3448216e0a456b8352e92de17413..35385f787049f61aa2c3a2c6c6b9ff6649e06cf6 100644 --- a/Framework/CurveFitting/test/Functions/ComptonProfileTestHelpers.h +++ b/Framework/CurveFitting/test/Functions/ComptonProfileTestHelpers.h @@ -87,10 +87,10 @@ createTestWorkspace(const size_t nhist, const double x0, const double x1, // Link workspace with detector for (size_t i = 0; i < nhist; ++i) { const Mantid::specnum_t specID = static_cast<Mantid::specnum_t>(id + i); - auto *spec = ws2d->getSpectrum(i); - spec->setSpectrumNo(specID); - spec->clearDetectorIDs(); - spec->addDetectorID(id); + auto &spec = ws2d->getSpectrum(i); + spec.setSpectrumNo(specID); + spec.clearDetectorIDs(); + spec.addDetectorID(id); } return ws2d; } diff --git a/Framework/CurveFitting/test/Functions/DiffRotDiscreteCircleTest.h b/Framework/CurveFitting/test/Functions/DiffRotDiscreteCircleTest.h index 87e190cc05f2f703f4d582c2a02068def2dc80ad..c667c12d27acf784194a5e24758e921897973ae5 100644 --- a/Framework/CurveFitting/test/Functions/DiffRotDiscreteCircleTest.h +++ b/Framework/CurveFitting/test/Functions/DiffRotDiscreteCircleTest.h @@ -579,7 +579,7 @@ private: // Set the instrument and spec-det mapping ws->setInstrument(inst); - ws->getSpectrum(0)->addDetectorID(det->getID()); + ws->getSpectrum(0).addDetectorID(det->getID()); // Set emergy mode and fixed energy ws->mutableRun().addLogData( diff --git a/Framework/CurveFitting/test/Functions/DiffSphereTest.h b/Framework/CurveFitting/test/Functions/DiffSphereTest.h index 7e27562ed3404a05c5c2d4b979daf594e0c32e38..1023e8c8a0701625648d60ba5b9c16f257d6715e 100644 --- a/Framework/CurveFitting/test/Functions/DiffSphereTest.h +++ b/Framework/CurveFitting/test/Functions/DiffSphereTest.h @@ -513,7 +513,7 @@ private: // Set the instrument and spec-det mapping ws->setInstrument(inst); - ws->getSpectrum(0)->addDetectorID(det->getID()); + ws->getSpectrum(0).addDetectorID(det->getID()); // Set emergy mode and fixed energy ws->mutableRun().addLogData( diff --git a/Framework/DataHandling/inc/MantidDataHandling/EventWorkspaceCollection.h b/Framework/DataHandling/inc/MantidDataHandling/EventWorkspaceCollection.h index 702d71f1cf10ec56efa1ff24d07e4b84c7d05f31..6bebeac4bdc8669fc3f28998ad1afc2ce05a8064 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/EventWorkspaceCollection.h +++ b/Framework/DataHandling/inc/MantidDataHandling/EventWorkspaceCollection.h @@ -64,10 +64,10 @@ public: size_t nPeriods() const; DataObjects::EventWorkspace_sptr getSingleHeldWorkspace(); API::Workspace_sptr combinedWorkspace(); - const DataObjects::EventList &getEventList(const size_t workspace_index, - const size_t periodNumber) const; - DataObjects::EventList &getEventList(const size_t workspace_index, - const size_t periodNumber); + const DataObjects::EventList &getSpectrum(const size_t workspace_index, + const size_t periodNumber) const; + DataObjects::EventList &getSpectrum(const size_t workspace_index, + const size_t periodNumber); void setGeometryFlag(const int flag); void setThickness(const float flag); void setHeight(const float flag); @@ -82,14 +82,10 @@ public: const API::Run &run() const; API::Run &mutableRun(); API::Sample &mutableSample(); - Mantid::API::ISpectrum *getSpectrum(const size_t index); - const Mantid::API::ISpectrum *getSpectrum(const size_t index) const; + DataObjects::EventList &getSpectrum(const size_t index); + const DataObjects::EventList &getSpectrum(const size_t index) const; Mantid::API::Axis *getAxis(const size_t &i) const; size_t getNumberHistograms() const; - const DataObjects::EventList & - getEventList(const size_t workspace_index) const; - - DataObjects::EventList &getEventList(const std::size_t workspace_index); std::vector<size_t> getSpectrumToWorkspaceIndexVector(Mantid::specnum_t &offset) const; @@ -106,7 +102,6 @@ public: void setMonitorWorkspace(const boost::shared_ptr<API::MatrixWorkspace> &monitorWS); void updateSpectraUsing(const API::SpectrumDetectorMapping &map); - DataObjects::EventList *getEventListPtr(size_t i); void populateInstrumentParameters(); void setTitle(std::string title); void applyFilter(boost::function<void(API::MatrixWorkspace_sptr)> func); diff --git a/Framework/DataHandling/inc/MantidDataHandling/GroupDetectors2.h b/Framework/DataHandling/inc/MantidDataHandling/GroupDetectors2.h index 5869e7f1ebeb5555203d67f90accdd74afebcc72..3e0f2300d7a85ea8590017e653d71b8ce4d0fbd7 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/GroupDetectors2.h +++ b/Framework/DataHandling/inc/MantidDataHandling/GroupDetectors2.h @@ -220,17 +220,10 @@ private: DataObjects::EventWorkspace_sptr outputWS, const double prog4Copy); - /// Copy the data data in ungrouped histograms from the input workspace to the - /// output - void moveOthers(const std::set<int64_t> &unGroupedSet, - API::MatrixWorkspace_const_sptr inputWS, - API::MatrixWorkspace_sptr outputWS, size_t outIndex); - /// Copy the data data in ungrouped event lists from the input workspace to - /// the output - void moveOthersEvent(const std::set<int64_t> &unGroupedSet, - DataObjects::EventWorkspace_const_sptr inputWS, - DataObjects::EventWorkspace_sptr outputWS, - size_t outIndex); + /// Copy the ungrouped spectra from the input workspace to the output + template <class TIn, class TOut> + void moveOthers(const std::set<int64_t> &unGroupedSet, const TIn &inputWS, + TOut &outputWS, size_t outIndex); /// flag values enum { @@ -260,6 +253,49 @@ private: /// the progress bar }; +/** +* Only to be used if the KeepUnGrouped property is true, moves the spectra that +* were not selected +* to be in a group to the end of the output spectrum +* @param unGroupedSet :: list of WORKSPACE indexes that were included in a +* group +* @param inputWS :: user selected input workspace for the algorithm +* @param outputWS :: user selected output workspace for the algorithm +* @param outIndex :: the next spectra index available after the grouped spectra +*/ +template <class TIn, class TOut> +void GroupDetectors2::moveOthers(const std::set<int64_t> &unGroupedSet, + const TIn &inputWS, TOut &outputWS, + size_t outIndex) { + g_log.debug() << "Starting to copy the ungrouped spectra\n"; + double prog4Copy = (1. - 1. * static_cast<double>(m_FracCompl)) / + static_cast<double>(unGroupedSet.size()); + + // go thorugh all the spectra in the input workspace + for (auto copyFrIt : unGroupedSet) { + if (copyFrIt == USED) + continue; // Marked as not to be used + size_t sourceIndex = static_cast<size_t>(copyFrIt); + + outputWS.getSpectrum(outIndex) = inputWS.getSpectrum(sourceIndex); + + // go to the next free index in the output workspace + outIndex++; + // make regular progress reports and check for cancelling the algorithm + if (outIndex % INTERVAL == 0) { + m_FracCompl += INTERVAL * prog4Copy; + if (m_FracCompl > 1.0) { + m_FracCompl = 1.0; + } + progress(m_FracCompl); + interruption_point(); + } + } + + g_log.debug() << name() << " copied " << unGroupedSet.size() - 1 + << " ungrouped spectra\n"; +} + } // namespace DataHandling } // namespace Mantid diff --git a/Framework/DataHandling/src/CompressEvents.cpp b/Framework/DataHandling/src/CompressEvents.cpp index 0c2f87527d0519c86adce3909caa3b0b71b55c24..7ee2ef71f1bc2c66a61a4de9e5e5da4dde7fbd5b 100644 --- a/Framework/DataHandling/src/CompressEvents.cpp +++ b/Framework/DataHandling/src/CompressEvents.cpp @@ -83,7 +83,7 @@ void CompressEvents::exec() { // Linux. Using this signed type suppresses warnings below const size_t index = static_cast<size_t>(i); // The input event list - EventList &input_el = inputWS->getEventList(index); + EventList &input_el = inputWS->getSpectrum(index); // And on the output side EventList &output_el = outputWS->getOrAddEventList(index); // Copy other settings into output @@ -106,11 +106,9 @@ void CompressEvents::exec() { for (int64_t i = 0; i < noSpectra; ++i) { PARALLEL_START_INTERUPT_REGION // The input (also output) event list - EventList *output_el = outputWS->getEventListPtr(static_cast<size_t>(i)); - if (output_el) { - // The EventList method does the work. - output_el->compressEvents(tolerance, output_el); - } + auto &output_el = outputWS->getSpectrum(static_cast<size_t>(i)); + // The EventList method does the work. + output_el.compressEvents(tolerance, &output_el); prog.report("Compressing"); PARALLEL_END_INTERUPT_REGION } diff --git a/Framework/DataHandling/src/CreateSimulationWorkspace.cpp b/Framework/DataHandling/src/CreateSimulationWorkspace.cpp index 680c6e7695cf5521dc09b1603deeace847dc019f..40b716dacb64001c620b8f02e325140a4214d493 100644 --- a/Framework/DataHandling/src/CreateSimulationWorkspace.cpp +++ b/Framework/DataHandling/src/CreateSimulationWorkspace.cpp @@ -355,11 +355,11 @@ MantidVecPtr CreateSimulationWorkspace::createBinBoundaries() const { void CreateSimulationWorkspace::applyDetectorMapping() { size_t wsIndex(0); for (auto &detGroup : m_detGroups) { - ISpectrum *spectrum = m_outputWS->getSpectrum(wsIndex); - spectrum->setSpectrumNo( + auto &spectrum = m_outputWS->getSpectrum(wsIndex); + spectrum.setSpectrumNo( static_cast<specnum_t>(wsIndex + 1)); // Ensure a contiguous mapping - spectrum->clearDetectorIDs(); - spectrum->addDetectorIDs(detGroup.second); + spectrum.clearDetectorIDs(); + spectrum.addDetectorIDs(detGroup.second); ++wsIndex; } } diff --git a/Framework/DataHandling/src/EventWorkspaceCollection.cpp b/Framework/DataHandling/src/EventWorkspaceCollection.cpp index 7da0d0915c6d9986f6cc9dbee06f822509f5535e..228f99822841dce09e2413b231b32dc64138f884 100644 --- a/Framework/DataHandling/src/EventWorkspaceCollection.cpp +++ b/Framework/DataHandling/src/EventWorkspaceCollection.cpp @@ -108,7 +108,7 @@ void EventWorkspaceCollection::setNPeriods( void EventWorkspaceCollection::reserveEventListAt(size_t wi, size_t size) { for (auto &ws : m_WsVec) { - ws->getEventList(wi).reserve(size); + ws->getSpectrum(wi).reserve(size); } } @@ -146,11 +146,10 @@ API::Run &EventWorkspaceCollection::mutableRun() { API::Sample &EventWorkspaceCollection::mutableSample() { return m_WsVec[0]->mutableSample(); } -Mantid::API::ISpectrum * -EventWorkspaceCollection::getSpectrum(const size_t index) { +EventList &EventWorkspaceCollection::getSpectrum(const size_t index) { return m_WsVec[0]->getSpectrum(index); } -const Mantid::API::ISpectrum * +const EventList & EventWorkspaceCollection::getSpectrum(const size_t index) const { return m_WsVec[0]->getSpectrum(index); } @@ -160,7 +159,7 @@ void EventWorkspaceCollection::setSpectrumNumbersFromUniqueSpectra( for (auto &ws : m_WsVec) { size_t counter = 0; for (auto spectrum : uniqueSpectra) { - ws->getSpectrum(counter)->setSpectrumNo(spectrum); + ws->getSpectrum(counter).setSpectrumNo(spectrum); ++counter; } } @@ -169,16 +168,16 @@ void EventWorkspaceCollection::setSpectrumNumbersFromUniqueSpectra( void EventWorkspaceCollection::setSpectrumNumberForAllPeriods( const size_t spectrumNumber, const specnum_t specid) { for (auto &ws : m_WsVec) { - auto spec = ws->getSpectrum(spectrumNumber); - spec->setSpectrumNo(specid); + auto &spec = ws->getSpectrum(spectrumNumber); + spec.setSpectrumNo(specid); } } void EventWorkspaceCollection::setDetectorIdsForAllPeriods( const size_t spectrumNumber, const detid_t id) { for (auto &ws : m_WsVec) { - auto spec = ws->getSpectrum(spectrumNumber); - spec->setDetectorID(id); + auto &spec = ws->getSpectrum(spectrumNumber); + spec.setDetectorID(id); } } @@ -188,28 +187,17 @@ Mantid::API::Axis *EventWorkspaceCollection::getAxis(const size_t &i) const { size_t EventWorkspaceCollection::getNumberHistograms() const { return m_WsVec[0]->getNumberHistograms(); } -const DataObjects::EventList & -EventWorkspaceCollection::getEventList(const size_t workspace_index) const { - return m_WsVec[0]->getEventList( - workspace_index); // TODO need to know PERIOD number TOO -} const DataObjects::EventList & -EventWorkspaceCollection::getEventList(const size_t workspace_index, - const size_t periodNumber) const { - return m_WsVec[periodNumber]->getEventList(workspace_index); +EventWorkspaceCollection::getSpectrum(const size_t workspace_index, + const size_t periodNumber) const { + return m_WsVec[periodNumber]->getSpectrum(workspace_index); } DataObjects::EventList & -EventWorkspaceCollection::getEventList(const size_t workspace_index, - const size_t periodNumber) { - return m_WsVec[periodNumber]->getEventList(workspace_index); -} - -DataObjects::EventList & -EventWorkspaceCollection::getEventList(const std::size_t workspace_index) { - return m_WsVec[0]->getEventList( - workspace_index); // TODO need to know PERIOD number TOO +EventWorkspaceCollection::getSpectrum(const size_t workspace_index, + const size_t periodNumber) { + return m_WsVec[periodNumber]->getSpectrum(workspace_index); } std::vector<size_t> EventWorkspaceCollection::getSpectrumToWorkspaceIndexVector( @@ -263,11 +251,6 @@ void EventWorkspaceCollection::updateSpectraUsing( } } -DataObjects::EventList *EventWorkspaceCollection::getEventListPtr(size_t i) { - return m_WsVec[0]->getEventListPtr( - i); // TODO, just take from the first workspace -} - void EventWorkspaceCollection::populateInstrumentParameters() { for (auto &ws : m_WsVec) { ws->populateInstrumentParameters(); diff --git a/Framework/DataHandling/src/FilterEventsByLogValuePreNexus.cpp b/Framework/DataHandling/src/FilterEventsByLogValuePreNexus.cpp index 182d5aa7773ded34ae6350468d2431cb513ce5b0..c578e914b8f9963e7923a3644f1c5fbd790a1abb 100644 --- a/Framework/DataHandling/src/FilterEventsByLogValuePreNexus.cpp +++ b/Framework/DataHandling/src/FilterEventsByLogValuePreNexus.cpp @@ -401,8 +401,8 @@ void FilterEventsByLogValuePreNexus::exec() { PARALLEL_FOR_NO_WSP_CHECK() for (int64_t i = 0; i < numberOfSpectra; i++) { PARALLEL_START_INTERUPT_REGION - m_localWorkspace->getEventListPtr(i) - ->setSortOrder(DataObjects::PULSETIME_SORT); + m_localWorkspace->getSpectrum(i) + .setSortOrder(DataObjects::PULSETIME_SORT); PARALLEL_END_INTERUPT_REGION } PARALLEL_CHECK_INTERUPT_REGION @@ -949,7 +949,7 @@ void FilterEventsByLogValuePreNexus::procEvents( for (detid_t j = 0; j < m_detid_max + 1; j++) { size_t wi = m_pixelToWkspindex[j]; // Save a POINTER to the vector<tofEvent> - theseEventVectors[j] = &partWS->getEventList(wi).getEvents(); + theseEventVectors[j] = &partWS->getSpectrum(wi).getEvents(); } } // END FOR [Threads] @@ -1021,19 +1021,19 @@ void FilterEventsByLogValuePreNexus::procEvents( size_t wi = size_t(iwi); // The output event list. - EventList &el = workspace->getEventList(wi); + EventList &el = workspace->getSpectrum(wi); el.clear(false); // How many events will it have? size_t numEvents = 0; for (size_t i = 0; i < numThreads; i++) - numEvents += partWorkspaces[i]->getEventList(wi).getNumberEvents(); + numEvents += partWorkspaces[i]->getSpectrum(wi).getNumberEvents(); // This will avoid too much copying. el.reserve(numEvents); // Now merge the event lists for (size_t i = 0; i < numThreads; i++) { - EventList &partEl = partWorkspaces[i]->getEventList(wi); + EventList &partEl = partWorkspaces[i]->getSpectrum(wi); el += partEl.getEvents(); // Free up memory as you go along. partEl.clear(false); @@ -1266,11 +1266,11 @@ void FilterEventsByLogValuePreNexus::procEventsLinear( // The addEventQuickly method does not clear the cache, making things slightly // faster. -// workspace->getEventList(this->m_pixelToWkspindex[pid]).addEventQuickly(event); +// workspace->getSpectrum(this->m_pixelToWkspindex[pid]).addEventQuickly(event); // - Add event to data structure // (This is equivalent to -// workspace->getEventList(this->m_pixelToWkspindex[pid]).addEventQuickly(event)) +// workspace->getSpectrum(this->m_pixelToWkspindex[pid]).addEventQuickly(event)) // (But should be faster as a bunch of these calls were cached.) #if defined(__GNUC__) && !(defined(__INTEL_COMPILER)) && !(defined(__clang__)) // This avoids a copy constructor call but is only available with GCC @@ -1578,7 +1578,7 @@ void FilterEventsByLogValuePreNexus::filterEvents() { for (detid_t j = 0; j < m_detid_max + 1; j++) { size_t wi = m_pixelToWkspindex[j]; // Save a POINTER to the vector<tofEvent> - theseEventVectors[j] = &partWS->getEventList(wi).getEvents(); + theseEventVectors[j] = &partWS->getSpectrum(wi).getEvents(); } } // END FOR [Threads] @@ -1651,19 +1651,19 @@ void FilterEventsByLogValuePreNexus::filterEvents() { size_t wi = size_t(iwi); // The output event list. - EventList &el = m_localWorkspace->getEventList(wi); + EventList &el = m_localWorkspace->getSpectrum(wi); el.clear(false); // How many events will it have? size_t numEvents = 0; for (size_t i = 0; i < numThreads; i++) - numEvents += partWorkspaces[i]->getEventList(wi).getNumberEvents(); + numEvents += partWorkspaces[i]->getSpectrum(wi).getNumberEvents(); // This will avoid too much copying. el.reserve(numEvents); // Now merge the event lists for (size_t i = 0; i < numThreads; i++) { - EventList &partEl = partWorkspaces[i]->getEventList(wi); + EventList &partEl = partWorkspaces[i]->getSpectrum(wi); el += partEl.getEvents(); // Free up memory as you go along. partEl.clear(false); @@ -2035,7 +2035,7 @@ void FilterEventsByLogValuePreNexus::filterEventsLinear( // Add event to vector of events // (This is equivalent to -// workspace->getEventList(this->m_pixelToWkspindex[pid]).addEventQuickly(event)) +// workspace->getSpectrum(this->m_pixelToWkspindex[pid]).addEventQuickly(event)) // (But should be faster as a bunch of these calls were cached.) #if defined(__GNUC__) && !(defined(__INTEL_COMPILER)) && !(defined(__clang__)) // This avoids a copy constructor call but is only available with GCC diff --git a/Framework/DataHandling/src/GroupDetectors.cpp b/Framework/DataHandling/src/GroupDetectors.cpp index 3aa85519fd8a92f458335c05a0b34f2867e7e781..17df881206a1642b9f6f557981d70a9c1882d79d 100644 --- a/Framework/DataHandling/src/GroupDetectors.cpp +++ b/Framework/DataHandling/src/GroupDetectors.cpp @@ -91,7 +91,7 @@ void GroupDetectors::exec() { const size_t vectorSize = WS->blocksize(); const specnum_t firstIndex = static_cast<specnum_t>(indexList[0]); - ISpectrum *firstSpectrum = WS->getSpectrum(firstIndex); + auto &firstSpectrum = WS->getSpectrum(firstIndex); MantidVec &firstY = WS->dataY(firstIndex); setProperty("ResultIndex", firstIndex); @@ -101,15 +101,15 @@ void GroupDetectors::exec() { for (size_t i = 0; i < indexList.size() - 1; ++i) { // The current spectrum const size_t currentIndex = indexList[i + 1]; - ISpectrum *spec = WS->getSpectrum(currentIndex); + auto &spec = WS->getSpectrum(currentIndex); // Add the current detector to belong to the first spectrum - firstSpectrum->addDetectorIDs(spec->getDetectorIDs()); + firstSpectrum.addDetectorIDs(spec.getDetectorIDs()); // Add up all the Y spectra and store the result in the first one - auto fEit = firstSpectrum->dataE().begin(); - auto Yit = spec->dataY().begin(); - auto Eit = spec->dataE().begin(); + auto fEit = firstSpectrum.dataE().begin(); + auto Yit = spec.dataY().begin(); + auto Eit = spec.dataE().begin(); for (auto fYit = firstY.begin(); fYit != firstY.end(); ++fYit, ++fEit, ++Yit, ++Eit) { *fYit += *Yit; @@ -119,10 +119,10 @@ void GroupDetectors::exec() { // Now zero the now redundant spectrum and set its spectraNo to indicate // this (using -1) - spec->dataY().assign(vectorSize, 0.0); - spec->dataE().assign(vectorSize, 0.0); - spec->setSpectrumNo(-1); - spec->clearDetectorIDs(); + spec.dataY().assign(vectorSize, 0.0); + spec.dataE().assign(vectorSize, 0.0); + spec.setSpectrumNo(-1); + spec.clearDetectorIDs(); progress.report(); } } diff --git a/Framework/DataHandling/src/GroupDetectors2.cpp b/Framework/DataHandling/src/GroupDetectors2.cpp index d1461b98c8a971a97dc0cab2cbcf9e627a315cb7..90793c665892e43343123f39d2a9a1744f028044 100644 --- a/Framework/DataHandling/src/GroupDetectors2.cpp +++ b/Framework/DataHandling/src/GroupDetectors2.cpp @@ -147,9 +147,15 @@ void GroupDetectors2::exec() { // doesn't want them const size_t numUnGrouped = keepAll ? unGroupedSet.size() - 1 : 0; - MatrixWorkspace_sptr outputWS = WorkspaceFactory::Instance().create( - inputWS, m_GroupWsInds.size() + numUnGrouped, inputWS->readX(0).size(), - inputWS->blocksize()); + auto outputWS = boost::dynamic_pointer_cast<Workspace2D>( + WorkspaceFactory::Instance().create( + inputWS, m_GroupWsInds.size() + numUnGrouped, + inputWS->readX(0).size(), inputWS->blocksize())); + // The cast might fail if the input is a WorkspaceSingleValue. That does not + // seem to make sense for this algorithm, so we throw. + if (!outputWS) + throw std::invalid_argument( + "Input workspace must be an EventWorkspace or Workspace2D"); // prepare to move the requested histograms into groups, first estimate how // long for progress reporting. +1 in the demonator gets rid of any divide by @@ -168,7 +174,7 @@ void GroupDetectors2::exec() { // If we're keeping ungrouped spectra if (keepAll) { // copy them into the output workspace - moveOthers(unGroupedSet, inputWS, outputWS, outIndex); + moveOthers(unGroupedSet, *inputWS, *outputWS, outIndex); } g_log.information() << name() << " algorithm has finished\n"; @@ -236,7 +242,7 @@ void GroupDetectors2::execEvent() { // If we're keeping ungrouped spectra if (keepAll) { // copy them into the output workspace - moveOthersEvent(unGroupedSet, inputWS, outputWS, outIndex); + moveOthers(unGroupedSet, *inputWS, *outputWS, outIndex); } // Set all X bins on the output @@ -935,32 +941,32 @@ size_t GroupDetectors2::formGroups(API::MatrixWorkspace_const_sptr inputWS, for (storage_map::const_iterator it = m_GroupWsInds.begin(); it != m_GroupWsInds.end(); ++it) { // This is the grouped spectrum - ISpectrum *outSpec = outputWS->getSpectrum(outIndex); + auto &outSpec = outputWS->getSpectrum(outIndex); // The spectrum number of the group is the key - outSpec->setSpectrumNo(it->first); + outSpec.setSpectrumNo(it->first); // Start fresh with no detector IDs - outSpec->clearDetectorIDs(); + outSpec.clearDetectorIDs(); // Copy over X data from first spectrum, the bin boundaries for all spectra // are assumed to be the same here - outSpec->dataX() = inputWS->readX(0); + outSpec.dataX() = inputWS->readX(0); // the Y values and errors from spectra being grouped are combined in the // output spectrum - MantidVec &firstY = outSpec->dataY(); + MantidVec &firstY = outSpec.dataY(); // Keep track of number of detectors required for masking size_t nonMaskedSpectra(0); beh->dataX(outIndex)[0] = 0.0; beh->dataE(outIndex)[0] = 0.0; for (auto originalWI : it->second) { // detectors to add to firstSpecNum - const ISpectrum *fromSpectrum = inputWS->getSpectrum(originalWI); + const auto &fromSpectrum = inputWS->getSpectrum(originalWI); // Add up all the Y spectra and store the result in the first one - auto fEit = outSpec->dataE().begin(); - auto Yit = fromSpectrum->dataY().cbegin(); - auto Eit = fromSpectrum->dataE().cbegin(); + auto fEit = outSpec.dataE().begin(); + auto Yit = fromSpectrum.dataY().cbegin(); + auto Eit = fromSpectrum.dataE().cbegin(); for (auto fYit = firstY.begin(); fYit != firstY.end(); ++fYit, ++fEit, ++Yit, ++Eit) { *fYit += *Yit; @@ -969,7 +975,7 @@ size_t GroupDetectors2::formGroups(API::MatrixWorkspace_const_sptr inputWS, } // detectors to add to the output spectrum - outSpec->addDetectorIDs(fromSpectrum->getDetectorIDs()); + outSpec.addDetectorIDs(fromSpectrum.getDetectorIDs()); try { Geometry::IDetector_const_sptr det = inputWS->getDetector(originalWI); if (!det->isMasked()) @@ -1045,7 +1051,7 @@ GroupDetectors2::formGroupsEvent(DataObjects::EventWorkspace_const_sptr inputWS, for (storage_map::const_iterator it = m_GroupWsInds.begin(); it != m_GroupWsInds.end(); ++it) { // This is the grouped spectrum - EventList &outEL = outputWS->getEventList(outIndex); + EventList &outEL = outputWS->getSpectrum(outIndex); // The spectrum number of the group is the key outEL.setSpectrumNo(it->first); @@ -1059,7 +1065,7 @@ GroupDetectors2::formGroupsEvent(DataObjects::EventWorkspace_const_sptr inputWS, beh->dataX(outIndex)[0] = 0.0; beh->dataE(outIndex)[0] = 0.0; for (auto originalWI : it->second) { - const EventList &fromEL = inputWS->getEventList(originalWI); + const EventList &fromEL = inputWS->getSpectrum(originalWI); // Add the event lists with the operator outEL += fromEL; @@ -1106,118 +1112,6 @@ GroupDetectors2::formGroupsEvent(DataObjects::EventWorkspace_const_sptr inputWS, return outIndex; } -/** -* Only to be used if the KeepUnGrouped property is true, moves the spectra that -* were not selected -* to be in a group to the end of the output spectrum -* @param unGroupedSet :: list of WORKSPACE indexes that were included in a -* group -* @param inputWS :: user selected input workspace for the algorithm -* @param outputWS :: user selected output workspace for the algorithm -* @param outIndex :: the next spectra index available after the grouped spectra -*/ -void GroupDetectors2::moveOthers(const std::set<int64_t> &unGroupedSet, - API::MatrixWorkspace_const_sptr inputWS, - API::MatrixWorkspace_sptr outputWS, - size_t outIndex) { - g_log.debug() << "Starting to copy the ungrouped spectra\n"; - double prog4Copy = (1. - 1. * static_cast<double>(m_FracCompl)) / - static_cast<double>(unGroupedSet.size()); - - // go thorugh all the spectra in the input workspace - for (auto copyFrIt : unGroupedSet) { - if (copyFrIt == USED) - continue; // Marked as not to be used - size_t sourceIndex = static_cast<size_t>(copyFrIt); - - // The input spectrum we'll copy - const ISpectrum *inputSpec = inputWS->getSpectrum(sourceIndex); - - // Destination of the copying - ISpectrum *outputSpec = outputWS->getSpectrum(outIndex); - - // Copy the data - outputSpec->dataX() = inputSpec->dataX(); - outputSpec->dataY() = inputSpec->dataY(); - outputSpec->dataE() = inputSpec->dataE(); - - // Spectrum numbers etc. - outputSpec->setSpectrumNo(inputSpec->getSpectrumNo()); - outputSpec->clearDetectorIDs(); - outputSpec->addDetectorIDs(inputSpec->getDetectorIDs()); - - // go to the next free index in the output workspace - outIndex++; - // make regular progress reports and check for cancelling the algorithm - if (outIndex % INTERVAL == 0) { - m_FracCompl += INTERVAL * prog4Copy; - if (m_FracCompl > 1.0) { - m_FracCompl = 1.0; - } - progress(m_FracCompl); - interruption_point(); - } - } - - g_log.debug() << name() << " copied " << unGroupedSet.size() - 1 - << " ungrouped spectra\n"; -} - -/** -* Only to be used if the KeepUnGrouped property is true, moves the spectra that -* were not selected -* to be in a group to the end of the output spectrum -* @param unGroupedSet :: list of WORKSPACE indexes that were included in a -* group -* @param inputWS :: user selected input workspace for the algorithm -* @param outputWS :: user selected output workspace for the algorithm -* @param outIndex :: the next spectra index available after the grouped spectra -*/ -void GroupDetectors2::moveOthersEvent( - const std::set<int64_t> &unGroupedSet, - DataObjects::EventWorkspace_const_sptr inputWS, - DataObjects::EventWorkspace_sptr outputWS, size_t outIndex) { - g_log.debug() << "Starting to copy the ungrouped spectra\n"; - double prog4Copy = (1. - 1. * static_cast<double>(m_FracCompl)) / - static_cast<double>(unGroupedSet.size()); - - // go thorugh all the spectra in the input workspace - for (auto copyFrIt : unGroupedSet) { - if (copyFrIt == USED) - continue; // Marked as not to be used - size_t sourceIndex = static_cast<size_t>(copyFrIt); - - // The input spectrum we'll copy - const EventList &inputSpec = inputWS->getEventList(sourceIndex); - - // Destination of the copying - EventList &outputSpec = outputWS->getEventList(outIndex); - - // Copy the data - outputSpec += inputSpec; - - // Spectrum numbers etc. - outputSpec.setSpectrumNo(inputSpec.getSpectrumNo()); - outputSpec.clearDetectorIDs(); - outputSpec.addDetectorIDs(inputSpec.getDetectorIDs()); - - // go to the next free index in the output workspace - outIndex++; - // make regular progress reports and check for cancelling the algorithm - if (outIndex % INTERVAL == 0) { - m_FracCompl += INTERVAL * prog4Copy; - if (m_FracCompl > 1.0) { - m_FracCompl = 1.0; - } - progress(m_FracCompl); - interruption_point(); - } - } - - g_log.debug() << name() << " copied " << unGroupedSet.size() - 1 - << " ungrouped spectra\n"; -} - // RangeHelper /** Expands any ranges in the input string of non-negative integers, eg. "1 3-5 * 4" -> "1 3 4 5 4" diff --git a/Framework/DataHandling/src/ImggAggregateWavelengths.cpp b/Framework/DataHandling/src/ImggAggregateWavelengths.cpp index 28d2f6676e4c8438c9223a5b3eb1d52b9a15ef2e..886dc9558e90a9789ecddb5658445d1619014b05 100644 --- a/Framework/DataHandling/src/ImggAggregateWavelengths.cpp +++ b/Framework/DataHandling/src/ImggAggregateWavelengths.cpp @@ -778,15 +778,10 @@ void ImggAggregateWavelengths::aggImage(API::MatrixWorkspace_sptr accum, } for (size_t row = 0; row < sizeY; row++) { - Mantid::API::ISpectrum *spectrum = accum->getSpectrum(row); - Mantid::API::ISpectrum *specIn = toAdd->getSpectrum(row); - auto &dataY = spectrum->dataY(); - const auto &dataYIn = specIn->readY(); + auto &dataY = accum->dataY(row); + const auto &dataYIn = toAdd->readY(row); std::transform(dataY.begin(), dataY.end(), dataYIn.cbegin(), dataY.begin(), std::plus<double>()); - // for (size_t col = 0; col < sizeX; col++) { - // dataY[col] += dataYIn[col]; - //} } } diff --git a/Framework/DataHandling/src/LoadAscii.cpp b/Framework/DataHandling/src/LoadAscii.cpp index 9ff4ba9b10e8b7029e523360d4bb181e1184ac1e..ec4949a4d484b63a20a3e9ea06d5db83319dac9a 100644 --- a/Framework/DataHandling/src/LoadAscii.cpp +++ b/Framework/DataHandling/src/LoadAscii.cpp @@ -237,8 +237,7 @@ API::Workspace_sptr LoadAscii::readData(std::ifstream &file) const { if (haveXErrors) localWorkspace->dataDx(i) = spectra[i].dataDx(); // Just have spectrum number start at 1 and count up - localWorkspace->getSpectrum(i) - ->setSpectrumNo(static_cast<specnum_t>(i) + 1); + localWorkspace->getSpectrum(i).setSpectrumNo(static_cast<specnum_t>(i) + 1); } return localWorkspace; } diff --git a/Framework/DataHandling/src/LoadAscii2.cpp b/Framework/DataHandling/src/LoadAscii2.cpp index 65b6ecd5d74aefd9303e21fcac994300cda260e4..7a45b382aa59eab3b9b66e057e52379ee0b09c3a 100644 --- a/Framework/DataHandling/src/LoadAscii2.cpp +++ b/Framework/DataHandling/src/LoadAscii2.cpp @@ -212,10 +212,10 @@ void LoadAscii2::writeToWorkspace(API::MatrixWorkspace_sptr &localWorkspace, } if (m_spectrumIDcount != 0) { localWorkspace->getSpectrum(i) - ->setSpectrumNo(m_spectra[i].getSpectrumNo()); + .setSpectrumNo(m_spectra[i].getSpectrumNo()); } else { localWorkspace->getSpectrum(i) - ->setSpectrumNo(static_cast<specnum_t>(i) + 1); + .setSpectrumNo(static_cast<specnum_t>(i) + 1); } } } diff --git a/Framework/DataHandling/src/LoadBBY.cpp b/Framework/DataHandling/src/LoadBBY.cpp index 8e0f9de90e98b344e091a5977a9046c460f0e973..bcc8b7ba610e1a0f6d8cfa05380e3448bee99622 100644 --- a/Framework/DataHandling/src/LoadBBY.cpp +++ b/Framework/DataHandling/src/LoadBBY.cpp @@ -251,7 +251,7 @@ void LoadBBY::exec() { numberHistograms, Progress_ReserveMemory); for (size_t i = 0; i != numberHistograms; ++i) { - DataObjects::EventList &eventList = eventWS->getEventList(i); + DataObjects::EventList &eventList = eventWS->getSpectrum(i); eventList.setSortOrder(DataObjects::PULSETIME_SORT); eventList.reserve(eventCounts[i]); diff --git a/Framework/DataHandling/src/LoadDetectorsGroupingFile.cpp b/Framework/DataHandling/src/LoadDetectorsGroupingFile.cpp index 15d7c163e0239d110f6c073df6448e675edd8c61..c145e7207211eceaa771be2cad6c8b733b7634a1 100644 --- a/Framework/DataHandling/src/LoadDetectorsGroupingFile.cpp +++ b/Framework/DataHandling/src/LoadDetectorsGroupingFile.cpp @@ -389,7 +389,7 @@ void LoadDetectorsGroupingFile::generateNoInstrumentGroupWorkspace() { new DataObjects::GroupingWorkspace(numvectors)); for (size_t i = 0; i < m_groupWS->getNumberHistograms(); i++) { - m_groupWS->getSpectrum(i)->setSpectrumNo(specids[i]); + m_groupWS->getSpectrum(i).setSpectrumNo(specids[i]); } return; diff --git a/Framework/DataHandling/src/LoadEventNexus.cpp b/Framework/DataHandling/src/LoadEventNexus.cpp index 812d46af634f4cbe3ccefb949bbd2dc62853925f..ad8c9129cb8f154292172122d5006c61167c2f77 100644 --- a/Framework/DataHandling/src/LoadEventNexus.cpp +++ b/Framework/DataHandling/src/LoadEventNexus.cpp @@ -372,14 +372,14 @@ public: if (usedDetIds[pixID - m_min_id]) { // Find the the workspace index corresponding to that pixel ID size_t wi = pixelID_to_wi_vector[pixID + pixelID_to_wi_offset]; - EventList *el = outputWS.getEventListPtr(wi); + auto &el = outputWS.getSpectrum(wi); if (compress) - el->compressEvents(alg->compressTolerance, el); + el.compressEvents(alg->compressTolerance, &el); else { if (pulsetimesincreasing) - el->setSortOrder(DataObjects::PULSETIME_SORT); + el.setSortOrder(DataObjects::PULSETIME_SORT); else - el->setSortOrder(DataObjects::UNSORTED); + el.setSortOrder(DataObjects::UNSORTED); } } } @@ -1421,11 +1421,9 @@ void LoadEventNexus::makeMapToEventLists(std::vector<std::vector<T>> &vectors) { } for (size_t period = 0; period < m_ws->nPeriods(); ++period) { for (size_t i = 0; i < m_ws->getNumberHistograms(); ++i) { - const ISpectrum *spec = m_ws->getSpectrum(i); - if (spec) { - getEventsFrom(m_ws->getEventList(i, period), - vectors[period][spec->getSpectrumNo()]); - } + const auto &spec = m_ws->getSpectrum(i); + getEventsFrom(m_ws->getSpectrum(i, period), + vectors[period][spec.getSpectrumNo()]); } } } else { @@ -1446,7 +1444,7 @@ void LoadEventNexus::makeMapToEventLists(std::vector<std::vector<T>> &vectors) { // Save a POINTER to the vector if (wi < m_ws->getNumberHistograms()) { for (size_t period = 0; period < m_ws->nPeriods(); ++period) { - getEventsFrom(m_ws->getEventList(wi, period), + getEventsFrom(m_ws->getSpectrum(wi, period), vectors[period][j - pixelID_to_wi_offset]); } } @@ -1881,7 +1879,7 @@ void LoadEventNexus::loadEvents(API::Progress *const prog, } else { // Convert to weighted events for (size_t i = 0; i < m_ws->getNumberHistograms(); i++) { - m_ws->getEventList(i).switchTo(API::WEIGHTED); + m_ws->getSpectrum(i).switchTo(API::WEIGHTED); } this->makeMapToEventLists<WeightedEventVector_pt>(weightedEventVectors); } @@ -1889,7 +1887,7 @@ void LoadEventNexus::loadEvents(API::Progress *const prog, // Set all (empty) event lists as sorted by pulse time. That way, calling // SortEvents will not try to sort these empty lists. for (size_t i = 0; i < m_ws->getNumberHistograms(); i++) - m_ws->getEventList(i).setSortOrder(DataObjects::PULSETIME_SORT); + m_ws->getSpectrum(i).setSortOrder(DataObjects::PULSETIME_SORT); // Count the limits to time of flight shortest_tof = @@ -2016,7 +2014,7 @@ void LoadEventNexus::loadEvents(API::Progress *const prog, for (int64_t i = 0; i < numHistograms; ++i) { PARALLEL_START_INTERUPT_REGION // Do the offsetting - m_ws->getEventList(i).addTof(mT0); + m_ws->getSpectrum(i).addTof(mT0); PARALLEL_END_INTERUPT_REGION } PARALLEL_CHECK_INTERUPT_REGION @@ -2740,7 +2738,7 @@ void LoadEventNexus::loadTimeOfFlightData(::NeXus::File &file, // loop over spectra for (size_t wi = start_wi; wi < end_wi; ++wi) { - EventList &event_list = WS->getEventList(wi); + EventList &event_list = WS->getSpectrum(wi); // sort the events event_list.sortTof(); std::vector<TofEvent> &events = event_list.getEvents(); diff --git a/Framework/DataHandling/src/LoadEventPreNexus.cpp b/Framework/DataHandling/src/LoadEventPreNexus.cpp index bcba4d59a150e4a7ca997eb0d8480a134b58fc46..d5ac3e278967b4b466fd63ce37c573c973959e96 100644 --- a/Framework/DataHandling/src/LoadEventPreNexus.cpp +++ b/Framework/DataHandling/src/LoadEventPreNexus.cpp @@ -531,7 +531,7 @@ void LoadEventPreNexus::procEvents( for (detid_t j = 0; j < detid_max + 1; j++) { size_t wi = pixel_to_wkspindex[j]; // Save a POINTER to the vector<tofEvent> - theseEventVectors[j] = &partWS->getEventList(wi).getEvents(); + theseEventVectors[j] = &partWS->getSpectrum(wi).getEvents(); } } @@ -598,19 +598,19 @@ void LoadEventPreNexus::procEvents( size_t wi = size_t(iwi); // The output event list. - EventList &el = workspace->getEventList(wi); + EventList &el = workspace->getSpectrum(wi); el.clear(false); // How many events will it have? size_t numEvents = 0; for (size_t i = 0; i < numThreads; i++) - numEvents += partWorkspaces[i]->getEventList(wi).getNumberEvents(); + numEvents += partWorkspaces[i]->getSpectrum(wi).getNumberEvents(); // This will avoid too much copying. el.reserve(numEvents); // Now merge the event lists for (size_t i = 0; i < numThreads; i++) { - EventList &partEl = partWorkspaces[i]->getEventList(wi); + EventList &partEl = partWorkspaces[i]->getSpectrum(wi); el += partEl.getEvents(); // Free up memory as you go along. partEl.clear(false); @@ -759,10 +759,10 @@ void LoadEventPreNexus::procEventsLinear( // The addEventQuickly method does not clear the cache, making things // slightly faster. - // workspace->getEventList(this->pixel_to_wkspindex[pid]).addEventQuickly(event); + // workspace->getSpectrum(this->pixel_to_wkspindex[pid]).addEventQuickly(event); // This is equivalent to - // workspace->getEventList(this->pixel_to_wkspindex[pid]).addEventQuickly(event); + // workspace->getSpectrum(this->pixel_to_wkspindex[pid]).addEventQuickly(event); // But should be faster as a bunch of these calls were cached. arrayOfVectors[pid]->push_back(event); diff --git a/Framework/DataHandling/src/LoadEventPreNexus2.cpp b/Framework/DataHandling/src/LoadEventPreNexus2.cpp index ec971dcceb5054985cb39ef79475c5ebfa2befff..12da0954c4c1ff938baf70c1dcadf338ed05c7d2 100644 --- a/Framework/DataHandling/src/LoadEventPreNexus2.cpp +++ b/Framework/DataHandling/src/LoadEventPreNexus2.cpp @@ -777,7 +777,7 @@ void LoadEventPreNexus2::procEvents( for (detid_t j = 0; j < detid_max + 1; j++) { size_t wi = pixel_to_wkspindex[j]; // Save a POINTER to the vector<tofEvent> - theseEventVectors[j] = &partWS->getEventList(wi).getEvents(); + theseEventVectors[j] = &partWS->getSpectrum(wi).getEvents(); } } @@ -853,19 +853,19 @@ void LoadEventPreNexus2::procEvents( size_t wi = size_t(iwi); // The output event list. - EventList &el = workspace->getEventList(wi); + EventList &el = workspace->getSpectrum(wi); el.clear(false); // How many events will it have? size_t numEvents = 0; for (size_t i = 0; i < numThreads; i++) - numEvents += partWorkspaces[i]->getEventList(wi).getNumberEvents(); + numEvents += partWorkspaces[i]->getSpectrum(wi).getNumberEvents(); // This will avoid too much copying. el.reserve(numEvents); // Now merge the event lists for (size_t i = 0; i < numThreads; i++) { - EventList &partEl = partWorkspaces[i]->getEventList(wi); + EventList &partEl = partWorkspaces[i]->getSpectrum(wi); el += partEl.getEvents(); // Free up memory as you go along. partEl.clear(false); @@ -1076,7 +1076,7 @@ void LoadEventPreNexus2::procEventsLinear( local_longest_tof = tof; // This is equivalent to -// workspace->getEventList(this->pixel_to_wkspindex[pid]).addEventQuickly(event); +// workspace->getSpectrum(this->pixel_to_wkspindex[pid]).addEventQuickly(event); // But should be faster as a bunch of these calls were cached. #if defined(__GNUC__) && !(defined(__INTEL_COMPILER)) && !(defined(__clang__)) // This avoids a copy constructor call but is only available with GCC diff --git a/Framework/DataHandling/src/LoadFITS.cpp b/Framework/DataHandling/src/LoadFITS.cpp index 150553978eb21b7ea69619c6b4403a986ad0aa74..4e5681435da665a23db40e7b4df4a30f52dba51d 100644 --- a/Framework/DataHandling/src/LoadFITS.cpp +++ b/Framework/DataHandling/src/LoadFITS.cpp @@ -858,10 +858,9 @@ void LoadFITS::readDataToWorkspace(const FITSInfo &fileInfo, double cmpp, PARALLEL_FOR_NO_WSP_CHECK() for (int i = 0; i < static_cast<int>(nrows); ++i) { - Mantid::API::ISpectrum *specRow = ws->getSpectrum(i); - auto &dataX = specRow->dataX(); - auto &dataY = specRow->dataY(); - auto &dataE = specRow->dataE(); + auto &dataX = ws->dataX(i); + auto &dataY = ws->dataY(i); + auto &dataE = ws->dataE(i); std::fill(dataX.begin(), dataX.end(), static_cast<double>(i) * cmpp); for (size_t j = 0; j < ncols; ++j) { diff --git a/Framework/DataHandling/src/LoadGSS.cpp b/Framework/DataHandling/src/LoadGSS.cpp index 61e80aec74ffc3d9a5c86bbc06c881fc568661ad..59899cbeffd4e6c34d0c1119fa4af9ef5e2676a7 100644 --- a/Framework/DataHandling/src/LoadGSS.cpp +++ b/Framework/DataHandling/src/LoadGSS.cpp @@ -415,7 +415,7 @@ API::MatrixWorkspace_sptr LoadGSS::loadGSASFile(const std::string &filename, // Reset spectrum number if if (useBankAsSpectrum) { specnum_t specno = static_cast<specnum_t>(detectorIDs[i]); - outputWorkspace->getSpectrum(i)->setSpectrumNo(specno); + outputWorkspace->getSpectrum(i).setSpectrumNo(specno); } } @@ -519,16 +519,11 @@ void LoadGSS::createInstrumentGeometry( detector->setPos(pos); // add copy to instrument, spectrum and mark it - API::ISpectrum *spec = workspace->getSpectrum(i); - if (spec) { - spec->clearDetectorIDs(); - spec->addDetectorID(detectorids[i]); - instrument->add(detector); - instrument->markAsDetector(detector); - } else { - g_log.error() << "Workspace " << i << " has no spectrum!\n"; - continue; - } + auto &spec = workspace->getSpectrum(i); + spec.clearDetectorIDs(); + spec.addDetectorID(detectorids[i]); + instrument->add(detector); + instrument->markAsDetector(detector); } // ENDFOR (i: spectrum) diff --git a/Framework/DataHandling/src/LoadISISNexus2.cpp b/Framework/DataHandling/src/LoadISISNexus2.cpp index 28ac4d2c805bd29682158177d183c049c63c5212..0fb704567bd4d09d3aa29fa19ef82de4e7c51df7 100644 --- a/Framework/DataHandling/src/LoadISISNexus2.cpp +++ b/Framework/DataHandling/src/LoadISISNexus2.cpp @@ -793,11 +793,11 @@ void LoadISISNexus2::loadPeriodData( if (update_spectra2det_mapping) { // local_workspace->getAxis(1)->setValue(hist_index, // static_cast<specnum_t>(it->first)); - auto spec = local_workspace->getSpectrum(hist_index); + auto &spec = local_workspace->getSpectrum(hist_index); specnum_t specNum = m_wsInd2specNum_map.at(hist_index); - spec->setDetectorIDs( + spec.setDetectorIDs( m_spec2det_map.getDetectorIDsForSpectrumNo(specNum)); - spec->setSpectrumNo(specNum); + spec.setSpectrumNo(specNum); } NXFloat timeBins = monitor.openNXFloat("time_of_flight"); @@ -893,12 +893,12 @@ void LoadISISNexus2::loadBlock(NXDataSetTyped<int> &data, int64_t blocksize, if (m_load_selected_spectra) { // local_workspace->getAxis(1)->setValue(hist, // static_cast<specnum_t>(spec_num)); - auto spec = local_workspace->getSpectrum(hist); + auto &spec = local_workspace->getSpectrum(hist); specnum_t specNum = m_wsInd2specNum_map.at(hist); // set detectors corresponding to spectra Number - spec->setDetectorIDs(m_spec2det_map.getDetectorIDsForSpectrumNo(specNum)); + spec.setDetectorIDs(m_spec2det_map.getDetectorIDsForSpectrumNo(specNum)); // set correct spectra Number - spec->setSpectrumNo(specNum); + spec.setSpectrumNo(specNum); } ++hist; diff --git a/Framework/DataHandling/src/LoadMcStas.cpp b/Framework/DataHandling/src/LoadMcStas.cpp index d77b22724fcb94299d81b231a81aaf9a2e1da2f2..75c9bab2a5391a7e41b3d115cf5049049bb576ee 100644 --- a/Framework/DataHandling/src/LoadMcStas.cpp +++ b/Framework/DataHandling/src/LoadMcStas.cpp @@ -234,9 +234,9 @@ void LoadMcStas::readEventData( std::vector<detid_t> detIDs = instrument->getDetectorIDs(); for (size_t i = 0; i < instrument->getNumberDetectors(); i++) { - eventWS->getEventList(i).addDetectorID(detIDs[i]); + eventWS->getSpectrum(i).addDetectorID(detIDs[i]); // spectrum number are treated as equal to detector IDs for McStas data - eventWS->getEventList(i).setSpectrumNo(detIDs[i]); + eventWS->getSpectrum(i).setSpectrumNo(detIDs[i]); } // the one is here for the moment for backward compatibility eventWS->rebuildSpectraMapping(true); @@ -347,18 +347,18 @@ void LoadMcStas::readEventData( detIDtoWSindex_map.find(detectorID)->second; int64_t pulse_time = 0; - // eventWS->getEventList(workspaceIndex) += + // eventWS->getSpectrum(workspaceIndex) += // TofEvent(detector_time,pulse_time); - // eventWS->getEventList(workspaceIndex) += TofEvent(detector_time); + // eventWS->getSpectrum(workspaceIndex) += TofEvent(detector_time); // The following line puts the events into the weighted event instance // Originally this was coded so the error squared is 1 it should be // data[numberOfDataColumn * in]*data[numberOfDataColumn * in] // introduced flag to allow old usage if (errorBarsSetTo1) { - eventWS->getEventList(workspaceIndex) += WeightedEvent( + eventWS->getSpectrum(workspaceIndex) += WeightedEvent( detector_time, pulse_time, data[numberOfDataColumn * in], 1.0); } else { - eventWS->getEventList(workspaceIndex) += WeightedEvent( + eventWS->getSpectrum(workspaceIndex) += WeightedEvent( detector_time, pulse_time, data[numberOfDataColumn * in], data[numberOfDataColumn * in] * data[numberOfDataColumn * in]); } diff --git a/Framework/DataHandling/src/LoadMuonNexus1.cpp b/Framework/DataHandling/src/LoadMuonNexus1.cpp index a8e2b897d3cc2fee1658211e50fbf1622baf729b..9d3ce816a21816b5ab1eb06ca7381b167baa0e41 100644 --- a/Framework/DataHandling/src/LoadMuonNexus1.cpp +++ b/Framework/DataHandling/src/LoadMuonNexus1.cpp @@ -291,8 +291,8 @@ void LoadMuonNexus1::exec() { } std::vector<int> specIDs, detecIDs; for (size_t i = 0; i < localWorkspace->getNumberHistograms(); i++) { - specIDs.push_back(localWorkspace->getSpectrum(i)->getSpectrumNo()); - detecIDs.push_back(localWorkspace->getSpectrum(i)->getSpectrumNo()); + specIDs.push_back(localWorkspace->getSpectrum(i).getSpectrumNo()); + detecIDs.push_back(localWorkspace->getSpectrum(i).getSpectrumNo()); } API::SpectrumDetectorMapping mapping(specIDs, detecIDs); localWorkspace->updateSpectraUsing(mapping); @@ -675,7 +675,7 @@ void LoadMuonNexus1::loadData(size_t hist, specnum_t &i, specnum_t specNo, new MantidVec(timeChannels, timeChannels + lengthIn + 1)); localWorkspace->setX(hist, timeChannelsVec); - localWorkspace->getSpectrum(hist)->setSpectrumNo(specNo); + localWorkspace->getSpectrum(hist).setSpectrumNo(specNo); // Clean up delete[] timeChannels; diff --git a/Framework/DataHandling/src/LoadMuonNexus2.cpp b/Framework/DataHandling/src/LoadMuonNexus2.cpp index 6295dbfd0bffb5452c79926df098aa24de82ab51..170e65c51eccf7bf716ede6c3f63c7f3b36cf3cc 100644 --- a/Framework/DataHandling/src/LoadMuonNexus2.cpp +++ b/Framework/DataHandling/src/LoadMuonNexus2.cpp @@ -249,7 +249,7 @@ void LoadMuonNexus2::doExec() { spec <= static_cast<int>(m_spec_max); ++spec) { int i = index_spectrum[spec]; // if spec not found i is 0 loadData(counts, timeBins, counter, period, i, localWorkspace); - localWorkspace->getSpectrum(counter)->setSpectrumNo(spectrum_index[i]); + localWorkspace->getSpectrum(counter).setSpectrumNo(spectrum_index[i]); counter++; progress.report(); } @@ -259,7 +259,7 @@ void LoadMuonNexus2::doExec() { for (auto spec : m_spec_list) { int k = index_spectrum[spec]; // if spec not found k is 0 loadData(counts, timeBins, counter, period, k, localWorkspace); - localWorkspace->getSpectrum(counter)->setSpectrumNo(spectrum_index[k]); + localWorkspace->getSpectrum(counter).setSpectrumNo(spectrum_index[k]); counter++; progress.report(); } diff --git a/Framework/DataHandling/src/LoadNexusMonitors2.cpp b/Framework/DataHandling/src/LoadNexusMonitors2.cpp index 8e718f7a89e3e409f3bad1d1c774cac2945d761d..47f2f08b310f0386da30ddf9abefc31e2cf9aff1 100644 --- a/Framework/DataHandling/src/LoadNexusMonitors2.cpp +++ b/Framework/DataHandling/src/LoadNexusMonitors2.cpp @@ -262,8 +262,8 @@ void LoadNexusMonitors2::exec() { file.closeGroup(); // NXmonitor // Default values, might change later. - m_workspace->getSpectrum(ws_index)->setSpectrumNo(spectrumNo); - m_workspace->getSpectrum(ws_index)->setDetectorID(monIndex); + m_workspace->getSpectrum(ws_index).setSpectrumNo(spectrumNo); + m_workspace->getSpectrum(ws_index).setDetectorID(monIndex); ++ws_index; prog3.report(); @@ -356,8 +356,8 @@ void LoadNexusMonitors2::exec() { // Fix the detector IDs/spectrum numbers for (size_t i = 0; i < m_workspace->getNumberHistograms(); i++) { - m_workspace->getSpectrum(i)->setSpectrumNo(spectra_numbers[i]); - m_workspace->getSpectrum(i)->setDetectorID(detector_numbers[i]); + m_workspace->getSpectrum(i).setSpectrumNo(spectra_numbers[i]); + m_workspace->getSpectrum(i).setDetectorID(detector_numbers[i]); } // add filename m_workspace->mutableRun().addProperty("Filename", m_filename); @@ -824,7 +824,7 @@ void LoadNexusMonitors2::readEventMonitorEntry(NeXus::File &file, size_t i) { file.closeData(); // load up the event list - DataObjects::EventList &event_list = eventWS->getEventList(i); + DataObjects::EventList &event_list = eventWS->getSpectrum(i); Mantid::Kernel::DateAndTime pulsetime(0); Mantid::Kernel::DateAndTime lastpulsetime(0); diff --git a/Framework/DataHandling/src/LoadNexusProcessed.cpp b/Framework/DataHandling/src/LoadNexusProcessed.cpp index 107fc961adf929296fc2fd2098c67bad26261a79..95a1afcc2bab31c5a067bd2170b5b7d917544da7 100644 --- a/Framework/DataHandling/src/LoadNexusProcessed.cpp +++ b/Framework/DataHandling/src/LoadNexusProcessed.cpp @@ -722,7 +722,7 @@ LoadNexusProcessed::loadEventEntry(NXData &wksp_cls, NXDouble &xbins, int64_t index_start = indices[wi]; int64_t index_end = indices[wi + 1]; if (index_end >= index_start) { - EventList &el = ws->getEventList(j); + EventList &el = ws->getSpectrum(j); el.switchTo(type); // Allocate all the required memory @@ -1650,13 +1650,13 @@ void LoadNexusProcessed::readInstrumentGroup( (m_list && find(m_spec_list.begin(), m_spec_list.end(), i) != m_spec_list.end())) { - ISpectrum *spec = local_workspace->getSpectrum(index); - spec->setSpectrumNo(spectrum); + auto &spec = local_workspace->getSpectrum(index); + spec.setSpectrumNo(spectrum); ++index; int start = spectraInfo.detectorIndex[i - 1]; int end = start + spectraInfo.detectorCount[i - 1]; - spec->setDetectorIDs( + spec.setDetectorIDs( std::set<detid_t>(spectraInfo.detectorList.get() + start, spectraInfo.detectorList.get() + end)); } diff --git a/Framework/DataHandling/src/LoadPreNexusMonitors.cpp b/Framework/DataHandling/src/LoadPreNexusMonitors.cpp index 890411be6427f138fdf5d7a2e85b29b5c5b24239..36d3d6c5d66f67afbbcbe845521d3ad2fec9c4d9 100644 --- a/Framework/DataHandling/src/LoadPreNexusMonitors.cpp +++ b/Framework/DataHandling/src/LoadPreNexusMonitors.cpp @@ -198,9 +198,9 @@ void LoadPreNexusMonitors::exec() { localWorkspace->dataY(i) = intensity; localWorkspace->dataE(i) = error; // Just have spectrum number be the same as the monitor number but -ve. - ISpectrum *spectrum = localWorkspace->getSpectrum(i); - spectrum->setSpectrumNo(monitorIDs[i]); - spectrum->setDetectorID(-monitorIDs[i]); + auto &spectrum = localWorkspace->getSpectrum(i); + spectrum.setSpectrumNo(monitorIDs[i]); + spectrum.setDetectorID(-monitorIDs[i]); } g_log.debug() << "Setting axis zero to TOF\n"; diff --git a/Framework/DataHandling/src/LoadRKH.cpp b/Framework/DataHandling/src/LoadRKH.cpp index a137e1d1c5961dd57e98fef4b4836150625e1d28..9975d815f3b519109974be3216735ee519451d9d 100644 --- a/Framework/DataHandling/src/LoadRKH.cpp +++ b/Framework/DataHandling/src/LoadRKH.cpp @@ -307,7 +307,7 @@ const API::MatrixWorkspace_sptr LoadRKH::read1D() { // Set the appropriate values for (int index = 0; index < pointsToRead; ++index) { localworkspace->getSpectrum(index) - ->setSpectrumNo(static_cast<int>(columnOne[index])); + .setSpectrumNo(static_cast<int>(columnOne[index])); localworkspace->dataY(index)[0] = ydata[index]; localworkspace->dataE(index)[0] = errdata[index]; } diff --git a/Framework/DataHandling/src/LoadRawHelper.cpp b/Framework/DataHandling/src/LoadRawHelper.cpp index 521ea1dd2eb6d8cc808b1a1bad22153a521b82cd..edcce90218406d02795f6dd750b79831ef291a07 100644 --- a/Framework/DataHandling/src/LoadRawHelper.cpp +++ b/Framework/DataHandling/src/LoadRawHelper.cpp @@ -392,7 +392,7 @@ void LoadRawHelper::setWorkspaceData( MantidVec &E = newWorkspace->dataE(wsIndex); std::transform(Y.begin(), Y.end(), E.begin(), dblSqrt); - newWorkspace->getSpectrum(wsIndex)->setSpectrumNo(nspecNum); + newWorkspace->getSpectrum(wsIndex).setSpectrumNo(nspecNum); // for loadrawbin0 if (binStart == 0) { newWorkspace->setX(wsIndex, timeChannelsVec[0]); diff --git a/Framework/DataHandling/src/LoadSNSspec.cpp b/Framework/DataHandling/src/LoadSNSspec.cpp index 36812039ab18937d308ee6b0f4576857a8a9b88d..73c7445b24ebbb6a7a150f7c116d0703a5f25f23 100644 --- a/Framework/DataHandling/src/LoadSNSspec.cpp +++ b/Framework/DataHandling/src/LoadSNSspec.cpp @@ -198,7 +198,7 @@ void LoadSNSspec::exec() { localWorkspace->dataY(i) = spectra[i].dataY(); localWorkspace->dataE(i) = spectra[i].dataE(); // Just have spectrum number start at 1 and count up - localWorkspace->getSpectrum(i)->setSpectrumNo(i + 1); + localWorkspace->getSpectrum(i).setSpectrumNo(i + 1); } setProperty("OutputWorkspace", localWorkspace); diff --git a/Framework/DataHandling/src/LoadSpec.cpp b/Framework/DataHandling/src/LoadSpec.cpp index 99f84d56599871c4c2f244d41c55a022b78e4d10..525705a3ec7f4b0c21b3b6d128c9df01ce6d082a 100644 --- a/Framework/DataHandling/src/LoadSpec.cpp +++ b/Framework/DataHandling/src/LoadSpec.cpp @@ -143,7 +143,7 @@ void LoadSpec::exec() { localWorkspace->dataY(i) = spectra[i].dataY(); localWorkspace->dataE(i) = spectra[i].dataE(); // Just have spectrum number start at 1 and count up - localWorkspace->getSpectrum(i)->setSpectrumNo(i + 1); + localWorkspace->getSpectrum(i).setSpectrumNo(i + 1); } setProperty("OutputWorkspace", localWorkspace); diff --git a/Framework/DataHandling/src/LoadSpice2D.cpp b/Framework/DataHandling/src/LoadSpice2D.cpp index d31b080f0680c0d5abba6119f64e737a1ee30fd6..71c547a4b2b6706db1952fc923dbb989119ec70c 100644 --- a/Framework/DataHandling/src/LoadSpice2D.cpp +++ b/Framework/DataHandling/src/LoadSpice2D.cpp @@ -92,7 +92,7 @@ void store_value(DataObjects::Workspace2D_sptr ws, int specID, double value, X[1] = wavelength + dwavelength / 2.0; Y[0] = value; E[0] = error; - ws->getSpectrum(specID)->setSpectrumNo(specID); + ws->getSpectrum(specID).setSpectrumNo(specID); } /** diff --git a/Framework/DataHandling/src/LoadSwans.cpp b/Framework/DataHandling/src/LoadSwans.cpp index 4d63732b3c9f3b8b68e0c70d1eb078e8f1c3a57b..5ec62e45913e52e693f58bb6a25d80a87a58ea66 100644 --- a/Framework/DataHandling/src/LoadSwans.cpp +++ b/Framework/DataHandling/src/LoadSwans.cpp @@ -239,7 +239,7 @@ void LoadSwans::setMetaDataAsWorkspaceProperties( void LoadSwans::loadDataIntoTheWorkspace( const std::map<uint32_t, std::vector<uint32_t>> &eventMap) { for (const auto &position : eventMap) { - EventList &el = m_ws->getEventList(position.first); + EventList &el = m_ws->getSpectrum(position.first); el.setSpectrumNo(position.first); el.setDetectorID(position.first); for (const auto &event : position.second) { diff --git a/Framework/DataHandling/src/LoadTOFRawNexus.cpp b/Framework/DataHandling/src/LoadTOFRawNexus.cpp index c96c323a1e8b0de92058ec25e5500479a647aecb..a36fc891db90346e74da59d1039f96e1dfe8e557 100644 --- a/Framework/DataHandling/src/LoadTOFRawNexus.cpp +++ b/Framework/DataHandling/src/LoadTOFRawNexus.cpp @@ -428,17 +428,17 @@ void LoadTOFRawNexus::loadBank(const std::string &nexusfilename, size_t wi = id_to_wi.find(pixelID)->second; // Set the basic info of that spectrum - ISpectrum *spec = WS->getSpectrum(wi); - spec->setSpectrumNo(specnum_t(wi + 1)); - spec->setDetectorID(pixel_id[i - iPart]); + auto &spec = WS->getSpectrum(wi); + spec.setSpectrumNo(specnum_t(wi + 1)); + spec.setDetectorID(pixel_id[i - iPart]); // Set the shared X pointer - spec->setX(X); + spec.setX(X); // Extract the Y - MantidVec &Y = spec->dataY(); + MantidVec &Y = spec.dataY(); Y.assign(data.begin() + i * m_numBins, data.begin() + (i + 1) * m_numBins); - MantidVec &E = spec->dataE(); + MantidVec &E = spec.dataE(); if (hasErrors) { // Copy the errors from the loaded document diff --git a/Framework/DataHandling/src/LoadVulcanCalFile.cpp b/Framework/DataHandling/src/LoadVulcanCalFile.cpp index 925e3708408a77c204d3afe48beeb3c489bb1fd1..a5a0b0c583be7ddf714563ce87387ff0521fae77 100644 --- a/Framework/DataHandling/src/LoadVulcanCalFile.cpp +++ b/Framework/DataHandling/src/LoadVulcanCalFile.cpp @@ -519,7 +519,7 @@ void LoadVulcanCalFile::alignEventWorkspace() { double factor = m_tofOffsetsWS->readY(i)[0]; // Perform the multiplication on all events - m_eventWS->getEventList(i).convertTof(1. / factor); + m_eventWS->getSpectrum(i).convertTof(1. / factor); PARALLEL_END_INTERUPT_REGION } diff --git a/Framework/DataHandling/src/MaskDetectors.cpp b/Framework/DataHandling/src/MaskDetectors.cpp index ec4aec353aaffa3c1e4f8cc5d482314de89c8f8b..dff0013be36d35897583901633d3de65c6b998bc 100644 --- a/Framework/DataHandling/src/MaskDetectors.cpp +++ b/Framework/DataHandling/src/MaskDetectors.cpp @@ -291,7 +291,7 @@ void MaskDetectors::fillIndexListFromSpectra( indexList.reserve(WS->getNumberHistograms()); for (int i = 0; i < static_cast<int>(WS->getNumberHistograms()); ++i) { - const specnum_t currentSpec = WS->getSpectrum(i)->getSpectrumNo(); + const specnum_t currentSpec = WS->getSpectrum(i).getSpectrumNo(); if (spectraSet.find(currentSpec) != spectraSet.end()) { indexList.push_back(i); } diff --git a/Framework/DataHandling/src/SaveAscii2.cpp b/Framework/DataHandling/src/SaveAscii2.cpp index 8608982bfac5969ca0fab72a4070ebc0e542f1ea..18cd2d66ec9b21b1df76515fca179bb4d011150a 100644 --- a/Framework/DataHandling/src/SaveAscii2.cpp +++ b/Framework/DataHandling/src/SaveAscii2.cpp @@ -284,8 +284,7 @@ be saved */ void SaveAscii2::writeSpectra(const std::set<int>::const_iterator &spectraItr, std::ofstream &file) { - auto spec = m_ws->getSpectrum(*spectraItr); - const auto specNo = spec->getSpectrumNo(); + const auto specNo = m_ws->getSpectrum(*spectraItr).getSpectrumNo(); const auto workspaceIndex = m_specToIndexMap[specNo]; for (auto iter = m_metaData.begin(); iter != m_metaData.end(); ++iter) { auto value = m_metaDataMap[*iter][workspaceIndex]; @@ -337,8 +336,7 @@ void SaveAscii2::writeSpectra(const std::set<int>::const_iterator &spectraItr, @param file :: the file writer object */ void SaveAscii2::writeSpectra(const int &spectraIndex, std::ofstream &file) { - auto spec = m_ws->getSpectrum(spectraIndex); - const auto specNo = spec->getSpectrumNo(); + const auto specNo = m_ws->getSpectrum(spectraIndex).getSpectrumNo(); const auto workspaceIndex = m_specToIndexMap[specNo]; for (auto iter = m_metaData.begin(); iter != m_metaData.end(); ++iter) { auto value = m_metaDataMap[*iter][workspaceIndex]; @@ -414,7 +412,7 @@ void SaveAscii2::populateQMetaData() { std::vector<std::string> qValues; const auto nHist = m_ws->getNumberHistograms(); for (size_t i = 0; i < nHist; i++) { - const auto specNo = m_ws->getSpectrum(i)->getSpectrumNo(); + const auto specNo = m_ws->getSpectrum(i).getSpectrumNo(); const auto workspaceIndex = m_specToIndexMap[specNo]; const auto detector = m_ws->getDetector(workspaceIndex); double twoTheta(0.0), efixed(0.0); @@ -444,7 +442,7 @@ void SaveAscii2::populateSpectrumNumberMetaData() { std::vector<std::string> spectrumNumbers; const size_t nHist = m_ws->getNumberHistograms(); for (size_t i = 0; i < nHist; i++) { - const auto specNum = m_ws->getSpectrum(i)->getSpectrumNo(); + const auto specNum = m_ws->getSpectrum(i).getSpectrumNo(); const auto specNumStr = std::to_string(specNum); spectrumNumbers.push_back(specNumStr); } @@ -458,7 +456,7 @@ void SaveAscii2::populateAngleMetaData() { std::vector<std::string> angles; const size_t nHist = m_ws->getNumberHistograms(); for (size_t i = 0; i < nHist; i++) { - const auto specNo = m_ws->getSpectrum(i)->getSpectrumNo(); + const auto specNo = m_ws->getSpectrum(i).getSpectrumNo(); const auto workspaceIndex = m_specToIndexMap[specNo]; auto det = m_ws->getDetector(workspaceIndex); const auto two_theta = m_ws->detectorTwoTheta(*det); diff --git a/Framework/DataHandling/src/SaveDetectorsGrouping.cpp b/Framework/DataHandling/src/SaveDetectorsGrouping.cpp index 3a437a70d23666044f27213613b2678c637ef91e..00bb3494e1e771cd2641890774ea3917b0733a84 100644 --- a/Framework/DataHandling/src/SaveDetectorsGrouping.cpp +++ b/Framework/DataHandling/src/SaveDetectorsGrouping.cpp @@ -103,15 +103,10 @@ void SaveDetectorsGrouping::createGroupDetectorIDMap( } // c) Convert workspace ID to detector ID - const API::ISpectrum *mspec = mGroupWS->getSpectrum(iws); - if (!mspec) { - g_log.error() << "Workspace index " << iws - << " has no spectrum. Impossible!\n"; - throw; - } - auto detids = mspec->getDetectorIDs(); + const auto &mspec = mGroupWS->getSpectrum(iws); + auto &detids = mspec.getDetectorIDs(); if (detids.size() != 1) { - g_log.error() << "Spectrum " << mspec->getSpectrumNo() << " has " + g_log.error() << "Spectrum " << mspec.getSpectrumNo() << " has " << detids.size() << " detectors. Not allowed situation!\n"; throw; } diff --git a/Framework/DataHandling/src/SaveDiffCal.cpp b/Framework/DataHandling/src/SaveDiffCal.cpp index 486f76ff09dd1a2446305e820a8f50d463074646..1a1adff28a37af99c680757705efc0ee56e594ed 100644 --- a/Framework/DataHandling/src/SaveDiffCal.cpp +++ b/Framework/DataHandling/src/SaveDiffCal.cpp @@ -142,8 +142,7 @@ void SaveDiffCal::writeIntFieldFromSVWS( int32_t value; for (size_t i = 0; i < m_numValues; ++i) { - auto spectrum = ws->getSpectrum(i); - auto ids = spectrum->getDetectorIDs(); + auto &ids = ws->getSpectrum(i).getDetectorIDs(); auto found = m_detidToIndex.find(*(ids.begin())); if (found != m_detidToIndex.end()) { value = static_cast<int32_t>(ws->getValue(found->first)); diff --git a/Framework/DataHandling/src/SaveFITS.cpp b/Framework/DataHandling/src/SaveFITS.cpp index aa50806236f7122be53dc94b929ba5c57a8f0197..aee2911ddbb392259e72612c4ece6e041c6cf7d3 100644 --- a/Framework/DataHandling/src/SaveFITS.cpp +++ b/Framework/DataHandling/src/SaveFITS.cpp @@ -172,8 +172,7 @@ void SaveFITS::writeFITSImageMatrix(const API::MatrixWorkspace_sptr img, const size_t bytespp = static_cast<size_t>(bitDepth) / 8; for (size_t row = 0; row < sizeY; ++row) { - Mantid::API::ISpectrum *spectrum = img->getSpectrum(row); - const auto &dataY = spectrum->readY(); + const auto &dataY = img->readY(row); for (size_t col = 0; col < sizeX; ++col) { int32_t pixelVal; if (8 == bitDepth) { diff --git a/Framework/DataHandling/src/SaveFocusedXYE.cpp b/Framework/DataHandling/src/SaveFocusedXYE.cpp index e38935cae7b3654f0e831530b0145f371111d518..36d567071538fd5cba670ea31a5e6f0e9fbd74ba 100644 --- a/Framework/DataHandling/src/SaveFocusedXYE.cpp +++ b/Framework/DataHandling/src/SaveFocusedXYE.cpp @@ -162,7 +162,7 @@ void SaveFocusedXYE::exec() { if (headers) { writeSpectraHeader(out, i + startingbank, - inputWS->getSpectrum(i)->getSpectrumNo(), l1 + l2, tth, + inputWS->getSpectrum(i).getSpectrumNo(), l1 + l2, tth, inputWS->getAxis(0)->unit()->caption()); // out << "# Data for spectra :" << i + startingbank << '\n'; // out << "# " << inputWS->getAxis(0)->unit()->caption() << " diff --git a/Framework/DataHandling/src/SaveGSS.cpp b/Framework/DataHandling/src/SaveGSS.cpp index e9566da390896a44d4344f68566d98ae01e0d4e0..ff9d120565024f1cb847996377c014ad897ef35a 100644 --- a/Framework/DataHandling/src/SaveGSS.cpp +++ b/Framework/DataHandling/src/SaveGSS.cpp @@ -291,7 +291,7 @@ void SaveGSS::writeGSASFile(const std::string &outfilename, bool append, // Determine bank number into GSAS file int bankid; if (m_useSpecAsBank) { - bankid = static_cast<int>(inputWS->getSpectrum(iws)->getSpectrumNo()); + bankid = static_cast<int>(inputWS->getSpectrum(iws).getSpectrumNo()); } else { bankid = basebanknumber + iws; } diff --git a/Framework/DataHandling/src/SaveMask.cpp b/Framework/DataHandling/src/SaveMask.cpp index b57e737d23e454a2c107bc5d2b3b0727675b391a..b737c70e541a86f7f3237f51833196529cfd12d3 100644 --- a/Framework/DataHandling/src/SaveMask.cpp +++ b/Framework/DataHandling/src/SaveMask.cpp @@ -91,23 +91,11 @@ void SaveMask::exec() { for (size_t i = 0; i < inpWS->getNumberHistograms(); i++) { if (inpWS->dataY(i)[0] > 0.1) { // It is way from 0 but smaller than 1 - // a) workspace index -> spectrum -> detector ID - const API::ISpectrum *spec = inpWS->getSpectrum(i); - if (!spec) { - g_log.error() << "No spectrum corresponds to workspace index " << i - << '\n'; - throw std::invalid_argument("Cannot find spectrum"); - } - - const auto detids = spec->getDetectorIDs(); - - // b) get detector id & Store - for (const auto &det_id : detids) { - // c) store + for (const auto &det_id : inpWS->getSpectrum(i).getDetectorIDs()) { detid0s.push_back(det_id); } - } // if - } // for + } + } // d) sort g_log.debug() << "Number of detectors to be masked = " << detid0s.size() diff --git a/Framework/DataHandling/src/SaveNexusProcessed.cpp b/Framework/DataHandling/src/SaveNexusProcessed.cpp index 20a1f05842c36607b2ccfe1f441d4eda9af4db72..f98fedecd198a35262bb43e360e3fbbfa13565ee 100644 --- a/Framework/DataHandling/src/SaveNexusProcessed.cpp +++ b/Framework/DataHandling/src/SaveNexusProcessed.cpp @@ -377,7 +377,7 @@ void SaveNexusProcessed::execEvent(Mantid::NeXus::NexusFileIO *nexusFile, wi < static_cast<int>(m_eventWorkspace->getNumberHistograms()); wi++) { indices.push_back(index); // Track the total # of events - index += m_eventWorkspace->getEventList(wi).getNumberEvents(); + index += m_eventWorkspace->getSpectrum(wi).getNumberEvents(); } indices.push_back(index); @@ -425,7 +425,7 @@ void SaveNexusProcessed::execEvent(Mantid::NeXus::NexusFileIO *nexusFile, for (int wi = 0; wi < static_cast<int>(m_eventWorkspace->getNumberHistograms()); wi++) { PARALLEL_START_INTERUPT_REGION - const DataObjects::EventList &el = m_eventWorkspace->getEventList(wi); + const DataObjects::EventList &el = m_eventWorkspace->getSpectrum(wi); // This is where it will land in the output array. // It is okay to write in parallel since none should step on each other. diff --git a/Framework/DataHandling/src/SaveRKH.cpp b/Framework/DataHandling/src/SaveRKH.cpp index 34fc2a4d3f90e3e7e25f253b37ff55b5fd1f801f..eabfc3e3b69cea198a0b3291199b4a004f95218a 100644 --- a/Framework/DataHandling/src/SaveRKH.cpp +++ b/Framework/DataHandling/src/SaveRKH.cpp @@ -156,7 +156,7 @@ void SaveRKH::write1D() { specnum_t specid(0); try { - specid = m_workspace->getSpectrum(i)->getSpectrumNo(); + specid = m_workspace->getSpectrum(i).getSpectrumNo(); } catch (...) { specid = static_cast<specnum_t>(i + 1); } diff --git a/Framework/DataHandling/test/CompressEventsTest.h b/Framework/DataHandling/test/CompressEventsTest.h index bba1a852779e87643a02f38b5fb6a689bdb65605..d3843b7add90b94b2c56d7d49749c5be9e1e86f9 100644 --- a/Framework/DataHandling/test/CompressEventsTest.h +++ b/Framework/DataHandling/test/CompressEventsTest.h @@ -85,8 +85,8 @@ public: TS_ASSERT_EQUALS(output->getEventType(), WEIGHTED_NOTIME); // Check an event to see if it makes sense - if (output->getEventList(0).getNumberEvents() > 0) { - WeightedEvent ev = output->getEventList(0).getEvent(0); + if (output->getSpectrum(0).getNumberEvents() > 0) { + WeightedEvent ev = output->getSpectrum(0).getEvent(0); TS_ASSERT_DELTA(ev.weight(), 2.0, 1e-6); TS_ASSERT_DELTA(ev.errorSquared(), 2.0, 1e-6); TS_ASSERT_DELTA(ev.tof(), 0.5, 1e-6); diff --git a/Framework/DataHandling/test/CreateSimulationWorkspaceTest.h b/Framework/DataHandling/test/CreateSimulationWorkspaceTest.h index 94cf522c2674ad1cf21417a8d7af6a308c790a8c..4bce217527f4b8f84edfcdd90a2bec1a1979a96c 100644 --- a/Framework/DataHandling/test/CreateSimulationWorkspaceTest.h +++ b/Framework/DataHandling/test/CreateSimulationWorkspaceTest.h @@ -69,11 +69,11 @@ public: TS_ASSERT_EQUALS(nhist, 12120); for (size_t i = 0; i < nhist; ++i) { - ISpectrum *spectrum(NULL); - TS_ASSERT_THROWS_NOTHING(spectrum = outputWS->getSpectrum(i)); + TS_ASSERT_THROWS_NOTHING(outputWS->getSpectrum(i)); + auto &spectrum = outputWS->getSpectrum(i); - TS_ASSERT_EQUALS(spectrum->getSpectrumNo(), i + 1); - TS_ASSERT_EQUALS(spectrum->getDetectorIDs().size(), 1); + TS_ASSERT_EQUALS(spectrum.getSpectrumNo(), i + 1); + TS_ASSERT_EQUALS(spectrum.getDetectorIDs().size(), 1); } } @@ -86,10 +86,10 @@ public: const size_t nhist = outputWS->getNumberHistograms(); TS_ASSERT_EQUALS(nhist, 2529); - TS_ASSERT_EQUALS(outputWS->getSpectrum(6)->getDetectorIDs().size(), 1); - TS_ASSERT_EQUALS(outputWS->getSpectrum(6)->getSpectrumNo(), 7); - TS_ASSERT_EQUALS(outputWS->getSpectrum(2083)->getDetectorIDs().size(), 10); - TS_ASSERT_EQUALS(outputWS->getSpectrum(2083)->getSpectrumNo(), 2084); + TS_ASSERT_EQUALS(outputWS->getSpectrum(6).getDetectorIDs().size(), 1); + TS_ASSERT_EQUALS(outputWS->getSpectrum(6).getSpectrumNo(), 7); + TS_ASSERT_EQUALS(outputWS->getSpectrum(2083).getDetectorIDs().size(), 10); + TS_ASSERT_EQUALS(outputWS->getSpectrum(2083).getSpectrumNo(), 2084); // The HET15869 data set was measured around 2005 on the HET instrument. // This is also the latest IDF. @@ -118,10 +118,10 @@ public: const size_t nhist = outputWS->getNumberHistograms(); TS_ASSERT_EQUALS(nhist, 17790); - TS_ASSERT_EQUALS(outputWS->getSpectrum(6)->getDetectorIDs().size(), 1); - TS_ASSERT_EQUALS(outputWS->getSpectrum(6)->getSpectrumNo(), 7); - TS_ASSERT_EQUALS(outputWS->getSpectrum(2083)->getDetectorIDs().size(), 1); - TS_ASSERT_EQUALS(outputWS->getSpectrum(2083)->getSpectrumNo(), 2084); + TS_ASSERT_EQUALS(outputWS->getSpectrum(6).getDetectorIDs().size(), 1); + TS_ASSERT_EQUALS(outputWS->getSpectrum(6).getSpectrumNo(), 7); + TS_ASSERT_EQUALS(outputWS->getSpectrum(2083).getDetectorIDs().size(), 1); + TS_ASSERT_EQUALS(outputWS->getSpectrum(2083).getSpectrumNo(), 2084); // The LOQ49886 data set was measured around 2009 on the LOQ instrument. // It does not link to the most recent version of the LOQ IDF (2012 or diff --git a/Framework/DataHandling/test/FindDetectorsParTest.h b/Framework/DataHandling/test/FindDetectorsParTest.h index 691fc31054a44b2273f824205e37fb16b5b11af6..f68e3cec6f8c10513c83d3d757e92b5a04399436 100644 --- a/Framework/DataHandling/test/FindDetectorsParTest.h +++ b/Framework/DataHandling/test/FindDetectorsParTest.h @@ -422,9 +422,9 @@ private: for (int j = 0; j < NHIST; ++j) { // Just set the spectrum number to match the index - ISpectrum *spec = inputWS->getSpectrum(j); - spec->setSpectrumNo(j + 1); - spec->setDetectorID(j + 1); + auto &spec = inputWS->getSpectrum(j); + spec.setSpectrumNo(j + 1); + spec.setDetectorID(j + 1); } AnalysisDataService::Instance().add(WS_Name, inputWS); @@ -465,9 +465,9 @@ private: // get pointers to the detectors, contributed into group; partDetectors = pDet->getDetectors(); - inputWS->getSpectrum(0)->setSpectrumNo(1); - inputWS->getSpectrum(0)->clearDetectorIDs(); - inputWS->getSpectrum(0)->addDetectorIDs(pDet->getDetectorIDs()); + inputWS->getSpectrum(0).setSpectrumNo(1); + inputWS->getSpectrum(0).clearDetectorIDs(); + inputWS->getSpectrum(0).addDetectorIDs(pDet->getDetectorIDs()); for (size_t i = 0; i < NDET; i++) { spInst->markAsDetector(partDetectors[i].get()); diff --git a/Framework/DataHandling/test/GroupDetectors2Test.h b/Framework/DataHandling/test/GroupDetectors2Test.h index 3f2881b700d58b15b08d80a62d99ec518f9f9d69..bc22c82cb801ed821482c65716f954e50aaa3e87 100644 --- a/Framework/DataHandling/test/GroupDetectors2Test.h +++ b/Framework/DataHandling/test/GroupDetectors2Test.h @@ -61,11 +61,11 @@ public: // (1+index_number) but the same // for each bin space2D->setData(j, data[j], errors); - space2D->getSpectrum(j)->setSpectrumNo(j + 1); // spectra numbers are also - // 1 + index_numbers - // because this is the - // tradition - space2D->getSpectrum(j)->setDetectorID(j); + space2D->getSpectrum(j).setSpectrumNo(j + 1); // spectra numbers are also + // 1 + index_numbers + // because this is the + // tradition + space2D->getSpectrum(j).setDetectorID(j); } Instrument_sptr instr(new Instrument); @@ -251,33 +251,33 @@ public: 1e-6); } TS_ASSERT_EQUALS(outputWS->getAxis(1)->spectraNo(0), 1); - TS_ASSERT_EQUALS(outputWS->getSpectrum(0)->getSpectrumNo(), 1); + TS_ASSERT_EQUALS(outputWS->getSpectrum(0).getSpectrumNo(), 1); TS_ASSERT_EQUALS(outputWS->dataX(1), tens); TS_ASSERT_EQUALS(outputWS->dataY(1), std::vector<double>(NBINS, 4)); // Directly # 4 TS_ASSERT_EQUALS(outputWS->dataE(1), ones); TS_ASSERT_EQUALS(outputWS->getAxis(1)->spectraNo(1), 2); - TS_ASSERT_EQUALS(outputWS->getSpectrum(1)->getSpectrumNo(), 2); + TS_ASSERT_EQUALS(outputWS->getSpectrum(1).getSpectrumNo(), 2); // check the unmoved spectra TS_ASSERT_EQUALS(outputWS->dataX(2), tens); TS_ASSERT_EQUALS(outputWS->dataY(2), std::vector<double>(NBINS, 2)); TS_ASSERT_EQUALS(outputWS->dataE(2), ones); TS_ASSERT_EQUALS(outputWS->getAxis(1)->spectraNo(2), 2); - TS_ASSERT_EQUALS(outputWS->getSpectrum(2)->getSpectrumNo(), 2); + TS_ASSERT_EQUALS(outputWS->getSpectrum(2).getSpectrumNo(), 2); TS_ASSERT_EQUALS(outputWS->dataX(3), tens); TS_ASSERT_EQUALS(outputWS->dataY(3), std::vector<double>(NBINS, 5)); TS_ASSERT_EQUALS(outputWS->dataE(3), ones); TS_ASSERT_EQUALS(outputWS->getAxis(1)->spectraNo(3), 5); - TS_ASSERT_EQUALS(outputWS->getSpectrum(3)->getSpectrumNo(), 5); + TS_ASSERT_EQUALS(outputWS->getSpectrum(3).getSpectrumNo(), 5); TS_ASSERT_EQUALS(outputWS->dataY(4), std::vector<double>(NBINS, 6)); TS_ASSERT_EQUALS(outputWS->dataE(4), ones); TS_ASSERT_EQUALS(outputWS->getAxis(1)->spectraNo(4), 6); - TS_ASSERT_EQUALS(outputWS->getSpectrum(4)->getSpectrumNo(), 6); + TS_ASSERT_EQUALS(outputWS->getSpectrum(4).getSpectrumNo(), 6); // the first two spectra should have a group of detectors the other spectra // a single detector @@ -327,14 +327,14 @@ public: 1e-6); } TS_ASSERT_EQUALS(outputWS->getAxis(1)->spectraNo(0), 1); - TS_ASSERT_EQUALS(outputWS->getSpectrum(0)->getSpectrumNo(), 1); + TS_ASSERT_EQUALS(outputWS->getSpectrum(0).getSpectrumNo(), 1); // check the second grouped spectrum TS_ASSERT_EQUALS(outputWS->dataX(1), tens); TS_ASSERT_EQUALS(outputWS->dataY(1), std::vector<double>(NBINS, 4)); TS_ASSERT_EQUALS(outputWS->dataE(1), ones); TS_ASSERT_EQUALS(outputWS->getAxis(1)->spectraNo(1), 2); - TS_ASSERT_EQUALS(outputWS->getSpectrum(1)->getSpectrumNo(), 2); + TS_ASSERT_EQUALS(outputWS->getSpectrum(1).getSpectrumNo(), 2); // check the third grouped spectrum TS_ASSERT_EQUALS(outputWS->dataX(2), tens); @@ -344,7 +344,7 @@ public: 1e-6); } TS_ASSERT_EQUALS(outputWS->getAxis(1)->spectraNo(2), 3); - TS_ASSERT_EQUALS(outputWS->getSpectrum(2)->getSpectrumNo(), 3); + TS_ASSERT_EQUALS(outputWS->getSpectrum(2).getSpectrumNo(), 3); AnalysisDataService::Instance().remove(output); remove(inputFile.c_str()); @@ -484,17 +484,17 @@ public: TS_ASSERT_EQUALS(output2D1->getNumberHistograms(), 4); std::set<detid_t>::const_iterator specDet; - specDet = output2D1->getSpectrum(0)->getDetectorIDs().begin(); + specDet = output2D1->getSpectrum(0).getDetectorIDs().begin(); TS_ASSERT_EQUALS(*specDet, 1); - specDet = output2D1->getSpectrum(1)->getDetectorIDs().begin(); + specDet = output2D1->getSpectrum(1).getDetectorIDs().begin(); TS_ASSERT_EQUALS(*specDet, 2); - specDet = output2D1->getSpectrum(2)->getDetectorIDs().begin(); + specDet = output2D1->getSpectrum(2).getDetectorIDs().begin(); TS_ASSERT_EQUALS(*specDet, 3); specDet++; TS_ASSERT_EQUALS(*specDet, 4); specDet++; TS_ASSERT_EQUALS(*specDet, 5); - specDet = output2D1->getSpectrum(3)->getDetectorIDs().begin(); + specDet = output2D1->getSpectrum(3).getDetectorIDs().begin(); TS_ASSERT_EQUALS(*specDet, 2); specDet++; TS_ASSERT_EQUALS(*specDet, 8); @@ -622,7 +622,7 @@ public: xRef[4] = 1e6; // Set an X-axis inputW->setX(pix, axis); - inputW->getEventList(pix).addEventQuickly(TofEvent(1000.0)); + inputW->getSpectrum(pix).addEventQuickly(TofEvent(1000.0)); } // ------------ Create a grouping workspace to match ------------- @@ -734,7 +734,7 @@ public: xRef[4] = 1e6; // Set an X-axis inputW->setX(pix, axis); - inputW->getEventList(pix).addEventQuickly(TofEvent(1000.0)); + inputW->getSpectrum(pix).addEventQuickly(TofEvent(1000.0)); } // ------------ Create a grouped workspace using GroupDetectors diff --git a/Framework/DataHandling/test/GroupDetectorsTest.h b/Framework/DataHandling/test/GroupDetectorsTest.h index 6af43cb63a47e1dd0305dd0684738adaf559634c..d139252a65d1f4e24fa424f8fbf6577dc3981a6d 100644 --- a/Framework/DataHandling/test/GroupDetectorsTest.h +++ b/Framework/DataHandling/test/GroupDetectorsTest.h @@ -40,8 +40,8 @@ public: for (int j = 0; j < 5; ++j) { space2D->setX(j, x); space2D->setData(j, vec, vec); - space2D->getSpectrum(j)->setSpectrumNo(j); - space2D->getSpectrum(j)->setDetectorID(j); + space2D->getSpectrum(j).setSpectrumNo(j); + space2D->getSpectrum(j).setDetectorID(j); } Instrument_sptr instr(new Instrument); for (detid_t i = 0; i < 5; i++) { @@ -118,23 +118,23 @@ public: for (int i = 0; i < 5; ++i) { TS_ASSERT_DELTA(outputWS->dataE(0)[i], 1.7321, 0.0001); } - TS_ASSERT_EQUALS(outputWS->getSpectrum(0)->getSpectrumNo(), 0); + TS_ASSERT_EQUALS(outputWS->getSpectrum(0).getSpectrumNo(), 0); TS_ASSERT_EQUALS(outputWS->dataX(1), tens); TS_ASSERT_EQUALS(outputWS->dataY(1), ones); TS_ASSERT_EQUALS(outputWS->dataE(1), ones); - TS_ASSERT_EQUALS(outputWS->getSpectrum(1)->getSpectrumNo(), 1); + TS_ASSERT_EQUALS(outputWS->getSpectrum(1).getSpectrumNo(), 1); TS_ASSERT_EQUALS(outputWS->dataX(2), tens); TS_ASSERT_EQUALS(outputWS->dataY(2), zeroes); TS_ASSERT_EQUALS(outputWS->dataE(2), zeroes); - TS_ASSERT_EQUALS(outputWS->getSpectrum(2)->getSpectrumNo(), -1); + TS_ASSERT_EQUALS(outputWS->getSpectrum(2).getSpectrumNo(), -1); TS_ASSERT_EQUALS(outputWS->dataX(3), tens); TS_ASSERT_EQUALS(outputWS->dataY(3), zeroes); TS_ASSERT_EQUALS(outputWS->dataE(3), zeroes); - TS_ASSERT_EQUALS(outputWS->getSpectrum(3)->getSpectrumNo(), -1); + TS_ASSERT_EQUALS(outputWS->getSpectrum(3).getSpectrumNo(), -1); TS_ASSERT_EQUALS(outputWS->dataX(4), tens); TS_ASSERT_EQUALS(outputWS->dataY(4), ones); TS_ASSERT_EQUALS(outputWS->dataE(4), ones); - TS_ASSERT_EQUALS(outputWS->getSpectrum(4)->getSpectrumNo(), 4); + TS_ASSERT_EQUALS(outputWS->getSpectrum(4).getSpectrumNo(), 4); boost::shared_ptr<const IDetector> det; TS_ASSERT_THROWS_NOTHING(det = outputWS->getDetector(0)); diff --git a/Framework/DataHandling/test/LoadDetectorInfoTest.h b/Framework/DataHandling/test/LoadDetectorInfoTest.h index 28ade5c976f2c3f5e123d04b94ac92e00c871cbe..f99c0771849a5cace974bc61aa5e5fef48bda634 100644 --- a/Framework/DataHandling/test/LoadDetectorInfoTest.h +++ b/Framework/DataHandling/test/LoadDetectorInfoTest.h @@ -217,9 +217,9 @@ void makeTestWorkspace(const int ndets, const int nbins, // each spectra (1+index_number) but // the same for each bin space2D->setData(j, data[j], errors); - ISpectrum *spec = space2D->getSpectrum(j); - spec->setSpectrumNo(j + 1); - spec->setDetectorID(j); + auto &spec = space2D->getSpectrum(j); + spec.setSpectrumNo(j + 1); + spec.setDetectorID(j); } Instrument_sptr instr(new Instrument); diff --git a/Framework/DataHandling/test/LoadEmptyInstrumentTest.h b/Framework/DataHandling/test/LoadEmptyInstrumentTest.h index cdcd53ac2d3db31412248965f7759c9b39e0df7c..7b4f3c2cfa416c72411ff681e56174c4b2ca3ddd 100644 --- a/Framework/DataHandling/test/LoadEmptyInstrumentTest.h +++ b/Framework/DataHandling/test/LoadEmptyInstrumentTest.h @@ -32,7 +32,7 @@ public: size_t numberDetectors) { TS_ASSERT_EQUALS(output->getNumberHistograms(), numberDetectors); for (size_t i = 0; i < output->getNumberHistograms(); i++) { - TS_ASSERT_EQUALS(output->getSpectrum(i)->getDetectorIDs().size(), 1); + TS_ASSERT_EQUALS(output->getSpectrum(i).getDetectorIDs().size(), 1); } } diff --git a/Framework/DataHandling/test/LoadEventNexusTest.h b/Framework/DataHandling/test/LoadEventNexusTest.h index 0f592aa967e4e8a2ac23518436690f005fbb6178..003fb101c51cfa04295dd3663fe650cc2c894d68 100644 --- a/Framework/DataHandling/test/LoadEventNexusTest.h +++ b/Framework/DataHandling/test/LoadEventNexusTest.h @@ -85,12 +85,12 @@ public: TS_ASSERT_DELTA((*WS->refX(0))[0], 44162.6, 0.05); TS_ASSERT_DELTA((*WS->refX(0))[1], 60830.2, 0.05); // Valid spectrum info - TS_ASSERT_EQUALS(WS->getSpectrum(0)->getSpectrumNo(), 1); - TS_ASSERT_EQUALS(WS->getSpectrum(0)->getDetectorIDs().size(), 1); - TS_ASSERT_EQUALS(*WS->getSpectrum(0)->getDetectorIDs().begin(), 0); + TS_ASSERT_EQUALS(WS->getSpectrum(0).getSpectrumNo(), 1); + TS_ASSERT_EQUALS(WS->getSpectrum(0).getDetectorIDs().size(), 1); + TS_ASSERT_EQUALS(*WS->getSpectrum(0).getDetectorIDs().begin(), 0); // Check one event from one pixel - does it have a reasonable pulse time - TS_ASSERT(WS->getEventListPtr(1000)->getEvents()[0].pulseTime() > + TS_ASSERT(WS->getSpectrum(1000).getEvents()[0].pulseTime() > DateAndTime(int64_t(1e9 * 365 * 10))); // Check filename @@ -166,9 +166,8 @@ public: int pixelID = 2000; - std::vector<TofEvent> events1 = WS->getEventListPtr(pixelID)->getEvents(); - std::vector<TofEvent> events2 = - WS2->getEventListPtr(pixelID)->getEvents(); + std::vector<TofEvent> events1 = WS->getSpectrum(pixelID).getEvents(); + std::vector<TofEvent> events2 = WS2->getSpectrum(pixelID).getEvents(); // std::cout << events1.size() << '\n'; TS_ASSERT_EQUALS(events1.size(), events2.size()); @@ -204,7 +203,7 @@ public: auto outWs = AnalysisDataService::Instance().retrieveWS<EventWorkspace>(wsName); - auto eventList = outWs->getEventList(4348); + auto eventList = outWs->getSpectrum(4348); auto events = eventList.getEvents(); double max = events.begin()->tof(); @@ -246,13 +245,13 @@ public: "spectra filtered", outWs->getNumberHistograms() == specList.size()); TSM_ASSERT("Some spectra were not found in the workspace", - outWs->getSpectrum(0)->getSpectrumNo() == 13); + outWs->getSpectrum(0).getSpectrumNo() == 13); TSM_ASSERT("Some spectra were not found in the workspace", - outWs->getSpectrum(1)->getSpectrumNo() == 16); + outWs->getSpectrum(1).getSpectrumNo() == 16); TSM_ASSERT("Some spectra were not found in the workspace", - outWs->getSpectrum(2)->getSpectrumNo() == 21); + outWs->getSpectrum(2).getSpectrumNo() == 21); TSM_ASSERT("Some spectra were not found in the workspace", - outWs->getSpectrum(3)->getSpectrumNo() == 28); + outWs->getSpectrum(3).getSpectrumNo() == 28); // B) test SpectrumMin and SpectrumMax wsName = "test_partial_spectra_loading_SpectrumMin_SpectrumMax"; @@ -274,7 +273,7 @@ public: const size_t numSpecs = specMax - specMin + 1; TS_ASSERT_EQUALS(outWs->getNumberHistograms(), numSpecs); for (size_t specIdx = 0; specIdx < numSpecs; specIdx++) { - TS_ASSERT_EQUALS(outWs->getSpectrum(specIdx)->getSpectrumNo(), + TS_ASSERT_EQUALS(outWs->getSpectrum(specIdx).getSpectrumNo(), static_cast<int>(specMin + specIdx)); } @@ -310,10 +309,10 @@ public: const size_t n = sMax - sMin + 1; // this n is the 20...22, excluding '17' TS_ASSERT_EQUALS(outWs->getNumberHistograms(), n + 1); // +1 is the '17' // 17 should come from SpectrumList - TS_ASSERT_EQUALS(outWs->getSpectrum(0)->getSpectrumNo(), 17); + TS_ASSERT_EQUALS(outWs->getSpectrum(0).getSpectrumNo(), 17); // and then sMin(20)...sMax(22) for (size_t specIdx = 0; specIdx < n; specIdx++) { - TS_ASSERT_EQUALS(outWs->getSpectrum(specIdx + 1)->getSpectrumNo(), + TS_ASSERT_EQUALS(outWs->getSpectrum(specIdx + 1).getSpectrumNo(), static_cast<int>(sMin + specIdx)); } } @@ -364,12 +363,12 @@ public: outWs->getNumberEvents(), outWs2->getNumberEvents()); TSM_ASSERT("Some spectra were not found in the workspace", - outWs->getSpectrum(0)->getSpectrumNo() == 10); + outWs->getSpectrum(0).getSpectrumNo() == 10); TSM_ASSERT("Some spectra were not found in the workspace", - outWs->getSpectrum(10)->getSpectrumNo() == 20); + outWs->getSpectrum(10).getSpectrumNo() == 20); TSM_ASSERT("Some spectra were not found in the workspace", - outWs->getSpectrum(11)->getSpectrumNo() == 45); + outWs->getSpectrum(11).getSpectrumNo() == 45); AnalysisDataService::Instance().remove(wsName); AnalysisDataService::Instance().remove(wsName2); @@ -439,8 +438,8 @@ public: 111274); // There are (slightly) fewer events for (size_t wi = 0; wi < WS->getNumberHistograms(); wi++) { // Pixels with at least one event will have switched - if (WS->getEventList(wi).getNumberEvents() > 0) - TS_ASSERT_EQUALS(WS->getEventList(wi).getEventType(), WEIGHTED_NOTIME) + if (WS->getSpectrum(wi).getNumberEvents() > 0) + TS_ASSERT_EQUALS(WS->getSpectrum(wi).getEventType(), WEIGHTED_NOTIME) } } @@ -619,9 +618,9 @@ public: TS_ASSERT_EQUALS(WS->getNumberEvents(), 10730347); for (size_t wi = 0; wi < WS->getNumberHistograms(); wi++) { // Times are NON-zero for ALL pixels. - if (WS->getEventList(wi).getNumberEvents() > 0) { + if (WS->getSpectrum(wi).getNumberEvents() > 0) { int64_t nanosec = - WS->getEventList(wi).getEvents()[0].pulseTime().totalNanoseconds(); + WS->getSpectrum(wi).getEvents()[0].pulseTime().totalNanoseconds(); TS_ASSERT_DIFFERS(nanosec, 0) if (nanosec == 0) { std::cout << "Failure at WI " << wi << '\n'; @@ -666,12 +665,12 @@ public: TS_ASSERT_EQUALS(WS->getNumberEvents(), 2); for (size_t wi = 0; wi < numHist; wi += 5000) { // All events should be weighted events for simulated data - TS_ASSERT_EQUALS(WS->getEventList(wi).getEventType(), WEIGHTED); + TS_ASSERT_EQUALS(WS->getSpectrum(wi).getEventType(), WEIGHTED); } // Check one event - TS_ASSERT_DELTA(WS->getEventList(26798).getWeightedEvents()[0].weight(), + TS_ASSERT_DELTA(WS->getSpectrum(26798).getWeightedEvents()[0].weight(), 1.8124e-11, 1.0e-4); - TS_ASSERT_EQUALS(WS->getEventList(26798).getWeightedEvents()[0].tof(), + TS_ASSERT_EQUALS(WS->getSpectrum(26798).getWeightedEvents()[0].tof(), 1476.0); } @@ -727,11 +726,11 @@ public: } for (size_t index = 0; index < ws->getNumberHistograms(); ++index) { if (isFirstChildWorkspace) { - specids.push_back(ws->getSpectrum(index)->getSpectrumNo()); + specids.push_back(ws->getSpectrum(index).getSpectrumNo()); } else { TSM_ASSERT_EQUALS( "The spectrNo should be the same for all child workspaces.", - specids[index], ws->getSpectrum(index)->getSpectrumNo()); + specids[index], ws->getSpectrum(index).getSpectrumNo()); } } diff --git a/Framework/DataHandling/test/LoadEventPreNexus2Test.h b/Framework/DataHandling/test/LoadEventPreNexus2Test.h index 43e36403a774b8992099aa618106304ff604b9f1..654b8c1ff8ec6a99c419995bcd2088b393364938 100644 --- a/Framework/DataHandling/test/LoadEventPreNexus2Test.h +++ b/Framework/DataHandling/test/LoadEventPreNexus2Test.h @@ -129,7 +129,7 @@ public: it = logMap.begin(); Kernel::DateAndTime start = it->first; - std::vector<TofEvent> events1 = ew->getEventListPtr(1000)->getEvents(); + std::vector<TofEvent> events1 = ew->getSpectrum(1000).getEvents(); for (size_t i = 0; i < events1.size(); i++) { std::cout << (events1[i].pulseTime() - start) << " sec \n"; } @@ -199,17 +199,17 @@ public: TS_ASSERT_EQUALS(outputWS->getInstrument()->getName(), "CNCS"); std::size_t wkspIndex = 4348; // a good workspace index (with events) - TS_ASSERT_EQUALS(outputWS->getEventList(wkspIndex).getNumberEvents(), 11); - if (outputWS->getEventList(wkspIndex).getNumberEvents() != 11) + TS_ASSERT_EQUALS(outputWS->getSpectrum(wkspIndex).getNumberEvents(), 11); + if (outputWS->getSpectrum(wkspIndex).getNumberEvents() != 11) return; - TS_ASSERT_EQUALS(outputWS->getEventList(wkspIndex).getEvents()[0].tof(), - inputWS->getEventList(wkspIndex).getEvents()[0].tof()); + TS_ASSERT_EQUALS(outputWS->getSpectrum(wkspIndex).getEvents()[0].tof(), + inputWS->getSpectrum(wkspIndex).getEvents()[0].tof()); // It should be possible to change an event list and not affect the other // one - outputWS->getEventList(wkspIndex).convertTof(1.5, 0.2); - TS_ASSERT_DIFFERS(outputWS->getEventList(wkspIndex).getEvents()[0].tof(), - inputWS->getEventList(wkspIndex).getEvents()[0].tof()); + outputWS->getSpectrum(wkspIndex).convertTof(1.5, 0.2); + TS_ASSERT_DIFFERS(outputWS->getSpectrum(wkspIndex).getEvents()[0].tof(), + inputWS->getSpectrum(wkspIndex).getEvents()[0].tof()); // Setting X should still be possible Kernel::cow_ptr<MantidVec> x; @@ -252,13 +252,13 @@ public: TS_ASSERT_EQUALS(ew->getAxis(1)->length(), 2); // Are the pixel IDs ok? - TS_ASSERT_EQUALS(ew->getSpectrum(0)->getSpectrumNo(), 46); - auto dets = ew->getSpectrum(0)->getDetectorIDs(); + TS_ASSERT_EQUALS(ew->getSpectrum(0).getSpectrumNo(), 46); + auto dets = ew->getSpectrum(0).getDetectorIDs(); TS_ASSERT_EQUALS(dets.size(), 1); TS_ASSERT_EQUALS(*dets.begin(), 45); - TS_ASSERT_EQUALS(ew->getSpectrum(1)->getSpectrumNo(), 111); - dets = ew->getSpectrum(1)->getDetectorIDs(); + TS_ASSERT_EQUALS(ew->getSpectrum(1).getSpectrumNo(), 111); + dets = ew->getSpectrum(1).getDetectorIDs(); TS_ASSERT_EQUALS(dets.size(), 1); TS_ASSERT_EQUALS(*dets.begin(), 110); } diff --git a/Framework/DataHandling/test/LoadEventPreNexusTest.h b/Framework/DataHandling/test/LoadEventPreNexusTest.h index e67b381b4b8a2b645542c06f978c6696bf325a73..08244828efd2c9ca46ce583e7bf1bb94cecc4535 100644 --- a/Framework/DataHandling/test/LoadEventPreNexusTest.h +++ b/Framework/DataHandling/test/LoadEventPreNexusTest.h @@ -129,7 +129,7 @@ public: it = logMap.begin(); Kernel::DateAndTime start = it->first; - std::vector<TofEvent> events1 = ew->getEventListPtr(1000)->getEvents(); + std::vector<TofEvent> events1 = ew->getSpectrum(1000).getEvents(); for (size_t i = 0; i < events1.size(); i++) { std::cout << (events1[i].pulseTime() - start) << " sec \n"; } @@ -199,17 +199,17 @@ public: TS_ASSERT_EQUALS(outputWS->getInstrument()->getName(), "CNCS"); std::size_t wkspIndex = 4348; // a good workspace index (with events) - TS_ASSERT_EQUALS(outputWS->getEventList(wkspIndex).getNumberEvents(), 11); - if (outputWS->getEventList(wkspIndex).getNumberEvents() != 11) + TS_ASSERT_EQUALS(outputWS->getSpectrum(wkspIndex).getNumberEvents(), 11); + if (outputWS->getSpectrum(wkspIndex).getNumberEvents() != 11) return; - TS_ASSERT_EQUALS(outputWS->getEventList(wkspIndex).getEvents()[0].tof(), - inputWS->getEventList(wkspIndex).getEvents()[0].tof()); + TS_ASSERT_EQUALS(outputWS->getSpectrum(wkspIndex).getEvents()[0].tof(), + inputWS->getSpectrum(wkspIndex).getEvents()[0].tof()); // It should be possible to change an event list and not affect the other // one - outputWS->getEventList(wkspIndex).convertTof(1.5, 0.2); - TS_ASSERT_DIFFERS(outputWS->getEventList(wkspIndex).getEvents()[0].tof(), - inputWS->getEventList(wkspIndex).getEvents()[0].tof()); + outputWS->getSpectrum(wkspIndex).convertTof(1.5, 0.2); + TS_ASSERT_DIFFERS(outputWS->getSpectrum(wkspIndex).getEvents()[0].tof(), + inputWS->getSpectrum(wkspIndex).getEvents()[0].tof()); // Setting X should still be possible Kernel::cow_ptr<MantidVec> x; @@ -251,13 +251,13 @@ public: TS_ASSERT_EQUALS(ew->getAxis(1)->length(), 2); // Are the pixel IDs ok? - TS_ASSERT_EQUALS(ew->getSpectrum(0)->getSpectrumNo(), 46); - auto dets = ew->getSpectrum(0)->getDetectorIDs(); + TS_ASSERT_EQUALS(ew->getSpectrum(0).getSpectrumNo(), 46); + auto dets = ew->getSpectrum(0).getDetectorIDs(); TS_ASSERT_EQUALS(dets.size(), 1); TS_ASSERT_EQUALS(*dets.begin(), 45); - TS_ASSERT_EQUALS(ew->getSpectrum(1)->getSpectrumNo(), 111); - dets = ew->getSpectrum(1)->getDetectorIDs(); + TS_ASSERT_EQUALS(ew->getSpectrum(1).getSpectrumNo(), 111); + dets = ew->getSpectrum(1).getDetectorIDs(); TS_ASSERT_EQUALS(dets.size(), 1); TS_ASSERT_EQUALS(*dets.begin(), 110); } diff --git a/Framework/DataHandling/test/LoadGSSTest.h b/Framework/DataHandling/test/LoadGSSTest.h index 67345807f42c15b2188334bcf1062450a6cf9a19..a20a770b2f84ffa87b6eb38a80457e95b407f1c5 100644 --- a/Framework/DataHandling/test/LoadGSSTest.h +++ b/Framework/DataHandling/test/LoadGSSTest.h @@ -104,9 +104,9 @@ public: if (outws->getNumberHistograms() != 3) return; - TS_ASSERT_EQUALS(outws->getSpectrum(0)->getSpectrumNo(), 1); - TS_ASSERT_EQUALS(outws->getSpectrum(1)->getSpectrumNo(), 3); - TS_ASSERT_EQUALS(outws->getSpectrum(2)->getSpectrumNo(), 5); + TS_ASSERT_EQUALS(outws->getSpectrum(0).getSpectrumNo(), 1); + TS_ASSERT_EQUALS(outws->getSpectrum(1).getSpectrumNo(), 3); + TS_ASSERT_EQUALS(outws->getSpectrum(2).getSpectrumNo(), 5); API::AnalysisDataService::Instance().remove("TestWS"); } diff --git a/Framework/DataHandling/test/LoadISISNexusTest.h b/Framework/DataHandling/test/LoadISISNexusTest.h index ba4fe1e4a8fa67e8e485cffbdc73414653ca9878..49dfd09b575e1a8183d053b76be486bb9ff744d4 100644 --- a/Framework/DataHandling/test/LoadISISNexusTest.h +++ b/Framework/DataHandling/test/LoadISISNexusTest.h @@ -101,12 +101,12 @@ public: // spectrum with ID 5 is now spectrum N 3 as 2 monitors TS_ASSERT_EQUALS(ws->readY(5 - 2)[1], 1.); - TS_ASSERT_EQUALS(ws->getSpectrum(5 - 2)->getSpectrumNo(), 6); - TS_ASSERT_EQUALS(*(ws->getSpectrum(5 - 2)->getDetectorIDs().begin()), 6); + TS_ASSERT_EQUALS(ws->getSpectrum(5 - 2).getSpectrumNo(), 6); + TS_ASSERT_EQUALS(*(ws->getSpectrum(5 - 2).getDetectorIDs().begin()), 6); // spectrum with ID 7 is now spectrum N 4 TS_ASSERT_EQUALS(ws->readY(6 - 2)[0], 1.); - TS_ASSERT_EQUALS(ws->getSpectrum(6 - 2)->getSpectrumNo(), 7); - TS_ASSERT_EQUALS(*(ws->getSpectrum(6 - 2)->getDetectorIDs().begin()), 7); + TS_ASSERT_EQUALS(ws->getSpectrum(6 - 2).getSpectrumNo(), 7); + TS_ASSERT_EQUALS(*(ws->getSpectrum(6 - 2).getDetectorIDs().begin()), 7); // TS_ASSERT_EQUALS(ws->readY(8 - 2)[3], 1.); @@ -166,46 +166,46 @@ public: TS_ASSERT_EQUALS(ws->readX(0)[0], 5.); TS_ASSERT_EQUALS(ws->readX(0)[1], 4005.); TS_ASSERT_EQUALS(ws->readX(0)[2], 8005.); - TS_ASSERT_EQUALS(ws->getSpectrum(0)->getSpectrumNo(), 1); - TS_ASSERT_EQUALS(*(ws->getSpectrum(0)->getDetectorIDs().begin()), 1); + TS_ASSERT_EQUALS(ws->getSpectrum(0).getSpectrumNo(), 1); + TS_ASSERT_EQUALS(*(ws->getSpectrum(0).getDetectorIDs().begin()), 1); TS_ASSERT_EQUALS(ws->readY(5)[1], 1.); - TS_ASSERT_EQUALS(ws->getSpectrum(5)->getSpectrumNo(), 6); - TS_ASSERT_EQUALS(*(ws->getSpectrum(5)->getDetectorIDs().begin()), 6); + TS_ASSERT_EQUALS(ws->getSpectrum(5).getSpectrumNo(), 6); + TS_ASSERT_EQUALS(*(ws->getSpectrum(5).getDetectorIDs().begin()), 6); TS_ASSERT_EQUALS(ws->readY(6)[0], 1.); - TS_ASSERT_EQUALS(ws->getSpectrum(6)->getSpectrumNo(), 7); - TS_ASSERT_EQUALS(*(ws->getSpectrum(6)->getDetectorIDs().begin()), 7); + TS_ASSERT_EQUALS(ws->getSpectrum(6).getSpectrumNo(), 7); + TS_ASSERT_EQUALS(*(ws->getSpectrum(6).getDetectorIDs().begin()), 7); TS_ASSERT_EQUALS(ws->readY(8)[3], 1.); - TS_ASSERT_EQUALS(ws->getSpectrum(8)->getSpectrumNo(), 9); - TS_ASSERT_EQUALS(*(ws->getSpectrum(8)->getDetectorIDs().begin()), 9); + TS_ASSERT_EQUALS(ws->getSpectrum(8).getSpectrumNo(), 9); + TS_ASSERT_EQUALS(*(ws->getSpectrum(8).getDetectorIDs().begin()), 9); TS_ASSERT_EQUALS(ws->readY(13)[1], 1.); - TS_ASSERT_EQUALS(ws->getSpectrum(13)->getSpectrumNo(), 14); - TS_ASSERT_EQUALS(*(ws->getSpectrum(13)->getDetectorIDs().begin()), 14); + TS_ASSERT_EQUALS(ws->getSpectrum(13).getSpectrumNo(), 14); + TS_ASSERT_EQUALS(*(ws->getSpectrum(13).getDetectorIDs().begin()), 14); TS_ASSERT_EQUALS(ws->readY(17)[1], 2.); - TS_ASSERT_EQUALS(ws->getSpectrum(17)->getSpectrumNo(), 18); - TS_ASSERT_EQUALS(*(ws->getSpectrum(17)->getDetectorIDs().begin()), 18); + TS_ASSERT_EQUALS(ws->getSpectrum(17).getSpectrumNo(), 18); + TS_ASSERT_EQUALS(*(ws->getSpectrum(17).getDetectorIDs().begin()), 18); TS_ASSERT_EQUALS(ws->readY(18)[1], 1.); - TS_ASSERT_EQUALS(ws->getSpectrum(18)->getSpectrumNo(), 19); - TS_ASSERT_EQUALS(*(ws->getSpectrum(18)->getDetectorIDs().begin()), 19); + TS_ASSERT_EQUALS(ws->getSpectrum(18).getSpectrumNo(), 19); + TS_ASSERT_EQUALS(*(ws->getSpectrum(18).getDetectorIDs().begin()), 19); TS_ASSERT_EQUALS(ws->readY(33)[2], 1.); - TS_ASSERT_EQUALS(ws->getSpectrum(33)->getSpectrumNo(), 34); - TS_ASSERT_EQUALS(*(ws->getSpectrum(33)->getDetectorIDs().begin()), 34); + TS_ASSERT_EQUALS(ws->getSpectrum(33).getSpectrumNo(), 34); + TS_ASSERT_EQUALS(*(ws->getSpectrum(33).getDetectorIDs().begin()), 34); TS_ASSERT_EQUALS(ws->readY(34)[1], 1.); - TS_ASSERT_EQUALS(ws->getSpectrum(34)->getSpectrumNo(), 35); - TS_ASSERT_EQUALS(*(ws->getSpectrum(34)->getDetectorIDs().begin()), 35); + TS_ASSERT_EQUALS(ws->getSpectrum(34).getSpectrumNo(), 35); + TS_ASSERT_EQUALS(*(ws->getSpectrum(34).getDetectorIDs().begin()), 35); TS_ASSERT_EQUALS(ws->readY(37)[3], 1.); TS_ASSERT_EQUALS(ws->readY(37)[4], 1.); - TS_ASSERT_EQUALS(ws->getSpectrum(37)->getSpectrumNo(), 38); - TS_ASSERT_EQUALS(*(ws->getSpectrum(37)->getDetectorIDs().begin()), 38); + TS_ASSERT_EQUALS(ws->getSpectrum(37).getSpectrumNo(), 38); + TS_ASSERT_EQUALS(*(ws->getSpectrum(37).getDetectorIDs().begin()), 38); - TS_ASSERT_EQUALS(ws->getSpectrum(1234)->getDetectorIDs().size(), 1); - TS_ASSERT_EQUALS(*(ws->getSpectrum(1234)->getDetectorIDs().begin()), 1235); + TS_ASSERT_EQUALS(ws->getSpectrum(1234).getDetectorIDs().size(), 1); + TS_ASSERT_EQUALS(*(ws->getSpectrum(1234).getDetectorIDs().begin()), 1235); - TS_ASSERT_EQUALS(ws->getSpectrum(1234)->getSpectrumNo(), 1235); - TS_ASSERT(ws->getSpectrum(1234)->hasDetectorID(1235)); + TS_ASSERT_EQUALS(ws->getSpectrum(1234).getSpectrumNo(), 1235); + TS_ASSERT(ws->getSpectrum(1234).hasDetectorID(1235)); const std::vector<Property *> &logs = ws->run().getLogData(); TS_ASSERT_EQUALS(logs.size(), 62); @@ -284,53 +284,53 @@ public: TS_ASSERT_EQUALS(ws->readX(0)[0], 5.); TS_ASSERT_EQUALS(ws->readX(0)[1], 4005.); TS_ASSERT_EQUALS(ws->readX(0)[2], 8005.); - TS_ASSERT_EQUALS(ws->getSpectrum(0)->getSpectrumNo(), 5); - TS_ASSERT_EQUALS(*(ws->getSpectrum(0)->getDetectorIDs().begin()), 5); + TS_ASSERT_EQUALS(ws->getSpectrum(0).getSpectrumNo(), 5); + TS_ASSERT_EQUALS(*(ws->getSpectrum(0).getDetectorIDs().begin()), 5); // these spectra are not loaded as above so their values are different // (occasionally 0) TSM_ASSERT_EQUALS("Total workspace spectra N13, index 1 is occasionally 1 ", ws->readY(5)[1], 1.); - TS_ASSERT_EQUALS(ws->getSpectrum(5)->getSpectrumNo(), 14); - TS_ASSERT_EQUALS(*(ws->getSpectrum(5)->getDetectorIDs().begin()), 14); + TS_ASSERT_EQUALS(ws->getSpectrum(5).getSpectrumNo(), 14); + TS_ASSERT_EQUALS(*(ws->getSpectrum(5).getDetectorIDs().begin()), 14); TS_ASSERT_EQUALS(ws->readY(6)[0], 0.); - TS_ASSERT_EQUALS(ws->getSpectrum(6)->getSpectrumNo(), 15); - TS_ASSERT_EQUALS(*(ws->getSpectrum(6)->getDetectorIDs().begin()), 15); + TS_ASSERT_EQUALS(ws->getSpectrum(6).getSpectrumNo(), 15); + TS_ASSERT_EQUALS(*(ws->getSpectrum(6).getDetectorIDs().begin()), 15); TS_ASSERT_EQUALS(ws->readY(8)[3], 0.); - TS_ASSERT_EQUALS(ws->getSpectrum(8)->getSpectrumNo(), 17); - TS_ASSERT_EQUALS(*(ws->getSpectrum(8)->getDetectorIDs().begin()), 17); + TS_ASSERT_EQUALS(ws->getSpectrum(8).getSpectrumNo(), 17); + TS_ASSERT_EQUALS(*(ws->getSpectrum(8).getDetectorIDs().begin()), 17); // look at the same values as the full loader above TS_ASSERT_EQUALS(ws->readY(13 - 8)[1], 1.); - TS_ASSERT_EQUALS(ws->getSpectrum(13 - 8)->getSpectrumNo(), 14); - TS_ASSERT_EQUALS(*(ws->getSpectrum(13 - 8)->getDetectorIDs().begin()), 14); + TS_ASSERT_EQUALS(ws->getSpectrum(13 - 8).getSpectrumNo(), 14); + TS_ASSERT_EQUALS(*(ws->getSpectrum(13 - 8).getDetectorIDs().begin()), 14); TS_ASSERT_EQUALS(ws->readY(17 - 8)[1], 2.); - TS_ASSERT_EQUALS(ws->getSpectrum(17 - 8)->getSpectrumNo(), 18); - TS_ASSERT_EQUALS(*(ws->getSpectrum(17 - 8)->getDetectorIDs().begin()), 18); + TS_ASSERT_EQUALS(ws->getSpectrum(17 - 8).getSpectrumNo(), 18); + TS_ASSERT_EQUALS(*(ws->getSpectrum(17 - 8).getDetectorIDs().begin()), 18); TS_ASSERT_EQUALS(ws->readY(18 - 8)[1], 1.); - TS_ASSERT_EQUALS(ws->getSpectrum(18 - 8)->getSpectrumNo(), 19); - TS_ASSERT_EQUALS(*(ws->getSpectrum(18 - 8)->getDetectorIDs().begin()), 19); + TS_ASSERT_EQUALS(ws->getSpectrum(18 - 8).getSpectrumNo(), 19); + TS_ASSERT_EQUALS(*(ws->getSpectrum(18 - 8).getDetectorIDs().begin()), 19); // look at the same values as the full loader above TS_ASSERT_EQUALS(ws->readY(33 - 21)[2], 1.); - TS_ASSERT_EQUALS(ws->getSpectrum(33 - 21)->getSpectrumNo(), 34); - TS_ASSERT_EQUALS(*(ws->getSpectrum(33 - 21)->getDetectorIDs().begin()), 34); + TS_ASSERT_EQUALS(ws->getSpectrum(33 - 21).getSpectrumNo(), 34); + TS_ASSERT_EQUALS(*(ws->getSpectrum(33 - 21).getDetectorIDs().begin()), 34); TS_ASSERT_EQUALS(ws->readY(34 - 21)[1], 1.); - TS_ASSERT_EQUALS(ws->getSpectrum(34 - 21)->getSpectrumNo(), 35); - TS_ASSERT_EQUALS(*(ws->getSpectrum(34 - 21)->getDetectorIDs().begin()), 35); + TS_ASSERT_EQUALS(ws->getSpectrum(34 - 21).getSpectrumNo(), 35); + TS_ASSERT_EQUALS(*(ws->getSpectrum(34 - 21).getDetectorIDs().begin()), 35); TS_ASSERT_EQUALS(ws->readY(37 - 23)[3], 1.); TS_ASSERT_EQUALS(ws->readY(37 - 23)[4], 1.); - TS_ASSERT_EQUALS(ws->getSpectrum(37 - 23)->getSpectrumNo(), 38); - TS_ASSERT_EQUALS(*(ws->getSpectrum(37 - 23)->getDetectorIDs().begin()), 38); + TS_ASSERT_EQUALS(ws->getSpectrum(37 - 23).getSpectrumNo(), 38); + TS_ASSERT_EQUALS(*(ws->getSpectrum(37 - 23).getDetectorIDs().begin()), 38); - TS_ASSERT_EQUALS(ws->getSpectrum(0)->getSpectrumNo(), 5); - TS_ASSERT_EQUALS(*(ws->getSpectrum(0)->getDetectorIDs().begin()), 5); - TS_ASSERT(ws->getSpectrum(0)->hasDetectorID(5)); + TS_ASSERT_EQUALS(ws->getSpectrum(0).getSpectrumNo(), 5); + TS_ASSERT_EQUALS(*(ws->getSpectrum(0).getDetectorIDs().begin()), 5); + TS_ASSERT(ws->getSpectrum(0).hasDetectorID(5)); - TS_ASSERT_EQUALS(ws->getSpectrum(1)->getSpectrumNo(), 10); - TS_ASSERT_EQUALS(*(ws->getSpectrum(1)->getDetectorIDs().begin()), 10); - TS_ASSERT(ws->getSpectrum(1)->hasDetectorID(10)); + TS_ASSERT_EQUALS(ws->getSpectrum(1).getSpectrumNo(), 10); + TS_ASSERT_EQUALS(*(ws->getSpectrum(1).getDetectorIDs().begin()), 10); + TS_ASSERT(ws->getSpectrum(1).hasDetectorID(10)); Mantid::specnum_t offset; auto spectNum2WSInd = ws->getSpectrumToWorkspaceIndexVector(offset); @@ -343,9 +343,9 @@ public: TS_ASSERT_EQUALS(i, spectNum2WSInd[Sample[i] + offset]); } - TS_ASSERT_EQUALS(ws->getSpectrum(14)->getSpectrumNo(), 38); - TS_ASSERT_EQUALS(*(ws->getSpectrum(14)->getDetectorIDs().begin()), 38); - TS_ASSERT(ws->getSpectrum(14)->hasDetectorID(38)); + TS_ASSERT_EQUALS(ws->getSpectrum(14).getSpectrumNo(), 38); + TS_ASSERT_EQUALS(*(ws->getSpectrum(14).getDetectorIDs().begin()), 38); + TS_ASSERT(ws->getSpectrum(14).hasDetectorID(38)); AnalysisDataService::Instance().remove("outWS"); } @@ -378,11 +378,11 @@ public: // look at the same values as the full/partial loader above TS_ASSERT_EQUALS(ws->readY(13 - 9)[1], 1.); - TS_ASSERT_EQUALS(ws->getSpectrum(13 - 9)->getSpectrumNo(), 14); + TS_ASSERT_EQUALS(ws->getSpectrum(13 - 9).getSpectrumNo(), 14); TS_ASSERT_EQUALS(ws->readY(17 - 9)[1], 2.); - TS_ASSERT_EQUALS(ws->getSpectrum(17 - 9)->getSpectrumNo(), 18); + TS_ASSERT_EQUALS(ws->getSpectrum(17 - 9).getSpectrumNo(), 18); TS_ASSERT_EQUALS(ws->readY(18 - 9)[1], 1.); - TS_ASSERT_EQUALS(ws->getSpectrum(18 - 9)->getSpectrumNo(), 19); + TS_ASSERT_EQUALS(ws->getSpectrum(18 - 9).getSpectrumNo(), 19); Mantid::specnum_t offset; auto spectNum2WSInd = ws->getSpectrumToWorkspaceIndexVector(offset); @@ -566,50 +566,50 @@ public: // spectrum with ID 5 is now spectrum N 3 as 2 monitors TS_ASSERT_EQUALS(ws->readY(5 - 2)[1], 1.); - TS_ASSERT_EQUALS(ws->getSpectrum(5 - 2)->getSpectrumNo(), 6); - TS_ASSERT_EQUALS(*(ws->getSpectrum(5 - 2)->getDetectorIDs().begin()), 6); + TS_ASSERT_EQUALS(ws->getSpectrum(5 - 2).getSpectrumNo(), 6); + TS_ASSERT_EQUALS(*(ws->getSpectrum(5 - 2).getDetectorIDs().begin()), 6); // spectrum with ID 7 is now spectrum N 4 TS_ASSERT_EQUALS(ws->readY(6 - 2)[0], 1.); - TS_ASSERT_EQUALS(ws->getSpectrum(6 - 2)->getSpectrumNo(), 7); - TS_ASSERT_EQUALS(*(ws->getSpectrum(6 - 2)->getDetectorIDs().begin()), 7); + TS_ASSERT_EQUALS(ws->getSpectrum(6 - 2).getSpectrumNo(), 7); + TS_ASSERT_EQUALS(*(ws->getSpectrum(6 - 2).getDetectorIDs().begin()), 7); // TS_ASSERT_EQUALS(ws->readY(8 - 2)[3], 1.); // spectrum with ID 9 is now spectrum N 6 - TS_ASSERT_EQUALS(ws->getSpectrum(8 - 2)->getSpectrumNo(), 9); - TS_ASSERT_EQUALS(*(ws->getSpectrum(8 - 2)->getDetectorIDs().begin()), 9); + TS_ASSERT_EQUALS(ws->getSpectrum(8 - 2).getSpectrumNo(), 9); + TS_ASSERT_EQUALS(*(ws->getSpectrum(8 - 2).getDetectorIDs().begin()), 9); // spectrum with ID 14 is now spectrum N 11 TS_ASSERT_EQUALS(ws->readY(13 - 2)[1], 1.); - TS_ASSERT_EQUALS(ws->getSpectrum(13 - 2)->getSpectrumNo(), 14); - TS_ASSERT_EQUALS(*(ws->getSpectrum(13 - 2)->getDetectorIDs().begin()), 14); + TS_ASSERT_EQUALS(ws->getSpectrum(13 - 2).getSpectrumNo(), 14); + TS_ASSERT_EQUALS(*(ws->getSpectrum(13 - 2).getDetectorIDs().begin()), 14); // spectrum with ID 18 is now spectrum N 15 TS_ASSERT_EQUALS(ws->readY(17 - 2)[1], 2.); - TS_ASSERT_EQUALS(ws->getSpectrum(17 - 2)->getSpectrumNo(), 18); - TS_ASSERT_EQUALS(*(ws->getSpectrum(17 - 2)->getDetectorIDs().begin()), 18); + TS_ASSERT_EQUALS(ws->getSpectrum(17 - 2).getSpectrumNo(), 18); + TS_ASSERT_EQUALS(*(ws->getSpectrum(17 - 2).getDetectorIDs().begin()), 18); // spectrum with ID 19 is now spectrum N 16 TS_ASSERT_EQUALS(ws->readY(18 - 2)[1], 1.); - TS_ASSERT_EQUALS(ws->getSpectrum(18 - 2)->getSpectrumNo(), 19); - TS_ASSERT_EQUALS(*(ws->getSpectrum(18 - 2)->getDetectorIDs().begin()), 19); + TS_ASSERT_EQUALS(ws->getSpectrum(18 - 2).getSpectrumNo(), 19); + TS_ASSERT_EQUALS(*(ws->getSpectrum(18 - 2).getDetectorIDs().begin()), 19); TS_ASSERT_EQUALS(ws->readY(33 - 2)[2], 1.); - TS_ASSERT_EQUALS(ws->getSpectrum(33 - 2)->getSpectrumNo(), 34); - TS_ASSERT_EQUALS(*(ws->getSpectrum(33 - 2)->getDetectorIDs().begin()), 34); + TS_ASSERT_EQUALS(ws->getSpectrum(33 - 2).getSpectrumNo(), 34); + TS_ASSERT_EQUALS(*(ws->getSpectrum(33 - 2).getDetectorIDs().begin()), 34); // TS_ASSERT_EQUALS(ws->readY(34 - 2)[1], 1.); - TS_ASSERT_EQUALS(ws->getSpectrum(34 - 2)->getSpectrumNo(), 35); - TS_ASSERT_EQUALS(*(ws->getSpectrum(34 - 2)->getDetectorIDs().begin()), 35); + TS_ASSERT_EQUALS(ws->getSpectrum(34 - 2).getSpectrumNo(), 35); + TS_ASSERT_EQUALS(*(ws->getSpectrum(34 - 2).getDetectorIDs().begin()), 35); TS_ASSERT_EQUALS(ws->readY(37 - 2)[3], 1.); TS_ASSERT_EQUALS(ws->readY(37 - 2)[4], 1.); - TS_ASSERT_EQUALS(ws->getSpectrum(37 - 2)->getSpectrumNo(), 38); - TS_ASSERT_EQUALS(*(ws->getSpectrum(37 - 2)->getDetectorIDs().begin()), 38); + TS_ASSERT_EQUALS(ws->getSpectrum(37 - 2).getSpectrumNo(), 38); + TS_ASSERT_EQUALS(*(ws->getSpectrum(37 - 2).getDetectorIDs().begin()), 38); - TS_ASSERT_EQUALS(ws->getSpectrum(1234 - 2)->getDetectorIDs().size(), 1); - TS_ASSERT_EQUALS(*(ws->getSpectrum(1234 - 2)->getDetectorIDs().begin()), + TS_ASSERT_EQUALS(ws->getSpectrum(1234 - 2).getDetectorIDs().size(), 1); + TS_ASSERT_EQUALS(*(ws->getSpectrum(1234 - 2).getDetectorIDs().begin()), 1235); - TS_ASSERT_EQUALS(ws->getSpectrum(1234 - 2)->getSpectrumNo(), 1235); - TS_ASSERT(ws->getSpectrum(1234 - 2)->hasDetectorID(1235)); + TS_ASSERT_EQUALS(ws->getSpectrum(1234 - 2).getSpectrumNo(), 1235); + TS_ASSERT(ws->getSpectrum(1234 - 2).hasDetectorID(1235)); const std::vector<Property *> &logs = ws->run().getLogData(); TS_ASSERT_EQUALS(logs.size(), 62); @@ -698,7 +698,7 @@ public: TS_ASSERT_DELTA(105, detWS0->readX(1)[1], 1e-08); TS_ASSERT_DELTA(2, detWS0->readY(1)[1], 1e-08); TS_ASSERT_DELTA(M_SQRT2, detWS0->readE(1)[1], 1e-08); - TS_ASSERT_EQUALS(detWS0->getSpectrum(0)->getSpectrumNo(), 4); + TS_ASSERT_EQUALS(detWS0->getSpectrum(0).getSpectrumNo(), 4); auto monWS0 = boost::dynamic_pointer_cast<MatrixWorkspace>(monGroup->getItem(0)); @@ -707,8 +707,8 @@ public: TS_ASSERT_DELTA(105, monWS0->readX(1)[1], 1e-08); TS_ASSERT_DELTA(12563.0, monWS0->readY(0)[1], 1e-08); TS_ASSERT_DELTA(std::sqrt(12563.0), monWS0->readE(0)[1], 1e-08); - TS_ASSERT_EQUALS(monWS0->getSpectrum(0)->getSpectrumNo(), 1); - TS_ASSERT_EQUALS(monWS0->getSpectrum(2)->getSpectrumNo(), 3); + TS_ASSERT_EQUALS(monWS0->getSpectrum(0).getSpectrumNo(), 1); + TS_ASSERT_EQUALS(monWS0->getSpectrum(2).getSpectrumNo(), 3); auto monWS1 = boost::dynamic_pointer_cast<MatrixWorkspace>(monGroup->getItem(1)); @@ -717,8 +717,8 @@ public: TS_ASSERT_DELTA(105, monWS1->readX(1)[1], 1e-08); TS_ASSERT_DELTA(12595.0, monWS1->readY(0)[1], 1e-08); TS_ASSERT_DELTA(std::sqrt(12595.0), monWS1->readE(0)[1], 1e-08); - TS_ASSERT_EQUALS(monWS1->getSpectrum(0)->getSpectrumNo(), 1); - TS_ASSERT_EQUALS(monWS1->getSpectrum(2)->getSpectrumNo(), 3); + TS_ASSERT_EQUALS(monWS1->getSpectrum(0).getSpectrumNo(), 1); + TS_ASSERT_EQUALS(monWS1->getSpectrum(2).getSpectrumNo(), 3); // Same number of logs const auto &monPeriod1Run = monWS0->run(); @@ -829,10 +829,10 @@ public: // detecor ID TSM_ASSERT_EQUALS( "Detector at WS index 142 should have a spectrum number of 143", 143, - ws->getSpectrum(142)->getSpectrumNo()); + ws->getSpectrum(142).getSpectrumNo()); TSM_ASSERT_EQUALS( "Detector at WS index 143 should have a spectrum number of 144", 144, - ws->getSpectrum(143)->getSpectrumNo()); + ws->getSpectrum(143).getSpectrumNo()); TSM_ASSERT_EQUALS( "Detector at WS index 142 should have a detector ID of 143", 143, ws->getDetector(142)->getID()); @@ -914,7 +914,7 @@ public: // detecor ID (for some sample spectra) TSM_ASSERT_EQUALS( "Detector at WS index 24 should have a spectrum number of 73", 73, - ws->getSpectrum(24)->getSpectrumNo()); + ws->getSpectrum(24).getSpectrumNo()); TSM_ASSERT_EQUALS("Detector at WS index 24 should have a detector ID of 73", 73, ws->getDetector(24)->getID()); @@ -979,10 +979,10 @@ public: // detecor ID TSM_ASSERT_EQUALS( "Detector at WS index 142 should have a spectrum number of 143", 143, - ws->getSpectrum(142)->getSpectrumNo()); + ws->getSpectrum(142).getSpectrumNo()); TSM_ASSERT_EQUALS( "Monitor at WS index 144 should have a spectrum number of 145", 145, - ws->getSpectrum(144)->getSpectrumNo()); + ws->getSpectrum(144).getSpectrumNo()); TSM_ASSERT_EQUALS( "Detector at WS index 142 should have a detector ID of 143", 143, ws->getDetector(142)->getID()); @@ -1072,13 +1072,13 @@ public: // detecor ID (for some sample spectra) TSM_ASSERT_EQUALS( "Detector at WS index 24 should have a spectrum number of 73", 73, - ws->getSpectrum(24)->getSpectrumNo()); + ws->getSpectrum(24).getSpectrumNo()); TSM_ASSERT_EQUALS("Detector at WS index 24 should have a detector ID of 73", 73, ws->getDetector(24)->getID()); TSM_ASSERT_EQUALS( "Monitor at WS index 25 should have a spectrum number of 145", 145, - ws->getSpectrum(25)->getSpectrumNo()); + ws->getSpectrum(25).getSpectrumNo()); TSM_ASSERT_EQUALS( "Detector at WS index 25 should have a detector ID of 145", 145, ws->getDetector(25)->getID()); @@ -1165,10 +1165,10 @@ public: // detecor ID TSM_ASSERT_EQUALS( "Detector at WS index 142 should have a spectrum number of 143", 143, - ws->getSpectrum(142)->getSpectrumNo()); + ws->getSpectrum(142).getSpectrumNo()); TSM_ASSERT_EQUALS( "Detector at WS index 143 should have a spectrum number of 144", 144, - ws->getSpectrum(143)->getSpectrumNo()); + ws->getSpectrum(143).getSpectrumNo()); TSM_ASSERT_EQUALS( "Detector at WS index 142 should have a detector ID of 143", 143, ws->getDetector(142)->getID()); @@ -1178,7 +1178,7 @@ public: TSM_ASSERT_EQUALS( "Monitor at WS index 0 should have a spectrum number of 145", 145, - mon_ws->getSpectrum(0)->getSpectrumNo()); + mon_ws->getSpectrum(0).getSpectrumNo()); TSM_ASSERT_EQUALS("Monitor at WS index 0 should have a detector ID of 145", 145, mon_ws->getDetector(0)->getID()); @@ -1264,14 +1264,14 @@ public: TSM_ASSERT_EQUALS( "Detector at WS index 2 should have a spectrum number of 51", 51, - ws->getSpectrum(2)->getSpectrumNo()); + ws->getSpectrum(2).getSpectrumNo()); TSM_ASSERT_EQUALS("Detector at WS index 2 should have a detector ID of 51", 51, ws->getDetector(2)->getID()); // Test the monitor workspace TSM_ASSERT_EQUALS( "Detector at WS index 0 should have a spectrum number of 145", 145, - mon_ws->getSpectrum(0)->getSpectrumNo()); + mon_ws->getSpectrum(0).getSpectrumNo()); TSM_ASSERT_EQUALS("Detector at WS index 0 should have a detector ID of 145", 145, mon_ws->getDetector(0)->getID()); @@ -1357,14 +1357,14 @@ public: TSM_ASSERT_EQUALS( "Detector at WS index 2 should have a spectrum number of 51", 51, - ws->getSpectrum(2)->getSpectrumNo()); + ws->getSpectrum(2).getSpectrumNo()); TSM_ASSERT_EQUALS("Detector at WS index 2 should have a detector ID of 51", 51, ws->getDetector(2)->getID()); // Test the monitor workspace TSM_ASSERT_EQUALS( "Detector at WS index 2 should have a spectrum number of 147", 147, - mon_ws->getSpectrum(2)->getSpectrumNo()); + mon_ws->getSpectrum(2).getSpectrumNo()); TSM_ASSERT_EQUALS("Detector at WS index 2 should have a detector ID of 147", 147, mon_ws->getDetector(2)->getID()); @@ -1406,12 +1406,12 @@ public: TSM_ASSERT_EQUALS( "Monitor at WS index 0 should have a spectrum number of 145", 145, - ws->getSpectrum(0)->getSpectrumNo()); + ws->getSpectrum(0).getSpectrumNo()); TSM_ASSERT_EQUALS("Monitor at WS index 0 should have a detector ID of 145", 145, ws->getDetector(0)->getID()); TSM_ASSERT_EQUALS( "Monitor at WS index 1 should have a spectrum number of 147", 147, - ws->getSpectrum(1)->getSpectrumNo()); + ws->getSpectrum(1).getSpectrumNo()); TSM_ASSERT_EQUALS("Monitor at WS index 1 should have a detector ID of 147", 147, ws->getDetector(1)->getID()); @@ -1484,7 +1484,7 @@ public: TSM_ASSERT_EQUALS( "Detector at WS index 2 should have a spectrum number of 52", 52, - ws->getSpectrum(2)->getSpectrumNo()); + ws->getSpectrum(2).getSpectrumNo()); TSM_ASSERT_EQUALS("Detector at WS index 2 should have a detector ID of 52", 52, ws->getDetector(2)->getID()); @@ -1532,18 +1532,18 @@ public: // Check some samples TSM_ASSERT_EQUALS( "Detector at WS index 2 should have a spectrum number of 5", 5, - ws->getSpectrum(2)->getSpectrumNo()); + ws->getSpectrum(2).getSpectrumNo()); TSM_ASSERT_EQUALS("Detector at WS index 2 should have a detector ID of 5", 5, ws->getDetector(2)->getID()); TSM_ASSERT_EQUALS( "Detector at WS index 3 should have a spectrum number of 6", 6, - ws->getSpectrum(3)->getSpectrumNo()); + ws->getSpectrum(3).getSpectrumNo()); TSM_ASSERT_EQUALS("Detector at WS index 3 should have a detector ID of 6", 6, ws->getDetector(3)->getID()); TSM_ASSERT_EQUALS( "Detector at WS index 0 should have a spectrum number of 2", 2, - mon_ws->getSpectrum(0)->getSpectrumNo()); + mon_ws->getSpectrum(0).getSpectrumNo()); TSM_ASSERT_EQUALS("Detector at WS index 0 should have a detector ID of 2", 2, mon_ws->getDetector(0)->getID()); diff --git a/Framework/DataHandling/test/LoadInstrumentTest.h b/Framework/DataHandling/test/LoadInstrumentTest.h index 589740006bdb901e9f08379952b68aa76f821e25..4e138ccff4102d1498953b41a90103517c0e7506 100644 --- a/Framework/DataHandling/test/LoadInstrumentTest.h +++ b/Framework/DataHandling/test/LoadInstrumentTest.h @@ -71,8 +71,8 @@ public: // put this workspace in the data service TS_ASSERT_THROWS_NOTHING(AnalysisDataService::Instance().add(wsName, ws2D)); // We want to test id the spectra mapping changes - TS_ASSERT_EQUALS(ws2D->getSpectrum(0)->getSpectrumNo(), 1); - TS_ASSERT_EQUALS(ws2D->getSpectrum(256)->getSpectrumNo(), 257); + TS_ASSERT_EQUALS(ws2D->getSpectrum(0).getSpectrumNo(), 1); + TS_ASSERT_EQUALS(ws2D->getSpectrum(256).getSpectrumNo(), 257); TS_ASSERT_EQUALS(ws2D->getNumberHistograms(), 2584); loader.setPropertyValue("Filename", "HET_Definition.xml"); @@ -138,7 +138,7 @@ public: TS_ASSERT_EQUALS(output->getAxis(1)->spectraNo(256), 257); TS_ASSERT_EQUALS(output->getAxis(1)->spectraNo(257), 258); - auto ids_from_map = output->getSpectrum(257)->getDetectorIDs(); + auto ids_from_map = output->getSpectrum(257).getDetectorIDs(); IDetector_const_sptr det_from_ws = output->getDetector(257); TS_ASSERT_EQUALS(ids_from_map.size(), 1); TS_ASSERT_EQUALS(*ids_from_map.begin(), 602); diff --git a/Framework/DataHandling/test/LoadMappingTableTest.h b/Framework/DataHandling/test/LoadMappingTableTest.h index ccf156aca854a14821ea5490303427521edbab16..238703c4e176685aa28c0dc243659f0e9c72618c 100644 --- a/Framework/DataHandling/test/LoadMappingTableTest.h +++ b/Framework/DataHandling/test/LoadMappingTableTest.h @@ -62,17 +62,17 @@ public: TS_ASSERT(loader.isExecuted()); // Test one to one mapping, for example spectra 6 has only 1 pixel - TS_ASSERT_EQUALS(work1->getSpectrum(6)->getDetectorIDs().size(), + TS_ASSERT_EQUALS(work1->getSpectrum(6).getDetectorIDs().size(), 1); // rummap.ndet(6),1); // Test one to many mapping, for example 10 pixels contribute to spectra // 2084 (workspace index 2083) - TS_ASSERT_EQUALS(work1->getSpectrum(2083)->getDetectorIDs().size(), + TS_ASSERT_EQUALS(work1->getSpectrum(2083).getDetectorIDs().size(), 10); // map.ndet(2084),10); // Check the id number of all pixels contributing std::set<detid_t> detectorgroup; - detectorgroup = work1->getSpectrum(2083)->getDetectorIDs(); + detectorgroup = work1->getSpectrum(2083).getDetectorIDs(); std::set<detid_t>::const_iterator it; int pixnum = 101191; for (it = detectorgroup.begin(); it != detectorgroup.end(); it++) diff --git a/Framework/DataHandling/test/LoadMuonNexus2Test.h b/Framework/DataHandling/test/LoadMuonNexus2Test.h index 061e768cebac77130a1ec8031ba04a31d4744951..7ad93d83204d1ee917c0affba51ddcdd02cdaafa 100644 --- a/Framework/DataHandling/test/LoadMuonNexus2Test.h +++ b/Framework/DataHandling/test/LoadMuonNexus2Test.h @@ -36,9 +36,9 @@ public: TS_ASSERT_EQUALS(output->getNumberHistograms(), 192); // Test one to one mapping, for example spectra 6 has only 1 pixel - TS_ASSERT_EQUALS(output->getSpectrum(6)->getDetectorIDs().size(), 1); + TS_ASSERT_EQUALS(output->getSpectrum(6).getDetectorIDs().size(), 1); - auto detectorgroup = output->getSpectrum(99)->getDetectorIDs(); + auto detectorgroup = output->getSpectrum(99).getDetectorIDs(); TS_ASSERT_EQUALS(detectorgroup.size(), 1); TS_ASSERT_EQUALS(*detectorgroup.begin(), 100); } diff --git a/Framework/DataHandling/test/LoadNexusMonitorsTest.h b/Framework/DataHandling/test/LoadNexusMonitorsTest.h index cdfc3eb5885614103ae9babd04bf4c5305ae5236..316d5e39a7b23bed334aec9546890aa96e85b071 100644 --- a/Framework/DataHandling/test/LoadNexusMonitorsTest.h +++ b/Framework/DataHandling/test/LoadNexusMonitorsTest.h @@ -80,8 +80,8 @@ public: // Correct number of monitors found TS_ASSERT_EQUALS(WS->getNumberHistograms(), 2); // Verify number of events loaded - TS_ASSERT_EQUALS(WS->getEventList(0).getNumberEvents(), 15000); - TS_ASSERT_EQUALS(WS->getEventList(1).getNumberEvents(), 15000); + TS_ASSERT_EQUALS(WS->getSpectrum(0).getNumberEvents(), 15000); + TS_ASSERT_EQUALS(WS->getSpectrum(1).getNumberEvents(), 15000); } void testOldFile() { diff --git a/Framework/DataHandling/test/LoadNexusProcessedTest.h b/Framework/DataHandling/test/LoadNexusProcessedTest.h index 11878f304d3ac52660c5b922cc4f3635a501bed3..e3d5d282cdc129a51271c8480774fe63d1d0cad0 100644 --- a/Framework/DataHandling/test/LoadNexusProcessedTest.h +++ b/Framework/DataHandling/test/LoadNexusProcessedTest.h @@ -133,8 +133,7 @@ public: // Test spectrum numbers are as expected size_t index(0); for (auto spectrum : {3, 4, 5}) { - TS_ASSERT_EQUALS(matrix_ws->getSpectrum(index)->getSpectrumNo(), - spectrum); + TS_ASSERT_EQUALS(matrix_ws->getSpectrum(index).getSpectrumNo(), spectrum); index++; } doHistoryTest(matrix_ws); @@ -173,8 +172,7 @@ public: // Test spectrum numbers size_t index(0); for (auto spectrum : {2, 3, 4, 5}) { - TS_ASSERT_EQUALS(matrix_ws->getSpectrum(index)->getSpectrumNo(), - spectrum); + TS_ASSERT_EQUALS(matrix_ws->getSpectrum(index).getSpectrumNo(), spectrum); index++; } @@ -216,8 +214,7 @@ public: // Test spectrum numbers size_t index(0); for (auto spectrum : {2, 3, 4, 5, 6}) { - TS_ASSERT_EQUALS(matrix_ws->getSpectrum(index)->getSpectrumNo(), - spectrum); + TS_ASSERT_EQUALS(matrix_ws->getSpectrum(index).getSpectrumNo(), spectrum); index++; } @@ -389,15 +386,15 @@ public: TS_ASSERT_EQUALS(ws->readX(0).size(), 100); for (size_t wi = 0; wi < 5; wi++) { - const EventList &el = ws->getEventList(wi); + const EventList &el = ws->getSpectrum(wi); TS_ASSERT_EQUALS(el.getEventType(), type); TS_ASSERT(el.hasDetectorID(detid_t(wi + 1) * 10)); } - TS_ASSERT_EQUALS(ws->getEventList(0).getNumberEvents(), 300); - TS_ASSERT_EQUALS(ws->getEventList(1).getNumberEvents(), 100); - TS_ASSERT_EQUALS(ws->getEventList(2).getNumberEvents(), 200); - TS_ASSERT_EQUALS(ws->getEventList(3).getNumberEvents(), 0); - TS_ASSERT_EQUALS(ws->getEventList(4).getNumberEvents(), 100); + TS_ASSERT_EQUALS(ws->getSpectrum(0).getNumberEvents(), 300); + TS_ASSERT_EQUALS(ws->getSpectrum(1).getNumberEvents(), 100); + TS_ASSERT_EQUALS(ws->getSpectrum(2).getNumberEvents(), 200); + TS_ASSERT_EQUALS(ws->getSpectrum(3).getNumberEvents(), 0); + TS_ASSERT_EQUALS(ws->getSpectrum(4).getNumberEvents(), 100); // Do the comparison algo to check that they really are the same origWS->sortAll(TOF_SORT, NULL); @@ -1169,7 +1166,7 @@ private: EventWorkspace_sptr ws = WorkspaceCreationHelper::CreateGroupedEventWorkspace(groups, 30, 1.0); - ws->getEventList(4).clear(); + ws->getSpectrum(4).clear(); TS_ASSERT_EQUALS(ws->getNumberHistograms(), groups.size()); @@ -1249,8 +1246,8 @@ private: // Check spectra in loaded workspace MatrixWorkspace_sptr outputWs = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>("output"); - TS_ASSERT_EQUALS(1, outputWs->getSpectrum(0)->getSpectrumNo()); - TS_ASSERT_EQUALS(2, outputWs->getSpectrum(1)->getSpectrumNo()); + TS_ASSERT_EQUALS(1, outputWs->getSpectrum(0).getSpectrumNo()); + TS_ASSERT_EQUALS(2, outputWs->getSpectrum(1).getSpectrumNo()); TS_ASSERT_EQUALS(inputWs->readX(0), outputWs->readX(0)); TS_ASSERT_EQUALS(inputWs->readX(1), outputWs->readX(1)); TS_ASSERT_EQUALS(inputWs->readY(0), outputWs->readY(0)); diff --git a/Framework/DataHandling/test/LoadPreNexusMonitorsTest.h b/Framework/DataHandling/test/LoadPreNexusMonitorsTest.h index b7b437eca4bde4672847e5628621a01cc8a8d38b..020501609fa26a38e0ea25c97960aabb5336e91b 100644 --- a/Framework/DataHandling/test/LoadPreNexusMonitorsTest.h +++ b/Framework/DataHandling/test/LoadPreNexusMonitorsTest.h @@ -59,7 +59,7 @@ public: TS_ASSERT_EQUALS(ws->dataY(1)[3424], 858); for (int i = 0; i < 3; ++i) { - TS_ASSERT_EQUALS(*ws->getSpectrum(i)->getDetectorIDs().begin(), + TS_ASSERT_EQUALS(*ws->getSpectrum(i).getDetectorIDs().begin(), -1 * (i + 1)); } diff --git a/Framework/DataHandling/test/LoadRaw3Test.h b/Framework/DataHandling/test/LoadRaw3Test.h index 25a6d9f26b22794cd6e74ae901d4c61c2a7970f7..171d4720dc481243200dc16e5c6d05f8cb0b062d 100644 --- a/Framework/DataHandling/test/LoadRaw3Test.h +++ b/Framework/DataHandling/test/LoadRaw3Test.h @@ -132,17 +132,17 @@ public: // Tests to check that spectra-detector mapping is done correctly //---------------------------------------------------------------------- // Test one to one mapping, for example spectra 6 has only 1 pixel - TS_ASSERT_EQUALS(output2D->getSpectrum(6)->getDetectorIDs().size(), + TS_ASSERT_EQUALS(output2D->getSpectrum(6).getDetectorIDs().size(), 1); // rummap.ndet(6),1); // Test one to many mapping, for example 10 pixels contribute to spectra // 2084 (workspace index 2083) - TS_ASSERT_EQUALS(output2D->getSpectrum(2083)->getDetectorIDs().size(), + TS_ASSERT_EQUALS(output2D->getSpectrum(2083).getDetectorIDs().size(), 10); // map.ndet(2084),10); // Check the id number of all pixels contributing std::set<detid_t> detectorgroup; - detectorgroup = output2D->getSpectrum(2083)->getDetectorIDs(); + detectorgroup = output2D->getSpectrum(2083).getDetectorIDs(); std::set<detid_t>::const_iterator it; int pixnum = 101191; for (it = detectorgroup.begin(); it != detectorgroup.end(); it++) @@ -258,11 +258,11 @@ public: boost::dynamic_pointer_cast<Workspace2D>(output); TS_ASSERT_EQUALS(output2D->getNumberHistograms(), 6); - TS_ASSERT_EQUALS(output2D->getSpectrum(0)->getSpectrumNo(), 5); - TS_ASSERT_EQUALS(output2D->getSpectrum(1)->getSpectrumNo(), 6); - TS_ASSERT(output2D->getSpectrum(1)->hasDetectorID(4103)); - TS_ASSERT_EQUALS(output2D->getSpectrum(5)->getSpectrumNo(), 10); - TS_ASSERT(output2D->getSpectrum(5)->hasDetectorID(4107)); + TS_ASSERT_EQUALS(output2D->getSpectrum(0).getSpectrumNo(), 5); + TS_ASSERT_EQUALS(output2D->getSpectrum(1).getSpectrumNo(), 6); + TS_ASSERT(output2D->getSpectrum(1).hasDetectorID(4103)); + TS_ASSERT_EQUALS(output2D->getSpectrum(5).getSpectrumNo(), 10); + TS_ASSERT(output2D->getSpectrum(5).hasDetectorID(4107)); AnalysisDataService::Instance().remove(outWS); } @@ -495,8 +495,8 @@ public: TS_ASSERT_EQUALS(monitoroutput2D->getNumberHistograms(), 4); - TS_ASSERT(monitoroutput2D->getSpectrum(0)->hasDetectorID(601)); - TS_ASSERT(monitoroutput2D->getSpectrum(1)->hasDetectorID(602)); + TS_ASSERT(monitoroutput2D->getSpectrum(0).hasDetectorID(601)); + TS_ASSERT(monitoroutput2D->getSpectrum(1).hasDetectorID(602)); // Check two X vectors are the same TS_ASSERT((output2D->dataX(95)) == (output2D->dataX(1730))); @@ -559,17 +559,17 @@ public: // Tests to check that spectra-detector mapping is done correctly //---------------------------------------------------------------------- // Test one to one mapping, for example spectra 6 has only 1 pixel - TS_ASSERT_EQUALS(output2D->getSpectrum(6)->getDetectorIDs().size(), + TS_ASSERT_EQUALS(output2D->getSpectrum(6).getDetectorIDs().size(), 1); // rummap.ndet(6),1); // Test one to many mapping, for example 10 pixels contribute to spectra // 2084 (workspace index 2083) - TS_ASSERT_EQUALS(output2D->getSpectrum(2079)->getDetectorIDs().size(), + TS_ASSERT_EQUALS(output2D->getSpectrum(2079).getDetectorIDs().size(), 10); // map.ndet(2084),10); // Check the id number of all pixels contributing std::set<detid_t> detectorgroup; - detectorgroup = output2D->getSpectrum(2079)->getDetectorIDs(); + detectorgroup = output2D->getSpectrum(2079).getDetectorIDs(); std::set<detid_t>::const_iterator it; int pixnum = 101191; for (it = detectorgroup.begin(); it != detectorgroup.end(); it++) @@ -759,15 +759,14 @@ public: ads.retrieveWS<MatrixWorkspace>(outputWSName + "_1"); TS_ASSERT_EQUALS(1, output1->getNumberHistograms()); - ISpectrum *spectrum2(NULL); - TS_ASSERT_THROWS_NOTHING(spectrum2 = output1->getSpectrum(0)); - if (spectrum2) { - TS_ASSERT_EQUALS(2, spectrum2->getSpectrumNo()); + TS_ASSERT_THROWS_NOTHING(output1->getSpectrum(0)); + auto &spectrum2 = output1->getSpectrum(0); + TS_ASSERT_EQUALS(2, spectrum2.getSpectrumNo()); + + const auto &detIDs = spectrum2.getDetectorIDs(); + TS_ASSERT_EQUALS(1, detIDs.size()); + TS_ASSERT(spectrum2.hasDetectorID(2)); - const auto &detIDs = spectrum2->getDetectorIDs(); - TS_ASSERT_EQUALS(1, detIDs.size()); - TS_ASSERT(spectrum2->hasDetectorID(2)); - } ads.remove(outputWSName); } diff --git a/Framework/DataHandling/test/LoadRawSaveNxsLoadNxsTest.h b/Framework/DataHandling/test/LoadRawSaveNxsLoadNxsTest.h index 24340c2e709f870639ef68ae29702a4f0eb3dece..a0eb1bed4c0cf877f2a96389e50f5b33c456ebd6 100644 --- a/Framework/DataHandling/test/LoadRawSaveNxsLoadNxsTest.h +++ b/Framework/DataHandling/test/LoadRawSaveNxsLoadNxsTest.h @@ -172,9 +172,9 @@ public: //---------------------------------------------------------------------- // Tests to check that spectra-detector mapping is done correctly //---------------------------------------------------------------------- - TS_ASSERT_EQUALS(output2D->getSpectrum(0)->getDetectorIDs().size(), 1); - TS_ASSERT_EQUALS(output2D->getSpectrum(0)->getSpectrumNo(), 1); - TS_ASSERT(output2D->getSpectrum(0)->hasDetectorID(1)); + TS_ASSERT_EQUALS(output2D->getSpectrum(0).getDetectorIDs().size(), 1); + TS_ASSERT_EQUALS(output2D->getSpectrum(0).getSpectrumNo(), 1); + TS_ASSERT(output2D->getSpectrum(0).hasDetectorID(1)); // obtain the expected log data which was read from the Nexus file (NXlog) diff --git a/Framework/DataHandling/test/LoadTOFRawNexusTest.h b/Framework/DataHandling/test/LoadTOFRawNexusTest.h index 2d3f1956f97f59ccc381c48e19ae74a92e4892db..f95d1d7f1d3d3cd3fc67bbd8ce5dd2f137b335e2 100644 --- a/Framework/DataHandling/test/LoadTOFRawNexusTest.h +++ b/Framework/DataHandling/test/LoadTOFRawNexusTest.h @@ -67,14 +67,14 @@ public: TS_ASSERT_EQUALS(ws->getInstrument()->getName(), "REF_L"); TS_ASSERT_EQUALS(ws->getNumberHistograms(), 77824); - ISpectrum *spec = ws->getSpectrum(27955); - TS_ASSERT_EQUALS(spec->getSpectrumNo(), 27956); - TS_ASSERT_EQUALS(spec->getDetectorIDs().size(), 1); - TS_ASSERT(spec->hasDetectorID(27955)); + auto &spec = ws->getSpectrum(27955); + TS_ASSERT_EQUALS(spec.getSpectrumNo(), 27956); + TS_ASSERT_EQUALS(spec.getDetectorIDs().size(), 1); + TS_ASSERT(spec.hasDetectorID(27955)); MantidVec X, Y, E; - X = spec->dataX(); - Y = spec->dataY(); - E = spec->dataE(); + X = spec.dataX(); + Y = spec.dataY(); + E = spec.dataE(); TS_ASSERT_EQUALS(X.size(), 502); TS_ASSERT_EQUALS(Y.size(), 501); TS_ASSERT_EQUALS(E.size(), 501); @@ -87,12 +87,12 @@ public: TS_ASSERT_DELTA(E[94], 1.0, 1e-4); // More data in this spectrum - spec = ws->getSpectrum(38019); - TS_ASSERT_EQUALS(spec->getSpectrumNo(), 38020); - TS_ASSERT_EQUALS(spec->getDetectorIDs().size(), 1); - TS_ASSERT(spec->hasDetectorID(38019)); - TS_ASSERT_DELTA(spec->dataY()[105], 23.0, 1e-4); - TS_ASSERT_DELTA(spec->dataE()[105], sqrt(23.0), 1e-4); + auto &spec2 = ws->getSpectrum(38019); + TS_ASSERT_EQUALS(spec2.getSpectrumNo(), 38020); + TS_ASSERT_EQUALS(spec2.getDetectorIDs().size(), 1); + TS_ASSERT(spec2.hasDetectorID(38019)); + TS_ASSERT_DELTA(spec2.dataY()[105], 23.0, 1e-4); + TS_ASSERT_DELTA(spec2.dataE()[105], sqrt(23.0), 1e-4); TS_ASSERT_EQUALS(ws->getAxis(1)->length(), 77824); TS_ASSERT_EQUALS(ws->getAxis(0)->length(), 502); diff --git a/Framework/DataHandling/test/MaskDetectorsTest.h b/Framework/DataHandling/test/MaskDetectorsTest.h index faed22dc99227ff944b23ecfdda7fbf3c04f9ef0..3bce0b3233139a04b4728514017c5fe8c94a0423 100644 --- a/Framework/DataHandling/test/MaskDetectorsTest.h +++ b/Framework/DataHandling/test/MaskDetectorsTest.h @@ -61,9 +61,9 @@ public: for (int j = 0; j < numspec; ++j) { // Just one event per pixel TofEvent event(1.23, int64_t(4.56)); - spaceEvent->getEventList(j).addEventQuickly(event); - spaceEvent->getEventList(j).setDetectorID(j); - spaceEvent->getSpectrum(j)->setSpectrumNo(j); + spaceEvent->getSpectrum(j).addEventQuickly(event); + spaceEvent->getSpectrum(j).setDetectorID(j); + spaceEvent->getSpectrum(j).setSpectrumNo(j); } x.access().push_back(0.0); x.access().push_back(10.0); @@ -80,8 +80,8 @@ public: for (int j = 0; j < numspec; ++j) { space2D->setX(j, x); space2D->setData(j, vec, vec); - space2D->getSpectrum(j)->setSpectrumNo(j); - space2D->getSpectrum(j)->setDetectorID(j); + space2D->getSpectrum(j).setSpectrumNo(j); + space2D->getSpectrum(j).setDetectorID(j); } } else { // In case of MaskWorkspace diff --git a/Framework/DataHandling/test/ProcessDasNexusLogTest.h b/Framework/DataHandling/test/ProcessDasNexusLogTest.h index 57034fe9926bcb8834198420f90c612547584324..94f68475b3500ffa6e2491cc4a32808e38902623 100644 --- a/Framework/DataHandling/test/ProcessDasNexusLogTest.h +++ b/Framework/DataHandling/test/ProcessDasNexusLogTest.h @@ -90,7 +90,7 @@ public: true); for (size_t i = 0; i < eventWS->getNumberHistograms(); i++) { - DataObjects::EventList *elist = eventWS->getEventListPtr(i); + auto &elist = eventWS->getSpectrum(i); for (int64_t pid = 0; pid < 5; pid++) { int64_t pulsetime_i64 = pid * pulsedt + runstart.totalNanoseconds(); @@ -98,7 +98,7 @@ public: for (size_t e = 0; e < 10; e++) { double tof = static_cast<double>(e * tofdt / 1000); DataObjects::TofEvent event(tof, pulsetime); - elist->addEventQuickly(event); + elist.addEventQuickly(event); } } // FOR each pulse } // For each bank diff --git a/Framework/DataHandling/test/SaveFocussedXYETest.h b/Framework/DataHandling/test/SaveFocussedXYETest.h index 43dae5aa852a01650fbc09a047d09857809cc6ff..6d6ebc38d7246348c310f7fb7585e04b454e48df 100644 --- a/Framework/DataHandling/test/SaveFocussedXYETest.h +++ b/Framework/DataHandling/test/SaveFocussedXYETest.h @@ -428,8 +428,7 @@ public: Workspace2D_sptr workspace = WorkspaceCreationHelper::create2DWorkspaceWithFullInstrument(3, 3); // Remove detectors from one spectrum - auto *spec = workspace->getSpectrum(1); - spec->clearDetectorIDs(); + workspace->getSpectrum(1).clearDetectorIDs(); std::string createdWS("ws"); AnalysisDataService::Instance().add(createdWS, workspace); diff --git a/Framework/DataHandling/test/SaveNXSPETest.h b/Framework/DataHandling/test/SaveNXSPETest.h index d6e9989404133f83f2e80f292a6ea0f60a9a275c..e93d05e75d2f25dac8d4b483ba4af54ed10ff574 100644 --- a/Framework/DataHandling/test/SaveNXSPETest.h +++ b/Framework/DataHandling/test/SaveNXSPETest.h @@ -157,7 +157,7 @@ private: for (size_t j = 0; j < inputWS->getNumberHistograms(); ++j) { // Just set the spectrum number to match the index inputWS->getSpectrum(j) - ->setSpectrumNo(static_cast<Mantid::specnum_t>(j + 1)); + .setSpectrumNo(static_cast<Mantid::specnum_t>(j + 1)); } // mask the detector diff --git a/Framework/DataHandling/test/SaveNexusProcessedTest.h b/Framework/DataHandling/test/SaveNexusProcessedTest.h index 4859004269dfa8de8a5d9640eb00dd9d2a8ba819..0d84fd061f073dcdbf3f54b1d3807c7191c4d21d 100644 --- a/Framework/DataHandling/test/SaveNexusProcessedTest.h +++ b/Framework/DataHandling/test/SaveNexusProcessedTest.h @@ -247,16 +247,16 @@ public: EventWorkspace_sptr WS = WorkspaceCreationHelper::CreateGroupedEventWorkspace(groups, 100, 1.0, 1.0); - WS->getEventList(3).clear(false); + WS->getSpectrum(3).clear(false); // Switch the event type if (makeDifferentTypes) { - WS->getEventList(0).switchTo(TOF); - WS->getEventList(1).switchTo(WEIGHTED); - WS->getEventList(2).switchTo(WEIGHTED_NOTIME); - WS->getEventList(4).switchTo(WEIGHTED); + WS->getSpectrum(0).switchTo(TOF); + WS->getSpectrum(1).switchTo(WEIGHTED); + WS->getSpectrum(2).switchTo(WEIGHTED_NOTIME); + WS->getSpectrum(4).switchTo(WEIGHTED); } else { for (size_t wi = 0; wi < WS->getNumberHistograms(); wi++) - WS->getEventList(wi).switchTo(type); + WS->getSpectrum(wi).switchTo(type); } SaveNexusProcessed alg; diff --git a/Framework/DataHandling/test/SavePARTest.h b/Framework/DataHandling/test/SavePARTest.h index adf5c2beb36ab8a3b1bd4165ca2a6aae29eabaff..1c65124f0847bc059b7106666083647e6a57ada1 100644 --- a/Framework/DataHandling/test/SavePARTest.h +++ b/Framework/DataHandling/test/SavePARTest.h @@ -152,7 +152,7 @@ private: // the following is largely about associating detectors with the workspace for (int j = 0; j < NHIST; ++j) { // Just set the spectrum number to match the index - inputWS->getSpectrum(j)->setSpectrumNo(j + 1); + inputWS->getSpectrum(j).setSpectrumNo(j + 1); } // we do not need to deal with analysisi data service here in test to avoid // holding the workspace there after the test diff --git a/Framework/DataHandling/test/SavePHXTest.h b/Framework/DataHandling/test/SavePHXTest.h index 89193fd949ba646341960072a52c00327f6a99d1..da03b4940dc00b656f2b917f7f838fd6aea35e3f 100644 --- a/Framework/DataHandling/test/SavePHXTest.h +++ b/Framework/DataHandling/test/SavePHXTest.h @@ -182,7 +182,7 @@ private: // the following is largely about associating detectors with the workspace for (int j = 0; j < NHIST; ++j) { // Just set the spectrum number to match the index - inputWS->getSpectrum(j)->setSpectrumNo(j + 1); + inputWS->getSpectrum(j).setSpectrumNo(j + 1); } // we do not need to deal with analysisi data service here in test to avoid // holding the workspace there after the test diff --git a/Framework/DataHandling/test/UpdateInstrumentFromFileTest.h b/Framework/DataHandling/test/UpdateInstrumentFromFileTest.h index 193d86edba1e7e109a2ca54c59408a6100f86504..9dcfc5c1a7502741ccf4420bfa6954d394815109 100644 --- a/Framework/DataHandling/test/UpdateInstrumentFromFileTest.h +++ b/Framework/DataHandling/test/UpdateInstrumentFromFileTest.h @@ -244,10 +244,10 @@ private: ws->setInstrument(inst); for (size_t i = 0; i < nhist; ++i) { - ISpectrum *spec = ws->getSpectrum(0); - spec->setSpectrumNo(static_cast<Mantid::specnum_t>(i + 1)); - spec->clearDetectorIDs(); - spec->addDetectorID(static_cast<Mantid::detid_t>(i + 1)); + auto &spec = ws->getSpectrum(0); + spec.setSpectrumNo(static_cast<Mantid::specnum_t>(i + 1)); + spec.clearDetectorIDs(); + spec.addDetectorID(static_cast<Mantid::detid_t>(i + 1)); } TS_ASSERT_THROWS_NOTHING( diff --git a/Framework/DataObjects/inc/MantidDataObjects/EventWorkspace.h b/Framework/DataObjects/inc/MantidDataObjects/EventWorkspace.h index c0edf7cf9d2dc7e32f1e972431a41b30f979966f..f0b195bacbe0b7c7cffc8ba010615a02cfe5d36b 100644 --- a/Framework/DataObjects/inc/MantidDataObjects/EventWorkspace.h +++ b/Framework/DataObjects/inc/MantidDataObjects/EventWorkspace.h @@ -75,13 +75,8 @@ public: // Get the number of histograms. aka the number of pixels or detectors. std::size_t getNumberHistograms() const override; - //------------------------------------------------------------ - // Return the underlying ISpectrum ptr at the given workspace index. - Mantid::API::ISpectrum *getSpectrum(const size_t index) override; - - // Return the underlying ISpectrum ptr (const version) at the given workspace - // index. - const Mantid::API::ISpectrum *getSpectrum(const size_t index) const override; + EventList &getSpectrum(const size_t index) override; + const EventList &getSpectrum(const size_t index) const override; //------------------------------------------------------------ @@ -145,16 +140,6 @@ public: // Set the x-axis data (histogram bins) for all pixels virtual void setAllX(Kernel::cow_ptr<MantidVec> &x); - // Get an EventList object at the given workspace index number - virtual EventList &getEventList(const std::size_t workspace_index); - - // Get a const EventList object at the given workspace index number - virtual const EventList & - getEventList(const std::size_t workspace_index) const; - - // Get an EventList pointer at the given workspace index number - EventList *getEventListPtr(const std::size_t workspace_index) override; - // Get or add an EventList EventList &getOrAddEventList(const std::size_t workspace_index); diff --git a/Framework/DataObjects/inc/MantidDataObjects/Histogram1D.h b/Framework/DataObjects/inc/MantidDataObjects/Histogram1D.h index 3ff602e7141e08d55a6a75b566a516be0461159a..76f406199619d84f0821c9a81541434e2e06a449 100644 --- a/Framework/DataObjects/inc/MantidDataObjects/Histogram1D.h +++ b/Framework/DataObjects/inc/MantidDataObjects/Histogram1D.h @@ -31,12 +31,22 @@ namespace DataObjects { File change history is stored at: <https://github.com/mantidproject/mantid>. Code Documentation is available at: <http://doxygen.mantidproject.org> */ -class DLLExport Histogram1D : public Mantid::API::ISpectrum { +class DLLExport Histogram1D final : public Mantid::API::ISpectrum { protected: MantidVecPtr refY; ///< RefCounted Y MantidVecPtr refE; ///< RefCounted Error public: + // Dummy implementation to avoid issues with POD default cosntruction. + Histogram1D() {} + Histogram1D(const Histogram1D &) = default; + Histogram1D(Histogram1D &&) = default; + Histogram1D(const ISpectrum &other); + + Histogram1D &operator=(const Histogram1D &) = default; + Histogram1D &operator=(Histogram1D &&) = default; + Histogram1D &operator=(const ISpectrum &rhs); + /// Sets the data. void setData(const MantidVec &Y) override { refY.access() = Y; }; /// Sets the data and errors diff --git a/Framework/DataObjects/inc/MantidDataObjects/Workspace2D.h b/Framework/DataObjects/inc/MantidDataObjects/Workspace2D.h index c8729e4593d114c09eeaf0567c3749619001d29d..45401d3080b9c91cca481007d1c4e1bbdb8b1cba 100644 --- a/Framework/DataObjects/inc/MantidDataObjects/Workspace2D.h +++ b/Framework/DataObjects/inc/MantidDataObjects/Workspace2D.h @@ -6,7 +6,6 @@ //---------------------------------------------------------------------- #include "MantidAPI/MatrixWorkspace.h" #include "MantidDataObjects/Histogram1D.h" -#include "MantidAPI/ISpectrum.h" namespace Mantid { @@ -65,12 +64,8 @@ public: std::size_t size() const override; std::size_t blocksize() const override; - /// Return the underlying ISpectrum ptr at the given workspace index. - Mantid::API::ISpectrum *getSpectrum(const size_t index) override; - - /// Return the underlying ISpectrum ptr (const version) at the given workspace - /// index. - const Mantid::API::ISpectrum *getSpectrum(const size_t index) const override; + Histogram1D &getSpectrum(const size_t index) override; + const Histogram1D &getSpectrum(const size_t index) const override; /// Generate a new histogram by rebinning the existing histogram. void generateHistogram(const std::size_t index, const MantidVec &X, @@ -109,7 +104,7 @@ protected: std::vector<specnum_t> m_monitorList; /// A vector that holds the 1D histograms - std::vector<Mantid::API::ISpectrum *> data; + std::vector<Histogram1D *> data; private: Workspace2D *doClone() const override { return new Workspace2D(*this); } diff --git a/Framework/DataObjects/inc/MantidDataObjects/WorkspaceSingleValue.h b/Framework/DataObjects/inc/MantidDataObjects/WorkspaceSingleValue.h index c0f3070622325c1d23a3d802fe826957f1ecda73..ee65d9976841447f5a89f02d9d3a840e5a555334 100644 --- a/Framework/DataObjects/inc/MantidDataObjects/WorkspaceSingleValue.h +++ b/Framework/DataObjects/inc/MantidDataObjects/WorkspaceSingleValue.h @@ -57,13 +57,8 @@ public: /// @return the number of histograms (spectra) std::size_t getNumberHistograms() const override { return 1; } - //------------------------------------------------------------ - // Return the underlying ISpectrum ptr at the given workspace index. - Mantid::API::ISpectrum *getSpectrum(const size_t index) override; - - // Return the underlying ISpectrum ptr (const version) at the given workspace - // index. - const Mantid::API::ISpectrum *getSpectrum(const size_t index) const override; + Histogram1D &getSpectrum(const size_t index) override; + const Histogram1D &getSpectrum(const size_t index) const override; void generateHistogram(const std::size_t index, const MantidVec &X, MantidVec &Y, MantidVec &E, diff --git a/Framework/DataObjects/src/EventWorkspace.cpp b/Framework/DataObjects/src/EventWorkspace.cpp index 675b4a4ce5b710bff3b80c51a339fadd85eef9b9..578487a4a488d0fd4402f7fe7beb42869036e3b5 100644 --- a/Framework/DataObjects/src/EventWorkspace.cpp +++ b/Framework/DataObjects/src/EventWorkspace.cpp @@ -182,23 +182,19 @@ size_t EventWorkspace::blocksize() const { */ size_t EventWorkspace::getNumberHistograms() const { return this->data.size(); } -//-------------------------------------------------------------------------------------------- -/// Return the underlying ISpectrum ptr at the given workspace index. -Mantid::API::ISpectrum *EventWorkspace::getSpectrum(const size_t index) { - if (index >= m_noVectors) - throw std::range_error( - "EventWorkspace::getSpectrum, workspace index out of range"); +/// Return const reference to EventList at the given workspace index. +EventList &EventWorkspace::getSpectrum(const size_t index) { invalidateCommonBinsFlag(); - return data[index]; + return const_cast<EventList &>( + static_cast<const EventWorkspace &>(*this).getSpectrum(index)); } -/// Return the underlying ISpectrum ptr at the given workspace index. -const Mantid::API::ISpectrum * -EventWorkspace::getSpectrum(const size_t index) const { +/// Return const reference to EventList at the given workspace index. +const EventList &EventWorkspace::getSpectrum(const size_t index) const { if (index >= m_noVectors) throw std::range_error( "EventWorkspace::getSpectrum, workspace index out of range"); - return data[index]; + return *data[index]; } //----------------------------------------------------------------------------- @@ -218,7 +214,7 @@ DateAndTime EventWorkspace::getPulseTimeMin() const { DateAndTime temp; for (size_t workspaceIndex = 0; workspaceIndex < numWorkspace; workspaceIndex++) { - const EventList &evList = this->getEventList(workspaceIndex); + const EventList &evList = this->getSpectrum(workspaceIndex); temp = evList.getPulseTimeMin(); if (temp < tMin) tMin = temp; @@ -237,7 +233,7 @@ DateAndTime EventWorkspace::getPulseTimeMax() const { DateAndTime temp; for (size_t workspaceIndex = 0; workspaceIndex < numWorkspace; workspaceIndex++) { - const EventList &evList = this->getEventList(workspaceIndex); + const EventList &evList = this->getSpectrum(workspaceIndex); temp = evList.getPulseTimeMax(); if (temp > tMax) tMax = temp; @@ -265,7 +261,7 @@ DateAndTime EventWorkspace::getTimeAtSampleMin(double tofOffset) const { const double L2 = this->getDetector(workspaceIndex)->getDistance(*sample); const double tofFactor = L1 / (L1 + L2); - const EventList &evList = this->getEventList(workspaceIndex); + const EventList &evList = this->getSpectrum(workspaceIndex); temp = evList.getTimeAtSampleMin(tofFactor, tofOffset); if (temp < tMin) tMin = temp; @@ -293,7 +289,7 @@ DateAndTime EventWorkspace::getTimeAtSampleMax(double tofOffset) const { const double L2 = this->getDetector(workspaceIndex)->getDistance(*sample); const double tofFactor = L1 / (L1 + L2); - const EventList &evList = this->getEventList(workspaceIndex); + const EventList &evList = this->getSpectrum(workspaceIndex); temp = evList.getTimeAtSampleMax(tofFactor, tofOffset); if (temp > tMax) tMax = temp; @@ -317,7 +313,7 @@ double EventWorkspace::getEventXMin() const { size_t numWorkspace = this->data.size(); for (size_t workspaceIndex = 0; workspaceIndex < numWorkspace; workspaceIndex++) { - const EventList &evList = this->getEventList(workspaceIndex); + const EventList &evList = this->getSpectrum(workspaceIndex); const double temp = evList.getTofMin(); if (temp < xmin) xmin = temp; @@ -341,7 +337,7 @@ double EventWorkspace::getEventXMax() const { size_t numWorkspace = this->data.size(); for (size_t workspaceIndex = 0; workspaceIndex < numWorkspace; workspaceIndex++) { - const EventList &evList = this->getEventList(workspaceIndex); + const EventList &evList = this->getSpectrum(workspaceIndex); const double temp = evList.getTofMax(); if (temp > xmax) xmax = temp; @@ -362,7 +358,7 @@ void EventWorkspace::getEventXMinMax(double &xmin, double &xmax) const { size_t numWorkspace = this->data.size(); for (size_t workspaceIndex = 0; workspaceIndex < numWorkspace; workspaceIndex++) { - const EventList &evList = this->getEventList(workspaceIndex); + const EventList &evList = this->getSpectrum(workspaceIndex); double temp = evList.getTofMin(); if (temp < xmin) xmin = temp; @@ -466,44 +462,6 @@ size_t EventWorkspace::getMemorySize() const { // --- Data Access ---- //----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- -/** Get an EventList object at the given workspace index number - * @param workspace_index :: The histogram workspace index number. - * @returns A reference to the eventlist - */ -EventList &EventWorkspace::getEventList(const std::size_t workspace_index) { - EventList *result = data[workspace_index]; - if (!result) - throw std::runtime_error( - "EventWorkspace::getEventList: NULL EventList found."); - else - return *result; -} - -//----------------------------------------------------------------------------- -/** Get a const EventList object at the given workspace index number - * @param workspace_index :: The workspace index number. - * @returns A const reference to the eventlist - */ -const EventList & -EventWorkspace::getEventList(const std::size_t workspace_index) const { - EventList *result = data[workspace_index]; - if (!result) - throw std::runtime_error( - "EventWorkspace::getEventList (const): NULL EventList found."); - else - return *result; -} - -//----------------------------------------------------------------------------- -/** Get an EventList pointer at the given workspace index number - * @param workspace_index :: index into WS - * @return an EventList pointer at the given workspace index number - */ -EventList *EventWorkspace::getEventListPtr(const std::size_t workspace_index) { - return data[workspace_index]; -} - //----------------------------------------------------------------------------- /** Either return an existing EventList from the list, or * create a new one if needed and expand the list. @@ -577,7 +535,7 @@ void EventWorkspace::padSpectra() { resizeTo(pixelIDs.size()); for (size_t i = 0; i < pixelIDs.size(); ++i) { - getSpectrum(i)->setDetectorID(pixelIDs[i]); + getSpectrum(i).setDetectorID(pixelIDs[i]); } } @@ -593,8 +551,8 @@ void EventWorkspace::padSpectra(const std::vector<int32_t> &specList) { for (size_t i = 0; i < specList.size(); ++i) { // specList ranges from 1, ..., N // detector ranges from 0, ..., N-1 - getSpectrum(i)->setDetectorID(specList[i] - 1); - getSpectrum(i)->setSpectrumNo(specList[i]); + getSpectrum(i).setDetectorID(specList[i] - 1); + getSpectrum(i).setSpectrumNo(specList[i]); } } } @@ -634,7 +592,7 @@ void EventWorkspace::deleteEmptyLists() { /// @param index :: the workspace index to return /// @returns A reference to the vector of binned X values MantidVec &EventWorkspace::dataX(const std::size_t index) { - return getSpectrum(index)->dataX(); + return getSpectrum(index).dataX(); } /// Return the data X error vector at a given workspace index @@ -643,7 +601,7 @@ MantidVec &EventWorkspace::dataX(const std::size_t index) { /// @param index :: the workspace index to return /// @returns A reference to the vector of binned error values MantidVec &EventWorkspace::dataDx(const std::size_t index) { - return getSpectrum(index)->dataDx(); + return getSpectrum(index).dataDx(); } /// Return the data Y vector at a given workspace index @@ -670,34 +628,34 @@ MantidVec &EventWorkspace::dataE(const std::size_t) { /** @return the const data X vector at a given workspace index * @param index :: workspace index */ const MantidVec &EventWorkspace::dataX(const std::size_t index) const { - return getSpectrum(index)->readX(); + return getSpectrum(index).readX(); } /** @return the const data X error vector at a given workspace index * @param index :: workspace index */ const MantidVec &EventWorkspace::dataDx(const std::size_t index) const { - return getSpectrum(index)->readDx(); + return getSpectrum(index).readDx(); } //--------------------------------------------------------------------------- /** @return the const data Y vector at a given workspace index * @param index :: workspace index */ const MantidVec &EventWorkspace::dataY(const std::size_t index) const { - return getSpectrum(index)->readY(); + return getSpectrum(index).readY(); } //--------------------------------------------------------------------------- /** @return the const data E (error) vector at a given workspace index * @param index :: workspace index */ const MantidVec &EventWorkspace::dataE(const std::size_t index) const { - return getSpectrum(index)->readE(); + return getSpectrum(index).readE(); } //--------------------------------------------------------------------------- /** @return a pointer to the X data vector at a given workspace index * @param index :: workspace index */ Kernel::cow_ptr<MantidVec> EventWorkspace::refX(const std::size_t index) const { - return getSpectrum(index)->ptrX(); + return getSpectrum(index).ptrX(); } //--------------------------------------------------------------------------- @@ -775,7 +733,7 @@ public: m_wiStop = m_WS->getNumberHistograms(); for (size_t wi = m_wiStart; wi < m_wiStop; wi++) { - double n = static_cast<double>(m_WS->getEventList(wi).getNumberEvents()); + double n = static_cast<double>(m_WS->getSpectrum(wi).getNumberEvents()); // Sorting time is approximately n * ln (n) m_cost += n * log(n); } @@ -791,14 +749,14 @@ public: return; for (size_t wi = m_wiStart; wi < m_wiStop; wi++) { if (m_sortType != TOF_SORT) - m_WS->getEventList(wi).sort(m_sortType); + m_WS->getSpectrum(wi).sort(m_sortType); else { if (m_howManyCores == 1) { - m_WS->getEventList(wi).sort(m_sortType); + m_WS->getSpectrum(wi).sort(m_sortType); } else if (m_howManyCores == 2) { - m_WS->getEventList(wi).sortTof2(); + m_WS->getSpectrum(wi).sortTof2(); } else if (m_howManyCores == 4) { - m_WS->getEventList(wi).sortTof4(); + m_WS->getSpectrum(wi).sortTof4(); } } // Report progress diff --git a/Framework/DataObjects/src/EventWorkspaceHelpers.cpp b/Framework/DataObjects/src/EventWorkspaceHelpers.cpp index f0d1075a3d31b44997a4069a85dc2608950c2813..4bbc3b827f180ee27efa2bd38ebdd6ed098a28b3 100644 --- a/Framework/DataObjects/src/EventWorkspaceHelpers.cpp +++ b/Framework/DataObjects/src/EventWorkspaceHelpers.cpp @@ -32,7 +32,7 @@ EventWorkspaceHelpers::convertEventTo2D(MatrixWorkspace_sptr inputMatrixW) { // Now let's set all the X bins and values for (size_t i = 0; i < inputW->getNumberHistograms(); i++) { - outputW->getSpectrum(i)->copyInfoFrom(*inputW->getSpectrum(i)); + outputW->getSpectrum(i).copyInfoFrom(inputW->getSpectrum(i)); outputW->setX(i, inputW->refX(i)); MantidVec &Yout = outputW->dataY(i); diff --git a/Framework/DataObjects/src/Histogram1D.cpp b/Framework/DataObjects/src/Histogram1D.cpp index d743b7ac5cbd44bda7401433a0cd0a9ef21a4519..1b7a62bf303cf34855efc1869b6b9d1e6eb3251f 100644 --- a/Framework/DataObjects/src/Histogram1D.cpp +++ b/Framework/DataObjects/src/Histogram1D.cpp @@ -5,6 +5,20 @@ namespace Mantid { namespace DataObjects { +/// Construct from ISpectrum. +Histogram1D::Histogram1D(const ISpectrum &other) : ISpectrum(other) { + dataY() = other.readY(); + dataE() = other.readE(); +} + +/// Assignment from ISpectrum. +Histogram1D &Histogram1D::operator=(const ISpectrum &rhs) { + ISpectrum::operator=(rhs); + dataY() = rhs.readY(); + dataE() = rhs.readE(); + return *this; +} + void Histogram1D::clearData() { MantidVec &yValues = this->dataY(); std::fill(yValues.begin(), yValues.end(), 0.0); diff --git a/Framework/DataObjects/src/ReflectometryTransform.cpp b/Framework/DataObjects/src/ReflectometryTransform.cpp index 9e8d27fb9c0af527b8e4476d8d958ed34ad754ba..8ccbadc12ba7b4577302a9e2db623922e5c1d329 100644 --- a/Framework/DataObjects/src/ReflectometryTransform.cpp +++ b/Framework/DataObjects/src/ReflectometryTransform.cpp @@ -494,7 +494,7 @@ MatrixWorkspace_sptr ReflectometryTransform::executeNormPoly( if (qIndex != 0 && qIndex < static_cast<int>(zBinsVec.size())) { // Add this spectra-detector pair to the mapping specNumberMapping.push_back( - outWS->getSpectrum(qIndex - 1)->getSpectrumNo()); + outWS->getSpectrum(qIndex - 1).getSpectrumNo()); detIDMapping.push_back(detector->getID()); } // Debugging diff --git a/Framework/DataObjects/src/SpecialWorkspace2D.cpp b/Framework/DataObjects/src/SpecialWorkspace2D.cpp index 7a3dbb3e57cc3661591f09ec7680a5c3f663057b..b17c8bf4a237eef8ad529a2313fd9beaa0ae0a36 100644 --- a/Framework/DataObjects/src/SpecialWorkspace2D.cpp +++ b/Framework/DataObjects/src/SpecialWorkspace2D.cpp @@ -40,7 +40,7 @@ SpecialWorkspace2D::SpecialWorkspace2D(Geometry::Instrument_const_sptr inst, // Make the mapping, which will be used for speed later. detID_to_WI.clear(); for (size_t wi = 0; wi < m_noVectors; wi++) { - set<detid_t> dets = getSpectrum(wi)->getDetectorIDs(); + auto &dets = getSpectrum(wi).getDetectorIDs(); for (auto det : dets) { detID_to_WI[det] = wi; } @@ -60,7 +60,7 @@ SpecialWorkspace2D::SpecialWorkspace2D(API::MatrixWorkspace_const_sptr parent) { // Make the mapping, which will be used for speed later. detID_to_WI.clear(); for (size_t wi = 0; wi < m_noVectors; wi++) { - set<detid_t> dets = getSpectrum(wi)->getDetectorIDs(); + auto &dets = getSpectrum(wi).getDetectorIDs(); for (auto det : dets) { detID_to_WI[det] = wi; } @@ -190,7 +190,7 @@ SpecialWorkspace2D::getDetectorIDs(const std::size_t workspaceIndex) const { if (size_t(workspaceIndex) > this->getNumberHistograms()) throw std::invalid_argument( "SpecialWorkspace2D::getDetectorID(): Invalid workspaceIndex given."); - return this->getSpectrum(workspaceIndex)->getDetectorIDs(); + return this->getSpectrum(workspaceIndex).getDetectorIDs(); } //-------------------------------------------------------------------------------------------- @@ -352,8 +352,8 @@ bool SpecialWorkspace2D::isCompatible( // 2. Check detector ID for (size_t ispec = 0; ispec < numhist1; ispec++) { - set<detid_t> ids1 = this->getSpectrum(ispec)->getDetectorIDs(); - set<detid_t> ids2 = ws->getSpectrum(ispec)->getDetectorIDs(); + set<detid_t> ids1 = this->getSpectrum(ispec).getDetectorIDs(); + set<detid_t> ids2 = ws->getSpectrum(ispec).getDetectorIDs(); if (ids1.size() != ids2.size()) { g_log.debug() << "Spectra " << ispec diff --git a/Framework/DataObjects/src/Workspace2D.cpp b/Framework/DataObjects/src/Workspace2D.cpp index 0af10bb6dbb1c9795625255bec2b919cd2f5a842..b5257f29abee9d4416ad83a718194fddab7d9ba6 100644 --- a/Framework/DataObjects/src/Workspace2D.cpp +++ b/Framework/DataObjects/src/Workspace2D.cpp @@ -25,10 +25,7 @@ Workspace2D::Workspace2D(const Workspace2D &other) data.resize(m_noVectors); for (size_t i = 0; i < m_noVectors; ++i) { - // Careful: data holds pointers to ISpectrum, but they point to Histogram1D. - // There are copy constructors, but we would need a clone() function that is - // aware of the polymorphism. Use cast + copy constructor for now. - data[i] = new Histogram1D(*static_cast<Histogram1D *>(other.data[i])); + data[i] = new Histogram1D(*(other.data[i])); } } @@ -243,27 +240,22 @@ void Workspace2D::setImageYAndE(const API::MantidImage &imageY, } } -//-------------------------------------------------------------------------------------------- -/// Return the underlying ISpectrum ptr at the given workspace index. -ISpectrum *Workspace2D::getSpectrum(const size_t index) { - if (index >= m_noVectors) { - std::stringstream ss; - ss << "Workspace2D::getSpectrum, histogram number " << index - << " out of range " << m_noVectors; - throw std::range_error(ss.str()); - } +/// Return reference to Histogram1D at the given workspace index. +Histogram1D &Workspace2D::getSpectrum(const size_t index) { invalidateCommonBinsFlag(); - return data[index]; + return const_cast<Histogram1D &>( + static_cast<const Workspace2D &>(*this).getSpectrum(index)); } -const ISpectrum *Workspace2D::getSpectrum(const size_t index) const { +/// Return const reference to Histogram1D at the given workspace index. +const Histogram1D &Workspace2D::getSpectrum(const size_t index) const { if (index >= m_noVectors) { std::stringstream ss; ss << "Workspace2D::getSpectrum, histogram number " << index << " out of range " << m_noVectors; throw std::range_error(ss.str()); } - return data[index]; + return *data[index]; } //-------------------------------------------------------------------------------------------- @@ -294,10 +286,10 @@ void Workspace2D::generateHistogram(const std::size_t index, const MantidVec &X, throw std::range_error( "Workspace2D::generateHistogram, histogram number out of range"); // output data arrays are implicitly filled by function - const ISpectrum *spec = this->getSpectrum(index); - const MantidVec ¤tX = spec->readX(); - const MantidVec ¤tY = spec->readY(); - const MantidVec ¤tE = spec->readE(); + const auto &spec = this->getSpectrum(index); + const MantidVec ¤tX = spec.readX(); + const MantidVec ¤tY = spec.readY(); + const MantidVec ¤tE = spec.readE(); if (X.size() <= 1) throw std::runtime_error( "Workspace2D::generateHistogram(): X vector must be at least length 2"); diff --git a/Framework/DataObjects/src/WorkspaceSingleValue.cpp b/Framework/DataObjects/src/WorkspaceSingleValue.cpp index 0efe80ddcb65403acfc680a796f7e99ba6daa4e3..d0bb1ec69e962940e8cbe1fdb9da4d79f4143592 100644 --- a/Framework/DataObjects/src/WorkspaceSingleValue.cpp +++ b/Framework/DataObjects/src/WorkspaceSingleValue.cpp @@ -40,17 +40,15 @@ void WorkspaceSingleValue::init(const std::size_t &NVectors, (void)YLength; // Avoid compiler warning } -//-------------------------------------------------------------------------------------------- -/// Return the underlying ISpectrum ptr at the given workspace index. -Mantid::API::ISpectrum * -WorkspaceSingleValue::getSpectrum(const size_t /*index*/) { - return &data; +/// Return the underlying Histogram1D at the given workspace index. +Histogram1D &WorkspaceSingleValue::getSpectrum(const size_t /*index*/) { + return data; } -/// Return the underlying ISpectrum ptr at the given workspace index. -const Mantid::API::ISpectrum * +/// Return the underlying Histogram1D at the given workspace index. +const Histogram1D & WorkspaceSingleValue::getSpectrum(const size_t /*index*/) const { - return &data; + return data; } /// Rebin the workspace. Not implemented for this workspace. diff --git a/Framework/DataObjects/test/EventWorkspaceTest.h b/Framework/DataObjects/test/EventWorkspaceTest.h index ec6a6d299191d8f8498de872cc0bf0fc93da2495..a89ff60a763e19da7a84b59b5c04586798b714ef 100644 --- a/Framework/DataObjects/test/EventWorkspaceTest.h +++ b/Framework/DataObjects/test/EventWorkspaceTest.h @@ -76,11 +76,11 @@ public: tof = (pix + i + 0.5) * BIN_DELTA; } size_t pulse_time = static_cast<size_t>(tof); - retVal->getEventList(pix) += TofEvent(tof, pulse_time); - retVal->getEventList(pix) += TofEvent(tof, pulse_time); + retVal->getSpectrum(pix) += TofEvent(tof, pulse_time); + retVal->getSpectrum(pix) += TofEvent(tof, pulse_time); } - retVal->getEventList(pix).addDetectorID(pix); - retVal->getEventList(pix).setSpectrumNo(pix); + retVal->getSpectrum(pix).addDetectorID(pix); + retVal->getSpectrum(pix).setSpectrumNo(pix); } } else { retVal->initialize(1, 1, 1); @@ -119,11 +119,11 @@ public: // for (int i=0; i<NUMBINS-1; i++) // { // //Two events per bin - // retVal->getEventList(pix) += TofEvent((i+0.5)*BIN_DELTA, 1); - // retVal->getEventList(pix) += TofEvent((i+0.5)*BIN_DELTA, 1); + // retVal->getSpectrum(pix) += TofEvent((i+0.5)*BIN_DELTA, 1); + // retVal->getSpectrum(pix) += TofEvent((i+0.5)*BIN_DELTA, 1); // } - // retVal->getEventList(pix).addDetectorID(pix); - // retVal->getEventList(pix).setSpectrumNo(pix); + // retVal->getSpectrum(pix).addDetectorID(pix); + // retVal->getSpectrum(pix).setSpectrumNo(pix); // } // // //Create the x-axis for histogramming. @@ -147,7 +147,7 @@ public: TS_ASSERT_EQUALS(ew->size(), (NUMBINS - 1) * NUMPIXELS); // Are the returned arrays the right size? - const EventList el(ew->getEventList(1)); + const EventList el(ew->getSpectrum(1)); TS_ASSERT_EQUALS(el.constDataX().size(), NUMBINS); boost::scoped_ptr<MantidVec> Y(el.makeDataY()); boost::scoped_ptr<MantidVec> E(el.makeDataE()); @@ -168,8 +168,8 @@ public: TS_ASSERT_EQUALS(ew2->getNumberEvents(), ew1->getNumberEvents()); // Double # of events in the copied workspace - ew2->getEventList(0) += ew2->getEventList(0); - ew2->getEventList(1) += ew2->getEventList(1); + ew2->getSpectrum(0) += ew2->getSpectrum(0); + ew2->getSpectrum(1) += ew2->getSpectrum(1); // Original is still 2.0 TS_ASSERT_DELTA(ew1->readY(0)[0], 2.0, 1e-5); @@ -220,7 +220,7 @@ public: TS_ASSERT_EQUALS(ew->size(), 500); // Didn't set X? well all the histograms show a single bin - const EventList el(ew->getEventList(1)); + const EventList el(ew->getSpectrum(1)); TS_ASSERT_EQUALS(el.constDataX().size(), 2); TS_ASSERT_EQUALS(el.constDataX()[0], 0.0); TS_ASSERT_EQUALS(el.constDataX()[1], std::numeric_limits<double>::min()); @@ -236,9 +236,9 @@ public: EventWorkspace_sptr ws = WorkspaceCreationHelper::createEventWorkspaceWithFullInstrument( 1, 10, false /*dont clear the events*/); - TS_ASSERT_EQUALS(ws->getEventList(2).getNumberEvents(), 200); + TS_ASSERT_EQUALS(ws->getSpectrum(2).getNumberEvents(), 200); ws->maskWorkspaceIndex(2); - TS_ASSERT_EQUALS(ws->getEventList(2).getNumberEvents(), 0); + TS_ASSERT_EQUALS(ws->getSpectrum(2).getNumberEvents(), 0); } void test_resizeTo() { @@ -247,8 +247,8 @@ public: ew->resizeTo(3); TS_ASSERT_EQUALS(ew->getNumberHistograms(), 3); for (size_t i = 0; i < ew->getNumberHistograms(); ++i) { - TS_ASSERT_EQUALS(ew->getSpectrum(i)->getSpectrumNo(), i + 1); - // TS_ASSERT( ew->getEventList(i).empty() ); + TS_ASSERT_EQUALS(ew->getSpectrum(i).getSpectrumNo(), i + 1); + // TS_ASSERT( ew->getSpectrum(i).empty() ); TS_ASSERT_EQUALS(ew->readX(i).size(), 2); } } @@ -271,11 +271,11 @@ public: TS_ASSERT_EQUALS(ew->getNumberHistograms(), numpixels); int badcount = 0; for (int i = 0; i < numpixels; i++) { - ISpectrum *spec = ew->getSpectrum(i); - bool b = spec->hasDetectorID(i + 1); + auto &spec = ew->getSpectrum(i); + bool b = spec.hasDetectorID(i + 1); TSM_ASSERT("Workspace i has the given detector id i+1", b); TSM_ASSERT_EQUALS("Matching detector ID and spectrum number.", - spec->getSpectrumNo(), i + 1); + spec.getSpectrumNo(), i + 1); if (b) if (badcount++ > 40) break; @@ -291,10 +291,10 @@ public: size_t wi = 0; for (int pix = 5; pix < NUMPIXELS; pix += 10) { for (int i = 0; i < pix; i++) { - uneven->getEventList(wi) += TofEvent((pix + i + 0.5) * BIN_DELTA, 1); + uneven->getSpectrum(wi) += TofEvent((pix + i + 0.5) * BIN_DELTA, 1); } - uneven->getEventList(wi).addDetectorID(pix); - uneven->getEventList(wi).setSpectrumNo(pix); + uneven->getSpectrum(wi).addDetectorID(pix); + uneven->getSpectrum(wi).setSpectrumNo(pix); wi++; } @@ -320,17 +320,17 @@ public: // pixel id: 5,15,25, etc. for (int wi = 0; wi < static_cast<int>(uneven->getNumberHistograms()); wi++) { - TS_ASSERT_EQUALS(*uneven->getSpectrum(wi)->getDetectorIDs().begin(), + TS_ASSERT_EQUALS(*uneven->getSpectrum(wi).getDetectorIDs().begin(), 5 + wi * 10); } // Workspace index 0 is at pixelid 5 and has 5 events - const EventList el0(uneven->getEventList(0)); + const EventList el0(uneven->getSpectrum(0)); TS_ASSERT_EQUALS(el0.getNumberEvents(), 5); // And so on, the # of events = pixel ID - const EventList el1(uneven->getEventList(1)); + const EventList el1(uneven->getSpectrum(1)); TS_ASSERT_EQUALS(el1.getNumberEvents(), 15); - const EventList el5(uneven->getEventList(5)); + const EventList el5(uneven->getSpectrum(5)); TS_ASSERT_EQUALS(el5.getNumberEvents(), 55); // Out of range @@ -363,7 +363,7 @@ public: xRef[i] = i * BIN_DELTA * 2; ew->setX(0, axis); - const EventList el(ew->getEventList(0)); + const EventList el(ew->getSpectrum(0)); TS_ASSERT_EQUALS(el.constDataX()[0], 0); TS_ASSERT_EQUALS(el.constDataX()[1], BIN_DELTA * 2); @@ -380,7 +380,7 @@ public: TS_ASSERT_EQUALS((*Y)[NUMBINS / 2 - 2], 4); // But pixel 1 is the same, 2 events in the bin - const EventList el1(ew->getEventList(1)); + const EventList el1(ew->getSpectrum(1)); TS_ASSERT_EQUALS(el1.constDataX()[1], BIN_DELTA * 1); boost::scoped_ptr<MantidVec> Y1(el1.makeDataY()); TS_ASSERT_EQUALS((*Y1)[1], 2); @@ -588,8 +588,8 @@ public: EventWorkspace_sptr ws(new EventWorkspace); ws->initialize(1, 2, 1); - ws->getEventList(0) += TofEvent(0, min); // min - ws->getEventList(0) += TofEvent(0, max); // max; + ws->getSpectrum(0) += TofEvent(0, min); // min + ws->getSpectrum(0) += TofEvent(0, max); // max; TS_ASSERT_EQUALS(max, ws->getPulseTimeMax()); } @@ -600,8 +600,8 @@ public: EventWorkspace_sptr ws(new EventWorkspace); ws->initialize(1, 2, 1); - ws->getEventList(0) += TofEvent(0, min); // min - ws->getEventList(0) += TofEvent(0, max); // max; + ws->getSpectrum(0) += TofEvent(0, min); // min + ws->getSpectrum(0) += TofEvent(0, max); // max; TS_ASSERT_EQUALS(min, ws->getPulseTimeMin()); } @@ -613,11 +613,11 @@ public: EventWorkspace_sptr ws(new EventWorkspace); ws->initialize(2, 2, 1); // First spectrum - ws->getEventList(0) += TofEvent(0, min + int64_t(1)); - ws->getEventList(0) += TofEvent(0, max); // max in spectra 1 + ws->getSpectrum(0) += TofEvent(0, min + int64_t(1)); + ws->getSpectrum(0) += TofEvent(0, max); // max in spectra 1 // Second spectrum - ws->getEventList(1) += TofEvent(0, min); // min in spectra 2 - ws->getEventList(1) += TofEvent(0, max - int64_t(1)); + ws->getSpectrum(1) += TofEvent(0, min); // min in spectra 2 + ws->getSpectrum(1) += TofEvent(0, max - int64_t(1)); V3D source(0, 0, 0); V3D sample(10, 0, 0); @@ -642,8 +642,8 @@ public: EventWorkspace_sptr ws(new EventWorkspace); ws->initialize(1,2,1); - ws->getEventList(0) += TofEvent(0, min); // min - ws->getEventList(0) += TofEvent(0, max); // max; + ws->getSpectrum(0) += TofEvent(0, min); // min + ws->getSpectrum(0) += TofEvent(0, max); // max; TS_ASSERT_EQUALS(min, ws->getPulseTimeMin()); */ @@ -656,13 +656,13 @@ public: boost::dynamic_pointer_cast<const EventWorkspace>(ew); // OK, we grab data0 from the MRU. - const ISpectrum *inSpec = ew2->getSpectrum(0); - const ISpectrum *inSpec300 = ew2->getSpectrum(300); - inSpec->lockData(); - inSpec300->lockData(); + const auto &inSpec = ew2->getSpectrum(0); + const auto &inSpec300 = ew2->getSpectrum(300); + inSpec.lockData(); + inSpec300.lockData(); - const MantidVec &data0 = inSpec->readY(); - const MantidVec &e300 = inSpec300->readE(); + const MantidVec &data0 = inSpec.readY(); + const MantidVec &e300 = inSpec300.readE(); TS_ASSERT_EQUALS(data0.size(), NUMBINS - 1); MantidVec data0_copy(data0); MantidVec e300_copy(e300); @@ -680,8 +680,8 @@ public: TS_ASSERT_EQUALS(e300[i], e300_copy[i]); } - inSpec->unlockData(); - inSpec300->unlockData(); + inSpec.unlockData(); + inSpec300.unlockData(); MantidVec otherData = ew2->readY(255); @@ -699,7 +699,7 @@ public: EventWorkspace_sptr outWS = test_in; for (int wi = 0; wi < NUMPIXELS; wi++) { - std::vector<TofEvent> ve = outWS->getEventList(wi).getEvents(); + std::vector<TofEvent> ve = outWS->getSpectrum(wi).getEvents(); TS_ASSERT_EQUALS(ve.size(), NUMBINS); for (size_t i = 0; i < ve.size() - 1; i++) TS_ASSERT_LESS_THAN_EQUALS(ve[i].tof(), ve[i + 1].tof()); @@ -718,7 +718,7 @@ public: test_in->sortAll(TOF_SORT, prog); EventWorkspace_sptr outWS = test_in; - std::vector<TofEvent> ve = outWS->getEventList(0).getEvents(); + std::vector<TofEvent> ve = outWS->getSpectrum(0).getEvents(); TS_ASSERT_EQUALS(ve.size(), numEvents); for (size_t i = 0; i < ve.size() - 1; i++) TS_ASSERT_LESS_THAN_EQUALS(ve[i].tof(), ve[i + 1].tof()); @@ -736,7 +736,7 @@ public: test_in->sortAll(PULSETIME_SORT, prog); EventWorkspace_sptr outWS = test_in; - std::vector<TofEvent> ve = outWS->getEventList(0).getEvents(); + std::vector<TofEvent> ve = outWS->getSpectrum(0).getEvents(); TS_ASSERT_EQUALS(ve.size(), numEvents); for (size_t i = 0; i < ve.size() - 1; i++) TS_ASSERT_LESS_THAN_EQUALS(ve[i].pulseTime(), ve[i + 1].pulseTime()); @@ -751,7 +751,7 @@ public: EventWorkspace_sptr outWS = test_in; for (int wi = 0; wi < NUMPIXELS; wi++) { - std::vector<TofEvent> ve = outWS->getEventList(wi).getEvents(); + std::vector<TofEvent> ve = outWS->getSpectrum(wi).getEvents(); TS_ASSERT_EQUALS(ve.size(), NUMBINS); for (size_t i = 0; i < ve.size() - 1; i++) TS_ASSERT_LESS_THAN_EQUALS(ve[i].pulseTime(), ve[i + 1].pulseTime()); diff --git a/Framework/DataObjects/test/GroupingWorkspaceTest.h b/Framework/DataObjects/test/GroupingWorkspaceTest.h index 6576262247655a23de169fde520c2bff3756488d..a2c232cbcf140400301b01a5c558ef81cee8104b 100644 --- a/Framework/DataObjects/test/GroupingWorkspaceTest.h +++ b/Framework/DataObjects/test/GroupingWorkspaceTest.h @@ -38,7 +38,7 @@ public: TS_ASSERT_EQUALS(ws->blocksize(), 1); TS_ASSERT_EQUALS(ws->getInstrument()->getName(), "basic"); // Name of the test instrument - auto dets = ws->getSpectrum(0)->getDetectorIDs(); + auto dets = ws->getSpectrum(0).getDetectorIDs(); TS_ASSERT_EQUALS(dets.size(), 1); // Set the group numbers @@ -72,7 +72,7 @@ public: TS_ASSERT_EQUALS(cloned->blocksize(), 1); TS_ASSERT_EQUALS(cloned->getInstrument()->getName(), "basic"); // Name of the test instrument - auto dets = cloned->getSpectrum(0)->getDetectorIDs(); + auto dets = cloned->getSpectrum(0).getDetectorIDs(); TS_ASSERT_EQUALS(dets.size(), 1); // Set the group numbers diff --git a/Framework/DataObjects/test/Histogram1DTest.h b/Framework/DataObjects/test/Histogram1DTest.h index 1d44bd541745bf8f1586f4d4cde36a405133e2a5..12eb21a75210e8ab45b28b630c5545958a5eb1e3 100644 --- a/Framework/DataObjects/test/Histogram1DTest.h +++ b/Framework/DataObjects/test/Histogram1DTest.h @@ -102,5 +102,82 @@ public: h.setData(y1, e1); TS_ASSERT_THROWS(h.dataE().at(nel), std::out_of_range); } + + void test_copy_constructor() { + const Histogram1D source; + Histogram1D clone(source); + TS_ASSERT_EQUALS(&clone.readX(), &source.readX()); + TS_ASSERT_EQUALS(&clone.readY(), &source.readY()); + TS_ASSERT_EQUALS(&clone.readE(), &source.readE()); + } + + void test_move_constructor() { + Histogram1D source; + auto oldX = &source.readX(); + auto oldY = &source.readY(); + auto oldE = &source.readE(); + Histogram1D clone(std::move(source)); + TS_ASSERT(!source.ptrX()); + TS_ASSERT_EQUALS(&clone.readX(), oldX); + TS_ASSERT_EQUALS(&clone.readY(), oldY); + TS_ASSERT_EQUALS(&clone.readE(), oldE); + } + + void test_constructor_from_ISpectrum() { + Histogram1D resource; + resource.dataX() = {0.1}; + resource.dataY() = {0.2}; + resource.dataE() = {0.3}; + const Mantid::API::ISpectrum &source = resource; + Histogram1D clone(source); + // X is shared... + TS_ASSERT_EQUALS(&clone.readX(), &source.readX()); + // .. but not Y and E, since they are not part of ISpectrum. + TS_ASSERT_DIFFERS(&clone.readY(), &source.readY()); + TS_ASSERT_DIFFERS(&clone.readE(), &source.readE()); + TS_ASSERT_EQUALS(clone.readX()[0], 0.1); + TS_ASSERT_EQUALS(clone.readY()[0], 0.2); + TS_ASSERT_EQUALS(clone.readE()[0], 0.3); + } + + void test_copy_assignment() { + const Histogram1D source; + Histogram1D clone; + clone = source; + TS_ASSERT_EQUALS(&clone.readX(), &source.readX()); + TS_ASSERT_EQUALS(&clone.readY(), &source.readY()); + TS_ASSERT_EQUALS(&clone.readE(), &source.readE()); + } + + void test_move_assignment() { + Histogram1D source; + auto oldX = &source.readX(); + auto oldY = &source.readY(); + auto oldE = &source.readE(); + Histogram1D clone; + clone = std::move(source); + TS_ASSERT(!source.ptrX()); + TS_ASSERT_EQUALS(&clone.readX(), oldX); + TS_ASSERT_EQUALS(&clone.readY(), oldY); + TS_ASSERT_EQUALS(&clone.readE(), oldE); + } + + void test_assign_ISpectrum() { + Histogram1D resource; + resource.dataX() = {0.1}; + resource.dataY() = {0.2}; + resource.dataE() = {0.3}; + const Mantid::API::ISpectrum &source = resource; + Histogram1D clone; + clone = source; + // X is shared... + TS_ASSERT_EQUALS(&clone.readX(), &source.readX()); + // .. but not Y and E, since they are not part of ISpectrum. + TS_ASSERT_DIFFERS(&clone.readY(), &source.readY()); + TS_ASSERT_DIFFERS(&clone.readE(), &source.readE()); + TS_ASSERT_EQUALS(clone.readX()[0], 0.1); + TS_ASSERT_EQUALS(clone.readY()[0], 0.2); + TS_ASSERT_EQUALS(clone.readE()[0], 0.3); + } }; #endif /*TESTHISTOGRAM1D_*/ diff --git a/Framework/DataObjects/test/SpecialWorkspace2DTest.h b/Framework/DataObjects/test/SpecialWorkspace2DTest.h index 5124ceea1f5c361d72ca731cd454566d54ef81c5..88d2f1608a15dac281f9888c1409ba1b9d225d1f 100644 --- a/Framework/DataObjects/test/SpecialWorkspace2DTest.h +++ b/Framework/DataObjects/test/SpecialWorkspace2DTest.h @@ -65,7 +65,7 @@ public: TS_ASSERT_EQUALS(ws->blocksize(), 1); TS_ASSERT_EQUALS(ws->getInstrument()->getName(), "basic"); // Name of the test instrument - const auto &dets = ws->getSpectrum(0)->getDetectorIDs(); + const auto &dets = ws->getSpectrum(0).getDetectorIDs(); TS_ASSERT_EQUALS(dets.size(), 1); TS_ASSERT_EQUALS(*(ws->getDetectorIDs(0).begin()), 1); diff --git a/Framework/DataObjects/test/Workspace2DTest.h b/Framework/DataObjects/test/Workspace2DTest.h index 059318ab6147ecbd8a8682942d122c007fe81dbc..980391ed2e73b4ba88736557d1b527e6e1ae3159 100644 --- a/Framework/DataObjects/test/Workspace2DTest.h +++ b/Framework/DataObjects/test/Workspace2DTest.h @@ -230,12 +230,9 @@ public: void testGetSpectrum() { boost::shared_ptr<MatrixWorkspace> ws = boost::make_shared<Workspace2D>(); ws->initialize(4, 1, 1); - ISpectrum *spec = NULL; - TS_ASSERT_THROWS_NOTHING(spec = ws->getSpectrum(0)); - TS_ASSERT(spec); - TS_ASSERT_THROWS_NOTHING(spec = ws->getSpectrum(3)); - TS_ASSERT(spec); - TS_ASSERT_THROWS_ANYTHING(spec = ws->getSpectrum(4)); + TS_ASSERT_THROWS_NOTHING(ws->getSpectrum(0)); + TS_ASSERT_THROWS_NOTHING(ws->getSpectrum(3)); + TS_ASSERT_THROWS_ANYTHING(ws->getSpectrum(4)); } /** @@ -290,9 +287,9 @@ public: ws1 = WorkspaceCreationHelper::Create2DWorkspaceBinned(nhist, 5); ws2 = WorkspaceCreationHelper::Create2DWorkspaceBinned(10, 5); for (size_t i = 0; i < 10; i++) { - ISpectrum *spec = ws2->getSpectrum(i); + auto &spec = ws2->getSpectrum(i); for (detid_t j = detid_t(i) * 100000; j < detid_t(i + 1) * 100000; j++) { - spec->addDetectorID(j); + spec.addDetectorID(j); } } } @@ -300,8 +297,8 @@ public: void test_ISpectrum_getDetectorIDs() { CPUTimer tim; for (size_t i = 0; i < ws1->getNumberHistograms(); i++) { - const ISpectrum *spec = ws1->getSpectrum(i); - const auto &detIDs = spec->getDetectorIDs(); + const auto &spec = ws1->getSpectrum(i); + const auto &detIDs = spec.getDetectorIDs(); detid_t oneDetId = *detIDs.begin(); UNUSED_ARG(oneDetId) } @@ -312,16 +309,16 @@ public: void test_ISpectrum_changeDetectorIDs() { CPUTimer tim; for (size_t i = 0; i < ws1->getNumberHistograms(); i++) { - ISpectrum *spec = ws1->getSpectrum(i); - spec->setDetectorID(detid_t(i)); + auto &spec = ws1->getSpectrum(i); + spec.setDetectorID(detid_t(i)); } std::cout << tim << " to set all detector IDs for " << nhist << " spectra, using the ISpectrum method (serial).\n"; PARALLEL_FOR_NO_WSP_CHECK() for (int i = 0; i < (int)ws1->getNumberHistograms(); i++) { - ISpectrum *spec = ws1->getSpectrum(i); - spec->setDetectorID(detid_t(i)); + auto &spec = ws1->getSpectrum(i); + spec.setDetectorID(detid_t(i)); } std::cout << tim << " to set all detector IDs for " << nhist << " spectra, using the ISpectrum method (in parallel).\n"; diff --git a/Framework/LiveData/src/FakeEventDataListener.cpp b/Framework/LiveData/src/FakeEventDataListener.cpp index 6c6aac9b6f98e486ee8ee37c8fb01e4656186593..8b79c5744879b02a0d97b8626ca73e5f0ae4ff2f 100644 --- a/Framework/LiveData/src/FakeEventDataListener.cpp +++ b/Framework/LiveData/src/FakeEventDataListener.cpp @@ -136,9 +136,9 @@ boost::shared_ptr<Workspace> FakeEventDataListener::extractData() { void FakeEventDataListener::generateEvents(Poco::Timer &) { std::lock_guard<std::mutex> _lock(m_mutex); for (long i = 0; i < m_callbackloop; ++i) { - m_buffer->getEventList(0) + m_buffer->getSpectrum(0) .addEventQuickly(DataObjects::TofEvent(m_rand->nextValue())); - m_buffer->getEventList(1) + m_buffer->getSpectrum(1) .addEventQuickly(DataObjects::TofEvent(m_rand->nextValue())); } diff --git a/Framework/LiveData/src/ISISHistoDataListener.cpp b/Framework/LiveData/src/ISISHistoDataListener.cpp index 2cdfdfc8a8e5bc8b7210d09444b4ea7b26239ba8..ac2b4c6cdc079e01f004ff32038b1008fda53849 100644 --- a/Framework/LiveData/src/ISISHistoDataListener.cpp +++ b/Framework/LiveData/src/ISISHistoDataListener.cpp @@ -435,8 +435,7 @@ void ISISHistoDataListener::getData(int period, int index, int count, workspace->setX(wi, m_bins[m_timeRegime]); MantidVec &y = workspace->dataY(wi); MantidVec &e = workspace->dataE(wi); - workspace->getSpectrum(wi) - ->setSpectrumNo(index + static_cast<specnum_t>(i)); + workspace->getSpectrum(wi).setSpectrumNo(index + static_cast<specnum_t>(i)); size_t shift = i * (numberOfBins + 1) + 1; y.assign(dataBuffer.begin() + shift, dataBuffer.begin() + shift + y.size()); std::transform(y.begin(), y.end(), e.begin(), dblSqrt); diff --git a/Framework/LiveData/src/ISISLiveEventDataListener.cpp b/Framework/LiveData/src/ISISLiveEventDataListener.cpp index 9e90db5fd9495e496b9c1613986381dc7c3d85d4..6eeb6f4b541f039c61075b5d403f0a16f2850215 100644 --- a/Framework/LiveData/src/ISISLiveEventDataListener.cpp +++ b/Framework/LiveData/src/ISISLiveEventDataListener.cpp @@ -388,7 +388,7 @@ void ISISLiveEventDataListener::saveEvents( for (const auto &streamEvent : data) { Mantid::DataObjects::TofEvent event(streamEvent.time_of_flight, pulseTime); m_eventBuffer[period] - ->getEventList(streamEvent.spectrum) + ->getSpectrum(streamEvent.spectrum) .addEventQuickly(event); } } diff --git a/Framework/LiveData/src/SNSLiveEventDataListener.cpp b/Framework/LiveData/src/SNSLiveEventDataListener.cpp index 428ddc6f69b8aab43f261ac50542d488a78609af..018997e1f5661f8cf7a9649f1cc6df2474ab1a28 100644 --- a/Framework/LiveData/src/SNSLiveEventDataListener.cpp +++ b/Framework/LiveData/src/SNSLiveEventDataListener.cpp @@ -511,7 +511,7 @@ bool SNSLiveEventDataListener::rxPacket(const ADARA::BeamMonitorPkt &pkt) { while (pkt.nextEvent(risingEdge, cycle, tof)) { // Add the event. Note that they're in units of 100 ns in the packet, // need to change to microseconds. - monitorBuffer->getEventList(it->second) + monitorBuffer->getSpectrum(it->second) .addEventQuickly(DataObjects::TofEvent(tof / 10.0, pktTime)); } } else { @@ -1292,7 +1292,7 @@ void SNSLiveEventDataListener::initMonitorWorkspace() { monitorsBuffer, true); // Set the id numbers for (size_t i = 0; i < monitors.size(); ++i) { - monitorsBuffer->getSpectrum(i)->setDetectorID(monitors[i]); + monitorsBuffer->getSpectrum(i).setDetectorID(monitors[i]); } m_monitorIndexMap = monitorsBuffer->getDetectorIDToWorkspaceIndexMap(true); @@ -1335,7 +1335,7 @@ void SNSLiveEventDataListener::appendEvent( if (it != m_indexMap.end()) { std::size_t workspaceIndex = it->second; Mantid::DataObjects::TofEvent event(tof, pulseTime); - m_eventBuffer->getEventList(workspaceIndex).addEventQuickly(event); + m_eventBuffer->getSpectrum(workspaceIndex).addEventQuickly(event); } else { g_log.warning() << "Invalid pixel ID: " << pixelId << " (TofF: " << tof << " microseconds)\n"; diff --git a/Framework/LiveData/src/TOPAZLiveEventDataListener.cpp b/Framework/LiveData/src/TOPAZLiveEventDataListener.cpp index e3926cb8464a06b2553da32abea1ec3ce5f4692b..e67790d8ed6bb69b1c6c1c0a01c5d58e6cdb3ed0 100644 --- a/Framework/LiveData/src/TOPAZLiveEventDataListener.cpp +++ b/Framework/LiveData/src/TOPAZLiveEventDataListener.cpp @@ -519,7 +519,7 @@ void TOPAZLiveEventDataListener::initMonitorWorkspace() { monitorsBuffer, true); // Set the id numbers for (size_t i = 0; i < monitors.size(); ++i) { - monitorsBuffer->getSpectrum(i)->setDetectorID(monitors[i]); + monitorsBuffer->getSpectrum(i).setDetectorID(monitors[i]); } m_monitorIndexMap = monitorsBuffer->getDetectorIDToWorkspaceIndexMap(true); @@ -539,7 +539,7 @@ void TOPAZLiveEventDataListener::appendEvent( if (it != m_indexMap.end()) { std::size_t workspaceIndex = it->second; Mantid::DataObjects::TofEvent event(tof, pulseTime); - m_eventBuffer->getEventList(workspaceIndex).addEventQuickly(event); + m_eventBuffer->getSpectrum(workspaceIndex).addEventQuickly(event); } else { // TODO: do we want to disable this warning? Most of the time, we // shouldn't have any invalid ID's, but if we do, we'll probably diff --git a/Framework/LiveData/test/ISISHistoDataListenerTest.h b/Framework/LiveData/test/ISISHistoDataListenerTest.h index fe421ff322ec365af1a5dae681742f20bea743f2..4b4931d60251b5863670ef95389c9432624acf93 100644 --- a/Framework/LiveData/test/ISISHistoDataListenerTest.h +++ b/Framework/LiveData/test/ISISHistoDataListenerTest.h @@ -109,15 +109,15 @@ public: TS_ASSERT_EQUALS(e[5], sqrt(97.0)); TS_ASSERT_EQUALS(e[29], sqrt(97.0)); - auto spec = ws->getSpectrum(0); - TS_ASSERT_EQUALS(spec->getSpectrumNo(), 1) - auto dets = spec->getDetectorIDs(); + auto &spec = ws->getSpectrum(0); + TS_ASSERT_EQUALS(spec.getSpectrumNo(), 1) + auto dets = spec.getDetectorIDs(); TS_ASSERT_EQUALS(dets.size(), 1); TS_ASSERT_EQUALS(*dets.begin(), 1); - spec = ws->getSpectrum(3); - TS_ASSERT_EQUALS(spec->getSpectrumNo(), 10) - dets = spec->getDetectorIDs(); + auto &spec2 = ws->getSpectrum(3); + TS_ASSERT_EQUALS(spec2.getSpectrumNo(), 10) + dets = spec2.getDetectorIDs(); TS_ASSERT_EQUALS(dets.size(), 1); TS_ASSERT_EQUALS(*dets.begin(), 4); @@ -213,27 +213,27 @@ public: TS_ASSERT_EQUALS(y[5], 1078); TS_ASSERT_EQUALS(y[29], 1078); - auto spec = ws1->getSpectrum(0); - TS_ASSERT_EQUALS(spec->getSpectrumNo(), 1) - auto dets = spec->getDetectorIDs(); + auto &spec10 = ws1->getSpectrum(0); + TS_ASSERT_EQUALS(spec10.getSpectrumNo(), 1) + auto dets = spec10.getDetectorIDs(); TS_ASSERT_EQUALS(dets.size(), 1); TS_ASSERT_EQUALS(*dets.begin(), 1); - spec = ws1->getSpectrum(3); - TS_ASSERT_EQUALS(spec->getSpectrumNo(), 4) - dets = spec->getDetectorIDs(); + auto &spec13 = ws1->getSpectrum(3); + TS_ASSERT_EQUALS(spec13.getSpectrumNo(), 4) + dets = spec13.getDetectorIDs(); TS_ASSERT_EQUALS(dets.size(), 1); TS_ASSERT_EQUALS(*dets.begin(), 4); - spec = ws2->getSpectrum(0); - TS_ASSERT_EQUALS(spec->getSpectrumNo(), 1) - dets = spec->getDetectorIDs(); + auto &spec20 = ws2->getSpectrum(0); + TS_ASSERT_EQUALS(spec20.getSpectrumNo(), 1) + dets = spec20.getDetectorIDs(); TS_ASSERT_EQUALS(dets.size(), 1); TS_ASSERT_EQUALS(*dets.begin(), 1); - spec = ws2->getSpectrum(3); - TS_ASSERT_EQUALS(spec->getSpectrumNo(), 4) - dets = spec->getDetectorIDs(); + auto &spec23 = ws2->getSpectrum(3); + TS_ASSERT_EQUALS(spec23.getSpectrumNo(), 4) + dets = spec23.getDetectorIDs(); TS_ASSERT_EQUALS(dets.size(), 1); TS_ASSERT_EQUALS(*dets.begin(), 4); diff --git a/Framework/LiveData/test/LoadLiveDataTest.h b/Framework/LiveData/test/LoadLiveDataTest.h index a301a7d9aa5e20108135e59b0414eb0d07f15060..ad1bb0c04451a1d7724f39b1ff271b7a5a45fa16 100644 --- a/Framework/LiveData/test/LoadLiveDataTest.h +++ b/Framework/LiveData/test/LoadLiveDataTest.h @@ -112,7 +112,7 @@ public: TS_ASSERT_EQUALS(ws2->getNumberEvents(), 200); TSM_ASSERT("Workspace changed when replaced", ws1 != ws2); TS_ASSERT_EQUALS(AnalysisDataService::Instance().size(), 1); - TSM_ASSERT("Events are sorted", ws2->getEventList(0).isSortedByTof()); + TSM_ASSERT("Events are sorted", ws2->getSpectrum(0).isSortedByTof()); } //-------------------------------------------------------------------------------------------- @@ -127,7 +127,7 @@ public: ws2 = doExec<EventWorkspace>("Append"); TS_ASSERT_EQUALS(ws2->getNumberHistograms(), 4); TS_ASSERT_EQUALS(AnalysisDataService::Instance().size(), 1); - TSM_ASSERT("Events are sorted", ws2->getEventList(0).isSortedByTof()); + TSM_ASSERT("Events are sorted", ws2->getSpectrum(0).isSortedByTof()); } //-------------------------------------------------------------------------------------------- @@ -146,7 +146,7 @@ public: TS_ASSERT_EQUALS(ws2->getNumberEvents(), 400); TSM_ASSERT("Workspace being added stayed the same pointer", ws1 == ws2); - TSM_ASSERT("Events are sorted", ws2->getEventList(0).isSortedByTof()); + TSM_ASSERT("Events are sorted", ws2->getSpectrum(0).isSortedByTof()); TS_ASSERT_EQUALS(AnalysisDataService::Instance().size(), 1); // Test monitor workspace is present @@ -265,8 +265,8 @@ public: TS_ASSERT_DELTA(ws->dataX(0)[0], 40e3, 1e-4); TS_ASSERT_EQUALS(AnalysisDataService::Instance().size(), 2); - TSM_ASSERT("Events are sorted", ws_accum->getEventList(0).isSortedByTof()); - TSM_ASSERT("Events are sorted", ws->getEventList(0).isSortedByTof()); + TSM_ASSERT("Events are sorted", ws_accum->getSpectrum(0).isSortedByTof()); + TSM_ASSERT("Events are sorted", ws->getSpectrum(0).isSortedByTof()); } //-------------------------------------------------------------------------------------------- @@ -295,8 +295,8 @@ public: TS_ASSERT_DELTA(ws->dataX(0)[0], 40e3, 1e-4); TS_ASSERT_EQUALS(AnalysisDataService::Instance().size(), 2); - TSM_ASSERT("Events are sorted", ws_accum->getEventList(0).isSortedByTof()); - TSM_ASSERT("Events are sorted", ws->getEventList(0).isSortedByTof()); + TSM_ASSERT("Events are sorted", ws_accum->getSpectrum(0).isSortedByTof()); + TSM_ASSERT("Events are sorted", ws->getSpectrum(0).isSortedByTof()); } //-------------------------------------------------------------------------------------------- diff --git a/Framework/LiveData/test/TestDataListener.cpp b/Framework/LiveData/test/TestDataListener.cpp index 82e2684d42e41c91d14ceda5fefeb6cb93858c0c..91c958ff2c34e7a58dc82625e8603a3ed8e266e4 100644 --- a/Framework/LiveData/test/TestDataListener.cpp +++ b/Framework/LiveData/test/TestDataListener.cpp @@ -86,7 +86,7 @@ void TestDataListener::createEmptyWorkspace() { WorkspaceFactory::Instance().create("EventWorkspace", 2, 2, 1)); // Give detector IDs for (size_t i = 0; i < m_buffer->getNumberHistograms(); i++) - m_buffer->getSpectrum(i)->setDetectorID(detid_t(i)); + m_buffer->getSpectrum(i).setDetectorID(detid_t(i)); // Create in TOF units m_buffer->getAxis(0)->setUnit("TOF"); // Load a fake instrument @@ -109,15 +109,15 @@ boost::shared_ptr<Workspace> TestDataListener::extractData() { // Add a small number of uniformly distributed events to each event list. using namespace DataObjects; - EventList &el1 = m_buffer->getEventList(0); - EventList &el2 = m_buffer->getEventList(1); + EventList &el1 = m_buffer->getSpectrum(0); + EventList &el2 = m_buffer->getSpectrum(1); for (int i = 0; i < 100; ++i) { el1.addEventQuickly(TofEvent(m_rand->nextValue())); el2.addEventQuickly(TofEvent(m_rand->nextValue())); } auto mon_buffer = boost::dynamic_pointer_cast<EventWorkspace>(m_buffer->monitorWorkspace()); - mon_buffer->getEventList(0).addEventQuickly(TofEvent(m_rand->nextValue())); + mon_buffer->getSpectrum(0).addEventQuickly(TofEvent(m_rand->nextValue())); // Copy the workspace pointer to a temporary variable EventWorkspace_sptr extracted = m_buffer; diff --git a/Framework/MDAlgorithms/src/ConvToMDEventsWS.cpp b/Framework/MDAlgorithms/src/ConvToMDEventsWS.cpp index d03f9157cc878d023ddbbd284f5a4933cb764406..d063563ec66050d5924100345bfb46bf3eb19f4b 100644 --- a/Framework/MDAlgorithms/src/ConvToMDEventsWS.cpp +++ b/Framework/MDAlgorithms/src/ConvToMDEventsWS.cpp @@ -10,7 +10,7 @@ template <class T> size_t ConvToMDEventsWS::convertEventList(size_t workspaceIndex) { const Mantid::DataObjects::EventList &el = - m_EventWS->getEventList(workspaceIndex); + m_EventWS->getSpectrum(workspaceIndex); size_t numEvents = el.getNumberEvents(); if (numEvents == 0) return 0; @@ -72,7 +72,7 @@ size_t ConvToMDEventsWS::convertEventList(size_t workspaceIndex) { * particular workspace index */ size_t ConvToMDEventsWS::conversionChunk(size_t workspaceIndex) { - switch (m_EventWS->getEventList(workspaceIndex).getEventType()) { + switch (m_EventWS->getSpectrum(workspaceIndex).getEventType()) { case Mantid::API::TOF: return this->convertEventList<Mantid::DataObjects::TofEvent>( workspaceIndex); diff --git a/Framework/MDAlgorithms/src/ConvertToDetectorFaceMD.cpp b/Framework/MDAlgorithms/src/ConvertToDetectorFaceMD.cpp index 349367186aec3bcacc203ea1b34453d0b614f86e..8c1879465bc96e63bbfb0d529e4e4e7b55480e7d 100644 --- a/Framework/MDAlgorithms/src/ConvertToDetectorFaceMD.cpp +++ b/Framework/MDAlgorithms/src/ConvertToDetectorFaceMD.cpp @@ -87,7 +87,7 @@ void ConvertToDetectorFaceMD::convertEventList( boost::shared_ptr<Mantid::DataObjects::MDEventWorkspace<MDE, nd>> outWS, size_t workspaceIndex, coord_t x, coord_t y, coord_t bankNum, uint16_t runIndex, int32_t detectorID) { - EventList &el = in_ws->getEventList(workspaceIndex); + EventList &el = in_ws->getSpectrum(workspaceIndex); // The 3/4D DataObjects that will be added into the MDEventWorkspce std::vector<MDE> out_events; @@ -282,7 +282,7 @@ void ConvertToDetectorFaceMD::exec() { coord_t yPos = static_cast<coord_t>(y); coord_t bankPos = static_cast<coord_t>(bankNum); - EventList &el = in_ws->getEventList(wi); + EventList &el = in_ws->getSpectrum(wi); // We want to bind to the right templated function, so we have to know // the type of TofEvent contained in the EventList. diff --git a/Framework/MDAlgorithms/src/ConvertToDiffractionMDWorkspace.cpp b/Framework/MDAlgorithms/src/ConvertToDiffractionMDWorkspace.cpp index c1a9e698faf3efbd2c62d112ed97e84054b118cd..bc007bc444b2b6ac3d75e7470cfd34746757ddcd 100644 --- a/Framework/MDAlgorithms/src/ConvertToDiffractionMDWorkspace.cpp +++ b/Framework/MDAlgorithms/src/ConvertToDiffractionMDWorkspace.cpp @@ -138,7 +138,7 @@ typedef DataObjects::MDLeanEvent<3> MDE; void ConvertToDiffractionMDWorkspace::convertSpectrum(int workspaceIndex) { if (m_inEventWS && !OneEventPerBin) { // ---------- Convert events directly ------------------------- - EventList &el = m_inEventWS->getEventList(workspaceIndex); + EventList &el = m_inEventWS->getSpectrum(workspaceIndex); // Call the right templated function switch (el.getEventType()) { @@ -161,11 +161,11 @@ void ConvertToDiffractionMDWorkspace::convertSpectrum(int workspaceIndex) { EventList el; // Create the events using the bins - const ISpectrum *inSpec = m_inWS->getSpectrum(workspaceIndex); + const auto &inSpec = m_inWS->getSpectrum(workspaceIndex); // If OneEventPerBin, generate exactly 1 event per bin, including zeros. // If !OneEventPerBin, generate up to 10 events per bin, excluding zeros el.createFromHistogram( - inSpec, OneEventPerBin /* Generate zeros */, + &inSpec, OneEventPerBin /* Generate zeros */, !OneEventPerBin /* Multiple events */, (OneEventPerBin ? 1 : 10) /* Max of this many events per bin */); @@ -527,7 +527,7 @@ void ConvertToDiffractionMDWorkspace::exec() { // Get an idea of how many events we'll be adding size_t eventsAdding = m_inWS->blocksize(); if (m_inEventWS && !OneEventPerBin) - eventsAdding = m_inEventWS->getEventList(wi).getNumberEvents(); + eventsAdding = m_inEventWS->getSpectrum(wi).getNumberEvents(); if (MultiThreadedAdding) { // Equivalent to calling "this->convertSpectrum(wi)" diff --git a/Framework/MDAlgorithms/src/ConvertToMD.cpp b/Framework/MDAlgorithms/src/ConvertToMD.cpp index ed28553f66b9aac4b6a89fd619598437a1311ea2..4121b67405a032b4f524f569ba7b6af7af41e081 100644 --- a/Framework/MDAlgorithms/src/ConvertToMD.cpp +++ b/Framework/MDAlgorithms/src/ConvertToMD.cpp @@ -359,7 +359,7 @@ void ConvertToMD::copyMetaData(API::IMDEventWorkspace_sptr &mdEventWS) const { // objects instead auto mapping = boost::make_shared<det2group_map>(); for (size_t i = 0; i < m_InWS2D->getNumberHistograms(); ++i) { - const auto &dets = m_InWS2D->getSpectrum(i)->getDetectorIDs(); + const auto &dets = m_InWS2D->getSpectrum(i).getDetectorIDs(); if (!dets.empty()) { mapping->emplace(*dets.begin(), std::vector<detid_t>(dets.begin(), dets.end())); diff --git a/Framework/MDAlgorithms/src/ConvertToMDMinMaxLocal.cpp b/Framework/MDAlgorithms/src/ConvertToMDMinMaxLocal.cpp index 75f537dff7687a7df1d7e215a69e9571110af9b0..df851913936b7219885b1c0885693e632355f6ba 100644 --- a/Framework/MDAlgorithms/src/ConvertToMDMinMaxLocal.cpp +++ b/Framework/MDAlgorithms/src/ConvertToMDMinMaxLocal.cpp @@ -165,7 +165,7 @@ void ConvertToMDMinMaxLocal::findMinMaxValues(MDWSDescription &WSDescription, pQtransf->calcYDepCoordinates(locCoord, iSpctr); // get the range of the input data in the spectra - auto source_range = inWS->getSpectrum(iSpctr)->getXDataRange(); + auto source_range = inWS->getSpectrum(iSpctr).getXDataRange(); // extract part of this range which has well defined unit conversion source_range = unitsConverter.getConversionRange(source_range.first, diff --git a/Framework/MDAlgorithms/src/IntegrateEllipsoids.cpp b/Framework/MDAlgorithms/src/IntegrateEllipsoids.cpp index 8ad64f634377134316a76ca3d3c4b611f3f7820a..6bc0ceab80b68fa40da80f9782e6990891dbcc65 100644 --- a/Framework/MDAlgorithms/src/IntegrateEllipsoids.cpp +++ b/Framework/MDAlgorithms/src/IntegrateEllipsoids.cpp @@ -68,7 +68,7 @@ void IntegrateEllipsoids::qListFromEventWS(Integrate3DEvents &integrator, std::vector<double> buffer(DIMS); // get a reference to the event list - EventList &events = wksp->getEventList(i); + EventList &events = wksp->getSpectrum(i); events.switchTo(WEIGHTED_NOTIME); events.compressEvents(1e-5, &events); diff --git a/Framework/MDAlgorithms/src/IntegrateFlux.cpp b/Framework/MDAlgorithms/src/IntegrateFlux.cpp index 054a06d29539982bd5488c93b6c4c64071fe565c..34f10cba4298e4eed60448525a59a10eef457352 100644 --- a/Framework/MDAlgorithms/src/IntegrateFlux.cpp +++ b/Framework/MDAlgorithms/src/IntegrateFlux.cpp @@ -178,7 +178,7 @@ void IntegrateFlux::integrateSpectraEvents( // loop overr the spectra and integrate for (size_t sp = 0; sp < nSpec; ++sp) { const std::vector<EventType> *el; - DataObjects::getEventsFrom(inputWS.getEventList(sp), el); + DataObjects::getEventsFrom(inputWS.getSpectrum(sp), el); auto &outY = integrWS.dataY(sp); double sum = 0; auto x = X.begin() + 1; @@ -479,7 +479,7 @@ IntegrateFlux::getMaxNumberOfPoints(const API::MatrixWorkspace &inputWS) const { // if it's events we shouldn't care about binning auto eventWS = dynamic_cast<const DataObjects::EventWorkspace *>(&inputWS); if (eventWS) { - return eventWS->getEventList(0).getNumberEvents(); + return eventWS->getSpectrum(0).getNumberEvents(); } return inputWS.blocksize(); diff --git a/Framework/MDAlgorithms/src/SaveIsawQvector.cpp b/Framework/MDAlgorithms/src/SaveIsawQvector.cpp index 8486438fda85ca49d82de35bf4781efd6aa214de..395f1bea6ff71a11e6a40dd07c4b28dbc01a88b1 100644 --- a/Framework/MDAlgorithms/src/SaveIsawQvector.cpp +++ b/Framework/MDAlgorithms/src/SaveIsawQvector.cpp @@ -149,7 +149,7 @@ void SaveIsawQvector::exec() { std::vector<double> Qx_save, Qy_save, Qz_save; for (std::size_t i = 0; i < numSpectra; ++i) { // get a reference to the event list - const EventList &events = wksp->getEventList(i); + const EventList &events = wksp->getSpectrum(i); // check to see if the event list is empty if (events.empty()) { diff --git a/Framework/MDAlgorithms/test/ConvertToDetectorFaceMDTest.h b/Framework/MDAlgorithms/test/ConvertToDetectorFaceMDTest.h index c1ac0083f23859481dea962a9b23d0044ff2bee1..603cfbdd38791f34d74328fb435a5acd848361b6 100644 --- a/Framework/MDAlgorithms/test/ConvertToDetectorFaceMDTest.h +++ b/Framework/MDAlgorithms/test/ConvertToDetectorFaceMDTest.h @@ -40,7 +40,7 @@ public: false); if ((type == WEIGHTED) || (type == WEIGHTED_NOTIME)) { for (size_t i = 0; i < in_ws->getNumberHistograms(); i++) { - EventList &el = in_ws->getEventList(i); + EventList &el = in_ws->getSpectrum(i); if (type == WEIGHTED) el.multiply(2.0); else diff --git a/Framework/MDAlgorithms/test/ConvertToDiffractionMDWorkspace2Test.h b/Framework/MDAlgorithms/test/ConvertToDiffractionMDWorkspace2Test.h index e95eb552bcd61d9f3537d1fe4f84e49ac761a769..6104965eb40f5b8c0c5eef1bf829ac6cd92043e6 100644 --- a/Framework/MDAlgorithms/test/ConvertToDiffractionMDWorkspace2Test.h +++ b/Framework/MDAlgorithms/test/ConvertToDiffractionMDWorkspace2Test.h @@ -107,7 +107,7 @@ public: in_ws *= 2.0; if (type == WEIGHTED_NOTIME) { for (size_t i = 0; i < in_ws->getNumberHistograms(); i++) { - EventList &el = in_ws->getEventList(i); + EventList &el = in_ws->getSpectrum(i); el.compressEvents(0.0, &el); } } diff --git a/Framework/MDAlgorithms/test/ConvertToDiffractionMDWorkspaceTest.h b/Framework/MDAlgorithms/test/ConvertToDiffractionMDWorkspaceTest.h index 2f7d1a4b887d2cdc796256efbed0c6eb1b71b737..c3078c822402748c84ca1365858f3540a60608f0 100644 --- a/Framework/MDAlgorithms/test/ConvertToDiffractionMDWorkspaceTest.h +++ b/Framework/MDAlgorithms/test/ConvertToDiffractionMDWorkspaceTest.h @@ -136,7 +136,7 @@ public: in_ws *= 2.0; if (type == WEIGHTED_NOTIME) { for (size_t i = 0; i < in_ws->getNumberHistograms(); i++) { - EventList &el = in_ws->getEventList(i); + EventList &el = in_ws->getSpectrum(i); el.compressEvents(0.0, &el); } } diff --git a/Framework/MDAlgorithms/test/ConvertToMDMinMaxGlobalTest.h b/Framework/MDAlgorithms/test/ConvertToMDMinMaxGlobalTest.h index 9899e57ac1c70a9528384efee762f584c486da6c..01bf2db558067efbdc651f8bc5579df310e944cb 100644 --- a/Framework/MDAlgorithms/test/ConvertToMDMinMaxGlobalTest.h +++ b/Framework/MDAlgorithms/test/ConvertToMDMinMaxGlobalTest.h @@ -212,7 +212,7 @@ private: testInst->add(physicalPixel); testInst->markAsDetector(physicalPixel); - ws->getSpectrum(0)->addDetectorID(physicalPixel->getID()); + ws->getSpectrum(0).addDetectorID(physicalPixel->getID()); if (Ei > 0) { ws->mutableRun().addProperty( diff --git a/Framework/MDAlgorithms/test/ConvertToMDMinMaxLocalTest.h b/Framework/MDAlgorithms/test/ConvertToMDMinMaxLocalTest.h index 0e7f78fc93f78a316e19b43d75f43b7d76fbca20..fb7a71ff0a6537601383adb2ca74339021dd4a36 100644 --- a/Framework/MDAlgorithms/test/ConvertToMDMinMaxLocalTest.h +++ b/Framework/MDAlgorithms/test/ConvertToMDMinMaxLocalTest.h @@ -232,7 +232,7 @@ private: testInst->add(physicalPixel); testInst->markAsDetector(physicalPixel); - ws->getSpectrum(0)->addDetectorID(physicalPixel->getID()); + ws->getSpectrum(0).addDetectorID(physicalPixel->getID()); if (Ei > 0) { ws->mutableRun().addProperty( diff --git a/Framework/MDAlgorithms/test/IntegrateEllipsoidsTest.h b/Framework/MDAlgorithms/test/IntegrateEllipsoidsTest.h index aa1e3d2ade792b78134202da36c1063857a0938d..d34c891138f86989b8602f6ea1601865e9562b82 100644 --- a/Framework/MDAlgorithms/test/IntegrateEllipsoidsTest.h +++ b/Framework/MDAlgorithms/test/IntegrateEllipsoidsTest.h @@ -31,7 +31,7 @@ void addFakeEllipsoid(const V3D &peakHKL, const int &totalNPixels, const double tofExact = peak->getTOF(); delete peak; - EventList &el = eventWS->getEventList(detectorId - totalNPixels); + EventList &el = eventWS->getSpectrum(detectorId - totalNPixels); // Add more events to the event list corresponding to the peak centre double start = tofExact - (double(nEvents) / 2 * tofGap); diff --git a/Framework/MPIAlgorithms/src/GatherWorkspaces.cpp b/Framework/MPIAlgorithms/src/GatherWorkspaces.cpp index d34038ab70ac9a3a40dd5870223568fbd755e342..e4e655c401780482505ab3a360a4779bba9dac66 100644 --- a/Framework/MPIAlgorithms/src/GatherWorkspaces.cpp +++ b/Framework/MPIAlgorithms/src/GatherWorkspaces.cpp @@ -169,7 +169,7 @@ void GatherWorkspaces::exec() { for (size_t wi = 0; wi < totalSpec; wi++) { if (included.rank() == 0) { - const ISpectrum *inSpec = inputWorkspace->getSpectrum(wi); + const auto &inSpec = inputWorkspace->getSpectrum(wi); if (accum == "Add") { outputWorkspace->dataX(wi) = inputWorkspace->readX(wi); reduce(included, inputWorkspace->readY(wi), outputWorkspace->dataY(wi), @@ -196,17 +196,17 @@ void GatherWorkspaces::exec() { reqs[j++] = included.irecv(i, 0, outputWorkspace->dataX(index)); reqs[j++] = included.irecv(i, 1, outputWorkspace->dataY(index)); reqs[j++] = included.irecv(i, 2, outputWorkspace->dataE(index)); - ISpectrum *outSpec = outputWorkspace->getSpectrum(index); - outSpec->clearDetectorIDs(); - outSpec->addDetectorIDs(inSpec->getDetectorIDs()); + auto &outSpec = outputWorkspace->getSpectrum(index); + outSpec.clearDetectorIDs(); + outSpec.addDetectorIDs(inSpec.getDetectorIDs()); } // Make sure everything's been received before exiting the algorithm mpi::wait_all(reqs.begin(), reqs.end()); } - ISpectrum *outSpec = outputWorkspace->getSpectrum(wi); - outSpec->clearDetectorIDs(); - outSpec->addDetectorIDs(inSpec->getDetectorIDs()); + auto &outSpec = outputWorkspace->getSpectrum(wi); + outSpec.clearDetectorIDs(); + outSpec.addDetectorIDs(inSpec.getDetectorIDs()); } else { if (accum == "Add") { reduce(included, inputWorkspace->readY(wi), vplus(), 0); @@ -250,20 +250,20 @@ void GatherWorkspaces::execEvent() { // How do we accumulate the data? std::string accum = this->getPropertyValue("AccumulationMethod"); std::vector<Mantid::DataObjects::EventList> out_values; - gather(included, eventW->getEventList(wi), out_values, 0); + gather(included, eventW->getSpectrum(wi), out_values, 0); for (int i = 0; i < included.size(); i++) { size_t index = wi; // accum == "Add" if (accum == "Append") index = wi + i * totalSpec; outputWorkspace->dataX(index) = eventW->readX(wi); outputWorkspace->getOrAddEventList(index) += out_values[i]; - const ISpectrum *inSpec = eventW->getSpectrum(wi); - ISpectrum *outSpec = outputWorkspace->getSpectrum(index); - outSpec->clearDetectorIDs(); - outSpec->addDetectorIDs(inSpec->getDetectorIDs()); + const auto &inSpec = eventW->getSpectrum(wi); + auto &outSpec = outputWorkspace->getSpectrum(index); + outSpec.clearDetectorIDs(); + outSpec.addDetectorIDs(inSpec.getDetectorIDs()); } } else { - gather(included, eventW->getEventList(wi), 0); + gather(included, eventW->getSpectrum(wi), 0); } } } diff --git a/Framework/Nexus/src/NexusFileIO.cpp b/Framework/Nexus/src/NexusFileIO.cpp index c390c7430cd46eaf500f90cab045d781ada4cd4c..d9c91a88152f67219ed728330221a49b7abec4b1 100644 --- a/Framework/Nexus/src/NexusFileIO.cpp +++ b/Framework/Nexus/src/NexusFileIO.cpp @@ -773,7 +773,7 @@ int NexusFileIO::writeNexusProcessedDataEvent( for (size_t wi = 0; wi < ws->getNumberHistograms(); wi++) { std::ostringstream group_name; group_name << "event_list_" << wi; - this->writeEventList(ws->getEventList(wi), group_name.str()); + this->writeEventList(ws->getSpectrum(wi), group_name.str()); } // Close up the overall group diff --git a/Framework/PythonInterface/mantid/api/src/Exports/IEventWorkspace.cpp b/Framework/PythonInterface/mantid/api/src/Exports/IEventWorkspace.cpp index d577ddabc9e5007c6a8d9f6e6d390e9bf80beb65..cc0473445fe86593b2ee1e118a5a9828b987af90 100644 --- a/Framework/PythonInterface/mantid/api/src/Exports/IEventWorkspace.cpp +++ b/Framework/PythonInterface/mantid/api/src/Exports/IEventWorkspace.cpp @@ -9,6 +9,19 @@ using namespace Mantid::API; using Mantid::PythonInterface::Registry::RegisterWorkspacePtrToPython; using namespace boost::python; +namespace { +/** + * Returns a reference to EventList and raises a deprecation warning + * @param self A reference to calling object + * @param index Workspace index + */ +IEventList &deprecatedGetEventList(IEventWorkspace &self, const size_t index) { + PyErr_Warn(PyExc_DeprecationWarning, + "'getEventList' is deprecated, use 'getSpectrum' instead."); + return self.getSpectrum(index); +} +} + /** * Python exports of the Mantid::API::IEventWorkspace class. */ @@ -23,8 +36,7 @@ void export_IEventWorkspace() { .def("getTofMax", &IEventWorkspace::getTofMax, args("self"), "Returns the maximum TOF value (in microseconds) held by the " "workspace") - .def("getEventList", (IEventList * (IEventWorkspace::*)(const int)) & - IEventWorkspace::getEventListPtr, + .def("getEventList", &deprecatedGetEventList, return_internal_reference<>(), args("self", "workspace_index"), "Return the event list managing the events at the given workspace " "index") diff --git a/Framework/PythonInterface/mantid/api/src/Exports/MatrixWorkspace.cpp b/Framework/PythonInterface/mantid/api/src/Exports/MatrixWorkspace.cpp index c8e1d7fd9d7de0ce17ada4d2c3bcb61fd95a837a..a6109d023e819e7efb2ded22cc6dda9c977b1b39 100644 --- a/Framework/PythonInterface/mantid/api/src/Exports/MatrixWorkspace.cpp +++ b/Framework/PythonInterface/mantid/api/src/Exports/MatrixWorkspace.cpp @@ -202,7 +202,7 @@ void export_MatrixWorkspace() { .def("detectorSignedTwoTheta", &MatrixWorkspace::detectorSignedTwoTheta, (arg("self"), arg("det")), "Returns the signed two theta value for given detector") - .def("getSpectrum", (ISpectrum * (MatrixWorkspace::*)(const size_t)) & + .def("getSpectrum", (ISpectrum & (MatrixWorkspace::*)(const size_t)) & MatrixWorkspace::getSpectrum, (arg("self"), arg("workspaceIndex")), return_internal_reference<>(), "Return the spectra at the given workspace index.") diff --git a/Framework/PythonInterface/test/python/mantid/api/IEventWorkspaceTest.py b/Framework/PythonInterface/test/python/mantid/api/IEventWorkspaceTest.py index ce5cc3175e0d6e249f391270bf421ccab4262263..842c6b26c084a573225592cf998e67cc2c25fd22 100644 --- a/Framework/PythonInterface/test/python/mantid/api/IEventWorkspaceTest.py +++ b/Framework/PythonInterface/test/python/mantid/api/IEventWorkspaceTest.py @@ -33,19 +33,19 @@ class IEventWorkspaceTest(unittest.TestCase): self.assertFalse(error_raised) def test_event_list_is_return_as_correct_type(self): - el = self._test_ws.getEventList(0) + el = self._test_ws.getSpectrum(0) self.assertTrue(isinstance(el, IEventList)) self.assertEquals(el.getNumberEvents(), 200) def test_event_list_getWeights(self): - el = self._test_ws.getEventList(0) + el = self._test_ws.getSpectrum(0) self.assertTrue(isinstance(el, IEventList)) TofList = el.getTofs() self.assertEquals(len(TofList), el.getNumberEvents()) #check length self.assertAlmostEquals(TofList[0], 0.5) #first value def test_event_list_getWeights(self): - el = self._test_ws.getEventList(0) + el = self._test_ws.getSpectrum(0) self.assertTrue(isinstance(el, IEventList)) weightList = el.getWeights() self.assertEquals(len(weightList), el.getNumberEvents()) #check length @@ -53,13 +53,18 @@ class IEventWorkspaceTest(unittest.TestCase): self.assertAlmostEquals(weightList[len(weightList)-1], 1.0) #last value def test_event_list_getWeightErrors(self): - el = self._test_ws.getEventList(0) + el = self._test_ws.getSpectrum(0) self.assertTrue(isinstance(el, IEventList)) weightErrorList = el.getWeightErrors() self.assertEquals(len(weightErrorList), el.getNumberEvents()) #check length self.assertAlmostEquals(weightErrorList[0], 1.0) #first value self.assertAlmostEquals(weightErrorList[len(weightErrorList)-1], 1.0) #last value + def test_deprecated_getEventList(self): + el = self._test_ws.getEventList(0) + self.assertTrue(isinstance(el, IEventList)) + self.assertEquals(el.getNumberEvents(), 200) + if __name__ == '__main__': unittest.main() diff --git a/Framework/SINQ/src/LoadFlexiNexus.cpp b/Framework/SINQ/src/LoadFlexiNexus.cpp index f8ebb7f754222c723afc4c1e4f9d85df54e701b0..a26f4366b6567c0d43a2c4ebd4847a9d9fd849c1 100644 --- a/Framework/SINQ/src/LoadFlexiNexus.cpp +++ b/Framework/SINQ/src/LoadFlexiNexus.cpp @@ -170,9 +170,9 @@ void LoadFlexiNexus::load2DWorkspace(NeXus::File *fin) { ws->setX(wsIndex, xData); // Xtof ws->getAxis(1)->spectraNo(i)= i; ws->getSpectrum(wsIndex) - ->setSpectrumNo(static_cast<specnum_t>(yData[wsIndex])); + .setSpectrumNo(static_cast<specnum_t>(yData[wsIndex])); ws->getSpectrum(wsIndex) - ->setDetectorID(static_cast<detid_t>(yData[wsIndex])); + .setDetectorID(static_cast<detid_t>(yData[wsIndex])); } ws->setYUnit("Counts"); diff --git a/Framework/SINQ/src/MDHistoToWorkspace2D.cpp b/Framework/SINQ/src/MDHistoToWorkspace2D.cpp index 25667c87898645b3fa054c71ff9124b0bb03f2cb..cfd672dc7392b1ee69473ac2f0ac6e983cd99475 100644 --- a/Framework/SINQ/src/MDHistoToWorkspace2D.cpp +++ b/Framework/SINQ/src/MDHistoToWorkspace2D.cpp @@ -98,7 +98,7 @@ void MDHistoToWorkspace2D::recurseData(IMDHistoWorkspace_sptr inWS, } outWS->setX(m_currentSpectra, xData); outWS->getSpectrum(m_currentSpectra) - ->setSpectrumNo(static_cast<specnum_t>(m_currentSpectra)); + .setSpectrumNo(static_cast<specnum_t>(m_currentSpectra)); m_currentSpectra++; } else { // recurse deeper @@ -118,10 +118,10 @@ void MDHistoToWorkspace2D::checkW2D( g_log.information() << "W2D has " << nSpectra << " histograms of length " << length; for (size_t i = 0; i < nSpectra; i++) { - ISpectrum *spec = outWS->getSpectrum(i); - x = spec->dataX(); - y = spec->dataY(); - e = spec->dataE(); + auto &spec = outWS->getSpectrum(i); + x = spec.dataX(); + y = spec.dataY(); + e = spec.dataE(); if (x.size() != length) { g_log.information() << "Spectrum " << i << " x-size mismatch, is " << x.size() << " should be " << length << "\n"; diff --git a/Framework/TestHelpers/inc/MantidTestHelpers/FakeObjects.h b/Framework/TestHelpers/inc/MantidTestHelpers/FakeObjects.h index b33ffb3b53b73cac7e196d7aa9e53b0d652a9492..47a01d00104f935d9427d150ee9dab9c7dca7e85 100644 --- a/Framework/TestHelpers/inc/MantidTestHelpers/FakeObjects.h +++ b/Framework/TestHelpers/inc/MantidTestHelpers/FakeObjects.h @@ -121,10 +121,9 @@ public: size_t blocksize() const override { return vec.empty() ? 0 : vec[0].dataY().size(); } - ISpectrum *getSpectrum(const size_t index) override { return &vec[index]; } - const ISpectrum *getSpectrum(const size_t index) const override { - return &vec[index]; - ; + ISpectrum &getSpectrum(const size_t index) override { return vec[index]; } + const ISpectrum &getSpectrum(const size_t index) const override { + return vec[index]; } void generateHistogram(const std::size_t, const MantidVec &, MantidVec &, MantidVec &, bool) const override {} diff --git a/Framework/TestHelpers/src/InstrumentCreationHelper.cpp b/Framework/TestHelpers/src/InstrumentCreationHelper.cpp index 1015c18941c219de06b3ca8226635e776d5181c9..cdf9f76f888d2133deb80fce1a0d899f7b027d20 100644 --- a/Framework/TestHelpers/src/InstrumentCreationHelper.cpp +++ b/Framework/TestHelpers/src/InstrumentCreationHelper.cpp @@ -42,7 +42,7 @@ void addFullInstrumentToWorkspace(MatrixWorkspace &workspace, physicalPixel->setPos(0.0, ypos, detZPos); instrument->add(physicalPixel); instrument->markAsDetector(physicalPixel); - workspace.getSpectrum(i)->setDetectorID(physicalPixel->getID()); + workspace.getSpectrum(i).setDetectorID(physicalPixel->getID()); } // Monitors last @@ -54,7 +54,7 @@ void addFullInstrumentToWorkspace(MatrixWorkspace &workspace, monitor1->setPos(0.0, 0.0, -9.0); instrument->add(monitor1); instrument->markAsMonitor(monitor1); - workspace.getSpectrum(ndets)->setDetectorID(ndets + 1); + workspace.getSpectrum(ndets).setDetectorID(ndets + 1); Detector *monitor2 = new Detector("mon2", workspace.getAxis(1)->spectraNo(ndets) + 1, @@ -62,7 +62,7 @@ void addFullInstrumentToWorkspace(MatrixWorkspace &workspace, monitor2->setPos(0.0, 0.0, -2.0); instrument->add(monitor2); instrument->markAsMonitor(monitor2); - workspace.getSpectrum(ndets + 1)->setDetectorID(ndets + 2); + workspace.getSpectrum(ndets + 1).setDetectorID(ndets + 2); } // Define a source and sample position diff --git a/Framework/TestHelpers/src/MDEventsTestHelper.cpp b/Framework/TestHelpers/src/MDEventsTestHelper.cpp index bf524406a8e8c76fe35093e265da4072264fc711..dd7adb9f890e8b1d1423ad07fead5ae5caf8956c 100644 --- a/Framework/TestHelpers/src/MDEventsTestHelper.cpp +++ b/Framework/TestHelpers/src/MDEventsTestHelper.cpp @@ -81,10 +81,10 @@ createDiffractionEventWorkspace(int numEvents, int numPixels, int numBins) { for (int pix = 0; pix < numPixels; pix++) { for (int i = 0; i < numEvents; i++) { - retVal->getEventList(pix) += Mantid::DataObjects::TofEvent( + retVal->getSpectrum(pix) += Mantid::DataObjects::TofEvent( (i + 0.5) * binDelta, run_start + double(i)); } - retVal->getEventList(pix).addDetectorID(pix); + retVal->getSpectrum(pix).addDetectorID(pix); } // Create the x-axis for histogramming. diff --git a/Framework/TestHelpers/src/SANSInstrumentCreationHelper.cpp b/Framework/TestHelpers/src/SANSInstrumentCreationHelper.cpp index 4bba77e6dea5ef7db5ecfe600153f5b813e2011a..e367ec58f3609ae10c83512e401ba2dc2ff48254 100644 --- a/Framework/TestHelpers/src/SANSInstrumentCreationHelper.cpp +++ b/Framework/TestHelpers/src/SANSInstrumentCreationHelper.cpp @@ -125,17 +125,17 @@ void SANSInstrumentCreationHelper::runLoadMappingTable( // Monitor: IDs start at 1 and increment by 1 for (size_t i = 0; i < nMonitors; i++) { // std::cout << "SANS instrument monitor number " << i << '\n'; - workspace->getSpectrum(wi)->setSpectrumNo(specnum_t(wi)); - workspace->getSpectrum(wi)->setDetectorID(detid_t(wi + 1)); + workspace->getSpectrum(wi).setSpectrumNo(specnum_t(wi)); + workspace->getSpectrum(wi).setDetectorID(detid_t(wi + 1)); wi++; } // Detector pixels for (size_t ix = 0; ix < nXbins; ix++) { for (size_t iy = 0; iy < nYbins; iy++) { - workspace->getSpectrum(wi)->setSpectrumNo(specnum_t(wi)); + workspace->getSpectrum(wi).setSpectrumNo(specnum_t(wi)); workspace->getSpectrum(wi) - ->setDetectorID(detid_t(1000000 + iy * 1000 + ix)); + .setDetectorID(detid_t(1000000 + iy * 1000 + ix)); wi++; } } diff --git a/Framework/TestHelpers/src/WorkspaceCreationHelper.cpp b/Framework/TestHelpers/src/WorkspaceCreationHelper.cpp index 4e810a0a46a638216c4c3ea13e8171b868625a80..3e1884e77d4e3f5e1fa9d41e5a184133da747fcd 100644 --- a/Framework/TestHelpers/src/WorkspaceCreationHelper.cpp +++ b/Framework/TestHelpers/src/WorkspaceCreationHelper.cpp @@ -165,8 +165,8 @@ Create2DWorkspaceWithValues(int64_t nHist, int64_t nBins, bool isHist, for (int i = 0; i < nHist; i++) { retVal->setX(i, x1); retVal->setData(i, y1, e1); - retVal->getSpectrum(i)->setDetectorID(i); - retVal->getSpectrum(i)->setSpectrumNo(i); + retVal->getSpectrum(i).setDetectorID(i); + retVal->getSpectrum(i).setSpectrumNo(i); } retVal = maskSpectra(retVal, maskedWorkspaceIndices); return retVal; @@ -372,8 +372,8 @@ create2DWorkspaceWithRectangularInstrument(int numBanks, int numPixels, ws->setInstrument(inst); ws->getAxis(0)->setUnit("dSpacing"); for (size_t wi = 0; wi < ws->getNumberHistograms(); wi++) { - ws->getSpectrum(wi)->setDetectorID(detid_t(numPixels * numPixels + wi)); - ws->getSpectrum(wi)->setSpectrumNo(specnum_t(wi)); + ws->getSpectrum(wi).setDetectorID(detid_t(numPixels * numPixels + wi)); + ws->getSpectrum(wi).setSpectrumNo(specnum_t(wi)); } return ws; @@ -412,10 +412,10 @@ createEventWorkspaceWithFullInstrument(int numBanks, int numPixels, // re-assign detector IDs to the rectangular detector int detID = numPixels * numPixels; for (int wi = 0; wi < static_cast<int>(ws->getNumberHistograms()); wi++) { - ws->getEventList(wi).clearDetectorIDs(); + ws->getSpectrum(wi).clearDetectorIDs(); if (clearEvents) - ws->getEventList(wi).clear(true); - ws->getEventList(wi).setDetectorID(detID); + ws->getSpectrum(wi).clear(true); + ws->getSpectrum(wi).setDetectorID(detID); detID++; } return ws; @@ -441,10 +441,10 @@ createEventWorkspaceWithNonUniformInstrument(int numBanks, bool clearEvents) { // Re-assign detector IDs for (size_t wi = 0; wi < ws->getNumberHistograms(); wi++) { - ws->getEventList(wi).clearDetectorIDs(); + ws->getSpectrum(wi).clearDetectorIDs(); if (clearEvents) - ws->getEventList(wi).clear(true); - ws->getEventList(wi).setDetectorID(detectorIds[wi]); + ws->getSpectrum(wi).clear(true); + ws->getSpectrum(wi).setDetectorID(detectorIds[wi]); } return ws; @@ -495,8 +495,8 @@ create2DWorkspaceWithReflectometryInstrument(double startX) { workspace->setYUnit("Counts"); workspace->setInstrument(instrument); - workspace->getSpectrum(0)->setDetectorID(det->getID()); - workspace->getSpectrum(1)->setDetectorID(monitor->getID()); + workspace->getSpectrum(0).setDetectorID(det->getID()); + workspace->getSpectrum(1).setDetectorID(monitor->getID()); return workspace; } @@ -528,7 +528,7 @@ void createInstrumentForWorkspaceWithDistances( instrument->markAsDetector(det); // Link it to the workspace - workspace->getSpectrum(i)->addDetectorID(det->getID()); + workspace->getSpectrum(i).addDetectorID(det->getID()); } } @@ -597,7 +597,7 @@ CreateEventWorkspaceWithStartTime(int numPixels, int numBins, int numEvents, size_t workspaceIndex = 0; for (int pix = start_at_pixelID + 0; pix < start_at_pixelID + numPixels; pix++) { - EventList &el = retVal->getEventList(workspaceIndex); + EventList &el = retVal->getSpectrum(workspaceIndex); el.setSpectrumNo(pix); el.setDetectorID(pix); @@ -716,7 +716,7 @@ EventWorkspace_sptr CreateRandomEventWorkspace(size_t numbins, size_t numpixels, // Make up some data for each pixels for (size_t i = 0; i < numpixels; i++) { // Create one event for each bin - EventList &events = retVal->getEventList(static_cast<detid_t>(i)); + EventList &events = retVal->getSpectrum(static_cast<detid_t>(i)); for (std::size_t ie = 0; ie < numbins; ie++) { // Create a list of events, randomize events += TofEvent(static_cast<double>(randomGen.nextValue()), @@ -743,10 +743,10 @@ MatrixWorkspace_sptr CreateGroupedWorkspace2D(size_t numHist, int numBins, static_cast<int>(numHist))); for (int g = 0; g < static_cast<int>(numHist); g++) { - ISpectrum *spec = retVal->getSpectrum(g); + auto &spec = retVal->getSpectrum(g); for (int i = 1; i <= 9; i++) - spec->addDetectorID(g * 9 + i); - spec->setSpectrumNo(g + 1); // Match detector ID and spec NO + spec.addDetectorID(g * 9 + i); + spec.setSpectrumNo(g + 1); // Match detector ID and spec NO } return boost::dynamic_pointer_cast<MatrixWorkspace>(retVal); } @@ -763,10 +763,10 @@ CreateGroupedWorkspace2DWithRingsAndBoxes(size_t RootOfNumHist, int numBins, ComponentCreationHelper::createTestInstrumentCylindrical( static_cast<int>(numHist))); for (int g = 0; g < static_cast<int>(numHist); g++) { - ISpectrum *spec = retVal->getSpectrum(g); + auto &spec = retVal->getSpectrum(g); for (int i = 1; i <= 9; i++) - spec->addDetectorID(g * 9 + i); - spec->setSpectrumNo(g + 1); // Match detector ID and spec NO + spec.addDetectorID(g * 9 + i); + spec.setSpectrumNo(g + 1); // Match detector ID and spec NO } return boost::dynamic_pointer_cast<MatrixWorkspace>(retVal); } @@ -921,13 +921,13 @@ createProcessedInelasticWS(const std::vector<double> &L2, L2, polar, azimutal)); for (int g = 0; g < static_cast<int>(numPixels); g++) { - ISpectrum *spec = ws->getSpectrum(g); + auto &spec = ws->getSpectrum(g); // we just made (in createCylInstrumentWithDetInGivenPosisions) det ID-s to // start from 1 - spec->setDetectorID(g + 1); + spec.setDetectorID(g + 1); // and this is absolutely different nummer, corresponding to det ID just by // chance ? -- some uncertainties remain - spec->setSpectrumNo(g + 1); + spec.setSpectrumNo(g + 1); // spec->setSpectrumNo(g+1); // spec->addDetectorID(g*9); // spec->setSpectrumNo(g+1); // Match detector ID and spec NO diff --git a/Framework/WorkflowAlgorithms/src/AlignAndFocusPowder.cpp b/Framework/WorkflowAlgorithms/src/AlignAndFocusPowder.cpp index 1b7924ac79600dae0fe612c11c6deaefa2f5d637..d4728d7ef12cae29fa32aaacfe370aa8ffbdbd90 100644 --- a/Framework/WorkflowAlgorithms/src/AlignAndFocusPowder.cpp +++ b/Framework/WorkflowAlgorithms/src/AlignAndFocusPowder.cpp @@ -782,7 +782,7 @@ AlignAndFocusPowder::conjoinWorkspaces(API::MatrixWorkspace_sptr ws1, specnum_t maxspecNo1 = 0; std::vector<specnum_t> origspecNos; for (size_t i = 0; i < nspec1; ++i) { - specnum_t tmpspecNo = ws1->getSpectrum(i)->getSpectrumNo(); + specnum_t tmpspecNo = ws1->getSpectrum(i).getSpectrumNo(); origspecNos.push_back(tmpspecNo); if (tmpspecNo > maxspecNo1) maxspecNo1 = tmpspecNo; @@ -809,12 +809,12 @@ AlignAndFocusPowder::conjoinWorkspaces(API::MatrixWorkspace_sptr ws1, // FIXED : Restore the original spectrum Nos to spectra from ws1 for (size_t i = 0; i < nspec1; ++i) { - specnum_t tmpspecNo = outws->getSpectrum(i)->getSpectrumNo(); - outws->getSpectrum(i)->setSpectrumNo(origspecNos[i]); + specnum_t tmpspecNo = outws->getSpectrum(i).getSpectrumNo(); + outws->getSpectrum(i).setSpectrumNo(origspecNos[i]); g_log.information() << "[DBx540] Conjoined spectrum " << i << ": restore spectrum number to " - << outws->getSpectrum(i)->getSpectrumNo() + << outws->getSpectrum(i).getSpectrumNo() << " from spectrum number = " << tmpspecNo << ".\n"; } @@ -822,7 +822,7 @@ AlignAndFocusPowder::conjoinWorkspaces(API::MatrixWorkspace_sptr ws1, if (offset >= 1) { for (size_t i = 0; i < nspec2; ++i) { specnum_t newspecid = maxspecNo1 + static_cast<specnum_t>((i) + offset); - outws->getSpectrum(nspec1 + i)->setSpectrumNo(newspecid); + outws->getSpectrum(nspec1 + i).setSpectrumNo(newspecid); // ISpectrum* spec = outws->getSpectrum(nspec1+i); // if (spec) // spec->setSpectrumNo(3); diff --git a/Framework/WorkflowAlgorithms/src/SANSSolidAngleCorrection.cpp b/Framework/WorkflowAlgorithms/src/SANSSolidAngleCorrection.cpp index 9cd60ed28a6adee540a6ef2afc066401791ff335..3c2b75ee14a68c257c35d16e13689b653016ee02 100644 --- a/Framework/WorkflowAlgorithms/src/SANSSolidAngleCorrection.cpp +++ b/Framework/WorkflowAlgorithms/src/SANSSolidAngleCorrection.cpp @@ -221,7 +221,7 @@ void SANSSolidAngleCorrection::execEvent() { } else { corr = theta_term * theta_term * theta_term; } - EventList &el = outputEventWS->getEventList(i); + EventList &el = outputEventWS->getSpectrum(i); el *= corr; progress.report("Solid Angle Correction"); PARALLEL_END_INTERUPT_REGION diff --git a/MantidPlot/src/Mantid/MantidMatrixModel.cpp b/MantidPlot/src/Mantid/MantidMatrixModel.cpp index 8422b2f11756c20aa60ba680ce39431299518eb5..0df195bca47301f8f31229732220fbcb16e4a5dc 100644 --- a/MantidPlot/src/Mantid/MantidMatrixModel.cpp +++ b/MantidPlot/src/Mantid/MantidMatrixModel.cpp @@ -100,12 +100,12 @@ QVariant MantidMatrixModel::headerData(int section, Qt::Orientation orientation, return QString("index %1%2spectra no %3") .arg(QString::number(section), toolTipSeperator, QString::number( - m_workspace->getSpectrum(section)->getSpectrumNo())); + m_workspace->getSpectrum(section).getSpectrumNo())); } else { return QString("%1%2sp-%3") .arg(QString::number(section), headerSeperator, QString::number( - m_workspace->getSpectrum(section)->getSpectrumNo())); + m_workspace->getSpectrum(section).getSpectrumNo())); } } diff --git a/MantidPlot/src/Mantid/MantidUI.cpp b/MantidPlot/src/Mantid/MantidUI.cpp index 3516f8abfa11673f5434ae935e56679652df95a4..7c47ec6f32eaea987658c9782e8068490d05a5f9 100644 --- a/MantidPlot/src/Mantid/MantidUI.cpp +++ b/MantidPlot/src/Mantid/MantidUI.cpp @@ -1196,10 +1196,10 @@ Table *MantidUI::createDetectorTable( colValues << QVariant(static_cast<double>(wsIndex)); const double dataY0(ws->readY(wsIndex)[0]), dataE0(ws->readE(wsIndex)[0]); try { - ISpectrum *spectrum = ws->getSpectrum(wsIndex); - Mantid::specnum_t specNo = spectrum->getSpectrumNo(); + auto &spectrum = ws->getSpectrum(wsIndex); + Mantid::specnum_t specNo = spectrum.getSpectrumNo(); QString detIds(""); - const auto &ids = spectrum->getDetectorIDs(); + const auto &ids = spectrum.getDetectorIDs(); size_t ndets = ids.size(); auto iter = ids.begin(); auto itEnd = ids.end(); diff --git a/MantidQt/CustomInterfaces/src/EnggDiffraction/EnggDiffractionPresenter.cpp b/MantidQt/CustomInterfaces/src/EnggDiffraction/EnggDiffractionPresenter.cpp index a3dc0b8bfb428560d00c0d4ac2922ae17f213738..1243dca20c108a5bd7f71d46d8bc77cbc45f999d 100644 --- a/MantidQt/CustomInterfaces/src/EnggDiffraction/EnggDiffractionPresenter.cpp +++ b/MantidQt/CustomInterfaces/src/EnggDiffraction/EnggDiffractionPresenter.cpp @@ -1282,10 +1282,8 @@ void EnggDiffractionPresenter::runAlignDetectorsAlg(std::string workspaceName) { difcTable->addColumn("double", "difa"); difcTable->addColumn("double", "tzero"); TableRow row = difcTable->appendRow(); - auto spec = inputWS->getSpectrum(0); - if (!spec) - return; - Mantid::detid_t detID = *(spec->getDetectorIDs().cbegin()); + auto &spec = inputWS->getSpectrum(0); + Mantid::detid_t detID = *(spec.getDetectorIDs().cbegin()); row << detID << difc << difa << tzero; } catch (std::runtime_error &rexc) { @@ -1370,7 +1368,7 @@ void EnggDiffractionPresenter::setDataToClonedWS(std::string ¤t_WS, auto currentPeakWS = ADS.retrieveWS<MatrixWorkspace>(current_WS); auto currentClonedWS = ADS.retrieveWS<MatrixWorkspace>(cloned_WS); currentClonedWS->getSpectrum(0) - ->setData(currentPeakWS->readY(0), currentPeakWS->readE(0)); + .setData(currentPeakWS->readY(0), currentPeakWS->readE(0)); } void EnggDiffractionPresenter::plotFitPeaksCurves() { diff --git a/MantidQt/CustomInterfaces/src/Indirect/IndirectDataReductionTab.cpp b/MantidQt/CustomInterfaces/src/Indirect/IndirectDataReductionTab.cpp index 208ca4e1c3ab8a035fb7c36d817965062ced3350..65494a6020f47ac25e2d667467ffbd73287dc5d8 100644 --- a/MantidQt/CustomInterfaces/src/Indirect/IndirectDataReductionTab.cpp +++ b/MantidQt/CustomInterfaces/src/Indirect/IndirectDataReductionTab.cpp @@ -199,10 +199,10 @@ std::map<std::string, double> IndirectDataReductionTab::getRangesFromInstrument( Mantid::specnum_t spectraMin = boost::lexical_cast<Mantid::specnum_t>(spectraMinDbl); - auto spectrum = energyWs->getSpectrum(0); - spectrum->setSpectrumNo(spectraMin); - spectrum->clearDetectorIDs(); - spectrum->addDetectorID(spectraMin); + auto &spectrum = energyWs->getSpectrum(0); + spectrum.setSpectrumNo(spectraMin); + spectrum.clearDetectorIDs(); + spectrum.addDetectorID(spectraMin); IAlgorithm_sptr convUnitsAlg = AlgorithmManager::Instance().create("ConvertUnits"); diff --git a/MantidQt/CustomInterfaces/src/Indirect/IndirectSymmetrise.cpp b/MantidQt/CustomInterfaces/src/Indirect/IndirectSymmetrise.cpp index 663116b4e5510a1f7ba09c3da3f73c8a6bef50f5..92092faa89f0a820df6f2d6a15425593b47a93af 100644 --- a/MantidQt/CustomInterfaces/src/Indirect/IndirectSymmetrise.cpp +++ b/MantidQt/CustomInterfaces/src/Indirect/IndirectSymmetrise.cpp @@ -231,7 +231,7 @@ void IndirectSymmetrise::plotRawInput(const QString &workspaceName) { MatrixWorkspace_sptr sampleWS = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>( workspaceName.toStdString()); - int minSpectrumRange = sampleWS->getSpectrum(0)->getSpectrumNo(); + int minSpectrumRange = sampleWS->getSpectrum(0).getSpectrumNo(); m_dblManager->setValue(m_properties["PreviewSpec"], static_cast<double>(minSpectrumRange)); @@ -293,10 +293,10 @@ void IndirectSymmetrise::replotNewSpectrum(QtProperty *prop, double value) { MatrixWorkspace_sptr sampleWS = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>( workspaceName.toStdString()); - int minSpectrumRange = sampleWS->getSpectrum(0)->getSpectrumNo(); + int minSpectrumRange = sampleWS->getSpectrum(0).getSpectrumNo(); int maxSpectrumRange = sampleWS->getSpectrum(sampleWS->getNumberHistograms() - 1) - ->getSpectrumNo(); + .getSpectrumNo(); // If entered value is lower then set spectra number to lowest valid value if (value < minSpectrumRange) { diff --git a/MantidQt/CustomInterfaces/src/Indirect/ResNorm.cpp b/MantidQt/CustomInterfaces/src/Indirect/ResNorm.cpp index 128771c38adfd46fa625da2d33703d113257a02e..049d7880cb0d8f1f2f3a6b97e836c4d814f8d95d 100644 --- a/MantidQt/CustomInterfaces/src/Indirect/ResNorm.cpp +++ b/MantidQt/CustomInterfaces/src/Indirect/ResNorm.cpp @@ -313,7 +313,7 @@ void ResNorm::previewSpecChanged(int value) { MatrixWorkspace_sptr fit = WorkspaceFactory::Instance().create(fitWs, 1); fit->setX(0, fitWs->readX(1)); - fit->getSpectrum(0)->setData(fitWs->readY(1), fitWs->readE(1)); + fit->getSpectrum(0).setData(fitWs->readY(1), fitWs->readE(1)); for (size_t i = 0; i < fit->blocksize(); i++) fit->dataY(0)[i] /= scaleFactors->cell<double>(m_previewSpec); diff --git a/MantidQt/CustomInterfaces/src/SANSDiagnostics.cpp b/MantidQt/CustomInterfaces/src/SANSDiagnostics.cpp index 05d5173b73fe38ad0515cc0f9a084d2072064d86..8a77a08fc608db3f6002ff1aaa378927852dae99 100644 --- a/MantidQt/CustomInterfaces/src/SANSDiagnostics.cpp +++ b/MantidQt/CustomInterfaces/src/SANSDiagnostics.cpp @@ -426,8 +426,8 @@ void SANSDiagnostics::getSpectraList( size_t aux; // this is a costly opperation and should be done just once for each file for (size_t i = 0; i < mws_sptr->getNumberHistograms(); ++i) { - const ISpectrum *const spec = mws_sptr->getSpectrum(i); - auto detIDs = spec->getDetectorIDs(); + const auto &spec = mws_sptr->getSpectrum(i); + auto detIDs = spec.getDetectorIDs(); if (!detIDs.empty()) { // Assuming 1 detector per spectrum (the old code would have failed if it // wasn't) @@ -435,7 +435,7 @@ void SANSDiagnostics::getSpectraList( // if detector id inside the range if (detID >= rectDet->getMinimumDetectorId() && detID <= rectDet->getMaximumDetectorId()) { - aux = spec->getSpectrumNo(); + aux = spec.getSpectrumNo(); if (aux > max_spec_index) max_spec_index = aux; if (aux < min_spec_index) @@ -452,8 +452,8 @@ void SANSDiagnostics::getSpectraList( specList.clear(); // it is not really required, it could stay with the workspace id, just for // compatibility - specList.push_back(mws_sptr->getSpectrum(min_spec_index)->getSpectrumNo()); - specList.push_back(mws_sptr->getSpectrum(max_spec_index)->getSpectrumNo()); + specList.push_back(mws_sptr->getSpectrum(min_spec_index).getSpectrumNo()); + specList.push_back(mws_sptr->getSpectrum(max_spec_index).getSpectrumNo()); } /** This method returns the minimum and maximum spectrum Nos * @param specList - list of spectra. diff --git a/MantidQt/CustomInterfaces/src/SANSRunWindow.cpp b/MantidQt/CustomInterfaces/src/SANSRunWindow.cpp index f30f9d96494273e8820bdfbec6febc2bf6edea0c..2fa029192f63da9756a447ee7c5dd1b1ae9eead5 100644 --- a/MantidQt/CustomInterfaces/src/SANSRunWindow.cpp +++ b/MantidQt/CustomInterfaces/src/SANSRunWindow.cpp @@ -1664,8 +1664,7 @@ void SANSRunWindow::setGeometryDetails() { return; } - const std::set<detid_t> &dets = - monitorWs->getSpectrum(monitorWsIndex)->getDetectorIDs(); + const auto &dets = monitorWs->getSpectrum(monitorWsIndex).getDetectorIDs(); if (dets.empty()) return; diff --git a/MantidQt/CustomInterfaces/src/Tomography/ImggFormatsConvertViewQtWidget.cpp b/MantidQt/CustomInterfaces/src/Tomography/ImggFormatsConvertViewQtWidget.cpp index d6d9885b644b2c3a70623bd4c21137d0108d9139..8b7bb3ecb71e957932515d06e834fcd9d52fcab5 100644 --- a/MantidQt/CustomInterfaces/src/Tomography/ImggFormatsConvertViewQtWidget.cpp +++ b/MantidQt/CustomInterfaces/src/Tomography/ImggFormatsConvertViewQtWidget.cpp @@ -281,9 +281,9 @@ ImggFormatsConvertViewQtWidget::loadImg(const std::string &inputName, imgWks->setTitle(inputName); const double scaleFactor = std::numeric_limits<unsigned char>::max(); for (int yi = 0; yi < static_cast<int>(width); ++yi) { - const auto &row = imgWks->getSpectrum(yi); - auto &dataY = row->dataY(); - auto &dataX = row->dataX(); + auto &row = imgWks->getSpectrum(yi); + auto &dataY = row.dataY(); + auto &dataX = row.dataX(); std::fill(dataX.begin(), dataX.end(), static_cast<double>(yi)); for (int xi = 0; xi < static_cast<int>(width); ++xi) { QRgb vRgb = img.pixel(xi, yi); diff --git a/MantidQt/MantidWidgets/src/InstrumentView/InstrumentActor.cpp b/MantidQt/MantidWidgets/src/InstrumentView/InstrumentActor.cpp index 486d9b522b079b6fb54f38a9b1486894aa6e9743..46ca5ea400e6bad8771fd5d26164dbb44b459b7a 100644 --- a/MantidQt/MantidWidgets/src/InstrumentView/InstrumentActor.cpp +++ b/MantidQt/MantidWidgets/src/InstrumentView/InstrumentActor.cpp @@ -644,7 +644,7 @@ void InstrumentActor::resetColors() { double integratedValue = m_specIntegrs[wi]; try { // Find if the detector is masked - const auto &dets = sharedWorkspace->getSpectrum(wi)->getDetectorIDs(); + const auto &dets = sharedWorkspace->getSpectrum(wi).getDetectorIDs(); bool masked = false; if (mask) { diff --git a/MantidQt/MantidWidgets/src/InstrumentView/InstrumentWidgetPickTab.cpp b/MantidQt/MantidWidgets/src/InstrumentView/InstrumentWidgetPickTab.cpp index 5ac1261a8439b222f25876a9eeaf5031c63318d9..ebec4086265b5b0b18b2411efe6385edada13744 100644 --- a/MantidQt/MantidWidgets/src/InstrumentView/InstrumentWidgetPickTab.cpp +++ b/MantidQt/MantidWidgets/src/InstrumentView/InstrumentWidgetPickTab.cpp @@ -1462,11 +1462,7 @@ void DetectorPlotController::savePlotToWorkspace() { size_t i = 0; for (std::vector<Mantid::detid_t>::const_iterator id = detids.begin(); id != detids.end(); ++id, ++i) { - Mantid::API::ISpectrum *spec = ws->getSpectrum(i); - if (!spec) { - throw std::runtime_error("Spectrum not found"); - } - spec->setDetectorID(*id); + ws->getSpectrum(i).setDetectorID(*id); } } diff --git a/MantidQt/SpectrumViewer/src/MatrixWSDataSource.cpp b/MantidQt/SpectrumViewer/src/MatrixWSDataSource.cpp index 3906981dd203f0286ccae603cbe9372263dd6d4e..143aad4113d9e034bbadc62607acb7c38b57548c 100644 --- a/MantidQt/SpectrumViewer/src/MatrixWSDataSource.cpp +++ b/MantidQt/SpectrumViewer/src/MatrixWSDataSource.cpp @@ -234,9 +234,9 @@ std::vector<std::string> MatrixWSDataSource::getInfoList(double x, double y) { int row = (int)y; restrictRow(row); - const ISpectrum *spec = m_matWs->getSpectrum(row); + const auto &spec = m_matWs->getSpectrum(row); - double spec_num = spec->getSpectrumNo(); + double spec_num = spec.getSpectrumNo(); SVUtils::PushNameValue("Spec Num", 8, 0, spec_num, list); std::string x_label = ""; @@ -246,7 +246,7 @@ std::vector<std::string> MatrixWSDataSource::getInfoList(double x, double y) { SVUtils::PushNameValue(x_label, 8, 3, x, list); } - auto ids = spec->getDetectorIDs(); + auto ids = spec.getDetectorIDs(); if (!ids.empty()) { list.emplace_back("Det ID"); const int64_t id = static_cast<int64_t>(*(ids.begin())); diff --git a/Testing/SystemTests/tests/analysis/ISISLoadingEventData.py b/Testing/SystemTests/tests/analysis/ISISLoadingEventData.py index 7e9973fee517779fe2da35e47dc6b09ec2ba3fa1..1e77231fc60bf764ee392ced1f3e78f8564eda66 100644 --- a/Testing/SystemTests/tests/analysis/ISISLoadingEventData.py +++ b/Testing/SystemTests/tests/analysis/ISISLoadingEventData.py @@ -12,7 +12,7 @@ class ISISLoadingEventData(stresstesting.MantidStressTest): # isis_vms_compat/SPB[2] self.assertEqual(ev_ws.sample().getGeometryFlag(), 1, "It does not read correctly the vms compat (check ") # Isis correct the tof using loadTimeOfFlight method. - self.assertDelta( ev_ws.getEventList(10).getTofs()[1], 1041.89,0.01, + self.assertDelta( ev_ws.getSpectrum(10).getTofs()[1], 1041.89,0.01, "The ISIS event correction is incorrect (check LoadEventNexus::loadTimeOfFlight") def validate(self): return True diff --git a/docs/source/algorithms/ChangeTimeZero-v1.rst b/docs/source/algorithms/ChangeTimeZero-v1.rst index 2496f234725228a04449eed6c02f0600ed9b6260..23e6e6f02ab09303362ead4c16fcf9af1b2b9363 100644 --- a/docs/source/algorithms/ChangeTimeZero-v1.rst +++ b/docs/source/algorithms/ChangeTimeZero-v1.rst @@ -42,8 +42,8 @@ Usage shifted_proton_charge = shifted_ws .getRun()['proton_charge'] # Check some events - original_pulse_times = original_ws.getEventList(7).getPulseTimes() - shifted_pulse_times = shifted_ws.getEventList(7).getPulseTimes() + original_pulse_times = original_ws.getSpectrum(7).getPulseTimes() + shifted_pulse_times = shifted_ws.getSpectrum(7).getPulseTimes() print "Original proton_charge time: ", original_proton_charge.nthTime(0), ", ", original_proton_charge.nthTime(1), ", ..." print "Shifted proton_charge time: ", shifted_proton_charge.nthTime(0), ", ", shifted_proton_charge.nthTime(1), ", ..." @@ -83,8 +83,8 @@ Output: shifted_proton_charge = shifted_ws .getRun()['proton_charge'] # Check some events - original_pulse_times = original_ws.getEventList(7).getPulseTimes() - shifted_pulse_times = shifted_ws.getEventList(7).getPulseTimes() + original_pulse_times = original_ws.getSpectrum(7).getPulseTimes() + shifted_pulse_times = shifted_ws.getSpectrum(7).getPulseTimes() print "Original proton_charge time: ", original_proton_charge.nthTime(0), ", ", original_proton_charge.nthTime(1), ", ..." print "Shifted proton_charge time: ", shifted_proton_charge.nthTime(0), ", ", shifted_proton_charge.nthTime(1), ", ..." diff --git a/docs/source/algorithms/CorelliCrossCorrelate-v1.rst b/docs/source/algorithms/CorelliCrossCorrelate-v1.rst index 43735f309b7457f619baf25bf8257f938c8fc6de..f9b667b482547ebf7abd2cf3db33ac6e3a21932d 100644 --- a/docs/source/algorithms/CorelliCrossCorrelate-v1.rst +++ b/docs/source/algorithms/CorelliCrossCorrelate-v1.rst @@ -34,9 +34,9 @@ Usage # Run the cross-correlation. This is using a TDC timing offset of 56000ns. wsOut = CorelliCrossCorrelate(ws,56000) - print 'The detector 172305 has ' + str(ws.getEventList(172305).getNumberEvents()) + ' events.' - print 'The event weights before cross-correlation are ' + str(ws.getEventList(172305).getWeights()) - print 'The event weights after cross-correlation are ' + str(wsOut.getEventList(172305).getWeights()) + print 'The detector 172305 has ' + str(ws.getSpectrum(172305).getNumberEvents()) + ' events.' + print 'The event weights before cross-correlation are ' + str(ws.getSpectrum(172305).getWeights()) + print 'The event weights after cross-correlation are ' + str(wsOut.getSpectrum(172305).getWeights()) Output: diff --git a/docs/source/algorithms/MDNormSCD-v1.rst b/docs/source/algorithms/MDNormSCD-v1.rst index 1e6f4afa223d3ebbf95fa2a413151984ec2b93da..925e3f505c297bcb9368ebfcc727a3a4456d63ee 100644 --- a/docs/source/algorithms/MDNormSCD-v1.rst +++ b/docs/source/algorithms/MDNormSCD-v1.rst @@ -45,7 +45,7 @@ Usage flux=CompressEvents(InputWorkspace=flux,Tolerance=1e-4) flux=Rebin(InputWorkspace=flux,Params='1.85,10,10') for i in range(flux.getNumberHistograms()): - el=flux.getEventList(i) + el=flux.getSpectrum(i) el.divide(flux.readY(i)[0],0) flux=Rebin(InputWorkspace=flux,Params='1.85,10,10') flux=IntegrateFlux(flux) diff --git a/docs/source/algorithms/SortEvents-v1.rst b/docs/source/algorithms/SortEvents-v1.rst index b64ae9542749531fcad25b14e3bdf20050d27100..1201168d28f15d26b954aff6ea44f865c451f438 100644 --- a/docs/source/algorithms/SortEvents-v1.rst +++ b/docs/source/algorithms/SortEvents-v1.rst @@ -29,7 +29,7 @@ Usage SortEvents(InputWorkspace='TestEventWS', SortBy="X Value") ws = mtd["TestEventWS"] - ev1 = ws.getEventList(1) + ev1 = ws.getSpectrum(1) ptimes = ev1.getPulseTimes() tofs = ev1.getTofs() for eindex in xrange(10): @@ -62,7 +62,7 @@ Output: SortEvents(InputWorkspace='TestEventWS',SortBy='Pulse Time + TOF') ws = mtd["TestEventWS"] - ev1 = ws.getEventList(1) + ev1 = ws.getSpectrum(1) ptimes = ev1.getPulseTimes() tofs = ev1.getTofs() for eindex in xrange(10): diff --git a/docs/source/concepts/EventWorkspace.rst b/docs/source/concepts/EventWorkspace.rst index 68a82b6804f3c082cfb47ac09e5c452dcaf140b4..ac8cc10ddde76e4d3e6d4d264a5a5cc2301a8805 100644 --- a/docs/source/concepts/EventWorkspace.rst +++ b/docs/source/concepts/EventWorkspace.rst @@ -101,7 +101,7 @@ Event Workspaces store their data in event lists, one per spectrum. You can acc evListCount = eventWS.getNumberHistograms() # Get the first event list - evList = eventWS.getEventList(0) + evList = eventWS.getSpectrum(0) # Get some basic information print "Number of events in event List 0:", evList.getNumberEvents() @@ -151,7 +151,7 @@ Please note these should only be done as part of a Python Algorithm, otherwise t import math eventWS = CreateSampleWorkspace(WorkspaceType="Event") # Get the first event list - evList = eventWS.getEventList(0) + evList = eventWS.getSpectrum(0) # Add an offset to the pulsetime (wall-clock time) of each event in the list. print "First pulse time before addPulsetime:", evList.getPulseTimes()[0]