Mantid
Loading...
Searching...
No Matches
LoadNGEM.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2019 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
10#include "MantidDataHandling/DllConfig.h"
13
14namespace Mantid {
15namespace DataHandling {
16
17static constexpr uint64_t CONTIN_ID_VALUE = 0x4F;
18static constexpr uint64_t EVENT_ID_MASK = 0x40;
19
22 uint64_t t0id : 24; // T0 ID
23 uint64_t reserved2 : 32; // Reserved for non-generics
24 uint64_t contin : 8; // 0x4F Continuation Code
25 uint64_t reserved1 : 56; // Reserved for non-generics
26 uint64_t id : 8; // Event ID
27 bool check() const {
28 // as id is 8 bit, we can do a simple AND to check
29 return (id & EVENT_ID_MASK) != 0 && contin == CONTIN_ID_VALUE;
30 }
31};
32
35 uint64_t t0id : 24; // T0 ID
36 uint64_t eventCount : 32; // Event Count
37 uint64_t contin : 8; // 0x4F Continuation Code
38 uint64_t totalLoss : 24; // Total loss count
39 uint64_t eventLoss : 20; // Event loss count
40 uint64_t frameLoss : 12; // Frame loss count
41 uint64_t id : 8; // 0x4E Event ID
42 static constexpr int T0_IDENTIFIER = 0x4E;
43 bool check() const { return id == T0_IDENTIFIER && contin == CONTIN_ID_VALUE; }
44};
45
48 uint64_t t0id : 24; // T0 ID
49 uint64_t clusterTimeY : 10; // Integrated time of the cluster on the Y side
50 // (5ns pixel)
51 uint64_t timeDiffY : 6; // Time lag from first to last detection on Y (5ns)
52 uint64_t clusterTimeX : 10; // Integrated time of the cluster on the X side
53 // (5ns pixel)
54 uint64_t timeDiffX : 6; // Time lag from first to last detection on X (5ns)
55 uint64_t contin : 8; // 0x4F Continuation Code
56 uint64_t lastY : 7; // Y position of pixel detected last
57 uint64_t firstY : 7; // Y position of pixel detected first
58 uint64_t lastX : 7; // X position of pixel detected last
59 uint64_t firstX : 7; // X position of pixel detected first
60 uint64_t timeOfFlight : 28; // Difference between T0 and detection (1ns)
61 uint64_t id : 8; // 0x47 Event ID.
62
63 uint64_t avgX() const { return (firstX + lastX) / 2; }
64 uint64_t avgY() const { return (firstY + lastY) / 2; }
65 static constexpr int COINCIDENCE_IDENTIFIER = 0x47;
66 bool check() { return id == COINCIDENCE_IDENTIFIER && contin == CONTIN_ID_VALUE; }
67 uint64_t getPixel() const {
68 return avgX() + (avgY() << 7); // Increase Y significance by 7 bits to
69 // account for 128x128 grid.
70 }
71};
72
75 uint64_t words[2]; // Array holding the word from the detector split in two.
76};
77
80 GenericEvent generic;
84};
85
86class MANTID_DATAHANDLING_DLL LoadNGEM : public API::IFileLoader<Kernel::FileDescriptor> {
87public:
89 const std::string name() const override { return "LoadNGEM"; }
91 const std::string summary() const override {
92 return "Load a file or range of files created by the nGEM detector into a "
93 "workspace.";
94 };
96 int version() const override { return 1; }
98 const std::string category() const override { return "DataHandling\\NGEM"; };
100 bool loadMutipleAsOne() override { return true; }
101
103 int confidence(Kernel::FileDescriptor &descriptor) const override;
104
105private:
107 void init() override;
109 void exec() override;
111 void loadSingleFile(const std::vector<std::string> &filePath, int &eventCountInFrame, double &maxToF, double &minToF,
112 int &rawFrames, int &goodFrames, const int &minEventsReq, const int &maxEventsReq,
113 MantidVec &frameEventCounts, std::vector<DataObjects::EventList> &events,
114 std::vector<DataObjects::EventList> &eventsInFrame, const size_t &totalFilePaths, int &fileCount);
116 size_t verifyFileSize(std::ifstream &file);
118 bool reportProgressAndCheckCancel(size_t &numProcessedEvents, int &eventCountInFrame, const size_t &totalNumEvents,
119 const size_t &totalFilePaths, const int &fileCount);
121 void createCountWorkspace(const std::vector<double> &frameEventCounts);
123 void loadInstrument(DataObjects::EventWorkspace_sptr &dataWorkspace);
125 std::map<std::string, std::string> validateInputs() override;
126};
127
128} // namespace DataHandling
129} // namespace Mantid
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
Algorithm's name for identification.
Definition: LoadNGEM.h:89
int version() const override
Algorithm's Version for identification.
Definition: LoadNGEM.h:96
bool loadMutipleAsOne() override
Should the loader load multiple files into one workspace.
Definition: LoadNGEM.h:100
const std::string summary() const override
The purpose of the algorithm.
Definition: LoadNGEM.h:91
const std::string category() const override
Algorithm's category for identification.
Definition: LoadNGEM.h:98
Defines a wrapper around an open file.
static constexpr uint64_t CONTIN_ID_VALUE
Definition: LoadNGEM.h:17
static constexpr uint64_t EVENT_ID_MASK
Definition: LoadNGEM.h:18
std::shared_ptr< EventWorkspace > EventWorkspace_sptr
shared pointer to the EventWorkspace class
Helper class which provides the Collimation Length for SANS instruments.
std::vector< double > MantidVec
typedef for the data storage used in Mantid matrix workspaces
Definition: cow_ptr.h:172
static constexpr int COINCIDENCE_IDENTIFIER
Definition: LoadNGEM.h:65
Holds the 128 bit words from the detector.
Definition: LoadNGEM.h:74
Generic event to separate bits.
Definition: LoadNGEM.h:21
Indicate time 0, the start of a new frame.
Definition: LoadNGEM.h:34
static constexpr int T0_IDENTIFIER
Definition: LoadNGEM.h:42
Is able to hold all versions of the data words in the same memory location.
Definition: LoadNGEM.h:79
CoincidenceEvent coincidence
Definition: LoadNGEM.h:82