Skip to content
Snippets Groups Projects

cleanup while preparing for replacement of SimulationAreaDetector

Merged Wuttke, Joachim requested to merge j.724h into main
1 file
+ 10
10
Compare changes
  • Side-by-side
  • Inline
+ 10
10
@@ -19,7 +19,6 @@
#include "Base/Util/Assert.h"
#include "Device/Data/Datafield.h"
#include "Device/Detector/IDetector.h"
#include "Device/Detector/SimulationAreaIterator.h" // roiIndex
#include "Sim/Simulation/ScatteringSimulation.h"
#include <utility>
@@ -50,21 +49,22 @@ Datafield repositionData(const ScatteringSimulation& simulation, const Datafield
if (data.hasErrorSigmas())
errors = std::vector<double>(coordSystem.size(), 0.);
const IDetector& det = simulation.detector();
std::vector<size_t> ai = det.activeIndices();
if (coordSystem.hasSameSizes(data.frame())) {
// data is already cropped to ROI
simulation.detector().iterateOverNonMaskedPoints([&](IDetector::const_iterator it) {
values[it.roiIndex()] = data[it.roiIndex()];
for (size_t i = 0; i < ai.size(); ++i) {
values[ai[i]] = data[ai[i]];
if (data.hasErrorSigmas())
errors[it.roiIndex()] = data.errorSigmas()[it.roiIndex()];
});
errors[ai[i]] = data.errorSigmas()[ai[i]];
}
} else if (haveSameSizes(simulation.detector(), data)) {
// experimental data has same shape as the detector, we have to copy the original
// data to a smaller roi map
simulation.detector().iterateOverNonMaskedPoints([&](IDetector::const_iterator it) {
values[it.roiIndex()] = data[it.detectorIndex()];
for (size_t i = 0; i < ai.size(); ++i) {
values[ai[i]] = data[det.roiToFullIndex(ai[i])];
if (data.hasErrorSigmas())
errors[it.roiIndex()] = data.errorSigmas()[it.detectorIndex()];
});
errors[ai[i]] = data.errorSigmas()[det.roiToFullIndex(ai[i])];
}
} else
throw std::runtime_error(
"FitObject::init_dataset: Detector and experimental data have different shape");
Loading