*-- Author : Stephen Burke 07/05/92
SUBROUTINE FVZWM(INFTKR,NFTKR,ZNOM,LFIRST,FVVEC,IERR)
*-----------------------------------------Updates 26/07/93-------
**: FVZWM 30907 RP. Farm changes.
*-----------------------------------------Updates 30/10/92-------
**: FVZWM 30907 SB. New debug histogram numbers.
*-----------------------------------------Updates 06/05/92-------
**: FVZWM 30907 SB. New deck to take a weighted mean of z values.
*-----------------------------------------Updates----------------
**********************************************************************
* *
* Calculate z-vertex by weighted mean *
* *
* INPUT; *
* INFTKR - FTKR bank index *
* NFTKR - The number of FTKR rows (= size of work bank) *
* ZNOM - the nominal z-vertex position *
* LFIRST - TRUE for the first call (primary vertex) *
* *
* OUTPUT; *
* FVVEC - the four words of the FTGR bank *
* IERR - non-zero if the weighted mean fails *
* *
**********************************************************************
*KEEP,FVSTEE.
*KEEP,FVPAR.
*KEEP,FVSCAL.
* Various counters
*KEEP,FVWBI.
* Work bank indices
*KEEP,BCS.
*KEEP,STFUNCT.
* index of element before row number IROW
* index of L'th element of row number IROW
* L'th integer element of the IROW'th row of bank with index IND
* L'th real element of the IROW'th row of bank with index IND
*KEND.
**********************************************************************
* Default is failure
*
* Take a weighted mean of the z0 values
*
* Rejected tracks have weight zero
* Accept new value if reasonably consistent with current estimate
* Mark value used by setting weight negative
* New value is closer to nominal z, so discard previous estimate
* Mark used by setting weight negative
* Reset used flag for previous tracks
* First guess at z0 and error
*
* Now work out a chi-squared, and throw away any tracks
* which are too far from the mean
*
* Used tracks now have negative weight
* Primary flag for diagnostics
* If there's only one track, accept it
* Accept if close enough to the mean
* Remove this track (but don't yet update ZMEAN)
* Reset used flag
CALL HFILL(213,CHI,0.,1.)
CALL HFILL(214,CHI,0.,1.)
* Iterate if necessary
* Create FTGX bank
INFTGX = NBANK('FTGX',0,2+NFTKR/2)
CALL ERRLOG(512,'S:FVZWM: Unable to create FTGX')
* Remove all tracks used for this vertex
* Fill the output vector
CALL UCOPY(NDF,FVVEC(4),1)
CALL HFILL(300,PRAT,0.,1.)
*