From 6ac1249d79f77826695a0ff79af610479c3d978e Mon Sep 17 00:00:00 2001 From: Thomas White Date: Fri, 31 Mar 2017 10:45:18 +0200 Subject: 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. --- src/geoptimiser.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src') 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 ) { -- cgit v1.2.3