aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel/src
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2014-08-13 15:20:53 +0200
committerThomas White <taw@physics.org>2014-08-13 15:20:53 +0200
commita17341e438a983a076063e8483a65e17f92f41cb (patch)
tree684fbd214be7048f5b9f580105652476166caaea /libcrystfel/src
parent5625ca80961b26aa8be3962b500febccec24fdf5 (diff)
Fix find_panel_number()
Diffstat (limited to 'libcrystfel/src')
-rw-r--r--libcrystfel/src/detector.c23
-rw-r--r--libcrystfel/src/detector.h2
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; p<det->n_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);