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 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 { return {"LoadISISNexus", "LoadEventAndCompress"}; }
93
95 const std::string category() const override { return "DataHandling\\Nexus"; }
96
97 int confidence(Nexus::NexusDescriptorLazy &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 int 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, std::string &status);
113
114 template <typename T>
115 static void loadEntryMetadata(const std::string &nexusfilename, T WS, const std::string &entry_name);
116
118 template <typename T>
119 static bool loadInstrument(const std::string &nexusfilename, T localWorkspace, const std::string &top_entry_name,
120 Algorithm *alg, const Nexus::NexusDescriptor *descriptor = nullptr);
121
123 template <typename T>
124 static bool runLoadIDFFromNexus(const std::string &nexusfilename, T localWorkspace, const std::string &top_entry_name,
125 Algorithm *alg);
126
128 template <typename T>
129 static bool runLoadInstrument(const std::string &nexusfilename, T localWorkspace, const std::string &top_entry_name,
130 Algorithm *alg, const Nexus::NexusDescriptor *descriptor = nullptr);
131
132 static void loadSampleDataISIScompatibility(Nexus::File &file, EventWorkspaceCollection &WS);
133
136 static std::string readInstrumentFromISIS_VMSCompat(Nexus::File &hFile);
137
138public:
140 std::string m_filename;
141
143 std::shared_ptr<EventWorkspaceCollection> m_ws;
144
151
153 int32_t m_specMin;
155 int32_t m_specMax;
156
158 Mantid::Types::Core::DateAndTime filter_time_start;
160 Mantid::Types::Core::DateAndTime filter_time_stop;
162 bool m_is_time_filtered{false};
163
164 bool filter_bad_pulses{false};
165 std::shared_ptr<Mantid::Kernel::TimeROI> bad_pulses_timeroi;
166
168 std::mutex m_tofMutex;
169
176 size_t bad_tofs;
180
184
186 std::shared_ptr<BankPulseTimes> m_allBanksPulseTimes;
187
189 std::string m_top_entry_name;
190 std::unique_ptr<Nexus::File> m_file;
191
192private:
194 void init() override;
195
197 void exec() override;
198
199 std::map<std::string, std::string> validateInputs() override;
200
202
203 void loadEvents(API::Progress *const prog, const bool monitors);
204 void createSpectraMapping(const std::string &nxsfile, const bool monitorsOnly,
205 const std::vector<std::string> &bankNames = std::vector<std::string>());
206 void deleteBanks(const EventWorkspaceCollection_sptr &workspace, const std::vector<std::string> &bankNames);
207 void runLoadMonitors();
209 void setTimeFilters(const bool monitors);
210 template <typename T>
211 T filterEventsByTime(T workspace, Mantid::Types::Core::DateAndTime &startTime,
212 Mantid::Types::Core::DateAndTime &stopTime);
213
215 std::unique_ptr<std::pair<std::vector<int32_t>, std::vector<int32_t>>>
216 loadISISVMSSpectraMapping(const std::string &entry_name);
217
218 template <typename T> void filterDuringPause(T workspace);
219
221 void setTopEntryName();
222
224 void safeOpenFile(const std::string &fname);
225
228
233};
234
235//-----------------------------------------------------------------------------
236// ISIS event corrections
237//-----------------------------------------------------------------------------
238
268template <typename T>
269void makeTimeOfFlightDataFuzzy(Nexus::File &file, T localWorkspace, const std::string &binsName, size_t start_wi = 0,
270 size_t end_wi = 0) {
271 // if the data is not randomized randomize it uniformly within each bin
272 file.openData(binsName);
273 // time of flights of events
274 std::vector<float> tofsFile;
275 file.getData(tofsFile);
276 file.closeData();
277
278 // todo: try to find if tof can be reduced to just 3 numbers: start, end and
279 // dt
280 if (end_wi <= start_wi) {
281 end_wi = localWorkspace->getNumberHistograms();
282 }
283
284 // random number generator
285 std::mt19937 rng;
286
287 // loop over spectra
288 for (size_t wi = start_wi; wi < end_wi; ++wi) {
289 DataObjects::EventList &event_list = dynamic_cast<DataObjects::EventList &>(localWorkspace->getSpectrum(wi));
290 if (event_list.empty())
291 continue;
292 // sort the events
293 event_list.sortTof();
294 auto tofsEventList = event_list.getTofs();
295
296 size_t n = tofsFile.size();
297 // iterate over the events and time bins
298 auto ev = tofsEventList.begin();
299 auto ev_end = tofsEventList.end();
300 for (size_t i = 1; i < n; ++i) {
301 double right = double(tofsFile[i]);
302 // find the right boundary for the current event
303 if ((ev != ev_end) && (right < *ev)) {
304 continue;
305 }
306 // count events which have the same right boundary
307 size_t m = 0;
308 while ((ev != ev_end) && (*ev < right)) {
309 ++ev;
310 ++m; // count events in the i-th bin
311 }
312
313 if (m > 0) { // m events in this bin
314 double left = double(tofsFile[i - 1]);
315 // spread the events uniformly inside the bin
316 std::uniform_real_distribution<double> flat(left, right);
317 std::vector<double> random_numbers(m);
318 std::generate(random_numbers.begin(), random_numbers.end(), [&flat, &rng]() { return flat(rng); });
319 std::sort(random_numbers.begin(), random_numbers.end());
320 auto it = random_numbers.begin();
321 for (auto ev1 = ev - m; ev1 != ev; ++ev1, ++it) {
322 *ev1 = *it;
323 }
324 }
325
326 } // for i
327 event_list.setTofs(tofsEventList);
328
329 event_list.sortTof();
330 } // for wi
331}
332
345template <typename T>
346void adjustTimeOfFlightISISLegacy(Nexus::File &file, T localWorkspace, const std::string &entry_name,
347 const std::string &classType) {
348 bool done = false;
349 // Go to the root, and then top entry
350 file.openAddress("/");
351 file.openGroup(entry_name, "NXentry");
352
353 using string_map_t = std::map<std::string, std::string>;
354 string_map_t entries = file.getEntries();
355 // try if monitors have their own bins
356 if (classType == "NXmonitor") {
357 std::vector<std::string> bankNames;
358 for (string_map_t::const_iterator it = entries.begin(); it != entries.end(); ++it) {
359 const std::string entry_class(it->second);
360 if (entry_class == classType) {
361 const std::string entryName(it->first);
362 bankNames.emplace_back(entryName);
363 }
364 }
365 for (size_t i = 0; i < bankNames.size(); ++i) {
366 const std::string &mon = bankNames[i];
367 file.openGroup(mon, classType);
368 entries = file.getEntries();
369 if (entries.find("event_time_bins") == entries.end()) {
370 // bins = entries.find("time_of_flight"); // I think time_of_flight
371 // doesn't work here
372 // if (bins == entries.end())
373 //{
374 done = false;
375 file.closeGroup();
376 break; // done == false => use bins from the detectors
377 //}
378 }
379 done = true;
380 makeTimeOfFlightDataFuzzy(file, localWorkspace, "event_time_bins", i, i + 1);
381 file.closeGroup();
382 }
383 }
384
385 if (!done) {
386 // first check detector_1_events
387 file.openGroup("detector_1_events", "NXevent_data");
388 entries = file.getEntries();
389 for (string_map_t::const_iterator it = entries.begin(); it != entries.end(); ++it) {
390 if (it->first == "time_of_flight" || it->first == "event_time_bins") {
391 makeTimeOfFlightDataFuzzy(file, localWorkspace, it->first);
392 done = true;
393 }
394 }
395 file.closeGroup(); // detector_1_events
396
397 if (!done) { // if time_of_flight was not found try
398 // instrument/dae/time_channels_#
399 file.openGroup("instrument", "NXinstrument");
400 file.openGroup("dae", "IXdae");
401 entries = file.getEntries();
402 size_t time_channels_number = 0;
403 for (string_map_t::const_iterator it = entries.begin(); it != entries.end(); ++it) {
404 // check if there are groups with names "time_channels_#" and select the
405 // one with the highest number
406 if (it->first.size() > 14 && it->first.substr(0, 14) == "time_channels_") {
407 size_t n = boost::lexical_cast<size_t>(it->first.substr(14));
408 if (n > time_channels_number) {
409 time_channels_number = n;
410 }
411 }
412 }
413 if (time_channels_number > 0) // the numbers start with 1
414 {
415 file.openGroup("time_channels_" + std::to_string(time_channels_number), "IXtime_channels");
416 entries = file.getEntries();
417 for (string_map_t::const_iterator it = entries.begin(); it != entries.end(); ++it) {
418 if (it->first == "time_of_flight" || it->first == "event_time_bins") {
419 makeTimeOfFlightDataFuzzy(file, localWorkspace, it->first);
420 }
421 }
422 file.closeGroup();
423 }
424 file.closeGroup(); // dae
425 file.closeGroup(); // instrument
426 }
427 }
428
429 // close top entry (or entry given in entry_name)
430 file.closeGroup();
431}
432
433//-----------------------------------------------------------------------------
444template <typename T>
445bool LoadEventNexus::runLoadInstrument(const std::string &nexusfilename, T localWorkspace,
446 const std::string &top_entry_name, Algorithm *alg,
447 const Nexus::NexusDescriptor *descriptor) {
448 std::string instrument;
449 std::string instFilename;
450
451 const bool isNexus = (descriptor == nullptr) ? LoadGeometry::isNexus(nexusfilename)
452 : LoadGeometry::isNexus(descriptor->getAllEntries());
453
454 // Check if the geometry can be loaded directly from the Nexus file
455 if (isNexus) {
456 instFilename = nexusfilename;
457 } else {
458 // Get the instrument name
459 Nexus::File nxfile(nexusfilename);
460 // Start with the base entry
461 nxfile.openGroup(top_entry_name, "NXentry");
462 // Open the instrument
463 nxfile.openGroup("instrument", "NXinstrument");
464 try {
465 nxfile.openData("name");
466 instrument = nxfile.getStrData();
467 alg->getLogger().debug() << "Instrument name read from NeXus file is " << instrument << '\n';
468 } catch (Nexus::Exception const &) {
469 // Try to fall back to isis compatibility options
470 nxfile.closeGroup();
471 instrument = readInstrumentFromISIS_VMSCompat(nxfile);
472 if (instrument.empty()) {
473 // Get the instrument name from the file instead
474 size_t n = nexusfilename.rfind('/');
475 if (n != std::string::npos) {
476 std::string temp = nexusfilename.substr(n + 1, nexusfilename.size() - n - 1);
477 n = temp.find('_');
478 if (n != std::string::npos && n > 0) {
479 instrument = temp.substr(0, n);
480 }
481 }
482 }
483 }
484 if (instrument == "POWGEN3") // hack for powgen b/c of bad long name
485 instrument = "POWGEN";
486 if (instrument == "NOM") // hack for nomad
487 instrument = "NOMAD";
488
489 if (instrument.empty())
490 throw std::runtime_error("Could not find the instrument name in the NXS "
491 "file or using the filename. Cannot load "
492 "instrument!");
493
494 // Now let's close the file as we don't need it anymore to load the
495 // instrument.
496 nxfile.close();
497 }
498
499 if (instFilename.empty()) {
500 try {
501 instFilename =
502 API::InstrumentFileFinder::getInstrumentFilename(instrument, localWorkspace->getWorkspaceStartDate());
504 if (instFilename.empty()) {
505 std::filesystem::path directory(Kernel::ConfigService::Instance().getInstrumentDirectory());
506 std::filesystem::path file(instrument + "_Definition.xml");
507 std::filesystem::path fullPath = directory / file;
508 instFilename = fullPath.string();
509 }
510 }
511 }
512
513 // do the actual work
514 auto loadInst = alg->createChildAlgorithm("LoadInstrument");
515
516 // Now execute the Child Algorithm. Catch and log any error, but don't stop.
517 bool executionSuccessful(true);
518 try {
519 loadInst->setPropertyValue("Filename", instFilename);
520 loadInst->setPropertyValue("InstrumentName", instrument);
521 loadInst->setProperty<Mantid::API::MatrixWorkspace_sptr>("Workspace", localWorkspace);
522 loadInst->setProperty("RewriteSpectraMap", Mantid::Kernel::OptionalBool(false));
523 loadInst->execute();
524
525 // Populate the instrument parameters in this workspace - this works around
526 // a bug
527 localWorkspace->populateInstrumentParameters();
528 } catch (std::invalid_argument &e) {
529 alg->getLogger().information() << "Invalid argument to LoadInstrument Child Algorithm : " << e.what() << '\n';
530 executionSuccessful = false;
531 } catch (std::runtime_error &e) {
532 alg->getLogger().information("Unable to successfully run LoadInstrument Child Algorithm");
533 alg->getLogger().information(e.what());
534 executionSuccessful = false;
535 }
536
537 // If loading instrument definition file fails
538 if (!executionSuccessful) {
539 alg->getLogger().error() << "Error loading Instrument definition file\n";
540 return false;
541 }
542
543 // Ticket #2049: Cleanup all loadinstrument members to a single instance
544 // If requested update the instrument to positions in the data file
545 const auto &pmap = localWorkspace->constInstrumentParameters();
546 if (!pmap.contains(localWorkspace->getInstrument()->getComponentID(), "det-pos-source"))
547 return executionSuccessful;
548
549 std::shared_ptr<Geometry::Parameter> updateDets =
550 pmap.get(localWorkspace->getInstrument()->getComponentID(), "det-pos-source");
551 std::string value = updateDets->value<std::string>();
552 if (value.substr(0, 8) == "datafile") {
553 auto updateInst = alg->createChildAlgorithm("UpdateInstrumentFromFile");
554 updateInst->setProperty<Mantid::API::MatrixWorkspace_sptr>("Workspace", localWorkspace);
555 updateInst->setPropertyValue("Filename", nexusfilename);
556 if (value == "datafile-ignore-phi") {
557 updateInst->setProperty("IgnorePhi", true);
558 alg->getLogger().information("Detector positions in IDF updated with "
559 "positions in the data file except for the "
560 "phi values");
561 } else {
562 alg->getLogger().information("Detector positions in IDF updated with positions in the data file");
563 }
564 // We want this to throw if it fails to warn the user that the information
565 // is not correct.
566 updateInst->execute();
567 }
568
569 return executionSuccessful;
570}
571
572//-----------------------------------------------------------------------------
574template <typename T>
575void LoadEventNexus::loadEntryMetadata(const std::string &nexusfilename, T WS, const std::string &entry_name) {
576 // Open the file
577 Nexus::File file(nexusfilename);
578 file.openGroup(entry_name, "NXentry");
579
580 // get the title
581 if (file.hasData("/" + entry_name + "/title")) {
582 file.openData("title");
583 if (file.getInfo().type == NXnumtype::CHAR) {
584 std::string title = file.getStrData();
585 if (!title.empty())
586 WS->setTitle(title);
587 }
588 file.closeData();
589 }
590
591 // get the notes
592 if (file.hasData("/" + entry_name + "/notes")) {
593 file.openData("notes");
594 if (file.getInfo().type == NXnumtype::CHAR) {
595 std::string notes = file.getStrData();
596 if (!notes.empty())
597 WS->mutableRun().addProperty("file_notes", notes, true);
598 }
599 file.closeData();
600 }
601
602 // Get the run number
603 if (file.hasData("/" + entry_name + "/run_number")) {
604 file.openData("run_number");
605 std::string run;
606 if (file.getInfo().type == NXnumtype::CHAR) {
607 run = file.getStrData();
608 } else if (file.isDataInt()) {
609 // inside ISIS the run_number type is int32
610 std::vector<int> value;
611 file.getData(value);
612 if (!value.empty())
613 run = std::to_string(value[0]);
614 }
615 if (!run.empty()) {
616 WS->mutableRun().addProperty("run_number", run, true);
617 }
618 file.closeData();
619 }
620
621 // get the experiment identifier
622 if (file.hasData("/" + entry_name + "/experiment_identifier")) {
623 file.openData("experiment_identifier");
624 std::string expId;
625 if (file.getInfo().type == NXnumtype::CHAR) {
626 expId = file.getStrData();
627 }
628 if (!expId.empty()) {
629 WS->mutableRun().addProperty("experiment_identifier", expId, true);
630 }
631 file.closeData();
632 }
633
634 // get the sample name - nested try/catch to leave the handle in an
635 // appropriate state
636 if (file.hasGroup("/" + entry_name + "/sample", "NXsample")) {
637 file.openGroup("sample", "NXsample");
638 try {
639 if (file.hasData("/" + entry_name + "/sample/name")) {
640 file.openData("name");
641 const auto info = file.getInfo();
642 std::string sampleName;
643 if (info.type == NXnumtype::CHAR) {
644 if (info.dims.size() == 1) {
645 sampleName = file.getStrData();
646 } else { // something special for 2-d array
647 const int64_t total_length = std::accumulate(info.dims.begin(), info.dims.end(), static_cast<int64_t>(1),
648 std::multiplies<int64_t>());
649 boost::scoped_array<char> val_array(new char[total_length]);
650 file.getData(val_array.get());
651 sampleName = std::string(val_array.get(), total_length);
652 }
653 }
654 file.closeData();
655 if (!sampleName.empty()) {
656 WS->mutableSample().setName(sampleName);
657 }
658 }
659 } catch (Nexus::Exception const &) {
660 // let it drop on floor if an exception occurs while reading sample
661 }
662 file.closeGroup();
663 }
664
665 // get the duration
666 if (file.hasData("/" + entry_name + "/duration")) {
667 file.openData("duration");
668 std::vector<double> duration;
669 file.getDataCoerce(duration);
670 if (duration.size() == 1) {
671 // get the units
672 std::string units;
673 if (file.hasAttr("units")) {
674 file.getAttr<std::string>("units", units);
675 }
676
677 // set the property
678 WS->mutableRun().addProperty("duration", duration[0], units, true);
679 }
680 file.closeData();
681 }
682
683 // close the file
684 file.close();
685}
686
687//-----------------------------------------------------------------------------
700template <typename T>
701bool LoadEventNexus::loadInstrument(const std::string &nexusfilename, T localWorkspace,
702 const std::string &top_entry_name, Algorithm *alg,
703 const Nexus::NexusDescriptor *descriptor) {
704
705 bool loadNexusInstrumentXML = true;
706 if (alg->existsProperty("LoadNexusInstrumentXML"))
707 loadNexusInstrumentXML = alg->getProperty("LoadNexusInstrumentXML");
708
709 bool foundInstrument = false;
710 if (loadNexusInstrumentXML)
711 foundInstrument = runLoadIDFFromNexus<T>(nexusfilename, localWorkspace, top_entry_name, alg);
712 if (!foundInstrument)
713 foundInstrument = runLoadInstrument<T>(nexusfilename, std::move(localWorkspace), top_entry_name, alg, descriptor);
714 return foundInstrument;
715}
716
717//-----------------------------------------------------------------------------
727template <typename T>
728bool LoadEventNexus::runLoadIDFFromNexus(const std::string &nexusfilename, T localWorkspace,
729 const std::string &top_entry_name, Algorithm *alg) {
730 // Test if IDF exists in file, move on quickly if not
731 try {
732 Nexus::File nxsfile(nexusfilename);
733 nxsfile.openAddress(top_entry_name + "/instrument/instrument_xml");
734 } catch (Nexus::Exception const &) {
735 alg->getLogger().information("No instrument XML definition found in " + nexusfilename + " at " + top_entry_name +
736 "/instrument");
737 return false;
738 }
739
740 auto loadInst = alg->createChildAlgorithm("LoadIDFFromNexus");
741
742 // Now execute the Child Algorithm. Catch and log any error, but don't stop.
743 try {
744 loadInst->setPropertyValue("Filename", nexusfilename);
745 loadInst->setProperty<Mantid::API::MatrixWorkspace_sptr>("Workspace", localWorkspace);
746 loadInst->setPropertyValue("InstrumentParentPath", top_entry_name);
747 loadInst->execute();
748 } catch (std::invalid_argument &) {
749 alg->getLogger().error("Invalid argument to LoadIDFFromNexus Child Algorithm ");
750 } catch (std::runtime_error &) {
751 alg->getLogger().debug("No instrument definition found by LoadIDFFromNexus in " + nexusfilename + " at " +
752 top_entry_name + "/instrument");
753 }
754
755 if (!loadInst->isExecuted())
756 alg->getLogger().information("No IDF loaded from Nexus file.");
757 return loadInst->isExecuted();
758}
759} // namespace DataHandling
760} // 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)