32using namespace Kernel;
35using namespace HistogramData;
37using namespace DataObjects;
42const std::string
BEAMLINE{
"/raw_data_1/beamline"};
47 : m_filename(), m_entrynumber(0), m_isFileMultiPeriod(false), m_multiPeriodsLoaded(false) {}
72 std::string def = file.getStrData();
73 if (def ==
"muonTD" || def ==
"pulsedTD") {
83 std::vector<std::string> extensions{
".nxs",
".nxs_v2"};
85 "The name of the Nexus file to load");
88 "The name of the workspace to be created as the output of the\n"
89 "algorithm. For multiperiod files, one workspace will be\n"
90 "generated for each period");
92 auto mustBePositiveSpectra = std::make_shared<BoundedValidator<specnum_t>>();
93 mustBePositiveSpectra->setLower(0);
97 auto mustBePositive = std::make_shared<BoundedValidator<int64_t>>();
98 mustBePositive->setLower(0);
100 "0 indicates that every entry is loaded, into a separate "
101 "workspace within a group. "
102 "A positive number identifies one entry to be loaded, into "
105 std::vector<std::string> FieldOptions{
"Transverse",
"Longitudinal"};
106 declareProperty(
"MainFieldDirection",
"Transverse", std::make_shared<StringListValidator>(FieldOptions),
107 "Output the main field direction if specified in Nexus file "
108 "(default longitudinal).",
112 declareProperty(
"FirstGoodData", 0.0,
"First good data in units of micro-seconds (default to 0.0)",
117 "A vector of time zero values");
121 "TableWorkspace containing time zero values per spectra.");
123 declareProperty(
"CorrectTime",
true,
"Boolean flag controlling whether time should be corrected by timezero.",
128 "Table or a group of tables containing detector dead times.");
132 "Table or a group of tables with information about the "
133 "detector grouping.");
142 m_nexusLoader = std::make_unique<LoadMuonNexusV2NexusHelper>(entry);
158 setProperty(
"DetectorGroupingTable", loadedGrouping);
180 if (numberOfPeriods > 1) {
204 struct ScopedNumThreadsSetter {
205 ScopedNumThreadsSetter(
const int numThreads) {
211 int globalNumberOfThreads;
213 ScopedNumThreadsSetter restoreDefaultThreadsOnExit(1);
216 auto ISISLoader = std::dynamic_pointer_cast<API::Algorithm>(childAlg);
217 ISISLoader->copyPropertiesFrom(*
this);
218 ISISLoader->execute();
233 assert(workspaceGroup);
234 auto numberHistograms = std::dynamic_pointer_cast<Workspace2D>(workspaceGroup->getItem(0))->getNumberHistograms();
255 std::string mainFieldDirection =
m_nexusLoader->loadMainFieldDirectionFromNexus();
256 setProperty(
"MainFieldDirection", mainFieldDirection);
258 double timeZero =
m_nexusLoader->loadTimeZeroFromNexusFile();
261 auto firstGoodData =
m_nexusLoader->loadFirstGoodDataFromNexus();
264 auto lastGoodData =
m_nexusLoader->loadLastGoodDataFromNexus();
267 auto timeZeroVector =
m_nexusLoader->loadTimeZeroListFromNexusFile(numSpectra);
279 if (workspaceGroup) {
280 for (
int i = 0; i < workspaceGroup->getNumberOfEntries(); ++i) {
281 auto workspace2D = std::dynamic_pointer_cast<Workspace2D>(workspaceGroup->getItem(i));
282 workspace2D->getAxis(0)->unit() = newUnit;
293 auto sequences =
m_nexusLoader->getPeriodSequenceString(numberOfPeriods);
295 auto requested =
m_nexusLoader->getPeriodFramesRequested(numberOfPeriods);
296 auto rawFrames =
m_nexusLoader->getPeriodRawFrames(numberOfPeriods);
297 auto output =
m_nexusLoader->getPeriodOutput(numberOfPeriods);
298 auto counts =
m_nexusLoader->getPeriodTotalCounts(numberOfPeriods);
301 if (workspaceGroup) {
302 for (
int i = 0; i < workspaceGroup->getNumberOfEntries(); ++i) {
303 auto workspace2D = std::dynamic_pointer_cast<Workspace2D>(workspaceGroup->getItem(i));
304 auto &run = workspace2D->mutableRun();
305 run.addProperty(
"period_labels", labels);
306 run.addProperty(
"period_sequences", sequences);
307 run.addProperty(
"period_type", types);
308 run.addProperty(
"frames_period_requested", requested);
309 run.addProperty(
"frames_period_raw", rawFrames);
310 run.addProperty(
"period_output", output);
311 run.addProperty(
"total_counts_period", counts);
317 run.addProperty(
"period_sequences", sequences);
318 run.addProperty(
"period_type", types);
319 run.addProperty(
"frames_period_requested", requested);
320 run.addProperty(
"frames_period_raw", rawFrames);
321 run.addProperty(
"period_output", output);
322 run.addProperty(
"total_counts_period", counts);
IPeaksWorkspace_sptr workspace
#define PARALLEL_SET_NUM_THREADS(MaxCores)
#define PARALLEL_GET_MAX_THREADS
#define DECLARE_NEXUS_HDF5_FILELOADER_ALGORITHM(classname)
DECLARE_NEXUS_HDF5_FILELOADER_ALGORITHM should be used in place of the standard DECLARE_ALGORITHM mac...
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
std::string getPropertyValue(const std::string &name) const override
Get the value of a property as a string.
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
virtual void copyPropertiesFrom(const Algorithm &alg)
Make m_properties point to the same PropertyManager as alg.m_properties.
const std::shared_ptr< Kernel::Unit > & unit() const
The unit for this axis.
Run & mutableRun()
Writable version of the run object.
@ Load
allowed here which will be passed to the algorithm
void addProperty(Kernel::Property *prop, bool overwrite=false)
Add data to the object in the form of a property.
virtual Axis * getAxis(const std::size_t &axisIndex) const
Get a non owning pointer to a workspace axis.
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) override
Create a Child Algorithm.
Class to hold a set of workspaces.
A property class for workspaces.
Base Workspace Abstract Class.
std::unique_ptr< LoadMuonStrategy > m_loadMuonStrategy
bool m_multiPeriodsLoaded
void isEntryMultiPeriod()
Determines whether the file is multi period If multi period the function determines whether multi per...
std::string m_filename
The name and path of the input file.
void applyTimeAxisUnitCorrection(API::Workspace &workspace)
std::unique_ptr< LoadMuonNexusV2NexusHelper > m_nexusLoader
void chooseLoaderStrategy(const API::Workspace_sptr &workspace)
Determines the loading strategy used by the Algorithm.
LoadMuonNexusV2()
Empty default constructor.
int64_t m_entrynumber
The number of the input entry.
void init() override
Overwrites Algorithm method.
void loadMuonProperties(size_t numSpectra)
Loads Muon specific data from the nexus entry and sets the appropriate output properties.
void execLoader() override
Overwrites Algorithm method.
int confidence(Kernel::NexusHDF5Descriptor &descriptor) const override
Returns a confidence value that this algorithm can load a file.
API::Workspace_sptr runLoadISISNexus()
Runs the child algorithm LoadISISNexus, which loads data into an output workspace.
void loadPeriodInfo(API::Workspace &workspace)
Concrete workspace implementation.
Support for a property that holds an array of values.
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
std::string getFilename() const noexcept
Returns a copy of the current file name.
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.
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
static const UnitLabel Microsecond
Microsecond.
Implements NXentry Nexus class.
Implements NXroot Nexus class.
NXEntry openEntry(const std::string &name)
Opens an entry – a topmost Nexus class.
std::shared_ptr< WorkspaceGroup > WorkspaceGroup_sptr
shared pointer to Mantid::API::WorkspaceGroup
std::shared_ptr< Workspace > Workspace_sptr
shared pointer to Mantid::API::Workspace
Kernel::Logger g_log("ExperimentInfo")
static logger object
const std::string BEAMLINE
const std::string RAWDATA
const std::string DEFINITION
std::shared_ptr< Workspace2D > Workspace2D_sptr
shared pointer to Mantid::DataObjects::Workspace2D
std::unique_ptr< T > create(const P &parent, const IndexArg &indexArg, const HistArg &histArg)
This is the create() method that all the other create() methods call.
constexpr int EMPTY_INT() noexcept
Returns what we consider an "empty" integer within a property.
int32_t specnum_t
Typedef for a spectrum Number.
@ Input
An input workspace.
@ Output
An output workspace.