16#include "boost/make_shared.hpp"
32 : m_convention(Kernel::
ConfigService::Instance().getString(
"Q.convention")), m_samplePos(
V3D(0, 0, 0)), m_H(0),
33 m_K(0), m_L(0), m_intensity(0), m_sigmaIntensity(0), m_binCount(0), m_absorptionWeightedPathLength(0),
34 m_GoniometerMatrix(3, 3, true), m_InverseGoniometerMatrix(3, 3, true), m_runNumber(0), m_monitorCount(0),
35 m_peakNumber(0), m_intHKL(
V3D(0, 0, 0)), m_intMNP(
V3D(0, 0, 0)), m_peakShape(
std::make_shared<
NoShape>()) {}
43 : m_convention(Kernel::
ConfigService::Instance().getString(
"Q.convention")), m_H(0), m_K(0), m_L(0), m_intensity(0),
44 m_sigmaIntensity(0), m_binCount(0), m_absorptionWeightedPathLength(0), m_GoniometerMatrix(goniometer),
45 m_InverseGoniometerMatrix(goniometer), m_runNumber(0), m_monitorCount(0), m_peakNumber(0), m_intHKL(
V3D(0, 0, 0)),
46 m_intMNP(
V3D(0, 0, 0)), m_peakShape(
std::make_shared<
NoShape>()) {
48 throw std::invalid_argument(
"BasePeak::ctor(): Goniometer matrix must non-singular.");
52 : m_convention(other.m_convention), m_samplePos(other.m_samplePos), m_H(other.m_H), m_K(other.m_K), m_L(other.m_L),
53 m_intensity(other.m_intensity), m_sigmaIntensity(other.m_sigmaIntensity), m_binCount(other.m_binCount),
54 m_absorptionWeightedPathLength(other.m_absorptionWeightedPathLength),
55 m_GoniometerMatrix(other.m_GoniometerMatrix), m_InverseGoniometerMatrix(other.m_InverseGoniometerMatrix),
56 m_runNumber(other.m_runNumber), m_monitorCount(other.m_monitorCount), m_peakNumber(other.m_peakNumber),
57 m_intHKL(other.m_intHKL), m_intMNP(other.m_intMNP), m_peakShape(other.m_peakShape->clone()) {}
65 :
IPeak(ipeak), m_convention(Kernel::
ConfigService::Instance().getString(
"Q.convention")), m_H(ipeak.getH()),
66 m_K(ipeak.getK()), m_L(ipeak.getL()), m_intensity(ipeak.getIntensity()),
67 m_sigmaIntensity(ipeak.getSigmaIntensity()), m_binCount(ipeak.getBinCount()),
68 m_absorptionWeightedPathLength(ipeak.getAbsorptionWeightedPathLength()),
69 m_GoniometerMatrix(ipeak.getGoniometerMatrix()), m_InverseGoniometerMatrix(ipeak.getGoniometerMatrix()),
70 m_runNumber(ipeak.getRunNumber()), m_monitorCount(ipeak.getMonitorCount()), m_peakNumber(ipeak.getPeakNumber()),
71 m_intHKL(ipeak.getIntHKL()), m_intMNP(ipeak.getIntMNP()), m_peakShape(
std::make_shared<
NoShape>()) {
73 throw std::invalid_argument(
"Peak::ctor(): Goniometer matrix must non-singular.");
193 return (std::isfinite(result)) ? result : 0.0;
221 if ((goniometerMatrix.
numCols() != 3) || (goniometerMatrix.
numRows() != 3))
222 throw std::invalid_argument(
"BasePeak::setGoniometerMatrix(): Goniometer matrix must be 3x3.");
227 throw std::invalid_argument(
"BasePeak::setGoniometerMatrix(): Goniometer "
228 "matrix must be non-singular.");
251 std::transform(name.begin(), name.end(), name.begin(), ::tolower);
252 if (name ==
"runnumber")
254 else if (name ==
"h")
256 else if (name ==
"k")
258 else if (name ==
"l")
260 else if (name ==
"wavelength")
262 else if (name ==
"energy")
264 else if (name ==
"tof")
266 else if (name ==
"dspacing")
268 else if (name ==
"intens")
270 else if (name ==
"sigint")
272 else if (name ==
"intens/sigint")
274 else if (name ==
"bincount")
276 else if (name ==
"peaknumber")
278 else if (name ==
"tbar")
281 throw std::runtime_error(
"BasePeak::getValueByColName() unknown column or "
282 "column is not a number: " +
310 if (&other !=
this) {
352 const double norm_q = qLab.
norm();
354 throw std::invalid_argument(
"BasePeak::setQLabFrame(): Q cannot be 0,0,0.");
357 V3D refBeamDir(0, 0, 1);
359 refBeamDir = refFrame->vecPointingAlongBeam();
362 const double qSign = (
m_convention !=
"Crystallography") ? 1.0 : -1.0;
363 const double qBeam = qLab.
scalar_prod(refBeamDir) * qSign;
366 throw std::invalid_argument(
"BasePeak::setQLabFrame(): Q cannot be 0 in the beam direction.");
368 const double one_over_wl = (norm_q * norm_q) / (2.0 * qBeam);
369 const double wl = (2.0 * M_PI) / one_over_wl;
371 std::ostringstream mess;
372 mess <<
"BasePeak::setQLabFrame(): Wavelength found was negative (" << wl <<
" Ang)! This Q is not physical.";
373 throw std::invalid_argument(mess.str());
Structure describing a single-crystal peak.
Mantid::Kernel::V3D getIntMNP() const override
Return the int MNP vector.
Mantid::Kernel::Matrix< double > getInverseGoniometerMatrix() const
Get the goniometer rotation matrix at which this peak was measured.
int m_runNumber
Originating run number for this peak.
bool isIndexed() const override
Return True if the peak has been indexed.
void setSigmaIntensity(double m_sigmaIntensity) override
Set the error on the integrated peak intensity.
double getL() const override
Get the L index of the peak.
void setIntMNP(const Mantid::Kernel::V3D &MNP) override
Sets the modulated peak structure number.
void setK(double m_K) override
Set the K index of this peak.
Mantid::Kernel::Matrix< double > m_GoniometerMatrix
Orientation matrix of the goniometer angles.
void setRunNumber(int m_runNumber) override
Set the run number that measured this peak.
BasePeak()
Default constructor.
void setPeakNumber(int m_peakNumber) override
Sets the unique peak number.
void setMonitorCount(double m_monitorCount) override
Set the monitor count for this peak.
double m_absorptionWeightedPathLength
absorption weighted path length (aka t bar)
double getIntensity() const override
Return the integrated peak intensity.
BasePeak & operator=(BasePeak &&) noexcept=default
Mantid::Kernel::V3D getSamplePos() const override
Return the sample position vector.
double getAbsorptionWeightedPathLength() const override
Gets the absorption weighted path length.
double getSigmaIntensity() const override
Return the error on the integrated peak intensity.
double m_intensity
Integrated peak intensity.
double getK() const override
Get the K index of the peak.
static Mantid::Kernel::Logger g_log
Static logger.
int getPeakNumber() const override
Returns the unique peak number Returns -1 if it could not find it.
void setPeakShape(Mantid::Geometry::PeakShape *shape) override
Set the PeakShape.
double m_sigmaIntensity
Error (sigma) on peak intensity.
Mantid::Kernel::V3D m_samplePos
Cached sample position.
void setH(double m_H) override
Set the H index of this peak.
int getRunNumber() const override
Return the run number this peak was measured at.
double getH() const override
Get the H index of the peak.
double calculateWavelengthFromQLab(const Mantid::Kernel::V3D &qLab)
void setIntensity(double m_intensity) override
Set the integrated peak intensity.
void setHKL(double H, double K, double L) override
Set all three H,K,L indices of the peak.
void setL(double m_L) override
Set the L index of this peak.
Mantid::Kernel::V3D getHKL() const override
Return the HKL vector.
double m_binCount
Count in the bin at the peak.
Mantid::Kernel::Matrix< double > m_InverseGoniometerMatrix
Inverse of the goniometer rotation matrix; used to go from Q in lab frame to Q in sample frame.
Mantid::Kernel::V3D m_intHKL
void setIntHKL(const Kernel::V3D &HKL) override
Set int HKL.
double getBinCount() const override
Return the # of counts in the bin at its peak.
Mantid::Kernel::Matrix< double > getGoniometerMatrix() const override
Get the goniometer rotation matrix at which this peak was measured.
const Mantid::Geometry::PeakShape & getPeakShape() const override
Get the peak shape.
double getIntensityOverSigma() const override
Return the peak intensity divided by the error in the intensity.
double getMonitorCount() const override
Return the monitor count stored in this peak.
Mantid::Geometry::PeakShape_const_sptr m_peakShape
Peak shape.
Mantid::Kernel::V3D m_intMNP
Mantid::Kernel::V3D getIntHKL() const override
Return the int HKL vector.
virtual double getValueByColName(std::string colName) const
Helper function for displaying/sorting peaks.
void setAbsorptionWeightedPathLength(double pathLength) override
Set the absorption weighted path length.
void setSamplePos(double samX, double samY, double samZ) override
Set sample position.
void setGoniometerMatrix(const Mantid::Kernel::Matrix< double > &goniometerMatrix) override
Set the goniometer rotation matrix at which this peak was measured.
void setBinCount(double m_binCount) override
Set the # of counts in the bin at its peak.
double m_monitorCount
Integrated monitor count over TOF range for this run.
PeakShapeNone : No peak shape.
Structure describing a single-crystal peak.
virtual double getTOF() const =0
virtual double getWavelength() const =0
virtual double getDSpacing() const =0
virtual double getInitialEnergy() const =0
virtual std::shared_ptr< const Geometry::ReferenceFrame > getReferenceFrame() const =0
PeakShape : Abstract type to describes the shape of a peak.
The Logger class is in charge of the publishing messages from the framework through various channels.
T Invert()
LU inversion routine.
size_t numRows() const
Return the number of rows in the matrix.
size_t numCols() const
Return the number of columns in the matrix.
Manage the lifetime of a class intended to be a singleton.
constexpr double scalar_prod(const V3D &v) const noexcept
Calculates the cross product.
constexpr double X() const noexcept
Get x.
double norm() const noexcept
std::shared_ptr< const PeakShape > PeakShape_const_sptr
Helper class which provides the Collimation Length for SANS instruments.