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

The class responsible for saving/loading MD boxes structure to/from HDD and for flattening/restoring the interconnected box structure (customized linked list) of MD workspace. More...

#include <MDBoxFlatTree.h>

Public Member Functions

void exportExperiment (Mantid::API::IMDEventWorkspace_sptr &targetWS)
 Export existing experiment info defined in the box structure to target workspace (or other experiment info) More...
 
const std::string & getBCXMLdescr () const
 
std::vector< API::IMDNode * > & getBoxes ()
 
const std::vector< int > & getBoxType () const
 
std::vector< uint64_t > & getEventIndex ()
 
size_t getNBoxes () const
 
int getNDims () const
 Return number of dimensions this class is initiated for (or not initiated if -1) More...
 
std::vector< double > & getSigErrData ()
 
void initFlatStructure (const API::IMDEventWorkspace_sptr &pws, const std::string &fileName)
 convert MDWS box structure into flat structure used for saving/loading on hdd More...
 
void loadBoxStructure (const std::string &fileName, int &nDim, const std::string &EventType, bool onlyEventInfo=false, bool restoreExperimentInfo=false)
 load box structure from the file, defined by file name More...
 
 MDBoxFlatTree ()
 The constructor of the flat box tree
More...
 
uint64_t restoreBoxTree (std::vector< API::IMDNode * > &Boxes, API::BoxController_sptr &bc, bool FileBackEnd, bool BoxStructureOnly=false)
 Method recovers the interconnected box structure from the plain tree into box tree, recovering both boxes and their connectivity does the opposite to the initFlatStructure operation (the class contents remains unchanged) More...
 
void saveBoxStructure (const std::string &fileName)
 Save flat box structure into a file, defined by the file name. More...
 
void setBoxesFilePositions (bool setFileBacked)
 

Static Public Member Functions

::NeXus::File * createOrOpenMDWSgroup (const std::string &fileName, int &nDims, const std::string &WSEventType, bool readOnly, bool &alreadyExists)
 The function to create a NeXus MD workspace group with specified events type and number of dimensions or opens the existing group, which corresponds to the input parameters. More...
 
static void loadExperimentInfos (::NeXus::File *const file, const std::string &filename, const std::shared_ptr< API::MultipleExperimentInfos > &mei, bool lazy=false)
 Load the ExperimentInfo blocks, if any, in the NXS file. More...
 
static void loadExperimentInfos (::NeXus::File *const file, const std::string &filename, std::shared_ptr< API::MultipleExperimentInfos > mei, const Mantid::Kernel::NexusHDF5Descriptor &fileInfo, const std::string &currentGroup, bool lazy=false)
 
static void saveAffineTransformMatricies (::NeXus::File *const file, const API::IMDWorkspace_const_sptr &ws)
 Save the affine matrices to both directional conversions to the data. More...
 
static void saveAffineTransformMatrix (::NeXus::File *const file, API::CoordTransform const *transform, const std::string &entry_name)
 Extract and save the requested affine matrix. More...
 
static void saveExperimentInfos (::NeXus::File *const file, const API::IMDEventWorkspace_const_sptr &ws)
 Save each NEW ExperimentInfo to a spot in the file. More...
 
static void saveWSGenericInfo (::NeXus::File *const file, const API::IMDWorkspace_const_sptr &ws)
 Save workspace generic info like dimension structure, history, title dimensions etc. More...
 

Private Member Functions

void loadBoxStructure (::NeXus::File *hFile, bool onlyEventInfo=false)
 Load flat box structure from a nexus file. More...
 
void saveBoxStructure (::NeXus::File *hFile)
 Load the part of the box structure, responsible for locating events only. More...
 

Private Attributes

std::string m_bcXMLDescr
 XML representation of the box controller. More...
 
std::vector< int > m_BoxChildren
 Start/end children IDs. More...
 
std::vector< API::IMDNode * > m_Boxes
 linear vector of boxes; More...
 
std::vector< uint64_t > m_BoxEventIndex
 Start/end indices into the list of events; 2*i – filePosition, 2*i+1 number of events in the block. More...
 
std::vector< double > m_BoxSignalErrorsquared
 Box cached signal/error squared. More...
 
std::vector< int > m_BoxType
 Box type (0=None, 1=MDBox, 2=MDGridBox. More...
 
std::vector< int > m_Depth
 Recursion depth. More...
 
std::string m_eventType
 name of the event type More...
 
std::vector< double > m_Extents
 Min/Max extents in each dimension. More...
 
std::string m_FileName
 
std::vector< double > m_InverseVolume
 Inverse of the volume of the cell. More...
 
std::shared_ptr< API::MultipleExperimentInfosm_mEI
 shared pointer to multiple experiment info stored within the workspace More...
 
int m_nDim
 

Detailed Description

The class responsible for saving/loading MD boxes structure to/from HDD and for flattening/restoring the interconnected box structure (customized linked list) of MD workspace.

Date
March 21, 2013

Definition at line 27 of file MDBoxFlatTree.h.

Constructor & Destructor Documentation

◆ MDBoxFlatTree()

Mantid::DataObjects::MDBoxFlatTree::MDBoxFlatTree ( )

The constructor of the flat box tree

Definition at line 60 of file MDBoxFlatTree.cpp.

Member Function Documentation

◆ createOrOpenMDWSgroup()

NeXus::File * Mantid::DataObjects::MDBoxFlatTree::createOrOpenMDWSgroup ( const std::string &  fileName,
int &  nDims,
const std::string &  WSEventType,
bool  readOnly,
bool &  alreadyExists 
)
static

The function to create a NeXus MD workspace group with specified events type and number of dimensions or opens the existing group, which corresponds to the input parameters.

Parameters
fileName– the name of the file to create or open WS group
nDims– number of workspace dimensions;
WSEventType– the string describing event type
readOnly– true if the file is opened for read-only access
alreadyExists– return true, if opened existing group or false if new group has been created.
Returns
NeXus pointer to properly opened NeXus data file and group.
Exceptions
ifgroup or its component do not exist and the file is opened read-only or if the existing file parameters are not equal to the input parameters.

Definition at line 670 of file MDBoxFlatTree.cpp.

Referenced by Mantid::MDAlgorithms::SaveMD::doSaveEvents(), Mantid::MDAlgorithms::MergeMDFiles::finalizeOutput(), loadBoxStructure(), Mantid::DataObjects::BoxControllerNeXusIO::openFile(), and saveBoxStructure().

◆ exportExperiment()

void Mantid::DataObjects::MDBoxFlatTree::exportExperiment ( Mantid::API::IMDEventWorkspace_sptr targetWS)

Export existing experiment info defined in the box structure to target workspace (or other experiment info)

Export existing experiment info defined in the box structure to target workspace (or other experiment info as workspace is an experiment info)

Definition at line 531 of file MDBoxFlatTree.cpp.

References m_mEI.

◆ getBCXMLdescr()

const std::string & Mantid::DataObjects::MDBoxFlatTree::getBCXMLdescr ( ) const
inline
Returns
XML description of the workspace box controller

Definition at line 33 of file MDBoxFlatTree.h.

Referenced by Mantid::MDAlgorithms::LoadMD::doLoad().

◆ getBoxes()

std::vector< API::IMDNode * > & Mantid::DataObjects::MDBoxFlatTree::getBoxes ( )
inline
Returns
internal linearized box structure of md workspace. Defined only when the class is properly initiated

Definition at line 38 of file MDBoxFlatTree.h.

Referenced by Mantid::MDAlgorithms::MergeMDFiles::doExecByCloning(), Mantid::MDAlgorithms::SaveMD::doSaveEvents(), and Mantid::MDAlgorithms::MergeMDFiles::loadBoxData().

◆ getBoxType()

const std::vector< int > & Mantid::DataObjects::MDBoxFlatTree::getBoxType ( ) const
inline

Definition at line 46 of file MDBoxFlatTree.h.

Referenced by Mantid::MDAlgorithms::MergeMDFiles::loadBoxData().

◆ getEventIndex()

std::vector< uint64_t > & Mantid::DataObjects::MDBoxFlatTree::getEventIndex ( )
inline
Returns
the vector of data which describes signals and errors locations on file

Definition at line 45 of file MDBoxFlatTree.h.

Referenced by Mantid::MDAlgorithms::LoadMD::doLoad(), Mantid::MDAlgorithms::SaveMD::doSaveEvents(), and Mantid::MDAlgorithms::MergeMDFiles::loadBoxData().

◆ getNBoxes()

size_t Mantid::DataObjects::MDBoxFlatTree::getNBoxes ( ) const
inline
Returns
number of boxes

Definition at line 40 of file MDBoxFlatTree.h.

Referenced by Mantid::MDAlgorithms::MergeMDFiles::doExecByCloning(), restoreBoxTree(), and saveBoxStructure().

◆ getNDims()

int Mantid::DataObjects::MDBoxFlatTree::getNDims ( ) const
inline

Return number of dimensions this class is initiated for (or not initiated if -1)

Definition at line 72 of file MDBoxFlatTree.h.

◆ getSigErrData()

std::vector< double > & Mantid::DataObjects::MDBoxFlatTree::getSigErrData ( )
inline
Returns
the vector of data which describes signals and errors over boxes

Definition at line 42 of file MDBoxFlatTree.h.

◆ initFlatStructure()

void Mantid::DataObjects::MDBoxFlatTree::initFlatStructure ( const API::IMDEventWorkspace_sptr pws,
const std::string &  fileName 
)

convert MDWS box structure into flat structure used for saving/loading on hdd

The method initiates the MDBoxFlatTree class internal structure in the form ready for saving this structure to HDD.

Parameters
pws– the shared pointer to the MD workspace which is the source of the flat box structure
fileName– the name of the file, where this structure should be written. TODO: It is here for the case of file based workspaces

Make sure that all children are ordered. TODO: This might not be needed if the IDs are rigorously done

Definition at line 70 of file MDBoxFlatTree.cpp.

References Mantid::Geometry::d, Mantid::Kernel::ISaveable::getFilePosition(), m_bcXMLDescr, m_BoxChildren, m_Boxes, m_BoxEventIndex, m_BoxSignalErrorsquared, m_BoxType, m_Depth, m_Extents, m_FileName, m_InverseVolume, m_nDim, and Mantid::API::IMDNode::sortObjByID().

Referenced by Mantid::MDAlgorithms::MergeMDFiles::doExecByCloning(), and Mantid::MDAlgorithms::SaveMD::doSaveEvents().

◆ loadBoxStructure() [1/2]

void Mantid::DataObjects::MDBoxFlatTree::loadBoxStructure ( ::NeXus::File *  hFile,
bool  onlyEventInfo = false 
)
private

Load flat box structure from a nexus file.

Definition at line 319 of file MDBoxFlatTree.cpp.

References m_bcXMLDescr, m_BoxChildren, m_BoxEventIndex, m_BoxSignalErrorsquared, m_BoxType, m_Depth, m_Extents, m_InverseVolume, and m_nDim.

◆ loadBoxStructure() [2/2]

void Mantid::DataObjects::MDBoxFlatTree::loadBoxStructure ( const std::string &  fileName,
int &  nDim,
const std::string &  EventType,
bool  onlyEventInfo = false,
bool  restoreExperimentInfo = false 
)

load box structure from the file, defined by file name

Parameters
fileName:: The name of the file with the box information
nDim:: number of dimensions the boxes have. If this number is <=0 on input, method loads existing number of box dimensions from the file, if it is a number, method verifies if if the number of dimensions provided equal to this number in the file. (leftover from the time when it was templated method)
EventType:: "MDEvent" or "MDLeanEvent" – describe the type of events the workspace contains, similarly to nDim, used to check the data integrity
onlyEventInfo:: load only box controller information and the events locations – do not restore boxes themselves
restoreExperimentInfo:: load also experiment information

Definition at line 289 of file MDBoxFlatTree.cpp.

References createOrOpenMDWSgroup(), loadBoxStructure(), loadExperimentInfos(), m_eventType, m_FileName, m_mEI, and m_nDim.

Referenced by Mantid::MDAlgorithms::LoadMD::doLoad(), and loadBoxStructure().

◆ loadExperimentInfos() [1/2]

void Mantid::DataObjects::MDBoxFlatTree::loadExperimentInfos ( ::NeXus::File *const  file,
const std::string &  filename,
const std::shared_ptr< API::MultipleExperimentInfos > &  mei,
bool  lazy = false 
)
static

Load the ExperimentInfo blocks, if any, in the NXS file.

Parameters
file:: the pointer to the properly opened nexus data file where the experiment info groups can be found.
filename:: the filename of the opened NeXus file. Use for the file-backed case
mei:: MDEventWorkspace/MDHisto to load experiment infos to or rather pointer to the base class of this workspaces (which is an experimentInfo)
lazy:: If true, use the FileBackedExperimentInfo class to only load the data from the file when it is requested

Definition at line 484 of file MDBoxFlatTree.cpp.

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

◆ loadExperimentInfos() [2/2]

void Mantid::DataObjects::MDBoxFlatTree::loadExperimentInfos ( ::NeXus::File *const  file,
const std::string &  filename,
std::shared_ptr< API::MultipleExperimentInfos mei,
const Mantid::Kernel::NexusHDF5Descriptor fileInfo,
const std::string &  currentGroup,
bool  lazy = false 
)
static

◆ restoreBoxTree()

uint64_t Mantid::DataObjects::MDBoxFlatTree::restoreBoxTree ( std::vector< API::IMDNode * > &  Boxes,
API::BoxController_sptr bc,
bool  FileBackEnd,
bool  BoxStructureOnly = false 
)

Method recovers the interconnected box structure from the plain tree into box tree, recovering both boxes and their connectivity does the opposite to the initFlatStructure operation (the class contents remains unchanged)

Parameters
Boxes:: the return vector of pointers to interconnected boxes. All previous pointers found in the vector will be overwritten (beware of memory loss)
bc:: shard pointer to the box controller, which each box uses
FileBackEnd:: if one should make the data file backed, namely restore/calculate the data, necessary to obtain events file positions
BoxStructureOnly:: restore box tree only ignoring information about the box events
Returns
totalNumEvents :: total number of events the box structure should contain and allocated memory for.

Definition at line 555 of file MDBoxFlatTree.cpp.

References Mantid::API::IMDNode::calcVolume(), Mantid::DataObjects::MDEventFactory::createBox(), Mantid::Geometry::d, Mantid::Kernel::Logger::debug(), Mantid::API::g_log, Mantid::API::IMDNode::getInverseVolume(), Mantid::DataObjects::MDEventFactory::getMaxNumDim(), getNBoxes(), m_BoxChildren, m_BoxEventIndex, m_BoxSignalErrorsquared, m_BoxType, m_Depth, m_eventType, m_Extents, m_InverseVolume, m_nDim, Mantid::DataHandling::numEvents(), Mantid::API::IMDNode::setErrorSquared(), Mantid::API::IMDNode::setFileBacked(), Mantid::API::IMDNode::setID(), Mantid::API::IMDNode::setInverseVolume(), and Mantid::API::IMDNode::setSignal().

Referenced by Mantid::MDAlgorithms::LoadMD::doLoad().

◆ saveAffineTransformMatricies()

void Mantid::DataObjects::MDBoxFlatTree::saveAffineTransformMatricies ( ::NeXus::File *const  file,
const API::IMDWorkspace_const_sptr ws 
)
static

Save the affine matrices to both directional conversions to the data.

Parameters
file: pointer to the NeXus file
ws: workspace to get matrix from

Definition at line 819 of file MDBoxFlatTree.cpp.

References saveAffineTransformMatrix().

Referenced by Mantid::MDAlgorithms::SaveMD::doSaveHisto(), Mantid::MDAlgorithms::SaveMD2::doSaveHisto(), and saveWSGenericInfo().

◆ saveAffineTransformMatrix()

void Mantid::DataObjects::MDBoxFlatTree::saveAffineTransformMatrix ( ::NeXus::File *const  file,
API::CoordTransform const *  transform,
const std::string &  entry_name 
)
static

Extract and save the requested affine matrix.

Parameters
file: pointer to the NeXus file
transform: the object to extract the affine matrix from
entry_name: the tag in the NeXus file to save under

Definition at line 837 of file MDBoxFlatTree.cpp.

References Mantid::Kernel::Logger::debug(), Mantid::API::g_log, Mantid::API::CoordTransform::id(), Mantid::API::CoordTransform::makeAffineMatrix(), and Mantid::Kernel::Matrix< T >::str().

Referenced by saveAffineTransformMatricies().

◆ saveBoxStructure() [1/2]

void Mantid::DataObjects::MDBoxFlatTree::saveBoxStructure ( ::NeXus::File *  hFile)
private

Load the part of the box structure, responsible for locating events only.

Save flat box structure into properly open nexus file

Definition at line 213 of file MDBoxFlatTree.cpp.

References Mantid::DataObjects::create(), getNBoxes(), m_bcXMLDescr, m_BoxChildren, m_BoxEventIndex, m_BoxSignalErrorsquared, m_BoxType, m_Depth, m_Extents, m_InverseVolume, and m_nDim.

◆ saveBoxStructure() [2/2]

void Mantid::DataObjects::MDBoxFlatTree::saveBoxStructure ( const std::string &  fileName)

Save flat box structure into a file, defined by the file name.

Definition at line 200 of file MDBoxFlatTree.cpp.

References createOrOpenMDWSgroup(), m_Boxes, m_FileName, m_nDim, and saveBoxStructure().

Referenced by Mantid::MDAlgorithms::SaveMD::doSaveEvents(), Mantid::MDAlgorithms::MergeMDFiles::finalizeOutput(), and saveBoxStructure().

◆ saveExperimentInfos()

void Mantid::DataObjects::MDBoxFlatTree::saveExperimentInfos ( ::NeXus::File *const  file,
const API::IMDEventWorkspace_const_sptr ws 
)
static

Save each NEW ExperimentInfo to a spot in the file.

Parameters
fileNeXus file pointer to the file, opened within appropriate group where one going to place experiment infos
ws– the shared pointer to the workspace with experiment infos to write.

Definition at line 375 of file MDBoxFlatTree.cpp.

References Mantid::API::g_log, Mantid::Kernel::Strings::toString(), and Mantid::Kernel::Logger::warning().

Referenced by Mantid::MDAlgorithms::SaveMD::doSaveEvents(), and Mantid::MDAlgorithms::MergeMDFiles::finalizeOutput().

◆ saveWSGenericInfo()

void Mantid::DataObjects::MDBoxFlatTree::saveWSGenericInfo ( ::NeXus::File *const  file,
const API::IMDWorkspace_const_sptr ws 
)
static

Save workspace generic info like dimension structure, history, title dimensions etc.

Definition at line 778 of file MDBoxFlatTree.cpp.

References Mantid::Geometry::d, and saveAffineTransformMatricies().

Referenced by Mantid::MDAlgorithms::SaveMD::doSaveEvents(), and Mantid::MDAlgorithms::MergeMDFiles::finalizeOutput().

◆ setBoxesFilePositions()

void Mantid::DataObjects::MDBoxFlatTree::setBoxesFilePositions ( bool  setFileBacked)

Definition at line 174 of file MDBoxFlatTree.cpp.

References m_Boxes, m_BoxEventIndex, and m_BoxType.

Referenced by Mantid::MDAlgorithms::SaveMD::doSaveEvents().

Member Data Documentation

◆ m_bcXMLDescr

std::string Mantid::DataObjects::MDBoxFlatTree::m_bcXMLDescr
private

XML representation of the box controller.

Definition at line 103 of file MDBoxFlatTree.h.

Referenced by initFlatStructure(), loadBoxStructure(), and saveBoxStructure().

◆ m_BoxChildren

std::vector<int> Mantid::DataObjects::MDBoxFlatTree::m_BoxChildren
private

Start/end children IDs.

Definition at line 99 of file MDBoxFlatTree.h.

Referenced by initFlatStructure(), loadBoxStructure(), restoreBoxTree(), and saveBoxStructure().

◆ m_Boxes

std::vector<API::IMDNode *> Mantid::DataObjects::MDBoxFlatTree::m_Boxes
private

linear vector of boxes;

Definition at line 101 of file MDBoxFlatTree.h.

Referenced by initFlatStructure(), saveBoxStructure(), and setBoxesFilePositions().

◆ m_BoxEventIndex

std::vector<uint64_t> Mantid::DataObjects::MDBoxFlatTree::m_BoxEventIndex
private

Start/end indices into the list of events; 2*i – filePosition, 2*i+1 number of events in the block.

Definition at line 91 of file MDBoxFlatTree.h.

Referenced by initFlatStructure(), loadBoxStructure(), restoreBoxTree(), saveBoxStructure(), and setBoxesFilePositions().

◆ m_BoxSignalErrorsquared

std::vector<double> Mantid::DataObjects::MDBoxFlatTree::m_BoxSignalErrorsquared
private

Box cached signal/error squared.

Definition at line 97 of file MDBoxFlatTree.h.

Referenced by initFlatStructure(), loadBoxStructure(), restoreBoxTree(), and saveBoxStructure().

◆ m_BoxType

std::vector<int> Mantid::DataObjects::MDBoxFlatTree::m_BoxType
private

Box type (0=None, 1=MDBox, 2=MDGridBox.

Definition at line 86 of file MDBoxFlatTree.h.

Referenced by initFlatStructure(), loadBoxStructure(), restoreBoxTree(), saveBoxStructure(), and setBoxesFilePositions().

◆ m_Depth

std::vector<int> Mantid::DataObjects::MDBoxFlatTree::m_Depth
private

Recursion depth.

Definition at line 88 of file MDBoxFlatTree.h.

Referenced by initFlatStructure(), loadBoxStructure(), restoreBoxTree(), and saveBoxStructure().

◆ m_eventType

std::string Mantid::DataObjects::MDBoxFlatTree::m_eventType
private

name of the event type

Definition at line 105 of file MDBoxFlatTree.h.

Referenced by loadBoxStructure(), and restoreBoxTree().

◆ m_Extents

std::vector<double> Mantid::DataObjects::MDBoxFlatTree::m_Extents
private

Min/Max extents in each dimension.

Definition at line 93 of file MDBoxFlatTree.h.

Referenced by initFlatStructure(), loadBoxStructure(), restoreBoxTree(), and saveBoxStructure().

◆ m_FileName

std::string Mantid::DataObjects::MDBoxFlatTree::m_FileName
private

Definition at line 84 of file MDBoxFlatTree.h.

Referenced by initFlatStructure(), loadBoxStructure(), and saveBoxStructure().

◆ m_InverseVolume

std::vector<double> Mantid::DataObjects::MDBoxFlatTree::m_InverseVolume
private

Inverse of the volume of the cell.

Definition at line 95 of file MDBoxFlatTree.h.

Referenced by initFlatStructure(), loadBoxStructure(), restoreBoxTree(), and saveBoxStructure().

◆ m_mEI

std::shared_ptr<API::MultipleExperimentInfos> Mantid::DataObjects::MDBoxFlatTree::m_mEI
private

shared pointer to multiple experiment info stored within the workspace

Definition at line 107 of file MDBoxFlatTree.h.

Referenced by exportExperiment(), and loadBoxStructure().

◆ m_nDim

int Mantid::DataObjects::MDBoxFlatTree::m_nDim
private

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