Skip to content

Commit

Permalink
Move muon hdf4 loaders to muon library
Browse files Browse the repository at this point in the history
  • Loading branch information
robertapplin committed Dec 5, 2024
1 parent d6096cf commit d4a523a
Show file tree
Hide file tree
Showing 16 changed files with 69 additions and 56 deletions.
8 changes: 0 additions & 8 deletions Framework/DataHandling/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,6 @@ set(SRC_FILES
src/LoadMcStas.cpp
src/LoadMcStasNexus.cpp
src/LoadMuonLog.cpp
src/LoadMuonNexus.cpp
src/LoadMuonNexus1.cpp
src/LoadMuonNexus2.cpp
src/LoadMuonNexusV2.cpp
src/LoadMuonNexusV2NexusHelper.cpp
src/LoadMuonStrategy.cpp
Expand Down Expand Up @@ -313,9 +310,6 @@ set(INC_FILES
inc/MantidDataHandling/LoadMcStas.h
inc/MantidDataHandling/LoadMcStasNexus.h
inc/MantidDataHandling/LoadMuonLog.h
inc/MantidDataHandling/LoadMuonNexus.h
inc/MantidDataHandling/LoadMuonNexus1.h
inc/MantidDataHandling/LoadMuonNexus2.h
inc/MantidDataHandling/LoadMuonNexusV2.h
inc/MantidDataHandling/LoadMuonNexusV2NexusHelper.h
inc/MantidDataHandling/LoadMuonStrategy.h
Expand Down Expand Up @@ -529,8 +523,6 @@ set(TEST_FILES
LoadMcStasNexusTest.h
LoadMcStasTest.h
LoadMuonLogTest.h
LoadMuonNexus1Test.h
LoadMuonNexus2Test.h
LoadMuonNexusV2Test.h
LoadNGEMTest.h
LoadNXSPETest.h
Expand Down
12 changes: 10 additions & 2 deletions Framework/Muon/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ set(SRC_FILES
src/CalMuonDetectorPhases.cpp
src/ConvertFitFunctionForMuonTFAsymmetry.cpp
src/LoadAndApplyMuonDetectorGrouping.cpp
src/EstimateMuonAsymmetryFromCounts.cpp
src/LoadMuonNexus.cpp
src/LoadMuonNexus1.cpp
src/LoadAndApplyMuonDetectorGrouping.cpp
src/LoadMuonNexus2.cpp
src/MuonAlgorithmHelper.cpp
src/MuonAsymmetryHelper.cpp
src/MuonGroupDetectors.cpp
Expand All @@ -35,6 +38,9 @@ set(INC_FILES
inc/MantidMuon/CalMuonDetectorPhases.h
inc/MantidMuon/ConvertFitFunctionForMuonTFAsymmetry.h
inc/MantidMuon/LoadAndApplyMuonDetectorGrouping.h
inc/MantidMuon/LoadMuonNexus.h
inc/MantidMuon/LoadMuonNexus1.h
inc/MantidMuon/LoadMuonNexus2.h
inc/MantidMuon/EstimateMuonAsymmetryFromCounts.h
inc/MantidMuon/MuonAlgorithmHelper.h
inc/MantidMuon/MuonAsymmetryHelper.h
Expand All @@ -61,6 +67,8 @@ set(TEST_FILES
CalMuonDetectorPhasesTest.h
ConvertFitFunctionForMuonTFAsymmetryTest.h
LoadAndApplyMuonDetectorGroupingTest.h
LoadMuonNexus1Test.h
LoadMuonNexus2Test.h
MuonAlgorithmHelperTest.h
EstimateMuonAsymmetryFromCountsTest.h
MuonGroupDetectorsTest.h
Expand Down Expand Up @@ -104,7 +112,7 @@ set_property(TARGET Muon PROPERTY FOLDER "MantidFramework")
target_link_libraries(
Muon
PUBLIC Mantid::API Mantid::Kernel Mantid::Geometry
PRIVATE Mantid::DataObjects Mantid::Indexing
PRIVATE Mantid::DataObjects Mantid::Indexing Mantid::Nexus
)
# Add the unit tests directory
add_subdirectory(test)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@
// Includes
//----------------------------------------------------------------------
#include "MantidAPI/IFileLoader.h"
#include "MantidDataHandling/DllConfig.h"
#include "MantidDataObjects/Workspace2D.h"
#include "MantidKernel/NexusDescriptor.h"
#include "MantidMuon/DllConfig.h"

//----------------------------------------------------------------------
// Forward declaration
//----------------------------------------------------------------------
class MuonNexusReader;

namespace Mantid {
namespace DataHandling {
namespace Algorithms {
/** @class LoadMuonNexus LoadMuonNexus.h DataHandling/LoadMuonNexus.h
It is a base class for loaders for versions 1 and 2 of the muon nexus file
Expand All @@ -47,7 +47,7 @@ multiperiod file)
together based on the groupings in the NeXus file. </LI>
</UL>
*/
class MANTID_DATAHANDLING_DLL LoadMuonNexus : public API::IFileLoader<Kernel::NexusDescriptor> {
class MANTID_MUON_DLL LoadMuonNexus : public API::IFileLoader<Kernel::NexusDescriptor> {
public:
/// Default constructor
LoadMuonNexus();
Expand Down Expand Up @@ -109,5 +109,5 @@ class MANTID_DATAHANDLING_DLL LoadMuonNexus : public API::IFileLoader<Kernel::Ne
void init() override;
};

} // namespace DataHandling
} // namespace Algorithms
} // namespace Mantid
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
//----------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------
#include "MantidDataHandling/LoadMuonNexus.h"
#include "MantidDataObjects/TableWorkspace.h"
#include "MantidDataObjects/Workspace2D.h"
#include "MantidMuon/LoadMuonNexus.h"

// Forward declaration (here, because is not in Mantid namespace)
class MuonNexusReader;
Expand All @@ -24,7 +24,7 @@ namespace NeXus {
class NXRoot;
}

namespace DataHandling {
namespace Algorithms {
/** @class LoadMuonNexus LoadMuonNexus.h DataHandling/LoadMuonNexus.h
Loads an file in Nexus Muon format version 1 and stores it in a 2D workspace
Expand Down Expand Up @@ -52,7 +52,7 @@ multiperiod file)
together based on the groupings in the NeXus file. </LI>
</UL>
*/
class MANTID_DATAHANDLING_DLL LoadMuonNexus1 : public LoadMuonNexus {
class MANTID_MUON_DLL LoadMuonNexus1 : public LoadMuonNexus {
public:
LoadMuonNexus1();

Expand Down Expand Up @@ -88,5 +88,5 @@ class MANTID_DATAHANDLING_DLL LoadMuonNexus1 : public LoadMuonNexus {
std::vector<int> const &grouping);
};

} // namespace DataHandling
} // namespace Algorithms
} // namespace Mantid
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
//----------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------
#include "MantidDataHandling/DllConfig.h"
#include "MantidDataHandling/LoadMuonNexus.h"
#include "MantidMuon/DllConfig.h"
#include "MantidMuon/LoadMuonNexus.h"
#include "MantidNexus/NexusClasses.h"

namespace Mantid {

namespace DataHandling {
namespace Algorithms {

/**
Loads an file in NeXus Muon format version 1 and 2 and stores it in a 2D
Expand Down Expand Up @@ -44,7 +44,7 @@ multiperiod file)
together based on the groupings in the NeXus file. </LI>
</UL>
*/
class MANTID_DATAHANDLING_DLL LoadMuonNexus2 : public LoadMuonNexus {
class MANTID_MUON_DLL LoadMuonNexus2 : public LoadMuonNexus {
public:
LoadMuonNexus2();

Expand All @@ -71,5 +71,5 @@ class MANTID_DATAHANDLING_DLL LoadMuonNexus2 : public LoadMuonNexus {
std::map<int, std::set<int>> loadDetectorMapping(const Mantid::NeXus::NXInt &spectrumIndex);
};

} // namespace DataHandling
} // namespace Algorithms
} // namespace Mantid
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//----------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------
#include "MantidDataHandling/LoadMuonNexus.h"
#include "MantidMuon/LoadMuonNexus.h"
#include "MantidAPI/FileProperty.h"
#include "MantidAPI/Progress.h"
#include "MantidAPI/TableRow.h"
Expand All @@ -33,7 +33,7 @@
#include <nexus/NeXusException.hpp>
// clang-format on

namespace Mantid::DataHandling {
namespace Mantid::Algorithms {

using namespace Kernel;
using namespace API;
Expand Down Expand Up @@ -214,4 +214,4 @@ void LoadMuonNexus::addToSampleLog(const std::string &logName, const std::string
alg->setProperty("LogText", logString);
alg->executeAsChildAlg();
}
} // namespace Mantid::DataHandling
} // namespace Mantid::Algorithms
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@
// NScD Oak Ridge National Laboratory, European Spallation Source,
// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
// SPDX - License - Identifier: GPL - 3.0 +
#include "MantidDataHandling/LoadMuonNexus1.h"
#include "MantidMuon/LoadMuonNexus1.h"

#include "MantidAPI/Axis.h"
#include "MantidAPI/FileProperty.h"
#include "MantidAPI/GroupingLoader.h"
#include "MantidAPI/Progress.h"
#include "MantidAPI/RegisterFileLoader.h"
#include "MantidAPI/Run.h"
#include "MantidAPI/SpectrumDetectorMapping.h"
#include "MantidAPI/TableRow.h"
#include "MantidAPI/WorkspaceFactory.h"
#include "MantidAPI/WorkspaceGroup.h"
#include "MantidDataHandling/ISISRunLogs.h"
#include "MantidDataHandling/LoadMuonStrategy.h"
// #include "MantidDataHandling/ISISRunLogs.h"
#include "MantidDataObjects/TableWorkspace.h"
#include "MantidDataObjects/Workspace2D.h"
#include "MantidGeometry/Instrument/Detector.h"
Expand Down Expand Up @@ -45,7 +45,25 @@
#include <limits>
#include <memory>

namespace Mantid::DataHandling {
namespace {
using namespace Mantid::DataObjects;

TableWorkspace_sptr createTimeZeroTable(const size_t numSpec, const std::vector<double> &timeZeros) {
TableWorkspace_sptr timeZeroTable = std::dynamic_pointer_cast<TableWorkspace>(
Mantid::API::WorkspaceFactory::Instance().createTable("TableWorkspace"));
timeZeroTable->addColumn("double", "time zero");

for (size_t specNum = 0; specNum < numSpec; ++specNum) {
Mantid::API::TableRow row = timeZeroTable->appendRow();
row << timeZeros[specNum];
}

return timeZeroTable;
}

} // namespace

namespace Mantid::Algorithms {
using namespace DataObjects;

// Register the algorithm into the algorithm factory
Expand Down Expand Up @@ -773,8 +791,8 @@ void LoadMuonNexus1::runLoadLog(const DataObjects::Workspace2D_sptr &localWorksp
setProperty("MainFieldDirection", mainFieldDirection);
run.addProperty("main_field_direction", mainFieldDirection);

ISISRunLogs runLogs(run);
runLogs.addStatusLog(run);
// ISISRunLogs runLogs(run);
// runLogs.addStatusLog(run);
}

/**
Expand All @@ -784,13 +802,13 @@ void LoadMuonNexus1::runLoadLog(const DataObjects::Workspace2D_sptr &localWorksp
*/
void LoadMuonNexus1::addPeriodLog(const DataObjects::Workspace2D_sptr &localWorkspace, int64_t period) {
auto &run = localWorkspace->mutableRun();
ISISRunLogs runLogs(run);
if (period == 0) {
runLogs.addPeriodLogs(1, run);
} else {
run.removeLogData("period 1");
runLogs.addPeriodLog(static_cast<int>(period) + 1, run);
}
// ISISRunLogs runLogs(run);
// if (period == 0) {
// runLogs.addPeriodLogs(1, run);
// } else {
// run.removeLogData("period 1");
// runLogs.addPeriodLog(static_cast<int>(period) + 1, run);
// }
}

void LoadMuonNexus1::addGoodFrames(const DataObjects::Workspace2D_sptr &localWorkspace, int64_t period, int nperiods) {
Expand Down Expand Up @@ -918,4 +936,4 @@ int LoadMuonNexus1::confidence(Kernel::NexusDescriptor &descriptor) const {
return 0;
}

} // namespace Mantid::DataHandling
} // namespace Mantid::Algorithms
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// NScD Oak Ridge National Laboratory, European Spallation Source,
// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
// SPDX - License - Identifier: GPL - 3.0 +
#include "MantidDataHandling/LoadMuonNexus2.h"
#include "MantidMuon/LoadMuonNexus2.h"

#include "MantidAPI/Axis.h"
#include "MantidAPI/FileProperty.h"
Expand All @@ -14,8 +14,7 @@
#include "MantidAPI/Sample.h"
#include "MantidAPI/WorkspaceFactory.h"
#include "MantidAPI/WorkspaceGroup.h"
#include "MantidDataHandling/LoadMuonNexus1.h"
#include "MantidDataHandling/LoadMuonNexusV2.h"
// #include "MantidDataHandling/LoadMuonNexus1.h"
#include "MantidDataObjects/Workspace2D.h"
#include "MantidGeometry/Instrument/Detector.h"
#include "MantidKernel/ArrayProperty.h"
Expand All @@ -39,7 +38,7 @@

using Mantid::Types::Core::DateAndTime;

namespace Mantid::DataHandling {
namespace Mantid::Algorithms {
// Register the algorithm into the algorithm factory
DECLARE_NEXUS_FILELOADER_ALGORITHM(LoadMuonNexus2)

Expand Down Expand Up @@ -482,4 +481,4 @@ std::map<int, std::set<int>> LoadMuonNexus2::loadDetectorMapping(const Mantid::N
return mapping;
}

} // namespace Mantid::DataHandling
} // namespace Mantid::Algorithms
1 change: 0 additions & 1 deletion Framework/Muon/test/AlphaCalcTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include "MantidDataHandling/GroupDetectors.h"
#include "MantidDataHandling/Load.h"
#include "MantidDataHandling/LoadInstrument.h"
#include "MantidDataHandling/LoadMuonNexus2.h"
#include "MantidDataObjects/Workspace2D.h"
#include "MantidMuon/AlphaCalc.h"
#include <stdexcept>
Expand Down
1 change: 0 additions & 1 deletion Framework/Muon/test/ApplyMuonDetectorGroupPairingTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include "MantidAPI/Workspace.h"
#include "MantidAPI/WorkspaceGroup.h"
#include "MantidAlgorithms/CompareWorkspaces.h"
#include "MantidDataHandling/LoadMuonNexus2.h"
#include "MantidDataObjects/TableWorkspace.h"
#include "MantidKernel/PhysicalConstants.h"

Expand Down
1 change: 0 additions & 1 deletion Framework/Muon/test/AsymmetryCalcTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include "MantidDataHandling/GroupDetectors.h"
#include "MantidDataHandling/Load.h"
#include "MantidDataHandling/LoadInstrument.h"
#include "MantidDataHandling/LoadMuonNexus2.h"
#include "MantidDataObjects/Workspace2D.h"
#include "MantidMuon/AsymmetryCalc.h"
#include <algorithm>
Expand Down
4 changes: 2 additions & 2 deletions Framework/Muon/test/CalMuonDeadTimeTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "MantidAPI/IAlgorithm.h"
#include "MantidAPI/Run.h"
#include "MantidAPI/Workspace.h"
#include "MantidDataHandling/LoadMuonNexus1.h"
#include "MantidDataHandling/Load.h"
#include "MantidDataObjects/TableWorkspace.h"
#include "MantidDataObjects/Workspace2D.h"
#include "MantidMuon/CalMuonDeadTime.h"
Expand Down Expand Up @@ -93,7 +93,7 @@ class CalMuonDeadTimeTest : public CxxTest::TestSuite {
private:
// Load the muon nexus file
MatrixWorkspace_sptr loadData() {
Mantid::DataHandling::LoadMuonNexus1 loader;
Mantid::DataHandling::Load loader;
loader.initialize();
loader.setChild(true);
loader.setPropertyValue("Filename", "emu00006473.nxs");
Expand Down
2 changes: 1 addition & 1 deletion Framework/Muon/test/EstimateMuonAsymmetryFromCountsTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ class EstimateMuonAsymmetryFromCountsTestPerformance : public CxxTest::TestSuite
void setUp() override { input = createWorkspace(1000, 100); }

void testExec2D() {
EstimateMuonAsymmetryFromCounts alg;
Mantid::Algorithms::EstimateMuonAsymmetryFromCounts alg;
alg.initialize();
alg.setProperty("InputWorkspace", input);
alg.setPropertyValue("OutputWorkspace", "output");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@
#include "MantidAPI/Sample.h"
#include "MantidAPI/ScopedWorkspace.h"
#include "MantidAPI/WorkspaceGroup.h"
#include "MantidDataHandling/LoadMuonNexus1.h"
#include "MantidKernel/ConfigService.h"
#include "MantidKernel/TimeSeriesProperty.h"
#include "MantidKernel/Unit.h"
#include "MantidMuon/LoadMuonNexus1.h"

#include <Poco/Path.h>

using namespace Mantid::API;
using namespace Mantid::Kernel;
using namespace Mantid::DataHandling;
using namespace Mantid::Algorithms;
using namespace Mantid::DataObjects;

class LoadMuonNexus1Test : public CxxTest::TestSuite {
Expand Down
Loading

0 comments on commit d4a523a

Please sign in to comment.