aboutsummaryrefslogtreecommitdiff
path: root/src/geometry.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2011-02-28 17:11:00 +0100
committerThomas White <taw@physics.org>2012-02-22 15:27:16 +0100
commitc080e2c362628da1a68ad17c117f303945724006 (patch)
treeb24e0c013e34dc2d339d91371ce0c3655a037831 /src/geometry.c
parent0d2fd58266f87fb20aceb017c68b0e455ab4baee (diff)
First round of fallout from new geometry format
Diffstat (limited to 'src/geometry.c')
-rw-r--r--src/geometry.c41
1 files changed, 25 insertions, 16 deletions
diff --git a/src/geometry.c b/src/geometry.c
index 33527f71..f8b74148 100644
--- a/src/geometry.c
+++ b/src/geometry.c
@@ -31,45 +31,54 @@
static signed int locate_peak(double x, double y, double z, double k,
struct detector *det, double *xdap, double *ydap)
{
- int p;
+ int i;
signed int found = -1;
const double den = k + z;
*xdap = -1; *ydap = -1;
- for ( p=0; p<det->n_panels; p++ ) {
+ for ( i=0; i<det->n_panels; i++ ) {
double xd, yd, cl;
- double xda, yda;
+ double fs, ss, plx, ply;
+ struct panel *p;
+
+ p = &det->panels[i];
/* Camera length for this panel */
- cl = det->panels[p].clen;
+ cl = p->clen;
/* Coordinates of peak relative to central beam, in m */
xd = cl * x / den;
yd = cl * y / den;
/* Convert to pixels */
- xd *= det->panels[p].res;
- yd *= det->panels[p].res;
+ xd *= p->res;
+ yd *= p->res;
+
+ /* Convert to relative to the panel corner */
+ plx = xd - p->cnx;
+ ply = yd - p->cny;
+
+ fs = p->xfs*plx + p->yfs*ply;
+ ss = p->xss*plx + p->yss*ply;
- /* Add the coordinates of the central beam */
- xda = xd + det->panels[p].cx;
- yda = yd + det->panels[p].cy;
+ fs += p->min_fs;
+ ss += p->min_ss;
/* Now, is this on this panel? */
- if ( xda < det->panels[p].min_fs ) continue;
- if ( xda > det->panels[p].max_fs ) continue;
- if ( yda < det->panels[p].min_ss ) continue;
- if ( yda > det->panels[p].max_ss ) continue;
+ if ( fs < p->min_fs ) continue;
+ if ( fs > p->max_fs ) continue;
+ if ( ss < p->min_ss ) continue;
+ if ( ss > p->max_ss ) continue;
/* If peak appears on multiple panels, reject it */
if ( found != -1 ) return -1;
/* Woohoo! */
- found = p;
- *xdap = xda;
- *ydap = yda;
+ found = i;
+ *xdap = fs;
+ *ydap = ss;
}