aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2017-03-31 10:45:18 +0200
committerThomas White <taw@physics.org>2017-03-31 16:42:04 +0200
commit6ac1249d79f77826695a0ff79af610479c3d978e (patch)
tree0f0345e92ac2bfde3c2010c78cb87c2517f60fd0 /src
parent3746b4dbed15569764ec6de473806468951748b8 (diff)
geoptimiser: Fix rounding of peak coordinates
Peak locations in CrystFEL are considered to be distances (in pixel units) from the corner of the detector panel. Therefore, simple truncation is needed here, not rounding.
Diffstat (limited to 'src')
-rw-r--r--src/geoptimiser.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/geoptimiser.c b/src/geoptimiser.c
index 4ba2c5d0..f7894787 100644
--- a/src/geoptimiser.c
+++ b/src/geoptimiser.c
@@ -631,10 +631,18 @@ static int add_distance_to_list(struct gpanel *gp,
double *det_shift)
{
int pix_index;
+ int ifs, iss;
double rfs, rss;
double crx, cry;
- pix_index = ((int)rint(imfe->fs) + gp->p->w*(int)rint(imfe->ss));
+ ifs = imfe->fs;
+ iss = imfe->ss; /* Explicit rounding towards zero (truncation) */
+ pix_index = ifs + gp->p->w*iss;
+
+ if ( (ifs >= gp->p->w) || (iss >= gp->p->h) ) {
+ ERROR("Peak is outside panel!\n");
+ return 1;
+ }
if ( gp->num_pix_displ[pix_index] > 0 ) {