Mantid
Loading...
Searching...
No Matches
LoadEventNexus.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 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 +
8
9#include "MantidAPI/Axis.h"
14#include "MantidAPI/Run.h"
15#include "MantidAPI/Sample.h"
25#include "MantidIndexing/IndexInfo.h"
33#include "MantidKernel/Timer.h"
37#include "MantidNexus/NexusFile.h"
39
40#include <H5Cpp.h>
41#include <boost/format.hpp>
42#include <memory>
43
44#include <regex>
45
46using Mantid::Types::Core::DateAndTime;
47using std::map;
48using std::string;
49using std::vector;
50
51namespace Mantid::DataHandling {
52
54
55using namespace Kernel;
56using namespace DateAndTimeHelpers;
57using namespace Geometry;
58using namespace API;
59using namespace DataObjects;
60using Types::Core::DateAndTime;
61
62namespace {
63const std::vector<std::string> binningModeNames{"Default", "Linear", "Logarithmic"};
64enum class BinningMode { DEFAULT, LINEAR, LOGARITHMIC, enum_count };
66
67const std::string LOG_CHARGE_NAME("proton_charge");
68
69namespace PropertyNames {
70const std::string COMPRESS_TOL("CompressTolerance");
71const std::string COMPRESS_MODE("CompressBinningMode");
72const std::string BAD_PULSES_CUTOFF("FilterBadPulsesLowerCutoff");
73} // namespace PropertyNames
74} // namespace
75
76bool doPerformISISEventShift(Nexus::File &file, std::string &topEntryName) {
77 std::string detectorEventsAddr = std::format("/{}/detector_1_events", topEntryName);
78 if (!file.hasAddress(detectorEventsAddr)) { // not an isis file
79 return false;
80 }
81
82 const std::string eventTimeShiftAddr(detectorEventsAddr + "/event_time_offset_shift");
83 if (file.hasAddress(eventTimeShiftAddr)) { // almost certainly an isis file
84 std::string eventShiftType;
85 file.readData(eventTimeShiftAddr, eventShiftType);
86 return !(eventShiftType == "random"); // event correction already applied
87 }
88
89 const std::string programNameAddr = std::format("/{}/program_name", topEntryName);
90 if (file.hasAddress(programNameAddr)) { // check for ISIS control program
91 std::string program_name;
92 file.readData(programNameAddr, program_name);
93 if (program_name == "ISISICP.EXE") {
94 return true;
95 }
96 }
97 return false;
98}
99
100//----------------------------------------------------------------------------------------------
104 : filter_tof_min(0), filter_tof_max(0), m_specMin(0), m_specMax(0), longest_tof(0), shortest_tof(0), bad_tofs(0),
105 discarded_events(0), compressEvents(false), m_instrument_loaded_correctly(false), loadlogs(false),
106 event_id_is_spec(false) {
108}
109
110//----------------------------------------------------------------------------------------------
118 int confidence = 0;
119 if (descriptor.classTypeExists("NXevent_data")) {
120 if (descriptor.isEntry("/entry", "NXentry") || descriptor.isEntry("/raw_data_1", "NXentry")) {
121 confidence = 80;
122 }
123 }
124
125 return confidence;
126}
127
128//----------------------------------------------------------------------------------------------
132 const std::vector<std::string> exts{".nxs.h5", ".nxs", "_event.nxs"};
133 this->declareProperty(std::make_unique<FileProperty>("Filename", "", FileProperty::Load, exts),
134 "The name of the Event NeXus file to read, including its full or "
135 "relative path. "
136 "The file name is typically of the form INST_####_event.nxs (N.B. case "
137 "sensitive if running on Linux).");
138
139 this->declareProperty(std::make_unique<WorkspaceProperty<Workspace>>("OutputWorkspace", "", Direction::Output),
140 "The name of the output EventWorkspace or WorkspaceGroup in which to "
141 "load the EventNexus file.");
142
143 declareProperty(std::make_unique<PropertyWithValue<string>>("NXentryName", "", Direction::Input),
144 "Optional: Name of the NXentry to load if it's not the default.");
145
146 declareProperty(std::make_unique<PropertyWithValue<double>>("FilterByTofMin", EMPTY_DBL(), Direction::Input),
147 "Optional: To exclude events that do not fall within a range "
148 "of times-of-flight. "
149 "This is the minimum accepted value in microseconds. Keep "
150 "blank to load all events.");
151
152 declareProperty(std::make_unique<PropertyWithValue<double>>("FilterByTofMax", EMPTY_DBL(), Direction::Input),
153 "Optional: To exclude events that do not fall within a range "
154 "of times-of-flight. "
155 "This is the maximum accepted value in microseconds. Keep "
156 "blank to load all events.");
157
158 declareProperty(std::make_unique<PropertyWithValue<double>>("FilterByTimeStart", EMPTY_DBL(), Direction::Input),
159 "Optional: To only include events after the provided start "
160 "time, in seconds (relative to the start of the run).");
161
162 declareProperty(std::make_unique<PropertyWithValue<double>>("FilterByTimeStop", EMPTY_DBL(), Direction::Input),
163 "Optional: To only include events before the provided stop "
164 "time, in seconds (relative to the start of the run).");
165
167 std::make_unique<PropertyWithValue<double>>(PropertyNames::BAD_PULSES_CUTOFF, EMPTY_DBL(), Direction::Input),
168 "Optional: To filter bad pulses set the Lower Cutoff percentage to use.");
169
170 std::string grp1 = "Filter Events";
171 setPropertyGroup("FilterByTofMin", grp1);
172 setPropertyGroup("FilterByTofMax", grp1);
173 setPropertyGroup("FilterByTimeStart", grp1);
174 setPropertyGroup("FilterByTimeStop", grp1);
175 setPropertyGroup("FilterBadPulsesLowerCutoff", grp1);
176
177 declareProperty(std::make_unique<ArrayProperty<string>>("BankName", Direction::Input),
178 "Optional: To only include events from one bank. Any bank "
179 "whose name does not match the given string will have no "
180 "events.");
181
182 declareProperty(std::make_unique<PropertyWithValue<bool>>("SingleBankPixelsOnly", true, Direction::Input),
183 "Optional: Only applies if you specified a single bank to "
184 "load with BankName. "
185 "Only pixels in the specified bank will be created if true; "
186 "all of the instrument's pixels will be created otherwise.");
187 setPropertySettings("SingleBankPixelsOnly", std::make_unique<VisibleWhenProperty>("BankName", IS_NOT_DEFAULT));
188
189 std::string grp2 = "Loading a Single Bank";
190 setPropertyGroup("BankName", grp2);
191 setPropertyGroup("SingleBankPixelsOnly", grp2);
192
193 declareProperty(std::make_unique<PropertyWithValue<bool>>("Precount", true, Direction::Input),
194 "Pre-count the number of events in each pixel before allocating memory "
195 "(optional, default True). "
196 "This can significantly reduce memory use and memory fragmentation; it "
197 "may also speed up loading.");
198
200 std::make_unique<PropertyWithValue<double>>(PropertyNames::COMPRESS_TOL, EMPTY_DBL(), Direction::Input),
201 "CompressEvents while loading (optional, default: off). "
202 "This specified the tolerance to use (in microseconds) when compressing where positive is linear tolerance, "
203 "negative is logorithmic tolerance, and zero indicates that time-of-flight must be identical to compress.");
205 PropertyNames::COMPRESS_MODE, binningModeNames[size_t(BinningMode::DEFAULT)],
206 std::make_shared<Mantid::Kernel::StringListValidator>(binningModeNames),
207 "Optional. "
208 "Binning behavior can be specified in the usual way through sign of binwidth and other properties ('Default'); "
209 "or can be set to one of the allowed binning modes. "
210 "This will override all other specification or default behavior.");
211
212 auto mustBePositive = std::make_shared<BoundedValidator<int>>();
213 mustBePositive->setLower(1);
214 declareProperty("ChunkNumber", EMPTY_INT(), mustBePositive,
215 "If loading the file by sections ('chunks'), this is the "
216 "section number of this execution of the algorithm.");
217 declareProperty("TotalChunks", EMPTY_INT(), mustBePositive,
218 "If loading the file by sections ('chunks'), this is the "
219 "total number of sections.");
220 // TotalChunks is only meaningful if ChunkNumber is set
221 // Would be nice to be able to restrict ChunkNumber to be <= TotalChunks at
222 // validation
223 setPropertySettings("TotalChunks", std::make_unique<VisibleWhenProperty>("ChunkNumber", IS_NOT_DEFAULT));
224
225 std::string grp3 = "Reduce Memory Use";
226 setPropertyGroup("Precount", grp3);
227 setPropertyGroup(PropertyNames::COMPRESS_TOL, grp3);
228 setPropertyGroup(PropertyNames::COMPRESS_MODE, grp3);
229 setPropertyGroup("ChunkNumber", grp3);
230 setPropertyGroup("TotalChunks", grp3);
231
232 declareProperty(std::make_unique<PropertyWithValue<bool>>("LoadMonitors", false, Direction::Input),
233 "Load the monitors from the file (optional, default False).");
234
235 std::vector<std::string> options{"", "Events", "Histogram"};
236 declareProperty("MonitorsLoadOnly", "", std::make_shared<Kernel::StringListValidator>(options),
237 "If multiple repesentations exist, which one to load. "
238 "Default is to load the one that is present.");
239
240 declareProperty(std::make_unique<PropertyWithValue<double>>("FilterMonByTofMin", EMPTY_DBL(), Direction::Input),
241 "Optional: To exclude events from monitors that do not fall "
242 "within a range of times-of-flight. "
243 "This is the minimum accepted value in microseconds.");
244
245 declareProperty(std::make_unique<PropertyWithValue<double>>("FilterMonByTofMax", EMPTY_DBL(), Direction::Input),
246 "Optional: To exclude events from monitors that do not fall "
247 "within a range of times-of-flight. "
248 "This is the maximum accepted value in microseconds.");
249
250 declareProperty(std::make_unique<PropertyWithValue<double>>("FilterMonByTimeStart", EMPTY_DBL(), Direction::Input),
251 "Optional: To only include events from monitors after the "
252 "provided start time, in seconds (relative to the start of "
253 "the run).");
254
255 declareProperty(std::make_unique<PropertyWithValue<double>>("FilterMonByTimeStop", EMPTY_DBL(), Direction::Input),
256 "Optional: To only include events from monitors before the "
257 "provided stop time, in seconds (relative to the start of "
258 "the run).");
259
260 setPropertySettings("MonitorsLoadOnly", std::make_unique<VisibleWhenProperty>("LoadMonitors", IS_EQUAL_TO, "1"));
261 auto asEventsIsOn = [] {
262 std::unique_ptr<IPropertySettings> prop = std::make_unique<VisibleWhenProperty>("LoadMonitors", IS_EQUAL_TO, "1");
263 return prop;
264 };
265 setPropertySettings("FilterMonByTofMin", asEventsIsOn());
266 setPropertySettings("FilterMonByTofMax", asEventsIsOn());
267 setPropertySettings("FilterMonByTimeStart", asEventsIsOn());
268 setPropertySettings("FilterMonByTimeStop", asEventsIsOn());
269
270 std::string grp4 = "Monitors";
271 setPropertyGroup("LoadMonitors", grp4);
272 setPropertyGroup("MonitorsLoadOnly", grp4);
273 setPropertyGroup("FilterMonByTofMin", grp4);
274 setPropertyGroup("FilterMonByTofMax", grp4);
275 setPropertyGroup("FilterMonByTimeStart", grp4);
276 setPropertyGroup("FilterMonByTimeStop", grp4);
277
278 declareProperty("SpectrumMin", EMPTY_INT(), mustBePositive, "The number of the first spectrum to read.");
279 declareProperty("SpectrumMax", EMPTY_INT(), mustBePositive, "The number of the last spectrum to read.");
280 declareProperty(std::make_unique<ArrayProperty<int32_t>>("SpectrumList"),
281 "A comma-separated list of individual spectra to read.");
282
283 declareProperty(std::make_unique<PropertyWithValue<bool>>("MetaDataOnly", false, Direction::Input),
284 "If true, only the meta data and sample logs will be loaded.");
285
286 declareProperty(std::make_unique<PropertyWithValue<bool>>("LoadLogs", true, Direction::Input),
287 "Load only the Sample/DAS logs from the file (default True).");
288
289 declareProperty(std::make_unique<PropertyWithValue<bool>>("LoadAllLogs", false, Direction::Input),
290 "Load all the logs from the nxs, without checking or processing them; if checked, LoadLogs will be "
291 "ignored; use with caution");
292
293 std::vector<std::string> loadType{"Default", "Multiprocess (experimental)"};
294 auto loadTypeValidator = std::make_shared<StringListValidator>(loadType);
296 "LoadType", "Default", loadTypeValidator,
297 "Deprecated feature. This option has no effect on algorithm behavior and will be removed in a future release.");
298
299 declareProperty(std::make_unique<PropertyWithValue<bool>>("LoadNexusInstrumentXML", true, Direction::Input),
300 "Reads the embedded Instrument XML from the NeXus file "
301 "(optional, default True). ");
302
303 declareProperty("NumberOfBins", 500, mustBePositive,
304 "The number of bins intially defined. Use Rebin to change "
305 "the binning later. If there is no data loaded, or you "
306 "select meta data only you will only get 1 bin.");
307
308 // Flexible log loading
309 declareProperty(std::make_unique<PropertyWithValue<std::vector<std::string>>>("AllowList", std::vector<std::string>(),
311 "If specified, only these logs will be loaded from the file (each "
312 "separated by a space).");
313 declareProperty(std::make_unique<PropertyWithValue<std::vector<std::string>>>("BlockList", std::vector<std::string>(),
315 "If specified, these logs will NOT be loaded from the file (each "
316 "separated by a space).");
317}
318
319std::map<std::string, std::string> LoadEventNexus::validateInputs() {
320
321 // Warn deprecated experimental feature, but do not throw error
322 if (!isDefault("LoadType")) {
323 g_log.warning() << "The experimental multiprocess loader has been discontinued. The default loader will be used "
324 "instead. Please remove use of this property from all scripts.";
325 }
326 setProperty("LoadType", "Default");
327
328 std::map<std::string, std::string> result;
329
330 if (!isDefault(PropertyNames::BAD_PULSES_CUTOFF)) {
331 const double cutoff = getProperty(PropertyNames::BAD_PULSES_CUTOFF);
332 if (cutoff < 0 || cutoff > 100)
333 result[PropertyNames::BAD_PULSES_CUTOFF] = "Must be empty or between 0 and 100";
334 }
335
336 return result;
337}
338
339//----------------------------------------------------------------------------------------------
343 std::string nxentryProperty = getProperty("NXentryName");
344 if (!nxentryProperty.empty()) {
345 m_top_entry_name = nxentryProperty;
346 return;
347 }
348
349 std::string firstGoodEntry("");
350 std::set<std::string> goodEntries{"entry", "raw_data_1"};
351 auto allEntries = m_file->getEntries();
352 for (std::string goodEntry : goodEntries) {
353 if (allEntries.count(goodEntry) != 0 && allEntries[goodEntry] != "SDS") {
354 firstGoodEntry = std::move(goodEntry);
355 break;
356 }
357 }
358 m_top_entry_name = std::move(firstGoodEntry);
359 if (m_top_entry_name.empty()) {
360 g_log.error() << "Unable to determine name of top level NXentry - assuming \"entry\".\n";
361 m_top_entry_name = "entry";
362 }
363}
364
365template <typename T> void LoadEventNexus::filterDuringPause(T workspace) {
366 try {
367 if ((!ConfigService::Instance().hasProperty("loadeventnexus.keeppausedevents")) &&
368 (m_ws->run().getLogData("pause")->size() > 1)) {
369 g_log.notice("Filtering out events when the run was marked as paused. "
370 "Set the loadeventnexus.keeppausedevents configuration "
371 "property to override this.");
372
373 auto filter = createChildAlgorithm("FilterByLogValue");
374 filter->setProperty("InputWorkspace", workspace);
375 filter->setProperty("OutputWorkspace", workspace);
376 filter->setProperty("LogName", "pause");
377 // The log value is set to 1 when the run is paused, 0 otherwise.
378 filter->setProperty("MinimumValue", 0.0);
379 filter->setProperty("MaximumValue", 0.0);
380 filter->setProperty("LogBoundary", "Left");
381 filter->execute();
382 }
383 } catch (Exception::NotFoundError &) {
384 // No "pause" log, just carry on
385 }
386}
387
388template <>
389void LoadEventNexus::filterDuringPause<EventWorkspaceCollection_sptr>(EventWorkspaceCollection_sptr workspace) {
390 // We provide a function pointer to the filter method of the object
391 using std::placeholders::_1;
392 auto func = std::bind(&LoadEventNexus::filterDuringPause<MatrixWorkspace_sptr>, this, _1);
393 workspace->applyFilterInPlace(func);
394}
395
396//-----------------------------------------------------------------------------
401template <typename T>
402T LoadEventNexus::filterEventsByTime(T workspace, Mantid::Types::Core::DateAndTime &startTime,
403 Mantid::Types::Core::DateAndTime &stopTime) {
404 auto filterByTime = createChildAlgorithm("FilterByTime");
405 g_log.information("Filtering events by time...");
406 filterByTime->setProperty("InputWorkspace", workspace);
407 // sample log already filtered by time so use absolute times to be safe
408 filterByTime->setProperty("AbsoluteStartTime", startTime.toISO8601String());
409 filterByTime->setProperty("AbsoluteStopTime", stopTime.toISO8601String());
410 filterByTime->execute();
411 return filterByTime->getProperty("OutputWorkspace");
412}
413
414template <>
416LoadEventNexus::filterEventsByTime<EventWorkspaceCollection_sptr>(EventWorkspaceCollection_sptr workspace,
417 Mantid::Types::Core::DateAndTime &startTime,
418 Mantid::Types::Core::DateAndTime &stopTime) {
419 // We provide a function pointer to the filter method of the object
420 using std::placeholders::_1;
421 auto func = std::bind(&LoadEventNexus::filterEventsByTime<EventWorkspace_sptr>, this, _1, startTime, stopTime);
422 workspace->applyFilter(func);
423 return workspace;
424}
425
426//------------------------------------------------------------------------------------------------
431 // Retrieve the filename from the properties
432 m_filename = getPropertyValue("Filename");
433
434 compressEvents = !isDefault(PropertyNames::COMPRESS_TOL);
435 compressTolerance = getProperty(PropertyNames::COMPRESS_TOL);
436 if (compressEvents) {
437 BINMODE mode = getPropertyValue(PropertyNames::COMPRESS_MODE);
438 if (mode == BinningMode::LINEAR)
440 else if (mode == BinningMode::LOGARITHMIC)
441 compressTolerance = -1. * std::fabs(compressTolerance);
442 }
443
444 loadlogs = getProperty("LoadLogs");
445
446 // Check to see if the monitors need to be loaded later
447 bool load_monitors = this->getProperty("LoadMonitors");
448
449 // this must make absolutely sure that m_file is a valid (and open)
450 // Nexus::File object
452
454
455 // Initialize progress reporting.
456 int reports = 3;
457 if (load_monitors)
458 reports++;
459 Progress prog(this, 0.0, 0.3, reports);
460
461 // Load the detector events
462 m_ws = std::make_shared<EventWorkspaceCollection>(); // Algorithm currently
463 // relies on an
464
465 // object-level workspace ptr
466 loadEvents(&prog, false); // Do not load monitor blocks
467
468 if (discarded_events > 0) {
470 << " events were encountered coming from pixels which "
471 "are not in the Instrument Definition File."
472 "These events were discarded.\n";
473 }
474
475 // If the run was paused at any point, filter out those events (SNS only, I
476 // think)
477 filterDuringPause(m_ws->getSingleHeldWorkspace());
478
479 // add filename
480 m_ws->mutableRun().addProperty("Filename", m_filename);
481 // Save output
482 this->setProperty("OutputWorkspace", m_ws->combinedWorkspace());
483
484 // close the file since LoadNexusMonitors will take care of its own file
485 // handle
486 m_file->close();
487
488 // Load the monitors with child algorithm 'LoadNexusMonitors'
489 if (load_monitors) {
490 prog.report("Loading monitors");
491 this->runLoadMonitors();
492 }
493}
494
495std::pair<DateAndTime, DateAndTime> firstLastPulseTimes(Nexus::File &file, Kernel::Logger &logger) {
496 file.openData("event_time_zero");
497 DateAndTime offset;
498 // According to the Nexus standard, if the offset is not present, it implies
499 // the offset is and absolute timestamp, which is relative to the start of
500 // Unix epoch (https://manual.nexusformat.org/classes/base_classes/NXlog.html)
501 if (!file.hasAttr("offset")) {
502 offset = DateAndTime("1970-01-01T00:00:00Z");
503 logger.warning("In firstLastPulseTimes: no ISO8601 offset attribute "
504 "provided for event_time_zero, using UNIX epoch instead");
505 } else {
506 std::string isooffset; // ISO8601 offset
507 file.getAttr("offset", isooffset);
508 offset = DateAndTime(isooffset);
509 }
510 std::string units; // time units
511 if (file.hasAttr("units"))
512 file.getAttr("units", units);
513 // Read in the pulse times
514 auto pulse_times = Nexus::IOHelper::readNexusVector<double>(file, "event_time_zero");
515 // Remember to close the entry
516 file.closeData();
517 if (pulse_times.empty()) {
518 throw std::invalid_argument("Cannot find run start; event_time_zero contains no pulse times");
519 }
520 // Convert to seconds
521 auto conv = Kernel::Units::timeConversionValue(units, "s");
522 return std::make_pair(DateAndTime(pulse_times.front() * conv, 0.0) + offset.totalNanoseconds(),
523 DateAndTime(pulse_times.back() * conv, 0.0) + offset.totalNanoseconds());
524} // namespace DataHandling
525
537std::size_t numEvents(Nexus::File &file, bool &hasTotalCounts, bool &oldNeXusFileNames, const std::string &prefix) {
538 // try getting the value of total_counts
539 if (hasTotalCounts) {
540 hasTotalCounts = false;
541 if (file.hasData(prefix + "/total_counts")) {
542 try {
543 file.openData("total_counts");
544 auto info = file.getInfo();
545 file.closeData();
546 if (info.type == NXnumtype::UINT64) {
547 uint64_t eventCount;
548 file.readData("total_counts", eventCount);
549 hasTotalCounts = true;
550 return eventCount;
551 }
552 } catch (Nexus::Exception const &) {
553 }
554 }
555 }
556
557 // just get the length of the event pixel ids
558 try {
559 if (oldNeXusFileNames)
560 file.openData("event_pixel_id");
561 else
562 file.openData("event_id");
563 } catch (Nexus::Exception const &) {
564 // Older files (before Nov 5, 2010) used this field.
565 try {
566 file.openData("event_pixel_id");
567 oldNeXusFileNames = true;
568 } catch (Nexus::Exception const &) {
569 // Some groups have neither indicating there are not events here
570 return 0;
571 }
572 }
573
574 size_t numEvents = static_cast<std::size_t>(file.getInfo().dims[0]);
575 file.closeData();
576 return numEvents;
577}
578
592template <typename T>
593std::shared_ptr<BankPulseTimes>
594LoadEventNexus::runLoadNexusLogs(const std::string &nexusfilename, T localWorkspace, API::Algorithm &alg,
595 bool returnpulsetimes, int &nPeriods,
596 std::unique_ptr<const TimeSeriesProperty<int>> &periodLog) {
597 // --------------------- Load DAS Logs -----------------
598 // The pulse times will be empty if not specified in the DAS logs.
599 // BankPulseTimes * out = NULL;
600 std::shared_ptr<BankPulseTimes> out;
601 auto loadLogs = alg.createChildAlgorithm("LoadNexusLogs");
602
603 // Now execute the Child Algorithm. Catch and log any error, but don't stop.
604 try {
605 alg.getLogger().information() << "Loading logs from NeXus file..."
606 << "\n";
607 loadLogs->setPropertyValue("Filename", nexusfilename);
608 loadLogs->setProperty<API::MatrixWorkspace_sptr>("Workspace", localWorkspace);
609 try {
610 loadLogs->setPropertyValue("NXentryName", alg.getPropertyValue("NXentryName"));
611 } catch (...) {
612 }
613
614 loadLogs->execute();
615
616 const Run &run = localWorkspace->run();
617 // Get the number of periods
618 if (run.hasProperty("nperiods")) {
619 nPeriods = run.getPropertyValueAsType<int>("nperiods");
620 }
621 // Get the period log. Map of DateAndTime to Period int values.
622 if (run.hasProperty("period_log")) {
623 const auto *temp = run.getProperty("period_log");
624 // Check for corrupted period logs
625 std::string status = "";
626 std::unique_ptr<TimeSeriesProperty<int>> tempPeriodLog(dynamic_cast<TimeSeriesProperty<int> *>(temp->clone()));
627 nPeriods = checkForCorruptedPeriods(std::move(tempPeriodLog), periodLog, nPeriods, nexusfilename, status);
628 if (!status.empty())
629 alg.getLogger().warning(status);
630 }
631
632 // If successful, we can try to load the pulse times
633 std::vector<Types::Core::DateAndTime> temp;
634 if (localWorkspace->run().hasProperty("proton_charge")) {
635 const auto *log =
636 dynamic_cast<Kernel::TimeSeriesProperty<double> *>(localWorkspace->mutableRun().getProperty("proton_charge"));
637 if (log)
638 temp = log->timesAsVector();
639 }
640 if (returnpulsetimes)
641 out = std::make_shared<BankPulseTimes>(temp);
642
643 // Use the first pulse as the run_start time.
644 if (!temp.empty()) {
645 if (temp[0] < Types::Core::DateAndTime("1991-01-01T00:00:00"))
646 alg.getLogger().warning() << "Found entries in the proton_charge "
647 "sample log with invalid pulse time!\n";
648
649 Types::Core::DateAndTime run_start = localWorkspace->getFirstPulseTime();
650 // add the start of the run as a ISO8601 date/time string. The start =
651 // first non-zero time.
652 // (this is used in LoadInstrument to find the right instrument file to
653 // use).
654 localWorkspace->mutableRun().addProperty("run_start", run_start.toISO8601String(), true);
655 } else if (run.hasProperty("start_time")) {
656 localWorkspace->mutableRun().addProperty("run_start", run.getProperty("start_time")->value(), true);
657 } else {
658 alg.getLogger().warning() << "Empty proton_charge sample log. You will "
659 "not be able to filter by time.\n";
660 }
662 try {
665 localWorkspace->mutableRun().setGoniometer(gm, true);
666 } catch (std::runtime_error &) {
667 }
668 } catch (const InvalidLogPeriods &) {
669 // Rethrow so LoadEventNexus fails.
670 // If we don't, Mantid will crash.
671 throw;
672 } catch (...) {
673 alg.getLogger().error() << "Error while loading Logs from SNS Nexus. Some "
674 "sample logs may be missing."
675 << "\n";
676 return out;
677 }
678 return out;
679}
680
696template <typename T>
697std::shared_ptr<BankPulseTimes> LoadEventNexus::runLoadNexusLogs(
698 const std::string &nexusfilename, T localWorkspace, API::Algorithm &alg, bool returnpulsetimes, int &nPeriods,
699 std::unique_ptr<const TimeSeriesProperty<int>> &periodLog, const std::vector<std::string> &allow_list,
700 const std::vector<std::string> &block_list) {
701 // --------------------- Load DAS Logs -----------------
702 // The pulse times will be empty if not specified in the DAS logs.
703 // BankPulseTimes * out = NULL;
704 std::shared_ptr<BankPulseTimes> out;
705 auto loadLogs = alg.createChildAlgorithm("LoadNexusLogs");
706
707 // Now execute the Child Algorithm. Catch and log any error, but don't stop.
708 try {
709 alg.getLogger().information() << "Loading logs from NeXus file..."
710 << "\n";
711 loadLogs->setPropertyValue("Filename", nexusfilename);
712 loadLogs->setProperty<API::MatrixWorkspace_sptr>("Workspace", localWorkspace);
713 loadLogs->setProperty<std::vector<std::string>>("AllowList", allow_list);
714 loadLogs->setProperty<std::vector<std::string>>("BlockList", block_list);
715
716 try {
717 loadLogs->setPropertyValue("NXentryName", alg.getPropertyValue("NXentryName"));
718 } catch (...) {
719 }
720
721 loadLogs->execute();
722
723 const Run &run = localWorkspace->run();
724 // Get the number of periods
725 if (run.hasProperty("nperiods")) {
726 nPeriods = run.getPropertyValueAsType<int>("nperiods");
727 }
728 // Get the period log. Map of DateAndTime to Period int values.
729 if (run.hasProperty("period_log")) {
730 auto *temp = run.getProperty("period_log");
731 std::string status = "";
732 // Check for corrupted period logs
733 std::unique_ptr<TimeSeriesProperty<int>> tempPeriodLog(dynamic_cast<TimeSeriesProperty<int> *>(temp->clone()));
734 nPeriods = checkForCorruptedPeriods(std::move(tempPeriodLog), periodLog, nPeriods, nexusfilename, status);
735 if (!status.empty())
736 alg.getLogger().warning(status);
737 }
738
739 // If successful, we can try to load the pulse times
740 std::vector<Types::Core::DateAndTime> temp;
741 if (localWorkspace->run().hasProperty("proton_charge")) {
742 auto *log =
743 dynamic_cast<Kernel::TimeSeriesProperty<double> *>(localWorkspace->mutableRun().getProperty("proton_charge"));
744 if (log)
745 temp = log->timesAsVector();
746 }
747 if (returnpulsetimes)
748 out = std::make_shared<BankPulseTimes>(temp);
749
750 // Use the first pulse as the run_start time.
751 if (!temp.empty()) {
752 if (temp[0] < Types::Core::DateAndTime("1991-01-01T00:00:00"))
753 alg.getLogger().warning() << "Found entries in the proton_charge "
754 "sample log with invalid pulse time!\n";
755
756 Types::Core::DateAndTime run_start = localWorkspace->getFirstPulseTime();
757 // add the start of the run as a ISO8601 date/time string. The start =
758 // first non-zero time.
759 // (this is used in LoadInstrument to find the right instrument file to
760 // use).
761 localWorkspace->mutableRun().addProperty("run_start", run_start.toISO8601String(), true);
762 } else {
763 alg.getLogger().warning() << "Empty proton_charge sample log. You will "
764 "not be able to filter by time.\n";
765 }
767 try {
770 localWorkspace->mutableRun().setGoniometer(gm, true);
771 } catch (std::runtime_error &) {
772 }
773 } catch (const InvalidLogPeriods &) {
774 // Rethrow so LoadEventNexus fails.
775 // If we don't, Mantid will crash.
776 throw;
777 } catch (...) {
778 alg.getLogger().error() << "Error while loading Logs from SNS Nexus. Some "
779 "sample logs may be missing."
780 << "\n";
781 return out;
782 }
783 return out;
784}
785
801 std::unique_ptr<const TimeSeriesProperty<int>> &periodLog,
802 const int &nPeriods, const std::string &nexusfilename,
803 std::string &status) {
804 const auto valuesAsVector = tempPeriodLog->valuesAsVector();
805 const auto nPeriodsInLog = *std::max_element(valuesAsVector.begin(), valuesAsVector.end());
806 int numberOfValidPeriods = nPeriodsInLog;
807 status = "";
808
809 // Check for historic files
810 if (nPeriodsInLog == 0 && nPeriods == 1) {
811 // "modernize" the local copy here by making period_log
812 // a vector of 1s
813 const std::vector<int> newValues(tempPeriodLog->realSize(), 1);
814 const auto times = tempPeriodLog->timesAsVector();
815 periodLog.reset(new const TimeSeriesProperty<int>("period_log", times, newValues));
816 numberOfValidPeriods = 1;
817 } else if (nPeriodsInLog < nPeriods) {
818 status = boost::str(
819 boost::format(
820 "The number of periods specified in the file (%1%) is greater than the maximum period in the data (%2%).") %
821 nPeriods % nPeriodsInLog);
822 } else if (nPeriodsInLog > nPeriods) {
823 // Sanity check here that period_log only contains period numbers up to
824 // nperiods. These values can be different due to instrument noise, and
825 // cause undescriptive crashes if not caught.
826 // We throw here to make it clear
827 // that the file is corrupted and must be manually assessed.
828 const auto msg = "File " + nexusfilename +
829 " has been corrupted. The log framelog/period_log/value "
830 "contains " +
831 std::to_string(nPeriodsInLog) + " periods, but periods/number contains " +
832 std::to_string(nPeriods) + ". This file should be manually inspected and corrected.";
833 throw InvalidLogPeriods(msg);
834 } else {
835 // periodLog should point to a copy of the period logs
836 periodLog = std::make_unique<const TimeSeriesProperty<int>>(*tempPeriodLog);
837 tempPeriodLog.reset();
838 }
839 return numberOfValidPeriods;
840}
841
856template <>
857std::shared_ptr<BankPulseTimes> LoadEventNexus::runLoadNexusLogs<EventWorkspaceCollection_sptr>(
858 const std::string &nexusfilename, EventWorkspaceCollection_sptr localWorkspace, API::Algorithm &alg,
859 bool returnpulsetimes, int &nPeriods, std::unique_ptr<const TimeSeriesProperty<int>> &periodLog) {
860 auto ws = localWorkspace->getSingleHeldWorkspace();
861 auto ret = runLoadNexusLogs<MatrixWorkspace_sptr>(nexusfilename, ws, alg, returnpulsetimes, nPeriods, periodLog);
862 return ret;
863}
864
881template <>
882std::shared_ptr<BankPulseTimes> LoadEventNexus::runLoadNexusLogs<EventWorkspaceCollection_sptr>(
883 const std::string &nexusfilename, EventWorkspaceCollection_sptr localWorkspace, API::Algorithm &alg,
884 bool returnpulsetimes, int &nPeriods, std::unique_ptr<const TimeSeriesProperty<int>> &periodLog,
885 const std::vector<std::string> &allow_list, const std::vector<std::string> &block_list) {
886 auto ws = localWorkspace->getSingleHeldWorkspace();
887 auto ret = runLoadNexusLogs<MatrixWorkspace_sptr>(nexusfilename, ws, alg, returnpulsetimes, nPeriods, periodLog,
888 allow_list, block_list);
889 return ret;
890}
891
892//-----------------------------------------------------------------------------
901void LoadEventNexus::loadEvents(API::Progress *const prog, const bool monitors) {
902 bool metaDataOnly = getProperty("MetaDataOnly");
903
904 // Get the time filters
905 setTimeFilters(monitors);
906
907 // Get the log filter if provided
908 std::vector<std::string> allow_list = getProperty("AllowList"); // if not empty, only these logs will be loaded
909 std::vector<std::string> block_list = getProperty("BlockList"); // if not empty, these logs won't be loaded
910
911 // The run_start will be loaded from the pulse times.
912 DateAndTime run_start(0, 0);
913 bool takeTimesFromEvents = false;
914 // Initialize the counter of bad TOFs
915 bad_tofs = 0;
916 int nPeriods = 1;
917 auto periodLog = std::make_unique<const TimeSeriesProperty<int>>("period_log");
918
919 bool loadAllLogs = getProperty("LoadAllLogs"); // load all logs, not just DAS logs.
920
921 if (loadlogs) {
922 if (!loadAllLogs) {
923 prog->doReport("Loading DAS logs");
924
925 if (allow_list.empty() && block_list.empty()) {
927 runLoadNexusLogs<EventWorkspaceCollection_sptr>(m_filename, m_ws, *this, true, nPeriods, periodLog);
928 } else {
929 m_allBanksPulseTimes = runLoadNexusLogs<EventWorkspaceCollection_sptr>(m_filename, m_ws, *this, true, nPeriods,
930 periodLog, allow_list, block_list);
931 }
932
933 try {
934 run_start = m_ws->getFirstPulseTime();
936 /*
937 This is added to (a) support legacy behaviour of continuing to take
938 times from the proto_charge log, but (b) allowing a fall back of
939 getting run start and end from actual pulse times within the
940 NXevent_data group. Note that the latter is better Nexus compliant.
941 */
942 takeTimesFromEvents = true;
943 }
944 } else {
945 prog->doReport("Loading all logs");
946 try {
947 // Open NeXus file
948 Nexus::File nxHandle(m_filename, NXaccess::READ);
949 LoadHelper::addNexusFieldsToWsRun(nxHandle, m_ws->mutableRun(), "", true);
950 } catch (Nexus::Exception const &e) {
951 g_log.debug() << "Failed to open nexus file \"" << m_filename << "\" in read mode: " << e.what() << "\n";
952 }
953 }
954 } else {
955 g_log.information() << "Skipping the loading of sample logs!\n"
956 << "Reading the start time directly from /" << m_top_entry_name << "/start_time\n";
957 // start_time is read and set
958 m_file->openAddress("/");
959 m_file->openGroup(m_top_entry_name, "NXentry");
960 std::string tmp;
961 m_file->readData("start_time", tmp);
962 m_file->closeGroup();
963 run_start = createFromSanitizedISO8601(tmp);
964 m_ws->mutableRun().addProperty("run_start", run_start.toISO8601String(), true);
965 }
966
967 // set more properties on the workspace
968 Nexus::NexusDescriptor const &descriptor = m_file->getFileDescriptor();
969 try {
970 // this is a static method that is why it is passing the
971 // file object and the file path
972
973 loadEntryMetadata<EventWorkspaceCollection_sptr>(m_filename, m_ws, m_top_entry_name);
974 } catch (std::runtime_error &e) {
975 // Missing metadata is not a fatal error. Log and go on with your life
976 g_log.error() << "Error loading metadata: " << e.what() << '\n';
977 }
978
979 m_ws->setNPeriods(static_cast<size_t>(nPeriods),
980 periodLog); // This is how many workspaces we are going to make.
981
982 // Make sure you have a non-NULL m_allBanksPulseTimes
983 if (m_allBanksPulseTimes == nullptr) {
984 std::vector<DateAndTime> temp;
985 m_allBanksPulseTimes = std::make_shared<BankPulseTimes>(temp);
986 }
987
988 if (!m_ws->getInstrument() || !m_instrument_loaded_correctly) {
989 // Load the instrument (if not loaded before)
990 prog->report("Loading instrument");
991 // Note that closing an re-opening the file is needed here for loading
992 // instruments directly from the nexus file containing the event data.
993 // This may not be needed in the future if both LoadEventNexus and
994 // LoadInstrument are made to use the same Nexus/HDF5 library
995 m_file->close();
997
999 throw std::runtime_error("Instrument was not initialized correctly! Loading cannot continue.");
1000 // reopen file
1002 }
1003
1004 // top level file information
1005 m_file->openAddress("/");
1006 // Start with the base entry
1007 m_file->openGroup(m_top_entry_name, "NXentry");
1008
1009 // Now we want to go through all the bankN_event entries
1010 vector<string> bankNames;
1011 vector<std::size_t> bankNumEvents;
1012 std::string classType = monitors ? "NXmonitor" : "NXevent_data";
1013 bool oldNeXusFileNames(false);
1014 bool haveWeights = false;
1015 auto firstPulseT = DateAndTime::maximum();
1016 if (m_file->classTypeExists(classType)) {
1017 std::map<std::string, std::string> entries = m_file->getEntries();
1018 for (auto entry : entries) {
1019 if (entry.second != classType) {
1020 continue;
1021 }
1022
1023 // skip entries with junk data
1024 if (entry.first == "bank_error_events" || entry.first == "bank_unmapped_events")
1025 continue;
1026
1027 m_file->openGroup(entry.first, classType);
1028 // get the number of events
1029 const std::string prefix = "/" + m_top_entry_name + "/" + entry.first;
1030 bool hasTotalCounts = true;
1031 std::size_t num = numEvents(*m_file, hasTotalCounts, oldNeXusFileNames, prefix);
1032 bankNames.emplace_back(entry.first);
1033 bankNumEvents.emplace_back(num);
1034 if (takeTimesFromEvents && num > 0) {
1035 /* If we are here, we are loading logs, but have failed to establish
1036 * the run_start from the proton_charge log. We are going to get this
1037 * from our event_time_zero instead
1038 */
1039 auto localFirstLast = firstLastPulseTimes(*m_file, this->g_log);
1040 firstPulseT = std::min(firstPulseT, localFirstLast.first);
1041 }
1042 // Look for weights in simulated file
1043 const std::string absoluteEventWeightName = prefix + "/event_weight";
1044 haveWeights = m_file->hasAddress(absoluteEventWeightName);
1045 m_file->closeGroup();
1046 }
1047 }
1048 if (takeTimesFromEvents)
1049 run_start = firstPulseT;
1050
1052
1053 // Close the 'top entry' group (raw_data_1 for NexusProcessed, etc.)
1054 m_file->closeGroup();
1055
1056 // Delete the output workspace name if it existed
1057 std::string outName = getPropertyValue("OutputWorkspace");
1058 if (AnalysisDataService::Instance().doesExist(outName))
1059 AnalysisDataService::Instance().remove(outName);
1060
1061 // --------------------------- Time filtering
1062 // ------------------------------------
1063 double filter_time_start_sec, filter_time_stop_sec;
1064 filter_time_start_sec = getProperty("FilterByTimeStart");
1065 filter_time_stop_sec = getProperty("FilterByTimeStop");
1066
1067 // Default to ALL pulse times
1068 filter_time_start = Types::Core::DateAndTime::minimum();
1069 filter_time_stop = Types::Core::DateAndTime::maximum();
1070
1071 if (m_allBanksPulseTimes->numberOfPulses() > 0) {
1072 // If not specified, use the limits of doubles. Otherwise, convert from
1073 // seconds to absolute PulseTime
1074 if (filter_time_start_sec != EMPTY_DBL()) {
1075 filter_time_start = run_start + filter_time_start_sec;
1076 m_is_time_filtered = true;
1077 }
1078
1079 if (filter_time_stop_sec != EMPTY_DBL()) {
1080 filter_time_stop = run_start + filter_time_stop_sec;
1081 m_is_time_filtered = true;
1082 }
1083
1084 // Silly values?
1086 std::string msg = "Your ";
1087 if (monitors)
1088 msg += "monitor ";
1089 msg += "filter for time's Stop value is smaller than the Start value.";
1090 throw std::invalid_argument(msg);
1091 }
1092 }
1093
1094 // setup filter bad pulses
1095 filter_bad_pulses = !isDefault(PropertyNames::BAD_PULSES_CUTOFF);
1096
1097 if (filter_bad_pulses) {
1098 double min_pcharge, max_pcharge;
1099 std::tie(min_pcharge, max_pcharge, std::ignore) =
1100 m_ws->run().getBadPulseRange(LOG_CHARGE_NAME, getProperty(PropertyNames::BAD_PULSES_CUTOFF));
1101
1102 const auto *pcharge_log =
1103 dynamic_cast<Kernel::TimeSeriesProperty<double> *>(m_ws->run().getLogData(LOG_CHARGE_NAME));
1104 bad_pulses_timeroi = std::make_shared<TimeROI>(
1105 pcharge_log->makeFilterByValue(min_pcharge, max_pcharge, false, TimeInterval(0, 1), 0., true));
1106 }
1107
1108 if (metaDataOnly) {
1109 // Now, create a default X-vector for histogramming, with just 2 bins.
1110 auto axis = HistogramData::BinEdges{1, static_cast<double>(std::numeric_limits<uint32_t>::max()) * 0.1 - 1};
1111 // Set the binning axis using this.
1112 m_ws->setAllX(axis);
1113
1114 createSpectraMapping(m_filename, monitors, std::vector<std::string>());
1115 return;
1116 }
1117
1118 // --------- Loading only one bank ? ----------------------------------
1119 std::vector<std::string> someBanks = getProperty("BankName");
1120 const bool SingleBankPixelsOnly = getProperty("SingleBankPixelsOnly");
1121 if ((!someBanks.empty()) && (!monitors)) {
1122 std::vector<std::string> eventedBanks;
1123 eventedBanks.reserve(someBanks.size());
1124 std::transform(someBanks.cbegin(), someBanks.cend(), std::back_inserter(eventedBanks),
1125 [](const auto &bank) { return bank + "_events"; });
1126
1127 // check that all of the requested banks are in the file
1128 const auto invalidBank =
1129 std::find_if(eventedBanks.cbegin(), eventedBanks.cend(), [&bankNames](const auto &someBank) {
1130 return std::none_of(bankNames.cbegin(), bankNames.cend(),
1131 [&someBank](const auto &name) { return name == someBank; });
1132 });
1133 if (invalidBank != eventedBanks.cend()) {
1134 throw std::invalid_argument("No entry named '" + *invalidBank + "' was found in the .NXS file.");
1135 }
1136
1137 // change the number of banks to load
1138 bankNames.assign(eventedBanks.cbegin(), eventedBanks.cend());
1139
1140 // TODO this equally weights the banks
1141 bankNumEvents.assign(someBanks.size(), 1);
1142
1143 if (!SingleBankPixelsOnly)
1144 someBanks.clear(); // Marker to load all pixels
1145 }
1146
1147 prog->report("Initializing all pixels");
1148
1149 // Remove unused banks if parameter is set
1150 if (m_ws->getInstrument()->hasParameter("remove-unused-banks")) {
1151 std::vector<double> instrumentUnused = m_ws->getInstrument()->getNumberParameter("remove-unused-banks", true);
1152 if (!instrumentUnused.empty()) {
1153 const auto unused = static_cast<int>(instrumentUnused.front());
1154 if (unused == 1)
1155 deleteBanks(m_ws, bankNames);
1156 }
1157 }
1158 //----------------- Pad Empty Pixels -------------------------------
1159 createSpectraMapping(m_filename, monitors, someBanks);
1160
1161 // Set all (empty) event lists as sorted by pulse time. That way, calling
1162 // SortEvents will not try to sort these empty lists.
1163 for (size_t i = 0; i < m_ws->getNumberHistograms(); i++)
1164 m_ws->getSpectrum(i).setSortOrder(DataObjects::PULSETIME_SORT);
1165
1166 // Count the limits to time of flight
1167 shortest_tof = static_cast<double>(std::numeric_limits<uint32_t>::max()) * 0.1;
1168 longest_tof = 0.;
1169
1170 bool precount = getProperty("Precount");
1171 int chunk = getProperty("ChunkNumber");
1172 int totalChunks = getProperty("TotalChunks");
1173 const auto startTime = std::chrono::high_resolution_clock::now();
1174 DefaultEventLoader::load(this, *m_ws, haveWeights, event_id_is_spec, bankNames, periodLog->valuesAsVector(),
1175 classType, bankNumEvents, oldNeXusFileNames, precount, chunk, totalChunks);
1176 addTimer("loadEvents", startTime, std::chrono::high_resolution_clock::now());
1177
1178 // Info reporting
1179 const std::size_t eventsLoaded = m_ws->getNumberEvents();
1180 g_log.information() << "Read " << eventsLoaded << " events"
1181 << ". Shortest TOF: " << shortest_tof << " microsec; longest TOF: " << longest_tof
1182 << " microsec.\n";
1183
1184 if (shortest_tof < 0)
1185 g_log.warning() << "The shortest TOF was negative! At least 1 event has an "
1186 "invalid time-of-flight.\n";
1187 if (bad_tofs > 0)
1188 g_log.warning() << "Found " << bad_tofs
1189 << " events with TOF > 2e8. This "
1190 "may indicate errors in the raw "
1191 "TOF data.\n";
1192
1193 // Use T0 offset from TOPAZ Parameter file if it exists
1194 if (m_ws->getInstrument()->hasParameter("T0")) {
1195 std::vector<double> instrumentT0 = m_ws->getInstrument()->getNumberParameter("T0", true);
1196 if (!instrumentT0.empty()) {
1197 const double mT0 = instrumentT0.front();
1198 if (mT0 != 0.0) {
1199 auto numHistograms = static_cast<int64_t>(m_ws->getNumberHistograms());
1201 for (int64_t i = 0; i < numHistograms; ++i) {
1203 // Do the offsetting
1204 m_ws->getSpectrum(i).addTof(mT0);
1206 }
1208 // set T0 in the run parameters
1209 API::Run &run = m_ws->mutableRun();
1210 run.addProperty<double>("T0", mT0, true);
1211 }
1212 }
1213 }
1214 // Now, create a default X-vector for histogramming, with just 2 bins.
1215 if (eventsLoaded > 0) {
1216 int nBins = getProperty("NumberOfBins");
1217 auto binEdgesVec = std::vector<double>(nBins + 1);
1218 binEdgesVec[0] = shortest_tof; // left edge is inclusive
1219 binEdgesVec[nBins] = longest_tof + 1; // right edge is exclusive
1220 double binStep = (binEdgesVec[nBins] - binEdgesVec[0]) / nBins;
1221 for (int binIndex = 1; binIndex < nBins; binIndex++) {
1222 binEdgesVec[binIndex] = binEdgesVec[0] + (binStep * binIndex);
1223 }
1224 m_ws->setAllX(HistogramData::BinEdges{binEdgesVec});
1225 } else
1226 m_ws->setAllX(HistogramData::BinEdges{0.0, 1.0});
1227
1228 // if there is time_of_flight load it
1229 if (doPerformISISEventShift(*m_file, m_top_entry_name)) {
1230 adjustTimeOfFlightISISLegacy(*m_file, m_ws, m_top_entry_name, classType);
1231 }
1232
1233 if (m_is_time_filtered) {
1234 // events were filtered during read
1235 // filter the logs the same way FilterByTime does
1236 TimeROI timeroi(filter_time_start, filter_time_stop);
1237 if (filter_bad_pulses)
1238 timeroi.update_intersection(*bad_pulses_timeroi);
1239 m_ws->mutableRun().setTimeROI(timeroi);
1240 m_ws->mutableRun().removeDataOutsideTimeROI();
1241 } else if (filter_bad_pulses) {
1242 m_ws->mutableRun().setTimeROI(*bad_pulses_timeroi);
1243 m_ws->mutableRun().removeDataOutsideTimeROI();
1244 }
1245}
1246
1247//-----------------------------------------------------------------------------
1258template <>
1259bool LoadEventNexus::runLoadIDFFromNexus<EventWorkspaceCollection_sptr>(const std::string &nexusfilename,
1260 EventWorkspaceCollection_sptr localWorkspace,
1261 const std::string &top_entry_name,
1262 Algorithm *alg) {
1263 auto ws = localWorkspace->getSingleHeldWorkspace();
1264 auto hasLoaded = runLoadIDFFromNexus<MatrixWorkspace_sptr>(nexusfilename, ws, top_entry_name, alg);
1265 localWorkspace->setInstrument(ws->getInstrument());
1266 return hasLoaded;
1267}
1268
1274 std::string instrumentName;
1275 try {
1276 hFile.openGroup("isis_vms_compat", "IXvms");
1277 } catch (std::runtime_error &) {
1278 return instrumentName;
1279 }
1280 try {
1281 hFile.openData("NAME");
1282 } catch (std::runtime_error &) {
1283 hFile.closeGroup();
1284 return instrumentName;
1285 }
1286
1287 instrumentName = hFile.getStrData();
1288 hFile.closeData();
1289 hFile.closeGroup();
1290
1291 return instrumentName;
1292}
1293
1294//-----------------------------------------------------------------------------
1307template <>
1308bool LoadEventNexus::runLoadInstrument<EventWorkspaceCollection_sptr>(const std::string &nexusfilename,
1309 EventWorkspaceCollection_sptr localWorkspace,
1310 const std::string &top_entry_name, Algorithm *alg,
1311 const Nexus::NexusDescriptor *descriptor) {
1312 auto ws = localWorkspace->getSingleHeldWorkspace();
1313 auto hasLoaded = runLoadInstrument<MatrixWorkspace_sptr>(nexusfilename, ws, top_entry_name, alg, descriptor);
1314 localWorkspace->setInstrument(ws->getInstrument());
1315 return hasLoaded;
1316}
1317
1318//-----------------------------------------------------------------------------
1325 const std::vector<std::string> &bankNames) {
1326 Instrument_sptr inst = std::const_pointer_cast<Instrument>(workspace->getInstrument()->baseInstrument());
1327 // Build a list of Rectangular Detectors
1328 std::vector<std::shared_ptr<RectangularDetector>> detList;
1329 for (int i = 0; i < inst->nelements(); i++) {
1330 std::shared_ptr<RectangularDetector> det;
1331 std::shared_ptr<ICompAssembly> assem;
1332 std::shared_ptr<ICompAssembly> assem2;
1333
1334 det = std::dynamic_pointer_cast<RectangularDetector>((*inst)[i]);
1335 if (det) {
1336 detList.emplace_back(det);
1337 } else {
1338 // Also, look in the first sub-level for RectangularDetectors (e.g.
1339 // PG3). We are not doing a full recursive search since that will be
1340 // very long for lots of pixels.
1341 assem = std::dynamic_pointer_cast<ICompAssembly>((*inst)[i]);
1342 if (assem) {
1343 for (int j = 0; j < assem->nelements(); j++) {
1344 det = std::dynamic_pointer_cast<RectangularDetector>((*assem)[j]);
1345 if (det) {
1346 detList.emplace_back(det);
1347
1348 } else {
1349 // Also, look in the second sub-level for RectangularDetectors
1350 // (e.g. PG3). We are not doing a full recursive search since that
1351 // will be very long for lots of pixels.
1352 assem2 = std::dynamic_pointer_cast<ICompAssembly>((*assem)[j]);
1353 if (assem2) {
1354 for (int k = 0; k < assem2->nelements(); k++) {
1355 det = std::dynamic_pointer_cast<RectangularDetector>((*assem2)[k]);
1356 if (det) {
1357 detList.emplace_back(det);
1358 }
1359 }
1360 }
1361 }
1362 }
1363 }
1364 }
1365 }
1366 if (detList.empty())
1367 return;
1368
1369 // Get ComponentInfo from the first workspace in the collection
1370 auto ws = workspace->getSingleHeldWorkspace();
1371 const auto &componentInfo = ws->componentInfo();
1372
1373 for (auto &det : detList) {
1374 bool keep = false;
1375 std::string det_name = det->getName();
1376 for (const auto &bankName : bankNames) {
1377 size_t pos = bankName.find("_events");
1378 if (det_name == bankName.substr(0, pos))
1379 keep = true;
1380 if (keep)
1381 break;
1382 }
1383 if (!keep) {
1384 const size_t parentIndex = componentInfo.indexOfAny(det_name);
1385 const auto children = componentInfo.children(parentIndex);
1386 for (const auto &colIndex : children) {
1387 const auto grandchildren = componentInfo.children(colIndex);
1388
1389 for (const auto &rowIndex : grandchildren) {
1390 auto *d = dynamic_cast<Detector *>(const_cast<IComponent *>(componentInfo.componentID(rowIndex)));
1391 if (d)
1392 inst->removeDetector(d);
1393 }
1394 }
1395 auto *comp = dynamic_cast<IComponent *>(det.get());
1396 inst->remove(comp);
1397 }
1398 }
1399}
1400//-----------------------------------------------------------------------------
1409void LoadEventNexus::createSpectraMapping(const std::string &nxsfile, const bool monitorsOnly,
1410 const std::vector<std::string> &bankNames) {
1411 LoadEventNexusIndexSetup indexSetup(m_ws->getSingleHeldWorkspace(), getProperty("SpectrumMin"),
1412 getProperty("SpectrumMax"), getProperty("SpectrumList"));
1413 if (!monitorsOnly && !bankNames.empty()) {
1414 if (!isDefault("SpectrumMin") || !isDefault("SpectrumMax") || !isDefault("SpectrumList"))
1415 g_log.warning() << "Spectrum min/max/list selection ignored when "
1416 "`SingleBankPixelsOnly` is enabled\n";
1417 m_ws->setIndexInfo(indexSetup.makeIndexInfo(bankNames));
1418 g_log.debug() << "Populated spectra map for select banks\n";
1419 } else if (auto mapping = loadISISVMSSpectraMapping(m_top_entry_name)) {
1420 if (monitorsOnly) {
1421 g_log.debug() << "Loading only monitor spectra from " << nxsfile << "\n";
1422 } else {
1423 g_log.debug() << "Loading only detector spectra from " << nxsfile << "\n";
1424 }
1425 m_ws->setIndexInfo(indexSetup.makeIndexInfo(*mapping, monitorsOnly));
1426 } else {
1427 g_log.debug() << "No custom spectra mapping found, continuing with default "
1428 "1:1 mapping of spectrum:detectorID\n";
1429 m_ws->setIndexInfo(indexSetup.makeIndexInfo());
1430 g_log.debug() << "Populated 1:1 spectra map for the whole instrument \n";
1431 }
1432 std::tie(m_specMin, m_specMax) = indexSetup.eventIDLimits();
1433}
1434
1435//-----------------------------------------------------------------------------
1442 std::string mon_wsname = this->getProperty("OutputWorkspace");
1443 mon_wsname.append("_monitors");
1444
1445 auto loadMonitors = createChildAlgorithm("LoadNexusMonitors");
1446 g_log.information("Loading monitors from NeXus file...");
1447 loadMonitors->setPropertyValue("Filename", m_filename);
1448 g_log.information() << "New workspace name for monitors: " << mon_wsname << '\n';
1449 loadMonitors->setPropertyValue("OutputWorkspace", mon_wsname);
1450 loadMonitors->setPropertyValue("LoadOnly", this->getProperty("MonitorsLoadOnly"));
1451 loadMonitors->setPropertyValue("NXentryName", this->getProperty("NXentryName"));
1452 loadMonitors->execute();
1453 Workspace_sptr monsOut = loadMonitors->getProperty("OutputWorkspace");
1454 // create the output workspace property on the fly
1455 this->declareProperty(
1456 std::make_unique<WorkspaceProperty<Workspace>>("MonitorWorkspace", mon_wsname, Direction::Output),
1457 "Monitors from the Event NeXus file");
1458 this->setProperty("MonitorWorkspace", monsOut);
1459
1460 // The output will either be a group workspace or a matrix workspace
1461 MatrixWorkspace_sptr mons = std::dynamic_pointer_cast<MatrixWorkspace>(monsOut);
1462 if (mons) {
1463 // Set the internal monitor workspace pointer as well
1464 m_ws->setMonitorWorkspace(mons);
1465
1466 filterDuringPause(mons);
1467 } else {
1468 WorkspaceGroup_sptr monsGrp = std::dynamic_pointer_cast<WorkspaceGroup>(monsOut);
1469 if (monsGrp) {
1470 // declare a property for each member of the group
1471 for (int i = 0; i < monsGrp->getNumberOfEntries(); i++) {
1472 std::stringstream ssWsName;
1473 ssWsName << mon_wsname << "_" << i + 1;
1474 std::stringstream ssPropName;
1475 ssPropName << "MonitorWorkspace"
1476 << "_" << i + 1;
1477 this->declareProperty(
1478 std::make_unique<WorkspaceProperty<MatrixWorkspace>>(ssPropName.str(), ssWsName.str(), Direction::Output),
1479 "Monitors from the Event NeXus file");
1480 this->setProperty(ssPropName.str(), monsGrp->getItem(i));
1481 }
1482 }
1483 }
1484}
1485
1486//
1496std::unique_ptr<std::pair<std::vector<int32_t>, std::vector<int32_t>>>
1497LoadEventNexus::loadISISVMSSpectraMapping(const std::string &entry_name) {
1498 const std::string vms_str = "/isis_vms_compat";
1499 try {
1500 g_log.debug() << "Attempting to load custom spectra mapping from '" << entry_name << vms_str << "'.\n";
1501 m_file->openAddress("/" + entry_name + vms_str);
1502 } catch (Nexus::Exception const &) {
1503 return nullptr; // Doesn't exist
1504 }
1505
1506 // The ISIS spectrum mapping is defined by 2 arrays in isis_vms_compat
1507 // block:
1508 // UDET - An array of detector IDs
1509 // SPEC - An array of spectrum numbers
1510 // There sizes must match. Hardware allows more than one detector ID to be
1511 // mapped to a single spectrum
1512 // and this is encoded in the SPEC/UDET arrays by repeating the spectrum
1513 // number in the array
1514 // for each mapped detector, e.g.
1515 //
1516 // 1 1001
1517 // 1 1002
1518 // 2 2001
1519 // 3 3001
1520 //
1521 // defines 3 spectra, where the first spectrum contains 2 detectors
1522
1523 // UDET
1524 m_file->openData("UDET");
1525 std::vector<int32_t> udet;
1526 m_file->getData(udet);
1527 m_file->closeData();
1528 // SPEC
1529 m_file->openData("SPEC");
1530 std::vector<int32_t> spec;
1531 m_file->getData(spec);
1532 m_file->closeData();
1533 // Go up/back. this assumes one level for entry name and a second level
1534 // for /isis_vms_compat, typically: /raw_data_1/isis_vms_compat
1535 m_file->closeGroup();
1536 m_file->closeGroup();
1537
1538 // The spec array will contain a spectrum number for each udet but the
1539 // spectrum number
1540 // may be the same for more that one detector
1541 const size_t ndets(udet.size());
1542 if (ndets != spec.size()) {
1543 std::ostringstream os;
1544 os << "UDET/SPEC list size mismatch. UDET=" << udet.size() << ", SPEC=" << spec.size() << "\n";
1545 throw std::runtime_error(os.str());
1546 }
1547 // If mapping loaded the event ID is the spectrum number and not det ID
1548 this->event_id_is_spec = true;
1549 return std::make_unique<std::pair<std::vector<int32_t>, std::vector<int32_t>>>(std::move(spec), std::move(udet));
1550}
1551
1557void LoadEventNexus::setTimeFilters(const bool monitors) {
1558 // Get the limits to the filter
1559 std::string prefix("Filter");
1560 if (monitors)
1561 prefix += "Mon";
1562
1563 filter_tof_min = getProperty(prefix + "ByTofMin");
1564 filter_tof_max = getProperty(prefix + "ByTofMax");
1565 if ((filter_tof_min == EMPTY_DBL()) && (filter_tof_max == EMPTY_DBL())) {
1566 // Nothing specified. Include everything
1567 filter_tof_range = false;
1568 } else if ((filter_tof_min != EMPTY_DBL()) && (filter_tof_max != EMPTY_DBL())) {
1569 // Both specified. Keep these values
1570 filter_tof_range = true;
1571 } else {
1572 std::string msg("You must specify both min & max or neither TOF filters");
1573 if (monitors)
1574 msg = " for the monitors.";
1575 throw std::invalid_argument(msg);
1576 }
1577}
1578
1579//-----------------------------------------------------------------------------
1580
1596 try {
1597 file.openGroup("isis_vms_compat", "IXvms");
1598 } catch (Nexus::Exception const &) {
1599 // No problem, it just means that this entry does not exist
1600 return;
1601 }
1602
1603 // read the data
1604 try {
1605 std::vector<int32_t> spb;
1606 std::vector<float> rspb;
1607 file.readData("SPB", spb);
1608 file.readData("RSPB", rspb);
1609
1610 WS.setGeometryFlag(spb[2]); // the flag is in the third value
1611 WS.setThickness(rspb[3]);
1612 WS.setHeight(rspb[4]);
1613 WS.setWidth(rspb[5]);
1614 } catch (Nexus::Exception const &ex) {
1615 // it means that the data was not as expected, report the problem
1616 std::stringstream s;
1617 s << "Wrong definition found in isis_vms_compat :> " << ex.what();
1618 file.closeGroup();
1619 throw std::runtime_error(s.str());
1620 }
1621
1622 file.closeGroup();
1623}
1624
1631void LoadEventNexus::safeOpenFile(const std::string &fname) {
1632 try {
1633 m_file = std::make_unique<Nexus::File>(m_filename, NXaccess::READ);
1634 } catch (std::runtime_error &e) {
1635 throw std::runtime_error("Severe failure when trying to open NeXus file: " + std::string(e.what()));
1636 }
1637 // make sure that by no means we could dereference NULL later on
1638 if (!m_file) {
1639 throw std::runtime_error("An unexpected failure happened, unable to "
1640 "initialize file object when trying to open NeXus "
1641 "file: " +
1642 fname);
1643 }
1644}
1645} // namespace Mantid::DataHandling
gsl_vector * tmp
IPeaksWorkspace_sptr workspace
#define PARALLEL_START_INTERRUPT_REGION
Begins a block to skip processing is the algorithm has been interupted Note the end of the block if n...
#define PARALLEL_END_INTERRUPT_REGION
Ends a block to skip processing is the algorithm has been interupted Note the start of the block if n...
#define PARALLEL_FOR_IF(condition)
Empty definitions - to enable set your complier to enable openMP.
#define PARALLEL_CHECK_INTERRUPT_REGION
Adds a check after a Parallel region to see if it was interupted.
#define DECLARE_NEXUS_FILELOADER_ALGORITHM(classname)
DECLARE_NEXUS_FILELOADER_ALGORITHM should be used in place of the standard DECLARE_ALGORITHM macro wh...
Base class from which all concrete algorithm classes should be derived.
Definition Algorithm.h:76
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
std::string getPropertyValue(const std::string &name) const override
Get the value of a property as a string.
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
virtual std::shared_ptr< Algorithm > createChildAlgorithm(const std::string &name, const double startProgress=-1., const double endProgress=-1., const bool enableLogging=true, const int &version=-1)
Create a Child Algorithm.
Kernel::Logger & g_log
Definition Algorithm.h:422
bool isDefault(const std::string &name) const
Kernel::Logger & getLogger() const
Returns a reference to the logger.
@ Load
allowed here which will be passed to the algorithm
bool hasProperty(const std::string &name) const
Does the property exist on the object.
Kernel::Property * getProperty(const std::string &name) const
Returns the named property as a pointer.
HeldType getPropertyValueAsType(const std::string &name) const
Get the value of a property as the given TYPE.
Helper class for reporting progress from algorithms.
Definition Progress.h:25
void doReport(const std::string &msg="") override
Actually do the reporting, without changing the loop counter.
Definition Progress.cpp:70
This class stores information regarding an experimental run as a series of log entries.
Definition Run.h:35
A property class for workspaces.
static void load(LoadEventNexus *alg, EventWorkspaceCollection &ws, bool haveWeights, bool event_id_is_spec, std::vector< std::string > bankNames, const std::vector< int > &periodLog, const std::string &classType, std::vector< std::size_t > bankNumEvents, const bool oldNeXusFileNames, const bool precount, const int chunk, const int totalChunks)
EventWorkspaceCollection : Collection of EventWorspaces to give backward-forward compatibility around...
Custom exception extending std::invalid_argument Thrown when nperiods does not match period_log Custo...
Helper for LoadEventNexus dealing with setting up indices (spectrum numbers an detector ID mapping) f...
std::pair< int32_t, int32_t > eventIDLimits() const
bool m_is_time_filtered
if wall-clock filtering was requested
static int checkForCorruptedPeriods(std::unique_ptr< Kernel::TimeSeriesProperty< int > > tempPeriodLog, std::unique_ptr< const Kernel::TimeSeriesProperty< int > > &periodLog, const int &nPeriods, const std::string &nexusfilename, std::string &status)
Check for corrupted period logs If data is historical (1 periods, period is labelled 0) then change p...
std::shared_ptr< Mantid::Kernel::TimeROI > bad_pulses_timeroi
void createSpectraMapping(const std::string &nxsfile, const bool monitorsOnly, const std::vector< std::string > &bankNames=std::vector< std::string >())
Create the required spectra mapping.
static void loadSampleDataISIScompatibility(Nexus::File &file, EventWorkspaceCollection &WS)
Load information of the sample.
Mantid::Types::Core::DateAndTime filter_time_start
Filter by start time.
double filter_tof_max
Filter by a maximum time-of-flight.
void safeOpenFile(const std::string &fname)
to open the nexus file with specific exception handling/message
bool loadlogs
Do we load the sample logs?
bool event_id_is_spec
True if the event_id is spectrum no not pixel ID.
size_t discarded_events
A count of events discarded because they came from a pixel that's not in the IDF.
T filterEventsByTime(T workspace, Mantid::Types::Core::DateAndTime &startTime, Mantid::Types::Core::DateAndTime &stopTime)
Filter the events by pulse time - no in place version so have to return workspace.
std::map< std::string, std::string > validateInputs() override
Perform validation of ALL the input properties of the algorithm.
Mantid::Types::Core::DateAndTime filter_time_stop
Filter by stop time.
void init() override
Intialisation code.
int32_t m_specMax
Maximum spectrum to load.
void exec() override
Execution code.
void deleteBanks(const EventWorkspaceCollection_sptr &workspace, const std::vector< std::string > &bankNames)
Deletes banks for a workspace given the bank names.
double compressTolerance
Tolerance for CompressEvents; use -1 to mean don't compress.
std::string m_filename
The name and path of the input file.
std::shared_ptr< BankPulseTimes > m_allBanksPulseTimes
Pulse times for ALL banks, taken from proton_charge log.
static std::shared_ptr< BankPulseTimes > runLoadNexusLogs(const std::string &nexusfilename, T localWorkspace, Algorithm &alg, bool returnpulsetimes, int &nPeriods, std::unique_ptr< const Kernel::TimeSeriesProperty< int > > &periodLog)
Load the log from the nexus file.
static bool loadInstrument(const std::string &nexusfilename, T localWorkspace, const std::string &top_entry_name, Algorithm *alg, const Nexus::NexusDescriptor *descriptor=nullptr)
Load instrument from Nexus file if possible, else from IDF spacified by Nexus file.
int confidence(Nexus::NexusDescriptorLazy &descriptor) const override
Return the confidence with with this algorithm can load the file.
void runLoadMonitors()
Load the Monitors from the NeXus file into a workspace.
std::unique_ptr< std::pair< std::vector< int32_t >, std::vector< int32_t > > > loadISISVMSSpectraMapping(const std::string &entry_name)
Load a spectra mapping from the given file.
bool filter_tof_range
Tof range is being filtered.
static std::string readInstrumentFromISIS_VMSCompat(Nexus::File &hFile)
method used to return instrument name for some old ISIS files where it is not written properly within...
std::unique_ptr< Nexus::File > m_file
std::shared_ptr< EventWorkspaceCollection > m_ws
The workspace being filled out.
void loadEvents(API::Progress *const prog, const bool monitors)
Load events from the file.
LoadEventNexus()
Empty default constructor.
bool m_instrument_loaded_correctly
Was the instrument loaded?
size_t bad_tofs
Count of all the "bad" tofs found.
int32_t m_specMin
Minimum spectrum to load.
void setTopEntryName()
Set the top entry field name.
double filter_tof_min
Filter by a minimum time-of-flight.
std::string m_top_entry_name
name of top level NXentry to use
void setTimeFilters(const bool monitors)
Set the filters on TOF.
This class represents a detector - i.e.
Definition Detector.h:30
Class to represent a particular goniometer setting, which is described by the rotation matrix.
Definition Goniometer.h:55
void makeUniversalGoniometer()
Make a default universal goniometer with phi,chi,omega angles according to SNS convention.
base class for Geometric IComponent
Definition IComponent.h:53
Support for a property that holds an array of values.
Exception for when an item is not found in a collection.
Definition Exception.h:145
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
void setPropertySettings(const std::string &name, std::unique_ptr< IPropertySettings const > settings)
Add a PropertySettings instance to the chain of settings for a given property.
void setPropertyGroup(const std::string &name, const std::string &group)
Set the group for a given property.
The Logger class is in charge of the publishing messages from the framework through various channels.
Definition Logger.h:51
void debug(const std::string &msg)
Logs at debug level.
Definition Logger.cpp:145
void notice(const std::string &msg)
Logs at notice level.
Definition Logger.cpp:126
void error(const std::string &msg)
Logs at error level.
Definition Logger.cpp:108
void warning(const std::string &msg)
Logs at warning level.
Definition Logger.cpp:117
void information(const std::string &msg)
Logs at information level.
Definition Logger.cpp:136
void report()
Increments the loop counter by 1, then sends the progress notification on behalf of its algorithm.
The concrete, templated class for properties.
virtual std::string value() const =0
Returns the value of the property as a string.
Represents a time interval.
Definition DateAndTime.h:25
A specialised Property class for holding a series of time-value pairs.
std::vector< Types::Core::DateAndTime > timesAsVector() const override
Return the time series's times as a vector<DateAndTime>
Class that provides for a standard Nexus exception.
bool isEntry(std::string const &entryName, std::string const &groupClass) const
Checks if a full-address entry exists for a particular groupClass in a Nexus dataset.
bool classTypeExists(std::string const &classType) const
Query if a given type exists somewhere in the file.
static unsigned short constexpr UINT64
std::shared_ptr< WorkspaceGroup > WorkspaceGroup_sptr
shared pointer to Mantid::API::WorkspaceGroup
std::shared_ptr< Workspace > Workspace_sptr
shared pointer to Mantid::API::Workspace
Kernel::Logger g_log("ExperimentInfo")
static logger object
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
void addNexusFieldsToWsRun(Nexus::File &filehandle, API::Run &runDetails, const std::string &entryName="", bool useFullAddress=false)
Add properties from a nexus file to the workspace run.
std::size_t numEvents(Nexus::File &file, bool &hasTotalCounts, bool &oldNeXusFileNames, const std::string &prefix)
Get the number of events in the currently opened group.
std::shared_ptr< EventWorkspaceCollection > EventWorkspaceCollection_sptr
std::pair< DateAndTime, DateAndTime > firstLastPulseTimes(Nexus::File &file, Kernel::Logger &logger)
void adjustTimeOfFlightISISLegacy(Nexus::File &file, T localWorkspace, const std::string &entry_name, const std::string &classType)
ISIS specific method for dealing with wide events.
MANTID_DATAHANDLING_DLL bool doPerformISISEventShift(Nexus::File &file, std::string &topEntryName)
std::shared_ptr< Instrument > Instrument_sptr
Shared pointer to an instrument object.
MANTID_KERNEL_DLL Types::Core::DateAndTime createFromSanitizedISO8601(const std::string &date)
Creates a DateAndTime object from a date string even if the string does not exactly conform to ISO860...
MANTID_KERNEL_DLL double timeConversionValue(const std::string &input_unit, const std::string &output_unit)
Definition Unit.cpp:1430
std::enable_if< std::is_pointer< Arg >::value, bool >::type threadSafe(Arg workspace)
Thread-safety check Checks the workspace to ensure it is suitable for multithreaded access.
const std::string BINMODE("BinningMode")
constexpr int EMPTY_INT() noexcept
Returns what we consider an "empty" integer within a property.
Definition EmptyValues.h:24
constexpr double EMPTY_DBL() noexcept
Returns what we consider an "empty" double within a property.
Definition EmptyValues.h:42
std::string to_string(const wide_integer< Bits, Signed > &n)
@ Input
An input workspace.
Definition Property.h:53
@ Output
An output workspace.
Definition Property.h:54