aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2023-06-19 15:58:54 +0200
committerThomas White <taw@physics.org>2023-07-28 13:22:05 +0200
commit6efd03ddd0699eb4ddc5a1f1e1885cae373b49d7 (patch)
tree72bf87881cc2d2894bb6acb1f58ab2b62451e457 /libcrystfel
parente2c50cf4d01c473e4d5f4ab632488b2b9987ebc9 (diff)
detgeom: Add panel group center coordinates
Diffstat (limited to 'libcrystfel')
-rw-r--r--libcrystfel/src/datatemplate.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/libcrystfel/src/datatemplate.c b/libcrystfel/src/datatemplate.c
index 16d1b68d..8651d76e 100644
--- a/libcrystfel/src/datatemplate.c
+++ b/libcrystfel/src/datatemplate.c
@@ -1806,6 +1806,16 @@ static int detector_flat(const DataTemplate *dtempl)
}
+static void add_dg_point(const struct detgeom_panel *p,
+ int fs, int ss,
+ double *tx, double *ty, double *tz)
+{
+ *tx += (p->cnx + fs*p->fsx + ss*p->ssx) * p->pixel_pitch;
+ *ty += (p->cny + fs*p->fsy + ss*p->ssy) * p->pixel_pitch;
+ *tz += (p->cnz + fs*p->fsz + ss*p->ssz) * p->pixel_pitch;
+}
+
+
static struct detgeom_panel_group *walk_group(const DataTemplate *dtempl,
struct panel_group_template *gt,
struct detgeom *detgeom,
@@ -1833,9 +1843,26 @@ static struct detgeom_panel_group *walk_group(const DataTemplate *dtempl,
}
gr->panel->group = gr;
+ /* Calculate and make a note of the panel center */
+ double tx = 0.0;
+ double ty = 0.0;
+ double tz = 0.0;
+
+ add_dg_point(gr->panel, 0, 0, &tx, &ty, &tz);
+ add_dg_point(gr->panel, gr->panel->w, 0, &tx, &ty, &tz);
+ add_dg_point(gr->panel, 0, gr->panel->h, &tx, &ty, &tz);
+ add_dg_point(gr->panel, gr->panel->w, gr->panel->h, &tx, &ty, &tz);
+
+ gr->cx = tx / 4.0;
+ gr->cy = ty / 4.0;
+ gr->cz = tz / 4.0;
+
} else {
int i;
+ double tx = 0.0;
+ double ty = 0.0;
+ double tz = 0.0;
gr->panel = NULL;
gr->children = malloc(gt->n_children*sizeof(struct detgeom_panel_group *));
@@ -1849,8 +1876,15 @@ static struct detgeom_panel_group *walk_group(const DataTemplate *dtempl,
detgeom, hierarchy_level+1, i);
if ( gr->children[i] == NULL ) return NULL;
gr->children[i]->parent = gr;
+ tx += gr->children[i]->cx;
+ ty += gr->children[i]->cy;
+ tz += gr->children[i]->cz;
}
+ gr->cx = tx / gt->n_children;
+ gr->cy = ty / gt->n_children;
+ gr->cz = tz / gt->n_children;
+
}
gr->member_index = member_index;