aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel/src/detector.c
diff options
context:
space:
mode:
Diffstat (limited to 'libcrystfel/src/detector.c')
-rw-r--r--libcrystfel/src/detector.c23
1 files changed, 7 insertions, 16 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];
}