Mantid
Loading...
Searching...
No Matches
MDBoxFlatTree.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2007 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7#pragma once
8
13#include "MantidKernel/Matrix.h"
14
15namespace Mantid {
16namespace DataObjects {
17//===============================================================================================
26class MANTID_DATAOBJECTS_DLL MDBoxFlatTree {
27public:
30
32 const std::string &getBCXMLdescr() const { return m_bcXMLDescr; }
33
34 //---------------------------------------------------------------------------------------------------------------------
37 std::vector<API::IMDNode *> &getBoxes() { return m_Boxes; }
39 size_t getNBoxes() const { return m_BoxType.size(); }
41 std::vector<double> &getSigErrData() { return m_BoxSignalErrorsquared; }
44 std::vector<uint64_t> &getEventIndex() { return m_BoxEventIndex; }
45 const std::vector<int> &getBoxType() const { return m_BoxType; }
46
47 //---------------------------------------------------------------------------------------------------------------------
50 void initFlatStructure(const API::IMDEventWorkspace_sptr &pws, const std::string &fileName);
51
52 uint64_t restoreBoxTree(std::vector<API::IMDNode *> &Boxes, API::BoxController_sptr &bc, bool FileBackEnd,
53 bool BoxStructureOnly = false);
54
55 /*** this function tries to set file positions of the boxes to
56 make data physically located close to each other to be as close as
57 possible on the HDD */
58 void setBoxesFilePositions(bool setFileBacked);
59
61 void saveBoxStructure(const std::string &fileName);
62 void loadBoxStructure(const std::string &fileName, int &nDim, const std::string &EventType,
63 bool onlyEventInfo = false, bool restoreExperimentInfo = false);
64
67 void exportExperiment(Mantid::API::IMDEventWorkspace_sptr &targetWS);
68
71 int getNDims() const { return m_nDim; }
72
73protected: // for testing
74private:
76 void loadBoxStructure(Mantid::Nexus::File *hFile, bool onlyEventInfo = false);
79 void saveBoxStructure(Mantid::Nexus::File *hFile);
80 //----------------------------------------------------------------------------------------------
81 int m_nDim;
82 // The name of the file the class will be working with
83 std::string m_FileName;
85 std::vector<int> m_BoxType;
87 std::vector<int> m_Depth;
90 std::vector<uint64_t> m_BoxEventIndex;
92 std::vector<double> m_Extents;
94 std::vector<double> m_InverseVolume;
96 std::vector<double> m_BoxSignalErrorsquared;
98 std::vector<int> m_BoxChildren;
100 std::vector<API::IMDNode *> m_Boxes;
102 std::string m_bcXMLDescr;
104 std::string m_eventType;
106 std::shared_ptr<API::MultipleExperimentInfos> m_mEI;
107
108public:
109 static Mantid::Nexus::File *createOrOpenMDWSgroup(const std::string &fileName, int &nDims,
110 const std::string &WSEventType, bool readOnly, bool &alreadyExists);
111 // save each experiment info into its own NeXus group within an existing
112 // opened group
113 static void saveExperimentInfos(Mantid::Nexus::File *const file, const API::IMDEventWorkspace_const_sptr &ws);
114
115 // load experiment infos, previously saved through the saveExperimentInfo
116 // function. Overload version that uses file's NexusDescriptor for LoadMD
117 static void loadExperimentInfos(Mantid::Nexus::File *const file, const std::string &filename,
118 std::shared_ptr<API::MultipleExperimentInfos> mei, const std::string &currentGroup,
119 bool lazy = false);
120
121 // load experiment infos, previously saved through the saveExperimentInfo
122 // function
123 static void loadExperimentInfos(Mantid::Nexus::File *const file, const std::string &filename,
124 const std::shared_ptr<API::MultipleExperimentInfos> &mei, bool lazy = false);
125
126 static void saveAffineTransformMatricies(Mantid::Nexus::File *const file, const API::IMDWorkspace_const_sptr &ws);
127 static void saveAffineTransformMatrix(Mantid::Nexus::File *const file, API::CoordTransform const *transform,
128 const std::string &entry_name);
129
130 static void saveWSGenericInfo(Mantid::Nexus::File *const file, const API::IMDWorkspace_const_sptr &ws);
131};
132
133template <typename T>
134void saveMatrix(Mantid::Nexus::File *const file, const std::string &name, Kernel::Matrix<T> &m, NXnumtype type,
135 const std::string &tag);
136} // namespace DataObjects
137} // namespace Mantid
std::string name
Definition Run.cpp:60
Unique SingleValueParameter Declaration for InputNDimensions.
The class responsible for saving/loading MD boxes structure to/from HDD and for flattening/restoring ...
std::vector< API::IMDNode * > & getBoxes()
std::vector< int > m_BoxChildren
Start/end children IDs.
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.
std::vector< double > m_InverseVolume
Inverse of the volume of the cell.
std::string m_eventType
name of the event type
std::vector< double > & getSigErrData()
const std::string & getBCXMLdescr() const
std::vector< double > m_BoxSignalErrorsquared
Box cached signal/error squared.
std::vector< uint64_t > & getEventIndex()
const std::vector< int > & getBoxType() const
std::vector< API::IMDNode * > m_Boxes
linear vector of boxes;
int getNDims() const
Return number of dimensions this class is initiated for (or not initiated if -1)
std::vector< double > m_Extents
Min/Max extents in each dimension.
std::string m_bcXMLDescr
XML representation of the box controller.
std::vector< int > m_Depth
Recursion depth.
std::shared_ptr< API::MultipleExperimentInfos > m_mEI
shared pointer to multiple experiment info stored within the workspace
std::vector< int > m_BoxType
Box type (0=None, 1=MDBox, 2=MDGridBox.
Numerical Matrix class.
Definition Matrix.h:42
The primitive types published by this API.
std::shared_ptr< IMDEventWorkspace > IMDEventWorkspace_sptr
Shared pointer to Mantid::API::IMDEventWorkspace.
std::shared_ptr< const IMDEventWorkspace > IMDEventWorkspace_const_sptr
Shared pointer to Mantid::API::IMDEventWorkspace (const version)
std::shared_ptr< const IMDWorkspace > IMDWorkspace_const_sptr
Shared pointer to the IMDWorkspace base class (const version)
std::shared_ptr< BoxController > BoxController_sptr
Shared ptr to BoxController.
EventType
What kind of event list is being stored.
Definition IEventList.h:18
void saveMatrix(Mantid::Nexus::File *const file, const std::string &name, Kernel::Matrix< T > &m, NXnumtype type, const std::string &tag)
Save routine for a generic matrix.
Helper class which provides the Collimation Length for SANS instruments.