FTCORG COMMENTS
*-- Author :    Stephen J. Maxfield   08/03/91
      SUBROUTINE FTCORG
*D: FTCORG.......SM.  Extension of FRG1 bank to include asymmetry.                                            
*D: FTCORG.......SM.  Get effective stagger from new FCR3 bank.                                               
*D: FTCORG.......SM.  Extension of FPG1 bank to include asymmetry.                                            
*D: FTCORG.......SM.  Get effective stagger from FCP1 bank.                                                   
**: FTCORG 30907 RP.  Farm changes.                                                                           
**----------------------------------------------------------------------                                      
*     ========== ======                                                                                       
*     Build tables of corrected geometry for Radial and Planar                                                
*     Drift Chambers.                                                                                         
*  *---------------------------------------------*                                                            
*  *  To be Called at beginning of each New Run  *                                                            
*  *---------------------------------------------*                                                            
*                                                                                                             
*  INPUT: Nominal geometry:- FGAR and FGAP Banks                                                              
*         Corrections     :- F1RC, F1PC, FCP1                                                                 
*         Dead wire maps  :- FRDW, FPDW                                                                       
*         Later: shifts from 'shift banks'                                                                    
*                                                                                                             
*  OUTPUT:  FRG1 and FPG1 banks                                                                               
*                                                                                                             
*!       BANKname BANKtype      ! Comments                                                                    
* TABLE  FRG1                   ! Corrected geometry of Radial Chambers                                       
*                               ! Row number = Cell number + 1                                                
*                               ! TEMPORARY.                                                                  
*!   ATTributes:                                                                                              
*!   -----------                                                                                              
*!COL ATT-name FMT Min    Max   ! Comments                                                                    
*!                                                                                                            
*  1  IDEAD    I                !  Dead wire indicator: 0=OK 1=dead                                           
*  2  PHIWP    F                !  Angle of +wire                                                             
*  3  STAGP    F                !  Stagger of +wire (effective)                                               
*  4  ZWP      F                !  Z of +wire                                                                 
*  5  PHIWM    F                !  Angle of -wire                                                             
*  6  STAGM    F                !  Stagger of -wire (effective)                                               
*  7  ZWM      F                !  Z of -wire                                                                 
*  8  STAGEP   F                !  Stagger of +wire (geometric)                                               
*  9  STAGEM   F                !  Stagger of -wire (geometric)                                               
*!                                                                                                            
* END TABLE                                                                                                   
*!       BANKname BANKtype      ! Comments                                                                    
* TABLE  FPG1                   ! Corrected geometry of Planar Chambers                                       
*                               ! Row number = Cell number                                                    
*                               ! TEMPORARY.                                                                  
*!   ATTributes:                                                                                              
*!   -----------                                                                                              
*!COL ATT-name FMT Min    Max   ! Comments                                                                    
*!                                                                                                            
*  1  IDEAD    I                !  Dead wire indicator: 0=OK 1=dead                                           
*  2  PHIW     F                !  Angle of wire                                                              
*  3  STAGE    F                !  Effective Stagger of wire                                                  
*  4  ZWP      F                !  Z of wire                                                                  
*  5  STAGG    F                !  Geometric  Stagger of wire                                                 
*!                                                                                                            
* END TABLE                                                                                                   
*#**********************************************************************                                      
*KEEP,BCS.                                                                                                    
*KEEP,H1EVDT.                                                                                                 
*                                                                                                             
*  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                                                                 
*                                                                                                             
*KEEP,CNSTBF.                                                                                                 
*KEEP,FWINDS.                                                                                                 
*     Work bank indices...                                                                                    
*KEND.                                                                                                        
*                                                                                                             
*                                                                                                             
*                                                                                                             
*     Locators for geometrical data in F1RC bank...                                                           
*     Locators for geometrical data in F1PC bank...                                                           
*     Locators for data in FCP1 bank...                                                                       
*     Locators for data in FCR3 bank...                                                                       
*     dead wire map...                                                                                        
*     Local arrays                                                                                            
*KEEP,STFUNCT.                                                                                                
*     index of element before row number IROW                                                                 
*     index of L'th element  of row number IROW                                                               
*     L'th integer element of the IROW'th row of bank with index IND                                          
*     L'th real element of the IROW'th row of bank with index IND                                             
*KEEP,FTFUNCT.                                                                                                
*     Statement functions for RADIAL Chamber data access.                                                     
*     Using Channel Number J                                                                                  
*     Module, Wedge-pair and Z-plane numbers...                                                               
*     Statement function for obtaining WEDGE numbers(0-47) of                                                 
*     wires at plus and minus ends of Cell numbers                                                            
*     Statement function for obtaining IOS wire number (1-36)                                                 
*     Statement functions for PLANAR Chamber data access.                                                     
*     Using Channel Number J                                                                                  
*     Module, orientation, W-cell and Z-plane numbers...                                                      
*     IPSMD in range 0:8 Planar module number.                                                                
*                                                                                                             
*     IOS wire number (runs from 0 to 36)                                                                     
* SB plane numbers (1-72) from cell number                                                                    
* Module, orientation, wire and (typical) cell number from plane                                              
* number in the range 1-72 (planars, radials and combined)                                                    
*KEND.                                                                                                        
*----------------------------------------------------------------------                                       
*----------------------------------------------------------------------                                       
*     Access nominal geometry banks FGAR and FGAP                                                             
*     --------------                                                                                          
        CALL BKFMT('FRG1','2I,(6F)')
        CALL BKFMT('FPG1','2I,(3F)')
        IQFRG1 = NAMIND('FRG1')
        IQFPG1 = NAMIND('FPG1')
        CALL UGTBNK('FGAR',INFGAR)
           CALL H1STOP                                                                                 
        CALL UGTBNK('FGAP',INDP)
           CALL H1STOP                                                                                 
*       Get basic radial parameters...                                                                        
*                                                                                                             
*                                                                                                             
*                                                                                                             
*     Get basic planar parameters...                                                                          
*                                                                                                             
*                                                                                                             
*     -----                                                                                                   
*                                                                                                             
*     Hit database for bank with corrections to nominal geometry                                              
      CALL UGTBNK('F1RC',INDC)
         CALL H1STOP                                                                                   
*     Hit database for effective stagger.                                                                     
      CALL UGTBNK('FCR3',INDCR3)
         CALL H1STOP                                                                                   
*     Hit database for dead wire map                                                                          
      CALL UGTRUN('FRDW',INDD)                                                                         
         CALL H1STOP                                                                                   
*     Check if old FRG1 bank exists. If so drop it.                                                           
         CALL BDROP(IW,'FRG1')
*                                                                                                             
*       Get dead wire flag...                                                                                 
*       Phi of wires at plus and minus end. Nominal...                                                        
*       ... add corrections                                                                                   
*       Geometric stagger of wire...                                                                          
*       Effective Stagger of wire.                                                                            
*       Attach sign of geometric stagger...                                                                   
*       Monte Carlo has no effective stagger...                                                               
*       Stagger of plus and minus wires (effective) corrected for                                             
*       geometric offsets from nominal...                                                                     
*       Z of wire (nominal only)                                                                              
*       Stagger of plus and minus wires (geometric) corrected for                                             
*       geometric offsets from nominal...                                                                     
*GDP                                                                                                          
*      WRITE(6,'('' ** FTCORG.R *'',3I4,8(1X,F7.3))') JJ,IRMOD(JJ),                                           
*    & IRZPL(JJ),IAR(1),(BAR(II),II=2,9)                                                                      
*GDP                                                                                                          
*                                                                                                             
*                                                                                                             
*                                                                                                             
* ------------------------------------------------------------------                                          
*                                                                                                             
*             Planar Geometry                                                                                 
*                                                                                                             
*                                                                                                             
*     Hit database for bank with corrections to nominal geometry                                              
      CALL UGTBNK('F1PC',INDC)
         CALL H1STOP                                                                                   
*     Hit database for effective stagger.                                                                     
      CALL UGTBNK('FCP1',INDCP1)
         CALL H1STOP                                                                                   
*     Hit database for dead wire map                                                                          
      CALL UGTRUN('FPDW',INDD)                                                                         
         CALL H1STOP                                                                                   
*     Check if old FPG1 bank exists. If so drop it.                                                           
         CALL BDROP(IW,'FPG1')
*       Get dead wire flag...                                                                                 
*       Phi of the Wires defined st Phi wire = Phi of +w-axis - pi/2                                          
*                                                                                                             
*       Geometric stagger of wire...                                                                          
*       Effective Stagger of wire...                                                                          
*       Attach sign of geometric stagger, convert from microns to cm...                                       
*       Monte Carlo has no effective stagger...                                                               
*       W of wire (effective)                                                                                 
*       Z of wire in cell...                                                                                  
*       W of wire (geometric)                                                                                 
*GDP                                                                                                          
*      WRITE(6,'('' ** FTCORG.P *'',6I4,6(1X,F8.3))') JJ,IPSMD(JJ),                                           
*    & IPZPL(JJ),IPWCL(JJ),KWCL,IAR(1),(BAR(II),II=2,4)                                                       
*GDP                                                                                                          
*