       Real FUNCTION snlightcurve(tin)
C Par(1) is fitted height for first term
C Par(2) is ratio of height inof second term to height of first term
C Par(3) is time zero
C Par(4) is rise time scale
C Par(5) is first peak position
C Par(6) is 2nd peak position
C Par(7) is a time stetch - to be used only when 3, 4, 5, and 6 are fixed 
C Par(8) is a translation in time, also used only when 3-6 are fixed

       Double PRECISION Par(24),FITFUN
       COMMON/HCFITD/Par,FITFUN 
      Double precision  risea, riseb, fall1, fall2, T, td
      Double precision  A, B, t0, TRise, TFall1,Tfall2
        
        A = Par(1) 
        B = Par(2) * Par(1) 
        t0 = Par(3) 
        TRise = Par(4) 
        Tfall1 = (Par(5)-par(3))**2/par(4) 
        Tfall2 = (Par(6)-par(3))**2/par(4) 

        td = (tin - par(8))/par(7)
        t = td - t0

       if(t.le.0) risea=0.
       if(t.le.0) riseb=0.
       if(t.gt.0) then
         risea =  exp(-(Trise/t))  / exp(-(TRise/ (par(5)-t0) ) )
         riseb =  exp(-(Trise/t))  / exp(-(TRise/ (par(6)-t0) ) )
       end if

       fall1 = exp(-t/Tfall1) / exp(-(par(5)-t0)/Tfall1)
       fall2 = exp(-t/Tfall2) / exp(-(par(6)-t0)/Tfall2)

       FitFun= A * risea * fall1 + B * riseb *fall2

       count = count + 1
       term1 = risea * A * fall1
       term2 = riseb * B * fall2

       riseaf = risea
       risebf = riseb
       fall1f = fall1
       fall2f = fall2
       
       if(count.Le.60)
       print *, tin, riseaf, risebf, fall1f, fall2f, term1, term2 
       if(count.eq.60) print *,tfall1,tfall2

       snlightcurve = FitFun
       Return
       END























