Mantid
|
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 ¤tGroup, 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::MultipleExperimentInfos > | m_mEI |
shared pointer to multiple experiment info stored within the workspace More... | |
int | m_nDim |
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.
Definition at line 27 of file MDBoxFlatTree.h.
Mantid::DataObjects::MDBoxFlatTree::MDBoxFlatTree | ( | ) |
The constructor of the flat box tree
Definition at line 60 of file MDBoxFlatTree.cpp.
|
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.
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. |
if | group 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().
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.
|
inline |
Definition at line 33 of file MDBoxFlatTree.h.
Referenced by Mantid::MDAlgorithms::LoadMD::doLoad().
|
inline |
Definition at line 38 of file MDBoxFlatTree.h.
Referenced by Mantid::MDAlgorithms::MergeMDFiles::doExecByCloning(), Mantid::MDAlgorithms::SaveMD::doSaveEvents(), and Mantid::MDAlgorithms::MergeMDFiles::loadBoxData().
|
inline |
Definition at line 46 of file MDBoxFlatTree.h.
Referenced by Mantid::MDAlgorithms::MergeMDFiles::loadBoxData().
|
inline |
Definition at line 45 of file MDBoxFlatTree.h.
Referenced by Mantid::MDAlgorithms::LoadMD::doLoad(), Mantid::MDAlgorithms::SaveMD::doSaveEvents(), and Mantid::MDAlgorithms::MergeMDFiles::loadBoxData().
|
inline |
Definition at line 40 of file MDBoxFlatTree.h.
Referenced by Mantid::MDAlgorithms::MergeMDFiles::doExecByCloning(), restoreBoxTree(), and saveBoxStructure().
|
inline |
Return number of dimensions this class is initiated for (or not initiated if -1)
Definition at line 72 of file MDBoxFlatTree.h.
|
inline |
Definition at line 42 of file MDBoxFlatTree.h.
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.
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().
|
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.
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
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().
|
static |
Load the ExperimentInfo blocks, if any, in the NXS file.
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().
|
static |
Definition at line 413 of file MDBoxFlatTree.cpp.
References Mantid::Kernel::NexusHDF5Descriptor::getAllEntries().
Referenced by Mantid::MDAlgorithms::LoadMD::execLoader(), loadBoxStructure(), and Mantid::MDAlgorithms::LoadMD::loadHisto().
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)
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 |
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().
|
static |
Save the affine matrices to both directional conversions to the data.
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().
|
static |
Extract and save the requested affine matrix.
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().
|
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.
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().
|
static |
Save each NEW ExperimentInfo to a spot in the file.
file | – NeXus 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().
|
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().
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().
|
private |
XML representation of the box controller.
Definition at line 103 of file MDBoxFlatTree.h.
Referenced by initFlatStructure(), loadBoxStructure(), and saveBoxStructure().
|
private |
Start/end children IDs.
Definition at line 99 of file MDBoxFlatTree.h.
Referenced by initFlatStructure(), loadBoxStructure(), restoreBoxTree(), and saveBoxStructure().
|
private |
linear vector of boxes;
Definition at line 101 of file MDBoxFlatTree.h.
Referenced by initFlatStructure(), saveBoxStructure(), and setBoxesFilePositions().
|
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().
|
private |
Box cached signal/error squared.
Definition at line 97 of file MDBoxFlatTree.h.
Referenced by initFlatStructure(), loadBoxStructure(), restoreBoxTree(), and saveBoxStructure().
|
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().
|
private |
Recursion depth.
Definition at line 88 of file MDBoxFlatTree.h.
Referenced by initFlatStructure(), loadBoxStructure(), restoreBoxTree(), and saveBoxStructure().
|
private |
name of the event type
Definition at line 105 of file MDBoxFlatTree.h.
Referenced by loadBoxStructure(), and restoreBoxTree().
|
private |
Min/Max extents in each dimension.
Definition at line 93 of file MDBoxFlatTree.h.
Referenced by initFlatStructure(), loadBoxStructure(), restoreBoxTree(), and saveBoxStructure().
|
private |
Definition at line 84 of file MDBoxFlatTree.h.
Referenced by initFlatStructure(), loadBoxStructure(), and saveBoxStructure().
|
private |
Inverse of the volume of the cell.
Definition at line 95 of file MDBoxFlatTree.h.
Referenced by initFlatStructure(), loadBoxStructure(), restoreBoxTree(), and saveBoxStructure().
|
private |
shared pointer to multiple experiment info stored within the workspace
Definition at line 107 of file MDBoxFlatTree.h.
Referenced by exportExperiment(), and loadBoxStructure().
|
private |
Definition at line 82 of file MDBoxFlatTree.h.
Referenced by initFlatStructure(), loadBoxStructure(), restoreBoxTree(), and saveBoxStructure().