aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2011-03-31 14:21:34 +0200
committerThomas White <taw@physics.org>2012-02-22 15:27:23 +0100
commit40c22e008a966d55e4a803373306f821f2fc788e (patch)
tree71eafaa33920678cdfbbbe44560dd0315a88ac24
parent3bd3007d172cb71684a328aeb064a1bed8f0ff1f (diff)
Allow default values in geometry files, and set integration radius seperately
-rw-r--r--doc/examples/cspad-feb2011.geom3
-rw-r--r--doc/examples/lcls-dec.geom6
-rw-r--r--doc/examples/lcls-june-r0013-r0128.geom6
-rw-r--r--doc/geometry.txt13
-rw-r--r--src/detector.c51
-rw-r--r--src/detector.h3
-rw-r--r--src/peaks.c13
7 files changed, 65 insertions, 30 deletions
diff --git a/doc/examples/cspad-feb2011.geom b/doc/examples/cspad-feb2011.geom
index 3d821517..c51a9746 100644
--- a/doc/examples/cspad-feb2011.geom
+++ b/doc/examples/cspad-feb2011.geom
@@ -1,3 +1,6 @@
+; Parameters common to all panels
+integr_radius = 2.0
+
; Quadrant 0, asic 0
q0a0/min_fs = 0
q0a0/min_ss = 0
diff --git a/doc/examples/lcls-dec.geom b/doc/examples/lcls-dec.geom
index 349d2b16..f98b42fd 100644
--- a/doc/examples/lcls-dec.geom
+++ b/doc/examples/lcls-dec.geom
@@ -2,6 +2,10 @@ mask = /processing/hitfinder/masks
mask_good = 0x07
mask_bad = 0x00
+; These default values will be used unless overridden by the per-panel values
+peak_sep = 50.0
+integr_radius = 10.0
+
upper/min_fs = 0
upper/max_fs = 1023
upper/min_ss = 512
@@ -13,7 +17,6 @@ upper/ss = y
upper/clen = 67.8e-3
upper/res = 13333.3 ; 75 micron pixel size
upper/badrow_direction = y
-upper/peak_sep = 50
lower/min_fs = 0
lower/max_fs = 1023
@@ -26,7 +29,6 @@ lower/ss = y
lower/clen = 70.8e-3
lower/res = 13333.3 ; 75 micron pixel size
lower/badrow_direction = y
-lower/peak_sep = 50
bad_jetneartobeam/min_x = -15.0
bad_jetneartobeam/max_x = +15.0
diff --git a/doc/examples/lcls-june-r0013-r0128.geom b/doc/examples/lcls-june-r0013-r0128.geom
index 730baf42..943b245f 100644
--- a/doc/examples/lcls-june-r0013-r0128.geom
+++ b/doc/examples/lcls-june-r0013-r0128.geom
@@ -2,6 +2,10 @@ mask = /processing/hitfinder/masks
mask_good = 0x27
mask_bad = 0x00
+; These default values will be used unless overridden by the per-panel values
+peak_sep = 50.0
+integr_radius = 10.0
+
; Upper panel (nearest the beam)
0/min_fs = 0
0/max_fs = 1023
@@ -14,7 +18,6 @@ mask_bad = 0x00
0/clen = 64.78e-3
0/res = 13333.3 ; 75 micron pixel size
0/badrow_direction = y
-0/peak_sep = 50
; Lower panel (furthest from the beam)
1/min_fs = 0
@@ -28,7 +31,6 @@ mask_bad = 0x00
1/clen = 67.73e-3
1/res = 13333.3 ; 75 micron pixel size
1/badrow_direction = y
-1/peak_sep = 50
bad_jetneartobeam/min_x = -15.0
bad_jetneartobeam/max_x = +15.0
diff --git a/doc/geometry.txt b/doc/geometry.txt
index bf395e1c..c215d27c 100644
--- a/doc/geometry.txt
+++ b/doc/geometry.txt
@@ -56,10 +56,14 @@ panel0/badrow_direction = -
; The resolution (in pixels per metre) for this panel
panel0/res = 9090.91
-; The characteristic peak separation. The peak detection will assume that
-; genuine peaks are separated by at least this amount.
+; The characteristic peak separation in pixels. The peak detection will assume
+; that genuine peaks are separated by at least this amount.
panel0/peak_sep = 6.0
+; You need to specify the peak integration radius, which should be a little
+; larger than the actual radii of the peaks in pixels
+panel0/integr_radius = 2.0
+
; The camera length (in metres) for this panel
; You can also specify the HDF path to a scalar floating point value containing
; the camera length in millimetres.
@@ -100,6 +104,9 @@ mask = /processing/hitfinder/masks
mask_good = 0x27
mask_bad = 0x00
+; Any of the per-panel values can be given without a panel prefix, for example:
+peak_sep = 6.0
+; in which case the value will be used for all *subsequent* panels.
-See the "examples" folder for some examples.
+See the "examples" folder for some examples (look at the ones ending in .geom).
diff --git a/src/detector.c b/src/detector.c
index b3eb8faa..c542a5a1 100644
--- a/src/detector.c
+++ b/src/detector.c
@@ -306,21 +306,12 @@ static struct panel *new_panel(struct detector *det, const char *name)
det->panels = realloc(det->panels, det->n_panels*sizeof(struct panel));
new = &det->panels[det->n_panels-1];
- new->min_fs = -1;
- new->min_ss = -1;
- new->max_fs = -1;
- new->max_ss = -1;
- new->cnx = NAN;
- new->cny = NAN;
- new->clen = -1.0;
- new->res = -1.0;
- new->badrow = '-';
- new->no_index = 0;
- new->peak_sep = 50.0;
- new->fsx = 1.0;
- new->fsy = 0.0;
- new->ssx = 0.0;
- new->ssy = 1.0;
+ memcpy(new, &det->defaults, sizeof(struct panel));
+
+ /* Create a new copy of the camera length location if needed */
+ if ( new->clen_from != NULL ) {
+ new->clen_from = strdup(new->clen_from);
+ }
strcpy(new->name, name);
return new;
@@ -408,6 +399,8 @@ static int parse_field_for_panel(struct panel *panel, const char *key,
panel->res = atof(val);
} else if ( strcmp(key, "peak_sep") == 0 ) {
panel->peak_sep = atof(val);
+ } else if ( strcmp(key, "integr_radius") == 0 ) {
+ panel->integr_radius = atof(val);
} else if ( strcmp(key, "badrow_direction") == 0 ) {
panel->badrow = val[0]; /* First character only */
if ( (panel->badrow != 'x') && (panel->badrow != 'y')
@@ -487,7 +480,11 @@ static void parse_toplevel(struct detector *det, const char *key,
det->mask_good = v;
}
- } else {
+ } else if ( strcmp(key, "peak_sep") == 0 ) {
+ det->defaults.peak_sep = atof(val);
+ } else if ( strcmp(key, "integr_radius") == 0 ) {
+ det->defaults.integr_radius = atof(val);
+ } else if ( parse_field_for_panel(&det->defaults, key, val) ) {
ERROR("Unrecognised top level field '%s'\n", key);
}
}
@@ -505,11 +502,12 @@ struct detector *get_detector_geometry(const char *filename)
fh = fopen(filename, "r");
if ( fh == NULL ) return NULL;
- det = malloc(sizeof(struct detector));
+ det = calloc(1, sizeof(struct detector));
if ( det == NULL ) {
fclose(fh);
return NULL;
}
+
det->n_panels = 0;
det->panels = NULL;
det->n_bad = 0;
@@ -518,6 +516,25 @@ struct detector *get_detector_geometry(const char *filename)
det->mask_bad = 0;
det->mask = NULL;
+ /* The default defaults... */
+ det->defaults.min_fs = -1;
+ det->defaults.min_ss = -1;
+ det->defaults.max_fs = -1;
+ det->defaults.max_ss = -1;
+ det->defaults.cnx = NAN;
+ det->defaults.cny = NAN;
+ det->defaults.clen = -1.0;
+ det->defaults.res = -1.0;
+ det->defaults.badrow = '-';
+ det->defaults.no_index = 0;
+ det->defaults.peak_sep = 50.0;
+ det->defaults.integr_radius = 10.0;
+ det->defaults.fsx = 1.0;
+ det->defaults.fsy = 0.0;
+ det->defaults.ssx = 0.0;
+ det->defaults.ssy = 1.0;
+ strncpy(det->defaults.name, "", 1023);
+
do {
int n1, n2;
diff --git a/src/detector.h b/src/detector.h
index 42651ebd..0ceff341 100644
--- a/src/detector.h
+++ b/src/detector.h
@@ -39,6 +39,7 @@ struct panel
char badrow; /* 'x' or 'y' */
int no_index; /* Don't index peaks in this panel if non-zero */
double peak_sep; /* Characteristic peak separation */
+ double integr_radius; /* Peak integration radius */
double fsx;
double fsy;
@@ -76,6 +77,8 @@ struct detector
char *mask;
unsigned int mask_bad;
unsigned int mask_good;
+
+ struct panel defaults;
};
diff --git a/src/peaks.c b/src/peaks.c
index 65002538..38825d93 100644
--- a/src/peaks.c
+++ b/src/peaks.c
@@ -160,8 +160,8 @@ int integrate_peak(struct image *image, int cfs, int css,
if ( p == NULL ) return 1;
if ( p->no_index ) return 1;
- lim = p->peak_sep/4.0;
- out_lim = 1.0 + lim;
+ lim = p->integr_radius;
+ out_lim = 2.0 + lim;
lim_sq = pow(lim, 2.0);
out_lim_sq = pow(out_lim, 2.0);
@@ -338,15 +338,16 @@ static void search_peaks_in_panel(struct image *image, float threshold,
}
/* Abort if drifted too far from the foot point */
- if ( distance(mask_fs, mask_ss, fs, ss)
- > p->peak_sep ) {
+ if ( distance(mask_fs, mask_ss, fs, ss) >
+ p->peak_sep/2.0 )
+ {
break;
}
} while ( did_something );
/* Too far from foot point? */
- if ( distance(mask_fs, mask_ss, fs, ss) > p->peak_sep ) {
+ if ( distance(mask_fs, mask_ss, fs, ss) > p->peak_sep/2.0 ) {
nrej_dis++;
continue;
}
@@ -377,7 +378,7 @@ static void search_peaks_in_panel(struct image *image, float threshold,
/* Check for a nearby feature */
image_feature_closest(image->features, f_fs, f_ss, &d, &idx);
- if ( d < p->peak_sep ) {
+ if ( d < p->peak_sep/2.0 ) {
nrej_pro++;
continue;
}