*
* $Id$
*
* $Log$
*
*CMZ :  3.00/00 28/08/2001  21.42.01  by  Unknown
*-- Author :    Marialuigia Ambriola   03/04/2001
      REAL FUNCTION XTRYIELD(I,G)
*****************
* Generate the energy spectra for x-rays transition radiation for a given
* energy, per interface, without any absorption.
* Ml. 3/04/2001
*****************
      PARAMETER (ALPHA=1/137.,PG=3.1415926536,HTC=197.3269E-16)
      PARAMETER (C=3.E+10)
      REAL X,C0,RMIN,A0,SUM,TRD2,B0,B1,B2,G
      INTEGER IMIN,IMAX,I
C      DATA RL1/7.0E-4/,RL2/14.1E-4/,N/709/,w1/31.59E-9/,w2/.7E-9/
      DATA RL1/7.0E-4/,RL2/204.E-4/,N/71/,w1/31.59E-9/,w2/.7E-9/
#include "gpaltr.inc"
C
      XTRYIELD=0.
      IF(I.EQ.1) THEN
         RMAX=(RL1+RL2)/(2*PG*HTC)*sqrt((RL1*W1**2+RL2*W2**2)/(RL1+RL2))
C	 PRINT*,'AMASS',AMASS
c         PRINT*,RMAX
      ENDIF
      X=ENATT(I)*1.E-6
c      PRINT*,X,I,ENATT(I)
      C0=(RL1+RL2)/(4*PG*HTC)*(X/G**2+(RL1*W1**2+RL2*W2**2)/X/(RL1+RL2))
      IMIN=1+MAX(INT(RMAX/G),INT(C0))
      IMAX=INT(RMAX)
      A0=ALPHA*((W1**2-W2**2)/X)**2*(RL1+RL2)**2/(X*HTC**2)
      SUM=0.
C      PRINT*,'IMIN,IMAX,RMAX,c0,rmax/g=',IMIN,IMAX,RMAX,c0,RMAX/G
      DO J=IMIN,IMAX
         B0=RL2/(RL1+RL2)*(RL1*(W1**2-W2**2)/(4*X*HTC)-PG*FLOAT(J))
         B0=SIN(B0)**2
         B1=2.*PG*FLOAT(J)-(RL1+RL2)*X/(2.*G**2*HTC)-
     +        (RL1*W1**2+RL2*W2**2)/(2.*X*HTC)
         B2=(RL1*(W1**2-W2**2)/(2.*X*HTC)-2*PG*FLOAT(J))**2
         B2=B2*(RL2*(W2**2-W1**2)/(2.*X*HTC)-2*PG*FLOAT(J))**2
C         PRINT*,'J,B0,B1,B2,SUM=',IMIN,IMAX,B0,B1,B2,SUM
         SUM=SUM+B0*B1/B2
      ENDDO
      XTRYIELD=X*A0*SUM
c      PRINT*,'XTRYIELD',XTRYIELD
      RETURN
      END
