SUBROUTINE FILLQR
*-- Author :    Girish D. Patel   07/12/93
      SUBROUTINE FILLQR(IW,T,Q,RAD,IS,IFLG2)
**********************************************************************                                        
*                                                                    *                                        
* Fill arrays with Ts and Qs for all cells, per event                *                                        
* IW    = Planar Channel Number (0 TO 1151)                          *                                        
* T     = Drift Time in nsec                                         *                                        
* Q     = Integrated Charge (FADC bins * FADC channel content)       *                                        
* RAD   = Charge division radius of hit in cms                       *                                        
* IS    = Wedge pair indicator 1 = + wedge , -1 = - wedge            *                                        
* IFLG2 = IFLAG2 FADC pulse information                              *                                        
*                                                                    *                                        
* JVM  9/6/92                                                        *                                        
**********************************************************************                                        
*KEEP,FMOBIN.                                                                                                 
      PARAMETER( NBINR=40 )                                             
*KEEP,FMOLUN.                                                                                                 
      COMMON/FMOLUN/ LUNH, LUNS, LMES                                   
*KEEP,FMOSUM.                                                                                                 
      COMMON/FMOSUM/ NDATE0,NTIME0,ISTATP(20),ISTATR(20),IFRHV,IFPHV,   
     &               NEVENT,NFIEL0,NPRES0,NECUR0,NPCUR0,IRTE0,IRTP0,    
     &               IEVIN,NFPEVT,NHITSP,NFREVT,NHITSR,NMIN92,          
     &               TOTL,H1L,RTIME,REFF,ILRET                          
*     TOTL   total run luminosity (mb^-1)                                                                     
*     H1L    H1 gated run luminosity (mb^-1)                                                                  
*     RTIME  total run time (sec)                                                                             
*     REFF   run efficiency = (1 - dead_time/run_time)                                                        
*     ILRET  return flag: 0 - ok,  1 - no inf. found in H1DB                                                  
*KEEP,FMOHIT.                                                                                                 
      COMMON/FMOHIT/ LHITSP(0:8), LHITSR(0:8)                           
*KEEP,FMOWRK.                                                                                                 
      PARAMETER (MAXHIT=20)                                             
      LOGICAL LNEWR                                                     
      LOGICAL LNEWP                                                     
      COMMON/H1WORK/                                                    
*     planar hit data...                                                                                      
     +         TT(0:287,4,MAXHIT), NHIT(0:287,4),                       
     +         QQ(0:287,4,MAXHIT), QQW(4) , LNEWP,                      
*     radial hit data...                                                                                      
     +         TTR(0:431,4,MAXHIT), NHITR(0:431,4),                     
     +         QQR(0:431,4,MAXHIT), QQWR(4) , LNEWR,                    
     +         RR(0:431,4,MAXHIT)                                       
*KEND.                                                                                                        
                                                                        
*KEEP,FMOHIS.                                                                                                 
      INTEGER IHS(28)                                                   
      COMMON/FMOHIS/ IHS                                                
*KEND.                                                                                                        
                                                                        
      ISTATR(11) = ISTATR(11) + 1                                       
      CALL SHSW(IHS(26),0,38.,1.)                                                                      
      IF( Q.LE.0. )THEN                                                 
        ISTATR(12) = ISTATR(12) + 1                                     
        CALL SHSW(IHS(26),0,39.,1.)                                                                    
        RETURN                                                          
      ENDIF                                                             
      QLOG = ALOG(Q)                                                    
                                                                        
      IF(IW.LT.0 .OR. IW.GT.863)THEN                                    
         WRITE(LMES,1000)IW,NEVENT                                      
 1000    FORMAT(1X,'*** FILLQR; illegal wire number',I10,' Event',I10)  
         RETURN                                                         
      ENDIF                                                             
                                                                        
      NWM = IW/288                                                      
      NWP = (IW-NWM*288)/12                                             
      NWP2= (NWP/2)*4 + MOD(NWP,2)                                      
      IF(IS.EQ.-1) NWP2 = MOD(NWP2+34,48)                               
      NWO = MOD(IW,12)/4                                                
      NWW = MOD(IW,12)+1                                                
      NC  = NWM*144 + NWP2 + NWO*48                                     
      NWC= MOD(IW,4)+1                                                  
      KRATE = IW/192                                                    
      ICKR  = MOD(IW,192)/4    ! cell number within crate               
      NWPPM = NWP*2+(IS+1)/2                                            
         CALL  SHD (IHS(11),0,FLOAT(NWPPM),FLOAT(NWM*12+NWW))    !SGI                                  
                                                                        
* fill vector of hits per orientation                                                                         
      LH = NWM*3 + NWO                                                  
      LHITSR(LH) = LHITSR(LH) + 1                                       
      CALL SHSW(IHS(26),0,57.+FLOAT(LH),1.)                                                            
* Histograms for ALL available hits ...                                                                       
         CALL  SHS (IHS(13),0,T)                                 !SGI                                  
*GDP     CALL  SHS (IHS(14),0,RAD*FLOAT(IS))                     !SGI                                         
         CALL  SHS (IHS(15),0,RAD)                               !SGI                                  
      IF(RAD.LT.80.0) THEN                                              
         CALL  SHSW(IHS(24),0,T-5.,+1.)                          !SGI                                  
         CALL  SHSW(IHS(24),0,T+5.,-1.)                          !SGI                                  
        XRAD = RAD*FLOAT(NBINR)/80.0                                    
        IRAD = XRAD                                                     
         CALL  SHDW(IHS(25),0,T-60.,XRAD,-1.)                    !SGI                                  
         CALL  SHDW(IHS(25),0,T+60.,XRAD,+1.)                    !SGI                                  
      ENDIF                                                             
*GDP     CALL  SHD (IHS(16),0,T,RAD)                             !SGI                                         
         CALL  SHD (IHS(20),0,T,QLOG)                            !SGI                                  
*GDP     CALL  SHD (IHS(17),0,T,RAD)       Histo  redefined      !SGI                                         
*GDP     CALL  SHD (IHS(18),0,T,RAD)       Histo  redefined      !SGI                                         
         CALL  SHD (IHS(21),0,QLOG,0.)                           !SGI                                  
         CALL  SHD (IHS(21),0,QLOG,FLOAT(NWW))                   !SGI                                  
         IF( NHITR(NC,NWC).EQ.MAXHIT ) GOTO 9000                        
         NHITR(NC,NWC) = NHITR(NC,NWC)+1                                
         TTR(NC,NWC,NHITR(NC,NWC)) = T                                  
         QQR(NC,NWC,NHITR(NC,NWC)) = Q                                  
         RR(NC,NWC,NHITR(NC,NWC)) = RAD                                 
         LNEWR = .TRUE.                                                 
 9000 CONTINUE                                                          
                                                                        
      RETURN                                                            
      END                                                               
*