9#include <nexus/NeXusFile.hpp>
26 file.openData(
"event_time_zero");
29 if (!file.hasAttr(
"offset"))
33 Mantid::Types::Core::DateAndTime start(
startTime);
36 const auto heldTimeZeroType = file.getInfo().type;
39 if (heldTimeZeroType == ::NeXus::FLOAT64) {
40 std::vector<double> seconds;
41 file.getData(seconds);
44 if (seconds.size() == 0)
45 throw std::runtime_error(
"event_time_zero field has no data!");
47 std::transform(seconds.cbegin(), seconds.cend(), std::back_inserter(
pulseTimes),
48 [start](
double seconds) { return start + seconds; });
49 }
else if (heldTimeZeroType == ::NeXus::UINT64) {
50 std::vector<uint64_t> nanoseconds;
51 file.getData(nanoseconds);
54 if (nanoseconds.size() == 0)
55 throw std::runtime_error(
"event_time_zero field has no data!");
57 std::transform(nanoseconds.cbegin(), nanoseconds.cend(), std::back_inserter(
pulseTimes),
58 [start](int64_t nanoseconds) { return start + nanoseconds; });
60 throw std::invalid_argument(
"Unsupported type for event_time_zero");
76 if (times.size() == 0)
BankPulseTimes(::NeXus::File &file, const std::vector< int > &pNumbers)
Constructor with NeXus::File.
static const unsigned int FirstPeriod
Starting number for assigning periods.
std::string startTime
String describing the start time.
std::vector< int > periodNumbers
Vector of period numbers corresponding to each pulse.
bool equals(size_t otherNumPulse, const std::string &otherStartTime)
Equals.
std::vector< Mantid::Types::Core::DateAndTime > pulseTimes
Array of the pulse times.