SUBROUTINE FVCHEK
*-- Author :    Stephen Burke   07/05/92
      SUBROUTINE FVCHEK(FVVEC)
*-----------------------------------------Updates 02/06/92-------                                             
**: FVCHEK.......SB. Change loop indices to please farm.                                                      
*-----------------------------------------Updates 06/05/92-------                                             
**: FVCHEK.......SB. New deck to check FVFIT output.                                                          
*-----------------------------------------Updates----------------                                             
**********************************************************************                                        
*                                                                    *                                        
* Compare the calculated z-vertex value with the truth               *                                        
*                                                                    *                                        
**********************************************************************                                        
                                                                        
      DIMENSION FVVEC(4)                                                
                                                                        
*KEEP,BCS.                                                                                                    
      INTEGER      NHROW,NHCOL,NHLEN                                    
      PARAMETER   (NHROW = 2, NHCOL = 1, NHLEN=2)                       
      INTEGER      NBOSIW                                               
      PARAMETER   (NBOSIW=1000000)                                      
      INTEGER      IW(NBOSIW)                                           
      REAL         RW(NBOSIW)                                           
      COMMON /BCS/ IW                                                   
      EQUIVALENCE (RW(1),IW(1))                                         
      SAVE   /BCS/                                                      
*KEEP,STFUNCT.                                                                                                
*     index of element before row number IROW                                                                 
      INDR(IND,IROW)=IND+2+IW(IND+1)*(IROW-1)                           
*     index of L'th element  of row number IROW                                                               
      INDCR(IND,L,IROW)=INDR(IND,IROW) + L                              
*     L'th integer element of the IROW'th row of bank with index IND                                          
      IBTAB(IND,L,IROW)=IW(INDCR(IND,L,IROW))                           
*     L'th real element of the IROW'th row of bank with index IND                                             
      RBTAB(IND,L,IROW)=RW(INDCR(IND,L,IROW))                           
*KEND.                                                                                                        
                                                                        
**********************************************************************                                        
                                                                        
      INSVX = NLINK('SVX ',0)                                           
      IF (INSVX.LE.0) THEN                                              
         CALL ERRLOG(531,'W:FVCHEK: No SVX bank')                                                      
         RETURN                                                         
      ENDIF                                                             
                                                                        
      JPRIM = 0                                                         
      ILOOP = IW(INSVX+2)                                               
      DO 100 JVX=ILOOP,1,-1                                             
         IF (IBTAB(INSVX,4,JVX).EQ.1) JPRIM = JVX                       
 100  CONTINUE                                                          
                                                                        
      IF (JPRIM.LE.0) THEN                                              
         CALL ERRLOG(532,'W:FVCHEK: No primary vertex!')                                               
         RETURN                                                         
      ENDIF                                                             
                                                                        
      ZERR   = RBTAB(INSVX,3,JPRIM) - FVVEC(1)                          
      ZPULL  = ZERR/FVVEC(2)                                            
      CHPROB = PROB(ZPULL**2,1)                                         
                                                                        
      CALL HFILL(101,ZERR,0.,1.)                                                                       
      CALL HFILL(102,ZPULL,0.,1.)                                                                      
      CALL HFILL(103,CHPROB,0.,1.)                                                                     
                                                                        
      RETURN                                                            
      END                                                               
*