Coord Package for Sunsort

Relies on: Nothing
C include file: evsubs.h
FORTRAN include file: n/a

The package may not be accessed directly from FORTRAN.

This package handles converting detector hit positions to and from 3d vectors. Detector coordinates are specified by an x, y pair with x and y being 0 at the centre of the detector and having a range of -0.5 to 0.5.

The following structure is used to pass coordinates on a detector surface to some of the routines:

        struct xy {
             double x;
             double y;
        };
      

Routines

int coord_init(int n);

Tell the package to reserve enough space to save the details of n detectors. It returns 0 if all went well, 1 if it couldn't get the memory.

int coord_det(int n, FILE *fp)

Read the coordinates of the corners of detector n from the file specified by fp. The corners should be specified as four lines each of the form:

	x y z
      

Where x, y and z are relative to the origin of the coordinate system, which should be the target for routines in the EV package to work.

int coord_andet(int i, FILE *fp)

Read the position of detector n from the file specified by fp. The detector position should be specified as:

	thx thy w h r
      

Where thx and thy are the angle of the centre of the detector specified as axial coordinates. w is the width of the detector, h is its height and r is the distance from the origin of the coordinate system (the target).

int coord(int dt, struct xy *cp, struct vector *hp)

Convert the detector hit position *cp on detector dt into a 3d vector in hp.

To do: Decide if passing the hit location as a structure is overkill.

int ndet_hit(int ndet, double th, double phi)

Given a direction in spherical polar coordinates, calculate which detector it hits from the detectors in the range 1..ndet. The return value is the number of the detector that was hit.

To do: Provide some way of returning the position of the hit.

int det_hit(int i, double th, double phi)

Given a direction in spherical polar coordinates, calculate if it hits detector i. Returns 1 for a hit, zero for a miss.

To do:

int inithitbins(double ts, double ps)

Initialise the hitbins array used by gethitbin. ts and ps specify the number of bins per degree of theta and phi respectively. If this function is called more than once it automatically frees the memory for the old array and initialises the new one to zero.

void freehitbins(void)

Frees the hitbins array to save memory.

int *gethitbin(double theta, double phi)

Convert floating point theta and phi into a pointer to a bin. If inithitbins hasn't been called, then this routine will automatically call it specifying 2 bins per degree.

To do: Decide if this routine (and inithitbins and freehitbins) should be part of the coord package, or if they should be made into their own package.


Steven M. Singer
Last modified: Wed Sep 29 10:13:04 BST 1999