      PROGRAM BUBBLE
C
C     ANALYSIS OF MEASUREMENTS FROM BUBBLE CHAMBER
C         PHOTOGRAPHS
C     -----------------------------------------------
C     AUTHOR: ROBERT EHRLICH (GEORGE MASON U    1973)
C     Revised: Peter Signell (Mich. St. U.      3/86)
C     Revised: Gary Herzenstiel (Mich. St. U.   3/86)
C     Revised: E.J.D.Kales (Mich. St. U.       11/87)
C     Revised: Peter Signell (Mich. St. U.      3/02)
C
C     Program analyzes measurements made on a series of
C     bubble chamber photographs.  Using measurements made
C     of the charged tracks, the program computes the mass
C     of an unseen neutral particle X, which is present in
C     Sigma decal.
C
C     SUBROUTINES:
C          GETINF  - get values for N, LSIG, TH, S, & LPI
C          CALC    - calculate the mass of particle X
C          DISPLA  - print the value of this mass
C          QUERY   - ask if user wants to try again
C
C                             B U B B L E   
C                                  :
C            ----------------------------------------------
C            :                    :              :        :
C         GETINF                CALC          DISPLA    QUERY
C      (N,LSIG,TH,S,LPI) (N,LSIG,TH,S,LPI,X)    (X)    (AGAIN)
C   
C     ***** DECLARATIONS *****
      REAL N,LSIG,LPI,TH,S,X
      CHARACTER AGAIN
      OPEN(UNIT=3,FILE='m358p1f.out')
C     WRITE(3,'(A1//)') 12
C                    
C     ***** M A I N   B O D Y *****
C
 10   CALL GETINF (      N,LSIG,TH,S,LPI)
      CALL CALC   (N,LSIG,TH,S,LPI,    X)
      CALL DISPLA (                    X)  
      CALL QUERY  (                AGAIN)
      IF(AGAIN.EQ.'Y') GOTO 10
      STOP
      END
C
C     ***** G E T I N F *****
C
      SUBROUTINE GETINF(    N,LSIG,TH,S,LPI)
C 
C     get values for N, LSIG, TH, S, & LPI
C
C     ***** DECLARATIONS *****
      REAL N,LSIG,TH,S,LPI
C
C     N    = identifying number for an event
C     LSIG = length of the Sigma track
C     TH   = angle in degrees between sigma and pi-minus tracks
C     S    = sagitta in cm of the pi-minus track
C     LPI  = chord length of the pi-minus track
C
      PRINT *,'Please supply values:'
      WRITE(*,20) 'event number, N='
      READ *,N
      WRITE(*,20) 'sigma track length, LSIG='
      READ *,LSIG
      WRITE(*,20) 'theta(degrees), TH='
      READ *,TH
      WRITE(*,20) 'sagitta of pi, S='
      READ *,S
      WRITE(*,20) 'chord length of pi, LPI='
      READ *,LPI
  20  FORMAT(/A25)
      WRITE(*,24) N,LSIG,TH,S,LPI
      WRITE(3,24) N,LSIG,TH,S,LPI
  24  FORMAT('m358p1f.for:   Bubble Chamber Photograph Analysis'///
     +'         Event Number =',F5.0/
     +'   Sigma track length =',F8.3/
     +'       Theta(degrees) =',F7.2/
     +'        sagitta of PI =',F8.3/
     +'   chord length of PI =',F8.3)
      RETURN                                         
      END
C
C     ***** C A L C *****
C
      SUBROUTINE CALC(N,LSIG,TH,S,LPI,      X)
C 
C     Calculate the mass of particle X
C
C     ***** DECLARATIONS *****
      REAL N,LSIG,TH,S,LPI,X
      REAL THETA,R,PPI,EPI,PSIG,ESIG
C     
C     convert THETA from degrees to radians
C
      THETA=TH*3.14159265/180.0
C
C     R is the momentum of curvature of the pi-minus track
C
      R=LPI**2/(8.0*S)+S/2.0
C
C     PPI is the momentum in MeV/C of the pi-minus track
C
      PPI=6.86*R
C
C     EPI is the total relativistic energy of the pi-minus
C     track
C
      EPI=SQRT(PPI**2+140.0**2)
C
C     maximum possible sigma track length is 0.597 cm
C
      IF((LSIG-0.597).GT.0) LSIG=0.597
C
C     compute sigma momentum from track length
C
      PSIG=174.0*(1.0-LSIG/0.597)**0.25
C
C     ESIG is the total relativistic energy of sigma-minus
C
      ESIG=SQRT(PSIG**2+1197.0**2)
C
C     compute the mass of the X particle
C
      X=SQRT((ESIG-EPI)**2-PSIG**2-PPI**2+2.0*PSIG*PPI*COS(THETA))
C
      RETURN
      END
C
C     ***** D I S P L A *****
C
      SUBROUTINE DISPLA(     X)
C 
C     ***** DECLARATIONS *****
      REAL X
C
      WRITE(*,40) X
      WRITE(3,40) X
 40   FORMAT(/'Mass of X particle =',F8.3)
      RETURN
      END
C
C     ***** Q U E R Y *****
C
      SUBROUTINE QUERY(    AGAIN)
C 
C     ask whether user would like to try another
C
C     ***** DECLARATIONS *****
      CHARACTER AGAIN
C
      PRINT *
      WRITE(*,62)
 62   FORMAT(
     +'Would you like to do this again using new values? (Y/N)? ')
      READ( *,'(A1)')AGAIN
      RETURN
      END
C     ***** P R O G R A M    E N D *****