SUBROUTINE VFCOPT ( * * inputs * : COUNT, DCOUNT, FOCUS, NPTS, REJECT, * * outputs * : FOCUSF, FOCUSC, NREJ, STATUS) * * Module number: 15.2.1.2 * * Module name: focusv * * Keyphrase: * ---------- * find the optimum focus setting using both "flat top" and "centroid" schemes * * Description: * ------------ * * FORTRAN name: VFCOPT.FOR * * Keywords of accessed files and tables: * -------------------------------------- * Name I/O Description / Comments * None * * Subroutines Called: * ------------------- * CDBS: * None * SDAS: * UMSPUT * Others: * None * * History: * -------- * Version Date Author Description * 1 06-01-87 J.-C. HSU design and coding * 2 11-20-87 J.-C. HSU F77 SDAS *------------------------------------------------------------------------------- * *== input: * --count rate and its standard deviation REAL COUNT(1), DCOUNT(1), * --focus setting : FOCUS(1), * --reject level : REJECT * --total number of input data points INTEGER NPTS * *== outputs * --best focus settings REAL FOCUSF, FOCUSC * --number of excluded points INTEGER NREJ, * --error status : STATUS * *== local: * --loop indices INTEGER I, * --number of usable points : NGOOD, * --status : STATOK * --maximum count rate REAL MAX, * --rejection count rate level : LEVEL, * --low end and high end of focus setting * --which are above rejection level : LOW, HIGH, * --summation of focus times count rate * --and count rate : SUMFCT, SUMCT * --error message context CHARACTER*130 CONTXT *=========================begin hsp.inc========================================= * --status return code INTEGER OK, ERRNUM(20) * --message destination and priority INTEGER DEST, PRIO DATA OK /0/ DATA ERRNUM /701, 702, 703, 704, 705, 706, 707, 708, 709, 710, : 711, 712, 713, 714, 715, 716, 717, 718, 719, 720/ DATA DEST, PRIO /1, 0/ *=========================end hsp.inc=========================================== *------------------------------------------------------------------------------ * * look for highest count rate * MAX = COUNT(1) LOW = FOCUS(1) HIGH = FOCUS(1) * DO 10 I = 1, NPTS IF (COUNT(I) .GT. MAX) THEN MAX = COUNT(I) LOW = FOCUS(I) HIGH = FOCUS(I) END IF 10 CONTINUE * * reject points whose count rates are below maximum count rate multiplied * by the rejection level * LEVEL = MAX * REJECT NGOOD = 0 NREJ = 0 SUMCT = 0. SUMFCT = 0. * DO 20 I = 1, NPTS IF (COUNT(I) .GE. LEVEL) THEN NGOOD = NGOOD + 1 * * subtract the rejection level from count rates and * accumulate summations of count rate and count rate times focus setting * COUNT(I) = COUNT(I) - LEVEL SUMCT = SUMCT + COUNT(I) SUMFCT = SUMFCT + COUNT(I) * FOCUS(I) * * determine the range of the usable focus setting * IF (FOCUS(I) .LT. LOW) THEN LOW = FOCUS(I) ELSE IF (FOCUS(I) .GT. HIGH) THEN HIGH = FOCUS(I) END IF ELSE NREJ = NREJ + 1 END IF 20 CONTINUE * IF (NGOOD .LE. 0) THEN STATUS = ERRNUM(1) CONTXT = 'no point is above rejection level' GO TO 999 END IF * IF (SUMCT .LE. 0.) THEN STATUS = ERRNUM(2) CONTXT = 'summation of count rates is not a positive number' GO TO 999 END IF * * flat top scheme: best focus is midway of the usable focus settings * FOCUSF = REAL(NINT((LOW + HIGH) / 2.)) * * centroid scheme * FOCUSC = REAL(NINT(SUMFCT / SUMCT)) * STATUS = OK GO TO 1000 * * write error message * 999 CALL UMSPUT ('VFCOPT: ' // CONTXT, DEST, PRIO, STATOK) * 1000 RETURN END