-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add another algorithm for LeBailFit. Refs #5306.
- Loading branch information
Showing
3 changed files
with
1,371 additions
and
0 deletions.
There are no files selected for viewing
136 changes: 136 additions & 0 deletions
136
Code/Mantid/Framework/CurveFitting/inc/MantidCurveFitting/RefinePowderInstrumentParameters.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
#ifndef MANTID_CURVEFITTING_REFINEPOWDERINSTRUMENTPARAMETERS_H_ | ||
#define MANTID_CURVEFITTING_REFINEPOWDERINSTRUMENTPARAMETERS_H_ | ||
|
||
#include "MantidKernel/System.h" | ||
#include "MantidAPI/Algorithm.h" | ||
#include "MantidDataObjects/TableWorkspace.h" | ||
#include "MantidDataObjects/Workspace2D.h" | ||
#include "MantidAPI/MatrixWorkspace.h" | ||
#include "MantidCurveFitting/ThermalNeutronBk2BkExpConvPV.h" | ||
#include "MantidAPI/CompositeFunction.h" | ||
#include "MantidCurveFitting/BackgroundFunction.h" | ||
#include "MantidAPI/ITableWorkspace.h" | ||
#include "MantidCurveFitting/Bk2BkExpConvPV.h" | ||
#include "MantidCurveFitting/Polynomial.h" | ||
|
||
namespace Mantid | ||
{ | ||
namespace CurveFitting | ||
{ | ||
|
||
/** RefinePowderInstrumentParameters : Algorithm to refine instrument geometry parameters only. | ||
How to use the algorithm to refine instrument geometry? | ||
- Input includes | ||
* Data workspace dataWS | ||
* Peak parameters ????? Not sure which to use. (1) ThermalNeutronBk2BkExpConvPV OR (2) Bk2BkExpConvPV | ||
* List of peaks (H, K, L) to fit for Bk2BkExpConvPV | ||
- Algorithm | ||
* For each input peak: | ||
1. Calculate TOF_h | ||
2. Find a proper range of data including peak and background around each peak | ||
3. For each peak | ||
a) Remove peak and fit the background | ||
Considering: get a linear function of two ends | ||
only include certain range of data around this linear function | ||
fit for all the points selected | ||
b) Construct a composite function containing (1) Bk2BkExpConvPV and (2) background function | ||
c) Fix background and fit the peak | ||
d) If fitting result is acceptible, record TOF_h | ||
e) Record the calcualed data as further refer. | ||
4. Construct workspace peakpositionWS such that | ||
dataGeometry.X = d-spacing value | ||
dataGeometry.Y = Observed TOF_h | ||
5. Fit zero, zerot, Dtt1, Dtt1t,and/or Dtt2t | ||
Copyright © 2012 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://svn.mantidproject.org/mantid/trunk/Code/Mantid> | ||
Code Documentation is available at: <http://doxygen.mantidproject.org> | ||
*/ | ||
class DLLExport RefinePowderInstrumentParameters : public API::Algorithm | ||
{ | ||
public: | ||
RefinePowderInstrumentParameters(); | ||
virtual ~RefinePowderInstrumentParameters(); | ||
|
||
/// Algorithm's name for identification overriding a virtual method | ||
virtual const std::string name() const { return "RefinePowderInstrumentParameters";} | ||
|
||
/// Algorithm's version for identification overriding a virtual method | ||
virtual int version() const { return 2;} | ||
|
||
/// Algorithm's category for identification overriding a virtual method | ||
virtual const std::string category() const { return "Diffraction";} | ||
|
||
private: | ||
/// Sets documentation strings for this algorithm | ||
virtual void initDocs(); | ||
// Implement abstract Algorithm methods | ||
void init(); | ||
// Implement abstract Algorithm methods | ||
void exec(); | ||
|
||
void generatePeaksFromInput(DataObjects::TableWorkspace_sptr peakparamws, | ||
std::map<std::vector<int>, CurveFitting::Bk2BkExpConvPV_sptr>& peaks); | ||
|
||
void importParametersFromTable(DataObjects::TableWorkspace_sptr parameterWS, std::map<std::string, double>& parameters); | ||
|
||
void fitPeaks(int workspaceindex, std::vector<std::vector<int> >& goodfitpeaks, std::vector<double> &goodfitchi2); | ||
|
||
bool fitLinearBackground(CurveFitting::Bk2BkExpConvPV_sptr peak, | ||
size_t workspaceindex, Polynomial_sptr, double xmin, double xmax); | ||
|
||
/// Generate (output) workspace of peak centers | ||
void genPeakCentersWorkspace(std::map<std::vector<int>, CurveFitting::Bk2BkExpConvPV_sptr> peaks, | ||
std::vector<std::vector<int> > goodpeaks, std::vector<double> goodfitchi2); | ||
|
||
/// Fit instrument geometry parameters by ThermalNeutronDtoTOFFunction | ||
void fitInstrumentParameters(); | ||
|
||
/// Create output of peak patterns | ||
DataObjects::Workspace2D_sptr createPeakDataWorkspace(size_t workspaceindex); | ||
|
||
/// Data | ||
API::MatrixWorkspace_sptr dataWS; | ||
|
||
/// Output Workspace | ||
DataObjects::Workspace2D_sptr outWS; | ||
|
||
/// Map for all peaks to fit individually | ||
std::map<std::vector<int>, CurveFitting::Bk2BkExpConvPV_sptr> mPeaks; | ||
|
||
/// Map for function (instrument parameter) | ||
std::map<std::string, double> mFuncParameters; | ||
|
||
/// Map for input (original) function | ||
std::map<std::string, double> mInputFuncParameters; | ||
|
||
/// Peak centers in d-spacing and TOF for final fitting | ||
std::map<std::vector<int>, std::pair<double, double> > mPeakCenters; | ||
|
||
/// Data for each individual peaks. (HKL)^2, vector index, function values | ||
std::map<int, std::pair<std::vector<size_t>, API::FunctionValues> > mPeakData; | ||
|
||
}; | ||
|
||
|
||
} // namespace CurveFitting | ||
} // namespace Mantid | ||
|
||
#endif /* MANTID_CURVEFITTING_REFINEPOWDERINSTRUMENTPARAMETERS_H_ */ |
Oops, something went wrong.