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"
15
16namespace Mantid {
17namespace DataObjects {
18//===============================================================================================
27class MANTID_DATAOBJECTS_DLL MDBoxFlatTree {
28public:
31
33 const std::string &getBCXMLdescr() const { return m_bcXMLDescr; }
34
35 //---------------------------------------------------------------------------------------------------------------------
38 std::vector<API::IMDNode *> &getBoxes() { return m_Boxes; }
40 size_t getNBoxes() const { return m_BoxType.size(); }
42 std::vector<double> &getSigErrData() { return m_BoxSignalErrorsquared; }
45 std::vector<uint64_t> &getEventIndex() { return m_BoxEventIndex; }
46 const std::vector<int> &getBoxType() const { return m_BoxType; }
47
48 //---------------------------------------------------------------------------------------------------------------------
51 void initFlatStructure(const API::IMDEventWorkspace_sptr &pws, const std::string &fileName);
52
53 uint64_t restoreBoxTree(std::vector<API::IMDNode *> &Boxes, API::BoxController_sptr &bc, bool FileBackEnd,
54 bool BoxStructureOnly = false);
55
56 /*** this function tries to set file positions of the boxes to
57 make data physically located close to each other to be as close as
58 possible on the HDD */
59 void setBoxesFilePositions(bool setFileBacked);
60
62 void saveBoxStructure(const std::string &fileName);
63 void loadBoxStructure(const std::string &fileName, int &nDim, const std::string &EventType,
64 bool onlyEventInfo = false, bool restoreExperimentInfo = false);
65
68 void exportExperiment(Mantid::API::IMDEventWorkspace_sptr &targetWS);
69
72 int getNDims() const { return m_nDim; }
73
74protected: // for testing
75private:
77 void loadBoxStructure(::NeXus::File *hFile, bool onlyEventInfo = false);
80 void saveBoxStructure(::NeXus::File *hFile);
81 //----------------------------------------------------------------------------------------------
82 int m_nDim;
83 // The name of the file the class will be working with
84 std::string m_FileName;
86 std::vector<int> m_BoxType;
88 std::vector<int> m_Depth;
91 std::vector<uint64_t> m_BoxEventIndex;
93 std::vector<double> m_Extents;
95 std::vector<double> m_InverseVolume;
97 std::vector<double> m_BoxSignalErrorsquared;
99 std::vector<int> m_BoxChildren;
101 std::vector<API::IMDNode *> m_Boxes;
103 std::string m_bcXMLDescr;
105 std::string m_eventType;
107 std::shared_ptr<API::MultipleExperimentInfos> m_mEI;
108
109public:
110 static ::NeXus::File *createOrOpenMDWSgroup(const std::string &fileName, int &nDims, const std::string &WSEventType,
111 bool readOnly, bool &alreadyExists);
112 // save each experiment info into its own NeXus group within an existing
113 // opened group
114 static void saveExperimentInfos(::NeXus::File *const file, const API::IMDEventWorkspace_const_sptr &ws);
115
116 // load experiment infos, previously saved through the the saveExperimentInfo
117 // function. Overload version that usese NexusHDF5Descriptor for LoadMD
118 static void loadExperimentInfos(::NeXus::File *const file, const std::string &filename,
119 std::shared_ptr<API::MultipleExperimentInfos> mei,
120 const Mantid::Kernel::NexusHDF5Descriptor &fileInfo, const std::string &currentGroup,
121 bool lazy = false);
122
123 // load experiment infos, previously saved through the the saveExperimentInfo
124 // function
125 static void loadExperimentInfos(::NeXus::File *const file, const std::string &filename,
126 const std::shared_ptr<API::MultipleExperimentInfos> &mei, bool lazy = false);
127
128 static void saveAffineTransformMatricies(::NeXus::File *const file, const API::IMDWorkspace_const_sptr &ws);
129 static void saveAffineTransformMatrix(::NeXus::File *const file, API::CoordTransform const *transform,
130 const std::string &entry_name);
131
132 static void saveWSGenericInfo(::NeXus::File *const file, const API::IMDWorkspace_const_sptr &ws);
133};
134
135template <typename T>
136void saveMatrix(::NeXus::File *const file, const std::string &name, Kernel::Matrix<T> &m, ::NeXus::NXnumtype type,
137 const std::string &tag);
138} // namespace DataObjects
139} // namespace Mantid
Unique SingleValueParameter Declaration for InputNDimensions.
The class responsible for saving/loading MD boxes structure to/from HDD and for flattening/restoring ...
Definition: MDBoxFlatTree.h:27
std::vector< API::IMDNode * > & getBoxes()
Definition: MDBoxFlatTree.h:38
std::vector< int > m_BoxChildren
Start/end children IDs.
Definition: MDBoxFlatTree.h:99
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.
Definition: MDBoxFlatTree.h:91
std::vector< double > m_InverseVolume
Inverse of the volume of the cell.
Definition: MDBoxFlatTree.h:95
std::string m_eventType
name of the event type
std::vector< double > & getSigErrData()
Definition: MDBoxFlatTree.h:42
const std::string & getBCXMLdescr() const
Definition: MDBoxFlatTree.h:33
std::vector< double > m_BoxSignalErrorsquared
Box cached signal/error squared.
Definition: MDBoxFlatTree.h:97
std::vector< uint64_t > & getEventIndex()
Definition: MDBoxFlatTree.h:45
const std::vector< int > & getBoxType() const
Definition: MDBoxFlatTree.h:46
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)
Definition: MDBoxFlatTree.h:72
std::vector< double > m_Extents
Min/Max extents in each dimension.
Definition: MDBoxFlatTree.h:93
std::string m_bcXMLDescr
XML representation of the box controller.
std::vector< int > m_Depth
Recursion depth.
Definition: MDBoxFlatTree.h:88
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.
Definition: MDBoxFlatTree.h:86
Numerical Matrix class.
Definition: Matrix.h:42
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)
Definition: IMDWorkspace.h:148
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(::NeXus::File *const file, const std::string &name, Kernel::Matrix< T > &m, ::NeXus::NXnumtype type, const std::string &tag)
Save routine for a generic matrix.
Helper class which provides the Collimation Length for SANS instruments.