Mantid
Loading...
Searching...
No Matches
LoadDNSEvent.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2022 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#include "BitStream.h"
10#include "MantidDataHandling/DllConfig.h"
14
15#include "MantidTypes/Core/DateAndTime.h"
16
17using namespace Mantid::Kernel;
18using namespace Mantid::API;
19
20namespace Mantid::DataHandling {
21
33class MANTID_DATAHANDLING_DLL LoadDNSEvent : public API::IFileLoader<Kernel::FileDescriptor> {
34public:
36 const std::string name() const override { return "LoadDNSEvent"; }
38 const std::string summary() const override {
39 return "Loads data from the DNS PSD detector to a Mantid EventWorkspace.";
40 }
41
42 // Algorithm's version for identification
43 int version() const override { return 1; }
44 // Algorithm's category for identification
45 const std::string category() const override { return "DataHandling"; }
46 // Returns a confidence value that this algorithm can load a file
47 int confidence(Kernel::FileDescriptor &descriptor) const override;
48
49private:
50 // Initialise the properties
51 void init() override;
52 // Run the algorithm
53 void exec() override;
54
55 struct BufferHeader {
56 uint16_t bufferLength = 0;
57 uint16_t bufferVersion = 0;
58 uint16_t headerLength = 0;
59 uint16_t bufferNumber = 0;
60 uint16_t runId = 0;
61 uint8_t mcpdId = 0;
62 uint8_t deviceStatus = 0;
63 uint64_t timestamp = 0;
64 };
65
66public:
67 enum event_id_e { NEUTRON = 0, TRIGGER = 1 };
68
69 struct CompactEvent {
70 uint64_t timestamp = 0;
71 };
72
73private:
75 // Neutron Events for each pixel
76 std::vector<std::vector<CompactEvent>> neutronEvents;
77 std::vector<CompactEvent> triggerEvents;
78 };
79
80 struct TriggerEvent {
81 bool isChopperTrigger = false;
82 CompactEvent event = {};
83 };
84
85 struct NeutronEvent {
86 size_t wsIndex = 0;
87 CompactEvent event = {};
88 };
89
90 uint32_t m_chopperChannel = 2;
91 uint32_t m_detectorPixelCount = 0;
92
93 bool m_discardPreChopperEvents = true;
94 bool m_setBinBoundary = false;
95
96 void populate_EventWorkspace(Mantid::DataObjects::EventWorkspace_sptr &eventWS,
97 EventAccumulator &finalEventAccumulator);
98
99 EventAccumulator parse_File(FileByteStream &file, const std::string &fileName);
100 std::vector<uint8_t> parse_Header(FileByteStream &file);
101
102 std::vector<std::vector<uint8_t>> split_File(FileByteStream &file, const unsigned maxChunckCount);
103
104 void parse_BlockList(VectorByteStream &file, EventAccumulator &eventAccumulator);
105 void parse_Block(VectorByteStream &file, EventAccumulator &eventAccumulator);
106 void parse_BlockSeparator(VectorByteStream &file);
107 void parse_DataBuffer(VectorByteStream &file, EventAccumulator &eventAccumulator);
108 BufferHeader parse_DataBufferHeader(VectorByteStream &file);
109
110 inline void parse_andAddEvent(VectorByteStream &file, const BufferHeader &bufferHeader,
111 EventAccumulator &eventAccumulator);
112
113 void parse_EndSignature(FileByteStream &file);
114
115 TriggerEvent processTrigger(const uint64_t &data, const LoadDNSEvent::BufferHeader &bufferHeader);
116 NeutronEvent processNeutron(const uint64_t &data, const LoadDNSEvent::BufferHeader &bufferHeader);
117};
118
119} // namespace Mantid::DataHandling
Defines an interface to an algorithm that loads a file so that it can take part in the automatic sele...
Definition IFileLoader.h:19
const std::string name() const override
function to return a name of the algorithm, must be overridden in all algorithms
const std::string summary() const override
Summary of algorithms purpose.
int version() const override
function to return a version of the algorithm, must be overridden in all algorithms
const std::string category() const override
function to return a category of the algorithm.
Defines a wrapper around an open file.
std::shared_ptr< EventWorkspace > EventWorkspace_sptr
shared pointer to the EventWorkspace class
std::vector< std::vector< CompactEvent > > neutronEvents