FUNCTION FFCHG
*-- Author : S.Burke
      INTEGER FUNCTION FFCHG(IPDG)
*-----------------------------------------Updates 03/03/93-------                                             
**: FFCHG .......SB. Protect against odd codes.                                                               
*-----------------------------------------Updates----------------                                             
**********************************************************************                                        
*                                                                    *                                        
* Work out the particle charge from the PDG code                     *                                        
*                                                                    *                                        
**********************************************************************                                        
                                                                        
      DIMENSION IQUARK(6),ILEPT(27)                                     
      SAVE IQUARK,ILEPT                                                 
                                                                        
      DATA IQUARK/-1,2,-1,2,-1,2/                                       
      DATA ILEPT/-1,0,-1,0,-1,8*0,1,12*0,1/                             
                                                                        
**********************************************************************                                        
                                                                        
* Zero will get this particle ignored                                                                         
      FFCHG = 0                                                         
                                                                        
      IAPDG = IABS(IPDG)                                                
      IF (IAPDG.LE.10) RETURN                                           
                                                                        
      IF (IAPDG.LT.38) THEN                                             
         FFCHG = ILEPT(IAPDG-10)                                        
         IF (IPDG.LT.0) FFCHG = -FFCHG                                  
         RETURN                                                         
      ENDIF                                                             
                                                                        
* Special codes                                                                                               
      IF (IAPDG.GT.490 .AND. IAPDG.LT.497) THEN                         
         IF (IAPDG.EQ.491 .OR. IAPDG.EQ.492) THEN                       
* Deuteron/triton                                                                                             
            FFCHG = 1                                                   
         ELSEIF (IAPDG.EQ.493) THEN                                     
* Alpha                                                                                                       
            FFCHG = 2                                                   
         ENDIF                                                          
* else geantino/showino                                                                                       
         IF (IPDG.LT.0) FFCHG = -FFCHG                                  
         RETURN                                                         
      ENDIF                                                             
                                                                        
      IQ1 = IAPDG/10   - (IAPDG/100)*10                                 
      IQ2 = IAPDG/100  - (IAPDG/1000)*10                                
      IQ3 = IAPDG/1000 - (IAPDG/10000)*10                               
                                                                        
      IF (IQ1.GT.6 .OR. IQ2.GT.6 .OR. IQ3.GT.6) RETURN                  
                                                                        
      IF (IQ3.GT.0) THEN                                                
         FFCHG = (IQUARK(IQ1) + IQUARK(IQ2) + IQUARK(IQ3))/3            
      ELSEIF (IQ2.EQ.(IQ2/2)*2) THEN                                    
         FFCHG = (IQUARK(IQ2) - IQUARK(IQ1))/3                          
      ELSE                                                              
         FFCHG = (IQUARK(IQ1) - IQUARK(IQ2))/3                          
      ENDIF                                                             
                                                                        
      IF (IPDG.LT.0) FFCHG = -FFCHG                                     
                                                                        
      RETURN                                                            
      END                                                               
*