Mantid
Loading...
Searching...
No Matches
SinglePeriodLoadMuonStrategy.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2020 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#include "MantidAPI/Run.h"
13
14namespace Mantid::DataHandling {
15
16using namespace API;
17using namespace NeXus;
18using std::size_t;
19using namespace DataObjects;
20
21// Constructor
23 LoadMuonNexusV2NexusHelper &nexusLoader,
24 Workspace2D &workspace, int entryNumber,
25 bool isFileMultiPeriod)
26 : LoadMuonStrategy(g_log, filename, nexusLoader), m_workspace(workspace), m_entryNumber(entryNumber),
27 m_isFileMultiPeriod(isFileMultiPeriod), m_detectors(getLoadedDetectors()) {}
28
34
35 auto &run = m_workspace.mutableRun();
36 auto sampleInformation = m_nexusLoader.loadSampleInformationFromNexus();
37 std::string mainFieldDirection = m_nexusLoader.loadMainFieldDirectionFromNexus();
38 double firstGoodData = m_nexusLoader.loadFirstGoodDataFromNexus();
39
40 run.addProperty("sample_temp", sampleInformation.temperature);
41 run.addProperty("sample_magn_field", sampleInformation.magneticField);
42 run.addProperty("main_field_direction", mainFieldDirection);
43 run.addProperty("FirstGoodData", firstGoodData);
44}
45
50 // Overwrite existing log entry
51 std::string goodframeProp{"goodfrm"};
52 auto &run = m_workspace.mutableRun();
53 run.removeProperty(goodframeProp);
55
57 run.addProperty(goodframeProp, goodframes[m_entryNumber - 1]);
58 } else {
59 run.addProperty(goodframeProp, goodframes[0]);
60 }
61}
62
70
73
74 if (table->rowCount() != 0) {
75 return table;
76 } else {
77 m_logger.notice("Loading grouping information from IDF");
79 }
80}
87 return createDeadTimeTable(m_detectors, deadTimes);
88}
94 const auto numSpec = m_workspace.getNumberHistograms();
95 auto timeZeros = m_nexusLoader.loadTimeZeroListFromNexusFile(numSpec);
96 return createTimeZeroTable(numSpec, timeZeros);
97}
102 double timeZero = m_nexusLoader.loadTimeZeroFromNexusFile();
103 auto numHistograms = m_workspace.getNumberHistograms();
104 for (size_t i = 0; i < numHistograms; ++i) {
105 auto &timeAxis = m_workspace.mutableX(i);
106 timeAxis = timeAxis - timeZero;
107 }
108}
114}
115} // namespace Mantid::DataHandling
IPeaksWorkspace_sptr workspace
Definition: IndexPeaks.cpp:114
Run & mutableRun()
Writable version of the run object.
void removeProperty(const std::string &name, bool delProperty=true)
Remove a named property.
Definition: LogManager.cpp:275
HistogramData::HistogramX & mutableX(const size_t index) &
std::vector< double > loadDeadTimesFromNexus(const std::vector< detid_t > &loadedDetectors, bool isFileMultiPeriod, int periodNumber)
std::vector< detid_t > loadDetectorGroupingFromNexus(const std::vector< detid_t > &loadedDetectors, bool isFileMultiPeriod, int periodNumber)
std::vector< double > loadTimeZeroListFromNexusFile(size_t numSpectra)
NeXus::NXInt loadGoodFramesDataFromNexus(bool isFileMultiPeriod)
DataObjects::TableWorkspace_sptr createDeadTimeTable(const std::vector< detid_t > &detectorsLoaded, const std::vector< double > &deadTimes) const
Creates the deadtime table for the loaded detectors .
std::vector< detid_t > getLoadedDetectorsFromWorkspace(const DataObjects::Workspace2D &localWorkspace) const
Determines the detectors loaded in the input workspace.
API::Workspace_sptr loadDefaultDetectorGrouping(const DataObjects::Workspace2D &localWorkspace) const
Loads default detector grouping, if this isn't present return dummy grouping.
DataObjects::TableWorkspace_sptr createDetectorGroupingTable(const std::vector< detid_t > &specToLoad, const std::vector< detid_t > &grouping) const
Creates Detector Grouping Table .
LoadMuonNexusV2NexusHelper & m_nexusLoader
void loadGoodFrames() override
Loads the good frames data into the stored workspace object.
API::Workspace_sptr loadDeadTimeTable() const override
Loads deadtime table from nexus file.
API::Workspace_sptr loadDetectorGrouping() const override
Loads detector grouping.
void loadMuonLogData() override
Loads Muon specific logs into the stored workspace These are logs which are not loaded by LoadISISNex...
SinglePeriodLoadMuonStrategy(Kernel::Logger &g_log, const std::string &filename, LoadMuonNexusV2NexusHelper &nexusLoader, DataObjects::Workspace2D &workspace, int entryNumber, bool isFileMultiPeriod)
std::vector< detid_t > getLoadedDetectors()
Finds the detectors which are loaded in the stored workspace.
void applyTimeZeroCorrection() override
Performs time-zero correction on the loaded workspace.
API::Workspace_sptr getTimeZeroTable() override
Gets time zero table from loaded time zeros.
Concrete workspace implementation.
Definition: Workspace2D.h:29
std::size_t getNumberHistograms() const override
Returns the histogram number.
The Logger class is in charge of the publishing messages from the framework through various channels.
Definition: Logger.h:52
void notice(const std::string &msg)
Logs at notice level.
Definition: Logger.cpp:95
Templated class implementation of NXDataSet.
Definition: NexusClasses.h:203
std::shared_ptr< Workspace > Workspace_sptr
shared pointer to Mantid::API::Workspace
Definition: Workspace_fwd.h:20
Kernel::Logger g_log("ExperimentInfo")
static logger object
DataObjects::TableWorkspace_sptr createTimeZeroTable(const size_t numSpec, const std::vector< double > &timeZeros)
Creates a timezero table for the loaded detectors.
std::shared_ptr< TableWorkspace > TableWorkspace_sptr
shared pointer to Mantid::DataObjects::TableWorkspace