aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2021-03-22 16:28:54 +0100
committerThomas White <taw@physics.org>2021-03-23 18:19:36 +0100
commit66eff85bd922212ffc5b6332abdeffff9c75e761 (patch)
tree0503b2f0a87ce7e98cec17799d5ff6a9f3732ac4 /libcrystfel
parent5d42a5a07530509f156bf56dcbcbbfce85e025c7 (diff)
Use crystal's detector shift during prediction
Previously, this was handled by updating the detector, but this could easily lead to strange double accounting.
Diffstat (limited to 'libcrystfel')
-rw-r--r--libcrystfel/src/geometry.c26
-rw-r--r--libcrystfel/src/predict-refine.c20
2 files changed, 17 insertions, 29 deletions
diff --git a/libcrystfel/src/geometry.c b/libcrystfel/src/geometry.c
index adb95e69..68a532b8 100644
--- a/libcrystfel/src/geometry.c
+++ b/libcrystfel/src/geometry.c
@@ -53,6 +53,7 @@
static int locate_peak_on_panel(double x, double y, double z, double k,
struct detgeom_panel *p,
+ double det_shift_x, double det_shift_y,
double *pfs, double *pss)
{
double ctt, tta, phi;
@@ -79,10 +80,10 @@ static int locate_peak_on_panel(double x, double y, double z, double k,
gsl_vector_set(t, 1, sin(tta)*sin(phi));
gsl_vector_set(t, 2, ctt);
- gsl_matrix_set(M, 0, 0, p->cnx);
+ gsl_matrix_set(M, 0, 0, p->cnx+(det_shift_x/p->pixel_pitch));
gsl_matrix_set(M, 0, 1, p->fsx);
gsl_matrix_set(M, 0, 2, p->ssx);
- gsl_matrix_set(M, 1, 0, p->cny);
+ gsl_matrix_set(M, 1, 0, p->cny+(det_shift_y/p->pixel_pitch));
gsl_matrix_set(M, 1, 1, p->fsy);
gsl_matrix_set(M, 1, 2, p->ssy);
gsl_matrix_set(M, 2, 0, p->cnz);
@@ -118,6 +119,7 @@ static int locate_peak_on_panel(double x, double y, double z, double k,
static signed int locate_peak(double x, double y, double z, double k,
struct detgeom *det,
+ double det_shift_x, double det_shift_y,
double *pfs, double *pss)
{
int i;
@@ -130,12 +132,9 @@ static signed int locate_peak(double x, double y, double z, double k,
p = &det->panels[i];
- if ( locate_peak_on_panel(x, y, z, k, p, pfs, pss) ) {
-
- /* Woohoo! */
- return i;
-
- }
+ if ( locate_peak_on_panel(x, y, z, k, p,
+ det_shift_x, det_shift_y,
+ pfs, pss) ) return i; /* Woohoo! */
}
@@ -387,9 +386,13 @@ static Reflection *check_reflection(struct image *image, Crystal *cryst,
if ( (image->detgeom != NULL) && (updateme != NULL) ) {
double fs, ss;
+ double det_shift_x, det_shift_y;
+
assert(get_panel_number(updateme) <= image->detgeom->n_panels);
+ crystal_get_det_shift(cryst, &det_shift_x, &det_shift_y);
locate_peak_on_panel(xl, yl, zl, mean_kpred,
&image->detgeom->panels[get_panel_number(updateme)],
+ det_shift_x, det_shift_y,
&fs, &ss);
set_detector_pos(refl, fs, ss);
@@ -401,8 +404,13 @@ static Reflection *check_reflection(struct image *image, Crystal *cryst,
double fs, ss; /* position on detector */
signed int p; /* panel number */
+ double det_shift_x, det_shift_y;
+
+ crystal_get_det_shift(cryst, &det_shift_x, &det_shift_y);
p = locate_peak(xl, yl, zl, mean_kpred,
- image->detgeom, &fs, &ss);
+ image->detgeom,
+ det_shift_x, det_shift_y,
+ &fs, &ss);
if ( p == -1 ) {
reflection_free(refl);
return NULL;
diff --git a/libcrystfel/src/predict-refine.c b/libcrystfel/src/predict-refine.c
index 2432055f..5a7c554f 100644
--- a/libcrystfel/src/predict-refine.c
+++ b/libcrystfel/src/predict-refine.c
@@ -322,22 +322,6 @@ int refine_radius(Crystal *cr, struct image *image)
}
-static void update_detector(struct detgeom *det,
- double xoffs, double yoffs, double coffs)
-{
- int i;
-
- for ( i=0; i<det->n_panels; i++ ) {
- struct detgeom_panel *p = &det->panels[i];
-
- /* Convert to pixels */
- p->cnx += xoffs / p->pixel_pitch;
- p->cny += yoffs / p->pixel_pitch;
- p->cnz += coffs / p->pixel_pitch;
- }
-}
-
-
static int iterate(struct reflpeak *rps, int n, UnitCell *cell,
struct image *image,
double *total_x, double *total_y, double *total_z)
@@ -503,10 +487,6 @@ static int iterate(struct reflpeak *rps, int n, UnitCell *cell,
csx += gsl_vector_get(shifts, 6);
csy += gsl_vector_get(shifts, 7);
csz += gsl_vector_get(shifts, 8);
- update_detector(image->detgeom,
- gsl_vector_get(shifts, 9),
- gsl_vector_get(shifts, 10),
- 0.0);
*total_x += gsl_vector_get(shifts, 9);
*total_y += gsl_vector_get(shifts, 10);
*total_z += 0.0;