Bugfix in AliPoints2Memory
[u/mrichter/AliRoot.git] / GEANT321 / cgpack / cgscop.F
1 *
2 * $Id$
3 *
4 * $Log$
5 * Revision 1.1.1.1  1995/10/24 10:19:44  cernlib
6 * Geant
7 *
8 *
9 #include "geant321/pilot.h"
10 *CMZ :  3.21/02 29/03/94  15.41.32  by  S.Giani
11 *-- Author :
12       SUBROUTINE CGSCOP(IFIRST,CG,RMIN,RMAX)
13 ************************************************************************
14 *                                                                      *
15 *     Name: CGSCOP                                                     *
16 *     Author: E. Chernyaev                       Date:    30.01.89     *
17 *                                                Revised:              *
18 *                                                                      *
19 *     Function: Compute CUBE scope of set of CG-objects                *
20 *                                                                      *
21 *     References: CGMNMX                                               *
22 *                                                                      *
23 *     Input:  IFIRST - flag (1 - if begin of the set)                  *
24 *             CG(*) - CG-object                                        *
25 *                                                                      *
26 *     Output: RMIN(3) - min coordinates of the CUBE                     *
27 *             RMAX(3) - max coordinates of the CUBE                     *
28 *                                                                      *
29 *     Errors: none                                                     *
30 *                                                                      *
31 ************************************************************************
32       REAL      CG(*),RMIN(3),RMAX(3)
33       REAL      RMID(3),RCMIN(3),RCMAX(3)
34 *-
35       CALL CGMNMX(CG,RMIN,RMAX)
36       IF (IFIRST .EQ. 0)                GOTO 100
37       RCMIN(1) = RMIN(1)
38       RCMIN(2) = RMIN(2)
39       RCMIN(3) = RMIN(3)
40       RCMAX(1) = RMAX(1)
41       RCMAX(2) = RMAX(2)
42       RCMAX(3) = RMAX(3)
43   100 IF (RMIN(1) .GT. RMAX(1))         GOTO 999
44       RRR = RCMAX(1) - RCMIN(1)
45       DO 200 I=1,3
46         IF (RCMIN(I) .GT. RMIN(I))      RCMIN(I) = RMIN(I)
47         IF (RCMAX(I) .LT. RMAX(I))      RCMAX(I) = RMAX(I)
48         RMID(I) = (RCMIN(I) + RCMAX(I))/2.
49         IF (RRR .LT. RCMAX(I)-RCMIN(I)) RRR = RCMAX(I) - RCMIN(I)
50   200   CONTINUE
51       DO 300 I=1,3
52         RCMIN(I) = RMID(I) - RRR/2.
53         RCMAX(I) = RMID(I) + RRR/2.
54   300   CONTINUE
55 *
56   999 RMIN(1)  = RCMIN(1)
57       RMIN(2)  = RCMIN(2)
58       RMIN(3)  = RCMIN(3)
59       RMAX(1)  = RCMAX(1)
60       RMAX(2)  = RCMAX(2)
61       RMAX(3)  = RCMAX(3)
62       RETURN
63       END