Commit 28275545 authored by Antti Soininen's avatar Antti Soininen
Browse files

Add monitor spectra to the end of a workspace instead of beginning.

Re #18842
parent ad29f5b7
......@@ -72,7 +72,7 @@ private:
void loadTimeDetails(NeXus::NXEntry &entry);
void loadDataIntoTheWorkSpace(NeXus::NXEntry &entry,
const std::vector<std::vector<int>> &);
void loadSpectra(size_t &spec, const size_t numberOfMonitors,
void loadSpectra(size_t &spec,
const size_t numberOfTubes,
const std::vector<Mantid::detid_t> &detectorIDs,
NeXus::NXInt data, Mantid::API::Progress progress);
......
......@@ -354,24 +354,14 @@ void LoadILLTOF2::loadDataIntoTheWorkSpace(
auto const &instrument = m_localWorkspace->getInstrument();
const auto monitorIDs = instrument->getMonitors();
for (const auto &monitor : monitors) {
m_localWorkspace->setHistogram(spec, m_localWorkspace->binEdges(0),
Counts(monitor.begin(), monitor.end()));
m_localWorkspace->getSpectrum(spec).setDetectorID(monitorIDs[spec]);
spec++;
}
const std::vector<detid_t> detectorIDs = instrument->getDetectorIDs(true);
const size_t numberOfMonitors = monitors.size();
Progress progress(this, 0, 1, m_numberOfTubes * m_numberOfPixelsPerTube);
loadSpectra(spec, numberOfMonitors, m_numberOfTubes, detectorIDs, data,
loadSpectra(spec, m_numberOfTubes, detectorIDs, data,
progress);
g_log.debug() << "Loading data into the workspace: DONE!\n";
g_log.debug() << "Loading detector data into the workspace: DONE!\n";
/**
* IN4 Rosace detectors are in a different NeXus entry
......@@ -389,9 +379,19 @@ void LoadILLTOF2::loadDataIntoTheWorkSpace(
Progress progressRosace(this, 0, 1,
numberOfTubes * m_numberOfPixelsPerTube);
loadSpectra(spec, numberOfMonitors, numberOfTubes, detectorIDs, dataRosace,
loadSpectra(spec, numberOfTubes, detectorIDs, dataRosace,
progressRosace);
}
const auto monitorIDs = instrument->getMonitors();
for (size_t i = 0; i < monitors.size(); ++i) {
const auto &monitor = monitors[i];
m_localWorkspace->setHistogram(spec, m_localWorkspace->binEdges(0),
Counts(monitor.begin(), monitor.end()));
m_localWorkspace->getSpectrum(spec).setDetectorID(monitorIDs[i]);
spec++;
}
}
/**
......@@ -405,7 +405,7 @@ void LoadILLTOF2::loadDataIntoTheWorkSpace(
* @param data The NeXus data to load into the workspace
* @param progress The progress monitor
*/
void LoadILLTOF2::loadSpectra(size_t &spec, const size_t numberOfMonitors,
void LoadILLTOF2::loadSpectra(size_t &spec,
const size_t numberOfTubes,
const std::vector<detid_t> &detectorIDs,
NXInt data, Progress progress) {
......@@ -416,7 +416,7 @@ void LoadILLTOF2::loadSpectra(size_t &spec, const size_t numberOfMonitors,
spec, m_localWorkspace->binEdges(0),
Counts(data_p, data_p + m_numberOfChannels));
m_localWorkspace->getSpectrum(spec)
.setDetectorID(detectorIDs[spec - numberOfMonitors]);
.setDetectorID(detectorIDs[spec]);
spec++;
progress.report();
}
......
......@@ -4,6 +4,7 @@
#include <cxxtest/TestSuite.h>
#include "MantidAPI/AnalysisDataService.h"
#include "MantidAPI/MatrixWorkspace.h"
#include "MantidAPI/SpectrumInfo.h"
#include "MantidDataHandling/LoadILLTOF2.h"
using namespace Mantid::API;
......@@ -41,6 +42,7 @@ public:
*/
MatrixWorkspace_sptr loadDataFile(const std::string dataFile,
const size_t numberOfHistograms,
const size_t numberOfMonitors,
const size_t numberOfChannels,
const double tofDelay,
const double tofChannelWidth) {
......@@ -59,8 +61,14 @@ public:
outputSpace);
TS_ASSERT_EQUALS(output->getNumberHistograms(), numberOfHistograms)
const auto &spectrumInfo = output->spectrumInfo();
for (size_t wsIndex = 0; wsIndex != output->getNumberHistograms();
++wsIndex) {
if (wsIndex < numberOfHistograms - numberOfMonitors) {
TS_ASSERT(!spectrumInfo.isMonitor(wsIndex))
} else {
TS_ASSERT(spectrumInfo.isMonitor(wsIndex))
}
const auto histogram = output->histogram(wsIndex);
TS_ASSERT_EQUALS(histogram.xMode(),
Mantid::HistogramData::Histogram::XMode::BinEdges)
......@@ -102,8 +110,9 @@ public:
const double tofChannelWidth = 5.85;
const size_t channelCount = 512;
const size_t histogramCount = 397;
const size_t monitorCount = 1;
MatrixWorkspace_sptr ws =
loadDataFile("ILL/IN4/084446.nxs", histogramCount, channelCount,
loadDataFile("ILL/IN4/084446.nxs", histogramCount, monitorCount, channelCount,
tofDelay, tofChannelWidth);
const double pulseInterval =
......@@ -117,7 +126,8 @@ public:
const double tofChannelWidth = 14.6349;
const size_t channelCount = 512;
const size_t histogramCount = 98305;
loadDataFile("ILL/IN5/104007.nxs", histogramCount, channelCount, tofDelay,
const size_t monitorCount = 1;
loadDataFile("ILL/IN5/104007.nxs", histogramCount, monitorCount, channelCount, tofDelay,
tofChannelWidth);
}
......@@ -127,8 +137,9 @@ public:
const double tofChannelWidth = 5.8;
const size_t channelCount = 1024;
const size_t histogramCount = 340;
const size_t monitorCount = 3;
MatrixWorkspace_sptr ws =
loadDataFile("ILL/IN6/164192.nxs", histogramCount, channelCount,
loadDataFile("ILL/IN6/164192.nxs", histogramCount, monitorCount, channelCount,
tofDelay, tofChannelWidth);
const double pulseInterval =
......
Markdown is supported
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