
*
* $Id: gpspev.F,v 3.2 2005/06/21 02:42:27 cafagna Exp $
*
* $Log: gpspev.F,v $
* Revision 3.2  2005/06/21 02:42:27  cafagna
* Major modification to the geometry and to the random number chain
*
* Revision 3.1.1.1  2002/07/11 16:02:14  cafagna
* First GPAMELA release on CVS
*
*
*CMZ :  2.01/00 05/04/2000  14.35.18  by  Marialuigia Ambriola
*CMZ :  2.00/00 03/03/2000  15.39.06  by  Francesco Cafagna
*CMZ :  1.02/00 07/03/97  14.48.41  by  Francesco Cafagna
*CMZ :  1.00/02 06/02/96  17.34.50  by  Francesco Cafagna
*-- Author :    Francesco Cafagna   09/12/95
      SUBROUTINE GPSPEV
************************************************************************
*                                                                      *
* Volumes definition for the silicon tracking system and magnet        *
* Called by: GPGEM                                                     *
* Author: Francesco Cafagna, 05/12/95 13.39.41                         *
*                                                                      *
************************************************************************
#include "gpgeo.inc"
#include "gpmed.inc"
*
      INTEGER IROT,IVOLU,N,NMED,NUM
      REAL X,Y,Z
*
*  Define the SPEB     volume
*
      NMED= MN2
      CALL GSVOLU('SPEB','BOX ',NMED,SPEB, 3,IVOLU)
*
*  Define the MGFR     volume
*
      NMED= MAL
      CALL GSVOLU('MGFR','BOX ',NMED,MGFR, 3,IVOLU)
*
*  Define the MGPL     volume
*
      NMED= MMAG
      CALL GSVOLU('MGPL','BOX ',NMED,MGPL, 3,IVOLU)
*
*  Define the MGPI     volume
*
      NMED= MN2
      CALL GSVOLU('MGPI','BOX ',NMED,MGPI, 3,IVOLU)
*
*  Define the TRPB     volume
*
      NMED= MAL
      CALL GSVOLU('TRPB','BOX ',NMED,TRPB, 3,IVOLU)
*****
cC ml 20/04/05:
*
cc*  Define the TRPL     volume
*  Define the TPAS and TPAI volume
*
      NMED= MN2
CC      CALL GSVOLU('TRPL','BOX ',NMED,TRPL, 3,IVOLU)
      CALL GSVOLU('TPAS','BOX ',NMED,TPAS, 3,IVOLU)
      NMED= MAL
      CALL GSVOLU('TPAI','BOX ',NMED,TPAI, 3,IVOLU)
CC end ml.
****************
*
*  Define the TRSL     volume
*
c ml: 26/11/04:
c      NMED= MN2
      NMED=MSIT
      CALL GSVOLU('TRSL','BOX ',NMED,TRSL, 3,IVOLU)
*
* Define the THBP volume
*
      NMED=MG10C
      CALL GSVOLU('THBP','BOX ',NMED,THBP, 3,IVOLU)
C end ml.
*
*  Define the TSPA     volume
*
      NMED= MSIT
      CALL GSVOLU('TSPA','BOX ',NMED,TSPA, 3,IVOLU)
*
*  Define the TRCP     volume
*
      NMED= MCF
      CALL GSVOLU('TRCP','BOX ',NMED,TRCP, 3,IVOLU)
*
* Positioning volume TSPA     into the mother TRSL
*
      N= 1
      X= 0.
c ml: 26/11/66:
c      Y= TRSL(2) - TSPA(2)
C #       Y=+TRSL(2)/2
      Y= 0.
      Z= 0.
      CALL GSPOS('TSPA',N,'TRSL',X,Y,Z,0,'ONLY')
C #       N= 2
C # C      Y= Y - 2.*TSPA(2)
C #       Y=-TRSL(2)/2
C #       CALL GSPOS('TSPA',N,'TRSL',X,Y,Z,0,'ONLY')
c ml: 26/11/04:
*
c* Positioning volume TRCP     into the mother TRSL
CC ml 20/04/05: 
CC* Positioning volume TRCP into mother TRPL
* Positioning volume TRCP into mother TRPB
*
c      N= 1
CC ml 20/04/05: 
cc      Z= 0.
cc      Y= 0.
C # Caf mod on 19 Jul 2005 all volumes are placed inside the TPAS one
C #       Z=-TRPB(3)+0.11+TRCP(3)
C #       Y=-TRPB(2)+1.5-0.225+TRCP(2)
CC end ml.
      Z=-0.005
      y=-0.225-TPAS(2)+TRCP(2)
C # end CAF mod
      DO I=1,4
CC ml 20/04/05:         
CC         X=-TRPL(1)+(2*I-1)*TRCP(1)+2*(I-1)*TRSL(1)
C # Caf mod on 19 Jul 2005 all volumes are placed inside the TPAS one
C #          X=-TRPB(1)+2.29+(2*I-1)*TRCP(1)+2*(I-1)*TRSL(1)
         X=-TPAS(1)+(2*I-1)*TRCP(1)+2*(I-1)*TRSL(1)
CC end ml
c         CALL GSPOS('TRCP',I,'TRPL',X,Y,Z,0,'ONLY')
C #          CALL GSPOS('TRCP',I,'TRPB',X,Y,Z,0,'ONLY')
         CALL GSPOS('TRCP',I,'TPAS',X,Y,Z,0,'ONLY')
C # end CAF mod
      ENDDO  
c      X= -TRSL(1) + TRCP(1)
c      CALL GSPOS('TRCP',N,'TRSL',X,Y,Z,0,'ONLY')
C      N= 2
C      X= -X
C      CALL GSPOS('TRCP',N,'TRSL',X,Y,Z,0,'ONLY')
*****
cc ml 20/04/05:
*
*** Positioning volume TRSL     into the mother TRPL
* Positioning volume TRSL     into the mother TRPB
*
c ml: 26/11/04:
C      Y= 0.
cc      Y=THBP(2)
C # Caf mod on 19 Jul 2005 all volumes are placed inside the TPAS one
C #       Y=-TRPB(2)+1.5+2*THBP(2)+TRSL(2)
C      Y=2.75
CC      Z= 0.
C #       Z=-TRPB(3)+0.11+TRCP(3)
      Z=-0.005
      DO I=1, NTRSL
         X=-TPAS(1)+2*(MOD(I-1,3)+1)*TRCP(1)+
     +        (2*(MOD(I-1,3)+1)-1)*TRSL(1)
         IF(I.LE.3) THEN
            Y=TPAS(2)-TRSL(2)
         ELSE
            Y=TPAS(2)-3*TRSL(2)
         ENDIF
         CALL GSPOS('TRSL',I,'TPAS',X,Y,Z,0,'ONLY')
      ENDDO
C # end CAF mod
**********
cc ml: 20/04/05
*
********* Positioning volume THBP     into the mother TRPL
* Positioning volume THBP     into the mother TRPB
*
cc      Y=-TRSL(2)
C # Caf mod on 19 Jul 2005 all volumes are placed inside the TPAS one
C #       Y=-TRPB(2)+1.5+THBP(2)
C # cc      Z= 0.
C #       Z=-TRPB(3)+0.11+TRCP(3)
      Y=-TPAS(2)+THBP(2)
      Z=-0.005
      DO I=1, NTHBP
CC         X= -TRPL(1) + 2*I*TRCP(1)+(2*I-1)*THBP(1)
C #          X=-TRPB(1)+2.29+2*I*TRCP(1)+(2*I-1)*THBP(1)
         X=-TPAS(1)+2*I*TRCP(1)+(2*I-1)*THBP(1)
cc         CALL GSPOS('THBP',I,'TRPL',X,Y,Z,0,'ONLY')
C #          CALL GSPOS('THBP',I,'TRPB',X,Y,Z,0,'ONLY')
         CALL GSPOS('THBP',I,'TPAS',X,Y,Z,0,'ONLY')
      ENDDO
c end ml.
cc ml: 20/04/05
*
* Positioning volume TPAI into the mother TRPB
*
C # Mod By Caf on 19th Jul 2005 all volumes inside the TPAS
      X=0
      Y=-TPAS(2)+TPAI(2)
      Z=-TPAS(3)+TPAI(3)
C #       X=-TRPB(1)+2.29+TPAI(1)
C #       Y=-TRPB(2)+1.5+2.5+TPAI(2)
C #       Z=-TRPB(3)+TPAI(3)
      CALL GSPOS('TPAI',I,'TPAS',X,Y,Z,0,'ONLY')
C # end CAF mod
*
* Positioning volume TPAS into the mother TRPB
*
C # Mod By Caf on 15th Jul 2005
      X=0
      Y=-TRPB(2)+1.5+TPAS(2)
      Z=0
C #       X=-TRPB(1)+2.29+TPAS(1)
C #       Y=-TRPB(2)+1.5+TPAS(2)
C #       Z=-TRPB(3)+0.11+2*TRCP(3)+TPAS(3)
      CALL GSPOS('TPAS',I,'TRPB',X,Y,Z,0,'ONLY')
c end ml.

*
* Positioning volume MGPI     into the mother MGPL
*
      N= 1
      X= 0.
      Y= 0.
      Z= 0.
      CALL GSPOS('MGPI',N,'MGPL',X,Y,Z,0,'ONLY')
*
* Positioning volume MGPL     into the mother MGFR
*
      CALL GSPOS('MGPL',N,'MGFR',X,Y,Z,0,'ONLY')
C Ml: 20/04/05:
c*
c* Positioning volume TRPL     into the mother TRPB
c*
c      N= 1
c      Z= 0.
c      CALL GSPOS('TRPL',N,'TRPB',X,Y,Z,0,'ONLY')
c end ml.
*
* Positioning volumes TRPB & MGPL into the mother SPEB
*
      N= 1
      X= 0.
      Y= SPEB(2) - TRPB(2)
      Z= SPEB(3) - TRPB(3)
      CALL GSPOS('TRPB',N,'SPEB',X,Y,Z,0,'ONLY')
      DO I=1, 5
         X= 0.
         Y= 0.
         Z= Z - TRPB(3) - MGFR(3)
         N= I
         CALL GSPOS('MGFR',N,'SPEB',X,Y,Z,0,'ONLY')
         Y= SPEB(2) - TRPB(2)
         Z= Z - MGFR(3) - TRPB(3)
         N= (I+1)
         IF(I.EQ.5) THEN
            CALL GSPOS('TRPB',N,'SPEB',X,Y,Z,10,'ONLY')
         ELSE
            CALL GSPOS('TRPB',N,'SPEB',X,Y,Z,0,'ONLY')
         ENDIF
      ENDDO
*
      RETURN
      END
