SUBROUTINE FPTINT
*-- Author : S.J. Maxfield
      SUBROUTINE FPTINT
**: FPTINT.......SM. Pick up pattern recognition parameters from bank.                                        
**----------------------------------------------------------------------                                      
*=====================================================================*                                       
*                                                                     *                                       
*     This routine performs several initialisation functions for the  *                                       
*     Forward tracker reconstruction. Parameters, flags etc are read  *                                       
*     from the following banks:-                                      *                                       
*                                                                     *                                       
*     FRCS  - Diagnostic flags                                        *                                       
*     FPRP  - Flags and parameters used by pattern recognition        *                                       
*     FPPP  - Flags and parameters used by pattern recognition        *                                       
*                                                                     *                                       
*     Calls FTDGEO - initialise geometry etc. for IOS                 *                                       
*           FTCORG - initialise geometrical constants - create FRG1   *                                       
*                                                              FPG1   *                                       
*                                                                     *                                       
*=====================================================================*                                       
*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,BOSMDL.                                                                                                 
C     ------BOSMDL                                                                                            
      LOGICAL       BEGJOB,ENDRUN,BEGRUN,REVENT,ENDJOB,OTHDAT           
      COMMON/BOSMDL/BEGJOB,ENDRUN,BEGRUN,REVENT,ENDJOB,OTHDAT,          
     +              LCCRUN,NCCRUN,NEVENT,                               
     +              IHA,IBS,IDB,IDATEL,LUP,ISN,JSN                      
      SAVE  /BOSMDL/                                                    
C     ------                                                                                                  
*KEEP,CNSTBF.                                                                                                 
      INTEGER   LW(NBOSIW)                                              
      REAL      SW(NBOSIW)                                              
      EQUIVALENCE (RW(1),IW(1),LW(1),SW(1))                             
*KEEP,H1EVDT.                                                                                                 
      COMMON /H1EVDT/ KEVENT,IDATA,MONTE,LCONF                          
      INTEGER KEVENT,IDATA,LCONF                                        
      LOGICAL MONTE                                                     
*                                                                                                             
*  IDATA  type of information (HEAD bank word 6) :                                                            
*                                                                                                             
*                       0 - real data H1                                                                      
*                       1 - MC data H1SIM                                                                     
*                       2 - real data CERN tests                                                              
*                       3 - MC data ARCET                                                                     
*                                                                                                             
*  MONTE = .TRUE.   if IDATA=1                                                                                
*  KEVENT = event processed counter for H1REC                                                                 
*                                                                                                             
*KEND.                                                                                                        
*                                                                                                             
*KEEP,FGMIOS.                                                                                                 
       COMMON/FGMIOS/                                                   
*    Planar geometry                                                                                          
     + ZPP(140),C(140),S(140),ITYPE(140),WZERO(140),WSPACE,             
*                                                                                                             
*    Radial geometry                                                                                          
     + ZP(36),PHW(36),WS(36)                                            
*                                                                                                             
*KEEP,FPLGEO.                                                                                                 
C---                                                                                                          
      COMMON /FPLGEO/   ZPLAN(36)   , TP(9)   , YP(26)    , PLANE(3,9), 
     1                 RMAX    , RMIN    , YSTART    , YSPACE    ,      
     2                 X0      , Y0      , PZSTRU (8), STAGER   ,       
     3                 RESOL   , ACUT    , CTP(9)    , STP(9)           
C---                                                                                                          
*KEEP,FPTVTX.                                                                                                 
      COMMON/VERTVV/ZV ,XVV,YVV                                         
**the common/VERTEX/ becomes /VERTVV/ (in analogy to /VERTFF/) on the                                         
** 17/6/91, since it is in conflict with the VERTEX module (g.bernardi)                                       
** (note that all these common names should start by F in this deck...)                                       
*KEEP,FDIFLG.                                                                                                 
      COMMON/LDIAG/IDIAG,IDIAG2,MAXPRT,IDOHIS,PMCUT                     
*KEEP,FRWERR.                                                                                                 
      COMMON /WERR/ERRVL,ERRV,ERRP,ERRRX                                
*KEEP,FPTFLG.                                                                                                 
      COMMON/FPTFLG/IPLAR, NIT, IREZ, LUNFP, NPLMAX                     
*KEEP,FPTPAR.                                                                                                 
      COMMON/FPTPAR/PCUT1, PCUT2, PCUT3, CXP, CYP,                      
     +              DRPCT1, DRPCT2, DRPCT3,                             
     +              DRCUT1, DRCUT2, DRCUT3                              
*KEEP,FSGPAR.                                                                                                 
      COMMON/FSGPAR/DMINX, PHIT, TSCUT, SLCUT, RCUT, TSLPC,             
     +              MINHTS, MINPTS, MAXCLU, LSCUT, NWIRES, IPLOT        
*KEEP,FJNPAR.                                                                                                 
      COMMON/FJNPAR/                                                    
     +      CHT3, CHT12, CHT23, CHT13,                                  
     +      PCT3, PCT12, PCT23, PCT13,                                  
     +      PSC3, PSC12, PSC23, PSC13,                                  
     +      RCT3, RCT12, RCT23, RCT13                                   
*KEEP,FPJPAR.                                                                                                 
      COMMON/FPJPAR/                                                    
     +      RRCUT1, RRCUT2, RRCUT3,                                     
     +      PLCC3, PLCC12, PLCC23, PLCC13                               
*KEND.                                                                                                        
                                                                        
      PARAMETER(TWOPI=6.2831853)                                        
                                                                        
*     Access Steering (Diagnostics, Histograms etc.)                                                          
*                                                                                                             
*                                                                                                             
      CALL UGTBNK('FRCS',INDRCS)
      IF(INDRCS.EQ.0) THEN                                              
*     Assume no diagnostics wanted but give warning...                                                        
       CALL ERRLOG(108,'F:FPTINT: No FRCS bank found. Defaults taken')                                 
       IDIAG = 0                                                        
       IDIAG2= 0                                                        
       MAXPRT= 0                                                        
       IDOHIS= 0                                                        
       IREZ  = 0                                                        
*      Unit number for HBOOK Histogram output.                                                                
       LUNFP  = 17                                                      
*      Diagnostics applied only if measured momentum greater than...                                          
       PMCUT = 10000.                                                   
      ELSE                                                              
       IVERS1= LW(INDRCS + 1)                                           
       IF(IVERS1 .EQ. 290492) THEN                                      
         IDIAG = LW(INDRCS + 2)                                         
         IDIAG2= LW(INDRCS + 3)                                         
         MAXPRT= LW(INDRCS + 4)                                         
         IDOHIS= LW(INDRCS + 5)                                         
         IREZ  = LW(INDRCS + 6)                                         
         PMCUT = SW(INDRCS + 7)                                         
       ELSE                                                             
         CALL ERRLOG(109,'F:FPTINT: Wrong FRCS version. Defaults taken')                               
       ENDIF                                                            
      ENDIF                                                             
                                                                        
*     Vertex.  Assume at zero for now.                                                                        
      ZV   =   0.0                                                      
      XVV  =   0.0                                                      
      YVV  =   0.0                                                      
                                                                        
*     Cuts and parameters from FPRP bank.                                                                     
*     Set default values...                                                                                   
*                                                                                                             
*     Drift and radial coordinate errors...                                                                   
      ERRP  = 0.04                                                      
      ERRRX = 4.5                                                       
      ERRV  = 0.02                                                      
      ERRVL = 10.0                                                      
                                                                        
*     Cuts and parameters for FTLSEG...                                                                       
                                                                        
*     Maximum  distance ( in drift) for digitising                                                            
*     to be associated with cluster                                                                           
*     ie road width is 2.*dminx  (cms.)                                                                       
      DMINX=0.20                                                        
*     Maximum  distance ( in phi  ) for digitising                                                            
*     to be associated with cluster =  .1 cm/r  approx                                                        
      PHIT   = 0.05                                                     
*     Minimum size of cluster for starting triple finding                                                     
      MINHTS = 3                                                        
*     minimum number of points/track segment                                                                  
      MINPTS = 4                                                        
*     max size of cluster for analysis                                                                        
      MAXCLU = 50                                                       
*     ABS((D1+D3)/2 -D2 ).LT.TSCUT for triple                                                                 
      TSCUT  = 0.1                                                      
*     Max slope for triple                                                                                    
      TSLPC  = 0.5                                                      
*     Slope cut for joining triples                                                                           
      SLCUT  = 0.2                                                      
*     Min length of segment before extension by projection                                                    
      LSCUT  = 3                                                        
*     Cut in r for triple and projection                                                                      
      RCUT   = 20.                                                      
*     Number of wires in radials                                                                              
      NWIRES = 12                                                       
*     IPLOT=0 for no diagnostic t0, rms to line seg,  plots: max speed                                        
      IPLOT  = 0                                                        
                                                                        
                                                                        
*     Cuts and parameters for Planar pickup.                                                                  
      IPLAR = 1                                                         
      NIT   = 3                                                         
                                                                        
*     Road widths for single point pick-up...                                                                 
      PCUT1 = 1.0                                                       
      PCUT2 = 0.5                                                       
      PCUT3 = 0.2                                                       
      CXP   = 0.0                                                       
      CYP   = 0.0                                                       
*     Road widths for segment pick-up (millimetres!)                                                          
      DRPCT1 = 30.                                                      
      DRPCT2 = 20.                                                      
      DRPCT3 = 20.                                                      
      DRCUT1  = 200.                                                    
      DRCUT2  = 75.                                                     
      DRCUT3  = 75.                                                     
                                                                        
*     Cuts and parameters for radial segment linking...                                                       
      CHT3  = 100.0                                                     
      CHT12 = 100.0                                                     
      CHT23 = 100.0                                                     
      CHT13 = 100.0                                                     
                                                                        
      PCT3  = 0.04                                                      
      PCT12 = 0.04                                                      
      PCT23 = 0.04                                                      
      PCT13 = 0.04                                                      
                                                                        
      PSC3  = 0.002                                                     
      PSC12 = 0.002                                                     
      PSC13 = 0.002                                                     
      PSC23 = 0.002                                                     
                                                                        
      RCT3  = 20.0                                                      
      RCT12 = 20.0                                                      
      RCT23 = 20.0                                                      
      RCT13 = 20.0                                                      
                                                                        
                                                                        
      CALL UGTRUN('FPRP',INDPRP)                                                                       
                                                                        
      IF(INDPRP.EQ.0) THEN                                              
*     Take defaults but give warning...                                                                       
       CALL ERRLOG(110,'F:FPTINT: No FPRP bank found. Defaults taken')                                 
      ELSE                                                              
       IVERS2=      LW(INDPRP + 1)                                      
       IF(IVERS2 .EQ. 300994)THEN                                       
         ERRP  =      SW(INDPRP + 2)                                    
         ERRRX =      SW(INDPRP + 3)                                    
         ERRV  =      SW(INDPRP + 4)                                    
         ERRVL =      SW(INDPRP + 5)                                    
                                                                        
         IPLAR =      LW(INDPRP + 6)                                    
         NIT   =      LW(INDPRP + 7)                                    
         PCUT1 =      SW(INDPRP + 8)                                    
         PCUT2 =      SW(INDPRP + 9)                                    
         PCUT3 =      SW(INDPRP +10)                                    
         CXP   =      SW(INDPRP +11)                                    
         CYP   =      SW(INDPRP +12)                                    
         DRPCT1=      SW(INDPRP +13)                                    
         DRPCT2=      SW(INDPRP +14)                                    
         DRPCT3=      SW(INDPRP +15)                                    
         DRCUT1=      SW(INDPRP +16)                                    
         DRCUT2=      SW(INDPRP +17)                                    
         DRCUT3=      SW(INDPRP +18)                                    
                                                                        
         DMINX =      SW(INDPRP +19)                                    
         PHIT  =      SW(INDPRP +20)                                    
         MINHTS=      LW(INDPRP +21)                                    
         MINPTS=      LW(INDPRP +22)                                    
         MAXCLU=      LW(INDPRP +23)                                    
         TSCUT =      SW(INDPRP +24)                                    
         TSLPC =      SW(INDPRP +25)                                    
         SLCUT =      SW(INDPRP +26)                                    
         LSCUT =      LW(INDPRP +27)                                    
         RCUT  =      SW(INDPRP +28)                                    
         NWIRES=      LW(INDPRP +29)                                    
         IPLOT =      LW(INDPRP +30)                                    
                                                                        
         CHT3  =      SW(INDPRP +31)                                    
         CHT12 =      SW(INDPRP +32)                                    
         CHT23 =      SW(INDPRP +33)                                    
         CHT13 =      SW(INDPRP +34)                                    
                                                                        
         PCT3  =      SW(INDPRP +35)                                    
         PCT12 =      SW(INDPRP +36)                                    
         PCT23 =      SW(INDPRP +37)                                    
         PCT13 =      SW(INDPRP +38)                                    
                                                                        
         PSC3  =      SW(INDPRP +39)                                    
         PSC12 =      SW(INDPRP +40)                                    
         PSC13 =      SW(INDPRP +41)                                    
         PSC23 =      SW(INDPRP +42)                                    
                                                                        
         RCT3  =      SW(INDPRP +43)                                    
         RCT12 =      SW(INDPRP +44)                                    
         RCT23 =      SW(INDPRP +45)                                    
         RCT13 =      SW(INDPRP +46)                                    
                                                                        
       ELSE                                                             
         CALL ERRLOG(111,'F:FPTINT: Wrong FPRP version. Defaults taken')                               
       ENDIF                                                            
      ENDIF                                                             
                                                                        
*     Errors and cuts used in pattern recognition in Planars(RWCH)                                            
      RESOL = 0.24                                                      
      ACUT  = 7.0                                                       
      RMIN = 185.0                                                      
      RMAX = 755.0                                                      
      NPLMAX = 10000                                                    
*     Cuts used in planar-planar linking.                                                                     
      RRCUT1 = 5.0                                                      
      RRCUT2 = 1.0                                                      
      RRCUT3 = 1.0                                                      
      PLCC3  = 100.0                                                    
      PLCC12 = 100.0                                                    
      PLCC23 = 100.0                                                    
      PLCC13 = 100.0                                                    
                                                                        
      CALL UGTBNK('FPPP',INDPPP)
      IF(INDPPP.EQ.0) THEN                                              
*     Take defaults but give warning...                                                                       
       CALL ERRLOG(112,'F:FPTINT: No FPPP bank found. Defaults taken')                                 
      ELSE                                                              
       IVERS3=      LW(INDPPP + 1)                                      
       IF(IVERS3 .EQ.  11194) THEN                                      
         RESOL =      SW(INDPPP + 2)                                    
         ACUT  =      SW(INDPPP + 3)                                    
         RMIN  =      SW(INDPPP + 4)                                    
         RMAX  =      SW(INDPPP + 5)                                    
         NPLMAX=      LW(INDPPP + 6)                                    
         RRCUT1=      SW(INDPPP + 7)                                    
         RRCUT2=      SW(INDPPP + 8)                                    
         RRCUT3=      SW(INDPPP + 9)                                    
         PLCC3 =      SW(INDPPP +10)                                    
         PLCC12=      SW(INDPPP +11)                                    
         PLCC23=      SW(INDPPP +12)                                    
         PLCC13=      SW(INDPPP +13)                                    
       ELSE                                                             
         CALL ERRLOG(113,'F:FPTINT: Wrong FPPP version. Defaults taken')                               
       ENDIF                                                            
      ENDIF                                                             
                                                                        
                                                                        
                                                                        
*     One small consistency check:-                                                                           
      IF(IDOHIS .EQ. 0 .AND. IREZ .NE. 0) THEN                          
         IREZ=0                                                         
      ENDIF                                                             
*     Fill COMMONS FRDGEO and FPLGEO with nominal geometry...                                                 
*     ...and set up Geometry by wire plane number for IOS                                                     
      CALL FTDGEO
*     Create corrected geometry banks FRG1 and FPG1...                                                        
      CALL FTCORG
      WRITE(6,*)                                                        
     +  '  '                                                            
      WRITE(6,*)                                                        
     +  '  '                                                            
      WRITE(6,*)                                                        
     +  '+----------------------------------------------------------+'  
      WRITE(6,*)                                                        
     +  '          FTREC Steering parameters and flags     '            
      WRITE(6,*)                                                        
     +  '          ===== ======== ========== === =====     '            
      WRITE(6,*)                                                        
     +  '  '                                                            
      WRITE(6,*)                                                        
     +  '--------- FRCS Steering Flags ------------------- '            
      WRITE(6,'(A50,I10)')                                              
     +  ' Bank version number                              ', IVERS1    
      WRITE(6,'(A50,I10)')                                              
     +  ' DIAGNOSTIC print FLAG 0 = None;1=more;2=yet more ', IDIAG     
      WRITE(6,'(A50,I10)')                                              
     +  ' DIAGNOSTIC print FLAG 1 = single line per event  ', IDIAG2    
      WRITE(6,'(A50,I10)')                                              
     +  ' Number of events for diag print out              ', MAXPRT    
      WRITE(6,'(A50,I10)')                                              
     +  ' Histograms 0=off   1=some   2=more(lots)         ', IDOHIS    
      WRITE(6,'(A50,I10)')                                              
     +  ' Additional residual histograms if >0             ', IREZ      
      WRITE(6,'(A50,F10.3)')                                            
     +  ' PMCUT (GeV) - no diags if pmeas < PMCUT          ', PMCUT     
      WRITE(6,*)                                                        
     +  '  '                                                            
      WRITE(6,*)                                                        
     +  '--------- FPRP Parameters     ------------------- '            
      WRITE(6,'(A50,I10)')                                              
     +  ' Bank version number                              ', IVERS2    
      WRITE(6,'(A50,F10.3)')                                            
     +  ' Nominal drift coordinate error                   ', ERRP      
      WRITE(6,'(A50,F10.3)')                                            
     +  ' Nominal radial coordinate error                  ', ERRRX     
      WRITE(6,'(A50,F10.3)')                                            
     +  ' Nominal vertex error                             ', ERRV      
      WRITE(6,'(A50,F10.3)')                                            
     +  ' Nominal verex error 2                            ', ERRVL     
      WRITE(6,'(A50,I10)')                                              
     +  ' IPLAR  Pick up planar points as:-                ', IPLAR     
      WRITE(6,'(A50,I10)')                                              
     +  ' NIT      Number of iterations in point pick-up   ', NIT       
      WRITE(6,'(A50,F10.3)')                                            
     +  ' PCUT1  )      (mm)                               ', PCUT1     
      WRITE(6,'(A50,F10.3)')                                            
     +  ' PCUT2  ) road widths for planar point pick-up    ', PCUT2     
      WRITE(6,'(A50,F10.3)')                                            
     +  ' PCUT3  )                                         ', PCUT3     
      WRITE(6,'(A50,F10.3)')                                            
     +  ' CXP    ) planar displacements.                   ', CXP       
      WRITE(6,'(A50,F10.3)')                                            
     +  ' CYP    )                                         ', CYP       
      WRITE(6,'(A50,F10.3)')                                            
     +  ' DRPCT1 )                                         ', DRPCT1    
      WRITE(6,'(A50,F10.3)')                                            
     +  ' DRPCT2 ) r-Phi road for segment pick-up          ', DRPCT2    
      WRITE(6,'(A50,F10.3)')                                            
     +  ' DRPCT3 )                                         ', DRPCT3    
      WRITE(6,'(A50,F10.3)')                                            
     +  ' DRCUT1 )                                         ', DRCUT1    
      WRITE(6,'(A50,F10.3)')                                            
     +  ' DRCUT2 ) Max allowed r-sep                       ', DRCUT2    
      WRITE(6,'(A50,F10.3)')                                            
     +  ' DRCUT3 )                                         ', DRCUT3    
*                                                                                                             
      WRITE(6,'(''    '')')                                             
      WRITE(6,'(10X,''   Ftlseg Cuts:-'')')                             
      WRITE(6,'(10X,''   ====== ====:-'')')                             
      WRITE(6,'(A50,F10.3)')                                            
     +  ' DMINX    Max dist in drift digi->cluster         ', DMINX     
      WRITE(6,'(A50,F10.3)')                                            
     +  ' PHIT     Max dist in Phi   digi->cluster         ', PHIT      
      WRITE(6,'(A50,I10)')                                              
     +  ' MINHTS   Min cluster size to start triple        ', MINHTS    
      WRITE(6,'(A50,I10)')                                              
     +  ' MINPTS   Min points per radia segment            ', MINPTS    
      WRITE(6,'(A50,I10)')                                              
     +  ' MAXCLU   Max size of cluster for analysis        ', MAXCLU    
      WRITE(6,'(A50,F10.3)')                                            
     +  ' TSCUT    abs( (d1+d3)/2 - d2 )