Calc_Peaks (ul_pbar_le_calc)

       Calc_Peaks(Trace_Data.r4.r, Ndata.i4.r, deltaT.r4.r,V1.r4.r, V4.r4.r, 
                  Fextr.r4.r, emit4.r4.r, emit4_fit.r4.r, emit84.r4.r,
                  emit84_fit.r4.r, Area.r4.r, BL53MHz.r4.r, Emit_Max.r4.r,
                  BL4.r4.r, Fit_Curve.r4.r, status.i4.r)

       Subroutine Calc_Peaks manages the various calculations that
       are performed on the monitor scope trace data.

       CALLING SEQUENCE:

         Input Arguments:
           Trace_Data      Array of scope trace data points in Volts
           Ndata           Number of points in "trace_data"
           deltaT          Time separation of trace data points in Sec.
           V1              ARF1 flat-top amplitude (Volts)
           V4              ARF4 final amplitude (Volts)
           Fext            ARF4 frequency (Hz @ h=4 on Acc. extr. orbit)

         Returned Quantities (emittances in eV-sec):
           emit4           h= 4 long. emittance from FWHM of envelope
           emit4_fit       h= 4 long. 95% emittance from parabolic fit to ln(V)
           emit84          Sum of h=84 long. emittances from FWHM over all detected bunches
           emit84_fit      Sum of h=84 long. emittances from parabolic fit over all detected bunches
           Area            Sum of areas of 53MHz peaks (Volt-nsec)
           BL53MHz         Bunch length of largest 53MHz peak (nsec)
           Emit_Max        Emittance of biggest 53 MHz bunch
           BL4	            Base length of h = 4 envelope (from fit) (nsec)
           Fit_Curve       Array of dimension Ndata giving the parabolic fit to the h=4 envelope
                           (Note: if status = 7, Fit_Curve will not be filled)
           status          Error status
                            0 -> Peak search successful
                            1 -> Signal extends beyond  "trace_data" array
                            2 -> Signal begins prior to "trace_data" array
                            3 -> Unable to determine baseline
                            4 -> Right and left baseline differ by > 20% of size of 1st peak
                            5 -> Parabolic fit failed
                            6 -> FWHM measurement failed
                            7 -> Envelope fit failed, Fit_Curve array empty
                           -1 -> No peaks found
                           -2 -> RF parameters out of bounds
                           -3 -> Invalid "delta_T"  T84/Ndata < deltaT < T84/3 { T84 = 1/(84*frev) }
                           -4 -> More than 84/4 = 22 bunches found

       Calc_Peaks also fills the /peak_data/ and /peak_find/ common blocks.
       These common blocks contain arrays containing various measured values 
       for each of the detcted 53 MHz bunches.

       /peak_find/ information (extracted by calling Peak_Locate)
       Peak_index(i)       Trace_Data(Peak_index(i)) is the peak of the ith bunch
       Npeak               Number of 53 MHz bunches detected

       /peak_data/ arrays 
       Pk_time(i)          Time (nsec) of the ith peak
       Pk_value(i)         Voltage at the ith peak (Volts)
       Pk_area(i)          Area of the ith bunch (Volt-sec)
       width_fit(i)        Base width from parabolic fit of ith bunch (nsec)
       Pk_wid(i)           Base width from FWHM of ith bunch (nsec)
       Pk_emit_fit(i)      Long. emittance from fit of ith bunch (eV-sec)
       Pk_emit(i)          Long. emittance from FWHM of ith bunch (eV-sec)
       Pk_stat(i)          Contains Error Status for ith peak

       Pk_index and Npeak is extracted by subroutine Peak_Locate
       Pk_wid, Pk_emit, and Pk_stat are extracted by subroutine EveryBunch

       This function reads the peak search parameters from File Share file:
           RSX$FSHARE_APPLICAT_PBAR_RF:PBARLEPAR.DAT

       CERNLIB routines used:
           LSQ  		(E208)
           VMAX, VMIN, VFILL	(F121)
           DELIKC, DELIEC	(C347)  (Used in LEMIT)

       Related functions:

       Peak_Locate, EveryBunch




Security, Privacy, Legal