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
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.
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 LoadEventPreNexus2 : public API::IFileLoader<Kernel::FileDescriptor>,
80public:
84 const std::string name() const override { return "LoadEventPreNexus"; }
86 int version() const override { return (2); }
87 const std::vector<std::string> seeAlso() const override { return {"LoadPreNexus"}; }
89 const std::string category() const override { return "DataHandling\\PreNexus"; }
91 const std::string alias() const override { return "LoadEventPreNeXus2"; }
93 const std::string summary() const override {
94 return "Loads SNS raw neutron event data format and stores it in a "
95 "workspace.";
96 }
98 int confidence(Kernel::FileDescriptor &descriptor) const override;
99
100private:
102 void init() override;
104 void exec() override;
105
106 std::unique_ptr<Mantid::API::Progress> prog = nullptr;
107
109 std::vector<int64_t> spectra_list;
110
112 std::vector<Types::Core::DateAndTime> pulsetimes;
114 std::vector<uint64_t> event_indices;
116 std::vector<double> proton_charge;
121 std::vector<std::size_t> pixel_to_wkspindex;
123 std::vector<PixelType> pixelmap;
124
127
129 std::unique_ptr<Mantid::Kernel::BinaryFile<DasEvent>> eventfile;
130 std::size_t num_events;
131 std::size_t num_pulses;
132 uint32_t numpixel;
133
134 std::size_t num_good_events;
135 std::size_t num_error_events;
136 std::size_t num_bad_events;
140 std::set<PixelType> wrongdetids;
141 std::map<PixelType, size_t> wrongdetidmap;
142 std::vector<std::vector<Types::Core::DateAndTime>> wrongdetid_pulsetimes;
143 std::vector<std::vector<double>> wrongdetid_tofs;
144
148 std::size_t first_event;
149 std::size_t max_events;
150
153
157 std::map<int64_t, bool> spectraLoadMap;
158
163
166
169
171 std::vector<detid_t> mSEids;
172 std::map<size_t, detid_t> mSEmap;
173 std::vector<std::vector<int64_t>> mSEpulseids;
174 std::vector<std::vector<double>> mSEtofs;
175
181
182 void loadPixelMap(const std::string &filename);
183
184 void openEventFile(const std::string &filename);
185
186 void readPulseidFile(const std::string &filename, const bool throwError);
187
188 void runLoadInstrument(const std::string &eventfilename, const API::MatrixWorkspace_sptr &localWorkspace);
189
190 inline void fixPixelId(PixelType &pixel, uint32_t &period) const;
191
193
194 void procEventsLinear(DataObjects::EventWorkspace_sptr &workspace,
195 std::vector<Types::Event::TofEvent> **arrayOfVectors, DasEvent *event_buffer,
196 size_t current_event_buffer_size, size_t fileOffset, bool dbprint);
197
198 void setProtonCharge(DataObjects::EventWorkspace_sptr &workspace);
199
200 void addToWorkspaceLog(const std::string &logtitle, size_t mindex);
201
202 void processImbedLogs();
203
204 void debugOutput(bool doit, size_t mindex);
205
206 void unmaskVetoEventIndex();
207
208 API::MatrixWorkspace_sptr generateEventDistribtionWorkspace();
209
210 void createOutputWorkspace(const std::string &event_filename);
211
213 void processInvestigationInputs();
214};
215} // namespace DataHandling
216} // namespace Mantid
IPeaksWorkspace_sptr workspace
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 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.
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.