Mantid
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
Mantid::Algorithms::MCInteractionVolume Class Reference

Defines a volume where interactions of Tracks and Objects can take place. More...

#include <MCInteractionVolume.h>

Inheritance diagram for Mantid::Algorithms::MCInteractionVolume:
Mantid::Algorithms::IMCInteractionVolume

Public Types

enum class  ScatteringPointVicinity { SAMPLEANDENVIRONMENT , SAMPLEONLY , ENVIRONMENTONLY }
 
- Public Types inherited from Mantid::Algorithms::IMCInteractionVolume
enum class  ScatteringPointVicinity { SAMPLEANDENVIRONMENT , SAMPLEONLY , ENVIRONMENTONLY }
 

Public Member Functions

virtual TrackPair calculateBeforeAfterTrack (Kernel::PseudoRandomNumberGenerator &rng, const Kernel::V3D &startPos, const Kernel::V3D &endPos, MCInteractionStatistics &stats) const override
 Calculate a before scatter and after scatter track based on a scatter point in the volume given a start and end point.
 
ComponentScatterPoint generatePoint (Kernel::PseudoRandomNumberGenerator &rng) const override
 Generate point randomly across one of the components of the environment including the sample itself in the selection.
 
const Geometry::BoundingBox getFullBoundingBox () const override
 Returns the defined gauge volume if one is present, otherwise returns axis-aligned bounding box for the volume including env if m_pointsIn != SampleOnly.
 
Geometry::IObject_sptr getGaugeVolume () const override
 Returns the defined gauge volume if one is present, otherwise returns nullptr.
 
void setActiveRegion (const Geometry::BoundingBox &region) override
 Sets the active region volume on the InteractionVolume.
 
void setGaugeVolume (Geometry::IObject_sptr gaugeVolume) override
 Sets the gauge volume on the InteractionVolume.
 
- Public Member Functions inherited from Mantid::Algorithms::IMCInteractionVolume
virtual ~IMCInteractionVolume ()=default
 

Static Public Member Functions

static std::shared_ptr< IMCInteractionVolumecreate (const API::Sample &sample, const size_t maxScatterAttempts=5000, const ScatteringPointVicinity pointsIn=ScatteringPointVicinity::SAMPLEANDENVIRONMENT, Geometry::IObject_sptr gaugeVolume=nullptr)
 Factory Method for constructing the volume encompassing the sample + any environment kit.
 

Protected Member Functions

void init () override
 Construct the volume encompassing the sample + any environment kit.
 

Private Member Functions

std::optional< Kernel::V3DgeneratePointInObjectByIndex (int componentIndex, Kernel::PseudoRandomNumberGenerator &rng) const
 Generate a point in an object identified by an index.
 
int getComponentIndex (Kernel::PseudoRandomNumberGenerator &rng) const
 Randomly select a component across the sample/environment.
 
 MCInteractionVolume (const API::Sample &sample, const size_t maxScatterAttempts=5000, const ScatteringPointVicinity pointsIn=ScatteringPointVicinity::SAMPLEANDENVIRONMENT, Geometry::IObject_sptr gaugeVolume=nullptr)
 Construct the volume encompassing the sample + any environment kit.
 

Private Attributes

Geometry::BoundingBox m_activeRegion
 
const Geometry::SampleEnvironmentm_env
 
Geometry::IObject_sptr m_gaugeVolume
 
const size_t m_maxScatterAttempts
 
const ScatteringPointVicinity m_pointsIn
 
const std::shared_ptr< Geometry::IObjectm_sample
 

Detailed Description

Defines a volume where interactions of Tracks and Objects can take place.

Given an initial Track, end point & wavelengths it calculates the absorption correction factor.

Definition at line 28 of file MCInteractionVolume.h.

Member Enumeration Documentation

◆ ScatteringPointVicinity

Enumerator
SAMPLEANDENVIRONMENT 
SAMPLEONLY 
ENVIRONMENTONLY 

Definition at line 30 of file MCInteractionVolume.h.

Constructor & Destructor Documentation

◆ MCInteractionVolume()

Mantid::Algorithms::MCInteractionVolume::MCInteractionVolume ( const API::Sample sample,
const size_t  maxScatterAttempts = 5000,
const ScatteringPointVicinity  pointsIn = ScatteringPointVicinity::SAMPLEANDENVIRONMENT,
Geometry::IObject_sptr  gaugeVolume = nullptr 
)
explicitprivate

Construct the volume encompassing the sample + any environment kit.

The active region defines a bounding region for the sampling of the scattering position.

Parameters
sampleA reference to a sample object that defines a valid shape & material
maxScatterAttemptsThe maximum number of tries to generate a random point within the object. [Default=5000]
pointsInWhere to generate the scattering point in
gaugeVolumePointer to any gauge volume object defined for the interaction

Definition at line 88 of file MCInteractionVolume.cpp.

Member Function Documentation

◆ calculateBeforeAfterTrack()

TrackPair Mantid::Algorithms::MCInteractionVolume::calculateBeforeAfterTrack ( Kernel::PseudoRandomNumberGenerator rng,
const Kernel::V3D startPos,
const Kernel::V3D endPos,
MCInteractionStatistics stats 
) const
overridevirtual

Calculate a before scatter and after scatter track based on a scatter point in the volume given a start and end point.

Parameters
rngA reference to a PseudoRandomNumberGenerator producing random number between [0,1]
startPosOrigin of the initial track
endPosFinal position of neutron after scattering (assumed to be outside of the "volume")
statsA statistics class to hold the statistics on the generated tracks such as the scattering angle and count of scatter points generated in each sample or environment part
Returns
A tuple containing a flag to indicate whether before/after tracks were successfully generated and (if yes) the before/after tracks

Implements Mantid::Algorithms::IMCInteractionVolume.

Definition at line 218 of file MCInteractionVolume.cpp.

References Mantid::Algorithms::ComponentScatterPoint::componentIndex, generatePoint(), Mantid::Geometry::SampleEnvironment::interceptSurfaces(), m_env, m_sample, Mantid::Kernel::normalize(), Mantid::Algorithms::ComponentScatterPoint::scatterPoint, Mantid::Algorithms::MCInteractionStatistics::UpdateScatterAngleStats(), and Mantid::Algorithms::MCInteractionStatistics::UpdateScatterPointCounts().

◆ create()

std::shared_ptr< IMCInteractionVolume > Mantid::Algorithms::MCInteractionVolume::create ( const API::Sample sample,
const size_t  maxScatterAttempts = 5000,
const ScatteringPointVicinity  pointsIn = ScatteringPointVicinity::SAMPLEANDENVIRONMENT,
Geometry::IObject_sptr  gaugeVolume = nullptr 
)
static

Factory Method for constructing the volume encompassing the sample + any environment kit.

The active region defines a bounding region for the sampling of the scattering position.

Parameters
sampleA reference to a sample object that defines a valid shape & material
maxScatterAttemptsThe maximum number of tries to generate a random point within the object. [Default=5000]
pointsInWhere to generate the scattering point in
gaugeVolumePointer to any gauge volume object defined for the interaction
Returns
returns a shared pointer to interaction volume object

Definition at line 67 of file MCInteractionVolume.cpp.

Referenced by Mantid::Algorithms::MonteCarloAbsorption::doSimulation(), and Mantid::Algorithms::AddAbsorptionWeightedPathLengths::exec().

◆ generatePoint()

ComponentScatterPoint Mantid::Algorithms::MCInteractionVolume::generatePoint ( Kernel::PseudoRandomNumberGenerator rng) const
overridevirtual

Generate point randomly across one of the components of the environment including the sample itself in the selection.

The method first selects a random component and then selects a random point within that component using Object::generatePointObject

Parameters
rngA reference to a PseudoRandomNumberGenerator where nextValue should return a flat random number between 0.0 & 1.0
Returns
A struct containing the generated point and the index of the component containing the scatter point

Implements Mantid::Algorithms::IMCInteractionVolume.

Definition at line 191 of file MCInteractionVolume.cpp.

References generatePointInObjectByIndex(), getComponentIndex(), m_maxScatterAttempts, and std::to_string().

Referenced by calculateBeforeAfterTrack().

◆ generatePointInObjectByIndex()

std::optional< Kernel::V3D > Mantid::Algorithms::MCInteractionVolume::generatePointInObjectByIndex ( int  componentIndex,
Kernel::PseudoRandomNumberGenerator rng 
) const
private

Generate a point in an object identified by an index.

Parameters
componentIndexIndex of the sample/environment component where the sample is -1
rngA reference to a PseudoRandomNumberGenerator where nextValue should return a flat random number between 0.0 & 1.0
Returns
The generated point

Definition at line 161 of file MCInteractionVolume.cpp.

References Mantid::Geometry::IObject::generatePointInObject(), Mantid::Geometry::SampleEnvironment::getComponent(), m_activeRegion, m_env, m_gaugeVolume, and m_sample.

Referenced by generatePoint().

◆ getComponentIndex()

int Mantid::Algorithms::MCInteractionVolume::getComponentIndex ( Kernel::PseudoRandomNumberGenerator rng) const
private

Randomly select a component across the sample/environment.

Parameters
rngA reference to a PseudoRandomNumberGenerator where nextValue should return a flat random number between 0.0 & 1.0
Returns
The randomly selected component index

Definition at line 134 of file MCInteractionVolume.cpp.

References ENVIRONMENTONLY, m_env, m_pointsIn, m_sample, Mantid::Geometry::SampleEnvironment::nelements(), Mantid::Kernel::PseudoRandomNumberGenerator::nextInt(), and SAMPLEONLY.

Referenced by generatePoint().

◆ getFullBoundingBox()

const Geometry::BoundingBox Mantid::Algorithms::MCInteractionVolume::getFullBoundingBox ( ) const
overridevirtual

Returns the defined gauge volume if one is present, otherwise returns axis-aligned bounding box for the volume including env if m_pointsIn != SampleOnly.

Returns
The bounding box of the interaction volume

Implements Mantid::Algorithms::IMCInteractionVolume.

Definition at line 111 of file MCInteractionVolume.cpp.

References Mantid::Geometry::SampleEnvironment::boundingBox(), Mantid::Geometry::BoundingBox::grow(), m_env, m_gaugeVolume, m_pointsIn, m_sample, and SAMPLEONLY.

Referenced by init().

◆ getGaugeVolume()

Geometry::IObject_sptr Mantid::Algorithms::MCInteractionVolume::getGaugeVolume ( ) const
overridevirtual

Returns the defined gauge volume if one is present, otherwise returns nullptr.

Returns
Shared pointer to gauge volume object

Implements Mantid::Algorithms::IMCInteractionVolume.

Definition at line 98 of file MCInteractionVolume.cpp.

References m_gaugeVolume.

◆ init()

void Mantid::Algorithms::MCInteractionVolume::init ( )
overrideprotectedvirtual

Construct the volume encompassing the sample + any environment kit.

The active region defines a bounding region for the sampling of the scattering position.

Implements Mantid::Algorithms::IMCInteractionVolume.

Definition at line 27 of file MCInteractionVolume.cpp.

References Mantid::Geometry::SampleEnvironment::getComponent(), getFullBoundingBox(), Mantid::Geometry::IObject::hasValidShape(), m_activeRegion, m_env, m_sample, and Mantid::Geometry::SampleEnvironment::nelements().

◆ setActiveRegion()

void Mantid::Algorithms::MCInteractionVolume::setActiveRegion ( const Geometry::BoundingBox region)
overridevirtual

Sets the active region volume on the InteractionVolume.

Parameters
regionA reference to a Bounding Box for the active region

Implements Mantid::Algorithms::IMCInteractionVolume.

Definition at line 126 of file MCInteractionVolume.cpp.

References m_activeRegion.

◆ setGaugeVolume()

void Mantid::Algorithms::MCInteractionVolume::setGaugeVolume ( Geometry::IObject_sptr  gaugeVolume)
overridevirtual

Sets the gauge volume on the InteractionVolume.

Parameters
gaugeVolumeA shared pointer to the gauge volume shape object

Implements Mantid::Algorithms::IMCInteractionVolume.

Definition at line 104 of file MCInteractionVolume.cpp.

References m_gaugeVolume.

Member Data Documentation

◆ m_activeRegion

Geometry::BoundingBox Mantid::Algorithms::MCInteractionVolume::m_activeRegion
private

Definition at line 54 of file MCInteractionVolume.h.

Referenced by generatePointInObjectByIndex(), init(), and setActiveRegion().

◆ m_env

const Geometry::SampleEnvironment* Mantid::Algorithms::MCInteractionVolume::m_env
private

◆ m_gaugeVolume

Geometry::IObject_sptr Mantid::Algorithms::MCInteractionVolume::m_gaugeVolume
private

◆ m_maxScatterAttempts

const size_t Mantid::Algorithms::MCInteractionVolume::m_maxScatterAttempts
private

Definition at line 55 of file MCInteractionVolume.h.

Referenced by generatePoint().

◆ m_pointsIn

const ScatteringPointVicinity Mantid::Algorithms::MCInteractionVolume::m_pointsIn
private

Definition at line 56 of file MCInteractionVolume.h.

Referenced by getComponentIndex(), and getFullBoundingBox().

◆ m_sample

const std::shared_ptr<Geometry::IObject> Mantid::Algorithms::MCInteractionVolume::m_sample
private

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