SUBROUTINE FILLQP
*-- Author :    Girish D. Patel   07/12/93
      SUBROUTINE FILLQP(IW,T,Q,M)
**********************************************************************                                        
*                                                                    *                                        
* 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)          *                                        
* M  = DOS multiplicity within hit (=1 for "clean" hit,0 if no info) *                                        
*                                                                    *                                        
* JVM  9/6/92                                                        *                                        
**********************************************************************                                        
                                                                        
*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,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)                                       
*KEEP,FMOHIT.                                                                                                 
      COMMON/FMOHIT/ LHITSP(0:8), LHITSR(0:8)                           
*KEND.                                                                                                        
                                                                        
*KEEP,FMOHIS.                                                                                                 
      INTEGER IHS(28)                                                   
      COMMON/FMOHIS/ IHS                                                
*KEEP,FMOLUN.                                                                                                 
      COMMON/FMOLUN/ LUNH, LUNS, LMES                                   
*KEND.                                                                                                        
                                                                        
      ISTATP(11) = ISTATP(11) + 1                                       
      CALL SHSW(IHS(26),0,18.,1.)                                                                      
      IF( Q.LE.0. )THEN                                                 
        ISTATP(12) = ISTATP(12) + 1                                     
      CALL SHSW(IHS(26),0,19.,1.)                                                                      
        RETURN                                                          
      ENDIF                                                             
      QLOG = ALOG(Q)                                                    
                                                                        
      IF(IW.LT.0 .OR. IW.GT.1151)THEN                                   
         WRITE(LMES,1000)IW,NEVENT                                      
 1000    FORMAT(1X,'*** FILLQP; illegal wire number',I10,' Event',I10)  
         RETURN                                                         
      ENDIF                                                             
                                                                        
      NC = IW/4                                                         
      NWC= MOD(IW,4)+1                                                  
      KRATE = IW/192                                                    
      ICKR  = MOD(IW,192)/4    ! cell number within crate               
      NCO = MOD(NC,32)                                                  
      NPIOS = (IW/128)*4+NWC                                            
         CALL SHD (IHS(1),0,FLOAT(NCO),FLOAT(NPIOS))             !SGI                                  
                                                                        
* fill vector of hits per orientation                                                                         
      LH = IW/128                                                       
      LM = IW/384                                                       
      LHITSP(LH) = LHITSP(LH) + 1                                       
* Histograms for ALL available hits ...                                                                       
      CALL SHSW(IHS(26),0,48.+FLOAT(LH),1.)                                                            
         CALL SHD (IHS( 5),0,T,QLOG)                             !SGI                                  
         CALL SHD (IHS( 6),0,QLOG,0.)                            !SGI                                  
         CALL SHD (IHS( 6),0,QLOG,FLOAT(NWC) )                   !SGI                                  
         CALL SHS (IHS(3),0,T)                                   !SGI                                  
         CALL SHDW (IHS(10),0,T-5.,0.5,+1.)                      !SGI                                  
         CALL SHDW (IHS(10),0,T+5.,0.5,-1.)                      !SGI                                  
         CALL SHDW (IHS(10),0,T-5.,FLOAT(LM)+1.5,+1.)            !SGI                                  
         CALL SHDW (IHS(10),0,T+5.,FLOAT(LM)+1.5,-1.)            !SGI                                  
         CALL SHDW (IHS(10),0,T-5.,FLOAT(LH)+4.5,+1.)            !SGI                                  
         CALL SHDW (IHS(10),0,T+5.,FLOAT(LH)+4.5,-1.)            !SGI                                  
         CALL SHDW (IHS( 9),0,T-5.,0.5,-1.)                      !SGI                                  
         CALL SHDW (IHS( 9),0,T+5.,0.5,+1.)                      !SGI                                  
         CALL SHDW (IHS( 9),0,T-5.,FLOAT(LM)+1.5,-1.)            !SGI                                  
         CALL SHDW (IHS( 9),0,T+5.,FLOAT(LM)+1.5,+1.)            !SGI                                  
         CALL SHDW (IHS( 9),0,T-5.,FLOAT(LH)+4.5,-1.)            !SGI                                  
         CALL SHDW (IHS( 9),0,T+5.,FLOAT(LH)+4.5,+1.)            !SGI                                  
                                                                        
         IF( NHIT(NC,NWC).EQ.MAXHIT ) GOTO 9000                         
         NHIT(NC,NWC) = NHIT(NC,NWC)+1                                  
         TT(NC,NWC,NHIT(NC,NWC)) = T                                    
         QQ(NC,NWC,NHIT(NC,NWC)) = Q                                    
         LNEWP = .TRUE.                                                 
 9000 CONTINUE                                                          
                                                                        
      RETURN                                                            
      END                                                               
*