Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into feature/9112_multip…
Browse files Browse the repository at this point in the history
…le_catalog_support. Refs #9112.

Conflicts:

- Code/Mantid/MantidQt/CustomDialogs/inc/MantidQtCustomDialogs/CatalogPublishDialog.h
- Code/Mantid/MantidQt/CustomDialogs/src/CatalogPublishDialog.cpp
  • Loading branch information
jawrainey committed Mar 13, 2014
2 parents 1de53d7 + d2e300d commit 90895d6
Show file tree
Hide file tree
Showing 226 changed files with 12,353 additions and 4,361 deletions.
5 changes: 4 additions & 1 deletion Code/Mantid/Framework/Algorithms/CMakeLists.txt
Expand Up @@ -189,6 +189,7 @@ set ( SRC_FILES
src/SaveGSASInstrumentFile.cpp
src/Scale.cpp
src/ScaleX.cpp
src/SetInstrumentParameter.cpp
src/SetUncertainties.cpp
src/ShiftLogTime.cpp
src/SignalOverError.cpp
Expand Down Expand Up @@ -415,6 +416,7 @@ set ( INC_FILES
inc/MantidAlgorithms/SaveGSASInstrumentFile.h
inc/MantidAlgorithms/Scale.h
inc/MantidAlgorithms/ScaleX.h
inc/MantidAlgorithms/SetInstrumentParameter.h
inc/MantidAlgorithms/SetUncertainties.h
inc/MantidAlgorithms/ShiftLogTime.h
inc/MantidAlgorithms/SignalOverError.h
Expand Down Expand Up @@ -498,10 +500,10 @@ set ( TEST_FILES
ConjoinWorkspacesTest.h
ConvertAxisByFormulaTest.h
ConvertFromDistributionTest.h
ConvertMDHistoToMatrixWorkspaceTest.h
ConvertSpectrumAxis2Test.h
ConvertSpectrumAxisTest.h
ConvertTableToMatrixWorkspaceTest.h
ConvertMDHistoToMatrixWorkspaceTest.h
ConvertToDistributionTest.h
ConvertToEventWorkspaceTest.h
ConvertToHistogramTest.h
Expand Down Expand Up @@ -634,6 +636,7 @@ set ( TEST_FILES
SaveGSASInstrumentFileTest.h
ScaleTest.h
ScaleXTest.h
SetInstrumentParameterTest.h
ShiftLogTimeTest.h
SignalOverErrorTest.h
SmoothDataTest.h
Expand Down
Expand Up @@ -95,7 +95,7 @@ class DLLExport CheckWorkspacesMatch : public API::Algorithm
void doPeaksComparison(API::IPeaksWorkspace_sptr tws1, API::IPeaksWorkspace_sptr tws2);
void doTableComparison(API::ITableWorkspace_const_sptr tws1, API::ITableWorkspace_const_sptr tws2);
void doMDComparison(API::Workspace_sptr w1, API::Workspace_sptr w2);
bool checkEventLists(DataObjects::EventWorkspace_const_sptr ews1, DataObjects::EventWorkspace_const_sptr ews2);
bool compareEventWorkspaces(DataObjects::EventWorkspace_const_sptr ews1, DataObjects::EventWorkspace_const_sptr ews2);
bool checkData(API::MatrixWorkspace_const_sptr ws1, API::MatrixWorkspace_const_sptr ws2);
bool checkAxes(API::MatrixWorkspace_const_sptr ws1, API::MatrixWorkspace_const_sptr ws2);
bool checkSpectraMap(API::MatrixWorkspace_const_sptr ws1, API::MatrixWorkspace_const_sptr ws2);
Expand All @@ -104,6 +104,11 @@ class DLLExport CheckWorkspacesMatch : public API::Algorithm
bool checkSample(const API::Sample& sample1, const API::Sample& sample2);
bool checkRunProperties(const API::Run& run1, const API::Run& run2);

/// Compare 2 EventsList
int compareEventsListInDetails(const DataObjects::EventList &el1, const DataObjects::EventList &el2,
double tolTof, double tolWeight, int64_t tolPulse, bool printdetails,
size_t& numdiffpulse, size_t& numdifftof, size_t& numdiffboth) const;

std::string result; ///< the result string

API::Progress * prog;
Expand Down
Expand Up @@ -4,6 +4,7 @@
#include "MantidAPI/Algorithm.h"
#include "MantidKernel/System.h"
#include "MantidDataObjects/OffsetsWorkspace.h"
#include "MantidDataObjects/EventWorkspace.h"
#include "MantidDataObjects/TableWorkspace.h"
#include "MantidAPI/MatrixWorkspace.h"
#include <gsl/gsl_blas.h>
Expand All @@ -15,6 +16,28 @@ namespace Mantid
{
namespace Algorithms
{

struct FitPeakOffsetResult
{
double mask;
double offset;
double chi2;
/// fit sum from GSL optimizer as offset's error
double fitSum;
/// summation of chi-square
double chisqSum;
/// Number of peaks with successful fitting
double peakPosFittedSize;
int numpeakstofit;
int numpeaksfitted;
int numpeaksindrange;
std::string fitoffsetstatus;
/// Highest peak position
double highestpeakpos;
/// Highest peak deviation after calibrated by offset
double highestpeakdev;
};

/**
Find the offsets for each detector
Expand Down Expand Up @@ -54,21 +77,78 @@ class DLLExport GetDetOffsetsMultiPeaks: public API::Algorithm
virtual int version() const { return 1; }
/// Algorithm's category for identification overriding a virtual method
virtual const std::string category() const { return "Diffraction"; }
/// Call Gaussian as a Child Algorithm to fit the peak in a spectrum
int fitSpectra(const int64_t wi, API::MatrixWorkspace_sptr inputW, const std::vector<double> &peakPositions, const std::vector<double> &fitWindows, size_t &nparams,
double &minD, double &maxD,
std::vector<double>&peakPosToFit, std::vector<double> &peakPosFitted, std::vector<double> &chisq);

private:
/// Sets documentation strings for this algorithm
virtual void initDocs();
// Overridden Algorithm methods
void init();
void exec();

void processProperties();

/// Call Gaussian as a Child Algorithm to fit the peak in a spectrum
int fitSpectra(const int64_t wi, API::MatrixWorkspace_sptr inputW, const std::vector<double> &m_peakPositions,
const std::vector<double> &m_fitWindows, size_t &nparams, double &minD, double &maxD,
std::vector<double>&peakPosToFit, std::vector<double> &peakPosFitted, std::vector<double> &chisq,
int &i_highestpeak);

/// Add peak fitting and offset calculation information to information table workspaces per spectrum
void addInfoToReportWS(int wi, FitPeakOffsetResult offsetresult, const std::vector<double> &tofitpeakpositions,
const std::vector<double> &fittedpeakpositions);

void generatePeaksList(const API::ITableWorkspace_sptr &peakslist,
int wi,
const std::vector<double> &peakPositionRef,
std::vector<double> &peakPosToFit,
std::vector<double> &peakPosFitted,
std::vector<double> &peakHeightFitted, std::vector<double> &chisq, bool useFitWindows,
const std::vector<double> &fitWindowsToUse, const double minD, const double maxD);

/// Generate output information table workspace
Mantid::DataObjects::TableWorkspace_sptr createOutputInfoTable(size_t numspec);

/// Generate output peak information table workspace
Mantid::DataObjects::TableWorkspace_sptr createOutputPeakOffsetTable(size_t numspec);

FitPeakOffsetResult calculatePeakOffset(const int wi, std::vector<double>& fittedpeakpositions, std::vector<double>& vec_peakPosRef);

/// Calculate a spectrum's offset by optimizing offset
void fitPeaksOffset(const size_t inpnparams, const double minD, const double maxD,
const std::vector<double>& vec_peakPosRef,
const std::vector<double>& vec_peakPosFitted,
const std::vector<double>& vec_fitChi2,
FitPeakOffsetResult& fitresult);

/// Make a summary on all fit
void makeFitSummary();

/// Remove rows without offset calculated from offset table workspace
void removeEmptyRowsFromPeakOffsetTable();

API::MatrixWorkspace_sptr inputW;
DataObjects::EventWorkspace_const_sptr eventW;
bool isEvent;

std::string m_backType;
std::string m_peakType;
double m_maxChiSq;
double m_minPeakHeight;

double maxOffset;

std::vector<double> m_peakPositions;
std::vector<double> m_fitWindows;

DataObjects::OffsetsWorkspace_sptr outputW;
/// Output workspace for debugging purpose
DataObjects::OffsetsWorkspace_sptr outputNP;
/// Output Mask workspace
API::MatrixWorkspace_sptr maskWS;

DataObjects::TableWorkspace_sptr m_infoTableWS;
DataObjects::TableWorkspace_sptr m_peakOffsetTableWS;

};

} // namespace Algorithm
Expand Down
@@ -0,0 +1,64 @@
#ifndef MANTID_ALGORITHMS_SETINSTRUMENTPARAMETER_H_
#define MANTID_ALGORITHMS_SETINSTRUMENTPARAMETER_H_

#include "MantidKernel/System.h"
#include "MantidAPI/Algorithm.h"

namespace Mantid
{

namespace Geometry
{
class ParameterMap;
class IComponent;
}

namespace Algorithms
{

/** SetInstrumentParameter : A simple algorithm to add or set the value of an instrument parameter
Copyright &copy; 2014 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory
This file is part of Mantid.
Mantid is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
Mantid is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
File change history is stored at: <https://github.com/mantidproject/mantid>
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
class DLLExport SetInstrumentParameter : public API::Algorithm
{
public:
SetInstrumentParameter();
virtual ~SetInstrumentParameter();

virtual const std::string name() const;
virtual int version() const;
virtual const std::string category() const;

private:
virtual void initDocs();
void init();
void exec();

void addParameter(Mantid::Geometry::ParameterMap& pmap, const Mantid::Geometry::IComponent* cmptId, const std::string& paramName, const std::string& paramType, const std::string& paramValue) const;

};


} // namespace Algorithms
} // namespace Mantid

#endif /* MANTID_ALGORITHMS_SETINSTRUMENTPARAMETER_H_ */

0 comments on commit 90895d6

Please sign in to comment.