Mantid
Loading...
Searching...
No Matches
Public Types | Public 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 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. More...
 
ComponentScatterPoint generatePoint (Kernel::PseudoRandomNumberGenerator &rng) const
 Generate point randomly across one of the components of the environment including the sample itself in the selection. More...
 
const Geometry::BoundingBox getFullBoundingBox () const override
 Returns the axis-aligned bounding box for the volume including env if m_pointsIn != SampleOnly. More...
 
 MCInteractionVolume (const API::Sample &sample, const size_t maxScatterAttempts=5000, const ScatteringPointVicinity pointsIn=ScatteringPointVicinity::SAMPLEANDENVIRONMENT)
 Construct the volume encompassing the sample + any environment kit. More...
 
void setActiveRegion (const Geometry::BoundingBox &region) override
 
- Public Member Functions inherited from Mantid::Algorithms::IMCInteractionVolume
virtual TrackPair calculateBeforeAfterTrack (Kernel::PseudoRandomNumberGenerator &rng, const Kernel::V3D &startPos, const Kernel::V3D &endPos, MCInteractionStatistics &stats) const =0
 
virtual const Geometry::BoundingBox getFullBoundingBox () const =0
 
virtual void setActiveRegion (const Geometry::BoundingBox &region)=0
 
virtual ~IMCInteractionVolume ()=default
 

Private Member Functions

boost::optional< Kernel::V3DgeneratePointInObjectByIndex (int componentIndex, Kernel::PseudoRandomNumberGenerator &rng) const
 Generate a point in an object identified by an index. More...
 
int getComponentIndex (Kernel::PseudoRandomNumberGenerator &rng) const
 Randomly select a component across the sample/environment. More...
 

Private Attributes

Geometry::BoundingBox m_activeRegion
 
const Geometry::SampleEnvironmentm_env
 
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 
)

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

Definition at line 31 of file MCInteractionVolume.cpp.

References Mantid::Geometry::SampleEnvironment::getComponent(), Mantid::API::Sample::getEnvironment(), Mantid::Geometry::IObject::hasValidShape(), m_env, m_sample, and Mantid::Geometry::SampleEnvironment::nelements().

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 156 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().

◆ generatePoint()

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

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

Definition at line 129 of file MCInteractionVolume.cpp.

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

Referenced by calculateBeforeAfterTrack().

◆ generatePointInObjectByIndex()

boost::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 109 of file MCInteractionVolume.cpp.

References Mantid::Geometry::IObject::generatePointInObject(), Mantid::Geometry::SampleEnvironment::getComponent(), m_activeRegion, m_env, 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 82 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 axis-aligned bounding box for the volume including env if m_pointsIn != SampleOnly.

Returns
The bounding box

Implements Mantid::Algorithms::IMCInteractionVolume.

Definition at line 65 of file MCInteractionVolume.cpp.

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

◆ setActiveRegion()

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

Implements Mantid::Algorithms::IMCInteractionVolume.

Definition at line 74 of file MCInteractionVolume.cpp.

References m_activeRegion.

Member Data Documentation

◆ m_activeRegion

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

Definition at line 46 of file MCInteractionVolume.h.

Referenced by generatePointInObjectByIndex(), and setActiveRegion().

◆ m_env

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

◆ m_maxScatterAttempts

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

Definition at line 47 of file MCInteractionVolume.h.

Referenced by generatePoint().

◆ m_pointsIn

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

Definition at line 48 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: