THE E852 SQUAW KINEMATIC FITTER C INTERFACE

The squaw kinematic fitter requires the GROUP_GEO_VERTICES and GROUP_GEO_TRACKS
to be present, and must be initialized with the squawio() function.  The
following groups can be added to the itape by making the appropriate calls:

	GROUP_SQUAW_SVFITS	840	svfits_t (squaw.h) single vertex fits
	GROUP_SQUAW_SVPULLS 	841	svpulls_t (squaw.h) single vertex pulls
	
	GROUP_SQUAW_MVFITS 	850	mvfits_t (squaw.h) multi-vertex fits
	GROUP_SQUAW_MVPULLS 	851	mvpulls_t (squaw.h) multi-vertex pulls


INITIALIZATION

void squawio(int, int, int)

	squawio() initializes the squaw fitter and should be called only once
	at the beginning of your program.  It allocates memory for four
	global pointers (mvfits, mvpulls, svfits, and svpulls), and calls
	the fortran function squawio_().

	The first two arguments are for debugging and should be set to zero
	for normal use.  The last argument sets the fitter up for single
	vertex fitting only if zero, or both single vertex and multi-vertex
	fitting if one.

        Example:  
	squawio(0, 0, 1); /*initializes squaw fitter for single vertex and
			    multi-vertex fitting*/

FITS

If one would like to add *both* the GROUP_SQUAW_MVFITS (squaw multi-vertex 
fits) and the GROUP_SQUAW_SVFITS (squaw single vertex fits) to the itape, use
the GenerateSquawFits() call.  If *only* single vertex fits or *only*
multi-vertex fits are required, use GenerateSquawSVFits() or 
GenerateSquawMVFits() instead.  These calls must be made once per event.

NOTE: *Never* use both GenerateSquawSVFits() and GenerateSquawMVFits() together
as this will cause squaw to run twice per event.

int GenerateSquawFits(itape_header_t *buffer, int bufsize)

	The function GenerateSquawFits() adds both GROUP_SQUAW_MVFITS (squaw 
	multi-vertex fits) and GROUP_SQUAW_SVFITS (squaw single vertex fits) 
	to the itape.  This call should be made once per event and requires
	the GROUP_GEO_VERTICES and GROUP_GEO_TRACKS to be present.  The third 
	argument of squawio() should have been set to one to initialize
      	multi-vertex fitting.

int GenerateSquawMVFits(itape_header_t *buffer, int bufsize)

	The function GenerateSquawMVFits() adds *only* GROUP_SQUAW_MVFITS 
	(squaw multi-vertex fits) to the itape.  This call should be made once
	per event and requires the GROUP_GEO_VERTICES and GROUP_GEO_TRACKS to 
	be present.  The third argument of squawio() should have been set to 
	one to initialize multi-vertex fitting.

	NOTE:  This function should not be used along with 
	GenerateSquawSVFits() or GenerateSQuawFits().

int GenerateSquawSVFits(itape_header_t *buffer, int bufsize)

	The function GenerateSquawSVFits() adds *only* GROUP_SQUAW_SVFITS 
	(squaw single vertex fits) to the itape.  This call should be made once
 	per event and requires the GROUP_GEO_VERTICES and GROUP_GEO_TRACKS to 
	be present.  The third argument of squawio() can be set to either zero
	or one, but, if only single vertex fits are required, should be
	set to zero as multi-vertex fits are significantly slower than
	single vertex fits.  

	NOTE:  This function should not be used along with 
	GenerateSquawMVFits() or GenerateSquawFits().

PULLS

The GenerateSquaw...Pulls() functions must always be called *after* the
GenerateSquaw...Fits() functions.  This is because the fit functions
invoke squaw while the pull functions do not.  These calls should be
made once per event.

If one would like to add *both* the GROUP_SQUAW_MVPULLS (squaw multi-vertex 
pulls) and the GROUP_SQUAW_SVPULLS (squaw single vertex pulls) to the itape, 
use the GenerateSquawPulls() call.  If *only* single vertex fits or *only*
multi-vertex fits are required, use the GenerateSquawSVPulls() or 
GenerateSquawMVPulls() instead.

int GenerateSquawPulls(itape_header_t *, int bufsize)

	The function GenerateSquawPulls() adds *both* GROUP_SQUAW_MVPULLS 
	(squaw multi-vertex pulls) and GROUP_SQUAW_SVPULLS (squaw single 
	vertex pulls) to the itape.  The third argument of squawio() should 
	have been set to one to initialize multi-vertex fitting.

int GenerateSquawMVPulls(itape_header_t *, int bufsize)

	The function GenerateSquawMVPulls() adds *only* GROUP_SQUAW_MVPULLS 
	(squaw multi-vertex pulls) to the itape.  The third argument of 
	squawio() should have been set to one to initialize multi-vertex 
	fitting.

int GenerateSquawSVPulls(itape_header_t *, int bufsize)

	The function GenerateSquawSVPulls() adds *only* GROUP_SQUAW_SVPULLS 
	(squaw single vertex pulls) to the itape.  The third argument of 
	squawio() can be set to either zero or one, but, if only single vertex
	fits are required, should be set to zero as multi-vertex fits are 
	significantly slower than single vertex fits.

LOWER LEVEL FUNCTIONS

The following functions are used by the GenerateSquaw...() functions.  If
the lower level functions are used directly in lieu of the higher level
functions, they should be called in the following order:
	
void fillFitParameters(itape_header_t *buffer)

	The function fillFitParameters() is needed to load the squaw input 
	common block with information from the itape.  It takes vertex, 
	charged track and gamma information from the itape record and maps it 
	into a fitpar_t.  This structure lies over the fitpar_ input common 
	block of squaw.

void squaw(void)

	This function calls squaw_ which does the actual fit.  Single vertex
	fit information is stored in the fitout_ common block; multi-vertex
	fit information is stored in the fitoutmv_ common block.  The latter
	is only filled if multi-vertex fitting was initialized and a 
	multi-vertex fit was found.

Fits:
	
int sortmvFits(void)

	This function should only be called if multi-vertex fitting was 
	intialized.  It maps the fitoutmv_ common block into the structure 
	mvfits, ordering the mvfits by confidence level.  The return value 
	is the number of multi-vertex fits or zero if squaw was unable to do a
	multi-vertex fit for this event.

int sortsvFits(void)

	This function maps the fitout_ common block into the structure svfits,
	ordering the svfits by confidence level.  The return value is the
	number of single vertex fits or zero if squaw was unable to do a 
	single vertex fit for this event.

int addSquawMVFitsGroup(itape_header_t *buffer, int bufsize)

	Adds GROUP_SQUAW_MVFITS to the itape record.

int addSquawSVFitsGroup(itape_header_t *buffer, int bufsize)

	Adds GROUP_SQUAW_SVFITS to the itape record.

Pulls:

int sortmvPulls(void)

	This function should only be called if multi-vertex fitting was 
	intialized.  It maps the fitoutmv_ common block into the structure 
	mvpulls, ordering the mvpulls by the corresponding fit confidence 
	level.  The return value is the number of multi-vertex fits or zero if
	squaw was unable to do a multi-vertex fit for this event.

int sortsvPulls(void)

	This function maps the fitout_ common block into the structure svpulls,
	ordering the svpulls by the corresponding fit confidence level.  The 
	return value is the number of single vertex fits or zero if squaw was
 	unable to do a single vertex fit for this event.

int addSquawMVPullsGroup(itape_header_t *buffer, int bufsize)

	Adds GROUP_SQUAW_MVPULLS to the itape record.

int addSquawSVPullsGroup(itape_header_t *buffer, int bufsize)
	
	Adds GROUP_SQUAW_SVPULLS to the itape record.


This last function in *not* needed unless you setup squawio() in debug mode, 
i.e. passed a one as the first or second argument to squawio().  If you are 
running in debug mode then you need to call squawend() in order to get the 
program to exit properly.  This call should be made only once after the last 
itape has been fit.

void squawend(void)
							-DS & ST

The routine resetconmin() has been created to reset the minimum confidence 
level for an acceptable fit.  The default is 1.e-4.  This should be used with 
care.  It will be better to let squaw do more fits and you select them than 
have squaw fail them.  There are some cases where a 1 constraint fit will have
a high chisq/low confidence level and the multi-vertex fit will have an
acceptable fit with more constraints.  With the minimum confidence level set
too high, some probably good fits will never get tried.  This routine should
be called at the same place in your program as squawio().

void resetconmin(float conminnew)
							-JMB

NOTE: You must include squaw.h in your code in order to have access to the 
following global structures or global pointers to structures:

	fitpar_t fitpar_;     /* squaw input common block */
	fitout_t fitout_;     /* squaw single vertex output common block */
	fitoutmv_t fitoutmv_; /* squaw multi-vertex output common block */
	fits_t fits;          /* single vertex fits structure */
	svfits_t *svfits;     /* single vertex fits group structure */
	svpulls_t *svpulls;   /* single vertex pulls group  structure */
	mvfits_t *mvfits;     /* multi-vertex fits group structure */
	mvpulls_t *mvpulls;   /* multi-vertex pulls group structure */

Also see: squaw.h, disData.h