*-- Author : R. Henderson 24/10/94 SUBROUTINE FPFSTS(ID1,ID2,ID3,ISM,PCHI,CHISQ,NDF,SOL,EXYSXY) C------------------------------------------------------------------ C C--- ESPECIALLY MODIFIED TO FIT SECONDARY AND TERTIARY SEGMENTS C C------------------------------------------------------------------ C C--- THIS ROUTINE PERFORMS A LEAST SQUARES FIT TO A STRAIGHT C--- LINE FOR POINTS AT POSITIONS Z(I) MEASURED IN THE Y U V COORDINATE C--- FRAMES WHERE U COORDINATES ARE AT ANGLE THETA(2) AND V ARE AT C--- ANGLE THETA(3) TO Y. THETA IS ASSUMED TO BE MEASURED IN THE C--- CLOCKWISE DIRECTION. C C--- INPUT : C C--- Y - POINTS FOR FITTING; 4 FROM Y COORDS, 4 FROM U, 4 FROM V. C--- RESOL - RESOLUTION ON EACH DIGITIZING (IN PRINCIPLE PER WIRE) C--- ZPLAN(36) - Z COORDINATE OF EACH PLANAR WIRE SET C C--- OUTPUT : C C--- PCHI PROBABILITY FROM CHISQUARE C--- SOL(4) X0 Y0 DX/DZ DY/DZ C--- EXYSXY(4,4) COVARIANCE MATRIX TO SOL C C------------------------------------------------------------------ C--- *KEEP,FPPRAM. C C--- MAXSEG is maximum number of segments per supermodule C--- MAXCON is maximum number of amibiguous segments associatable with C--- one segment C--- LIMSTO is maximum number of 2 cluster planes intersections to be C--- stored per supermodule C--- MSEGLM is maximum number of clusters that can be found before C--- connectivity considered C--- MAXCLU is maximum number of clusters that can be found after C--- forming non-connected set MUST BE 50 IF RUN WITH OLD RCW C--- (cluster = 3/4 digits found in a straight line in one C--- 4-wire orientation) C C--- *KEND. C--- *KEEP,FPLSEG. C--- C--- *KEND. C--- *KEEP,FPLGEO. C--- C--- *KEND. C--- *KEEP,FPCLUS. C--- *KEND. C--- *KEEP,FPH1WRK. C-- *KEEP,FPCSEG. C--- C--- C-- *KEEP,FPDIGI. C--- C-- *KEEP,FPDGI. C--- C-- *KEEP,FPSTID. C--- C-- *interface to real data C---. *KEEP,BOSMDL. C ------BOSMDL C ------ *KEEP,FPSTSG. C--- *KEND. C--- C--- C--- C DATA THETA/ 0.0 , - 1.0471976 , 1.0471976/ C--- C C--- INITIALIZATION PER SUPERMODULE C C C--- ROTATE THETA SO THETA(1) = 0.0 C C C--- SETUP GEOMETRICAL CONSTANTS C C C--- SETUP Z ARRAY APPROPRIATE TO CURRENT SM C C C--- CENTRE OF PLANES C C C--- FIND Y U V FOR THE CURRENT SEGMENT C C C--- FIND OFSETS SUCH THAT Y ARRAY IS ON ORDER YUV C C--- C--- C--- C C--- Unpack segment Y values identifiers C C C--- SET WEIGHT MATRIX C C--- C C--- COUNT NUMBER OF DIGITIZINGS CONTRIBUTING C C C--- ZERO SUMS C C C--- LOOP OVER Z POSITIONS TO FORM SUMS C C--- C--- C C--- SCALE TERMS 2,3 BY COS2T C C C--- NOW FORM MTRIXA C C--- C--- C--- C C--- NOW CALCULATE ERROR MATRIX FOR XY,SLOPE XY C C--- CALL DINV(4,EXYSXY,4,WORK,IFAIL) C--- CALL ERRLOG(215,'W:FPFSTS: YUV fit failed') C C--- CALCULATE VECTOR B C C C--- NOW SOLVE FOR X,Y,SX,SY C C C--- PUT ZERO BACK TO Z=0 FROM Z=ZMEAN C C-- CALL FPPPTZ(EXYSXY,-ZMEAN) C C--- NOW CALCULATE RESULTANT Y U V C C C--- CALCULATE CHISQUARE C C C--- C * Fix for v. small Chisq... C C--- PLSEG ARRAY FILLED HERE C CALL ERRLOG(216,'W:FPFSTS: .GT. MAXSEG segments found') C C--- INCREMENT FOUND SEGMENT COUNTER C C C--- Store away digitization pointers for found segment C C C--- C C--- PREPARE OUTPUT BANKS C C C--- ROTATE BACK FROM THETA(1) = 0.0 TO X Y FRAME C C C--- Store segments information for FPSGRF C C--- C--- *