Skip to content
Snippets Groups Projects
Commit c7a46f73 authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

[j.offspec2] OffspecDetector internally row-major ()

Merging branch 'j.offspec2'  into 'main'.

See merge request !2027
parents a2806391 1e9e4e90
No related branches found
No related tags found
1 merge request!2027OffspecDetector internally row-major
Pipeline #115241 passed
......@@ -53,18 +53,12 @@ const Scale& OffspecDetector::axis(size_t index) const
return *m_axes[index];
}
size_t OffspecDetector::axisBinIndex(size_t index, size_t selected_axis) const
size_t OffspecDetector::axisBinIndex(size_t i, size_t k_axis) const
{
const size_t dim = 2;
size_t remainder(index);
size_t i_axis = dim;
for (size_t i = 0; i < dim; ++i) {
--i_axis;
if (selected_axis == i_axis)
return remainder % m_axes[i_axis]->size();
remainder /= m_axes[i_axis]->size();
}
ASSERT_NEVER;
if (k_axis == 0)
return i % m_axes[0]->size();
else
return i / m_axes[0]->size();
}
size_t OffspecDetector::totalSize() const
......@@ -99,5 +93,5 @@ size_t OffspecDetector::indexOfSpecular(double alpha, double phi) const
size_t OffspecDetector::getGlobalIndex(size_t x, size_t y) const
{
return x * axis(1).size() + y;
return y * axis(0).size() + x;
}
......@@ -133,20 +133,23 @@ size_t OffspecSimulation::nElements() const
Datafield OffspecSimulation::packResult()
{
const size_t ns = m_scan->nScan();
const size_t ny = m_detector->axis(1).size();
const size_t Ndet = m_detector->axis(0).size() * ny;
std::vector<double> out(ns * ny, 0.);
const size_t nphi = m_detector->axis(0).size();
const size_t nalp = m_detector->axis(1).size();
const size_t Ndet = nalp * nphi;
std::vector<double> out(ns * nalp, 0.);
// Apply detector resolution and transfer detector image
for (size_t j = 0; j < ns; ++j) {
// TODO restore resolution m_detector->applyDetectorResolution(&detector_image);
for (size_t i = 0; i < Ndet; ++i) {
double& val = out[j * ny + i % ny];
val += m_cache[j * Ndet + i];
for (size_t ia = 0; ia < nalp; ++ia) {
double val = 0;
for (size_t ip = 0; ip < nphi; ++ip)
val += m_cache[j * Ndet + ia * nphi + ip];
if (background())
val = background()->addBackground(val);
out[j * nalp + ia] = val;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment