15#include "boost/make_shared.hpp"
31 : m_convention(Kernel::
ConfigService::Instance().getString(
"Q.convention")), m_samplePos(
V3D(0, 0, 0)), m_H(0),
32 m_K(0), m_L(0), m_intensity(0), m_sigmaIntensity(0), m_binCount(0), m_absorptionWeightedPathLength(0),
33 m_GoniometerMatrix(3, 3, true), m_InverseGoniometerMatrix(3, 3, true), m_runNumber(0), m_monitorCount(0),
34 m_peakNumber(0), m_intHKL(
V3D(0, 0, 0)), m_intMNP(
V3D(0, 0, 0)), m_peakShape(
std::make_shared<
NoShape>()) {}
42 : m_convention(Kernel::
ConfigService::Instance().getString(
"Q.convention")), m_H(0), m_K(0), m_L(0), m_intensity(0),
43 m_sigmaIntensity(0), m_binCount(0), m_absorptionWeightedPathLength(0), m_GoniometerMatrix(goniometer),
44 m_InverseGoniometerMatrix(goniometer), m_runNumber(0), m_monitorCount(0), m_peakNumber(0), m_intHKL(
V3D(0, 0, 0)),
45 m_intMNP(
V3D(0, 0, 0)), m_peakShape(
std::make_shared<
NoShape>()) {
47 throw std::invalid_argument(
"BasePeak::ctor(): Goniometer matrix must non-singular.");
51 : 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),
52 m_intensity(other.m_intensity), m_sigmaIntensity(other.m_sigmaIntensity), m_binCount(other.m_binCount),
53 m_absorptionWeightedPathLength(other.m_absorptionWeightedPathLength),
54 m_GoniometerMatrix(other.m_GoniometerMatrix), m_InverseGoniometerMatrix(other.m_InverseGoniometerMatrix),
55 m_runNumber(other.m_runNumber), m_monitorCount(other.m_monitorCount), m_peakNumber(other.m_peakNumber),
56 m_intHKL(other.m_intHKL), m_intMNP(other.m_intMNP), m_peakShape(other.m_peakShape->clone()) {}
64 :
IPeak(ipeak), m_convention(Kernel::
ConfigService::Instance().getString(
"Q.convention")), m_H(ipeak.getH()),
65 m_K(ipeak.getK()), m_L(ipeak.getL()), m_intensity(ipeak.getIntensity()),
66 m_sigmaIntensity(ipeak.getSigmaIntensity()), m_binCount(ipeak.getBinCount()),
67 m_absorptionWeightedPathLength(ipeak.getAbsorptionWeightedPathLength()),
68 m_GoniometerMatrix(ipeak.getGoniometerMatrix()), m_InverseGoniometerMatrix(ipeak.getGoniometerMatrix()),
69 m_runNumber(ipeak.getRunNumber()), m_monitorCount(ipeak.getMonitorCount()), m_peakNumber(ipeak.getPeakNumber()),
70 m_intHKL(ipeak.getIntHKL()), m_intMNP(ipeak.getIntMNP()), m_peakShape(
std::make_shared<
NoShape>()) {
72 throw std::invalid_argument(
"Peak::ctor(): Goniometer matrix must non-singular.");
192 return (std::isfinite(result)) ? result : 0.0;
220 if ((goniometerMatrix.
numCols() != 3) || (goniometerMatrix.
numRows() != 3))
221 throw std::invalid_argument(
"BasePeak::setGoniometerMatrix(): Goniometer matrix must be 3x3.");
226 throw std::invalid_argument(
"BasePeak::setGoniometerMatrix(): Goniometer "
227 "matrix must be non-singular.");
250 std::transform(
name.begin(),
name.end(),
name.begin(), ::tolower);
251 if (
name ==
"runnumber")
253 else if (name ==
"h")
255 else if (name ==
"k")
257 else if (name ==
"l")
259 else if (name ==
"wavelength")
261 else if (name ==
"energy")
263 else if (name ==
"tof")
265 else if (name ==
"dspacing")
267 else if (name ==
"intens")
269 else if (name ==
"sigint")
271 else if (name ==
"intens/sigint")
273 else if (name ==
"bincount")
275 else if (name ==
"peaknumber")
277 else if (name ==
"tbar")
279 else if (name ==
"qlab")
281 else if (name ==
"qsample")
283 else if (name ==
"inthkl")
285 else if (name ==
"intmnp")
288 throw std::runtime_error(
"BasePeak::getValueByColName() unknown column or "
289 "column is not a number: " +
317 if (&other !=
this) {
359 const double norm_q = qLab.
norm();
361 throw std::invalid_argument(
"BasePeak::setQLabFrame(): Q cannot be 0,0,0.");
364 V3D refBeamDir(0, 0, 1);
366 refBeamDir = refFrame->vecPointingAlongBeam();
369 const double qSign = (
m_convention !=
"Crystallography") ? 1.0 : -1.0;
370 const double qBeam = qLab.
scalar_prod(refBeamDir) * qSign;
373 throw std::invalid_argument(
"BasePeak::setQLabFrame(): Q cannot be 0 in the beam direction.");
375 const double one_over_wl = (norm_q * norm_q) / (2.0 * qBeam);
376 const double wl = (2.0 * M_PI) / one_over_wl;
378 std::ostringstream mess;
379 mess <<
"BasePeak::setQLabFrame(): Wavelength found was negative (" << wl <<
" Ang)! This Q is not physical.";
380 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
virtual Mantid::Kernel::V3D getQSampleFrame() const =0
virtual Mantid::Kernel::V3D getQLabFrame() 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.
constexpr double scalar_prod(const V3D &v) const noexcept
Calculates the cross product.
constexpr double X() const noexcept
Get x.
double norm() const noexcept
constexpr double norm2() const noexcept
Vector length squared.
std::shared_ptr< const PeakShape > PeakShape_const_sptr
Mantid::Kernel::SingletonHolder< ConfigServiceImpl > ConfigService
Helper class which provides the Collimation Length for SANS instruments.