From a17341e438a983a076063e8483a65e17f92f41cb Mon Sep 17 00:00:00 2001 From: Thomas White Date: Wed, 13 Aug 2014 15:20:53 +0200 Subject: Fix find_panel_number() --- libcrystfel/src/detector.c | 23 +++++++---------------- libcrystfel/src/detector.h | 2 +- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/libcrystfel/src/detector.c b/libcrystfel/src/detector.c index 868b027f..c86f8351 100644 --- a/libcrystfel/src/detector.c +++ b/libcrystfel/src/detector.c @@ -435,7 +435,7 @@ void record_image(struct image *image, int do_poisson, int background, } -struct panel *find_panel(struct detector *det, double fs, double ss) +signed int find_panel_number(struct detector *det, double fs, double ss) { int p; @@ -446,27 +446,18 @@ struct panel *find_panel(struct detector *det, double fs, double ss) if ( (fs >= det->panels[p].min_fs) && (fs < det->panels[p].max_fs+1) && (ss >= det->panels[p].min_ss) - && (ss < det->panels[p].max_ss+1) ) { - return &det->panels[p]; - } + && (ss < det->panels[p].max_ss+1) ) return p; } - return NULL; + return -1; } -int find_panel_number(struct detector *det, int fs, int ss) +struct panel *find_panel(struct detector *det, double fs, double ss) { - int p; - - for ( p=0; pn_panels; p++ ) { - if ( (fs >= det->panels[p].min_fs) - && (fs <= det->panels[p].max_fs) - && (ss >= det->panels[p].min_ss) - && (ss <= det->panels[p].max_ss) ) return p; - } - - return -1; + signed int pn = find_panel_number(det, fs, ss); + if ( pn == -1 ) return NULL; + return &det->panels[pn]; } diff --git a/libcrystfel/src/detector.h b/libcrystfel/src/detector.h index b87e6dc9..0fc0610a 100644 --- a/libcrystfel/src/detector.h +++ b/libcrystfel/src/detector.h @@ -170,7 +170,7 @@ extern void record_image(struct image *image, int do_poisson, int background, extern struct panel *find_panel(struct detector *det, double fs, double ss); -extern int find_panel_number(struct detector *det, int fs, int ss); +extern signed int find_panel_number(struct detector *det, double fs, double ss); extern struct detector *get_detector_geometry(const char *filename); -- cgit v1.2.3