aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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);