Mantid
Loading...
Searching...
No Matches
NexusLoader.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2025 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
8#pragma once
9
10#include "MantidDataHandling/DllConfig.h"
11#include <H5Cpp.h>
12#include <memory>
13#include <stack>
14#include <string>
15#include <vector>
16
18
19namespace NxsFieldNames {
20const std::string TIME_OF_FLIGHT("event_time_offset"); // float32 in ORNL nexus files
21const std::string DETID("event_id"); // uint32 in ORNL nexus files
22const std::string INDEX_ID("event_index");
23} // namespace NxsFieldNames
24
25using PulseROI = std::pair<size_t, size_t>; // start and stop indices for the pulse ROIs
26using EventROI = std::pair<uint64_t, uint64_t>; // start and stop indices for the events ROIs
27
28class MANTID_DATAHANDLING_DLL NexusLoader {
29public:
30 NexusLoader(const bool is_time_filtered, const std::vector<PulseROI> &pulse_indices,
31 const std::vector<std::pair<int, PulseROI>> &target_to_pulse_indices = {});
32 virtual ~NexusLoader();
33
34 virtual void loadData(H5::DataSet &SDS, std::unique_ptr<std::vector<uint32_t>> &data,
35 const std::vector<size_t> &offsets, const std::vector<size_t> &slabsizes);
36 virtual void loadData(H5::DataSet &SDS, std::unique_ptr<std::vector<float>> &data, const std::vector<size_t> &offsets,
37 const std::vector<size_t> &slabsizes);
38
39 virtual std::stack<EventROI> getEventIndexRanges(H5::Group &event_group, const uint64_t number_events,
40 std::unique_ptr<std::vector<uint64_t>> *event_index = nullptr) const;
41 std::stack<std::pair<int, EventROI>> getEventIndexSplitRanges(H5::Group &event_group, const uint64_t number_events);
42
43private:
44 template <typename Type>
45 void loadDataInternal(H5::DataSet &SDS, std::unique_ptr<std::vector<Type>> &data, const std::vector<size_t> &offsets,
46 const std::vector<size_t> &slabsizes) const;
48 const std::vector<PulseROI> m_pulse_indices;
49 std::vector<std::pair<int, PulseROI>> m_target_to_pulse_indices;
50 void loadEventIndex(H5::Group &event_group, std::unique_ptr<std::vector<uint64_t>> &data) const;
51};
52
53} // namespace Mantid::DataHandling::AlignAndFocusPowderSlim
std::vector< std::pair< int, PulseROI > > m_target_to_pulse_indices
Definition NexusLoader.h:49
const std::string TIME_OF_FLIGHT("event_time_offset")
std::pair< uint64_t, uint64_t > EventROI
Definition NexusLoader.h:26