C   05/11/82 705211100  MEMBER NAME  ERRMOM   (JADEGS)      FORTRAN
      SUBROUTINE ERRMOM(IP,P,FMASS,DP)
      IMPLICIT INTEGER*2 (H)
C
C        RETURNS THE (THEORETICALLY EXPECTED) MOMENTUM ERROR DP IN GEV
C        FOR A TRACK WITH A GIVEN MASS HYPOTHESIS.
C           THE SPACE RESOLUTION CONTRIBUTION IS GIVEN BY A GLUCKSTERN
C        TYPE FORMULA, CORRECT TO FIRST ORDER IN 1/N, WHERE N=NRFI, THE
C        NUMBER OF RFI POINTS USED IN THE FIT.
C           XYRES AND ZRES ARE THE JADE XY AND Z RESOLUTIONS IN MM.
C           FACMSC=(0.015 GEV)**2*CN, WHERE CN=1.43 FOR NRFI >> 3.
C           FACTAN=12., REF. E.G. R.G.GLASSER: 'ANALYSIS OF ERRORS....',
C        N.R.L. REPORT 6150 (1964)
C           RADLEN IS THE MEAN RADIATION LENGTH OF THE JADE JET CHAMBER
C        IN MM, FOUND AS FOLLOWS:
C              TRLEN=FSENSW(3)-FSENSW(1)
C        IS THE MAXIMUM RADIAL DISTANCE ALONG THE TRACK, WHERE TWO
C        LAYERS OF ROHACELL, AND, OF COURSE, THE JADE GAS CONTRIBUTE
C        TO THE RADIATION LENGTH. THUS:
C              RADLEN=TRLEN/(XR1ROH+XR2ROH+TRLEN/XRJETC)=11666 MM
C        (THE VARIABLES ARE ALL IN COMMON /CGEO1/ )
C
C        INPUTS:
C                IP    = POINTER TO TRACK IN 'PATR'
C                P     = MOMENTUM (GEV), FOUND E. G. BY ROUTINES
C                        'FNDMOM' OR 'TRACK'
C                FMASS = PARTICLE MASS (NEEDED FOR MULTIPLE SCATTERING)
C
#include "cdata.for"
#include "cgeo1.for"
      DATA XYRES/0.180/,FACMSC/3.22E-4/,RADLEN/11666./,ZRES/42./
      DATA FACTAN/12./
      DATA VELH/0.2998E-4/
      DATA IPRMAX/10/,IPR/0/
C        GET PARAMETERS
      VELHB=VELH*ABS(BKGAUS)
      NRFI=IDATA(IP+24)
      NRZ=IDATA(IP+33)
      TAN=ADATA(IP+30)
      COSTSQ=1./(TAN*TAN+1.)
      COST=SQRT(COSTSQ)
      PSQ=P*P
C        PROJECTED TRACK LENGTH
      XF = ADATA(IP+5)
      YF = ADATA(IP+6)
      XL = ADATA(IP+12)
      YL = ADATA(IP+13)
      PROLSQ = (XF-XL)**2+(YF-YL)**2
      PROLEN=SQRT(PROLSQ)
      IF(P.GT..001.AND.PROLEN.GT.10..AND.NRZ.GT.1)GO TO 10
      IPR=IPR+1
      IF(IPR-IPRMAX)82,83,91
   82 WRITE(6,999)P,PROLEN
  999 FORMAT(/' *** ERRMOM TROUBLE *** P,PROLEN=',2E12.4/)
      GO TO 91
   83 WRITE(6,998)
  998 FORMAT(' *** ERRMOM: DIAGNOSTICS TURNED OFF, LIMIT REACHED ***')
      GO TO 91
C        POSITION RESOLUTION
   10 DPRESQ=720./(NRFI+5.)*PSQ*COSTSQ*(XYRES/(VELHB*PROLSQ))**2
C        MULTIPLE SCATTERING
      DPMSCQ=FACMSC*(1.+FMASS*FMASS/PSQ)/(VELHB**2*RADLEN*PROLEN*COST)
C        COS THETA (R-Z) RESOLUTION
      DPCOSQ=TAN*ZRES/((TAN*TAN+1.)*PROLEN)
      DPCOSQ=FACTAN*DPCOSQ*DPCOSQ/FLOAT(NRZ)
C        PUT IT ALL TOGETHER
      DP=SQRT(DPRESQ+DPMSCQ+DPCOSQ)*P
   90 RETURN
   91 DP=1.E15
      GO TO 90
      END
