Mantid
Loading...
Searching...
No Matches
LoadEventPreNexus2.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
10#include "MantidDataHandling/DllConfig.h"
15#include <fstream>
16#include <string>
17#include <vector>
18
19namespace Mantid {
20namespace DataHandling {
27#undef LOADEVENTPRENEXUS_ALLOW_PARALLEL
28
30using PixelType = int;
31
33using DasTofType = int;
34
36#pragma pack(push, 4) // Make sure the structure is 8 bytes.
37struct DasEvent {
42};
43#pragma pack(pop)
44
46#pragma pack(push, 4) // Make sure the structure is 8 bytes.
47struct IntermediateEvent {
53 size_t frame_index;
55 uint32_t period;
56};
57#pragma pack(pop)
58
60#pragma pack(push, 4) // Make sure the structure is 16 bytes.
61struct Pulse {
64 uint32_t nanoseconds;
65
67 uint32_t seconds;
68
70 uint64_t event_index;
71
73 double pCurrent;
74};
75#pragma pack(pop)
76
77class MANTID_DATAHANDLING_DLL LoadEventPreNexus2 : public API::IFileLoader<Kernel::FileDescriptor> {
78public:
82 const std::string name() const override { return "LoadEventPreNexus"; }
84 int version() const override { return (2); }
85 const std::vector<std::string> seeAlso() const override { return {"LoadPreNexus", "FilterEventsByLogValuePreNexus"}; }
87 const std::string category() const override { return "DataHandling\\PreNexus"; }
89 const std::string alias() const override { return "LoadEventPreNeXus2"; }
91 const std::string summary() const override {
92 return "Loads SNS raw neutron event data format and stores it in a "
93 "workspace.";
94 }
96 int confidence(Kernel::FileDescriptor &descriptor) const override;
97
98private:
100 void init() override;
102 void exec() override;
103
104 std::unique_ptr<Mantid::API::Progress> prog = nullptr;
105
107 std::vector<int64_t> spectra_list;
108
110 std::vector<Types::Core::DateAndTime> pulsetimes;
112 std::vector<uint64_t> event_indices;
114 std::vector<double> proton_charge;
119 std::vector<std::size_t> pixel_to_wkspindex;
121 std::vector<PixelType> pixelmap;
122
125
127 std::unique_ptr<Mantid::Kernel::BinaryFile<DasEvent>> eventfile;
128 std::size_t num_events;
129 std::size_t num_pulses;
130 uint32_t numpixel;
131
132 std::size_t num_good_events;
133 std::size_t num_error_events;
134 std::size_t num_bad_events;
138 std::set<PixelType> wrongdetids;
139 std::map<PixelType, size_t> wrongdetidmap;
140 std::vector<std::vector<Types::Core::DateAndTime>> wrongdetid_pulsetimes;
141 std::vector<std::vector<double>> wrongdetid_tofs;
142
146 std::size_t first_event;
147 std::size_t max_events;
148
151
155 std::map<int64_t, bool> spectraLoadMap;
156
161
164
167
169 std::vector<detid_t> mSEids;
170 std::map<size_t, detid_t> mSEmap;
171 std::vector<std::vector<int64_t>> mSEpulseids;
172 std::vector<std::vector<double>> mSEtofs;
173
179
180 void loadPixelMap(const std::string &filename);
181
182 void openEventFile(const std::string &filename);
183
184 void readPulseidFile(const std::string &filename, const bool throwError);
185
186 void runLoadInstrument(const std::string &eventfilename, const API::MatrixWorkspace_sptr &localWorkspace);
187
188 inline void fixPixelId(PixelType &pixel, uint32_t &period) const;
189
191
192 void procEventsLinear(DataObjects::EventWorkspace_sptr &workspace,
193 std::vector<Types::Event::TofEvent> **arrayOfVectors, DasEvent *event_buffer,
194 size_t current_event_buffer_size, size_t fileOffset, bool dbprint);
195
196 void setProtonCharge(DataObjects::EventWorkspace_sptr &workspace);
197
198 void addToWorkspaceLog(const std::string &logtitle, size_t mindex);
199
200 void processImbedLogs();
201
202 void debugOutput(bool doit, size_t mindex);
203
204 void unmaskVetoEventIndex();
205
206 API::MatrixWorkspace_sptr generateEventDistribtionWorkspace();
207
208 void createOutputWorkspace(const std::string &event_filename);
209
211 void processInvestigationInputs();
212};
213} // namespace DataHandling
214} // namespace Mantid
IPeaksWorkspace_sptr workspace
Definition: IndexPeaks.cpp:114
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 routine for SNS pre-nexus event files.
Mantid::detid_t detid_max
The maximum detector ID possible.
std::vector< double > proton_charge
The proton charge on a pulse by pulse basis.
std::size_t num_good_events
The number of good events loaded.
std::map< int64_t, bool > spectraLoadMap
Handle to the loaded spectra map.
const std::string alias() const override
Algorithm's aliases.
std::vector< int64_t > spectra_list
the list of Spectra
std::vector< detid_t > mSEids
sample environment event
bool loadOnlySomeSpectra
For loading only some spectra.
std::vector< Types::Core::DateAndTime > pulsetimes
The times for each pulse.
bool using_mapping_file
Set to true if a valid Mapping file was provided.
std::size_t num_error_events
The number of error events encountered.
const std::string summary() const override
Summary of algorithms purpose.
int version() const override
Algorithm's version.
std::vector< PixelType > pixelmap
Map between the DAS pixel IDs and our pixel IDs, used while loading.
std::vector< std::vector< Types::Core::DateAndTime > > wrongdetid_pulsetimes
const std::string category() const override
Algorithm's category for identification.
std::vector< std::vector< double > > mSEtofs
double proton_charge_tot
The total proton charge for the run.
const std::vector< std::string > seeAlso() const override
Function to return all of the seeAlso (these are not validated) algorithms related to this algorithm....
bool pulsetimesincreasing
Whether or not the pulse times are sorted in increasing order.
std::size_t num_events
The number of events in the file.
std::vector< std::vector< double > > wrongdetid_tofs
bool m_dbOutput
Investigation properties.
std::set< PixelType > wrongdetids
detector IDs. Part of error events.
void debugOutput(bool doit, size_t mindex)
std::size_t num_bad_events
The number of bad events.
const std::string name() const override
Algorithm's name.
std::vector< uint64_t > event_indices
The index of the first event in each pulse.
std::size_t first_event
The first event to load (count from zero)
std::size_t num_pulses
the number of pulses
std::vector< std::vector< int64_t > > mSEpulseids
std::size_t num_wrongdetid_events
The number of events with wrong.
std::map< PixelType, size_t > wrongdetidmap
std::size_t num_ignored_events
the number of events that were ignored (not loaded) because, e.g.
std::unique_ptr< Mantid::Kernel::BinaryFile< DasEvent > > eventfile
Handles loading from the event file.
bool parallelProcessing
Flag to allow for parallel loading.
DataObjects::EventWorkspace_sptr localWorkspace
std::vector< std::size_t > pixel_to_wkspindex
The value of the vector is the workspace index.
std::size_t max_events
Number of events to load.
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.
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.
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.