Skip to content

Commit

Permalink
Remove datahandling dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
robertapplin committed Dec 6, 2024
1 parent 47d76c3 commit cfd68f3
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ namespace DataHandling {
class LoadMuonNexusV2NexusHelper;

// Create time zero table
MANTID_DATAHANDLING_DLL DataObjects::TableWorkspace_sptr createTimeZeroTable(const size_t numSpec,
const std::vector<double> &timeZeros);
DataObjects::TableWorkspace_sptr createTimeZeroTable(const size_t numSpec, const std::vector<double> &timeZeros);

class MANTID_DATAHANDLING_DLL LoadMuonStrategy {
public:
Expand Down
2 changes: 1 addition & 1 deletion Framework/Muon/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ set_property(TARGET Muon PROPERTY FOLDER "MantidFramework")
target_link_libraries(
Muon
PUBLIC Mantid::API Mantid::Kernel Mantid::Geometry
PRIVATE Mantid::DataHandling Mantid::DataObjects Mantid::Indexing Mantid::Nexus
PRIVATE Mantid::DataObjects Mantid::Indexing Mantid::Nexus
)
# Add the unit tests directory
add_subdirectory(test)
Expand Down
45 changes: 32 additions & 13 deletions Framework/Muon/src/LoadMuonNexus1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
#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 "MantidDataHandling/LoadMuonStrategy.h"
#include "MantidDataObjects/TableWorkspace.h"
#include "MantidDataObjects/Workspace2D.h"
#include "MantidGeometry/Instrument/Detector.h"
Expand Down Expand Up @@ -46,6 +46,25 @@
#include <limits>
#include <memory>

namespace {

Mantid::DataObjects::TableWorkspace_sptr createTimeZeroTable(const size_t numSpec,
const std::vector<double> &timeZeros) {
Mantid::DataObjects::TableWorkspace_sptr timeZeroTable =
std::dynamic_pointer_cast<Mantid::DataObjects::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;

Expand Down Expand Up @@ -343,7 +362,7 @@ void LoadMuonNexus1::exec() {
auto timeZeroList = std::vector<double>(m_numberOfSpectra, getProperty("TimeZero"));
setProperty("TimeZeroList", timeZeroList);
if (!getPropertyValue("TimeZeroTable").empty())
setProperty("TimeZeroTable", DataHandling::createTimeZeroTable(m_numberOfSpectra, timeZeroList));
setProperty("TimeZeroTable", createTimeZeroTable(m_numberOfSpectra, timeZeroList));
}

if (m_numberOfPeriods == 1)
Expand Down Expand Up @@ -774,8 +793,8 @@ void LoadMuonNexus1::runLoadLog(const DataObjects::Workspace2D_sptr &localWorksp
setProperty("MainFieldDirection", mainFieldDirection);
run.addProperty("main_field_direction", mainFieldDirection);

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

/**
Expand All @@ -784,14 +803,14 @@ void LoadMuonNexus1::runLoadLog(const DataObjects::Workspace2D_sptr &localWorksp
* @param period A period for this workspace.
*/
void LoadMuonNexus1::addPeriodLog(const DataObjects::Workspace2D_sptr &localWorkspace, int64_t period) {
auto &run = localWorkspace->mutableRun();
DataHandling::ISISRunLogs runLogs(run);
if (period == 0) {
runLogs.addPeriodLogs(1, run);
} else {
run.removeLogData("period 1");
runLogs.addPeriodLog(static_cast<int>(period) + 1, run);
}
// auto &run = localWorkspace->mutableRun();
// DataHandling::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

0 comments on commit cfd68f3

Please sign in to comment.