Mantid
Loading...
Searching...
No Matches
LoadEventNexus.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
13#include "MantidDataHandling/DllConfig.h"
26
28
30#include "MantidNexus/NexusFile.h"
31
32#include <algorithm>
33#include <boost/lexical_cast.hpp>
34#include <boost/scoped_array.hpp>
35#include <cstdint>
36#include <filesystem>
37#include <functional>
38#include <memory>
39#include <mutex>
40#include <numeric>
41#include <random>
42#include <string>
43
44namespace Mantid {
45namespace DataHandling {
46
53class MANTID_DATAHANDLING_DLL InvalidLogPeriods : public std::invalid_argument {
54public:
55 InvalidLogPeriods(const std::string &msg) : std::invalid_argument(msg) {}
56};
57
58bool exists(Nexus::File &file, const std::string &name);
59
60bool exists(const std::map<std::string, std::string> &entries, const std::string &name);
61
62MANTID_DATAHANDLING_DLL bool doPerformISISEventShift(Nexus::File &file, std::string &topEntryName);
63
76class MANTID_DATAHANDLING_DLL LoadEventNexus : public API::IFileLoader<Nexus::NexusDescriptorLazy> {
77
78public:
80
81 const std::string name() const override { return "LoadEventNexus"; };
82
84 const std::string summary() const override {
85 return "Loads an Event NeXus file and stores as an "
86 "EventWorkspace. Optionally, you can filter out events falling "
87 "outside a range of times-of-flight and/or a time interval.";
88 }
89
91 int version() const override { return 1; };
92 const std::vector<std::string> seeAlso() const override {
93 return {"LoadISISNexus", "LoadEventAndCompress", "LoadEventAsWorkspace2D"};
94 }
95
97 const std::string category() const override { return "DataHandling\\Nexus"; }
98
99 int confidence(Nexus::NexusDescriptorLazy &descriptor) const override;
100
101 template <typename T>
102 static std::shared_ptr<BankPulseTimes>
103 runLoadNexusLogs(const std::string &nexusfilename, T localWorkspace, Algorithm &alg, bool returnpulsetimes,
104 int &nPeriods, std::unique_ptr<const Kernel::TimeSeriesProperty<int>> &periodLog);
105
106 template <typename T>
107 static std::shared_ptr<BankPulseTimes>
108 runLoadNexusLogs(const std::string &nexusfilename, T localWorkspace, Algorithm &alg, bool returnpulsetimes,
109 int &nPeriods, std::unique_ptr<const Kernel::TimeSeriesProperty<int>> &periodLog,
110 const std::vector<std::string> &allow_list, const std::vector<std::string> &block_list);
111
112 static int checkForCorruptedPeriods(std::unique_ptr<Kernel::TimeSeriesProperty<int>> tempPeriodLog,
113 std::unique_ptr<const Kernel::TimeSeriesProperty<int>> &periodLog,
114 const int &nPeriods, const std::string &nexusfilename, std::string &status);
115
116 template <typename T>
117 static void loadEntryMetadata(const std::string &nexusfilename, T WS, const std::string &entry_name);
118
120 template <typename T>
121 static bool loadInstrument(const std::string &nexusfilename, T localWorkspace, const std::string &top_entry_name,
122 Algorithm *alg, const Nexus::NexusDescriptor *descriptor = nullptr);
123
125 template <typename T>
126 static bool runLoadIDFFromNexus(const std::string &nexusfilename, T localWorkspace, const std::string &top_entry_name,
127 Algorithm *alg);
128
130 template <typename T>
131 static bool runLoadInstrument(const std::string &nexusfilename, T localWorkspace, const std::string &top_entry_name,
132 Algorithm *alg, const Nexus::NexusDescriptor *descriptor = nullptr);
133
134 static void loadSampleDataISIScompatibility(Nexus::File &file, EventWorkspaceCollection &WS);
135
138 static std::string readInstrumentFromISIS_VMSCompat(Nexus::File &hFile);
139
140public:
142 std::string m_filename;
143
145 std::shared_ptr<EventWorkspaceCollection> m_ws;
146
153
155 int32_t m_specMin;
157 int32_t m_specMax;
158
160 Mantid::Types::Core::DateAndTime filter_time_start;
162 Mantid::Types::Core::DateAndTime filter_time_stop;
164 bool m_is_time_filtered{false};
165
166 bool filter_bad_pulses{false};
167 std::shared_ptr<Mantid::Kernel::TimeROI> bad_pulses_timeroi;
168
170 std::mutex m_tofMutex;
171
178 size_t bad_tofs;
182
186
188 std::shared_ptr<BankPulseTimes> m_allBanksPulseTimes;
189
191 std::string m_top_entry_name;
192 std::unique_ptr<Nexus::File> m_file;
193
194private:
196 void init() override;
197
199 void exec() override;
200
201 std::map<std::string, std::string> validateInputs() override;
202
204
205 void loadEvents(API::Progress *const prog, const bool monitors);
206 void createSpectraMapping(const std::string &nxsfile, const bool monitorsOnly,
207 const std::vector<std::string> &bankNames = std::vector<std::string>());
208 void deleteBanks(const EventWorkspaceCollection_sptr &workspace, const std::vector<std::string> &bankNames);
209 void runLoadMonitors();
211 void setTimeFilters(const bool monitors);
212 template <typename T>
213 T filterEventsByTime(T workspace, Mantid::Types::Core::DateAndTime &startTime,
214 Mantid::Types::Core::DateAndTime &stopTime);
215
217 std::unique_ptr<std::pair<std::vector<int32_t>, std::vector<int32_t>>>
218 loadISISVMSSpectraMapping(const std::string &entry_name);
219
220 template <typename T> void filterDuringPause(T workspace);
221
223 void setTopEntryName();
224
226 void safeOpenFile(const std::string &fname);
227
230
235};
236
237//-----------------------------------------------------------------------------
238// ISIS event corrections
239//-----------------------------------------------------------------------------
240
270template <typename T>
271void makeTimeOfFlightDataFuzzy(Nexus::File &file, T localWorkspace, const std::string &binsName, size_t start_wi = 0,
272 size_t end_wi = 0) {
273 // if the data is not randomized randomize it uniformly within each bin
274 file.openData(binsName);
275 // time of flights of events
276 std::vector<float> tofsFile;
277 file.getData(tofsFile);
278 file.closeData();
279
280 // todo: try to find if tof can be reduced to just 3 numbers: start, end and
281 // dt
282 if (end_wi <= start_wi) {
283 end_wi = localWorkspace->getNumberHistograms();
284 }
285
286 // random number generator
287 std::mt19937 rng;
288
289 // loop over spectra
290 for (size_t wi = start_wi; wi < end_wi; ++wi) {
291 DataObjects::EventList &event_list = dynamic_cast<DataObjects::EventList &>(localWorkspace->getSpectrum(wi));
292 if (event_list.empty())
293 continue;
294 // sort the events
295 event_list.sortTof();
296 auto tofsEventList = event_list.getTofs();
297
298 size_t n = tofsFile.size();
299 // iterate over the events and time bins
300 auto ev = tofsEventList.begin();
301 auto ev_end = tofsEventList.end();
302 for (size_t i = 1; i < n; ++i) {
303 double right = double(tofsFile[i]);
304 // find the right boundary for the current event
305 if ((ev != ev_end) && (right < *ev)) {
306 continue;
307 }
308 // count events which have the same right boundary
309 size_t m = 0;
310 while ((ev != ev_end) && (*ev < right)) {
311 ++ev;
312 ++m; // count events in the i-th bin
313 }
314
315 if (m > 0) { // m events in this bin
316 double left = double(tofsFile[i - 1]);
317 // spread the events uniformly inside the bin
318 std::uniform_real_distribution<double> flat(left, right);
319 std::vector<double> random_numbers(m);
320 std::generate(random_numbers.begin(), random_numbers.end(), [&flat, &rng]() { return flat(rng); });
321 std::sort(random_numbers.begin(), random_numbers.end());
322 auto it = random_numbers.begin();
323 for (auto ev1 = ev - m; ev1 != ev; ++ev1, ++it) {
324 *ev1 = *it;
325 }
326 }
327
328 } // for i
329 event_list.setTofs(tofsEventList);
330
331 event_list.sortTof();
332 } // for wi
333}
334
347template <typename T>
348void adjustTimeOfFlightISISLegacy(Nexus::File &file, T localWorkspace, const std::string &entry_name,
349 const std::string &classType) {
350 bool done = false;
351 // Go to the root, and then top entry
352 file.openAddress("/");
353 file.openGroup(entry_name, "NXentry");
354
355 using string_map_t = std::map<std::string, std::string>;
356 string_map_t entries = file.getEntries();
357 // try if monitors have their own bins
358 if (classType == "NXmonitor") {
359 std::vector<std::string> bankNames;
360 for (string_map_t::const_iterator it = entries.begin(); it != entries.end(); ++it) {
361 const std::string entry_class(it->second);
362 if (entry_class == classType) {
363 const std::string entryName(it->first);
364 bankNames.emplace_back(entryName);
365 }
366 }
367 for (size_t i = 0; i < bankNames.size(); ++i) {
368 const std::string &mon = bankNames[i];
369 file.openGroup(mon, classType);
370 entries = file.getEntries();
371 if (entries.find("event_time_bins") == entries.end()) {
372 // bins = entries.find("time_of_flight"); // I think time_of_flight
373 // doesn't work here
374 // if (bins == entries.end())
375 //{
376 done = false;
377 file.closeGroup();
378 break; // done == false => use bins from the detectors
379 //}
380 }
381 done = true;
382 makeTimeOfFlightDataFuzzy(file, localWorkspace, "event_time_bins", i, i + 1);
383 file.closeGroup();
384 }
385 }
386
387 if (!done) {
388 // first check detector_1_events
389 file.openGroup("detector_1_events", "NXevent_data");
390 entries = file.getEntries();
391 for (string_map_t::const_iterator it = entries.begin(); it != entries.end(); ++it) {
392 if (it->first == "time_of_flight" || it->first == "event_time_bins") {
393 makeTimeOfFlightDataFuzzy(file, localWorkspace, it->first);
394 done = true;
395 }
396 }
397 file.closeGroup(); // detector_1_events
398
399 if (!done) { // if time_of_flight was not found try
400 // instrument/dae/time_channels_#
401 file.openGroup("instrument", "NXinstrument");
402 file.openGroup("dae", "IXdae");
403 entries = file.getEntries();
404 size_t time_channels_number = 0;
405 for (string_map_t::const_iterator it = entries.begin(); it != entries.end(); ++it) {
406 // check if there are groups with names "time_channels_#" and select the
407 // one with the highest number
408 if (it->first.size() > 14 && it->first.substr(0, 14) == "time_channels_") {
409 size_t n = boost::lexical_cast<size_t>(it->first.substr(14));
410 if (n > time_channels_number) {
411 time_channels_number = n;
412 }
413 }
414 }
415 if (time_channels_number > 0) // the numbers start with 1
416 {
417 file.openGroup("time_channels_" + std::to_string(time_channels_number), "IXtime_channels");
418 entries = file.getEntries();
419 for (string_map_t::const_iterator it = entries.begin(); it != entries.end(); ++it) {
420 if (it->first == "time_of_flight" || it->first == "event_time_bins") {
421 makeTimeOfFlightDataFuzzy(file, localWorkspace, it->first);
422 }
423 }
424 file.closeGroup();
425 }
426 file.closeGroup(); // dae
427 file.closeGroup(); // instrument
428 }
429 }
430
431 // close top entry (or entry given in entry_name)
432 file.closeGroup();
433}
434
435//-----------------------------------------------------------------------------
446template <typename T>
447bool LoadEventNexus::runLoadInstrument(const std::string &nexusfilename, T localWorkspace,
448 const std::string &top_entry_name, Algorithm *alg,
449 const Nexus::NexusDescriptor *descriptor) {
450 std::string instrument;
451 std::string instFilename;
452
453 const bool isNexus = (descriptor == nullptr) ? LoadGeometry::isNexus(nexusfilename)
454 : LoadGeometry::isNexus(descriptor->getAllEntries());
455
456 // Check if the geometry can be loaded directly from the Nexus file
457 if (isNexus) {
458 instFilename = nexusfilename;
459 } else {
460 // Get the instrument name
461 Nexus::File nxfile(nexusfilename);
462 // Start with the base entry
463 nxfile.openGroup(top_entry_name, "NXentry");
464 // Open the instrument
465 nxfile.openGroup("instrument", "NXinstrument");
466 try {
467 nxfile.openData("name");
468 instrument = nxfile.getStrData();
469 alg->getLogger().debug() << "Instrument name read from NeXus file is " << instrument << '\n';
470 } catch (Nexus::Exception const &) {
471 // Try to fall back to isis compatibility options
472 nxfile.closeGroup();
473 instrument = readInstrumentFromISIS_VMSCompat(nxfile);
474 if (instrument.empty()) {
475 // Get the instrument name from the file instead
476 size_t n = nexusfilename.rfind('/');
477 if (n != std::string::npos) {
478 std::string temp = nexusfilename.substr(n + 1, nexusfilename.size() - n - 1);
479 n = temp.find('_');
480 if (n != std::string::npos && n > 0) {
481 instrument = temp.substr(0, n);
482 }
483 }
484 }
485 }
486 if (instrument == "POWGEN3") // hack for powgen b/c of bad long name
487 instrument = "POWGEN";
488 if (instrument == "NOM") // hack for nomad
489 instrument = "NOMAD";
490
491 if (instrument.empty())
492 throw std::runtime_error("Could not find the instrument name in the NXS "
493 "file or using the filename. Cannot load "
494 "instrument!");
495
496 // Now let's close the file as we don't need it anymore to load the
497 // instrument.
498 nxfile.close();
499 }
500
501 if (instFilename.empty()) {
502 try {
503 instFilename =
504 API::InstrumentFileFinder::getInstrumentFilename(instrument, localWorkspace->getWorkspaceStartDate());
506 if (instFilename.empty()) {
507 std::filesystem::path directory(Kernel::ConfigService::Instance().getInstrumentDirectory());
508 std::filesystem::path file(instrument + "_Definition.xml");
509 std::filesystem::path fullPath = directory / file;
510 instFilename = fullPath.string();
511 }
512 }
513 }
514
515 // do the actual work
516 auto loadInst = alg->createChildAlgorithm("LoadInstrument");
517
518 // Now execute the Child Algorithm. Catch and log any error, but don't stop.
519 bool executionSuccessful(true);
520 try {
521 loadInst->setPropertyValue("Filename", instFilename);
522 loadInst->setPropertyValue("InstrumentName", instrument);
523 loadInst->setProperty<Mantid::API::MatrixWorkspace_sptr>("Workspace", localWorkspace);
524 loadInst->setProperty("RewriteSpectraMap", Mantid::Kernel::OptionalBool(false));
525 loadInst->execute();
526
527 // Populate the instrument parameters in this workspace - this works around
528 // a bug
529 localWorkspace->populateInstrumentParameters();
530 } catch (std::invalid_argument &e) {
531 alg->getLogger().information() << "Invalid argument to LoadInstrument Child Algorithm : " << e.what() << '\n';
532 executionSuccessful = false;
533 } catch (std::runtime_error &e) {
534 alg->getLogger().information("Unable to successfully run LoadInstrument Child Algorithm");
535 alg->getLogger().information(e.what());
536 executionSuccessful = false;
537 }
538
539 // If loading instrument definition file fails
540 if (!executionSuccessful) {
541 alg->getLogger().error() << "Error loading Instrument definition file\n";
542 return false;
543 }
544
545 // Ticket #2049: Cleanup all loadinstrument members to a single instance
546 // If requested update the instrument to positions in the data file
547 const auto &pmap = localWorkspace->constInstrumentParameters();
548 if (!pmap.contains(localWorkspace->getInstrument()->getComponentID(), "det-pos-source"))
549 return executionSuccessful;
550
551 std::shared_ptr<Geometry::Parameter> updateDets =
552 pmap.get(localWorkspace->getInstrument()->getComponentID(), "det-pos-source");
553 std::string value = updateDets->value<std::string>();
554 if (value.substr(0, 8) == "datafile") {
555 auto updateInst = alg->createChildAlgorithm("UpdateInstrumentFromFile");
556 updateInst->setProperty<Mantid::API::MatrixWorkspace_sptr>("Workspace", localWorkspace);
557 updateInst->setPropertyValue("Filename", nexusfilename);
558 if (value == "datafile-ignore-phi") {
559 updateInst->setProperty("IgnorePhi", true);
560 alg->getLogger().information("Detector positions in IDF updated with "
561 "positions in the data file except for the "
562 "phi values");
563 } else {
564 alg->getLogger().information("Detector positions in IDF updated with positions in the data file");
565 }
566 // We want this to throw if it fails to warn the user that the information
567 // is not correct.
568 updateInst->execute();
569 }
570
571 return executionSuccessful;
572}
573
574//-----------------------------------------------------------------------------
576template <typename T>
577void LoadEventNexus::loadEntryMetadata(const std::string &nexusfilename, T WS, const std::string &entry_name) {
578 // Open the file
579 Nexus::File file(nexusfilename);
580 file.openGroup(entry_name, "NXentry");
581
582 // get the title
583 if (file.hasData("/" + entry_name + "/title")) {
584 file.openData("title");
585 if (file.getInfo().type == NXnumtype::CHAR) {
586 std::string title = file.getStrData();
587 if (!title.empty())
588 WS->setTitle(title);
589 }
590 file.closeData();
591 }
592
593 // get the notes
594 if (file.hasData("/" + entry_name + "/notes")) {
595 file.openData("notes");
596 if (file.getInfo().type == NXnumtype::CHAR) {
597 std::string notes = file.getStrData();
598 if (!notes.empty())
599 WS->mutableRun().addProperty("file_notes", notes, true);
600 }
601 file.closeData();
602 }
603
604 // Get the run number
605 if (file.hasData("/" + entry_name + "/run_number")) {
606 file.openData("run_number");
607 std::string run;
608 if (file.getInfo().type == NXnumtype::CHAR) {
609 run = file.getStrData();
610 } else if (file.isDataInt()) {
611 // inside ISIS the run_number type is int32
612 std::vector<int> value;
613 file.getData(value);
614 if (!value.empty())
615 run = std::to_string(value[0]);
616 }
617 if (!run.empty()) {
618 WS->mutableRun().addProperty("run_number", run, true);
619 }
620 file.closeData();
621 }
622
623 // get the experiment identifier
624 if (file.hasData("/" + entry_name + "/experiment_identifier")) {
625 file.openData("experiment_identifier");
626 std::string expId;
627 if (file.getInfo().type == NXnumtype::CHAR) {
628 expId = file.getStrData();
629 }
630 if (!expId.empty()) {
631 WS->mutableRun().addProperty("experiment_identifier", expId, true);
632 }
633 file.closeData();
634 }
635
636 // get the sample name - nested try/catch to leave the handle in an
637 // appropriate state
638 if (file.hasGroup("/" + entry_name + "/sample", "NXsample")) {
639 file.openGroup("sample", "NXsample");
640 try {
641 if (file.hasData("/" + entry_name + "/sample/name")) {
642 file.openData("name");
643 const auto info = file.getInfo();
644 std::string sampleName;
645 if (info.type == NXnumtype::CHAR) {
646 if (info.dims.size() == 1) {
647 sampleName = file.getStrData();
648 } else { // something special for 2-d array
649 const int64_t total_length = std::accumulate(info.dims.begin(), info.dims.end(), static_cast<int64_t>(1),
650 std::multiplies<int64_t>());
651 boost::scoped_array<char> val_array(new char[total_length]);
652 file.getData(val_array.get());
653 sampleName = std::string(val_array.get(), total_length);
654 }
655 }
656 file.closeData();
657 if (!sampleName.empty()) {
658 WS->mutableSample().setName(sampleName);
659 }
660 }
661 } catch (Nexus::Exception const &) {
662 // let it drop on floor if an exception occurs while reading sample
663 }
664 file.closeGroup();
665 }
666
667 // get the duration
668 if (file.hasData("/" + entry_name + "/duration")) {
669 file.openData("duration");
670 std::vector<double> duration;
671 file.getDataCoerce(duration);
672 if (duration.size() == 1) {
673 // get the units
674 std::string units;
675 if (file.hasAttr("units")) {
676 file.getAttr<std::string>("units", units);
677 }
678
679 // set the property
680 WS->mutableRun().addProperty("duration", duration[0], units, true);
681 }
682 file.closeData();
683 }
684
685 // close the file
686 file.close();
687}
688
689//-----------------------------------------------------------------------------
702template <typename T>
703bool LoadEventNexus::loadInstrument(const std::string &nexusfilename, T localWorkspace,
704 const std::string &top_entry_name, Algorithm *alg,
705 const Nexus::NexusDescriptor *descriptor) {
706
707 bool loadNexusInstrumentXML = true;
708 if (alg->existsProperty("LoadNexusInstrumentXML"))
709 loadNexusInstrumentXML = alg->getProperty("LoadNexusInstrumentXML");
710
711 bool foundInstrument = false;
712 if (loadNexusInstrumentXML)
713 foundInstrument = runLoadIDFFromNexus<T>(nexusfilename, localWorkspace, top_entry_name, alg);
714 if (!foundInstrument)
715 foundInstrument = runLoadInstrument<T>(nexusfilename, std::move(localWorkspace), top_entry_name, alg, descriptor);
716 return foundInstrument;
717}
718
719//-----------------------------------------------------------------------------
729template <typename T>
730bool LoadEventNexus::runLoadIDFFromNexus(const std::string &nexusfilename, T localWorkspace,
731 const std::string &top_entry_name, Algorithm *alg) {
732 // Test if IDF exists in file, move on quickly if not
733 try {
734 Nexus::File nxsfile(nexusfilename);
735 nxsfile.openAddress(top_entry_name + "/instrument/instrument_xml");
736 } catch (Nexus::Exception const &) {
737 alg->getLogger().information("No instrument XML definition found in " + nexusfilename + " at " + top_entry_name +
738 "/instrument");
739 return false;
740 }
741
742 auto loadInst = alg->createChildAlgorithm("LoadIDFFromNexus");
743
744 // Now execute the Child Algorithm. Catch and log any error, but don't stop.
745 try {
746 loadInst->setPropertyValue("Filename", nexusfilename);
747 loadInst->setProperty<Mantid::API::MatrixWorkspace_sptr>("Workspace", localWorkspace);
748 loadInst->setPropertyValue("InstrumentParentPath", top_entry_name);
749 loadInst->execute();
750 } catch (std::invalid_argument &) {
751 alg->getLogger().error("Invalid argument to LoadIDFFromNexus Child Algorithm ");
752 } catch (std::runtime_error &) {
753 alg->getLogger().debug("No instrument definition found by LoadIDFFromNexus in " + nexusfilename + " at " +
754 top_entry_name + "/instrument");
755 }
756
757 if (!loadInst->isExecuted())
758 alg->getLogger().information("No IDF loaded from Nexus file.");
759 return loadInst->isExecuted();
760}
761} // namespace DataHandling
762} // namespace Mantid
std::string name
Definition Run.cpp:60
double value
The value of the point.
Definition FitMW.cpp:51
IPeaksWorkspace_sptr workspace
double left
double right
Base class from which all concrete algorithm classes should be derived.
Definition Algorithm.h:76
bool existsProperty(const std::string &name) const override
Checks whether the named property is already in the list of managed property.
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 & getLogger() const
Returns a reference to the logger.
Defines an interface to an algorithm that loads a file so that it can take part in the automatic sele...
Definition IFileLoader.h:19
static std::string getInstrumentFilename(const std::string &instrumentName, const std::string &date="")
Get the IDF using the instrument name and date.
Helper class for reporting progress from algorithms.
Definition Progress.h:25
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...
InvalidLogPeriods(const std::string &msg)
std::shared_ptr< Mantid::Kernel::TimeROI > bad_pulses_timeroi
double longest_tof
Limits found to tof.
Mantid::Types::Core::DateAndTime filter_time_start
Filter by start time.
double filter_tof_max
Filter by a maximum time-of-flight.
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.
Mantid::Types::Core::DateAndTime filter_time_stop
Filter by stop time.
static bool runLoadInstrument(const std::string &nexusfilename, T localWorkspace, const std::string &top_entry_name, Algorithm *alg, const Nexus::NexusDescriptor *descriptor=nullptr)
Load instrument from IDF file specified by Nexus file.
const std::string summary() const override
Summary of algorithms purpose.
int32_t m_specMax
Maximum spectrum to load.
double compressTolerance
Tolerance for CompressEvents; use -1 to mean don't compress.
const std::string category() const override
Category.
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 void loadEntryMetadata(const std::string &nexusfilename, T WS, const std::string &entry_name)
Load the run number and other meta data from the given bank.
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.
const std::vector< std::string > seeAlso() const override
Function to return all of the seeAlso (these are not validated) algorithms related to this algorithm....
double shortest_tof
Limits found to tof.
std::mutex m_tofMutex
Mutex protecting tof limits.
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...
DataObjects::EventWorkspace_sptr createEmptyEventWorkspace()
const std::string name() const override
function to return a name of the algorithm, must be overridden in all algorithms
std::unique_ptr< Nexus::File > m_file
std::shared_ptr< EventWorkspaceCollection > m_ws
The workspace being filled out.
static bool runLoadIDFFromNexus(const std::string &nexusfilename, T localWorkspace, const std::string &top_entry_name, Algorithm *alg)
Load instrument for Nexus file.
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.
int version() const override
Version.
double filter_tof_min
Filter by a minimum time-of-flight.
std::string m_top_entry_name
name of top level NXentry to use
A class for holding :
Definition EventList.h:57
void setTofs(const MantidVec &tofs) override
Set a list of TOFs to the current event list.
void sortTof() const
Sort events by TOF in one thread.
bool empty() const
Much like stl containers, returns true if there is nothing in the event list.
void getTofs(std::vector< double > &tofs) const override
Fill a vector with the list of TOFs.
Exception for when an item is not found in a collection.
Definition Exception.h:145
void debug(const std::string &msg)
Logs at debug level.
Definition Logger.cpp:145
void error(const std::string &msg)
Logs at error level.
Definition Logger.cpp:108
void information(const std::string &msg)
Logs at information level.
Definition Logger.cpp:136
OptionalBool : Tri-state bool.
A specialised Property class for holding a series of time-value pairs.
Class that provides for a standard Nexus exception.
const std::map< std::string, std::set< std::string > > & getAllEntries() const noexcept
Returns a const reference of the internal map holding all entries in the Nexus HDF5 file.
static unsigned short constexpr CHAR
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
bool isNexus(const std::string &filename)
Determine if the Geometry file type is Nexus.
void makeTimeOfFlightDataFuzzy(Nexus::File &file, T localWorkspace, const std::string &binsName, size_t start_wi=0, size_t end_wi=0)
Load the time of flight data.
std::shared_ptr< EventWorkspaceCollection > EventWorkspaceCollection_sptr
bool exists(Nexus::File &file, const std::string &name)
void loadEvents(API::Progress &prog, const char *progMsg, EP &eventProcessor, const Nexus::NXEntry &entry, uint64_t start_nsec, uint64_t end_nsec)
Definition LoadBBY2.cpp:120
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< EventWorkspace > EventWorkspace_sptr
shared pointer to the EventWorkspace class
Helper class which provides the Collimation Length for SANS instruments.
Generate a tableworkspace to store the calibration results.
STL namespace.
std::string to_string(const wide_integer< Bits, Signed > &n)