*
* $Id$
*
* $Log$
*
*CMZ :  2.01/00 05/04/2000  14.35.18  by  Marialuigia Ambriola
*CMZ :  2.00/00 03/03/2000  15.39.05  by  Francesco Cafagna
*CMZ :  1.01/00 17/05/96  23.19.39  by  Francesco Cafagna
*-- Author :    Francesco Cafagna   06/05/96
      INTEGER FUNCTION GPNHIT(CHSET,CHDET)
************************************************************************
*                                                                      *
* Return the total number of hits stored for set and detector CHSET&CHDET *
*                                                                      *
* Variables definition:                                                *
* IN:                                                                  *
*  CHSET, set name                                                     *
*  CHDET, detector name                                                *
*                                                                      *
* Called by:<USER>                                                     *
* Author: Francesco Cafagna, 06/05/96 10.23.50                         *
*                                                                      *
************************************************************************
#include "gcbank.inc"
      CHARACTER*4 CHSET,CHDET
      INTEGER NDET,NSET,ILAST,JS,JH,JD,JHD,JDH
C
C             Find if selected set, detector exists
C
      IF(JHITS.LE.0)GO TO 10
      NSET=IQ(JSET-1)
      CALL GLOOK(CHSET,IQ(JSET+1),NSET,ISET)
      IF(ISET.LE.0)GO TO 10
C
      JS=LQ(JSET-ISET)
      JH=LQ(JHITS-ISET)
      IF(JS.LE.0)GO TO 10
      IF(JH.LE.0)GO TO 10
      NDET=IQ(JS-1)
      CALL GLOOK(CHDET,IQ(JS+1),NDET,IDET)
      IF(IDET.EQ.0)GO TO 10
C
      JD=LQ(JS-IDET)
      JHD=LQ(JH-IDET)
      IF(JHD.LE.0)GO TO 10
      JDH=LQ(JD-1)
C
      ILAST=IQ(JH+IDET)
      IF(ILAST.EQ.0) THEN
         GPNHIT = 0
         GO TO 10
      ENDIF
      NV=IQ(JD+2)
      NH=IQ(JD+4)
      NW=IQ(JD+1)+IQ(JD+3)+1
      GPNHIT=INT(ILAST/NW)
   10 RETURN
      END
