This commit was generated by cvs2svn to compensate for changes in r2,
[u/mrichter/AliRoot.git] / GEANT321 / ghits / gschit.F
1 *
2 * $Id$
3 *
4 * $Log$
5 * Revision 1.1.1.1  1995/10/24 10:21:11  cernlib
6 * Geant
7 *
8 *
9 #include "geant321/pilot.h"
10 *CMZ :  3.21/02 29/03/94  15.41.20  by  S.Giani
11 *-- Author :
12       SUBROUTINE GSCHIT(ISET,IDET,ITRA,NUMBV,HITS,NHSUM,IHIT)
13 C.
14 C.    ******************************************************************
15 C.    *                                                                *
16 C.    *       Store HITS values into detector IUDET of set IUSET       *
17 C.    *                                                                *
18 C.    *       NUMBV  volume numbers                                    *
19 C.    *       HITS  array of values for the elements of current hit    *
20 C.    *       ITRA  track number associated to this hit                *
21 C.    *       IHIT  output parameter containing the hit number         *
22 C.    *             If IHIT=0  hit has not been stored                 *
23 C.    *                                                                *
24 C.    *       Same action as GSAHIT but in case the physical volume    *
25 C.    *       specified by NUMBV contains already some hit for the     *
26 C.    *       same track, then the routine will sum up the last NHSUM  *
27 C.    *       elements of the hit.                                     *
28 C.    *        In order to use that routine , no packing must be       *
29 C.    *        specified for these NHSUM last hits.                    *
30 C.    *        If NHSUM.LE.0 then GSCHIT is the same as GSAHIT.        *
31 C.    *                                                                *
32 C.    *    ==>Called by : <USER>, GUSTEP                               *
33 C.    *       Authors    R.Brun, M.Maire  *********                    *
34 C.    *                                                                *
35 C.    ******************************************************************
36 C.
37 #include "geant321/gcbank.inc"
38 #include "geant321/gcunit.inc"
39       COMMON/GCLOCA/NLOCAL(2),JS,JD,JDH,JH,JHD,LOCAL(15)
40       DIMENSION NUMBV(*),HITS(*)
41       PARAMETER (MAXINT=2147483647)
42       SAVE NMESS
43       DATA NMESS/0/
44 C.
45 C.    ------------------------------------------------------------------
46 C.
47       CALL GSAHIT(ISET,IDET,ITRA,NUMBV,HITS,IHIT)
48       IF(IHIT.LE.1)GO TO 999
49       IF(NHSUM.LE.0)GO TO 999
50 C
51       NV=IQ(JD+1)
52       NH=IQ(JD+3)
53       NW=NV+NH+1
54       JNEWH = JHD+(IHIT-1)*NW
55       JCURR = JNEWH
56 C
57       DO 30 I=1,IHIT-1
58          JCURR = JCURR-NW
59 C
60 C             Check if track number is ITRA
61 C
62          IF(ITRA.NE.IQ(JCURR+1))GO TO 999
63 C
64 C             Check if volume numbers are the same
65 C
66          DO 10 J=2,NV+1
67             IF(IQ(JCURR+J).NE.IQ(JNEWH+J))GO TO 30
68    10    CONTINUE
69 C
70 C             Volumes are the same. Now sum the last NHSUM hits
71 C
72          DO 20 K=NW,NW-NHSUM+1,-1
73             IF(IQ(JCURR+K).GT.MAXINT-IQ(JNEWH+K)) THEN
74                IQ(JCURR+K) = MAXINT
75                NMESS=NMESS+1
76                IF(NMESS.LT.10)THEN
77                   WRITE(CHMAIL,10000)IQ(JSET+ISET),IQ(JS+IDET)
78                   CALL GMAIL(0,0)
79                ENDIF
80             ELSE
81                IQ(JCURR+K)=IQ(JCURR+K)+IQ(JNEWH+K)
82             ENDIF
83    20    CONTINUE
84 C
85 C             Remove temporarily stored hit
86 C
87          IHIT=IHIT-1
88          IQ(JH+IDET)=IQ(JH+IDET)-NW
89          GO TO 999
90    30 CONTINUE
91 C
92 10000 FORMAT(' ***** GSCHIT OVERFLOW WHEN IUSET= ',A4,' IUDET= ',A4)
93   999 END