SUBROUTINE FTDSGI
*-- Author :    Girish D. Patel   07/12/93
      SUBROUTINE FTDSGI
**********************************************************************                                        
*                                                                    *                                        
* FTDSGI is to be called once per event on the SGI , to fill all FTD *                                        
* monitoring histograms. It performs start-of-run initialisation in  *                                        
* IF (BEGRUN) and fills statistics histogram at end of each event in *                                        
* FTDSGE                                                             *                                        
*                                                                    *                                        
* GDP 22/10/93                                                       *                                        
*                                                                    *                                        
**********************************************************************                                        
                                                                        
*KEEP,FMORUN.                                                                                                 
      LOGICAL PLANAR,RADIAL                                             
      COMMON /FMORUN/  NRUN,NRUN0,NRUN1,MAXEV,PLANAR,RADIAL             
*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                                                                 
*                                                                                                             
*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     ------                                                                                                  
*KEND.                                                                                                        
                                                                        
      IF(BEGRUN) THEN                                                   
                                                                        
* general initialisation ...                                                                                  
        CALL FTDINT
                                                                        
        NRUN0 = NCCRUN                                                  
                                                                        
* Histogram booking ...                                                                                       
        CALL FQBOOK
                                                                        
      ENDIF                                                             
                                                                        
* Event selection for real data only                                                                          
      IF (MONTE) THEN                                                   
         IRET = 0                                                       
      ELSE                                                              
         CALL FMSLCT(EVT0,EVZV,IRET)
      ENDIF                                                             
                                                                        
      IF(REVENT .AND. IRET.EQ.0) THEN                                   
* update statistics etc ...                                                                                   
         CALL FQMON
                                                                        
* locate FRPE bank and fill Planar monitoring hists ...                                                       
         IF( PLANAR ) CALL FQMONP
                                                                        
* locate FRRE bank and fill Radial monitoring hists ...                                                       
         IF( RADIAL ) CALL FQMONR
                                                                        
      ENDIF                                                             
                                                                        
      RETURN                                                            
      END                                                               
*