Commit 2062d0ef authored by Stephen's avatar Stephen
Browse files

Rename algorithm to LoadMuonNexusV2

parent f388655a
......@@ -86,8 +86,8 @@ set(SRC_FILES
src/LoadMuonNexus.cpp
src/LoadMuonNexus1.cpp
src/LoadMuonNexus2.cpp
src/LoadMuonNexus3.cpp
src/LoadMuonNexus3Helper.cpp
src/LoadMuonNexusV2.cpp
src/LoadMuonNexusV2Helper.cpp
src/LoadMuonStrategy.cpp
src/SinglePeriodLoadMuonStrategy.cpp
src/LoadNXSPE.cpp
......@@ -300,8 +300,8 @@ set(INC_FILES
inc/MantidDataHandling/LoadMuonNexus.h
inc/MantidDataHandling/LoadMuonNexus1.h
inc/MantidDataHandling/LoadMuonNexus2.h
inc/MantidDataHandling/LoadMuonNexus3.h
inc/MantidDataHandling/LoadMuonNexus3Helper.h
inc/MantidDataHandling/LoadMuonNexusV2.h
inc/MantidDataHandling/LoadMuonNexusV2Helper.h
inc/MantidDataHandling/LoadMuonStrategy.h
inc/MantidDataHandling/SinglePeriodLoadMuonStrategy.h
inc/MantidDataHandling/LoadNXSPE.h
......@@ -504,7 +504,7 @@ set(TEST_FILES
LoadMuonLogTest.h
LoadMuonNexus1Test.h
LoadMuonNexus2Test.h
LoadMuonNexus3Test.h
LoadMuonNexusV2Test.h
LoadNXSPETest.h
LoadNXcanSASTest.h
LoadNexusLogsTest.h
......
......@@ -5,7 +5,6 @@
// & Institut Laue - Langevin
// SPDX - License - Identifier: GPL - 3.0 +
#pragma once
#include "MantidAPI/Algorithm.h"
#include "MantidAPI/IFileLoader.h"
#include "MantidAPI/NexusFileLoader.h"
......@@ -25,9 +24,9 @@
namespace Mantid {
namespace DataHandling {
/** @class LoadMuonNexus3 LoadMuonNexus3.h DataHandling/LoadMuonNexus3.h
/** @class LoadMuonNexusV2 LoadMuonNexusV2.h DataHandling/LoadMuonNexusV2.h
Loads a file in the Nexus Muon format version 2 and stores it in a 2D workspace
Loads a file in the Nexus Muon format V2 and stores it in a 2D workspace
(Workspace2D class). LoadMuonNexus is an algorithm that loads
an HDF5 file and as such inherits from API::NexusFileLoader and
the init() & execLoader() methods.
......@@ -38,7 +37,7 @@ Required Properties:
data
(a multiperiod file will store higher periods in workspaces called
OutputWorkspace_PeriodNo)
[ not yet implemented for Muon Nexus 2 ]</LI>
[ not yet implemented for Muon Nexus V2 ]</LI>
</UL>
Optional Properties: (note that these options are not available if reading a
......@@ -51,12 +50,12 @@ multiperiod file)
@author Stephen Smith, ISIS
*/
class DLLExport LoadMuonNexus3 : public API::NexusFileLoader {
class DLLExport LoadMuonNexusV2 : public API::NexusFileLoader {
public:
// Default constructor
LoadMuonNexus3();
LoadMuonNexusV2();
/// Algorithm's name for identification overriding a virtual method
const std::string name() const override { return "LoadMuonNexus3"; }
const std::string name() const override { return "LoadMuonNexusV2"; }
/// Summary of algorithms purpose
const std::string summary() const override {
return "Loads a Muon Nexus V2 data file and stores it in a 2D "
......@@ -83,8 +82,6 @@ private:
void loadMuonProperties(const NeXus::NXEntry &entry);
/// The name and path of the input file
std::string m_filename;
/// The sample name read from Nexus
std::string m_sampleName;
/// The number of the input entry
int64_t m_entrynumber;
/// The number of periods in the raw file
......@@ -93,8 +90,6 @@ private:
bool m_isFileMultiPeriod;
// Are multi periods loaded
bool m_multiPeriodsLoaded;
/// The group which each detector belongs to in order
std::vector<specnum_t> m_groupings;
// The loading strategy used
std::unique_ptr<LoadMuonStrategy> m_loadMuonStrategy;
};
......
......@@ -19,7 +19,7 @@
namespace Mantid {
namespace DataHandling {
namespace LoadMuonNexus3Helper {
namespace LoadMuonNexusV2Helper {
// Loads the good frame data from the nexus file
NeXus::NXInt loadGoodFramesDataFromNexus(const NeXus::NXEntry &entry,
......
......@@ -46,8 +46,8 @@ protected:
const std::vector<double> &deadTimes) const;
// Logger
Kernel::Logger &m_logger;
// File name, used for running child algorithms
std::string m_filename;
// Filename, used for running child algorithms
const std::string & m_filename;
};
} // namespace DataHandling
} // namespace Mantid
......@@ -4,14 +4,14 @@
// NScD Oak Ridge National Laboratory, European Spallation Source
// & Institut Laue - Langevin
// SPDX - License - Identifier: GPL - 3.0 +
#include "MantidDataHandling/LoadMuonNexus3.h"
#include "MantidDataHandling/LoadMuonNexusV2.h"
#include "MantidAPI/FileProperty.h"
#include "MantidAPI/GroupingLoader.h"
#include "MantidAPI/RegisterFileLoader.h"
#include "MantidAPI/WorkspaceFactory.h"
#include "MantidAPI/WorkspaceGroup.h"
#include "MantidDataHandling/LoadISISNexus2.h"
#include "MantidDataHandling/LoadMuonNexus3Helper.h"
#include "MantidDataHandling/LoadMuonNexusV2Helper.h"
#include "MantidDataHandling/SinglePeriodLoadMuonStrategy.h"
#include "MantidDataObjects/Workspace2D.h"
#include "MantidGeometry/Instrument.h"
......@@ -26,7 +26,7 @@
namespace Mantid {
namespace DataHandling {
DECLARE_NEXUS_HDF5_FILELOADER_ALGORITHM(LoadMuonNexus3)
DECLARE_NEXUS_HDF5_FILELOADER_ALGORITHM(LoadMuonNexusV2)
using namespace Kernel;
using namespace API;
......@@ -36,9 +36,8 @@ using std::size_t;
using namespace DataObjects;
/// Empty default constructor
LoadMuonNexus3::LoadMuonNexus3()
: m_filename(), m_sampleName(), m_isFileMultiPeriod(false),
m_multiPeriodsLoaded(false) {}
LoadMuonNexusV2::LoadMuonNexusV2()
: m_filename(), m_isFileMultiPeriod(false), m_multiPeriodsLoaded(false) {}
/**
* Return the confidence criteria for this algorithm can load the file
......@@ -46,27 +45,27 @@ LoadMuonNexus3::LoadMuonNexus3()
* @returns An integer specifying the confidence level. 0 indicates it will not
* be used
*/
int LoadMuonNexus3::confidence(NexusHDF5Descriptor &descriptor) const {
int LoadMuonNexusV2::confidence(NexusHDF5Descriptor &descriptor) const {
// Without this entry we cannot use LoadISISNexus
if (!descriptor.isEntry("/raw_data_1", "NXentry")) {
return 0;
}
const std::string root = "/raw_data_1";
// Check if Muon source in defintiion entry
// Check if Muon source in definition entry
if (!descriptor.isEntry(root + "/definition"))
return 0;
::NeXus::File file(descriptor.getFilename());
file.openPath(root + "/definition");
std::string def = file.getStrData();
if (def == "muonTD" || def == "pulsedTD") {
return 82; // have to return 82 to "beat" the LoadMuonNexusV2 algorithm,
return 82; // have to return 82 to "beat" the LoadMuonNexus2 algorithm,
// which returns 81 for this file as well
} else {
return 0;
}
}
/// Initialization method.
void LoadMuonNexus3::init() {
void LoadMuonNexusV2::init() {
declareProperty(std::make_unique<FileProperty>("Filename", "",
FileProperty::Load, ".nxs"),
"The name of the Nexus file to load");
......@@ -88,14 +87,14 @@ void LoadMuonNexus3::init() {
"0 indicates that every entry is loaded, into a separate "
"workspace within a group. "
"A positive number identifies one entry to be loaded, into "
"one worskspace");
"one workspace");
std::vector<std::string> FieldOptions{"Transverse", "Longitudinal"};
declareProperty("MainFieldDirection", "Transverse",
std::make_shared<StringListValidator>(FieldOptions),
"Output the main field direction if specified in Nexus file "
"(run/instrument/detector/orientation, default "
"longitudinal). Version 1 only.",
"longitudinal).",
Direction::Output);
declareProperty("TimeZero", 0.0,
......@@ -108,17 +107,15 @@ void LoadMuonNexus3::init() {
declareProperty(
std::make_unique<WorkspaceProperty<Workspace>>(
"DeadTimeTable", "", Direction::Output, PropertyMode::Optional),
"Table or a group of tables containing detector dead times. Version 1 "
"only.");
"Table or a group of tables containing detector dead times.");
declareProperty(
std::make_unique<WorkspaceProperty<Workspace>>("DetectorGroupingTable",
"", Direction::Output,
PropertyMode::Optional),
"Table or a group of tables with information about the "
"detector grouping stored in the file (if any). Version 1 only.");
declareProperty(std::make_unique<WorkspaceProperty<Workspace>>(
"DetectorGroupingTable", "", Direction::Output,
PropertyMode::Optional),
"Table or a group of tables with information about the "
"detector grouping stored in the file (if any).");
}
void LoadMuonNexus3::execLoader() {
void LoadMuonNexusV2::execLoader() {
// prepare nexus entry
m_entrynumber = getProperty("EntryNumber");
......@@ -149,8 +146,8 @@ void LoadMuonNexus3::execLoader() {
m_loadMuonStrategy->loadGoodFrames();
m_loadMuonStrategy->applyTimeZeroCorrection();
// Grouping info should be returned if user has set the property
auto loadedGrouping = m_loadMuonStrategy->loadDetectorGrouping();
if (!getPropertyValue("DetectorGroupingTable").empty()) {
auto loadedGrouping = m_loadMuonStrategy->loadDetectorGrouping();
setProperty("DetectorGroupingTable", loadedGrouping);
};
// Deadtime table should be returned if user has set the property
......@@ -164,7 +161,7 @@ void LoadMuonNexus3::execLoader() {
* Determines whether the file is multi period
* If multi period the function determines whether multi periods are loaded
*/
void LoadMuonNexus3::isEntryMultiPeriod(const NXEntry &entry) {
void LoadMuonNexusV2::isEntryMultiPeriod(const NXEntry &entry) {
NXClass periodClass = entry.openNXGroup("periods");
int numberOfPeriods = periodClass.getInt("number");
if (numberOfPeriods > 1) {
......@@ -181,7 +178,7 @@ void LoadMuonNexus3::isEntryMultiPeriod(const NXEntry &entry) {
* Runs the child algorithm LoadISISNexus, which loads data into an output
* workspace
*/
void LoadMuonNexus3::runLoadISISNexus() {
void LoadMuonNexusV2::runLoadISISNexus() {
IAlgorithm_sptr childAlg =
createChildAlgorithm("LoadISISNexus", 0, 1, true, 2);
declareProperty("LoadMonitors", "Exclude"); // we need to set this property
......@@ -194,16 +191,16 @@ void LoadMuonNexus3::runLoadISISNexus() {
* Loads Muon specific data from the nexus entry
* and sets the appropriate output properties
*/
void LoadMuonNexus3::loadMuonProperties(const NXEntry &entry) {
void LoadMuonNexusV2::loadMuonProperties(const NXEntry &entry) {
std::string mainFieldDirection =
LoadMuonNexus3Helper::loadMainFieldDirectionFromNexus(entry);
LoadMuonNexusV2Helper::loadMainFieldDirectionFromNexus(entry);
setProperty("MainFieldDirection", mainFieldDirection);
double timeZero = LoadMuonNexus3Helper::loadTimeZeroFromNexusFile(entry);
double timeZero = LoadMuonNexusV2Helper::loadTimeZeroFromNexusFile(entry);
setProperty("timeZero", timeZero);
auto firstGoodData = LoadMuonNexus3Helper::loadFirstGoodDataFromNexus(entry);
auto firstGoodData = LoadMuonNexusV2Helper::loadFirstGoodDataFromNexus(entry);
setProperty("FirstGoodData", firstGoodData);
}
} // namespace DataHandling
......
......@@ -8,13 +8,13 @@
// These functions handle the nexus operations needed to load
// the information from the Muon Nexus V2 file
#include "MantidDataHandling/LoadMuonNexus3Helper.h"
#include "MantidDataHandling/LoadMuonNexusV2Helper.h"
#include "MantidAPI/TableRow.h"
#include "MantidAPI/WorkspaceFactory.h"
namespace Mantid {
namespace DataHandling {
namespace LoadMuonNexus3Helper {
namespace LoadMuonNexusV2Helper {
using namespace NeXus;
using namespace Kernel;
......@@ -157,6 +157,6 @@ getLoadedDetectors(const DataObjects::Workspace2D_sptr &localWorkspace) {
return loadedDetectors;
}
} // namespace LoadMuonNexus3Helper
} // namespace LoadMuonNexusV2Helper
} // namespace DataHandling
} // namespace Mantid
......@@ -12,7 +12,7 @@
#include "MantidAPI/WorkspaceFactory.h"
#include "MantidDataHandling/ISISRunLogs.h"
#include "MantidDataHandling/LoadMuonLog.h"
#include "MantidDataHandling/LoadMuonNexus3Helper.h"
#include "MantidDataHandling/LoadMuonNexusV2Helper.h"
#include "MantidKernel/UnitFactory.h"
#include "MantidKernel/UnitLabelTypes.h"
......@@ -50,7 +50,7 @@ void SinglePeriodLoadMuonStrategy::loadMuonLogData() {
m_logger.error("Unable to successfully run LoadMuonLog Child Algorithm");
}
std::string mainFieldDirection =
LoadMuonNexus3Helper::loadMainFieldDirectionFromNexus(m_entry);
LoadMuonNexusV2Helper::loadMainFieldDirectionFromNexus(m_entry);
// set output property and add to workspace logs
auto &run = m_workspace->mutableRun();
run.addProperty("main_field_direction", mainFieldDirection);
......@@ -64,7 +64,7 @@ void SinglePeriodLoadMuonStrategy::loadGoodFrames() {
auto &run = m_workspace->mutableRun();
run.removeProperty("goodfrm");
NXInt goodframes = LoadMuonNexus3Helper::loadGoodFramesDataFromNexus(
NXInt goodframes = LoadMuonNexusV2Helper::loadGoodFramesDataFromNexus(
m_entry, m_isFileMultiPeriod);
if (m_isFileMultiPeriod) {
......@@ -82,7 +82,7 @@ void SinglePeriodLoadMuonStrategy::loadGoodFrames() {
*/
Workspace_sptr SinglePeriodLoadMuonStrategy::loadDetectorGrouping() const {
auto grouping = LoadMuonNexus3Helper::loadDetectorGroupingFromNexus(
auto grouping = LoadMuonNexusV2Helper::loadDetectorGroupingFromNexus(
m_entry, m_detectors, m_isFileMultiPeriod);
DataObjects::TableWorkspace_sptr table =
createDetectorGroupingTable(m_detectors, grouping);
......@@ -133,7 +133,7 @@ SinglePeriodLoadMuonStrategy::loadDefaultDetectorGrouping() const {
*/
Workspace_sptr SinglePeriodLoadMuonStrategy::loadDeadTimeTable() const {
auto deadTimes = LoadMuonNexus3Helper::loadDeadTimesFromNexus(
auto deadTimes = LoadMuonNexusV2Helper::loadDeadTimesFromNexus(
m_entry, m_detectors, m_isFileMultiPeriod);
auto deadTimeTable = createDeadTimeTable(m_detectors, deadTimes);
......@@ -149,7 +149,7 @@ Workspace_sptr SinglePeriodLoadMuonStrategy::loadDeadTimeTable() const {
*/
void SinglePeriodLoadMuonStrategy::applyTimeZeroCorrection() {
double timeZero = LoadMuonNexus3Helper::loadTimeZeroFromNexusFile(m_entry);
double timeZero = LoadMuonNexusV2Helper::loadTimeZeroFromNexusFile(m_entry);
auto newUnit = std::dynamic_pointer_cast<Kernel::Units::Label>(
Kernel::UnitFactory::Instance().create("Label"));
newUnit->setLabel("Time", Kernel::Units::Symbol::Microsecond);
......
......@@ -12,7 +12,7 @@
#include "MantidAPI/MatrixWorkspace.h"
#include "MantidAPI/Run.h"
#include "MantidAPI/WorkspaceGroup.h"
#include "MantidDataHandling/LoadMuonNexus3.h"
#include "MantidDataHandling/LoadMuonNexusV2.h"
#include "MantidDataObjects/Workspace2D.h"
#include <cmath>
......@@ -27,7 +27,7 @@ private:
// helper methods
public:
void testExec() {
LoadMuonNexus3 ld;
LoadMuonNexusV2 ld;
ld.initialize();
ld.setPropertyValue("Filename", "EMU00103638.nxs_v2");
ld.setPropertyValue("OutputWorkspace", "outWS");
......@@ -73,5 +73,5 @@ public:
void testDefaultLoad() { loader.execute(); }
private:
LoadMuonNexus3 loader;
LoadMuonNexusV2 loader;
};
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment