      SUBROUTINE PTTOP(MODE,P,ETA,PHI,PT)
*.
*...PTTOP      utility routine to convert from/to momentum 4-vector 
*.             to/from pt, eta and phi
*.
*. INPUT     : MODE   = 1  convert pt, eta and phi into p(4)
*.           :          2  convert p(4) into pt, eta and phi
*.           : if MODE = 1,
*.           :   ETA  pseudo-rapidity
*.           :   PHI  azimuthal angle
*.           :   PT   transverse momentum
*.           : if MODE = 2
*.           :   P(4) momentum 4-vector
*.
*. OUTPUT    : if MODE = 1
*.           :   P(4)
*.           : if MODE = 2
*.           :   ETA, PHI and PT
*.
*. CALLED    : RANTFL
*.
*. AUTHOR    : D.Toya
*. CREATED   : xx-XXX-xxxx
*.
*. MODIFICATION LOG
*. 06-Jul-2000 J.Kanzaki
*.
*.**********************************************************************
      IMPLICIT NONE
      INTEGER MODE
      REAL P(4),ETA,PT,PHI
      REAL THETA,ETA1

      IF (MODE.EQ.1) THEN
         P(1)=PT*COS(PHI)
         P(2)=PT*SIN(PHI)
         P(3)=PT*SINH(ETA)
         P(4)=PT*COSH(ETA)
      ELSEIF (MODE.EQ.2) THEN
         PT=SQRT(P(1)**2+P(2)**2)
         PHI=ATAN2(P(2),P(1))
         ETA=SIGN(LOG((SQRT(PT**2+P(3)**2)+ABS(P(3)))/PT),P(3))
      ENDIF

      RETURN
      END
