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
14#include "MantidDataHandling/DllConfig.h"
27
28#include <Poco/Path.h>
29#include <boost/lexical_cast.hpp>
30#include <boost/scoped_array.hpp>
31
32// clang-format off
33#include <nexus/NeXusFile.hpp>
34#include <nexus/NeXusException.hpp>
35// clang-format on
36
37#include <algorithm>
38#include <cstdint>
39#include <functional>
40#include <memory>
41#include <mutex>
42#include <numeric>
43#include <random>
44#include <string>
45
46namespace Mantid {
47namespace DataHandling {
48
55class InvalidLogPeriods : public std::invalid_argument {
56public:
57 InvalidLogPeriods(const std::string &msg) : std::invalid_argument(msg) {}
58};
59
60bool exists(::NeXus::File &file, const std::string &name);
61
62bool exists(const std::map<std::string, std::string> &entries, const std::string &name);
63
76class MANTID_DATAHANDLING_DLL LoadEventNexus : public API::NexusFileLoader {
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 { return {"LoadISISNexus", "LoadEventAndCompress"}; }
93
95 const std::string category() const override { return "DataHandling\\Nexus"; }
96
97 int confidence(Kernel::NexusHDF5Descriptor &descriptor) const override;
98
99 template <typename T>
100 static std::shared_ptr<BankPulseTimes>
101 runLoadNexusLogs(const std::string &nexusfilename, T localWorkspace, Algorithm &alg, bool returnpulsetimes,
102 int &nPeriods, std::unique_ptr<const Kernel::TimeSeriesProperty<int>> &periodLog);
103
104 template <typename T>
105 static std::shared_ptr<BankPulseTimes>
106 runLoadNexusLogs(const std::string &nexusfilename, T localWorkspace, Algorithm &alg, bool returnpulsetimes,
107 int &nPeriods, std::unique_ptr<const Kernel::TimeSeriesProperty<int>> &periodLog,
108 const std::vector<std::string> &allow_list, const std::vector<std::string> &block_list);
109
110 static void checkForCorruptedPeriods(std::unique_ptr<Kernel::TimeSeriesProperty<int>> tempPeriodLog,
111 std::unique_ptr<const Kernel::TimeSeriesProperty<int>> &periodLog,
112 const int &nPeriods, const std::string &nexusfilename);
113
114 template <typename T>
115 static void loadEntryMetadata(const std::string &nexusfilename, T WS, const std::string &entry_name,
116 const Kernel::NexusHDF5Descriptor &descriptor);
117
128 template <typename T>
129 static bool loadInstrument(const std::string &nexusfilename, T localWorkspace, const std::string &top_entry_name,
130 Algorithm *alg, const Kernel::NexusHDF5Descriptor *descriptor = nullptr);
131
133 template <typename T>
134 static bool runLoadIDFFromNexus(const std::string &nexusfilename, T localWorkspace, const std::string &top_entry_name,
135 Algorithm *alg);
136
146 template <typename T>
147 static bool runLoadInstrument(const std::string &nexusfilename, T localWorkspace, const std::string &top_entry_name,
148 Algorithm *alg, const Kernel::NexusHDF5Descriptor *descriptor = nullptr);
149
150 static void loadSampleDataISIScompatibility(::NeXus::File &file, EventWorkspaceCollection &WS);
151
154 static std::string readInstrumentFromISIS_VMSCompat(::NeXus::File &hFile);
155
156public:
158 std::string m_filename;
159
161 std::shared_ptr<EventWorkspaceCollection> m_ws;
162
167
169 int32_t m_specMin;
171 int32_t m_specMax;
172
174 Mantid::Types::Core::DateAndTime filter_time_start;
176 Mantid::Types::Core::DateAndTime filter_time_stop;
177
179 std::mutex m_tofMutex;
180
187 size_t bad_tofs;
191
194
196 std::shared_ptr<BankPulseTimes> m_allBanksPulseTimes;
197
199 std::string m_top_entry_name;
200 std::unique_ptr<::NeXus::File> m_file;
201
202protected:
203 Parallel::ExecutionMode
204 getParallelExecutionMode(const std::map<std::string, Parallel::StorageMode> &storageModes) const override;
205
206private:
208 enum class LoaderType;
209
211 void init() override;
212
214 void execLoader() override;
215
216 LoadEventNexus::LoaderType defineLoaderType(const bool haveWeights, const bool oldNeXusFileNames,
217 const std::string &classType) const;
218
220
221 void loadEvents(API::Progress *const prog, const bool monitors);
222 void createSpectraMapping(const std::string &nxsfile, const bool monitorsOnly,
223 const std::vector<std::string> &bankNames = std::vector<std::string>());
224 void deleteBanks(const EventWorkspaceCollection_sptr &workspace, const std::vector<std::string> &bankNames);
225 void runLoadMonitors();
227 void setTimeFilters(const bool monitors);
228 template <typename T>
229 T filterEventsByTime(T workspace, Mantid::Types::Core::DateAndTime &startTime,
230 Mantid::Types::Core::DateAndTime &stopTime);
231
233 std::unique_ptr<std::pair<std::vector<int32_t>, std::vector<int32_t>>>
234 loadISISVMSSpectraMapping(const std::string &entry_name);
235
236 template <typename T> void filterDuringPause(T workspace);
237
239 void setTopEntryName();
240
242 void safeOpenFile(const std::string &fname);
243
246
251};
252
253//-----------------------------------------------------------------------------
254// ISIS event corrections
255//-----------------------------------------------------------------------------
256
286template <typename T>
287void makeTimeOfFlightDataFuzzy(::NeXus::File &file, T localWorkspace, const std::string &binsName, size_t start_wi = 0,
288 size_t end_wi = 0) {
289 const std::string EVENT_TIME_SHIFT_TAG("event_time_offset_shift");
290 // first check if the data is already randomized
291 const auto entries = file.getEntries();
292 if (entries.find(EVENT_TIME_SHIFT_TAG) != entries.end()) {
293 std::string event_shift_type;
294 file.readData(EVENT_TIME_SHIFT_TAG, event_shift_type);
295 if (event_shift_type == "random") {
296 return;
297 }
298 }
299
300 // if the data is not randomized randomize it uniformly within each bin
301 file.openData(binsName);
302 // time of flights of events
303 std::vector<float> tofsFile;
304 file.getData(tofsFile);
305 file.closeData();
306
307 // todo: try to find if tof can be reduced to just 3 numbers: start, end and
308 // dt
309 if (end_wi <= start_wi) {
310 end_wi = localWorkspace->getNumberHistograms();
311 }
312
313 // random number generator
314 std::mt19937 rng;
315
316 // loop over spectra
317 for (size_t wi = start_wi; wi < end_wi; ++wi) {
318 DataObjects::EventList &event_list = dynamic_cast<DataObjects::EventList &>(localWorkspace->getSpectrum(wi));
319 if (event_list.empty())
320 continue;
321 // sort the events
322 event_list.sortTof();
323 auto tofsEventList = event_list.getTofs();
324
325 size_t n = tofsFile.size();
326 // iterate over the events and time bins
327 auto ev = tofsEventList.begin();
328 auto ev_end = tofsEventList.end();
329 for (size_t i = 1; i < n; ++i) {
330 double right = double(tofsFile[i]);
331 // find the right boundary for the current event
332 if ((ev != ev_end) && (right < *ev)) {
333 continue;
334 }
335 // count events which have the same right boundary
336 size_t m = 0;
337 while ((ev != ev_end) && (*ev < right)) {
338 ++ev;
339 ++m; // count events in the i-th bin
340 }
341
342 if (m > 0) { // m events in this bin
343 double left = double(tofsFile[i - 1]);
344 // spread the events uniformly inside the bin
345 std::uniform_real_distribution<double> flat(left, right);
346 std::vector<double> random_numbers(m);
347 std::generate(random_numbers.begin(), random_numbers.end(), [&flat, &rng]() { return flat(rng); });
348 std::sort(random_numbers.begin(), random_numbers.end());
349 auto it = random_numbers.begin();
350 for (auto ev1 = ev - m; ev1 != ev; ++ev1, ++it) {
351 *ev1 = *it;
352 }
353 }
354
355 } // for i
356 event_list.setTofs(tofsEventList);
357
358 event_list.sortTof();
359 } // for wi
360}
361
375template <typename T>
376void adjustTimeOfFlightISISLegacy(::NeXus::File &file, T localWorkspace, const std::string &entry_name,
377 const std::string &classType,
378 const Kernel::NexusHDF5Descriptor *descriptor = nullptr) {
379 bool done = false;
380 // Go to the root, and then top entry
381 file.openPath("/");
382 file.openGroup(entry_name, "NXentry");
383
384 // NexusHDF5Descriptor
385 if (descriptor != nullptr) {
386 // not an ISIS file
387 if (!descriptor->isEntry("/" + entry_name + "/detector_1_events")) {
388 return;
389 }
390 }
391
392 using string_map_t = std::map<std::string, std::string>;
393 string_map_t entries = file.getEntries();
394
395 if (entries.find("detector_1_events") == entries.end()) { // not an ISIS file
396 return;
397 }
398
399 // try if monitors have their own bins
400 if (classType == "NXmonitor") {
401 std::vector<std::string> bankNames;
402 for (string_map_t::const_iterator it = entries.begin(); it != entries.end(); ++it) {
403 std::string entryName(it->first);
404 std::string entry_class(it->second);
405 if (entry_class == classType) {
406 bankNames.emplace_back(entryName);
407 }
408 }
409 for (size_t i = 0; i < bankNames.size(); ++i) {
410 const std::string &mon = bankNames[i];
411 file.openGroup(mon, classType);
412 entries = file.getEntries();
413 if (entries.find("event_time_bins") == entries.end()) {
414 // bins = entries.find("time_of_flight"); // I think time_of_flight
415 // doesn't work here
416 // if (bins == entries.end())
417 //{
418 done = false;
419 file.closeGroup();
420 break; // done == false => use bins from the detectors
421 //}
422 }
423 done = true;
424 makeTimeOfFlightDataFuzzy(file, localWorkspace, "event_time_bins", i, i + 1);
425 file.closeGroup();
426 }
427 }
428
429 if (!done) {
430 // first check detector_1_events
431 file.openGroup("detector_1_events", "NXevent_data");
432 entries = file.getEntries();
433 for (string_map_t::const_iterator it = entries.begin(); it != entries.end(); ++it) {
434 if (it->first == "time_of_flight" || it->first == "event_time_bins") {
435 makeTimeOfFlightDataFuzzy(file, localWorkspace, it->first);
436 done = true;
437 }
438 }
439 file.closeGroup(); // detector_1_events
440
441 if (!done) { // if time_of_flight was not found try
442 // instrument/dae/time_channels_#
443 file.openGroup("instrument", "NXinstrument");
444 file.openGroup("dae", "IXdae");
445 entries = file.getEntries();
446 size_t time_channels_number = 0;
447 for (string_map_t::const_iterator it = entries.begin(); it != entries.end(); ++it) {
448 // check if there are groups with names "time_channels_#" and select the
449 // one with the highest number
450 if (it->first.size() > 14 && it->first.substr(0, 14) == "time_channels_") {
451 size_t n = boost::lexical_cast<size_t>(it->first.substr(14));
452 if (n > time_channels_number) {
453 time_channels_number = n;
454 }
455 }
456 }
457 if (time_channels_number > 0) // the numbers start with 1
458 {
459 file.openGroup("time_channels_" + std::to_string(time_channels_number), "IXtime_channels");
460 entries = file.getEntries();
461 for (string_map_t::const_iterator it = entries.begin(); it != entries.end(); ++it) {
462 if (it->first == "time_of_flight" || it->first == "event_time_bins") {
463 makeTimeOfFlightDataFuzzy(file, localWorkspace, it->first);
464 }
465 }
466 file.closeGroup();
467 }
468 file.closeGroup(); // dae
469 file.closeGroup(); // instrument
470 }
471 }
472
473 // close top entry (or entry given in entry_name)
474 file.closeGroup();
475}
476
477//-----------------------------------------------------------------------------
487template <typename T>
488bool LoadEventNexus::runLoadInstrument(const std::string &nexusfilename, T localWorkspace,
489 const std::string &top_entry_name, Algorithm *alg,
490 const Kernel::NexusHDF5Descriptor *descriptor) {
491 std::string instrument;
492 std::string instFilename;
493
494 const bool isNexus = (descriptor == nullptr) ? LoadGeometry::isNexus(nexusfilename)
495 : LoadGeometry::isNexus(nexusfilename, descriptor->getAllEntries());
496
497 // Check if the geometry can be loaded directly from the Nexus file
498 if (isNexus) {
499 instFilename = nexusfilename;
500 } else {
501 // Get the instrument name
502 ::NeXus::File nxfile(nexusfilename);
503 // Start with the base entry
504 nxfile.openGroup(top_entry_name, "NXentry");
505 // Open the instrument
506 nxfile.openGroup("instrument", "NXinstrument");
507 try {
508 nxfile.openData("name");
509 instrument = nxfile.getStrData();
510 alg->getLogger().debug() << "Instrument name read from NeXus file is " << instrument << '\n';
511 } catch (::NeXus::Exception &) {
512 // Try to fall back to isis compatibility options
513 nxfile.closeGroup();
514 instrument = readInstrumentFromISIS_VMSCompat(nxfile);
515 if (instrument.empty()) {
516 // Get the instrument name from the file instead
517 size_t n = nexusfilename.rfind('/');
518 if (n != std::string::npos) {
519 std::string temp = nexusfilename.substr(n + 1, nexusfilename.size() - n - 1);
520 n = temp.find('_');
521 if (n != std::string::npos && n > 0) {
522 instrument = temp.substr(0, n);
523 }
524 }
525 }
526 }
527 if (instrument == "POWGEN3") // hack for powgen b/c of bad long name
528 instrument = "POWGEN";
529 if (instrument == "NOM") // hack for nomad
530 instrument = "NOMAD";
531
532 if (instrument.empty())
533 throw std::runtime_error("Could not find the instrument name in the NXS "
534 "file or using the filename. Cannot load "
535 "instrument!");
536
537 // Now let's close the file as we don't need it anymore to load the
538 // instrument.
539 nxfile.close();
540 }
541
542 if (instFilename.empty()) {
543 try {
544 instFilename =
545 API::InstrumentFileFinder::getInstrumentFilename(instrument, localWorkspace->getWorkspaceStartDate());
547 if (instFilename.empty()) {
548 Poco::Path directory(Kernel::ConfigService::Instance().getInstrumentDirectory());
549 Poco::Path file(instrument + "_Definition.xml");
550 Poco::Path fullPath(directory, file);
551 instFilename = fullPath.toString();
552 }
553 }
554 }
555
556 // do the actual work
557 auto loadInst = alg->createChildAlgorithm("LoadInstrument");
558
559 // Now execute the Child Algorithm. Catch and log any error, but don't stop.
560 bool executionSuccessful(true);
561 try {
562 loadInst->setPropertyValue("Filename", instFilename);
563 loadInst->setPropertyValue("InstrumentName", instrument);
564 loadInst->setProperty<Mantid::API::MatrixWorkspace_sptr>("Workspace", localWorkspace);
565 loadInst->setProperty("RewriteSpectraMap", Mantid::Kernel::OptionalBool(false));
566 loadInst->execute();
567
568 // Populate the instrument parameters in this workspace - this works around
569 // a bug
570 localWorkspace->populateInstrumentParameters();
571 } catch (std::invalid_argument &e) {
572 alg->getLogger().information() << "Invalid argument to LoadInstrument Child Algorithm : " << e.what() << '\n';
573 executionSuccessful = false;
574 } catch (std::runtime_error &e) {
575 alg->getLogger().information("Unable to successfully run LoadInstrument Child Algorithm");
576 alg->getLogger().information(e.what());
577 executionSuccessful = false;
578 }
579
580 // If loading instrument definition file fails
581 if (!executionSuccessful) {
582 alg->getLogger().error() << "Error loading Instrument definition file\n";
583 return false;
584 }
585
586 // Ticket #2049: Cleanup all loadinstrument members to a single instance
587 // If requested update the instrument to positions in the data file
588 const auto &pmap = localWorkspace->constInstrumentParameters();
589 if (!pmap.contains(localWorkspace->getInstrument()->getComponentID(), "det-pos-source"))
590 return executionSuccessful;
591
592 std::shared_ptr<Geometry::Parameter> updateDets =
593 pmap.get(localWorkspace->getInstrument()->getComponentID(), "det-pos-source");
594 std::string value = updateDets->value<std::string>();
595 if (value.substr(0, 8) == "datafile") {
596 auto updateInst = alg->createChildAlgorithm("UpdateInstrumentFromFile");
597 updateInst->setProperty<Mantid::API::MatrixWorkspace_sptr>("Workspace", localWorkspace);
598 updateInst->setPropertyValue("Filename", nexusfilename);
599 if (value == "datafile-ignore-phi") {
600 updateInst->setProperty("IgnorePhi", true);
601 alg->getLogger().information("Detector positions in IDF updated with "
602 "positions in the data file except for the "
603 "phi values");
604 } else {
605 alg->getLogger().information("Detector positions in IDF updated with positions in the data file");
606 }
607 // We want this to throw if it fails to warn the user that the information
608 // is not correct.
609 updateInst->execute();
610 }
611
612 return executionSuccessful;
613}
614
615//-----------------------------------------------------------------------------
617template <typename T>
618void LoadEventNexus::loadEntryMetadata(const std::string &nexusfilename, T WS, const std::string &entry_name,
619 const Kernel::NexusHDF5Descriptor &descriptor) {
620 // Open the file
621 ::NeXus::File file(nexusfilename);
622 file.openGroup(entry_name, "NXentry");
623
624 // get the title
625 if (descriptor.isEntry("/" + entry_name + "/title", "SDS")) {
626 file.openData("title");
627 if (file.getInfo().type == ::NeXus::CHAR) {
628 std::string title = file.getStrData();
629 if (!title.empty())
630 WS->setTitle(title);
631 }
632 file.closeData();
633 }
634
635 // get the notes
636 if (descriptor.isEntry("/" + entry_name + "/notes", "SDS")) {
637 file.openData("notes");
638 if (file.getInfo().type == ::NeXus::CHAR) {
639 std::string notes = file.getStrData();
640 if (!notes.empty())
641 WS->mutableRun().addProperty("file_notes", notes, true);
642 }
643 file.closeData();
644 }
645
646 // Get the run number
647 if (descriptor.isEntry("/" + entry_name + "/run_number", "SDS")) {
648 file.openData("run_number");
649 std::string run;
650 if (file.getInfo().type == ::NeXus::CHAR) {
651 run = file.getStrData();
652 } else if (file.isDataInt()) {
653 // inside ISIS the run_number type is int32
654 std::vector<int> value;
655 file.getData(value);
656 if (!value.empty())
657 run = std::to_string(value[0]);
658 }
659 if (!run.empty()) {
660 WS->mutableRun().addProperty("run_number", run, true);
661 }
662 file.closeData();
663 }
664
665 // get the experiment identifier
666 if (descriptor.isEntry("/" + entry_name + "/experiment_identifier", "SDS")) {
667 file.openData("experiment_identifier");
668 std::string expId;
669 if (file.getInfo().type == ::NeXus::CHAR) {
670 expId = file.getStrData();
671 }
672 if (!expId.empty()) {
673 WS->mutableRun().addProperty("experiment_identifier", expId, true);
674 }
675 file.closeData();
676 }
677
678 // get the sample name - nested try/catch to leave the handle in an
679 // appropriate state
680 if (descriptor.isEntry("/" + entry_name + "/sample", "NXsample")) {
681 file.openGroup("sample", "NXsample");
682 try {
683 if (descriptor.isEntry("/" + entry_name + "/sample/name", "SDS")) {
684 file.openData("name");
685 const auto info = file.getInfo();
686 std::string name;
687 if (info.type == ::NeXus::CHAR) {
688 if (info.dims.size() == 1) {
689 name = file.getStrData();
690 } else { // something special for 2-d array
691 const int64_t total_length = std::accumulate(info.dims.begin(), info.dims.end(), static_cast<int64_t>(1),
692 std::multiplies<int64_t>());
693 boost::scoped_array<char> val_array(new char[total_length]);
694 file.getData(val_array.get());
695 name = std::string(val_array.get(), total_length);
696 }
697 }
698 file.closeData();
699 if (!name.empty()) {
700 WS->mutableSample().setName(name);
701 }
702 }
703 } catch (::NeXus::Exception &) {
704 // let it drop on floor if an exception occurs while reading sample
705 }
706 file.closeGroup();
707 }
708
709 // get the duration
710 if (descriptor.isEntry("/" + entry_name + "/duration", "SDS")) {
711 file.openData("duration");
712 std::vector<double> duration;
713 file.getDataCoerce(duration);
714 if (duration.size() == 1) {
715 // get the units
716 // clang-format off
717 std::vector< ::NeXus::AttrInfo> infos = file.getAttrInfos();
718 std::string units;
719 for (std::vector< ::NeXus::AttrInfo>::const_iterator it = infos.begin();
720 it != infos.end(); ++it) {
721 if (it->name == "units") {
722 units = file.getStrAttr(*it);
723 break;
724 }
725 }
726 // clang-format on
727
728 // set the property
729 WS->mutableRun().addProperty("duration", duration[0], units, true);
730 }
731 file.closeData();
732 }
733
734 // close the file
735 file.close();
736}
737
738//-----------------------------------------------------------------------------
750template <typename T>
751bool LoadEventNexus::loadInstrument(const std::string &nexusfilename, T localWorkspace,
752 const std::string &top_entry_name, Algorithm *alg,
753 const Kernel::NexusHDF5Descriptor *descriptor) {
754
755 bool loadNexusInstrumentXML = true;
756 if (alg->existsProperty("LoadNexusInstrumentXML"))
757 loadNexusInstrumentXML = alg->getProperty("LoadNexusInstrumentXML");
758
759 bool foundInstrument = false;
760 if (loadNexusInstrumentXML)
761 foundInstrument = runLoadIDFFromNexus<T>(nexusfilename, localWorkspace, top_entry_name, alg);
762 if (!foundInstrument)
763 foundInstrument = runLoadInstrument<T>(nexusfilename, localWorkspace, top_entry_name, alg, descriptor);
764 return foundInstrument;
765}
766
767//-----------------------------------------------------------------------------
777template <typename T>
778bool LoadEventNexus::runLoadIDFFromNexus(const std::string &nexusfilename, T localWorkspace,
779 const std::string &top_entry_name, Algorithm *alg) {
780 // Test if IDF exists in file, move on quickly if not
781 try {
782 ::NeXus::File nxsfile(nexusfilename);
783 nxsfile.openPath(top_entry_name + "/instrument/instrument_xml");
784 } catch (::NeXus::Exception &) {
785 alg->getLogger().information("No instrument XML definition found in " + nexusfilename + " at " + top_entry_name +
786 "/instrument");
787 return false;
788 }
789
790 auto loadInst = alg->createChildAlgorithm("LoadIDFFromNexus");
791
792 // Now execute the Child Algorithm. Catch and log any error, but don't stop.
793 try {
794 loadInst->setPropertyValue("Filename", nexusfilename);
795 loadInst->setProperty<Mantid::API::MatrixWorkspace_sptr>("Workspace", localWorkspace);
796 loadInst->setPropertyValue("InstrumentParentPath", top_entry_name);
797 loadInst->execute();
798 } catch (std::invalid_argument &) {
799 alg->getLogger().error("Invalid argument to LoadIDFFromNexus Child Algorithm ");
800 } catch (std::runtime_error &) {
801 alg->getLogger().debug("No instrument definition found by LoadIDFFromNexus in " + nexusfilename + " at " +
802 top_entry_name + "/instrument");
803 }
804
805 if (!loadInst->isExecuted())
806 alg->getLogger().information("No IDF loaded from Nexus file.");
807 return loadInst->isExecuted();
808}
809} // namespace DataHandling
810} // namespace Mantid
double value
The value of the point.
Definition: FitMW.cpp:51
IPeaksWorkspace_sptr workspace
Definition: IndexPeaks.cpp:114
double left
Definition: LineProfile.cpp:80
double right
Definition: LineProfile.cpp:81
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:85
bool existsProperty(const std::string &name) const override
Checks whether the named property is already in the list of managed property.
Definition: Algorithm.cpp:2008
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
Definition: Algorithm.cpp:2076
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.
Definition: Algorithm.cpp:842
Kernel::Logger & getLogger() const
Returns a reference to the logger.
Definition: Algorithm.cpp:1660
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)
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.
static bool runLoadInstrument(const std::string &nexusfilename, T localWorkspace, const std::string &top_entry_name, Algorithm *alg, const Kernel::NexusHDF5Descriptor *descriptor=nullptr)
Load instrument from IDF file specified by Nexus file.
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.
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.
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.
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
static void loadEntryMetadata(const std::string &nexusfilename, T WS, const std::string &entry_name, const Kernel::NexusHDF5Descriptor &descriptor)
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 Kernel::NexusHDF5Descriptor *descriptor=nullptr)
Load instrument from Nexus file if possible, else from IDF spacified by Nexus file.
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::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:56
void setTofs(const MantidVec &tofs) override
Set a list of TOFs to the current event list.
Definition: EventList.cpp:3226
void sortTof() const
Sort events by TOF in one thread.
Definition: EventList.cpp:947
bool empty() const
Much like stl containers, returns true if there is nothing in the event list.
Definition: EventList.cpp:1158
void getTofs(std::vector< double > &tofs) const override
Fill a vector with the list of TOFs.
Definition: EventList.cpp:2734
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:114
void error(const std::string &msg)
Logs at error level.
Definition: Logger.cpp:77
void information(const std::string &msg)
Logs at information level.
Definition: Logger.cpp:105
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.
bool isEntry(const std::string &entryName, const std::string &groupClass) const noexcept
Checks if a full-path entry exists for a particular groupClass in a Nexus dataset.
OptionalBool : Tri-state bool.
Definition: OptionalBool.h:25
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
A specialised Property class for holding a series of time-value pairs.
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.
bool exists(::NeXus::File &file, const std::string &name)
Based on the current group in the file, does the named sub-entry exist?
std::shared_ptr< EventWorkspaceCollection > EventWorkspaceCollection_sptr
void adjustTimeOfFlightISISLegacy(::NeXus::File &file, T localWorkspace, const std::string &entry_name, const std::string &classType, const Kernel::NexusHDF5Descriptor *descriptor=nullptr)
ISIS specific method for dealing with wide events.
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)