-
Notifications
You must be signed in to change notification settings - Fork 122
/
MergeMDFiles.h
102 lines (79 loc) · 3.01 KB
/
MergeMDFiles.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2011 ISIS Rutherford Appleton Laboratory UKRI,
// NScD Oak Ridge National Laboratory, European Spallation Source,
// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
// SPDX - License - Identifier: GPL - 3.0 +
#pragma once
#include "MantidAPI/Algorithm.h"
#include "MantidAPI/IMDEventWorkspace_fwd.h"
#include "MantidDataObjects/MDBoxFlatTree.h"
#include "MantidDataObjects/MDEventWorkspace.h"
#include "MantidKernel/System.h"
#include <mutex>
#include <nexus/NeXusFile.hpp>
namespace Mantid {
namespace MDAlgorithms {
/** Algorithm to merge multiple MDEventWorkspaces from files that
* obey a common box format.
@author Janik Zikovsky
@date 2011-08-16
*/
class DLLExport MergeMDFiles : public API::Algorithm {
public:
MergeMDFiles();
~MergeMDFiles() override;
/// Algorithm's name for identification
const std::string name() const override { return "MergeMDFiles"; };
/// Summary of algorithms purpose
const std::string summary() const override {
return "Merge multiple MDEventWorkspaces from files that obey a common box "
"format.";
}
/// Algorithm's version for identification
int version() const override { return 1; };
const std::vector<std::string> seeAlso() const override { return {"MergeMD"}; }
/// Algorithm's category for identification
const std::string category() const override { return "MDAlgorithms\\Creation"; }
private:
/// Initialise the properties
void init() override;
/// Run the algorithm
void exec() override;
void loadBoxData();
void doExecByCloning(const Mantid::API::IMDEventWorkspace_sptr &ws, const std::string &outputFile);
void finalizeOutput(const std::string &outputFile);
uint64_t loadEventsFromSubBoxes(API::IMDNode *TargetBox);
// the class which flatten the box structure and deal with it
DataObjects::MDBoxFlatTree m_BoxStruct;
// the vector of box structures for contributing files components
std::vector<DataObjects::MDBoxFlatTree> m_fileComponentsStructure;
protected:
/// Set to true if the output is cloned of the first one
// bool clonedFirst;
void clearEventLoaders();
/// number of workspace dimensions
int m_nDims;
/// string describes type of the event, stored in the workspaces.
std::string m_MDEventType;
/// if the workspace is indeed file-based
bool m_fileBasedTargetWS;
/// Files to load
std::vector<std::string> m_Filenames;
/// Vector of file handles to each input file //TODO unique?
std::vector<API::IBoxControllerIO *> m_EventLoader;
/// Output IMDEventWorkspace
Mantid::API::IMDEventWorkspace_sptr m_OutIWS;
/// # of events from ALL input files
uint64_t m_totalEvents;
/// # of events loaded from all tasks
uint64_t m_totalLoaded;
/// Mutex for file access
std::mutex m_fileMutex;
/// Mutex for modifying stats
std::mutex m_statsMutex;
/// Progress reporter
std::unique_ptr<Mantid::API::Progress> m_progress = nullptr;
};
} // namespace MDAlgorithms
} // namespace Mantid