Commit 8d51021e authored by Dan Nixon's avatar Dan Nixon
Browse files

Correct Kafka 1:1 generated mapping

Streamed data assumes spectra numbers start at zero.
parent 6d83269a
......@@ -99,7 +99,8 @@ public:
virtual void updateSpectraUsing(const SpectrumDetectorMapping &map);
/// Build the default spectra mapping, most likely wanted after an instrument
/// update
void rebuildSpectraMapping(const bool includeMonitors = true);
void rebuildSpectraMapping(const bool includeMonitors = true,
const specnum_t specNumOffset = 1);
// More mapping
spec2index_map getSpectrumToWorkspaceIndexMap() const;
......
......@@ -364,8 +364,11 @@ void MatrixWorkspace::updateSpectraUsing(const SpectrumDetectorMapping &map) {
* the same ID. If an empty instrument is set then a 1:1 map from 1->NHistograms
* is created.
* @param includeMonitors :: If false the monitors are not included
* @param specNumOffset :: Constant offset from detector ID used to derive
* spectrum number
*/
void MatrixWorkspace::rebuildSpectraMapping(const bool includeMonitors) {
void MatrixWorkspace::rebuildSpectraMapping(const bool includeMonitors,
const specnum_t specNumOffset) {
if (sptr_instrument->nelements() == 0) {
return;
}
......@@ -380,8 +383,7 @@ void MatrixWorkspace::rebuildSpectraMapping(const bool includeMonitors) {
++it) {
// The detector ID
const detid_t detId = *it;
// By default: Spectrum number = index + 1
const auto specNo = specnum_t(index + 1);
const auto specNo = specnum_t(index + specNumOffset);
if (index < this->getNumberHistograms()) {
auto &spec = getSpectrum(index);
......
......@@ -550,7 +550,8 @@ void KafkaEventStreamDecoder::initLocalCaches(
API::WorkspaceFactory::Instance().create("EventWorkspace", nspec, 2,
1));
eventBuffer->setInstrument(ws->getInstrument());
eventBuffer->rebuildSpectraMapping();
/* Need a mapping with spectra numbers starting at zero */
eventBuffer->rebuildSpectraMapping(true, 0);
eventBuffer->getAxis(0)->unit() =
Kernel::UnitFactory::Instance().create("TOF");
eventBuffer->setYUnit("Counts");
......
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