Skip to content

Commit

Permalink
Merge remote branch 'origin/feature/9358_gen_peak_enhance'
Browse files Browse the repository at this point in the history
  • Loading branch information
VickieLynch committed Jun 24, 2014
2 parents 002d2ca + 9ffa9d0 commit 8893776
Show file tree
Hide file tree
Showing 3 changed files with 960 additions and 338 deletions.
Expand Up @@ -8,6 +8,7 @@
#include "MantidDataObjects/Workspace2D.h"
#include "MantidAPI/IPeakFunction.h"
#include "MantidAPI/CompositeFunction.h"
#include "MantidAPI/IBackgroundFunction.h"

namespace Mantid
{
Expand Down Expand Up @@ -55,31 +56,101 @@ namespace Algorithms
virtual const std::string category() const { return "Crystal";}

private:

// Implement abstract Algorithm methods

void init();
// Implement abstract Algorithm methods

/// Implement abstract Algorithm methods
void exec();

API::MatrixWorkspace_sptr createDataWorkspace(std::set<specid_t> spectra, std::vector<double> binparameters);
/// Process algorithm properties
void processAlgProperties(std::string &peakfunctype, std::string &bkgdfunctype);

/// Process column names with peak parameter names
void processTableColumnNames();

void importPeaksFromTable(std::map<specid_t, std::vector<std::pair<double, API::IFunction_sptr> > >& functionmap);

/// Import peak and background function parameters from vector
void importPeakFromVector(std::vector<std::pair<double, API::IFunction_sptr> >& functionmap);


API::IFunction_sptr createFunction(const std::string &peakFuncType, const std::vector<std::string> &colNames,
const bool isRaw, const bool withBackground,
DataObjects::TableWorkspace_const_sptr peakParmsWS,
const std::size_t bkg_offset, const std::size_t rowNum,
double &centre, double &fwhm);
/// Generate peaks in output data workspaces
void generatePeaks(const std::map<specid_t, std::vector<std::pair<double, API::IFunction_sptr> > >& functionmap, API::MatrixWorkspace_sptr dataWS);

void getSpectraSet(DataObjects::TableWorkspace_const_sptr peakParmsWS, std::set<specid_t>& spectra);
/// Check whether function has a certain parameter
bool hasParameter(API::IFunction_sptr function, std::string paramname);

void generatePeaks(API::MatrixWorkspace_sptr dataWS, DataObjects::TableWorkspace_const_sptr peakparameters,
std::string peakfunction, bool newWSFromParent);
/// Create output workspace
API::MatrixWorkspace_sptr createOutputWorkspace();

API::MatrixWorkspace_sptr createDataWorkspace(std::vector<double> binparameters);

void createFunction(std::string& peaktype, std::string& bkgdtype);

void getSpectraSet(DataObjects::TableWorkspace_const_sptr peakParmsWS);

double getTableValue(DataObjects::TableWorkspace_const_sptr tableWS, std::string colname, size_t index);

/// Get the IPeakFunction part in the input function
API::IPeakFunction_sptr getPeakFunction(API::IFunction_sptr infunction);

std::map<specid_t, specid_t> mSpectrumMap;
/// Add function parameter names to
std::vector<std::string> addFunctionParameterNames(std::vector<std::string> funcnames);

/// Peak function
API::IPeakFunction_sptr m_peakFunction;

/// Background function
API::IBackgroundFunction_sptr m_bkgdFunction;

///
std::vector<double> m_vecPeakParamValues;
///
std::vector<double> m_vecBkgdParamValues;

/// Spectrum map from full spectra workspace to partial spectra workspace
std::map<specid_t, specid_t> m_SpectrumMap;

/// Set of spectra (workspace indexes) in the original workspace that contain peaks to generate
std::set<specid_t> m_spectraSet;

/// Flag to use automatic background (???)
bool m_useAutoBkgd;

/// Parameter table workspace
DataObjects::TableWorkspace_sptr m_funcParamWS;

/// Input workspace (optional)
API::MatrixWorkspace_const_sptr inputWS;

/// Flag whether the new workspace is exactly as input
bool m_newWSFromParent;

/// Binning parameters
std::vector<double> binParameters;

/// Flag to generate background
bool m_genBackground;

/// Flag to indicate parameter table workspace containing raw parameters names
bool m_useRawParameter;

/// Maximum chi-square to have peak generated
double m_maxChi2;

/// Number of FWHM for peak to extend
double m_numPeakWidth;

/// List of functions' parameters naems
std::vector<std::string> m_funcParameterNames;

/// Indexes of height, centre, width, a0, a1, and a2 in input parameter table
int i_height, i_centre, i_width, i_a0, i_a1, i_a2;

/// Flag to use parameter table workspace
bool m_useFuncParamWS;

/// Spectrum if only 1 peak is to plot
int m_wsIndex;
};


Expand Down

0 comments on commit 8893776

Please sign in to comment.