Mantid
Loading...
Searching...
No Matches
Public Member Functions | List of all members
Mantid::API::Sample Class Reference

This class stores information about the sample used in particular run. More...

#include <Sample.h>

Public Member Functions

void addSample (const std::shared_ptr< Sample > &childSample)
 Adds a sample to the list. More...
 
const std::string & getName () const
 Returns the name of the sample. More...
 
const Geometry::IObjectgetShape () const
 Return the sample shape. More...
 
const Geometry::IObject_sptr getShapePtr () const
 Return a pointer to the sample shape. More...
 
bool hasShape () const
 Check if sample has a valid shape. More...
 
int loadNexus (::NeXus::File *file, const std::string &group)
 Load the object from an open NeXus file. More...
 
Sampleoperator= (const Sample &rhs)
 Assignment operator. More...
 
Sampleoperator[] (const int index)
 index operator for accessing multiple samples More...
 
 Sample ()
 Default constructor. More...
 
 Sample (const Sample &copy)
 Copy constructor. More...
 
void saveNexus (::NeXus::File *file, const std::string &group) const
 Save the object to an open NeXus file. More...
 
void setName (const std::string &name)
 Set the name of the sample. More...
 
void setShape (const Geometry::IObject_sptr &shape)
 Update the shape of the object. More...
 
std::size_t size () const
 the number of samples More...
 
 ~Sample ()
 Destructor. More...
 
Material properties.
const Kernel::MaterialgetMaterial () const
 Return the material (convenience method) More...
 
Access the environment information
bool hasEnvironment () const
 
const Geometry::SampleEnvironmentgetEnvironment () const
 Get a reference to the sample's environment. More...
 
void setEnvironment (std::shared_ptr< Geometry::SampleEnvironment > env)
 Set the environment used to contain the sample. More...
 
Access the sample's lattice structure and orientation
const Geometry::OrientedLatticegetOrientedLattice () const
 Get a reference to the sample's OrientedLattice. More...
 
Geometry::OrientedLatticegetOrientedLattice ()
 Get a reference to the sample's OrientedLattice. More...
 
void setOrientedLattice (std::unique_ptr< Geometry::OrientedLattice > lattice)
 Set the pointer to OrientedLattice defining the sample's lattice and orientation. More...
 
bool hasOrientedLattice () const
 
Access the sample's crystal structure
const Geometry::CrystalStructuregetCrystalStructure () const
 
void setCrystalStructure (const Geometry::CrystalStructure &newCrystalStructure)
 Resets the internal pointer to the new CrystalStructure (it's copied). More...
 
bool hasCrystalStructure () const
 Returns true if the sample actually holds a CrystalStructure. More...
 
void clearCrystalStructure ()
 Destroys the internally stored CrystalStructure-object. More...
 

Legacy functions

std::string m_name
 The sample name. More...
 
Geometry::IObject_sptr m_shape
 The sample shape object. More...
 
std::shared_ptr< Geometry::SampleEnvironmentm_environment
 An owned pointer to the SampleEnvironment object. More...
 
std::unique_ptr< Geometry::OrientedLatticem_lattice
 Pointer to the OrientedLattice of the sample, NULL if not set. More...
 
std::unique_ptr< Geometry::CrystalStructurem_crystalStructure
 CrystalStructure of the sample. More...
 
std::vector< std::shared_ptr< Sample > > m_samples
 Vector of child samples. More...
 
int m_geom_id
 The sample geometry flag. More...
 
double m_thick
 The sample thickness from the SPB_STRUCT in the raw file. More...
 
double m_height
 The sample height from the SPB_STRUCT in the raw file. More...
 
double m_width
 The sample width from the SPB_STRUCT in the raw file. More...
 
void setGeometryFlag (int geom_id)
 Sets the geometry flag. More...
 
int getGeometryFlag () const
 Returns the geometry flag. More...
 
void setThickness (double thick)
 Sets the thickness. More...
 
double getThickness () const
 Returns the thickness. More...
 
void setHeight (double height)
 Sets the height. More...
 
double getHeight () const
 Returns the height. More...
 
void setWidth (double width)
 Sets the width. More...
 
double getWidth () const
 Returns the width. More...
 
void clearOrientedLattice ()
 Delete the oriented lattice. More...
 
bool operator== (const Sample &other) const
 
bool operator!= (const Sample &other) const
 

Detailed Description

This class stores information about the sample used in particular run.

It is a type of ObjComponent meaning it has a shape, a position and a material.

Definition at line 33 of file Sample.h.

Constructor & Destructor Documentation

◆ Sample() [1/2]

Mantid::API::Sample::Sample ( )

Default constructor.

Required for cow_ptr.

Definition at line 30 of file Sample.cpp.

◆ Sample() [2/2]

Mantid::API::Sample::Sample ( const Sample copy)

Copy constructor.

Parameters
copy:: const reference to the sample object

Definition at line 38 of file Sample.cpp.

References getCrystalStructure(), getOrientedLattice(), hasCrystalStructure(), m_crystalStructure, and m_lattice.

◆ ~Sample()

Mantid::API::Sample::~Sample ( )
default

Destructor.

References std::operator!=(), and std::operator==().

Member Function Documentation

◆ addSample()

void Mantid::API::Sample::addSample ( const std::shared_ptr< Sample > &  childSample)

Adds a sample to the list.

Adds a sample to the sample collection.

Parameters
childSampleThe child sample to be added

Definition at line 279 of file Sample.cpp.

References m_samples.

Referenced by loadNexus().

◆ clearCrystalStructure()

void Mantid::API::Sample::clearCrystalStructure ( )

Destroys the internally stored CrystalStructure-object.

Definition at line 202 of file Sample.cpp.

References m_crystalStructure.

Referenced by export_Sample().

◆ clearOrientedLattice()

void Mantid::API::Sample::clearOrientedLattice ( )

Delete the oriented lattice.

Definition at line 408 of file Sample.cpp.

References m_lattice.

Referenced by Mantid::Crystal::ClearUB::clearSingleExperimentInfo(), and export_Sample().

◆ getCrystalStructure()

const Geometry::CrystalStructure & Mantid::API::Sample::getCrystalStructure ( ) const

◆ getEnvironment()

const SampleEnvironment & Mantid::API::Sample::getEnvironment ( ) const

◆ getGeometryFlag()

int Mantid::API::Sample::getGeometryFlag ( ) const

Returns the geometry flag.

Get the geometry flag that is specified in the raw file within the SPB_STRUCT 1 = cylinder, 2 = flat plate, 3 = disc, 4 = single crystal.

Returns
The flag for the sample geometry

Definition at line 216 of file Sample.cpp.

References m_geom_id.

Referenced by Mantid::Algorithms::CopySample::copyParameters(), and export_Sample().

◆ getHeight()

double Mantid::API::Sample::getHeight ( ) const

Returns the height.

Get the height value.

Returns
The parameter height parameter

Definition at line 240 of file Sample.cpp.

References m_height.

Referenced by Mantid::Algorithms::CopySample::copyParameters(), and export_Sample().

◆ getMaterial()

const Material & Mantid::API::Sample::getMaterial ( ) const

Return the material (convenience method)

Return the material.

Returns
A reference to the material the sample is composed of

Definition at line 127 of file Sample.cpp.

References m_shape.

Referenced by Mantid::Algorithms::CopySample::copyParameters(), export_Sample(), Mantid::DataHandling::SetSample::setSampleShape(), and Mantid::DataHandling::CreateSampleShape::setSampleShape().

◆ getName()

const std::string & Mantid::API::Sample::getName ( ) const

Returns the name of the sample.

Returns
The name of this sample

Definition at line 86 of file Sample.cpp.

References m_name.

Referenced by Mantid::Algorithms::CompareWorkspaces::checkSample(), Mantid::Algorithms::CopySample::copyParameters(), and export_Sample().

◆ getOrientedLattice() [1/2]

OrientedLattice & Mantid::API::Sample::getOrientedLattice ( )

Get a reference to the sample's OrientedLattice.

Return a reference to the OrientedLattice of this sample.

Returns
A reference to a OrientedLattice object
Exceptions
std::runtime_errorIf the OrientedLattice has not been defined

Definition at line 165 of file Sample.cpp.

References m_lattice.

◆ getOrientedLattice() [2/2]

const OrientedLattice & Mantid::API::Sample::getOrientedLattice ( ) const

◆ getShape()

const IObject & Mantid::API::Sample::getShape ( ) const

Return the sample shape.

Get a reference to the sample shape object.

It is assumed that this is defined within its own coordinate system with its centre at [0,0,0]

Returns
A reference to the object describing the shape

Definition at line 102 of file Sample.cpp.

References m_shape.

Referenced by Mantid::Algorithms::AbsorptionCorrection::constructSample(), Mantid::Algorithms::PaalmanPingsAbsorptionCorrection::constructSample(), Mantid::Algorithms::CopySample::copyParameters(), Mantid::Algorithms::BeamProfileFactory::createBeamProfile(), and export_Sample().

◆ getShapePtr()

const IObject_sptr Mantid::API::Sample::getShapePtr ( ) const

Return a pointer to the sample shape.

Get a pointer to the sample shape object.

It is assumed that this is defined within its own coordinate system with its centre at [0,0,0]

Returns
A pointer to the object describing the shape

Definition at line 110 of file Sample.cpp.

References m_shape.

◆ getThickness()

double Mantid::API::Sample::getThickness ( ) const

Returns the thickness.

Get the thickness value.

Returns
The parameter thickness parameter

Definition at line 228 of file Sample.cpp.

References m_thick.

Referenced by Mantid::Algorithms::CopySample::copyParameters(), and export_Sample().

◆ getWidth()

double Mantid::API::Sample::getWidth ( ) const

Returns the width.

Get the height value.

Returns
The parameter height parameter

Definition at line 252 of file Sample.cpp.

References m_width.

Referenced by Mantid::Algorithms::CopySample::copyParameters(), and export_Sample().

◆ hasCrystalStructure()

bool Mantid::API::Sample::hasCrystalStructure ( ) const

Returns true if the sample actually holds a CrystalStructure.

Definition at line 195 of file Sample.cpp.

References m_crystalStructure.

Referenced by export_Sample(), getCrystalStructure(), Sample(), and Mantid::Crystal::PredictPeaks::setStructureFactorCalculatorFromSample().

◆ hasEnvironment()

bool Mantid::API::Sample::hasEnvironment ( ) const

◆ hasOrientedLattice()

bool Mantid::API::Sample::hasOrientedLattice ( ) const

◆ hasShape()

bool Mantid::API::Sample::hasShape ( ) const

Check if sample has a valid shape.

Definition at line 94 of file Sample.cpp.

References m_shape.

Referenced by export_Sample().

◆ loadNexus()

int Mantid::API::Sample::loadNexus ( ::NeXus::File *  file,
const std::string &  group 
)

Load the object from an open NeXus file.

Parameters
file:: open NeXus file
group:: name of the group to open
Returns
the version tag of the sample group

Definition at line 327 of file Sample.cpp.

References addSample(), Mantid::Geometry::ShapeFactory::createShape(), Mantid::Kernel::Material::loadNexus(), m_geom_id, m_height, m_lattice, m_name, m_shape, m_thick, m_width, Mantid::Kernel::Strings::strip(), and Mantid::Kernel::Strings::toString().

Referenced by Mantid::API::ExperimentInfo::loadSampleAndLogInfoNexus().

◆ operator!=()

bool Mantid::API::Sample::operator!= ( const Sample other) const

Definition at line 437 of file Sample.cpp.

References operator==().

◆ operator=()

Sample & Mantid::API::Sample::operator= ( const Sample rhs)

Assignment operator.

Parameters
rhs:: const reference to the sample object
Returns
A reference to this object, which will have the same state as the argument

Definition at line 58 of file Sample.cpp.

References m_crystalStructure, m_environment, m_geom_id, m_height, m_lattice, m_name, m_samples, m_shape, m_thick, m_width, and rhs.

◆ operator==()

bool Mantid::API::Sample::operator== ( const Sample other) const

◆ operator[]()

Sample & Mantid::API::Sample::operator[] ( const int  index)

index operator for accessing multiple samples

Gets the desired sample, 0 is the current sample.

Parameters
indexThe index of the desired sample
Returns
The desired sample

Definition at line 259 of file Sample.cpp.

References index, and m_samples.

◆ saveNexus()

void Mantid::API::Sample::saveNexus ( ::NeXus::File *  file,
const std::string &  group 
) const

Save the object to an open NeXus file.

Parameters
file:: open NeXus file
group:: name of the group to create

Definition at line 286 of file Sample.cpp.

References hasOrientedLattice(), m_geom_id, m_height, m_lattice, m_name, m_samples, m_shape, m_thick, m_width, saveNexus(), and Mantid::Kernel::Strings::toString().

Referenced by Mantid::API::ExperimentInfo::saveExperimentInfoNexus(), and saveNexus().

◆ setCrystalStructure()

void Mantid::API::Sample::setCrystalStructure ( const Geometry::CrystalStructure newCrystalStructure)

Resets the internal pointer to the new CrystalStructure (it's copied).

Definition at line 190 of file Sample.cpp.

References m_crystalStructure.

Referenced by export_Sample().

◆ setEnvironment()

void Mantid::API::Sample::setEnvironment ( std::shared_ptr< Geometry::SampleEnvironment env)

Set the environment used to contain the sample.

Attach an environment onto this sample.

Parameters
env:: A pointer to a created sample environment. This takes ownership of the object.

Definition at line 148 of file Sample.cpp.

References m_environment.

Referenced by Mantid::Algorithms::CopySample::copyParameters(), export_Sample(), Mantid::DataHandling::LoadSampleEnvironment::loadEnvironmentFromSTL(), Mantid::DataHandling::SetSample::setSampleEnvironmentFromFile(), and Mantid::DataHandling::SetSample::setSampleEnvironmentFromXML().

◆ setGeometryFlag()

void Mantid::API::Sample::setGeometryFlag ( int  geom_id)

Sets the geometry flag.

Set the geometry flag that is specfied in the raw file within the SPB_STRUCT 1 = cylinder, 2 = flat plate, 3 = disc, 4 = single crystal.

Parameters
geom_id:: The flag for the geometry

Definition at line 209 of file Sample.cpp.

References m_geom_id.

Referenced by Mantid::Algorithms::CopySample::copyParameters(), export_Sample(), and Mantid::DataHandling::LoadISISNexusHelper::loadSampleGeometry().

◆ setHeight()

void Mantid::API::Sample::setHeight ( double  height)

Sets the height.

Set the height value.

Parameters
height:: The parameter e_height in the SPB_STRUCT

Definition at line 234 of file Sample.cpp.

References height, and m_height.

Referenced by Mantid::Algorithms::CopySample::copyParameters(), export_Sample(), and Mantid::DataHandling::LoadISISNexusHelper::loadSampleGeometry().

◆ setName()

void Mantid::API::Sample::setName ( const std::string &  name)

Set the name of the sample.

Update the name of the sample.

Parameters
name:: The name of the sample

Definition at line 92 of file Sample.cpp.

References m_name.

Referenced by Mantid::Algorithms::CopySample::copyParameters().

◆ setOrientedLattice()

void Mantid::API::Sample::setOrientedLattice ( std::unique_ptr< Geometry::OrientedLattice lattice)

Set the pointer to OrientedLattice defining the sample's lattice and orientation.

Attach an OrientedLattice onto this sample.

Parameters
lattice:: A pointer to a OrientedLattice.

Definition at line 176 of file Sample.cpp.

References m_lattice.

Referenced by Mantid::Algorithms::CopySample::copyParameters().

◆ setShape()

void Mantid::API::Sample::setShape ( const Geometry::IObject_sptr shape)

Update the shape of the object.

Set the object that describes the sample shape.

The object is defined within its own coordinate system

Parameters
shape:: The object describing the shape

Definition at line 116 of file Sample.cpp.

References Mantid::Geometry::ShapeFactory::createShape(), and m_shape.

Referenced by Mantid::Algorithms::AbsorptionCorrection::constructSample(), Mantid::Algorithms::CopySample::copyParameters(), Mantid::DataHandling::LoadSampleShape::exec(), export_Sample(), Mantid::DataHandling::SetSample::setSampleShape(), and Mantid::DataHandling::CreateSampleShape::setSampleShape().

◆ setThickness()

void Mantid::API::Sample::setThickness ( double  thick)

Sets the thickness.

Set the thickness value.

Parameters
thick:: The parameter e_thick in the SPB_STRUCT

Definition at line 222 of file Sample.cpp.

References m_thick.

Referenced by Mantid::Algorithms::CopySample::copyParameters(), export_Sample(), and Mantid::DataHandling::LoadISISNexusHelper::loadSampleGeometry().

◆ setWidth()

void Mantid::API::Sample::setWidth ( double  width)

Sets the width.

Set the width value.

Parameters
width:: The parameter e_width in the SPB_STRUCT

Definition at line 246 of file Sample.cpp.

References m_width.

Referenced by Mantid::Algorithms::CopySample::copyParameters(), export_Sample(), and Mantid::DataHandling::LoadISISNexusHelper::loadSampleGeometry().

◆ size()

std::size_t Mantid::API::Sample::size ( ) const

the number of samples

Gets the number of samples in this collection.

Returns
The count of samples

Definition at line 273 of file Sample.cpp.

References m_samples.

Referenced by export_Sample().

Member Data Documentation

◆ m_crystalStructure

std::unique_ptr<Geometry::CrystalStructure> Mantid::API::Sample::m_crystalStructure
private

CrystalStructure of the sample.

Definition at line 136 of file Sample.h.

Referenced by clearCrystalStructure(), getCrystalStructure(), hasCrystalStructure(), operator=(), operator==(), Sample(), and setCrystalStructure().

◆ m_environment

std::shared_ptr<Geometry::SampleEnvironment> Mantid::API::Sample::m_environment
private

An owned pointer to the SampleEnvironment object.

Definition at line 131 of file Sample.h.

Referenced by getEnvironment(), hasEnvironment(), operator=(), operator==(), and setEnvironment().

◆ m_geom_id

int Mantid::API::Sample::m_geom_id
private

The sample geometry flag.

Definition at line 142 of file Sample.h.

Referenced by getGeometryFlag(), loadNexus(), operator=(), operator==(), saveNexus(), and setGeometryFlag().

◆ m_height

double Mantid::API::Sample::m_height
private

The sample height from the SPB_STRUCT in the raw file.

Definition at line 146 of file Sample.h.

Referenced by getHeight(), loadNexus(), operator=(), operator==(), saveNexus(), and setHeight().

◆ m_lattice

std::unique_ptr<Geometry::OrientedLattice> Mantid::API::Sample::m_lattice
private

Pointer to the OrientedLattice of the sample, NULL if not set.

Definition at line 133 of file Sample.h.

Referenced by clearOrientedLattice(), getOrientedLattice(), hasOrientedLattice(), loadNexus(), operator=(), operator==(), Sample(), saveNexus(), and setOrientedLattice().

◆ m_name

std::string Mantid::API::Sample::m_name
private

The sample name.

Definition at line 127 of file Sample.h.

Referenced by getName(), loadNexus(), operator=(), operator==(), saveNexus(), and setName().

◆ m_samples

std::vector<std::shared_ptr<Sample> > Mantid::API::Sample::m_samples
private

Vector of child samples.

Definition at line 139 of file Sample.h.

Referenced by addSample(), operator=(), operator==(), operator[](), saveNexus(), and size().

◆ m_shape

Geometry::IObject_sptr Mantid::API::Sample::m_shape
private

The sample shape object.

Definition at line 129 of file Sample.h.

Referenced by getMaterial(), getShape(), getShapePtr(), hasShape(), loadNexus(), operator=(), operator==(), saveNexus(), and setShape().

◆ m_thick

double Mantid::API::Sample::m_thick
private

The sample thickness from the SPB_STRUCT in the raw file.

Definition at line 144 of file Sample.h.

Referenced by getThickness(), loadNexus(), operator=(), operator==(), saveNexus(), and setThickness().

◆ m_width

double Mantid::API::Sample::m_width
private

The sample width from the SPB_STRUCT in the raw file.

Definition at line 148 of file Sample.h.

Referenced by getWidth(), loadNexus(), operator=(), operator==(), saveNexus(), and setWidth().


The documentation for this class was generated from the following files: