*-- Author : Stephen Burke
SUBROUTINE FFKLMN(INFTUR,JTR)
*-----------------------------------------Updates 30/09/94-------
**: FFKLMN.......SB. Corrections moved to FFCORR.
*-----------------------------------------Updates 17/05/94-------
**: FFKLMN 50106 SB. Bug fix for low momentum.
*-----------------------------------------Updates 22/11/93-------
**: FFKLMN.......SB. Farm changes.
**: FFKLMN.......SB. New params in FFOUT call.
**: FFKLMN.......SB. Debug histos only for .GE.2 planar segs.
*-----------------------------------------Updates 27/07/93-------
**: FFKLMN 30907 RP. Farm changes.
*-----------------------------------------Updates 03/05/93-------
**: FFKLMN 30907 SB. Radius ignored if there are planar hits.
*-----------------------------------------Updates 29/10/92-------
**: FFKLMN 30907 SB. Small change in debug steering.
*-----------------------------------------Updates 25/08/92-------
**: FFKLMN 30907 SB. Trap SGI overwrites.
*-----------------------------------------Updates 06/08/92-------
**: FFKLMN 30907 SB. Cosmetic changes; new histograms.
*-----------------------------------------Updates 04/05/92-------
**: FFKLMN 30907 SB. Severity added to ERRLOG messages.
**: FFKLMN 30205.SB. ERRLOG error numbers changed.
*-----------------------------------------Updates 28/01/92-------
**: FFKLMN 30205.SB. Make efficiency histograms conditional on PMCUT
*-----------------------------------------Updates 24/01/92-------
**: FFKLMN 30205.SB. BKFMT calls moved to FFKAL.
**: FFKLMN 30205.SB. Check the drift sign in debug mode.
**: FFKLMN 30205.SB. Count failed tracks.
**: FFKLMN 30205.SB. Starting errors must be .LE. errors in FTUR bank.
**: FFKLMN 30205.SB. ERRLOG message format changed.
*-----------------------------------------Updates----------------
**********************************************************************
* *
* Read the FPATREC output banks, pick up the digi list and fit *
* *
* INFTUR is the track bank index and JTR is the track number *
* *
**********************************************************************
LOGICAL FFRJCT,LFAILP,LFAILR
*KEEP,FKNPL.
*
* Per-track values can go in H1WORK; note that LTRUE and LFIRST must
* be set at least per event.
*
* This is about 36k words long; the remaining common blocks are
* about 3.6k in total. Some of this could be in /H1WORK/, but the
* blocks would have to be reorganised.
*
* /FKPROJ/
* /FKFILT/
* /FKSMTH/
* /FKINT/
* /FKRSID/
* /FKTRUE/
* /FKDBG/
*KEEP,FKCNTL.
*KEEP,FKFLAG.
*KEEP,FKCONS.
*KEEP,FKPROJ.
*KEEP,FKSMTH.
*KEEP,FKRSID.
*KEEP,FKTRUE.
*KEEP,FKMEAS.
*KEEP,FFSTEE.
*KEEP,FFSCAL.
* Counters
*KEEP,FFGEO.
*KEEP,FFWBI.
* Work bank indices (note that INDKTR is *NOT* a work bank index!)
*KEEP,FFDBG.
*KEEP,FKDBG.
*KEEP,FKINT.
*KEEP,FRLORA.
*KEEP,BCS.
*KEEP,CNSTBF.
*KEEP,FTANG.
* Statement functions for track angle corrections...
* (assumes COMMON FRLORA present)
*
*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
*KEEP,STFCLW.
* statement functions acting on the BOS COMMON LW
* index of element before row number LWROW
* index of L-th element of row number LWROW
* L-th integer element of the LWROW'th row in bank with index LND
* L-th real element of the LWROW'th row in bank with index LND
*
*KEEP,FTFUNCT.
* Statement functions for RADIAL Chamber data access.
* Using Channel Number J
* Module, Wedge-pair and Z-plane numbers...
* Statement function for obtaining WEDGE numbers(0-47) of
* wires at plus and minus ends of Cell numbers
* Statement function for obtaining IOS wire number (1-36)
* Statement functions for PLANAR Chamber data access.
* Using Channel Number J
* Module, orientation, W-cell and Z-plane numbers...
* IPSMD in range 0:8 Planar module number.
*
* IOS wire number (runs from 0 to 36)
* SB plane numbers (1-72) from cell number
* Module, orientation, wire and (typical) cell number from plane
* number in the range 1-72 (planars, radials and combined)
*KEND.
**********************************************************************
* Set up the Kalman filter arrays
CALL FFFILL(JTR,LFAILP,LFAILR)
IF (LFAILP) CALL ERRLOG(321,'S:FFKLMN: Bad planar digi pointers')
IF (LFAILR) CALL ERRLOG(322,'S:FFKLMN: Bad radial digi pointers')
* Get the starting vector into the KF format
CALL FKETOI(RW(INDCR(INFTUR,1,JTR)),SSTART,CSTART)
CALL FKNORM(SSTART,IFAIL)
* Initial veto for bad tracks
IF (FFRJCT(SSTART(3))) RETURN
* Find the true track
IF (LTRUTH) CALL FFHUNT(JDIGP,JDIGR,JMAX)
* Histogram the patrec efficiencies
& CALL FFCHEK(JDIGP,JDIGR,JMAX)
* Increment track number
* Corrections for real data only
* Event T0
CALL FFEVT0(DEVT0,ZNOM,VXYZ)
CALL UCOPY(SSTART,SS,10)
CALL FFTRF(DZ,ZTRAN,SS,STRAN,BZ)
* Track angle, time-of-flight, propagation time
CALL FFCORR(JPL,STRAN,ZNOM,VXYZ,DEVT0,BZ,DCORR)
CALL UCOPY(STRAN,SS,10)
* Set up the starting vector
CALL FFSTART(SSTART,CSTART,ZSTART)
* LFIRST and LTRUE can be in /H1WORK/, so must be set here
* Fill the TRUE array if needed
IF (JMAX.GT.0) CALL FFTRUE(JMAX)
* Kalman filter
CALL FKLFTR(IFAIL)
CALL FKLFIT(IFAIL)
CALL ERRLOG(324,'S:FFKLMN: Fatal error in track fit')
* Add to the output banks
CALL FFOUT(JTR,NPS,NRS)
* Analyse the results
IF (IHFK.GT.0 .AND. NPS.GT.1) CALL FKANAL(0,RES,CHISQ,NPS,NRS)
CALL HCDIR('//PAWC/'//CFDBG,' ')
*