Mantid
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Mantid::DataObjects::FakeMD Class Reference

Provides a helper class to add fake data to an MD workspace. More...

#include <FakeMD.h>

Public Member Functions

 FakeMD (const std::vector< double > &uniformParams, const std::vector< double > &peakParams, const std::vector< double > &ellipsoidParams, const int randomSeed, const bool randomizeSignal)
 Constructor. More...
 
void fill (const API::IMDEventWorkspace_sptr &workspace)
 Add the fake data to the given workspace. More...
 

Private Member Functions

template<typename MDE , size_t nd>
void addFakeEllipsoid (typename MDEventWorkspace< MDE, nd >::sptr ws)
 Function that adds a fake single-crystal peak with a multivariate normal distribution (an ellipsoid) around a central point (x1,...x_N). More...
 
template<typename MDE , size_t nd>
void addFakePeak (typename MDEventWorkspace< MDE, nd >::sptr ws)
 Function generates random uniformly distributed events within an nD-sphere to simulate a single-crystal peak and adds it to the workspace. More...
 
template<typename MDE , size_t nd>
void addFakeRandomData (const std::vector< double > &params, typename MDEventWorkspace< MDE, nd >::sptr ws)
 Add fake randomized data to the workspace. More...
 
template<typename MDE , size_t nd>
void addFakeRegularData (const std::vector< double > &params, typename MDEventWorkspace< MDE, nd >::sptr ws)
 
template<typename MDE , size_t nd>
void addFakeUniformData (typename MDEventWorkspace< MDE, nd >::sptr ws)
 Function makes up a fake uniform event data and adds it to the workspace. More...
 
detid_t pickDetectorID ()
 Pick a detector ID for a particular event. More...
 
void setupDetectorCache (const API::IMDEventWorkspace &workspace)
 Setup a detector cache for randomly picking IDs from the first instrument in the ExperimentInfo list. More...
 

Private Attributes

std::vector< detid_t > m_detIDs
 
std::vector< double > m_ellipsoidParams
 
std::vector< double > m_peakParams
 
std::mt19937 m_randGen
 
const bool m_randomizeSignal
 
const int m_randomSeed
 
Kernel::uniform_int_distribution< size_t > m_uniformDist
 
std::vector< double > m_uniformParams
 

Detailed Description

Provides a helper class to add fake data to an MD workspace.

Definition at line 22 of file FakeMD.h.

Constructor & Destructor Documentation

◆ FakeMD()

Mantid::DataObjects::FakeMD::FakeMD ( const std::vector< double > &  uniformParams,
const std::vector< double > &  peakParams,
const std::vector< double > &  ellipsoidParams,
const int  randomSeed,
const bool  randomizeSignal 
)

Constructor.

Parameters
uniformParamsAdd a uniform, randomized distribution of events
peakParamsAdd a peak with a normal distribution around a central point
ellipsoidParamsAdd a multivariate gaussian peak (ellipsoid)
randomSeedSeed int for the random number generator
randomizeSignalIf true, the events' signal and error values will be " randomized around 1.0+-0.5

Definition at line 38 of file FakeMD.cpp.

Member Function Documentation

◆ addFakeEllipsoid()

template<typename MDE , size_t nd>
void Mantid::DataObjects::FakeMD::addFakeEllipsoid ( typename MDEventWorkspace< MDE, nd >::sptr  ws)
private

Function that adds a fake single-crystal peak with a multivariate normal distribution (an ellipsoid) around a central point (x1,...x_N).

The ellipsoid is defined by N eigenvectors with N elements and N eigenvalues which correpsond to the variance along the principal axes. The peak is generated from an affine transformation of a uniform normal distirbution of variance = 1.

Parameters
wsA pointer to the workspace that receives the events

Definition at line 161 of file FakeMD.cpp.

References Mantid::Geometry::d, Mantid::Kernel::Matrix< T >::getVector(), Mantid::Kernel::Matrix< T >::Invert(), m_ellipsoidParams, m_randomSeed, n, Mantid::DataHandling::numEvents(), pickDetectorID(), Mantid::DataObjects::MDEventWorkspace::refreshCache(), Mantid::DataObjects::MDEventWorkspace::splitAllIfNeeded(), Mantid::DataObjects::MDEventWorkspace::splitBox(), tmp, and tp.

Referenced by fill().

◆ addFakePeak()

template<typename MDE , size_t nd>
void Mantid::DataObjects::FakeMD::addFakePeak ( typename MDEventWorkspace< MDE, nd >::sptr  ws)
private

Function generates random uniformly distributed events within an nD-sphere to simulate a single-crystal peak and adds it to the workspace.

Parameters
wsA pointer to the workspace that receives the events

Definition at line 85 of file FakeMD.cpp.

References Mantid::Geometry::d, m_peakParams, m_randomizeSignal, m_randomSeed, pickDetectorID(), radius, Mantid::DataObjects::MDEventWorkspace::refreshCache(), Mantid::DataObjects::MDEventWorkspace::splitAllIfNeeded(), Mantid::DataObjects::MDEventWorkspace::splitBox(), and tp.

Referenced by fill().

◆ addFakeRandomData()

template<typename MDE , size_t nd>
void Mantid::DataObjects::FakeMD::addFakeRandomData ( const std::vector< double > &  params,
typename MDEventWorkspace< MDE, nd >::sptr  ws 
)
private

Add fake randomized data to the workspace.

Parameters
paramsA reference to the parameter vector
wsThe workspace to hold the data

Definition at line 325 of file FakeMD.cpp.

References Mantid::Geometry::d, m_randomizeSignal, m_randomSeed, and pickDetectorID().

◆ addFakeRegularData()

template<typename MDE , size_t nd>
void Mantid::DataObjects::FakeMD::addFakeRegularData ( const std::vector< double > &  params,
typename MDEventWorkspace< MDE, nd >::sptr  ws 
)
private

◆ addFakeUniformData()

template<typename MDE , size_t nd>
void Mantid::DataObjects::FakeMD::addFakeUniformData ( typename MDEventWorkspace< MDE, nd >::sptr  ws)
private

◆ fill()

void Mantid::DataObjects::FakeMD::fill ( const API::IMDEventWorkspace_sptr workspace)

Add the fake data to the given workspace.

Parameters
workspaceA pointer to MD event workspace to fill using the object parameters

Definition at line 53 of file FakeMD.cpp.

References addFakeEllipsoid(), addFakePeak(), addFakeUniformData(), CALL_MDEVENT_FUNCTION, setupDetectorCache(), and workspace.

Referenced by Mantid::MDAlgorithms::FakeMDEventData::exec(), and Mantid::DataObjects::MDEventsTestHelper::makeFakeMDEventWorkspace().

◆ pickDetectorID()

detid_t Mantid::DataObjects::FakeMD::pickDetectorID ( )
private

Pick a detector ID for a particular event.

Returns
A detector ID randomly selected from the instrument

Definition at line 439 of file FakeMD.cpp.

References m_detIDs, m_randGen, and m_uniformDist.

Referenced by addFakeEllipsoid(), addFakePeak(), addFakeRandomData(), and addFakeRegularData().

◆ setupDetectorCache()

void Mantid::DataObjects::FakeMD::setupDetectorCache ( const API::IMDEventWorkspace workspace)
private

Setup a detector cache for randomly picking IDs from the first instrument in the ExperimentInfo list.

Parameters
workspaceThe input workspace

Definition at line 69 of file FakeMD.cpp.

References m_detIDs, m_uniformDist, and workspace.

Referenced by fill().

Member Data Documentation

◆ m_detIDs

std::vector<detid_t> Mantid::DataObjects::FakeMD::m_detIDs
mutableprivate

Definition at line 49 of file FakeMD.h.

Referenced by pickDetectorID(), and setupDetectorCache().

◆ m_ellipsoidParams

std::vector<double> Mantid::DataObjects::FakeMD::m_ellipsoidParams
private

Definition at line 46 of file FakeMD.h.

Referenced by addFakeEllipsoid().

◆ m_peakParams

std::vector<double> Mantid::DataObjects::FakeMD::m_peakParams
private

Definition at line 45 of file FakeMD.h.

Referenced by addFakePeak().

◆ m_randGen

std::mt19937 Mantid::DataObjects::FakeMD::m_randGen
private

Definition at line 50 of file FakeMD.h.

Referenced by pickDetectorID().

◆ m_randomizeSignal

const bool Mantid::DataObjects::FakeMD::m_randomizeSignal
private

Definition at line 48 of file FakeMD.h.

Referenced by addFakePeak(), and addFakeRandomData().

◆ m_randomSeed

const int Mantid::DataObjects::FakeMD::m_randomSeed
private

Definition at line 47 of file FakeMD.h.

Referenced by addFakeEllipsoid(), addFakePeak(), and addFakeRandomData().

◆ m_uniformDist

Kernel::uniform_int_distribution<size_t> Mantid::DataObjects::FakeMD::m_uniformDist
private

Definition at line 51 of file FakeMD.h.

Referenced by pickDetectorID(), and setupDetectorCache().

◆ m_uniformParams

std::vector<double> Mantid::DataObjects::FakeMD::m_uniformParams
private

Definition at line 44 of file FakeMD.h.

Referenced by addFakeUniformData().


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