Mantid
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
Mantid::API::ExperimentInfo Class Reference

This class is shared by a few Workspace types and holds information related to a particular experiment/run: More...

#include <ExperimentInfo.h>

Inheritance diagram for Mantid::API::ExperimentInfo:
Mantid::API::FileBackedExperimentInfo Mantid::API::IPeaksWorkspace Mantid::API::MatrixWorkspace Mantid::DataObjects::LeanElasticPeaksWorkspace Mantid::DataObjects::PeaksWorkspace AxeslessWorkspaceTester Mantid::API::HistoWorkspace Mantid::API::IEventWorkspace VariableBinThrowingTester WorkspaceTester Mantid::DataObjects::Workspace2D Mantid::DataObjects::WorkspaceSingleValue Mantid::DataObjects::EventWorkspace Mantid::Algorithms::SparseWorkspace Mantid::DataObjects::RebinnedOutput Mantid::DataObjects::SpecialWorkspace2D Mantid::DataObjects::GroupingWorkspace Mantid::DataObjects::MaskWorkspace Mantid::DataObjects::OffsetsWorkspace

Public Member Functions

virtual ExperimentInfocloneExperimentInfo () const
 Clone us. More...
 
const Geometry::ComponentInfocomponentInfo () const
 
const Geometry::ParameterMapconstInstrumentParameters () const
 Const version. More...
 
void copyExperimentInfoFrom (const ExperimentInfo *other)
 Copy everything from the given experiment object. More...
 
const Geometry::DetectorInfodetectorInfo () const
 Return a const reference to the DetectorInfo object. More...
 
 ExperimentInfo ()
 Default constructor. More...
 
 ExperimentInfo (const ExperimentInfo &)
 Copy constructor. More...
 
std::string getAvailableWorkspaceEndDate () const
 Return workspace end date as a formatted string (strftime style, as returned by Kernel::DateAdnTime) string, if available. More...
 
std::string getAvailableWorkspaceStartDate () const
 Return workspace start date as a formatted string (strftime, as returned by Types::Core::DateAndTime) string, if available. More...
 
double getEFixed (const detid_t detID) const
 Easy access to the efixed value for this run & detector ID. More...
 
double getEFixed (const std::shared_ptr< const Geometry::IDetector > &detector=std::shared_ptr< const Geometry::IDetector >{nullptr}) const
 Easy access to the efixed value for this run & optional detector. More...
 
double getEFixedForIndirect (const std::shared_ptr< const Geometry::IDetector > &detector, const std::vector< std::string > &parameterNames) const
 
double getEFixedGivenEMode (const std::shared_ptr< const Geometry::IDetector > &detector, const Kernel::DeltaEMode::Type emode) const
 Easy access to the efixed value for this run & detector. More...
 
Kernel::DeltaEMode::Type getEMode () const
 Returns the emode for this run. More...
 
Geometry::Instrument_const_sptr getInstrument () const
 Returns the parameterized instrument. More...
 
Kernel::PropertygetLog (const std::string &log) const
 Access a log for this experiment. More...
 
double getLogAsSingleValue (const std::string &log) const
 Access a single value from a log for this experiment. More...
 
int getRunNumber () const
 Utility method to get the run number. More...
 
std::string getWorkspaceStartDate () const
 Returns the start date for this experiment (or current time if no info available) More...
 
Geometry::ParameterMapinstrumentParameters ()
 Returns a modifiable set of instrument parameters. More...
 
const Geometry::ParameterMapinstrumentParameters () const
 Returns the set of parameters modifying the base instrument (const-version) More...
 
void invalidateSpectrumDefinition (const size_t index)
 Notifies the ExperimentInfo that a spectrum definition has changed. More...
 
void loadExperimentInfoNexus (const std::string &nxFilename, ::NeXus::File *file, std::string &parameterStr)
 Loads an experiment description from the open NeXus file. More...
 
void loadExperimentInfoNexus (const std::string &nxFilename, ::NeXus::File *file, std::string &parameterStr, const Mantid::Kernel::NexusHDF5Descriptor &fileInfo, const std::string &prefix)
 
void loadInstrumentInfoNexus (const std::string &nxFilename, ::NeXus::File *file)
 Load the instrument from an open NeXus file without reading any parameters. More...
 
void loadInstrumentInfoNexus (const std::string &nxFilename, ::NeXus::File *file, std::string &parameterStr)
 Load the instrument from an open NeXus file. More...
 
void loadInstrumentParametersNexus (::NeXus::File *file, std::string &parameterStr)
 Load instrument parameters from an open Nexus file in Instument group if found there. More...
 
void loadSampleAndLogInfoNexus (::NeXus::File *file)
 Load the sample and log info from an open NeXus file. More...
 
void loadSampleAndLogInfoNexus (::NeXus::File *file, const Mantid::Kernel::NexusHDF5Descriptor &fileInfo, const std::string &prefix)
 Load the sample and log info from an open NeXus file. More...
 
Geometry::ComponentInfomutableComponentInfo ()
 
Geometry::DetectorInfomutableDetectorInfo ()
 Return a non-const reference to the DetectorInfo object. More...
 
RunmutableRun ()
 Writable version of the run object. More...
 
SamplemutableSample ()
 Writable version of the sample object. More...
 
SpectrumInfomutableSpectrumInfo ()
 Return a non-const reference to the SpectrumInfo object. More...
 
ExperimentInfooperator= (const ExperimentInfo &)
 Implements the copy assignment operator. More...
 
void populateInstrumentParameters ()
 Add parameters to the instrument parameter map that are defined in instrument definition file or parameter file, which may contain parameters that require logfile data to be available. More...
 
void readParameterMap (const std::string &parameterStr)
 Populate the parameter map given a string. More...
 
const Runrun () const
 Run details object access. More...
 
const Samplesample () const
 Sample accessors. More...
 
void saveExperimentInfoNexus (::NeXus::File *file, bool saveInstrument, bool saveSample, bool saveLogs) const
 Saves this experiment description to the open NeXus file. More...
 
void saveExperimentInfoNexus (::NeXus::File *file, bool saveLegacyInstrument=true) const
 Saves this experiment description to the open NeXus file. More...
 
void setDetectorGrouping (const size_t index, const std::set< detid_t > &detIDs) const
 Sets the detector grouping for the spectrum with the given index. More...
 
void setEFixed (const detid_t detID, const double value)
 Set the efixed value for a given detector ID. More...
 
void setInstrument (const Geometry::Instrument_const_sptr &instr)
 Instrument accessors. More...
 
void setNumberOfDetectorGroups (const size_t count) const
 Sets the number of detector groups. More...
 
void setSharedRun (Kernel::cow_ptr< Run > run)
 Set the run object. Use in particular to clear run without copying old run. More...
 
Kernel::cow_ptr< RunsharedRun ()
 Return the cow ptr of the run. More...
 
const SpectrumInfospectrumInfo () const
 Return a reference to the SpectrumInfo object. More...
 
const std::string toString () const
 Returns a string description of the object. More...
 
void updateSpectrumDefinitionIfNecessary (const size_t index) const
 
virtual ~ExperimentInfo ()
 Virtual destructor. More...
 

Protected Member Functions

size_t numberOfDetectorGroups () const
 Returns the number of detector groups. More...
 
virtual void populateIfNotLoaded () const
 Called as the first operation of most public methods. More...
 
void setSpectrumDefinitions (Kernel::cow_ptr< std::vector< SpectrumDefinition > > spectrumDefinitions)
 Sets the SpectrumDefinition for all spectra. More...
 
virtual void updateCachedDetectorGrouping (const size_t index) const
 Update detector grouping for spectrum with given index. More...
 

Protected Attributes

std::shared_ptr< Geometry::ParameterMapm_parmap
 Parameters modifying the base instrument. More...
 
Geometry::Instrument_const_sptr sptr_instrument
 The base (unparametrized) instrument. More...
 

Private Member Functions

void cacheDefaultDetectorGrouping () const
 Sets up a default detector grouping. More...
 
void invalidateAllSpectrumDefinitions ()
 Sets flags for all spectrum definitions indicating that they need to be updated. More...
 
void loadEmbeddedInstrumentInfoNexus (::NeXus::File *file, std::string &instrumentName, std::string &instrumentXml)
 Attempt to load instrument embedded in Nexus file. More...
 
std::string loadInstrumentXML (const std::string &filename)
 Loads the contents of a file and returns the string The file is assumed to be an IDF, and already checked that the path is correct. More...
 
void populateWithParameter (Geometry::ParameterMap &paramMap, Geometry::ParameterMap &paramMapForPosAndRot, const std::string &name, const Geometry::XMLInstrumentParameter &paramInfo, const Run &runData)
 Fill with given instrument parameter. More...
 
void setInstumentFromXML (const std::string &nxFilename, std::string &instrumentName, std::string &instrumentXml)
 Set the instrument given the name and XML leading from IDF file if XML string is empty. More...
 

Private Attributes

std::once_flag m_defaultDetectorGroupingCached
 
std::unordered_map< detid_t, size_t > m_det2group
 Detector grouping information. More...
 
Kernel::cow_ptr< Runm_run
 The run information. More...
 
Kernel::cow_ptr< Samplem_sample
 The information on the sample environment. More...
 
std::vector< char > m_spectrumDefinitionNeedsUpdate
 
std::unique_ptr< Beamline::SpectrumInfo > m_spectrumInfo
 
std::mutex m_spectrumInfoMutex
 
std::unique_ptr< SpectrumInfom_spectrumInfoWrapper
 

Detailed Description

This class is shared by a few Workspace types and holds information related to a particular experiment/run:

Definition at line 53 of file ExperimentInfo.h.

Constructor & Destructor Documentation

◆ ExperimentInfo() [1/2]

Mantid::API::ExperimentInfo::ExperimentInfo ( )

Default constructor.

Constructor.

Definition at line 68 of file ExperimentInfo.cpp.

Referenced by cloneExperimentInfo().

◆ ~ExperimentInfo()

Mantid::API::ExperimentInfo::~ExperimentInfo ( )
virtualdefault

Virtual destructor.

◆ ExperimentInfo() [2/2]

Mantid::API::ExperimentInfo::ExperimentInfo ( const ExperimentInfo source)

Copy constructor.

Constructs the object from a copy if the input.

This leaves the new mutex unlocked.

Parameters
sourceThe source object from which to initialize

Definition at line 77 of file ExperimentInfo.cpp.

Member Function Documentation

◆ cacheDefaultDetectorGrouping()

void Mantid::API::ExperimentInfo::cacheDefaultDetectorGrouping ( ) const
private

Sets up a default detector grouping.

The purpose of this method is to work around potential issues of MDWorkspaces that do not have grouping information. In such cases a default 1:1 mapping/grouping is generated by this method. See also issue #18252.

Definition at line 877 of file ExperimentInfo.cpp.

References detectorInfo(), Mantid::Geometry::DetectorInfo::indexOf(), m_det2group, m_spectrumDefinitionNeedsUpdate, m_spectrumInfo, setNumberOfDetectorGroups(), and sptr_instrument.

Referenced by spectrumInfo().

◆ cloneExperimentInfo()

ExperimentInfo * Mantid::API::ExperimentInfo::cloneExperimentInfo ( ) const
virtual

Clone us.

Clone this ExperimentInfo class into a new one.

Reimplemented in Mantid::API::FileBackedExperimentInfo.

Definition at line 110 of file ExperimentInfo.cpp.

References ExperimentInfo().

◆ componentInfo()

const Geometry::ComponentInfo & Mantid::API::ExperimentInfo::componentInfo ( ) const

◆ constInstrumentParameters()

const Geometry::ParameterMap & Mantid::API::ExperimentInfo::constInstrumentParameters ( ) const

Const version.

Returns a const reference to the instrument parameters.

Returns
a const reference to the instrument ParameterMap.

Definition at line 232 of file ExperimentInfo.cpp.

References m_parmap, and populateIfNotLoaded().

Referenced by Mantid::WorkflowAlgorithms::SofTwoThetaTOF::clarifyAngleStep(), getEFixedForIndirect(), getEMode(), getLog(), getLogAsSingleValue(), and toString().

◆ copyExperimentInfoFrom()

void Mantid::API::ExperimentInfo::copyExperimentInfoFrom ( const ExperimentInfo other)

Copy everything from the given experiment object.

Copy the experiment info data from another ExperimentInfo instance, e.g.

a MatrixWorkspace.

Parameters
other:: the source from which to copy ExperimentInfo

Definition at line 95 of file ExperimentInfo.cpp.

References getInstrument(), m_run, m_sample, and setInstrument().

Referenced by Mantid::API::WorkspaceFactoryImpl::initializeFromParent(), operator=(), and MantidQt::MantidWidgets::MuonFitPropertyBrowser::setFitWorkspaces().

◆ detectorInfo()

const Geometry::DetectorInfo & Mantid::API::ExperimentInfo::detectorInfo ( ) const

◆ getAvailableWorkspaceEndDate()

std::string Mantid::API::ExperimentInfo::getAvailableWorkspaceEndDate ( ) const

Return workspace end date as a formatted string (strftime style, as returned by Kernel::DateAdnTime) string, if available.

If unavailable, an empty string is returned

Returns
workspace end date as a string (empty if no date available)

Definition at line 755 of file ExperimentInfo.cpp.

References Mantid::API::LogManager::endTime(), Mantid::API::g_log, Mantid::Kernel::Logger::information(), populateIfNotLoaded(), and run().

Referenced by toString().

◆ getAvailableWorkspaceStartDate()

std::string Mantid::API::ExperimentInfo::getAvailableWorkspaceStartDate ( ) const

Return workspace start date as a formatted string (strftime, as returned by Types::Core::DateAndTime) string, if available.

If unavailable, an empty string is returned

Returns
workspace start date as a string (empty if no date available)

Definition at line 738 of file ExperimentInfo.cpp.

References Mantid::API::g_log, Mantid::Kernel::Logger::information(), populateIfNotLoaded(), run(), and Mantid::API::LogManager::startTime().

Referenced by toString().

◆ getEFixed() [1/2]

double Mantid::API::ExperimentInfo::getEFixed ( const detid_t  detID) const

Easy access to the efixed value for this run & detector ID.

Parameters
detID:: The detector ID to ask for the efixed mode (ignored in Direct & Elastic mode). The detector with ID matching that given is pulled from the instrument with this method and it will throw a Exception::NotFoundError if the ID is unknown.
Returns
The current EFixed value

Definition at line 624 of file ExperimentInfo.cpp.

References getEFixed(), getInstrument(), and populateIfNotLoaded().

Referenced by export_ExperimentInfo(), getEFixed(), and Mantid::Algorithms::SparseWorkspace::SparseWorkspace().

◆ getEFixed() [2/2]

double Mantid::API::ExperimentInfo::getEFixed ( const std::shared_ptr< const Geometry::IDetector > &  detector = std::shared_ptr<const Geometry::IDetector>{nullptr}) const

Easy access to the efixed value for this run & optional detector.

Easy access to the efixed value for this run & detector.

Parameters
detector:: The detector object to ask for the efixed mode. Only required for Indirect mode
Returns
The current efixed value

Definition at line 636 of file ExperimentInfo.cpp.

References getEFixedGivenEMode(), getEMode(), and populateIfNotLoaded().

◆ getEFixedForIndirect()

double Mantid::API::ExperimentInfo::getEFixedForIndirect ( const std::shared_ptr< const Geometry::IDetector > &  detector,
const std::vector< std::string > &  parameterNames 
) const

◆ getEFixedGivenEMode()

double Mantid::API::ExperimentInfo::getEFixedGivenEMode ( const std::shared_ptr< const Geometry::IDetector > &  detector,
const Kernel::DeltaEMode::Type  emode 
) const

Easy access to the efixed value for this run & detector.

Parameters
detector:: The detector object to ask for the efixed mode. Only required for Indirect mode
emode:: enum value indicating whether elastic, direct or indirect
Returns
The current efixed value

Definition at line 678 of file ExperimentInfo.cpp.

References Mantid::Kernel::DeltaEMode::Direct, Mantid::Kernel::efixed, getEFixedForIndirect(), Mantid::API::LogManager::getPropertyValueAsType(), Mantid::Kernel::DeltaEMode::Indirect, and run().

Referenced by Mantid::API::SpectrumInfo::getDetectorValues(), and getEFixed().

◆ getEMode()

Kernel::DeltaEMode::Type Mantid::API::ExperimentInfo::getEMode ( ) const

Returns the emode for this run.

It first searchs the run logs for a "deltaE-mode" log and falls back to the instrument if one is not found. If neither exist then the run is considered Elastic.

Returns
The emode enum for the energy transfer mode of this run. Currently checks the sample log & instrument in this order

Definition at line 600 of file ExperimentInfo.cpp.

References constInstrumentParameters(), Mantid::Geometry::ParameterMap::contains(), Mantid::Kernel::DeltaEMode::Elastic, Mantid::Kernel::DeltaEMode::fromString(), Mantid::Geometry::ParameterMap::get(), Mantid::API::LogManager::getPropertyValueAsType(), populateIfNotLoaded(), run(), and sptr_instrument.

Referenced by export_ExperimentInfo(), getEFixed(), and Mantid::Algorithms::SparseWorkspace::SparseWorkspace().

◆ getInstrument()

Instrument_const_sptr Mantid::API::ExperimentInfo::getInstrument ( ) const

Returns the parameterized instrument.

Get a shared pointer to the parametrized instrument associated with this workspace.

Returns
The instrument class

Definition at line 207 of file ExperimentInfo.cpp.

References Mantid::Geometry::ParComponentFactory::createInstrument(), detectorInfo(), m_parmap, populateIfNotLoaded(), and sptr_instrument.

Referenced by Mantid::Algorithms::DetectorDiagnostic::calculateMedian(), Mantid::Algorithms::WorkspaceJoiners::checkCompatibility(), Mantid::WorkflowAlgorithms::SofTwoThetaTOF::clarifyAngleStep(), copyExperimentInfoFrom(), Mantid::DataObjects::PeaksWorkspace::createPeak(), Mantid::DataObjects::PeaksWorkspace::createPeakHKL(), Mantid::DataObjects::PeaksWorkspace::createPeakQSample(), Mantid::Algorithms::SampleLogsBehaviour::createSampleLogsMapsFromInstrumentParams(), Mantid::API::MatrixWorkspace::detectorSignedTwoTheta(), Mantid::API::MatrixWorkspace::detectorTwoTheta(), Mantid::Algorithms::MonteCarloAbsorption::doSimulation(), Mantid::Algorithms::DirectILLTubeBackground::exec(), export_ExperimentInfo(), Mantid::API::MatrixWorkspace::getDetector(), Mantid::API::MatrixWorkspace::getDetectorIDToWorkspaceIndexVector(), getEFixed(), getEFixedForIndirect(), Mantid::DataObjects::MaskWorkspace::hasInstrument(), Mantid::Algorithms::DiscusMultipleScatteringCorrection::interpolateFromSparse(), Mantid::Algorithms::MonteCarloAbsorption::interpolateFromSparse(), Mantid::DataObjects::MaskWorkspace::isMasked(), Mantid::DataHandling::LoadMuonStrategy::loadDefaultDetectorGrouping(), Mantid::Algorithms::CalculateEfficiency::maskComponent(), populateInstrumentParameters(), readParameterMap(), Mantid::API::MatrixWorkspace::rebuildSpectraMapping(), saveExperimentInfoNexus(), Mantid::DataHandling::SaveNexusProcessed::saveSpectraDetectorMapNexus(), setEFixed(), Mantid::DataHandling::SetSample::setSampleEnvironmentFromFile(), Mantid::DataHandling::SetSample::setSampleEnvironmentFromXML(), Mantid::DataHandling::SetSample::setSampleShape(), Mantid::Algorithms::SparseWorkspace::SparseWorkspace(), and toString().

◆ getLog()

Kernel::Property * Mantid::API::ExperimentInfo::getLog ( const std::string &  log) const

Access a log for this experiment.

Get an experimental log either by log name or by type, e.g.

  • temperature_log
  • chopper_speed_log The logs are first checked for one matching the given string and if that fails then the instrument is checked for a parameter of the same name and if this exists then its value is assume to be the actual log required
    Parameters
    log:: A string giving either a specific log name or instrument parameter whose value is to be retrieved
    Returns
    A pointer to the property

Definition at line 525 of file ExperimentInfo.cpp.

References constInstrumentParameters(), Mantid::API::LogManager::getProperty(), Mantid::Geometry::ParameterMap::getString(), populateIfNotLoaded(), run(), and sptr_instrument.

Referenced by Mantid::Algorithms::SampleLogsBehaviour::addPropertyForList(), Mantid::Algorithms::SampleLogsBehaviour::addPropertyForTimeSeries(), Mantid::Algorithms::SampleLogsBehaviour::setSampleMap(), and Mantid::Algorithms::SampleLogsBehaviour::updateListProperty().

◆ getLogAsSingleValue()

double Mantid::API::ExperimentInfo::getLogAsSingleValue ( const std::string &  log) const

Access a single value from a log for this experiment.

Get an experimental log as a single value either by log name or by type.

See also
getLog
Parameters
log:: A string giving either a specific log name or instrument parameter whose value is to be retrieved
Returns
A pointer to the property

Definition at line 550 of file ExperimentInfo.cpp.

References constInstrumentParameters(), Mantid::API::LogManager::getPropertyAsSingleValue(), Mantid::Geometry::ParameterMap::getString(), populateIfNotLoaded(), run(), and sptr_instrument.

Referenced by Mantid::Algorithms::SampleLogsBehaviour::setNumericValue().

◆ getRunNumber()

int Mantid::API::ExperimentInfo::getRunNumber ( ) const

◆ getWorkspaceStartDate()

std::string Mantid::API::ExperimentInfo::getWorkspaceStartDate ( ) const

Returns the start date for this experiment (or current time if no info available)

Return workspace start date as an ISO 8601 string.

If this info not stored in workspace the method returns current date. This date is used for example to retrieve the instrument file.

Returns
workspace start date as a string (current time if start date not available)

Definition at line 719 of file ExperimentInfo.cpp.

References Mantid::API::g_log, Mantid::Kernel::Logger::information(), populateIfNotLoaded(), run(), and Mantid::API::LogManager::startTime().

Referenced by setInstumentFromXML().

◆ instrumentParameters() [1/2]

Geometry::ParameterMap & Mantid::API::ExperimentInfo::instrumentParameters ( )

Returns a modifiable set of instrument parameters.

Returns a new copy of the instrument parameters.

Returns
a (new) copy of the instruments parameter map

Definition at line 216 of file ExperimentInfo.cpp.

References m_parmap, and populateIfNotLoaded().

◆ instrumentParameters() [2/2]

const Geometry::ParameterMap & Mantid::API::ExperimentInfo::instrumentParameters ( ) const

Returns the set of parameters modifying the base instrument (const-version)

Returns a const reference to the instrument parameters.

Returns
a const reference to the instrument ParameterMap.

Definition at line 224 of file ExperimentInfo.cpp.

References m_parmap, and populateIfNotLoaded().

Referenced by populateInstrumentParameters(), readParameterMap(), setEFixed(), and Mantid::Algorithms::SparseWorkspace::SparseWorkspace().

◆ invalidateAllSpectrumDefinitions()

void Mantid::API::ExperimentInfo::invalidateAllSpectrumDefinitions ( )
private

Sets flags for all spectrum definitions indicating that they need to be updated.

Definition at line 896 of file ExperimentInfo.cpp.

References m_spectrumDefinitionNeedsUpdate.

Referenced by setInstrument(), and setSpectrumDefinitions().

◆ invalidateSpectrumDefinition()

void Mantid::API::ExperimentInfo::invalidateSpectrumDefinition ( const size_t  index)

Notifies the ExperimentInfo that a spectrum definition has changed.

ExperimentInfo will rebuild its spectrum definitions before the next use. In general it should not be necessary to use this method: ISpectrum will take care of this when its detector IDs are modified.

Definition at line 861 of file ExperimentInfo.cpp.

References index, and m_spectrumDefinitionNeedsUpdate.

Referenced by Mantid::API::ISpectrum::invalidateSpectrumDefinition().

◆ loadEmbeddedInstrumentInfoNexus()

void Mantid::API::ExperimentInfo::loadEmbeddedInstrumentInfoNexus ( ::NeXus::File *  file,
std::string &  instrumentName,
std::string &  instrumentXml 
)
private

Attempt to load instrument embedded in Nexus file.

Attempt to load an IDF embedded in the Nexus file.

*file must have instrument group open.

Parameters
file:: open NeXus file with instrument group open
[out]instrumentName:: name of instrument
[out]instrumentXml:: XML string of embedded instrument definition or empty if not found

Definition at line 1060 of file ExperimentInfo.cpp.

References Mantid::Kernel::Logger::debug(), and Mantid::API::g_log.

Referenced by loadInstrumentInfoNexus().

◆ loadExperimentInfoNexus() [1/2]

void Mantid::API::ExperimentInfo::loadExperimentInfoNexus ( const std::string &  nxFilename,
::NeXus::File *  file,
std::string &  parameterStr 
)

Loads an experiment description from the open NeXus file.

Load the object from an open NeXus file.

Parameters
file:: open NeXus file
nxFilename:: the filename of the nexus file
[out]parameterStr:: special string for all the parameters. Feed that to ExperimentInfo::readParameterMap() after the instrument is done.
Exceptions
Exception::NotFoundErrorIf instrument definition is not in the nexus file and cannot be loaded from the IDF.

Definition at line 989 of file ExperimentInfo.cpp.

References loadInstrumentInfoNexus(), and loadSampleAndLogInfoNexus().

◆ loadExperimentInfoNexus() [2/2]

void Mantid::API::ExperimentInfo::loadExperimentInfoNexus ( const std::string &  nxFilename,
::NeXus::File *  file,
std::string &  parameterStr,
const Mantid::Kernel::NexusHDF5Descriptor fileInfo,
const std::string &  prefix 
)

◆ loadInstrumentInfoNexus() [1/2]

void Mantid::API::ExperimentInfo::loadInstrumentInfoNexus ( const std::string &  nxFilename,
::NeXus::File *  file 
)

Load the instrument from an open NeXus file without reading any parameters.

Load the instrument from an open NeXus file without reading any parameters (yet).

Parameters
nxFilename:: the filename of the nexus file
file:: open NeXus file instrument is done.
Exceptions
Exception::NotFoundErrorIf instrument definition is not in the nexus file and cannot be loaded from the IDF.

Definition at line 1037 of file ExperimentInfo.cpp.

References loadEmbeddedInstrumentInfoNexus(), and setInstumentFromXML().

◆ loadInstrumentInfoNexus() [2/2]

void Mantid::API::ExperimentInfo::loadInstrumentInfoNexus ( const std::string &  nxFilename,
::NeXus::File *  file,
std::string &  parameterStr 
)

Load the instrument from an open NeXus file.

Parameters
nxFilename:: the filename of the nexus file
file:: open NeXus file
[out]parameterStr:: special string for all the parameters. Feed that to ExperimentInfo::readParameterMap() after the instrument is done.
Exceptions
Exception::NotFoundErrorIf instrument definition is not in the nexus file and cannot be loaded from the IDF.

Definition at line 1007 of file ExperimentInfo.cpp.

References loadEmbeddedInstrumentInfoNexus(), loadInstrumentParametersNexus(), and setInstumentFromXML().

Referenced by loadExperimentInfoNexus().

◆ loadInstrumentParametersNexus()

void Mantid::API::ExperimentInfo::loadInstrumentParametersNexus ( ::NeXus::File *  file,
std::string &  parameterStr 
)

Load instrument parameters from an open Nexus file in Instument group if found there.

Load the instrument parameters from an open NeXus file if found there.

Parameters
file:: open NeXus file in its Instrument group
[out]parameterStr:: special string for all the parameters. Feed that to ExperimentInfo::readParameterMap() after the instrument is done.

Definition at line 1154 of file ExperimentInfo.cpp.

References Mantid::Kernel::Logger::debug(), Mantid::API::g_log, and Mantid::Kernel::Logger::information().

Referenced by loadInstrumentInfoNexus().

◆ loadInstrumentXML()

std::string Mantid::API::ExperimentInfo::loadInstrumentXML ( const std::string &  filename)
private

Loads the contents of a file and returns the string The file is assumed to be an IDF, and already checked that the path is correct.

Parameters
filename:: the path to the file

Definition at line 1138 of file ExperimentInfo.cpp.

References Mantid::Kernel::Logger::debug(), Mantid::Kernel::Logger::error(), Mantid::API::g_log, and Mantid::Kernel::Strings::loadFile().

Referenced by setInstumentFromXML().

◆ loadSampleAndLogInfoNexus() [1/2]

void Mantid::API::ExperimentInfo::loadSampleAndLogInfoNexus ( ::NeXus::File *  file)

Load the sample and log info from an open NeXus file.

Parameters
file:: open NeXus file

Definition at line 953 of file ExperimentInfo.cpp.

References Mantid::API::Sample::loadNexus(), Mantid::API::Run::loadNexus(), mutableRun(), and mutableSample().

◆ loadSampleAndLogInfoNexus() [2/2]

void Mantid::API::ExperimentInfo::loadSampleAndLogInfoNexus ( ::NeXus::File *  file,
const Mantid::Kernel::NexusHDF5Descriptor fileInfo,
const std::string &  prefix 
)

Load the sample and log info from an open NeXus file.

Overload that uses NexusHDF5Descriptor for faster metadata lookup

Parameters
filecurrently opened NeXus file
fileInfodescriptor with in-memory index with all entries
prefixindicates current group location in file (absolute name)
file:: open NeXus file

Definition at line 934 of file ExperimentInfo.cpp.

References Mantid::API::Sample::loadNexus(), Mantid::API::Run::loadNexus(), mutableRun(), and mutableSample().

Referenced by loadExperimentInfoNexus().

◆ mutableComponentInfo()

ComponentInfo & Mantid::API::ExperimentInfo::mutableComponentInfo ( )

Definition at line 840 of file ExperimentInfo.cpp.

References m_parmap.

Referenced by populateInstrumentParameters(), and readParameterMap().

◆ mutableDetectorInfo()

Geometry::DetectorInfo & Mantid::API::ExperimentInfo::mutableDetectorInfo ( )

Return a non-const reference to the DetectorInfo object.

Definition at line 779 of file ExperimentInfo.cpp.

References m_parmap, and populateIfNotLoaded().

Referenced by Mantid::DataObjects::MaskWorkspace::clearMask(), populateWithParameter(), and readParameterMap().

◆ mutableRun()

Run & Mantid::API::ExperimentInfo::mutableRun ( )

◆ mutableSample()

Sample & Mantid::API::ExperimentInfo::mutableSample ( )

Writable version of the sample object.

Get a reference to the Sample associated with this workspace.

This non-const method will copy the sample if it is shared between more than one workspace, and the reference returned will be to the copy.

Returns
reference to sample object

Definition at line 484 of file ExperimentInfo.cpp.

References m_sample, and populateIfNotLoaded().

Referenced by Mantid::Crystal::ClearUB::clearSingleExperimentInfo(), export_ExperimentInfo(), loadSampleAndLogInfoNexus(), Mantid::DataHandling::SetSample::setSampleEnvironmentFromFile(), Mantid::DataHandling::SetSample::setSampleEnvironmentFromXML(), Mantid::DataHandling::SetSample::setSampleShape(), and Mantid::DataHandling::CreateSampleShape::setSampleShape().

◆ mutableSpectrumInfo()

SpectrumInfo & Mantid::API::ExperimentInfo::mutableSpectrumInfo ( )

Return a non-const reference to the SpectrumInfo object.

Not thread safe.

Definition at line 834 of file ExperimentInfo.cpp.

References spectrumInfo().

Referenced by Mantid::Algorithms::CalculateEfficiency::maskComponent().

◆ numberOfDetectorGroups()

size_t Mantid::API::ExperimentInfo::numberOfDetectorGroups ( ) const
protected

Returns the number of detector groups.

For MatrixWorkspace this is equal to getNumberHistograms() (after initialization).

Definition at line 438 of file ExperimentInfo.cpp.

References m_spectrumDefinitionNeedsUpdate.

Referenced by Mantid::DataObjects::EventWorkspace::init(), Mantid::DataObjects::Workspace2D::init(), and AxeslessWorkspaceTester::init().

◆ operator=()

ExperimentInfo & Mantid::API::ExperimentInfo::operator= ( const ExperimentInfo source)

Implements the copy assignment operator.

Definition at line 82 of file ExperimentInfo.cpp.

References copyExperimentInfoFrom(), setSpectrumDefinitions(), Mantid::API::SpectrumInfo::sharedSpectrumDefinitions(), and spectrumInfo().

◆ populateIfNotLoaded()

void Mantid::API::ExperimentInfo::populateIfNotLoaded ( ) const
protectedvirtual

◆ populateInstrumentParameters()

void Mantid::API::ExperimentInfo::populateInstrumentParameters ( )

Add parameters to the instrument parameter map that are defined in instrument definition file or parameter file, which may contain parameters that require logfile data to be available.

Logs must be loaded before running this method.

Definition at line 336 of file ExperimentInfo.cpp.

References Mantid::Geometry::ParameterMap::addV3D(), componentInfo(), Mantid::API::g_log, getInstrument(), Mantid::Kernel::Logger::information(), instrumentParameters(), mutableComponentInfo(), Mantid::Geometry::ComponentInfo::name(), populateIfNotLoaded(), populateWithParameter(), Mantid::Geometry::ParameterMap::pos(), run(), Mantid::Kernel::V3D::spherical(), and value.

◆ populateWithParameter()

void Mantid::API::ExperimentInfo::populateWithParameter ( Geometry::ParameterMap paramMap,
Geometry::ParameterMap paramMapForPosAndRot,
const std::string &  name,
const Geometry::XMLInstrumentParameter paramInfo,
const Run runData 
)
private

Fill with given instrument parameter.

Fill map with instrument parameter first set in xml file Where this is appropriate a parameter value is dependent on values in a log entry.

Parameters
paramMapMap to populate (except for position and rotation parameters)
paramMapForPosAndRotMap to populate with positions and rotations
nameThe name of the parameter
paramInfoA reference to the object describing this parameter
runDataA reference to the run object, which stores log value entries

Definition at line 1275 of file ExperimentInfo.cpp.

References Mantid::Geometry::ParameterMap::add(), Mantid::Geometry::ParameterMap::addBool(), Mantid::Geometry::ParameterMap::addDouble(), Mantid::Geometry::ParameterMap::addInt(), Mantid::Geometry::ParameterMap::addPositionCoordinate(), Mantid::Geometry::ParameterMap::addRotationParam(), Mantid::Geometry::ParameterMap::addString(), componentInfo(), Mantid::Geometry::IComponent::getComponentID(), Mantid::Geometry::ComponentInfo::indexOf(), Mantid::Geometry::XMLInstrumentParameter::m_component, Mantid::Geometry::XMLInstrumentParameter::m_constraint, Mantid::Geometry::XMLInstrumentParameter::m_description, Mantid::Geometry::XMLInstrumentParameter::m_fittingFunction, Mantid::Geometry::XMLInstrumentParameter::m_formula, Mantid::Geometry::XMLInstrumentParameter::m_formulaUnit, Mantid::Geometry::XMLInstrumentParameter::m_interpolation, Mantid::Geometry::XMLInstrumentParameter::m_penaltyFactor, Mantid::Geometry::XMLInstrumentParameter::m_resultUnit, Mantid::Geometry::XMLInstrumentParameter::m_tie, Mantid::Geometry::XMLInstrumentParameter::m_type, Mantid::Geometry::XMLInstrumentParameter::m_value, Mantid::Geometry::XMLInstrumentParameter::m_visible, mutableDetectorInfo(), Mantid::Geometry::DetectorInfo::setMasked(), and value.

Referenced by populateInstrumentParameters().

◆ readParameterMap()

void Mantid::API::ExperimentInfo::readParameterMap ( const std::string &  parameterStr)

◆ run()

const Run & Mantid::API::ExperimentInfo::run ( ) const

Run details object access.

Get a constant reference to the Run object associated with this workspace.

Returns
const reference to run object

Definition at line 492 of file ExperimentInfo.cpp.

References m_run, and populateIfNotLoaded().

Referenced by Mantid::Algorithms::SampleLogsBehaviour::addPropertyForTimeSeries(), Mantid::MDAlgorithms::MDNorm::calQTransform(), Mantid::Algorithms::GetEiMonDet3::computeTOF(), Mantid::DataObjects::PeaksWorkspace::createPeak(), Mantid::DataObjects::LeanElasticPeaksWorkspace::createPeakHKL(), Mantid::DataObjects::PeaksWorkspace::createPeakHKL(), Mantid::DataObjects::LeanElasticPeaksWorkspace::createPeakQSample(), Mantid::DataObjects::PeaksWorkspace::createPeakQSample(), export_ExperimentInfo(), getAvailableWorkspaceEndDate(), getAvailableWorkspaceStartDate(), Mantid::Algorithms::ConvertSpectrumAxis2::getEfixed(), getEFixedGivenEMode(), getEMode(), Mantid::API::MatrixWorkspace::getFirstPulseTime(), Mantid::API::MatrixWorkspace::getLastPulseTime(), getLog(), getLogAsSingleValue(), Mantid::DataObjects::LeanElasticPeaksWorkspace::getLogs(), Mantid::DataObjects::PeaksWorkspace::getLogs(), MantidQt::MantidWidgets::LogValueFinder::getLogValue(), Mantid::API::MatrixWorkspace::getMemorySize(), Mantid::DataObjects::EventWorkspace::getMemorySize(), Mantid::Algorithms::Qxy::getQminFromWs(), getRunNumber(), Mantid::API::MatrixWorkspace::getTitle(), getWorkspaceStartDate(), Mantid::DataObjects::LeanElasticPeaksWorkspace::hasIntegratedPeaks(), Mantid::DataObjects::PeaksWorkspace::hasIntegratedPeaks(), Mantid::DataHandling::LoadMuonStrategy::loadDefaultDetectorGrouping(), Mantid::DataObjects::PeaksWorkspace::peakInfo(), populateInstrumentParameters(), saveExperimentInfoNexus(), Mantid::DataHandling::SetSample::setSampleShape(), setSharedRun(), Mantid::API::MatrixWorkspace::setTitle(), Mantid::Algorithms::SampleLogsBehaviour::updateListProperty(), and Mantid::Algorithms::SampleLogsBehaviour::updateTimeSeriesProperty().

◆ sample()

const Sample & Mantid::API::ExperimentInfo::sample ( ) const

◆ saveExperimentInfoNexus() [1/2]

void Mantid::API::ExperimentInfo::saveExperimentInfoNexus ( ::NeXus::File *  file,
bool  saveInstrument,
bool  saveSample,
bool  saveLogs 
) const

Saves this experiment description to the open NeXus file.

Save the object to an open NeXus file.

Parameters
file:: open NeXus file
saveInstrument:: option to save Instrument
saveSample:: option to save Sample
saveLogs:: option to save Logs

Definition at line 919 of file ExperimentInfo.cpp.

References getInstrument(), run(), sample(), Mantid::API::Sample::saveNexus(), and Mantid::API::Run::saveNexus().

◆ saveExperimentInfoNexus() [2/2]

void Mantid::API::ExperimentInfo::saveExperimentInfoNexus ( ::NeXus::File *  file,
bool  saveLegacyInstrument = true 
) const

Saves this experiment description to the open NeXus file.

Save the object to an open NeXus file.

Parameters
file:: open NeXus file
saveLegacyInstrument: defaults to true, otherwise not in file output

Definition at line 904 of file ExperimentInfo.cpp.

References getInstrument(), run(), sample(), Mantid::API::Sample::saveNexus(), and Mantid::API::Run::saveNexus().

◆ setDetectorGrouping()

void Mantid::API::ExperimentInfo::setDetectorGrouping ( const size_t  index,
const std::set< detid_t > &  detIDs 
) const

Sets the detector grouping for the spectrum with the given index.

This method should not need to be called explicitly. Groupings are updated automatically when modifying detector IDs in a workspace (via ISpectrum).

Definition at line 444 of file ExperimentInfo.cpp.

References detectorInfo(), index, Mantid::Geometry::DetectorInfo::indexOf(), m_spectrumDefinitionNeedsUpdate, and m_spectrumInfo.

Referenced by Mantid::API::MatrixWorkspace::updateCachedDetectorGrouping().

◆ setEFixed()

void Mantid::API::ExperimentInfo::setEFixed ( const detid_t  detID,
const double  value 
)

Set the efixed value for a given detector ID.

Definition at line 704 of file ExperimentInfo.cpp.

References getInstrument(), instrumentParameters(), populateIfNotLoaded(), and value.

Referenced by export_ExperimentInfo(), and Mantid::Algorithms::SparseWorkspace::SparseWorkspace().

◆ setInstrument()

void Mantid::API::ExperimentInfo::setInstrument ( const Geometry::Instrument_const_sptr instr)

Instrument accessors.

Set the instrument.

Parameters
instr:: Shared pointer to an instrument.

Definition at line 180 of file ExperimentInfo.cpp.

References invalidateAllSpectrumDefinitions(), m_parmap, m_spectrumInfoWrapper, and sptr_instrument.

Referenced by copyExperimentInfoFrom(), setInstumentFromXML(), Mantid::Crystal::CentroidPeaks::sizeBanks(), and Mantid::Algorithms::SparseWorkspace::SparseWorkspace().

◆ setInstumentFromXML()

void Mantid::API::ExperimentInfo::setInstumentFromXML ( const std::string &  nxFilename,
std::string &  instrumentName,
std::string &  instrumentXml 
)
private

Set the instrument given the name and XML leading from IDF file if XML string is empty.

Set the instrument given its name and definition in XML If the XML string is empty the definition is loaded from the IDF file specified by the name.

Parameters
nxFilename:: the filename of the nexus file, needed to check whether instrument already exists in ADS.
instrumentName:: name of instrument
instrumentXml:: XML string of instrument or empty to indicate load of instrument definition file

Definition at line 1083 of file ExperimentInfo.cpp.

References Mantid::Kernel::Logger::debug(), Mantid::API::g_log, Mantid::API::InstrumentFileFinder::getInstrumentFilename(), Mantid::Geometry::InstrumentDefinitionParser::getMangledName(), getWorkspaceStartDate(), Mantid::Kernel::SingletonHolder< T >::Instance(), loadInstrumentXML(), Mantid::Geometry::InstrumentDefinitionParser::parseXML(), setInstrument(), and Mantid::Kernel::Strings::strip().

Referenced by loadInstrumentInfoNexus().

◆ setNumberOfDetectorGroups()

void Mantid::API::ExperimentInfo::setNumberOfDetectorGroups ( const size_t  count) const

Sets the number of detector groups.

This method should not need to be called explicitly. The number of detector groups will be set either when initializing a MatrixWorkspace, or by calling cacheDetectorGroupings for an ExperimentInfo stored in an MDWorkspace.

Definition at line 425 of file ExperimentInfo.cpp.

References count, m_spectrumDefinitionNeedsUpdate, m_spectrumInfo, m_spectrumInfoWrapper, and populateIfNotLoaded().

Referenced by cacheDefaultDetectorGrouping(), Mantid::API::MatrixWorkspace::initialize(), Mantid::DataObjects::LeanElasticPeaksWorkspace::LeanElasticPeaksWorkspace(), and Mantid::DataObjects::PeaksWorkspace::PeaksWorkspace().

◆ setSharedRun()

void Mantid::API::ExperimentInfo::setSharedRun ( Kernel::cow_ptr< Run run)

Set the run object. Use in particular to clear run without copying old run.

Definition at line 508 of file ExperimentInfo.cpp.

References m_run, and run().

◆ setSpectrumDefinitions()

void Mantid::API::ExperimentInfo::setSpectrumDefinitions ( Kernel::cow_ptr< std::vector< SpectrumDefinition > >  spectrumDefinitions)
protected

◆ sharedRun()

Kernel::cow_ptr< Run > Mantid::API::ExperimentInfo::sharedRun ( )

Return the cow ptr of the run.

Definition at line 511 of file ExperimentInfo.cpp.

References m_run.

◆ spectrumInfo()

const SpectrumInfo & Mantid::API::ExperimentInfo::spectrumInfo ( ) const

Return a reference to the SpectrumInfo object.

Any modifications of the instrument or instrument parameters will invalidate this reference.

Definition at line 789 of file ExperimentInfo.cpp.

References cacheDefaultDetectorGrouping(), detectorInfo(), m_parmap, m_spectrumDefinitionNeedsUpdate, m_spectrumInfo, m_spectrumInfoMutex, m_spectrumInfoWrapper, populateIfNotLoaded(), and updateSpectrumDefinitionIfNecessary().

Referenced by Mantid::Algorithms::SparseWorkspace::bilinearInterpolateFromDetectorGrid(), Mantid::Algorithms::DetectorDiagnostic::calculateMedian(), Mantid::Algorithms::MonteCarloAbsorption::doSimulation(), Mantid::Algorithms::DiscusMultipleScatteringCorrection::exec(), Mantid::Algorithms::WorkspaceJoiners::execEvent(), Mantid::Algorithms::WorkspaceJoiners::execWS2D(), export_ExperimentInfo(), Mantid::Algorithms::SparseWorkspace::extremeAngles(), Mantid::API::MatrixWorkspace::getDetectorIDToWorkspaceIndexMap(), Mantid::DataObjects::EventWorkspace::getTimeAtSampleMax(), Mantid::DataObjects::EventWorkspace::getTimeAtSampleMin(), Mantid::Algorithms::DiscusMultipleScatteringCorrection::getXMinMax(), Mantid::API::MatrixWorkspace::indexInfo(), Mantid::Algorithms::SparseWorkspace::interpolateFromDetectorGrid(), Mantid::Algorithms::DiscusMultipleScatteringCorrection::interpolateFromSparse(), Mantid::Algorithms::MonteCarloAbsorption::interpolateFromSparse(), Mantid::Algorithms::RemoveMaskedSpectra::makeIndexList(), Mantid::Algorithms::GetEiMonDet3::minimumTOF(), mutableSpectrumInfo(), operator=(), and Mantid::Algorithms::SofQCommon::qBinHintsDirect().

◆ toString()

const std::string Mantid::API::ExperimentInfo::toString ( ) const

◆ updateCachedDetectorGrouping()

void Mantid::API::ExperimentInfo::updateCachedDetectorGrouping ( const size_t  index) const
protectedvirtual

Update detector grouping for spectrum with given index.

This method is called when the detector grouping stored in SpectrumDefinition at index in Beamline::SpectrumInfo is not initialized or outdated. The implementation throws, since no grouping information for update is available when grouping comes from a call to cacheDetectorGroupings. This method is overridden in MatrixWorkspace.

Reimplemented in Mantid::API::MatrixWorkspace.

Definition at line 465 of file ExperimentInfo.cpp.

Referenced by updateSpectrumDefinitionIfNecessary().

◆ updateSpectrumDefinitionIfNecessary()

void Mantid::API::ExperimentInfo::updateSpectrumDefinitionIfNecessary ( const size_t  index) const

Member Data Documentation

◆ m_defaultDetectorGroupingCached

std::once_flag Mantid::API::ExperimentInfo::m_defaultDetectorGroupingCached
mutableprivate

Definition at line 215 of file ExperimentInfo.h.

◆ m_det2group

std::unordered_map<detid_t, size_t> Mantid::API::ExperimentInfo::m_det2group
mutableprivate

Detector grouping information.

Definition at line 212 of file ExperimentInfo.h.

Referenced by cacheDefaultDetectorGrouping().

◆ m_parmap

std::shared_ptr<Geometry::ParameterMap> Mantid::API::ExperimentInfo::m_parmap
protected

◆ m_run

Kernel::cow_ptr<Run> Mantid::API::ExperimentInfo::m_run
private

The run information.

Definition at line 209 of file ExperimentInfo.h.

Referenced by copyExperimentInfoFrom(), getRunNumber(), mutableRun(), run(), setSharedRun(), and sharedRun().

◆ m_sample

Kernel::cow_ptr<Sample> Mantid::API::ExperimentInfo::m_sample
private

The information on the sample environment.

Definition at line 207 of file ExperimentInfo.h.

Referenced by copyExperimentInfoFrom(), mutableSample(), and sample().

◆ m_spectrumDefinitionNeedsUpdate

std::vector<char> Mantid::API::ExperimentInfo::m_spectrumDefinitionNeedsUpdate
mutableprivate

◆ m_spectrumInfo

std::unique_ptr<Beamline::SpectrumInfo> Mantid::API::ExperimentInfo::m_spectrumInfo
mutableprivate

◆ m_spectrumInfoMutex

std::mutex Mantid::API::ExperimentInfo::m_spectrumInfoMutex
mutableprivate

Definition at line 219 of file ExperimentInfo.h.

Referenced by spectrumInfo().

◆ m_spectrumInfoWrapper

std::unique_ptr<SpectrumInfo> Mantid::API::ExperimentInfo::m_spectrumInfoWrapper
mutableprivate

◆ sptr_instrument

Geometry::Instrument_const_sptr Mantid::API::ExperimentInfo::sptr_instrument
protected

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