Skip to content

Commit

Permalink
Refs #9445. Fixing more style problems.
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Wedel committed Jul 8, 2014
1 parent dc06bbb commit 7a7daa5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 23 deletions.
Expand Up @@ -59,20 +59,20 @@ class MANTID_SINQ_DLL PoldiCalculateSpectrum2D : public API::Algorithm
virtual const std::string summary() const;

protected:
PoldiPeakCollection_sptr getPeakCollection(DataObjects::TableWorkspace_sptr peakTable);
PoldiPeakCollection_sptr getIntegratedPeakCollection(PoldiPeakCollection_sptr rawPeakCollection);
PoldiPeakCollection_sptr getNormalizedPeakCollection(PoldiPeakCollection_sptr peakCollection);
PoldiPeakCollection_sptr getPeakCollection(const DataObjects::TableWorkspace_sptr &peakTable) const;
PoldiPeakCollection_sptr getIntegratedPeakCollection(const PoldiPeakCollection_sptr &rawPeakCollection) const;
PoldiPeakCollection_sptr getNormalizedPeakCollection(const PoldiPeakCollection_sptr &peakCollection) const;

boost::shared_ptr<Poldi2DFunction> getFunctionFromPeakCollection(PoldiPeakCollection_sptr peakCollection);
boost::shared_ptr<Poldi2DFunction> getFunctionFromPeakCollection(const PoldiPeakCollection_sptr &peakCollection) const;

API::MatrixWorkspace_sptr calculateSpectrum(PoldiPeakCollection_sptr peakCollection, API::MatrixWorkspace_sptr matrixWorkspace);
API::MatrixWorkspace_sptr calculateSpectrum(const PoldiPeakCollection_sptr &peakCollection, const API::MatrixWorkspace_sptr &matrixWorkspace);

void setTimeTransformerFromInstrument(PoldiInstrumentAdapter_sptr poldiInstrument);
void setTimeTransformer(PoldiTimeTransformer_sptr poldiTimeTransformer);
void setTimeTransformerFromInstrument(const PoldiInstrumentAdapter_sptr &poldiInstrument);
void setTimeTransformer(const PoldiTimeTransformer_sptr &poldiTimeTransformer);

void setDeltaTFromWorkspace(API::MatrixWorkspace_sptr matrixWorkspace);
void setDeltaTFromWorkspace(const API::MatrixWorkspace_sptr &matrixWorkspace);
void setDeltaT(double newDeltaT);
bool isValidDeltaT(double deltaT);
bool isValidDeltaT(double deltaT) const;

void throwOnInsufficientState();

Expand Down
30 changes: 16 additions & 14 deletions Code/Mantid/Framework/SINQ/src/PoldiCalculateSpectrum2D.cpp
Expand Up @@ -18,6 +18,8 @@ TODO: Enter a full wiki-markup description of your algorithm here. You can then

#include "MantidSINQ/PoldiUtilities/Poldi2DFunction.h"

#include "boost/make_shared.hpp"

namespace Mantid
{
namespace Poldi
Expand Down Expand Up @@ -77,7 +79,7 @@ namespace Poldi
* @param peakCollection :: PoldiPeakCollection containing peaks with integral intensities
* @return Poldi2DFunction with one PoldiSpectrumDomainFunction per peak
*/
boost::shared_ptr<Poldi2DFunction> PoldiCalculateSpectrum2D::getFunctionFromPeakCollection(PoldiPeakCollection_sptr peakCollection)
boost::shared_ptr<Poldi2DFunction> PoldiCalculateSpectrum2D::getFunctionFromPeakCollection(const PoldiPeakCollection_sptr &peakCollection) const
{
boost::shared_ptr<Poldi2DFunction> mdFunction(new Poldi2DFunction);

Expand Down Expand Up @@ -106,7 +108,7 @@ namespace Poldi
MatrixWorkspace_sptr ws = getProperty("InputWorkspace");
setDeltaTFromWorkspace(ws);

setTimeTransformerFromInstrument(PoldiInstrumentAdapter_sptr(new PoldiInstrumentAdapter(ws)));
setTimeTransformerFromInstrument(boost::make_shared<PoldiInstrumentAdapter>(ws));

PoldiPeakCollection_sptr peakCollection = getPeakCollection(peakTable);

Expand All @@ -127,7 +129,7 @@ namespace Poldi
* @param matrixWorkspace :: MatrixWorkspace with POLDI instrument and correct dimensions
* @return MatrixWorkspace with the calculated data
*/
MatrixWorkspace_sptr PoldiCalculateSpectrum2D::calculateSpectrum(PoldiPeakCollection_sptr peakCollection, MatrixWorkspace_sptr matrixWorkspace)
MatrixWorkspace_sptr PoldiCalculateSpectrum2D::calculateSpectrum(const PoldiPeakCollection_sptr &peakCollection, const MatrixWorkspace_sptr &matrixWorkspace)
{
PoldiPeakCollection_sptr integratedPeaks = getIntegratedPeakCollection(peakCollection);
PoldiPeakCollection_sptr normalizedPeakCollection = getNormalizedPeakCollection(integratedPeaks);
Expand Down Expand Up @@ -157,17 +159,17 @@ namespace Poldi
*
* @param poldiInstrument :: PoldiInstrumentAdapter with valid components
*/
void PoldiCalculateSpectrum2D::setTimeTransformerFromInstrument(PoldiInstrumentAdapter_sptr poldiInstrument)
void PoldiCalculateSpectrum2D::setTimeTransformerFromInstrument(const PoldiInstrumentAdapter_sptr &poldiInstrument)
{
setTimeTransformer(PoldiTimeTransformer_sptr(new PoldiTimeTransformer(poldiInstrument)));
setTimeTransformer(boost::make_shared<PoldiTimeTransformer>(poldiInstrument));
}

/**
* Sets the time transformer object that is used for all calculations.
*
* @param poldiTimeTransformer
*/
void PoldiCalculateSpectrum2D::setTimeTransformer(PoldiTimeTransformer_sptr poldiTimeTransformer)
void PoldiCalculateSpectrum2D::setTimeTransformer(const PoldiTimeTransformer_sptr &poldiTimeTransformer)
{
m_timeTransformer = poldiTimeTransformer;
}
Expand All @@ -181,7 +183,7 @@ namespace Poldi
*
* @param matrixWorkspace :: MatrixWorkspace with at least one spectrum with at least two x-values.
*/
void PoldiCalculateSpectrum2D::setDeltaTFromWorkspace(MatrixWorkspace_sptr matrixWorkspace)
void PoldiCalculateSpectrum2D::setDeltaTFromWorkspace(const MatrixWorkspace_sptr &matrixWorkspace)
{
if(matrixWorkspace->getNumberHistograms() < 1) {
throw std::invalid_argument("MatrixWorkspace does not contain any data.");
Expand Down Expand Up @@ -217,7 +219,7 @@ namespace Poldi
* @param deltaT :: Value to be checked for validity as a time difference.
* @return True if delta t is larger than 0, otherwise false.
*/
bool PoldiCalculateSpectrum2D::isValidDeltaT(double deltaT)
bool PoldiCalculateSpectrum2D::isValidDeltaT(double deltaT) const
{
return deltaT > 0.0;
}
Expand All @@ -228,10 +230,10 @@ namespace Poldi
* @param peakTable :: TableWorkspace with POLDI peak data.
* @return PoldiPeakCollection with the data from the table workspace.
*/
PoldiPeakCollection_sptr PoldiCalculateSpectrum2D::getPeakCollection(TableWorkspace_sptr peakTable)
PoldiPeakCollection_sptr PoldiCalculateSpectrum2D::getPeakCollection(const TableWorkspace_sptr &peakTable) const
{
try {
return PoldiPeakCollection_sptr(new PoldiPeakCollection(peakTable));
return boost::make_shared<PoldiPeakCollection>(peakTable);
} catch(...) {
throw std::runtime_error("Could not initialize peak collection.");
}
Expand All @@ -251,7 +253,7 @@ namespace Poldi
* @param rawPeakCollection :: PoldiPeakCollection
* @return PoldiPeakCollection with integrated intensities
*/
PoldiPeakCollection_sptr PoldiCalculateSpectrum2D::getIntegratedPeakCollection(PoldiPeakCollection_sptr rawPeakCollection)
PoldiPeakCollection_sptr PoldiCalculateSpectrum2D::getIntegratedPeakCollection(const PoldiPeakCollection_sptr &rawPeakCollection) const
{
if(!rawPeakCollection) {
throw std::invalid_argument("Cannot proceed with invalid PoldiPeakCollection.");
Expand Down Expand Up @@ -282,7 +284,7 @@ namespace Poldi

PeakFunctionIntegrator peakIntegrator(1e-10);

PoldiPeakCollection_sptr integratedPeakCollection(new PoldiPeakCollection(PoldiPeakCollection::Integral));
PoldiPeakCollection_sptr integratedPeakCollection = boost::make_shared<PoldiPeakCollection>(PoldiPeakCollection::Integral);
integratedPeakCollection->setProfileFunctionName(rawPeakCollection->getProfileFunctionName());

for(size_t i = 0; i < rawPeakCollection->peakCount(); ++i) {
Expand Down Expand Up @@ -330,7 +332,7 @@ namespace Poldi
* @param peakCollection :: PoldiPeakCollection with integrated intensities
* @return PoldiPeakCollection with normalized intensities
*/
PoldiPeakCollection_sptr PoldiCalculateSpectrum2D::getNormalizedPeakCollection(PoldiPeakCollection_sptr peakCollection)
PoldiPeakCollection_sptr PoldiCalculateSpectrum2D::getNormalizedPeakCollection(const PoldiPeakCollection_sptr &peakCollection) const
{
if(!peakCollection) {
throw std::invalid_argument("Cannot proceed with invalid PoldiPeakCollection.");
Expand All @@ -340,7 +342,7 @@ namespace Poldi
throw std::invalid_argument("Cannot proceed without PoldiTimeTransformer.");
}

PoldiPeakCollection_sptr normalizedPeakCollection(new PoldiPeakCollection(PoldiPeakCollection::Integral));
PoldiPeakCollection_sptr normalizedPeakCollection = boost::make_shared<PoldiPeakCollection>(PoldiPeakCollection::Integral);
normalizedPeakCollection->setProfileFunctionName(peakCollection->getProfileFunctionName());

for(size_t i = 0; i < peakCollection->peakCount(); ++i) {
Expand Down

0 comments on commit 7a7daa5

Please sign in to comment.