Mantid
Loading...
Searching...
No Matches
FilterEventsByLogValuePreNexus.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2010 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
11#include "MantidDataHandling/DllConfig.h"
16#include <fstream>
17#include <string>
18#include <vector>
19
20namespace Mantid {
21namespace DataHandling {
28#undef LOADEVENTPRENEXUS_ALLOW_PARALLEL
29
31using PixelType = int;
32
34using DasTofType = int;
35
37#pragma pack(push, 4) // Make sure the structure is 8 bytes.
38struct DasEvent {
43};
44#pragma pack(pop)
45
47#pragma pack(push, 4) // Make sure the structure is 8 bytes.
56 uint32_t period;
57};
58#pragma pack(pop)
59
61#pragma pack(push, 4) // Make sure the structure is 16 bytes.
62struct Pulse {
65 uint32_t nanoseconds;
66
68 uint32_t seconds;
69
71 uint64_t event_index;
72
74 double pCurrent;
75};
76#pragma pack(pop)
77
78class MANTID_DATAHANDLING_DLL FilterEventsByLogValuePreNexus : public API::IFileLoader<Kernel::FileDescriptor>,
80public:
86 const std::string name() const override { return "FilterEventsByLogValuePreNexus"; }
88 int version() const override { return (2); }
90 const std::string category() const override { return "DataHandling\\PreNexus"; }
92 const std::string alias() const override { return "LoadEventPreNeXus2"; }
94 const std::string summary() const override {
95 return "Load and split SNS raw neutron event data format and stores it in "
96 "a workspace";
97 }
98
100 int confidence(Kernel::FileDescriptor &descriptor) const override;
101
102private:
104 void init() override;
106 void exec() override;
107
109 void processProperties();
110
112 DataObjects::EventWorkspace_sptr setupOutputEventWorkspace();
113
114 void loadPixelMap(const std::string &filename);
115
116 void openEventFile(const std::string &filename);
117
118 void readPulseidFile(const std::string &filename, const bool throwError);
119
120 void runLoadInstrument(const std::string &eventfilename, const API::MatrixWorkspace_sptr &localWorkspace);
121
123
124 void procEventsLinear(DataObjects::EventWorkspace_sptr &workspace,
125 std::vector<Types::Event::TofEvent> **arrayOfVectors, DasEvent *event_buffer,
126 size_t current_event_buffer_size, size_t fileOffset);
127
128 void setProtonCharge(DataObjects::EventWorkspace_sptr &workspace);
129
130 void addToWorkspaceLog(const std::string &logtitle, size_t mindex);
131
132 void processEventLogs();
133
135 size_t padOutEmptyPixels(const DataObjects::EventWorkspace_sptr &eventws);
136
138 void setupPixelSpectrumMap(const DataObjects::EventWorkspace_sptr &eventws);
139
141 void filterEvents();
143 void filterEventsLinear(DataObjects::EventWorkspace_sptr &workspace,
144 std::vector<Types::Event::TofEvent> **arrayOfVectors, DasEvent *event_buffer,
145 size_t current_event_buffer_size, size_t fileOffset);
146
148 void unmaskVetoEventIndexes();
149
152 int findRunFrequency();
153
154 void debugOutput(bool doit, size_t mindex);
155
157 void doStatToEventLog(size_t mindex);
158
159 std::unique_ptr<Mantid::API::Progress> m_progress = nullptr;
160
162 std::vector<int64_t> m_spectraList;
163
165 std::vector<Types::Core::DateAndTime> pulsetimes;
167 std::vector<uint64_t> m_vecEventIndex;
169 std::vector<double> m_protonCharge;
174 std::vector<std::size_t> m_pixelToWkspindex;
176 std::vector<PixelType> m_pixelmap;
177
180
182 std::unique_ptr<Mantid::Kernel::BinaryFile<DasEvent>> m_eventFile;
183 std::size_t m_numEvents;
184 std::size_t m_numPulses;
185 uint32_t m_numPixel;
186
187 std::size_t m_numGoodEvents;
188 std::size_t m_numErrorEvents;
189 std::size_t m_numBadEvents;
193 std::set<PixelType> wrongdetids;
194 std::map<PixelType, size_t> wrongdetidmap;
195 std::vector<std::vector<Types::Core::DateAndTime>> wrongdetid_pulsetimes;
196 std::vector<std::vector<double>> wrongdetid_tofs;
197
201 std::size_t m_firstEvent;
202 std::size_t m_maxNumEvents;
203
206
210 std::map<int64_t, bool> spectraLoadMap;
211
216
219
222
224 std::vector<detid_t> mSEids;
225 std::map<size_t, detid_t> mSEmap;
226 std::vector<std::vector<int64_t>> mSEpulseids;
227 std::vector<std::vector<double>> mSEtofs;
228
230 std::string m_eventFileName;
231
233 std::string m_pulseIDFileName;
236
238 std::string m_functionMode;
239
242
245
248
250 std::vector<int> m_vecLogPixelID;
252 std::vector<std::string> m_vecLogPixelTag;
253
256
259
260 int64_t m_istep;
261
262 int64_t m_dbPixelID;
264
266};
267} // namespace DataHandling
268} // namespace Mantid
IPeaksWorkspace_sptr workspace
Definition: IndexPeaks.cpp:114
Class for marking algorithms as deprecated.
Defines an interface to an algorithm that loads a file so that it can take part in the automatic sele...
Definition: IFileLoader.h:19
A data loading and splitting routine for SNS pre-nexus event files.
const std::string category() const override
Algorithm's category for identification.
std::set< PixelType > wrongdetids
detector IDs. Part of error events.
const std::string name() const override
Algorithm's name.
Mantid::detid_t m_detid_max
The maximum detector ID possible.
std::vector< PixelType > m_pixelmap
Map between the DAS pixel IDs and our pixel IDs, used while loading.
~FilterEventsByLogValuePreNexus() override
Virtual destructor.
std::size_t m_numGoodEvents
The number of good events loaded.
std::unique_ptr< Mantid::Kernel::BinaryFile< DasEvent > > m_eventFile
Handles loading from the event file.
bool m_usingMappingFile
Set to true if a valid Mapping file was provided.
std::size_t m_numEvents
The number of events in the file.
std::vector< Types::Core::DateAndTime > pulsetimes
The times for each pulse.
std::vector< std::string > m_vecLogPixelTag
Log pixel Tags for filtering.
const std::string alias() const override
Algorithm's aliases.
std::size_t m_numIgnoredEvents
the number of events that were ignored (not loaded) because, e.g.
std::vector< detid_t > mSEids
sample environment event
std::vector< int > m_vecLogPixelID
Log pixel IDs for filtering.
std::size_t m_firstEvent
The first event to load (count from zero)
std::vector< std::size_t > m_pixelToWkspindex
The value of the vector is the workspace index.
std::vector< std::vector< Types::Core::DateAndTime > > wrongdetid_pulsetimes
const std::string summary() const override
Summary of algorithms purpose.
std::vector< uint64_t > m_vecEventIndex
The index of the first event in each pulse.
bool m_pulseTimesIncreasing
Whether or not the pulse times are sorted in increasing order.
std::vector< double > m_protonCharge
The proton charge on a pulse by pulse basis.
std::map< int64_t, bool > spectraLoadMap
Handle to the loaded spectra map.
std::size_t m_numWrongdetidEvents
The number of events with wrong.
DataObjects::EventWorkspace_sptr m_localWorkspaceBA
Output EventWorkspace for filtered event B->A.
double m_protonChargeTot
The total proton charge for the run.
std::size_t m_numErrorEvents
The number of error events encountered.
Defines a wrapper around an open file.
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
int DasTofType
Type for the DAS time of flight (data file)
int PixelType
DetermineChunking : Workflow algorithm to determine chunking.
std::shared_ptr< EventWorkspace > EventWorkspace_sptr
shared pointer to the EventWorkspace class
Helper class which provides the Collimation Length for SANS instruments.
int32_t detid_t
Typedef for a detector ID.
Definition: SpectrumInfo.h:21
Structure that matches the form in the binary event list.
DasTofType tof
Time of flight.
PixelType pid
Pixel identifier as published by the DAS/DAE/DAQ.
Structure used as an intermediate for parallel processing of events.
uint32_t period
Period of the event (not really used at this time)
size_t frame_index
Frame index (pulse # of this event)
PixelType pid
Pixel identifier as published by the DAS/DAE/DAQ.
Structure that matches the form in the new pulseid files.
uint32_t nanoseconds
The number of nanoseconds since the seconds field.
uint64_t event_index
The index of the first event for this pulse.
double pCurrent
The proton charge for the pulse.
uint32_t seconds
The number of seconds since January 1, 1990.