      SUBROUTINE UGEOMETRY  ! including part from geom_cryostat2.f

******Purpose: Define set up geometry and materials***************

      DIMENSION PAR(10), centx(9),centy(9),
     +          P_ANTF(3),P_ANT1(3),P_ANT2(3)
     
      data centx/-7.39902,7.39902,15.400002,-15.400002,8.19912,
     +            -8.19912,0.0000,-5.64896,5.64896/
      data centy/-3.02514,-3.02514,4.97332,4.97332,13.97508,
     +             13.97508,5.77342,-14.92504,-14.92504/

      common/centers/centx,centy

      call hessi_rotms


*** Define VOLUMES ***

****** MOTHER VOLUME = MASTER REFERENCE SYSTEM (MARS)**********
      PAR(1) =  0.0
      PAR(2) =  1000.01
      PAR(3) =  0.
      PAR(4) =  180.
      PAR(5) =  0.
      PAR(6) =  360.
      CALL GSVOLU('MARS', 'SPHE', 1, PAR, 6, IVOL) ! VACUUM

****** HESSI mother volume ******
        PAR(1) = 0.
        PAR(2) = 400.0
        PAR(3) = 250.0
        CALL GSVOLU('HESS', 'TUBE', 1, PAR, 3, IVOL) ! VACUUM
        
****** Tubus  (mass: here: 13.8 kg, real: 14.4 kg)
        PAR(1) = 0.
        PAR(2) = 50.5/2.
        PAR(3) = 142.04/2.
        CALL GSVOLU('TUBU', 'TUBE', 1, PAR, 3, IVOL) ! vacuum
        PAR(1) = 46./2.
        PAR(2) = 46.53/2.
        PAR(3) = 140./2.
        CALL GSVOLU('TUBA', 'TUBE',12, PAR, 3, IVOL) ! Carbon Fiber 8.1 kg
        PAR(1)=21.65  
        PAR(2)=23.45 
        PAR(3)=0.5                 ! mass: here: 1.36 kg, real: 1.37 kg
        CALL GSVOLU('ENRI', 'TUBE', 4, PAR, 3, IVOL) ! Endring bottom
        CALL GSVOLU('FRRI', 'TUBE', 4, PAR, 3, IVOL) ! Endring top
        PAR(1)=23.7 
        PAR(2)=25.2 
        PAR(3)=1.0
        CALL GSVOLU('CER1', 'TUBE', 4, PAR, 3, IVOL) ! Center Ring 1.64 kg
        PAR(1)=23.265 
        PAR(2)=23.7 
        PAR(3)=3.0              
        CALL GSVOLU('CER2', 'TUBE', 4, PAR, 3, IVOL) ! Center Ring 1.37 kg
        ! mass CER1+CER2= here: 3.0 kg real: 3.1 kg
        
****** Imager Support Ring   (mass: here:2.1 kg, real:1.96 kg)
        PAR(1)=0.
        PAR(2)=58.167/2
        PAR(3)=7.01
        call GSVOLU('ISRI', 'TUBE', 1,PAR, 3, IVOL)
        PAR(1)=50.546/2 
        PAR(2)=51.   /2 
        PAR(3)=6.75
        call GSVOLU('ISR1', 'TUBE', 6,PAR, 3, IVOL)
        PAR(1)=50.546/2
        PAR(2)=56.92/2
        PAR(3)=0.125
        call GSVOLU('ISR2', 'TUBE', 6,PAR, 3, IVOL)
        PAR(1)=50.546/2
        PAR(2)=58.166/2 
        PAR(3)=0.125
        call GSVOLU('ISR3', 'TUBE', 6,PAR, 3, IVOL)
        
****** Central Cylinder    (mass: here:3.9 kg, real:3.74 kg)
        PAR(1)=0.
        PAR(2)=56.93/2
        PAR(3)=11.44
        call GSVOLU('CCYL', 'TUBE', 1,PAR, 3, IVOL)
        PAR(1)=50.546/2 
        PAR(2)=51.2  /2 
        PAR(3)=11.18
        call GSVOLU('CCY1', 'TUBE', 6,PAR, 3, IVOL)
        PAR(1)=50.546/2
        PAR(2)=56.92/2
        PAR(3)=0.125
        call GSVOLU('CCY2', 'TUBE', 6,PAR, 3, IVOL)
        PAR(1)=50.546/2
        PAR(2)=56.92/2
        PAR(3)=0.125
        call GSVOLU('CCY3', 'TUBE', 6,PAR, 3, IVOL)

****** Base Ring   (mass: here:4.5 kg, real:4.4 kg)
        PAR(1) = 45.9
        PAR(2) = 49.3
        PAR(3) = .375
        CALL GSVOLU('BRI1', 'TUBE', 6, PAR, 3, IVOL) ! Alu
        PAR(1) = 45.9
        PAR(2) = 46.72
        PAR(3) = 1.79
        CALL GSVOLU('BRI2', 'TUBE', 6, PAR, 3, IVOL) ! Alu

****** Balance masses
        PAR(1) = 1.88516  
        PAR(2) = 2.77813
        PAR(3) = 2.52016
        CALL GSVOLU('BALM', 'BOX ',62, PAR, 3, IVOL) ! BRASS

****** Honeycomb Deck   (mass: here: 5.6 kg(16E3 ccm), real:5.6 kg)
        PAR(1) = 97./2.
        PAR(2) = 97./2.
        PAR(3) = 2.5/2.
        CALL GSVOLU('HCDE', 'BOX ',13, PAR, 3, IVOL) ! Alu Honeycomb ! 
        PAR(1) = 0./2.
        PAR(2) = 50.5/2.
        PAR(3) = 2.5/2.
        CALL GSVOLU('HCDH', 'TUBE', 1, PAR, 3, IVOL) ! hole in center
        PAR(1) = 29.3/2.
        PAR(2) =  0.0/2.
        PAR(3) =  2.5/2.
        PAR(4) = 14.65/2.
        CALL GSVOLU('HCDC', 'TRD1', 1, PAR, 4, IVOL) ! corner, vacuum

****** Solar panels  (total mass: here: 33 kg, real: 34 kg)
        PAR(1) = 244./2.
        PAR(2) = 48./2.
        PAR(3) = 4./2.
        CALL GSVOLU('SOLP', 'BOX ', 1, PAR, 3, IVOL) ! Vacuum
        PAR(1) = 230./2. ! here: 5.41 kg massive Al
        PAR(2) = 47./2.  ! see critic. design rev. vol II p 114,72 for mass
        PAR(3) = 0.5/2.  ! 5.45 kg honeycomb +...
        CALL GSVOLU('SOLA', 'BOX ', 6, PAR, 3, IVOL) ! 
        PAR(1) = 3./2.
        PAR(2) = 5./2.
        PAR(3) = 3./2.
        CALL GSVOLU('HING', 'BOX ', 3, PAR, 3, IVOL) ! 4x2, 0.35 kg, steel?
        PAR(1) = 10./2.
        PAR(2) = 30./2.
        PAR(3) = 1.06/2.
        CALL GSVOLU('INMA', 'BOX ', 3, PAR, 3, IVOL) ! inertia mass 2.5kg      
*                                                      4x, steel
****** SAS-Box  (mass: here: 0.38 kg, real: 0.39 kg)
        PAR(1) = 17./2.
        PAR(2) = 0.
        PAR(3) = 5.6/2.
        PAR(4) = 9./2.
        CALL GSVOLU('SASB', 'TRD1', 6, PAR, 4, IVOL)  ! SAS-Box-Wall
        PAR(1) = 15./2.
        PAR(2) = 0.
        PAR(3) = 4.8/2.
        PAR(4) = 8./2.
        CALL GSVOLU('SASV', 'TRD1', 1, PAR, 4, IVOL)  ! SAS-Box-Interior

****** RAS
        PAR(1) = 15.5/2.
        PAR(2) = 23./2.
        PAR(3) = 15.5/2.
        CALL GSVOLU('RASC', 'BOX ', 1, PAR, 3, IVOL)  ! "Container"
        PAR(1) = 10./2.
        PAR(2) = 4.5/2.
        PAR(3) = 8./2.
        CALL GSVOLU('RASW', 'BOX ', 6, PAR, 3, IVOL)  ! Box-Wall 164g
        PAR(1) = 9.6/2.
        PAR(2) = 4.1/2.
        PAR(3) = 7.6/2.
        CALL GSVOLU('RASV', 'BOX ', 1, PAR, 3, IVOL)  ! Box-Interior
        PAR(1) = 17./2.
        PAR(2) = 14.6/2.
        PAR(3) = 15./2.
        PAR(4) = 5.6/2.
        PAR(5) = 6./2.
        CALL GSVOLU('RASB', 'CONE',12, PAR, 5, IVOL)  ! Baffle
        PAR(1) = 10./2.
        PAR(2) = 14./2.
        PAR(3) = 2./2.
        CALL GSVOLU('RASF', 'TUBE', 4, PAR, 3, IVOL) ! Ti-Flang 536g

****** Forward Antenna Brackets  (mass: here: 0.37 kg, real: 0.37 kg)
        DATA P_ANTF/5.,7.,13.5/
        CALL GSVOLU('ANTF', 'BOX ', 1, P_ANTF, 3, IVOL)
        DATA P_ANT1/5.,6.,0.125/
        CALL GSVOLU('ANT1', 'BOX ', 6, P_ANT1, 3, IVOL)
        DATA P_ANT2/1.25,0.125,13./
        CALL GSVOLU('ANT2', 'BOX ', 6, P_ANT2, 3, IVOL)
                        

******* Battery & other boxes:
        call sp_battery_assembly
        call sp_ssr_bracket
        call sp_solid_state_recorder
        call sp_instrument_data_processing_unit
        call sp_instrument_power_converter
        call sp_spacecraft_electronics_module


******Positions of volumes********************************************

* HESS
         CALL GSPOS('HESS',1,'MARS', 0.0, 0.0,  20.0 , 0, 'ONLY')


* Tubus
         CALL GSPOS('TUBU',1,'HESS', 0.0 , 0.0, 77.0,  0, 'MANY')
         CALL GSPOS('TUBA',1,'TUBU', 0.0 , 0.0,  0.0,  0, 'ONLY')
         CALL GSPOS('ENRI',1,'TUBU', 0.0 , 0.0,-70.51 ,0, 'ONLY')
         CALL GSPOS('FRRI',1,'TUBU', 0.0 , 0.0, 70.51 ,0, 'ONLY')
         CALL GSPOS('CER1',1,'TUBU', 0.0 , 0.0,  0    ,0, 'ONLY')
         CALL GSPOS('CER2',1,'TUBU', 0.0 , 0.0,  0    ,0, 'ONLY')

* Imager Support Ring
         CALL GSPOS('ISRI',1,'HESS', 0.0 , 0.0, 51.7,  0, 'MANY')
         CALL GSPOS('ISR1',1,'ISRI', 0.0 , 0.0,  0  ,  0, 'ONLY')
         CALL GSPOS('ISR2',1,'ISRI', 0.0 , 0.0,-6.875, 0, 'ONLY')
         CALL GSPOS('ISR3',1,'ISRI', 0.0 , 0.0, 6.875, 0, 'ONLY')
         
* Central Cylinder
         CALL GSPOS('CCYL',1,'HESS', 0.0 , 0.0, 28.79 ,  0, 'MANY')
         CALL GSPOS('CCY1',1,'CCYL', 0.0 , 0.0,  0    ,  0, 'ONLY')
         CALL GSPOS('CCY2',1,'CCYL', 0.0 , 0.0,-11.305,  0, 'ONLY')
         CALL GSPOS('CCY3',1,'CCYL', 0.0 , 0.0, 11.305,  0, 'ONLY')

* Base Ring
         CALL GSPOS('BRI2',1,'HESS', 0.0 , 0.0,-35.4 ,   0, 'ONLY')
         CALL GSPOS('BRI1',1,'HESS',0.0,0.0,-35.4+1.79+.375,0,'ONLY')
         CALL GSPOS('BRI1',2,'HESS',0.0,0.0,-35.4-1.79-.375,0,'ONLY')

* Balance masses:
c;positioning: radial position of center is:
c;     outside of ring - 2.77813 + 3/16" extension beyond outside of ring
c; = 49.3-2.77813+0.47625 = 47.00
c; First one: 1"+ 5/16" + 1.88516 = rout*tan(theta), rout = 49.3+.47625
c;   then theta = 5.985 degrees.  So the coordinates are:
c;   x = 47.00*sin(5.985) = 4.901  y = 46.744  z = -30.340
c; Second one: angle from previous is:
c;   (2.*1.88516cm + 5/8") = rout*tan(dtheta), so dtheta = 6.1435 degrees.

         CALL GSPOS('BALM',1,'HESS',4.901,46.744,-30.3400, 150, 'ONLY')
         CALL GSPOS('BALM',2,'HESS',9.875,45.951,-30.3400, 151, 'ONLY')
         CALL GSPOS('BALM',3,'HESS',23.896,40.472,-30.3400, 152, 'ONLY')
         CALL GSPOS('BALM',4,'HESS',31.961,34.460,-30.3400, 153, 'ONLY')
         CALL GSPOS('BALM',5,'HESS',35.466,30.841,-30.3400, 154, 'ONLY')

* Honeycomb Deck
         CALL GSPOS('HCDE',1,'HESS', 0.0 , 0.0, 42.1 ,   0, 'MANY')
         CALL GSPOS('HCDH',1,'HCDE', 0.0 , 0.0,  0.0 ,   0, 'MANY')
         CALL GSPOS('HCDC',1,'HCDE',-43.32, 43.32, 0.0 ,256, 'MANY')
         CALL GSPOS('HCDC',2,'HCDE',-43.32,-43.32, 0.0 ,257, 'MANY')
         CALL GSPOS('HCDC',3,'HCDE', 43.32,-43.32, 0.0 ,258, 'MANY')
         CALL GSPOS('HCDC',4,'HCDE', 43.32, 43.32, 0.0 ,259, 'MANY')
         
* Solar panels
         CALL GSPOS('SOLA',1,'SOLP',  -3.5,   0.0,    0.0  ,0,'ONLY')
         CALL GSPOS('INMA',1,'SOLP', 116.5,   0.0,    0.0  ,0,'ONLY')
         CALL GSPOS('HING',1,'SOLP',-120.25, 12.0,    0.0  ,0,'ONLY') 
         CALL GSPOS('HING',2,'SOLP',-120.25,-12.0,    0.0  ,0,'ONLY')
         
         CALL GSPOS('SOLP',1,'HESS', 173.0,   0.0,    45.0, 0,'MANY')
         CALL GSPOS('SOLP',2,'HESS',   0.0,  173.0,   45.0,216,'MANY') 
         CALL GSPOS('SOLP',3,'HESS',-173.0,    0.0,   45.0,217,'MANY')
         CALL GSPOS('SOLP',4,'HESS',   0.0 ,-173.0,   45.0,218,'MANY')

* SAS-Box
         CALL GSPOS('SASV',1,'SASB',  0.0 ,  0.0,   0.0 ,  0, 'ONLY')
         CALL GSPOS('SASB',1,'HESS',  0.0  ,18.6,   3.0 , 219, 'ONLY')
         CALL GSPOS('SASB',2,'HESS',-16.1 , -9.3,   3.0 , 228, 'ONLY')
         CALL GSPOS('SASB',3,'HESS', 16.1 , -9.3,   3.0 , 229, 'ONLY')

* RAS
         CALL GSROTM(223, 90.,225.,75.,315.,15.,135.)
         CALL GSPOS('RASC',1,'HESS', 29.0, -29.0, 26.0 , 223, 'MANY')
         CALL GSPOS('RASB',1,'RASC',  0.0,   2.9,  0.0 , 219, 'ONLY')
         CALL GSPOS('RASW',1,'RASC',  0.0,  -9. ,  0.0 ,  0, 'ONLY')
         CALL GSPOS('RASV',1,'RASW',  0.0,   0. ,  0.0 ,  0, 'ONLY')
         CALL GSPOS('RASF',1,'RASC',  0.0,  -6.1,  0.0 , 219, 'ONLY')

* Antennas
         CALL GSROTM(251, 90., 0., 97.7, 90., 7.7, 90.)
         CALL GSPOS('ANT1',1,'ANTF',  0.0,  0.9,  13.1 ,  0, 'ONLY')
         CALL GSPOS('ANT2',1,'ANTF',  0.0, -5.0,  -0.1 , 251, 'ONLY')
         CALL GSPOS('ANTF',1,'HESS',  0.0, 31.0, 155.0 ,  0, 'MANY')
         CALL GSPOS('ANTF',2,'HESS',-31.0,  0.0, 155.0 , 216, 'MANY')
         CALL GSPOS('ANTF',3,'HESS', 31.0,  0.0, 155.0 , 218, 'MANY')



****** Create and place other parts****

* Grids
         CALL grids


* Struts  (Imager to Spacecraft struts, primary struts, sec. str., 
*          solar array suppport struts and ring)
         CALL struts


* Spectrometer

         CALL spectrometer
         
******Close geometry banks. (compulsory system routine)***********
      
*      CALL GPVOLU(-1)  ! Print Volumes
*      CALL GPROTM(0)   ! Print Rot. Mat.
      CALL GGCLOS

      RETURN
      END  ! UGEOM



************************************************************************

      subroutine grids
            
      DIMENSION P_GTC(3), P_GRTR(3),P_GRTW(3),P_GRTT(3),P_GRTB(3),
     +          P_GTH1(3),P_GTHW(3),P_GTH3(3),P_GTSW(3),P_GTH5(3),
     +          P_GTMW(3),P_GTCR(9)
      DIMENSION P_GRH1(3),P_GRH2(3),P_GRH3(3),P_GRH4(3),
     +          P_GRH5(3),P_GRH6(3),P_GRH7(3),P_GRH8(3),P_GRH9(3),
     +          P_GRV1(3),P_GRV2(3),P_GRV3(3),P_GRV4(3),
     +          P_GRV5(3),P_GRV6(3),P_GRV7(3),P_GRV8(3),P_GRV9(3),
     +          P_GRI1(3),P_GRI2(3),P_GRI3(3),P_GRI4(3),
     +          P_GRI5(3),P_GRI6(3),P_GRI7(3),P_GRI8(3),P_GRI9(3)
      DIMENSION P_TRMT(3),P_TRM1(3),P_TRM2(3),P_TRM3(3),P_TRM4(3)
      DIMENSION P_SCAC(3),P_SCAP(3),P_SCAB(3),P_SCAH(3),P_SCAM(3)
      DIMENSION SAS_holes_x(3),SAS_holes_y(3),
     +          small_holes_x(3),small_holes_y(3)
      DIMENSION centx(9),centy(9),gridz(9),gridzOld(9)
      
      common/centers/centx,centy
      
      INTEGER gridrot(9)
      CHARACTER*4 grnumb(9)

* Some variables for cPbLs grid slats read-in:
      character*20 vName,mName,vType
      integer incNum,medium,npar,rotNum
      real innerD,outerD,thickness,px,py,pz,paramArray(3)
      
* 16 Mar 2001: grnumb elements changed from GRHn to GRVn:
      DATA grnumb/'GRV1','GRV2','GRV3','GRV4','GRV5',
     +            'GRV6','GRV7','GRV8','GRV9'/
      DATA gridrot/0,0,0,0,222,222,222,0,0/

c What were the following for? No docs. What is the +3. 
c added in the grid positioning?
      DATA gridzOld/1.966,1.966,1.93,2.06,2.5,2.5,2.5,2.5,2.5/
c 14 May 01: cPbL: Following are simply reproduced from the data 
c statements below (f77!) and are useful for aligning the grids so 
c that their front surfaces are coplanar, which is what they should 
c be, we are told.
      data gridz/0.0638,0.1022,0.1771,0.3068,0.535,0.928,
     .     0.3095,0.3090,1.5/

c cPbL:: 3rd parameters below are HALF-heights (z)
c 19 March 2001: Heights updated.
c GRI`s match the grid slat heights exactly.  [no; see below]
c GRH`s can be longer or shorter than the slats.
c 30 Nov 03 (DMS): GRI(3) must be max(slat height, holder
c                  height) for the square grids.  For
c                  the round grids it just has to be
c                  >= the slat height.

        DATA P_GRI1/0. , 4.4 , 0.0638/ !0.215/
        DATA P_GRI2/0. , 4.4 , 0.1022/ !0.215/
        DATA P_GRI3/0. , 4.5 , 0.1771/ ! 0.18/
        DATA P_GRI4/0. , 4.5 ,  0.3068/ !0.31/
        DATA P_GRH1/4.4, 5.5 , 0.215/
        DATA P_GRH2/4.4, 5.5 , 0.215/
        DATA P_GRH3/4.5, 5.5 ,  0.18/
        DATA P_GRH4/4.5, 5.5 ,  0.31/
        DATA P_GRV1/0. , 5.5 , 0.215/
        DATA P_GRV2/0. , 5.5 , 0.215/
        DATA P_GRV3/0. , 5.5 ,  0.18/
        DATA P_GRV4/0. , 5.5 ,  0.31/

        DATA P_GRI5/4. ,   4.  ,  0.535/
        DATA P_GRI6/4. ,   4.  ,  0.928/
        DATA P_GRI7/4. ,   4.  ,  0.5/
        DATA P_GRI8/4. ,   4.  ,  0.5/
        DATA P_GRI9/4. ,   4.  ,  1.5/

        DATA P_GRH5/5. ,   5.   , 0.5/
        DATA P_GRH6/5. ,   5.   , 0.5/
        DATA P_GRH7/5. ,   5.   , 0.5/
        DATA P_GRH8/5. ,   5.   , 0.5/
        DATA P_GRH9/5. ,   5.   , 0.5/
        DATA P_GRV5/5.   , 5.   , 0.55/
        DATA P_GRV6/5.   , 5.   , 0.93/
        DATA P_GRV7/5.   , 5.   , 0.5/
        DATA P_GRV8/5.   , 5.   , 0.5/
        DATA P_GRV9/5.   , 5.   , 1.5/

* Def Vol

****** Grid-Tray Container
        DATA P_GTC/0., 25., 8.5/
C        DATA P_GTCR/0., 360., 2., 8.5, 0., 25., -5.2, 0., 25./
        DATA P_GTCR/0., 360., 2., -5.2, 0., 25., 8.5, 0., 25./
        CALL GSVOLU('GTCF','TUBE',1,P_GTC,3,IVOL) ! front
        CALL GSVOLU('GTCR','PCON',1,P_GTCR,9,IVOL) ! rear
C        CALL GSVOLU('GTCR','TUBE',1,P_GTC,3,IVOL) ! FAKE REAR!!!
        
****** Grid-Tray
        DATA P_GRTR/0.,  22.6, 1.8/
        CALL GSVOLU('GRTR', 'TUBE', 1, P_GRTR, 3, IVOL) ! Grid-Tray
        DATA P_GRTW/21.6,22.0, 1.375/
        CALL GSVOLU('GRTW', 'TUBE', 6, P_GRTW, 3, IVOL) ! Wall
        DATA P_GRTT/0., 22.5, 0.3/
        CALL GSVOLU('GRTT', 'TUBE', 6, P_GRTT, 3, IVOL) ! Top
        DATA P_GRTB/0., 22.0,  0.075/
        CALL GSVOLU('GRTB', 'TUBE', 6, P_GRTB, 3, IVOL) ! Bottom
        DATA P_GTH1/0.,  4.5, 1.75/
        CALL GSVOLU('GTH1', 'TUBE', 1, P_GTH1, 3, IVOL) ! grid-holes(9)
        DATA P_GTHW/4.5, 4.7, 1.75/
        CALL GSVOLU('GTHW', 'TUBE', 6, P_GTHW, 3, IVOL) ! grid-holes-wall(9)
        DATA P_GTH3/0.,  2.4, 1.75/
        CALL GSVOLU('GTH3', 'TUBE', 1, P_GTH3, 3, IVOL) ! SAS-holes(3)
        DATA P_GTSW/2.4, 2.6, 1.75/
        CALL GSVOLU('GTSW', 'TUBE', 6, P_GTSW, 3, IVOL) ! SAS-holes-wall(3)
        DATA P_GTH5/0.,  1.5, 1.75/
        CALL GSVOLU('GTH5', 'TUBE', 1, P_GTH5, 3, IVOL) ! small-holes(3)
        DATA P_GTMW/1.5, 1.7, 1.75/
        CALL GSVOLU('GTMW', 'TUBE', 6, P_GTMW, 3, IVOL) ! small-holes-wall(3)

****** Grid-Holder round
        CALL GSVOLU('GRH1', 'TUBE', 4, P_GRH1, 3, IVOL)
        CALL GSVOLU('GRH2', 'TUBE', 4, P_GRH2, 3, IVOL)
        CALL GSVOLU('GRH3', 'TUBE', 4, P_GRH3, 3, IVOL)
        CALL GSVOLU('GRH4', 'TUBE', 4, P_GRH4, 3, IVOL)

        CALL GSVOLU('GRV1', 'TUBE', 1, P_GRV1, 3, IVOL)
        CALL GSVOLU('GRV2', 'TUBE', 1, P_GRV2, 3, IVOL)
        CALL GSVOLU('GRV3', 'TUBE', 1, P_GRV3, 3, IVOL)
        CALL GSVOLU('GRV4', 'TUBE', 1, P_GRV4, 3, IVOL)
        
****** Grid-Holder square
* Outer edge
        CALL GSVOLU('GRH5', 'BOX ', 6, P_GRH5, 3, IVOL) !approx
        CALL GSVOLU('GRH6', 'BOX ', 6, P_GRH6, 3, IVOL) !approx
        CALL GSVOLU('GRH7', 'BOX ', 6, P_GRH7, 3, IVOL) !approx
        CALL GSVOLU('GRH8', 'BOX ', 6, P_GRH8, 3, IVOL) !approx
        CALL GSVOLU('GRH9', 'BOX ', 6, P_GRH9, 3, IVOL) !approx

* Null package
        CALL GSVOLU('GRV5', 'BOX ', 1, P_GRV5, 3, IVOL) !approx
        CALL GSVOLU('GRV6', 'BOX ', 1, P_GRV6, 3, IVOL) !approx
        CALL GSVOLU('GRV7', 'BOX ', 1, P_GRV7, 3, IVOL) !approx
        CALL GSVOLU('GRV8', 'BOX ', 1, P_GRV8, 3, IVOL) !approx
        CALL GSVOLU('GRV9', 'BOX ', 1, P_GRV9, 3, IVOL) !approx

****** Grid number 1
        CALL GSVOLU('GRI1', 'TUBE', 1, P_GRI1, 3, IVOL)

****** Grid number 2
        CALL GSVOLU('GRI2', 'TUBE', 1, P_GRI2, 3, IVOL)

****** Grid number 3
        CALL GSVOLU('GRI3', 'TUBE', 1, P_GRI3, 3, IVOL)

****** Grid number 4
        CALL GSVOLU('GRI4', 'TUBE', 1, P_GRI4, 3, IVOL)

****** Grid number 5
        CALL GSVOLU('GRI5', 'BOX ', 1, P_GRI5, 3, IVOL) !approx

****** Grid number 6
        CALL GSVOLU('GRI6', 'BOX ', 1, P_GRI6, 3, IVOL) !approx

****** Grid number 7
        CALL GSVOLU('GRI7', 'BOX ', 1, P_GRI7, 3, IVOL) !approx

****** Grid number 8
        CALL GSVOLU('GRI8', 'BOX ', 1, P_GRI8, 3, IVOL) !approx

****** Grid number 9
        CALL GSVOLU('GRI9', 'BOX ', 1, P_GRI9, 3, IVOL) !approx

***** cPbL: Feb 5 2001: Load in the slats from a text file, 
***** created (at run time) by plotGrids.m
c
        open(34,file='gridslats.txt',status='old')
        read(34,*)              ! Skip the comment line
 138    continue
        read(34,*,end=137) vName
c        write(*,*)vName
        if (vName .EQ. 'V') then
         read(34,*)vName, vType,medium,innerD,outerD,thickness,npar
c     write(*,'(a5,$)')vName  !,vType,medium,innerD,outerD,thickness,npar
           paramArray(1)=innerD
           paramArray(2)=outerD
           paramArray(3)=thickness
           CALL GSVOLU(vName,vType,medium,paramArray,npar,IVOL)
        else                    ! vName eq 'P'
           read(34,*) vName,incNum,mName,px,py,pz,rotNum
c         write(*,'(a5,$)') vName !,$ !incNum,mName,px,py,pz,rotNum
c
c must use MANY here (at least for square grids) because square grids 
c have the vacuum to carve out the holder.
c 30 Nov 03: No, CPBL misunderstood many/only.  Slats are the only
c   daughters of GRI, so they can be ONLY:
c
           CALL GSPOS(vName,incNum,mName,px,py,pz,rotNum,'ONLY')
        endif
        goto 138
 137    close(34)

****** Tray mount  ! (mass: here:  real: kg)
        DATA P_TRMT/5.1, 0.9, 3.5/
        CALL GSVOLU('TRMT', 'BOX ', 1, P_TRMT, 3, IVOL)
        DATA P_TRM1/5.0, 0.85, 0.25/
        CALL GSVOLU('TRM1', 'BOX ', 4, P_TRM1, 3, IVOL)
        DATA P_TRM2/1.5, 0.75, 0.4/
        CALL GSVOLU('TRM2', 'BOX ', 4, P_TRM2, 3, IVOL)
        DATA P_TRM3/0.6, 0.2, 2.2/
        CALL GSVOLU('TRM3', 'BOX ', 4, P_TRM3, 3, IVOL)
        DATA P_TRM4/1.2, 0.2, 0.475/
        CALL GSVOLU('TRM4', 'BOX ', 4, P_TRM4, 3, IVOL)

****** Scaffolding
        DATA P_SCAC/0., 23.8, 6./
        CALL GSVOLU('SCAC', 'TUBE', 1, P_SCAC, 3, IVOL) ! Scaffolding-Container
        DATA P_SCAP/0., 23.2, 0.1/
        CALL GSVOLU('SCAP', 'TUBE',12, P_SCAP, 3, IVOL) ! Plate
        DATA P_SCAB/23.2, 23.3, 0.5/
        CALL GSVOLU('SCAB', 'TUBE',12, P_SCAB, 3, IVOL) ! Border
        DATA P_SCAH/0., 4.7, 0.1/
        CALL GSVOLU('SCAH', 'TUBE', 1, P_SCAH, 3, IVOL) ! Holes
        DATA P_SCAM/1.5, 0.1, 5.2/
        CALL GSVOLU('SCAM', 'BOX ',12, P_SCAM, 3, IVOL) ! Mounts


* Pos Grid Tray Containers
        CALL GSPOS('GTCF',1,'HESS', 0.0 , 0.0, 153.25 ,  0, 'MANY')
        CALL GSPOS('GTCR',1,'HESS', 0.0 , 0.0,   -2.1 ,  0, 'MANY')


* Pos Grid Tray Elements
        CALL GSPOS('GRTW',1,'GRTR', 0.0 , 0.0, -0.225,  0, 'ONLY')
        CALL GSPOS('GRTT',1,'GRTR', 0.0 , 0.0,  1.45 ,  0, 'MANY')
        CALL GSPOS('GRTB',1,'GRTR', 0.0 , 0.0, -1.675,  0, 'MANY')
        do i=1,9
          call gspos('GTH1',i,'GRTR',centx(i),centy(i),0.,0,'ONLY')
          call gspos('GTHW',i,'GRTR',centx(i),centy(i),0.,0,'ONLY')
        end do
        DATA SAS_holes_x/     0.0, -15.76, 15.76/
        DATA SAS_holes_y/    18.2,  -9.1,  -9.1/
        DATA small_holes_x/ -17.2,  17.2,   0.0/
        DATA small_holes_y/  -3.2,  -3.2,  -6.4/
        do i=1,3
          call gspos('GTH3',i,'GRTR',SAS_holes_x(i),SAS_holes_y(i),
     +          0.,0,'ONLY')
          call gspos('GTSW',i,'GRTR',SAS_holes_x(i),SAS_holes_y(i),
     +          0.,0,'ONLY')      
          call gspos('GTH5',i,'GRTR',small_holes_x(i),small_holes_y(i),
     +          0.,0,'ONLY')
          call gspos('GTMW',i,'GRTR',small_holes_x(i),small_holes_y(i),
     +          0.,0,'ONLY')
        end do

* Pos Grid Trays
* 18 Apr 2001: I found this as 'ONLY' !!  (May: I`m not sure what the conflict was: what else overlaps GRTR?) -> Changed it back to ONLYs.
        CALL GSPOS('GRTR',1,'GTCF', 0.0 , 0.0, 0.0, 0, 'ONLY')
        CALL GSPOS('GRTR',2,'GTCR', 0.0 , 0.0, 0.0, 0, 'ONLY')

* 16 Mar 2001: cPbL: I`m
*  reorganizing structure from GTCR->GRHn->GRVn->GRIn to
*  GTCR->GRVn->GRIn and GRVn->GRHn->GRJn since GRIn daughters can extend
*  outside GRHn.
* 30 Nov 2003: This made a lot of problems; vacuum and grids were both
*   "many" and sometimes one went transparent.  Removed "GRJ*" and 
*   returned the GRI* to its *dual* function of carving out the 
*   center of the square grid mounts and containing the grids. -DMS
* Pos Grid Elements    

* 18 Apr 2001: I found all GRH/GRIs  as 'ONLY'. All changed to MANY
* 30 Nov 2003(DMS): that was part of the problem.....
        CALL GSPOS('GRH1',1,'GRV1', 0.,0.,0.,0,'MANY')
        CALL GSPOS('GRI1',1,'GRV1', 0.,0.,0.,0,'ONLY')
        
        CALL GSPOS('GRH2',1,'GRV2', 0.,0.,0.,0,'MANY')
        CALL GSPOS('GRI2',1,'GRV2', 0.,0.,0.,0,'ONLY')

        CALL GSPOS('GRH3',1,'GRV3', 0.,0.,0.,0,'MANY')
        CALL GSPOS('GRI3',1,'GRV3', 0.,0.,0.,0,'ONLY')
        
        CALL GSPOS('GRH4',1,'GRV4', 0.,0.,0.,0,'MANY')
        CALL GSPOS('GRI4',1,'GRV4', 0.,0.,0.,0,'ONLY')
        
        CALL GSPOS('GRH5',1,'GRV5', 0.,0.,0.,0,'MANY')
        CALL GSPOS('GRI5',1,'GRV5', 0.,0.,0.,0,'ONLY')
        
        CALL GSPOS('GRH6',1,'GRV6', 0.,0.,0.,0,'MANY')
        CALL GSPOS('GRI6',1,'GRV6', 0.,0.,0.,0,'ONLY')
        
        CALL GSPOS('GRH7',1,'GRV7', 0.,0.,0.,0,'MANY')
        CALL GSPOS('GRI7',1,'GRV7', 0.,0.,0.,0,'ONLY')
        
        CALL GSPOS('GRH8',1,'GRV8', 0.,0.,0.,0,'MANY')
        CALL GSPOS('GRI8',1,'GRV8', 0.,0.,0.,0,'ONLY')
        
        CALL GSPOS('GRH9',1,'GRV9', 0.,0.,0.,0,'MANY')
        CALL GSPOS('GRI9',1,'GRV9', 0.,0.,0.,0,'ONLY')
        
* Pos Front Grids
      do i=1,9
        call gspos(grnumb(i),1,'GTCF',centx(i),centy(i),
     .        7.8426-gridz(i),
c     .        gridzOld(i)+3., 
     +             gridrot(i),'ONLY')
      end do

* Pos Rear Grids
      do i=1,9
        call gspos(grnumb(i),2,'GTCR',centx(i),centy(i),
     .        7.8426-gridz(i),
c     .        gridzOld(i)+3.,
     +             gridrot(i),'ONLY')
      end do

* Pos Tray Mounts
        CALL GSPOS('TRM1',1,'TRMT', 0.0,  0.0,-3.225, 0,'ONLY')
        CALL GSPOS('TRM2',1,'TRMT', 0.0, -0.1, 2.125, 0,'ONLY')
        CALL GSPOS('TRM3',1,'TRMT',-1.8,-0.65,-0.575,230,'ONLY')
        CALL GSPOS('TRM3',2,'TRMT', 1.8,-0.65,-0.575,231,'ONLY')
        CALL GSPOS('TRM4',1,'TRMT', 0.0,-0.65, 3.0   ,0,'ONLY')
        
        CALL GSPOS('TRMT',1,'GTCF',  0.0,-23.0, -1.55,  0,'MANY')
        CALL GSPOS('TRMT',2,'GTCF', 19.9, 11.5 ,-1.55, 220,'MANY')
        CALL GSPOS('TRMT',3,'GTCF',-19.9, 11.5 ,-1.55, 221,'MANY')
        CALL GSPOS('TRMT',4,'GTCR',  0.0,-22.5,  4.5,  232,'MANY')
        CALL GSPOS('TRMT',5,'GTCR', 19.4, 11.25, 4.5,  233,'MANY')
        CALL GSPOS('TRMT',6,'GTCR',-19.4, 11.25, 4.5,  234,'MANY')
        
* Pos Scaffolding Elements
        CALL GSROTM(252, 90., 36., 90., 126., 0.,  0.)
        CALL GSROTM(253, 90.,144., 90., 234., 0.,  0.)
        CALL GSROTM(254, 90.,216., 90., 306., 0.,  0.)
        CALL GSROTM(255, 90.,324., 90.,  54., 0.,  0.)
        CALL GSPOS('SCAP',1,'SCAC', 0.0 , 0.0 , 5.8 , 0, 'ONLY')
        do i=1,9
          call gspos('SCAH',i,'SCAP',centx(i),centy(i),0.,0,'ONLY')
        end do
        CALL GSPOS('SCAB',1,'SCAC',   0.0,   0.0,  5.1,  0, 'ONLY')
        CALL GSPOS('SCAM',1,'SCAC', -13.7,  18.9, -0.7, 252, 'ONLY')
        CALL GSPOS('SCAM',2,'SCAC', -13.7, -18.9, -0.7, 253, 'ONLY')
        CALL GSPOS('SCAM',3,'SCAC',  13.7, -18.9, -0.7, 254, 'ONLY')
        CALL GSPOS('SCAM',4,'SCAC',  13.7,  18.9, -0.7, 255, 'ONLY')

* Pos Scaffoldings
        CALL GSPOS('SCAC',1,'GTCF', 0.0 , 0.0, 2.0,  0, 'MANY')
        CALL GSPOS('SCAC',2,'GTCR', 0.0 , 0.0, 1.0, 232, 'MANY') 
        
      end ! grids



************************************************************************

      subroutine struts
      
      DIMENSION P_STRC(3),P_STRT(3),P_STTU(3),P_STRI(3),
     +          P_STE1(18),P_STE2(18),P_STRM(4),
     +          P_PSTC(3),P_PST1(3),P_PST2(3),
     +          P_SSTC(3),P_SST1(3),P_SST2(3),
     +          P_SARC(3),P_SAR1(3),P_SAR2(3),P_SAR3(3),
     +          P_SAR4(3),P_SAR5(3),P_SAR6(3),
     +          P_SS1A(3),P_SS2A(3),P_SS1B(3),P_SS2B(3)
     

* Def Struts Space Craft to Imager
        DATA P_STRC/25., 31., 10.5/     ! Struts-Container
        CALL GSVOLU('STRC', 'TUBE', 1, P_STRC, 3, IVOL)
        DATA P_STRT/0. , 1.62 , 11.8/     ! Strut
        CALL GSVOLU('STRT', 'TUBE', 1, P_STRT, 3, IVOL)
        DATA P_STTU/0. , 1.61 , 6.65/     ! Strut-Tube Vespel?
        CALL GSVOLU('STTU', 'TUBE', 12, P_STTU, 3, IVOL)
        DATA P_STRI/0.3, 1.25, 0.8/       ! Strut-Ring   Ti ?
        CALL GSVOLU('STRI', 'TUBE', 4, P_STRI, 3, IVOL)
        DATA P_STE1/0., 360., 5.,         ! Strut-End 1  Ti ?
     +        -2.8, 1.1, 1.15,
     +         0.7, 0.8, 1.2, 
     +         1.0, 0.0, 1.5,
     +         2.8, 0.0, 0.7, 
     +         3.2, 0.0, 0.7/
        CALL GSVOLU('STE1', 'PCON', 4, P_STE1, 18, IVOL)
        DATA P_STE2/0., 360., 5.,         ! Strut-End 2  Ti ?
     +        -3.2, 0.0, 0.7,
     +        -2.8, 0.0, 0.7,
     +        -1.0, 0.0, 1.5,
     +        -0.7, 0.8, 1.2, 
     +         2.8, 1.1, 1.15/
        CALL GSVOLU('STE2', 'PCON', 4, P_STE2, 18, IVOL)
        DATA P_STRM/4.0, 0.0, 1.12, 1.8/   ! Strut-Mount
        CALL GSVOLU('STRM', 'TRD1', 4, P_STRM, 4, IVOL)  !  Ti ?

* Def Primary Struts  (mass: here: 5.3 kg, real: 5.3 kg)
        DATA P_PSTC/22.5, 0.5, 26.5/
        CALL GSVOLU('PSTC', 'BOX ', 1, P_PSTC, 3, IVOL)
        DATA P_PST1/1.5, 0.43, 27./
        CALL GSVOLU('PST1', 'BOX ', 6, P_PST1, 3, IVOL)
        DATA P_PST2/10., 0.43, 1.5/
        CALL GSVOLU('PST2', 'BOX ', 6, P_PST2, 3, IVOL)

* Def Secondary Struts  (mass: here: 4.8 kg, real: 4.8 kg)

* Revised to a "cross" shape with right cross section
         DATA P_SSTC/22., 1.6, 36.0/
         CALL GSVOLU('SSTC', 'BOX ', 1, P_SSTC, 3, IVOL)

         DATA P_SST1/1.59, 1.59, 34.0/
         CALL GSVOLU('SST1', 'BOX ', 6, P_SST1, 3, IVOL)
         DATA P_SST2/1.59, 1.59, 38.0/
         CALL GSVOLU('SST2', 'BOX ', 6, P_SST2, 3, IVOL)

         DATA P_SS1A/0.0762, 1.5876, 34.0/
         CALL GSVOLU('SS1A', 'BOX ', 6, P_SS1A, 3, IVOL)

         DATA P_SS2A/0.0762, 1.5875, 38.0/
         CALL GSVOLU('SS2A', 'BOX ', 6, P_SS2A, 3, IVOL)

         DATA P_SS1B/1.4351, 0.0762, 34.0/
         CALL GSVOLU('SS1B', 'BOX ', 6, P_SS1B, 3, IVOL)

         DATA P_SS2B/1.4351, 0.0762, 38.0/
         CALL GSVOLU('SS2B', 'BOX ', 6, P_SS2B, 3, IVOL)


* Def Solar Array Support Ring and Struts (mass: here: 4.2 kg, real: 4.3 kg)
        DATA P_SARC/33.,20.,45./
        CALL GSVOLU('SARC', 'BOX ', 1, P_SARC, 3, IVOL)
        DATA P_SAR1/20.5,1.27,1.27/
        CALL GSVOLU('SAR1', 'BOX ', 6, P_SAR1, 3, IVOL)
        DATA P_SAR2/20.5,1.07,1.07/
        CALL GSVOLU('SAR2', 'BOX ', 1, P_SAR2, 3, IVOL) ! 207g
        DATA P_SAR3/7.0,1.27,1.27/
        CALL GSVOLU('SAR3', 'BOX ', 6, P_SAR3, 3, IVOL)
        DATA P_SAR4/7.0,0.97,0.97/
        CALL GSVOLU('SAR4', 'BOX ', 1, P_SAR4, 3, IVOL) ! 102g
        DATA P_SAR5/7.,0.3,1.5/
        CALL GSVOLU('SAR5', 'BOX ', 6, P_SAR5, 3, IVOL) ! 68g
        DATA P_SAR6/1.43,1.5875,41.5/
        CALL GSVOLU('SAR6', 'TUBE', 6, P_SAR6, 3, IVOL) ! 335g

********

* Pos elements of SC/I strut        
        CALL GSPOS('STTU',1,'STRT', 0.,0.,  0.,    0,'ONLY')
        CALL GSPOS('STE1',1,'STRT', 0.,0.,  5.95,  0,'ONLY')
        CALL GSPOS('STE2',1,'STRT', 0.,0., -5.95,  0,'ONLY')
        CALL GSPOS('STRI',1,'STRT', 0.,0., 10.5,  224,'ONLY')
        CALL GSPOS('STRI',2,'STRT', 0.,0.,-10.5,  224,'ONLY')
        
* Pos SC/I struts in container
        CALL GSROTM(225, 90.,  0., 60., 90., 30.,270.)
        CALL GSROTM(226, 90.,120., 60.,210., 30., 30.)
        CALL GSROTM(227, 90.,240., 60.,330., 30.,150.)
        CALL GSPOS('STRT',1,'STRC', -26.6,  6.6, 0., 225,'ONLY')
        CALL GSPOS('STRT',2,'STRC',  26.6,  6.6, 0., 225,'ONLY')
        CALL GSPOS('STRT',3,'STRC',   7.8,-26.2, 0., 226,'ONLY')
        CALL GSPOS('STRT',4,'STRC', -19.0, 20.0, 0., 226,'ONLY')
        CALL GSPOS('STRT',5,'STRC',  -7.8,-26.2, 0., 227,'ONLY')
        CALL GSPOS('STRT',6,'STRC',  19.0, 20.0, 0., 227,'ONLY')

* Pos SC/I mounts in container
        CALL GSPOS('STRM',1,'STRC',  0.0,-27.9,-9.0, 219,'ONLY')
        CALL GSPOS('STRM',2,'STRC', 23.9, 14.1,-9.0, 228,'ONLY')
        CALL GSPOS('STRM',3,'STRC',-23.9, 14.1,-9.0, 229,'ONLY')
        
* Pos SC/I container in HESS
        CALL GSPOS('STRC',1,'HESS', 0., 0., 69.1, 0,'MANY')

* Pos Primary Struts
        CALL GSROTM(235, 109.1, 0., 90., 90., 19.1,   0.)
        CALL GSROTM(236,  70.9, 0., 90., 90., 19.1, 180.)
        CALL GSPOS('PST1',1,'PSTC', -10.625, 0.,  0.,   235,'ONLY')
        CALL GSPOS('PST1',2,'PSTC',  10.625, 0.,  0.,   236,'ONLY')
        CALL GSPOS('PST2',1,'PSTC',   0.0  , 0., -6.6 ,  0,'ONLY')
        
        CALL GSROTM(237, 90.,   0., 70., 90., 20., 270.)
        CALL GSROTM(238, 90.,  60., 70.,150., 20., 330.)
        CALL GSROTM(239, 90., 120., 70.,210., 20.,  30.)
        CALL GSROTM(240, 90., 180., 70.,270., 20.,  90.)
        CALL GSROTM(241, 90., 240., 70.,330., 20., 150.)
        CALL GSROTM(242, 90., 300., 70., 30., 20., 210.)
        CALL GSPOS('PSTC',1,'HESS',  0., 38., -7.5, 237,'MANY')
        CALL GSPOS('PSTC',2,'HESS',-33., 19., -7.5, 238,'MANY')
        CALL GSPOS('PSTC',3,'HESS',-33.,-20., -7.5, 239,'MANY')
        CALL GSPOS('PSTC',4,'HESS',  0.,-38., -7.5, 240,'MANY')
        CALL GSPOS('PSTC',5,'HESS', 33.,-19., -7.5, 241,'MANY')
        CALL GSPOS('PSTC',6,'HESS', 33., 19., -7.5, 242,'MANY')

* Pos Secondary Struts
        CALL GSROTM(243,  85.4, 0., 90., 90.,  4.6, 180.)
        CALL GSROTM(244,  94.6, 0., 90., 90.,  4.6,   0.)
        CALL GSROTM(245, 112.8, 0., 90., 90., 22.8,   0.)
        CALL GSROTM(246,  67.2, 0., 90., 90., 22.8, 180.)


        call gspos('SS1A',1,'SSTC', 1.5113-16.6-3.*.0802, 
     .               0.,-4.+3.*.996779, 243, 'ONLY')
        call gspos('SS1A',2,'SSTC', -1.5113-16.6-3.*.0802, 
     .               0.,-4.+3.*.996779, 243, 'ONLY')
        call gspos('SS1B',1,'SSTC', -16.6-3.*.0802, 
     .               0.,-4.+3.*.996779, 243, 'ONLY')

        call gspos('SS1A',3,'SSTC', 1.5113+16.6+3.*.0802, 
     .               0.,-4.+3.*.996779, 244, 'ONLY')
        call gspos('SS1A',4,'SSTC', -1.5113+16.6+3.*.0802, 
     .               0.,-4.+3.*.996779, 244, 'ONLY')
        call gspos('SS1B',2,'SSTC', 16.6+3.*.0802, 
     .               0.,-4.+3.*.996779, 244, 'ONLY')

c 1.39321 = (1.4351+.0762)*cos(22.8)
c 0.58565 = (1.4351+.0762)*sin(22.8)
c Note: we set out to lengthen SS2 by 2x2.5cm and slip it downwards
c by 2.5 cm to compensate, but it was a little too high already in
c the original version, so we are using 2.75cm to slip it down instead:

        call gspos('SS2A',1,'SSTC', 1.39321+4.1-2.75*.387516, 
     .               0.,2.8-2.75*.921863-.58565, 245, 'ONLY')
        call gspos('SS2A',2,'SSTC', -1.39321+4.1-2.75*.387516, 
     .               0.,2.8-2.75*.921863+.58565, 245, 'ONLY')
        call gspos('SS2B',1,'SSTC', 4.1-2.75*.387516, 
     .               0.,2.8-2.75*.921863, 245, 'ONLY')

        call gspos('SS2A',3,'SSTC', 1.39321-4.1+2.75*.387516, 
     .               0.,2.8-2.75*.921863+.58565, 246, 'ONLY')
        call gspos('SS2A',4,'SSTC', -1.39321-4.1+2.75*.387516, 
     .               0.,2.8-2.75*.921863-.58565, 246, 'ONLY')
        call gspos('SS2B',2,'SSTC', -4.1+2.75*.387516, 
     .               0.,2.8-2.75*.921863, 246, 'ONLY')

        
        CALL GSROTM(247, 90.,   0., 92., 90., 2.,  90.)
        CALL GSROTM(248, 90.,  90., 92.,180., 2., 180.)
        CALL GSROTM(249, 90., 180., 92.,270., 2., 270.)
        CALL GSROTM(250, 90., 270., 92.,  0., 2.,   0.)
        CALL GSPOS('SSTC',1,'HESS',  0., 48., 3.5, 247,'MANY')
        CALL GSPOS('SSTC',2,'HESS',-48.,  0., 3.5, 248,'MANY')
        CALL GSPOS('SSTC',3,'HESS',  0.,-48., 3.5, 249,'MANY')
        CALL GSPOS('SSTC',4,'HESS', 48.,  0., 3.5, 250,'MANY')


* Pos Solar Array Ring and Struts
        CALL GSROTM(261, 90.,345., 78., 75., 12., 255.)
        CALL GSROTM(262, 90., 15., 78.,105., 12., 285.)
        CALL GSPOS('SAR1',1,'SARC',   0., -5.5,  40.,  0,'ONLY')
        CALL GSPOS('SAR2',1,'SAR1',   0.,  0.,    0.,  0,'ONLY')
        CALL GSPOS('SAR3',1,'SARC', -27.,-10.0,  40., 222,'ONLY')
        CALL GSPOS('SAR4',1,'SAR3',   0.,  0.,    0.,  0,'ONLY')
        CALL GSPOS('SAR5',1,'SARC',   0., -5.5,  43.,  0,'ONLY')
        CALL GSPOS('SAR6',1,'SARC', -22.5, 2.0,  -3.0,261,'ONLY')
        CALL GSPOS('SAR6',2,'SARC',  22.5, 2.0,  -3.0,262,'ONLY')
        CALL GSPOS('SARC',1,'HESS',   0., 37.0,  88.,  0,'MANY')
        CALL GSPOS('SARC',2,'HESS', -37.0, 0.,   88., 216,'MANY')
        CALL GSPOS('SARC',3,'HESS',   0.,-37.,   88., 217,'MANY')
        CALL GSPOS('SARC',4,'HESS',  37.,  0.,   88., 218,'MANY')
        
      end ! struts

C---------------------------------------------------------------

      subroutine sp_battery_assembly
   
      dimension par_sbat(3),PAR_sba2(3)
      data par_sbat/11.56,13.34,16.8/
      data par_sba2/11.241879, 13.022177, 16.482756/

      call gsvolu('SBAT','BOX ',6,par_sbat,3,ivolu)
      call gsvolu('SBA2','BOX ',1,par_sba2,3,ivolu)   

      call gspos('SBAT',1,'HESS',-30.71,-30.89,23.98,133,'ONLY')
      call gspos('SBA2',1,'SBAT',0.0,0.0,0.0,0,'ONLY')

      end
C-----------------------------------------------------------------

      subroutine sp_ssr_bracket

      dimension par_ssr1(3),par_ssr2(3)
      data par_ssr1/9.78,.13,13.34/
      data par_ssr2/9.78,5.72,.13/

      call gsvolu('SSR1','BOX ',6,par_SSR1,3,ivolu)
      call gsvolu('SSR2','BOX ',6,par_ssr2,3,ivolu)

      call gspos('SSR1',1,'HESS',-20.12,20.12,56.73,133,'ONLY')
      call gspos('SSR2',1,'HESS',-9.75,9.75,43.52,133,'ONLY')

      end

C------------------------------------------------------------------

      subroutine sp_solid_state_recorder

      dimension par_SSSR(3),PAR_SS2R(3)
      data par_sssr/9.75,7.0,13.25/
      DATA PAR_SS2R/8.954322, 6.343040, 12.277771/

      call gsvolu('SSSR','BOX ',6,par_SSSR,3,ivolu)
      call gsvolu('SS2R','BOX ',1,par_SS2R,3,ivolu)
                               

      call gspos('SSSR',1,'HESS',-32.94,33.20,56.64,133,'ONLY')
      call gspos('SS2R',1,'SSSR',0.0,0.0,0.0,0,'ONLY')

      end

C--------------------------------------------------------------

      subroutine  sp_spacecraft_electronics_module

      dimension par_SSEM(3),PAR_SSEN(3)
      data par_SSEM/14.6,9.9,9.7/
      data par_SSEN/14.402627, 9.662267, 9.460549/

      call gsvolu('SSEM','BOX ',6,par_SSEM,3,ivolu)
      call gsvolu('SSEN','BOX ',1,par_SSEN,3,ivolu)      

      call gspos('SSEM',1,'HESS',-27.84,28.27,31.11,133,'ONLY')
      call gspos('SSEN',1,'SSEM',0.0,0.0,0.0,0,'ONLY')

      end

c-----------------------------------------------------------------

      subroutine sp_instrument_data_processing_unit

      dimension par_SIDP(3),par_SIDQ(3)
      data par_SIDP/13.34,13.10,9.68/
      data par_SIDQ/13.011511, 12.771667, 9.353897/

      call gsvolu('SIDP','BOX ',6,par_SIDP,3,ivolu)
      call gsvolu('SIDQ','BOX ',1,PAR_SIDQ,3,ivolu)

      call gspos('SIDP',1,'HESS',28.02,28.4,31.13,133,'ONLY')
      call gspos('SIDQ',1,'SIDP',0.0,0.0,0.0,0,'ONLY')

      end

c-------------------------------------------------------------------

      subroutine sp_instrument_power_converter

      dimension par_SIPC(3),par_SIPD(3)
      data par_SIPC/5.72,13.34,6.67/
      data par_SIPD/5.430813, 13.094295, 6.386234/

      call gsvolu('SIPC','BOX ',6,par_SIPC,3,ivolu)
      call gsvolu('SIPD','BOX ',1,par_SIPD,3,ivolu)

      call gspos('SIPC',1,'HESS',26.09,26.09,50.06,133,'ONLY')
      call gspos('SIPD',1,'SIPC',0.0,0.0,0.0,0,'ONLY')

      end

c-----------------------------------------------------------------

* 22June2002 dms: bring in changes made to another version by CPBL:
*            --improved gra
* 21June2002 dms: correct cl00 from Al to vacuum
* 17June2001:cPbL: Eliminate Mylar blankets. Still need to change size of two graded Z rings!!!

c-------------------------------------------------------------------------
      SUBROUTINE SPECTROMETER
   
      dimension PAR_C000(21),par_wrld(3),centx(9),centy(9),PAR_CCMT(9)

      data PAR_C000/0.0,360.,6.,
     .             -15.6,0.,45.3,
     .              -.88,0.,45.3,
     .              -.87,0.,41.0,
     .              1.77,0.,41.0,
     .              1.78,0.,34.7,
     .              19.4,0.,34.7/


      data par_wrld/0.,300.,300./
      character*4 modnames(9)
      character*4 shutters_thick(9), shutters_thin(9)           
    
      DATA PAR_CCMT/0.0000,360.000,2.,
     +             -13.0175,0.0000,25.8064,
     +             13.6525,0.0000,25.8064/

c For the detector with centx=0, the mechanical drawing, which
c is sized as machined (instead of at 77K), has centy = 2.2548inch=5.7272 cm
c which is 1/2 mm off the number below.  Check both against PSI numbers,
C predictions for shrunken cold size.  Check for all dets against drawing.

      common/centers/centx,centy
      
      data modnames/'DMD1','DMD2','DMD3','DMD4','DMD5','DMD6','DMD7',
     +              'DMD8','DMD9'/
      data shutters_thick/'CST1','CST2','CST3','CST4','CST5','CST6',
     +              'CST7','CST8','CST9'/
      data shutters_thin/'CSN1','CSN2','CSN3','CSN4','CSN5','CSN6',
     +              'CSN7','CSN8','CSN9'/

      call gsvolu('C000','PCON',1,PAR_C000,21,ivol)
      CALL GSPOS ('C000',1,'HESS',0.0,0.0,-27.1175,0,'ONLY') 
c create mother for the cryostat unit
      call gsvolu('CCMT','PCON',1,PAR_CCMT,9,IVOL)
      CALL GSPOS('CCMT',1,'C000',0.,0.,0.,0,'ONLY')

      CALL coldplate
      call legs      
      call BESCATT
      call MOUNT
      call N2TANK
      CALL POS_N2TANK
      CALL CRYOSORB
      CALL RING

c These involve the top section of the cryostat:
      CALL BEAMS
      call scatthole
      CALL OUTSID       
      CALL CYLNDR
      CALL POSCYL
      CALL SHELL
      CALL GRADEDZ
      CALL POS_TOPPLATE

      CALL HOUSE
      CALL COOLER
      CALL COOLER_LEGS
      CALL N2_TUBES
      CALL N2_PORT
      CALL INNER_SHIELD

      CALL OUTER_SHIELD
      CALL SLINK
      CALL LEGS_OUTER
      CALL PREAMP

      call SHUTTER_FRAME
      do i=1,9
        call SHUTTER_THICK(shutters_thick(i),i)
        call gspos(shutters_thick(i),1,'C001',centx(i),centy(i),
     .             0.0,0,'MANY')       
      end do
      do i=1,9
        call SHUTTER_THIN(shutters_thin(i),i)
        call gspos(shutters_thin(i),1,'C002',centx(i),centy(i),
     .             0.0,0,'MANY')
      end do

c This is the radiator assembly
      CALL RADIATOR

c These involve detectors and modules
      call prep_detectors
      call prep_modules
      do i=1,9
        call geom_module(modnames(i),i)
        call geom_dets(modnames(i),i)
        call gspos(modnames(i),i,'CCMT',centx(i),centy(i), 
     .                    5.671+0.381+0.0762,0,'ONLY')
      end do

c UNCOMMENT THIS IF SPECTROMETER IS RUN ALONE WITHOUT SPACECRAFT:
c      call ggclos


      END 
c------------------------------------------------------------------------
        SUBROUTINE SHUTTER_FRAME

      dimension par_C001(3),par_CS01(4),par_CS02(11),par_CS03(5),
     +          par_CS04(6),par_CS05(6),par_CS06(4),par_CS07(6),
     +          par_CS08(11),par_CS09(11),par_CS10(11),par_CS11(4),
     +          par_CS12(5),par_CS13(11),par_CS14(11),par_CS15(3),
     +          par_CS16(5),par_CS17(11),par_CSB1(5),par_CSB2(11),
     +          par_CSB3(6),par_CSB4(6),par_CSB5(6)
     
      common/switches/iswitch1,iswitch2
      character*4 frame_mthr(2) 
      data frame_mthr/'C001','C002'/ 
      data par_C001/0.0,27.,.37/
    
      data par_CS01/12.4212,12.3501,.18745,.242443/
      data par_CS02/.243205,4.211,0.0,.18745,6.93311,6.93311,
     +             0.0,.18745,6.969125,6.969125,0.0/          
      data par_CS03/3.08414,3.57055,.18745,188.545589,270./
      data par_CS04/10.811649,.242443,.18745,2.76,0.0,0.0/
      data par_CS05/9.736217,.242443,.18745,11.092091,0.0,0.0/
      data par_CS06/3.23179,3.404235,.18745,.318262/
      data par_CS07/6.9148,.2462,.18745,4.7634,0.0,0.0/
      data par_CS08/0.24003,35.,0.0,.18745,6.9175884,6.9175884,0.0,
     +              .18745,7.181469,7.181469,0.0/
      data par_CS09/0.47752,2.427521,0.0,.18745,3.8788,3.8788,
     +              0.0,.18745,3.919347,3.919347,0.0/
      data par_CS10/0.2462,18.,0.,0.18745,2.884538,2.884538,0.,
     +              0.18745,3.087116,3.087116,0./
      data par_CS11/3.325475,3.42274,0.18745,0.318262/
      data par_CS12/3.0855,3.57,.18745,18.934,140.9679595/
      data par_CS13/0.24295,2.8564766,0.,.18745,5.762866,5.762866,
     +              0.,.18745,5.939986,5.939986,0./
      data par_CS14/0.23039,14.8635,0.,.18745,1.1248263,1.1248263,
     +              0.,.18745,1.0179,1.0179,0./
      data par_CS15/0.242951,3.019,.18745/
      data par_CS16/3.0722,3.56,.18745,180.,270./
      data par_CS17/0.24,4.273665,0.,.18745,1.8393,1.8393,0.,
     +              .18745,1.87542,1.87542,0./   
      data par_CSB1/3.0855,3.57,.18745,102.0146,140.9679595/
      data par_CSB2/.24257,17.618921,0.0,.18745,4.72023,4.72023,
     +              0.0,.18745,4.8743,4.8743,0.0/
      data par_CSB3/4.29369,.2462,.18745,18.396472,0.0,0.0/ 
      data par_CSB4/1.113152,.637449,.18745,18.396472,0.0,0.0/
      data par_CSB5/3.46309,.245,.18745,7.313,0.0,0.0/

      if (iswitch1.eq.0) then
           y_adjust1 = 0.0
      else 
           y_adjust1 = 6.0
      end if

      if (iswitch2.eq.0) then
           y_adjust2 = 0.0
      else 
           y_adjust2 = 6.0
      end if


      call gsvolu('C001','TUBE',1,par_C001,3,IVOL)
      call gsvolu('C002','TUBE',1,par_C001,3,IVOL)
      call gsvolu('CS01','TRD1',6,par_CS01,4,IVOL)
      call gsvolu('CS02','TRAP',6,par_CS02,11,IVOL)
      call gsvolu('CS03','TUBS',6,par_CS03,5,IVOL)
      call gsvolu('CS04','PARA',6,par_CS04,6,IVOL)
      call gsvolu('CS05','PARA',6,par_CS05,6,IVOL)
      call gsvolu('CS06','TRD1',6,par_CS06,4,IVOL)
      call gsvolu('CS07','PARA',6,par_CS07,6,IVOL)
      call gsvolu('CS08','TRAP',6,par_CS08,11,IVOL)
      call gsvolu('CS09','TRAP',6,par_CS09,11,IVOL)
      call gsvolu('CS10','TRAP',6,par_CS10,11,IVOL)
      call gsvolu('CS11','TRD1',6,par_CS11,4,IVOL)
      call gsvolu('CS12','TUBS',6,par_CS12,5,IVOL)
      call gsvolu('CS13','TRAP',6,par_CS13,11,IVOL)
      call gsvolu('CS14','TRAP',6,par_CS14,11,IVOL)
      call gsvolu('CS15','BOX ',6,par_CS15,3,IVOL)
      call gsvolu('CS16','TUBS',6,par_CS16,5,IVOL)
      call gsvolu('CS17','TRAP',6,par_CS17,11,IVOL)
      call gsvolu('CSB1','TUBS',6,par_CSB1,5,IVOL)
      call gsvolu('CSB2','TRAP',6,par_CSB2,11,IVOL)     
      call gsvolu('CSB3','PARA',6,par_CSB3,6,IVOL)
      call gsvolu('CSB4','PARA',6,par_CSB4,6,IVOL)
      call gsvolu('CSB5','PARA',6,par_CSB5,6,IVOL)
 
      call gsvolu('CSS1','TUBE',6,0,0,IVOL)
      call gsvolu('CSM1','TUBE',6,0,0,IVOL)
      call gsvolu('CSL1','TUBE',6,0,0,IVOL)
      call gsvolu('CSS2','TUBE',6,0,0,IVOL)
      call gsvolu('CSM2','TUBE',6,0,0,IVOL) 
      call gsvolu('CSL2','TUBE',6,0,0,IVOL)
     
      call gspos('C001',1,'C000',0.0,y_adjust1,17.548914,0,'MANY')
      call gspos('C002',1,'C000',0.0,y_adjust2,19.001921,0,'MANY')    
      call gspos('CS01',1,'C001',10.2846,-6.24048-6.,0.0,82,
     +           'ONLY')
      call gspos('CS02',1,'C001',1.3049,-18.250738-6.,0.0,83,
     +           'ONLY')
      call gspos('CS03',1,'C001',-5.6463,-14.92338-6.,0.0,0,
     +           'ONLY')
      call gspos('CS04',1,'C001',-10.503196,-4.74263-6.,0.0,84,
     +           'ONLY')
      call gspos('CS01',2,'C002',-10.2846,-6.24048-6.,0.0,101,
     +           'ONLY')
      call gspos('CS02',2,'C002',-1.3049,-18.250738-6.,0.0,93,
     +           'ONLY')
      call gspos('CS03',2,'C002',5.6463,-14.92338-6.,0.0,96,'ONLY')
      call gspos('CS04',2,'C002',10.503196,-4.74263-6.,0.0,102,
     +           'ONLY') 
      call gspos('CS10',1,'C001',-4.132,18.34793-6.,0.0,94,
     +              'ONLY')     
      call gspos('CS12',1,'C001',-8.19912,13.98,0.0,0,
     +              'ONLY')
      call gspos('CSB1',1,'C002',-8.19912,13.98,0.0,0,'ONLY')
      call gspos('CSB2',1,'C002',-4.14997989,18.22023,0.0,103,
     +            'ONLY')
      call gspos('CSB3',1,'C002',-4.5307,13.5891469,0.0,104,
     +            'ONLY')
      call gspos('CSB4',1,'C002',-2.6081455,10.5757,0.0,104,'ONLY')
      call gspos('CSB5',1,'C002',-2.0939,15.0669,0.0,105,'ONLY')

      do i=1,2

         call gspos('CS05',i,frame_mthr(i),2.354487,-8.453196-6.,.0,
     +              85,'ONLY')
         call gspos('CS05',i+2,frame_mthr(i),-2.354487,-8.453196-6.,
     +              .0,86,'ONLY')
         call gspos('CS06',i,frame_mthr(i),0.0,-2.4271732-6.,.0,83,
     +              'ONLY')
         call gspos('CS07',i,frame_mthr(i),3.652968,7.992-6.,.0,87,
     +              'ONLY')
         call gspos('CS07',i+2,frame_mthr(i),-3.652968,7.992-6.,.0,88,
     +              'ONLY')
         call gspos('CS08',i,frame_mthr(i),-12.07682,13.02823-6.,.0,
     +              91,'ONLY')
         call gspos('CS08',i+2,frame_mthr(i),12.084,13.02823-6.,.0,92,
     +              'ONLY')
         call gspos('CS09',i,frame_mthr(i),-7.93769,6.5568-6.,.0,83,
     +              'ONLY')
         call gspos('CS09',i+2,frame_mthr(i),7.93879,6.5568-6.,.0,93,
     +              'ONLY')           
         call gspos('CS10',i+1,frame_mthr(i),4.132,18.34793-6.,.0,95,
     +              'ONLY')
         call gspos('CS11',i,frame_mthr(i),0.,15.2-6.,.0,83,'ONLY')
         call gspos('CS12',i+1,frame_mthr(i),8.19912,13.98,.0,96,
     +              'ONLY')
         call gspos('CS13',i,frame_mthr(i),-14.371,17.6015-6.,.0,97,
     +              'ONLY')
         call gspos('CS13',i+2,frame_mthr(i),14.371,17.6015-6.,.0,98,
     +              'ONLY')
         call gspos('CS14',i,frame_mthr(i),-18.373,12.01888-6.,.0,106,
     +              'ONLY')
         call gspos('CS14',i+2,frame_mthr(i),18.373,12.01888-6.,.0,
     +              100,'ONLY')
         call gspos('CS15',i,frame_mthr(i),-18.7198,7.986-6.,.0,0,
     +              'ONLY')
         call gspos('CS15',i+2,frame_mthr(i),18.7198,7.986-6.,.0,0,
     +              'ONLY')
         call gspos('CS16',i,frame_mthr(i),-15.40016,4.967-6.,.0,0,
     +              'ONLY')
         call gspos('CS16',i+2,frame_mthr(i),15.40016,4.967-6.,.0,96,
     +              'ONLY')
         call gspos('CS17',i,frame_mthr(i),-13.5427987,1.649-6.,.0,83,
     +              'ONLY')
         call gspos('CS17',i+2,frame_mthr(i),13.5427987,1.649-6.,.0,
     +              93,'ONLY')
        
      end do

      end
c----------------------------------------------------------------------
        SUBROUTINE SHUTTER_THICK(shutter_center1,ith)
      
      character*4 shutter_center1
      real  par_CSS1(3),par_CSM1(3),par_CSL1(3),par_shr1(3)
      real  S_Radius1(9),S_Thickness1(9),M_Thickness1(9),
     +      L_Thickness1(9)    
  
      data par_shr1/0.,3.006,.35/
      data S_Radius1/.1716,.1716,.1716,.1716,.194,.1716,.205,.194,
     +               .336/
      data S_Thickness1/.0062,.0062,.0062,.0062,.0062,.0062,.0062,
     +                  .0062,.01/
      data M_Thickness1/.061,.061,.061,.061,.052,.061,.052,.052,
     +                  .056/
      data L_Thickness1/.153,.153,.153,.153,.144,.153,.144,.144,
     +                  .147/
     
      data par_CSS1/0.0,0.0,0.0/
      data par_CSM1/0.0,1.215,0.0/
      data par_CSL1/1.215,3.005,0.0/

      par_CSS1(2)= S_Radius1(ith)/2.
      par_CSS1(3)= S_Thickness1(ith)/2.

      call gsvolu(shutter_center1,'TUBE',1,par_shr1,3,IVOL)

      call gsposp('CSS1',ith,shutter_center1,0.0,0.0,
     +           S_Thickness1(ith)/2.+.187452,0,'ONLY',par_CSS1,3)
     
      par_CSM1(1)= S_Radius1(ith)/2.
      par_CSM1(3)= M_Thickness1(ith)/2.
      call gsposp('CSM1',ith,shutter_center1,0.0,0.0,
     +           M_Thickness1(ith)/2.+.187452,0,'ONLY',par_CSM1,3)

      par_CSL1(3)= L_Thickness1(ith)/2.
      call gsposp('CSL1',ith,shutter_center1,0.0,0.0,
     +            L_Thickness1(ith)/2.+.187452,0,'ONLY',par_CSL1,3)

      end
c--------------------------------------------------------------------------
        SUBROUTINE SHUTTER_THIN(shutter_center2,jth)
 
      character*4 shutter_center2
      real  par_CSS2(3),par_CSM2(3),par_CSL2(3),par_shr2(3)
      real  S_Radius2(9)
      
      data par_shr2/0.,3.006,.35/
      data S_Radius2/.6743,.6743,.6743,.6743,.6743,.6743,.6743,
     +               .6743,.615/
     
      data par_CSS2/0.0,0.0,.0031/
      data par_CSM2/0.0,.855,.0485/
      data par_CSL2/.855,3.005,.0205/

      call gsvolu(shutter_center2,'TUBE',1,par_shr2,3,IVOL)

      par_CSS2(2)= S_Radius2(jth)/2.
      call gsposp('CSS2',jth,shutter_center2,0.0,0.0,.190552,0,
     +           'ONLY',par_CSS2,3)   
      par_CSM2(1)= S_Radius2(jth)/2.
      call gsposp('CSM2',jth,shutter_center2,0.0,0.0,.235952,0,
     +           'ONLY',par_CSM2,3)
      call gsposp('CSL2',jth,shutter_center2,0.0,0.0,.207952,0,
     +           'ONLY',par_CSL2,3)
      
      end

c-----------------------------------------------------------------------

      SUBROUTINE coldplate
 
c SHAPE PARAMETERS OF THE BOUNDARY OF THE COLDPLATE
 
      DIMENSION PAR_CCSA(3),PAR_CCSB(3),PAR_CCSC(3),PAR_CCSD(3),
     +          PAR_CCDG(3),PAR_CCDH(3),PAR_CCDJ(3),PAR_CCDL(3),
     +          PAR_CCDM(3),PAR_CCW(3),PAR_CCOY(3), PAR_CCAA(3)
 
      data PAR_CCSA/4.31800,0.12700,1.44780/ 
      data PAR_CCSB/9.76884,0.31750,1.44780/ 
      data PAR_CCSC/4.34848,0.12700,1.44780/ 
      data PAR_CCSD/6.62432,0.31750,1.44780/ 
      data PAR_CCDG/13.55344,0.44298,1.44780/ 
      data PAR_CCDH/5.96138,0.44298,1.44780/ 
      data PAR_CCDJ/3.04038,0.44298,1.44780/ 
      data PAR_CCDL/14.31036,0.44298,1.44780/ 
      data PAR_CCDM/4.71424,0.44298,1.44780/ 
C SHAPE PARAMETERS OF HOLE IN CENTER(AREA W)
      DATA PAR_CCW/2.54000,3.17500,1.44780/ 
C SHAPE PARAMETERS FOR OUTER BOXES
      DATA PAR_CCOY/1.52400,1.47320,0.47498/ 
      DATA PAR_CCAA/1.90500,3.49250,1.04775/ 

      dimension centx(9),centy(9)
      common/centers/centx,centy
 
c NOW CREATE VOLUMES
 
      CALL GSVOLU ('CCSA','BOX ',6,PAR_CCSA,3,IVOL)
      CALL GSVOLU ('CCSB','BOX ',6,PAR_CCSB,3,IVOL)
      CALL GSVOLU ('CCSC','BOX ',6,PAR_CCSC,3,IVOL)
      CALL GSVOLU ('CCSD','BOX ',6,PAR_CCSD,3,IVOL)
      CALL GSVOLU ('CCDG','BOX ',6,PAR_CCDG,3,IVOL)
      CALL GSVOLU ('CCDH','BOX ',6,PAR_CCDH,3,IVOL)
      CALL GSVOLU ('CCDJ','BOX ',6,PAR_CCDJ,3,IVOL)
      CALL GSVOLU ('CCDL','BOX ',6,PAR_CCDL,3,IVOL)
      CALL GSVOLU ('CCDM','BOX ',6,PAR_CCDM,3,IVOL)

C CREATION OF AREA W
      CALL GSVOLU ('CCW ','TUBE',6,PAR_CCW,3,IVOL)
C CREATION OF AREA Y, AND AREA AA
C NOTE THAT AREA Y AND Z HAVE SAME DIMENSIONS
      CALL GSVOLU('CCOY','BOX ',6,PAR_CCOY,3,IVOL)
      CALL GSVOLU('CCAA','BOX ',6,PAR_CCAA,3,IVOL)
 
C NOW POSITION THE ELEMENTS OF THE COLDPLATE
 
      CALL GSPOS ('CCSA',1,'CCMT',0.00000,-19.79930,0.00000,0,'ONLY') 
      CALL GSPOS ('CCSB',1,'CCMT',-14.72692,-7.15772,0.00000,1,'ONLY') 
      CALL GSPOS ('CCSC',1,'CCMT',-15.69720,12.37488,0.00000,2,'ONLY') 
      CALL GSPOS ('CCSD',1,'CCMT',0.00000,18.68424,0.00000,0,'ONLY') 
C POSITION BOX E;  BOX E HAS SAME SHAPE PARAMETERS AS BOX C
      CALL GSPOS ('CCSC',2,'CCMT',15.69720,12.37488,0.00000,3,'ONLY') 
C POSITION BOX F;  BOX F HAS SAME SHAPE PARAMETERS AS BOX B
      CALL GSPOS ('CCSB',2,'CCMT',14.72692,-7.15772,0.00000,4,'ONLY') 
      CALL GSPOS ('CCDG',1,'CCMT',-7.89940,5.25272,0.00000,5,'MANY') 
      CALL GSPOS ('CCDH',1,'CCMT',-6.98500,4.90982,0.00000,6,'MANY') 
C POSITION BOX I;  BOX I HAS SAME SHAPE PARAMETERS AS BOX G
      CALL GSPOS ('CCDG',2,'CCMT',7.89940,5.25272,0.00000,7,'MANY') 
      CALL GSPOS ('CCDJ',1,'CCMT',0,13.79982,0.00000,8,'ONLY') 
C POSITION BOX K;  BOX K HAS SAME SHAPE PARAMETERS AS BOX H
      CALL GSPOS ('CCDH',2,'CCMT',6.98500,4.90982,0.00000,9,'MANY') 
      CALL GSPOS ('CCDL',1,'CCMT',0,-8.40232,0.00000,0,'ONLY') 
      CALL GSPOS ('CCDM',1,'CCMT',0,-9.54786,0.00000,10,'ONLY') 
      CALL GSPOS('CCOY',1,'CCMT',16.00200,-9.24052,-0.41338,11,'ONLY') 
C POSITION BOX Z;  BOX Z HAS SAME DIMENSION AS BOX Y
      CALL GSPOS('CCOY',2,'CCMT',-16.00200,-9.24052,-0.41338,12,'ONLY') 
      CALL GSPOS('CCAA',1,'CCMT',3.38074,14.82598,0.40005,0,'MANY')
 
c now position cylinders
      call coldplate_cylinder
      do i=1,9
         CALL GSPOS('CCCL',i,'CCMT',centx(i),centy(i),0.07620,1,'MANY') 
      end do
 
C  AREA W
 
      CALL GSPOS('CCW ',1,'CCMT',0.00000,-1.73736,0.00000,1,'MANY') 
 
c now position the back plate
 
      CALL coldplate_plate

      end
c-----------------------------------------------------------------------
 
      subroutine coldplate_cylinder
 
c this subroutine defines the housing for the cylinder
 
      dimension PAR_CCCL(3)
      DIMENSION PAR_CCC1(3),PAR_CCC2(3),PAR_CCC3(3),PAR_CCC4(3)
      DATA PAR_CCCL/0.00000,4.62280,1.52400/                             
      DATA PAR_CCC1/3.17500,3.35280,0.38100/ 
      DATA PAR_CCC2/3.35280,4.11988,0.07620/
      DATA PAR_CCC3/4.11988,4.36626,0.38100/
      DATA PAR_CCC4/4.36626,4.72186,1.52400/
C MOTHER REGION FOR CYLINDER
      CALL GSVOLU ('CCCL','TUBE',1,PAR_CCCL,3,IVOL)
 
C DAUGHTER REGIONS FOR CYLINDER
 
      CALL GSVOLU('CCC1','TUBE',6,PAR_CCC1,3,IVOL)
      CALL GSVOLU('CCC2','TUBE',6,PAR_CCC2,3,IVOL)
      CALL GSVOLU('CCC3','TUBE',6,PAR_CCC3,3,IVOL)
      CALL GSVOLU('CCC4','TUBE',6,PAR_CCC4,3,IVOL)
 
      CALL GSPOS('CCC1',1,'CCCL',0.00000,0.00000,0.00000,0,'ONLY') 
      CALL GSPOS('CCC2',1,'CCCL',0.00000,0.00000,-0.22860,0,'ONLY') 
      CALL GSPOS('CCC3',1,'CCCL',0.00000,0.00000,0.00000,0,'ONLY') 
      CALL GSPOS('CCC4',1,'CCCL',0.00000,0.00000,0.00000,0,'ONLY') 
      end
 
c-----------------------------------------------------------------------
      subroutine coldplate_plate
 
c this subroutine creates the bottom plate of the coldplate
 
      DIMENSION PAR_CCTH(4),PAR_CCBH(4)
      DIMENSION centx(9),centy(9)

      common/centers/centx,centy

      DATA PAR_CCTH/21.27504,10.59180,0.07620,6.67766/ 
      DATA PAR_CCBH/21.27504,8.76808,0.07620,12.76350/ 
 
      CALL GSVOLU('CCTH','TRD1',6,PAR_CCTH,4,IVOL)
      CALL GSVOLU('CCBH','TRD1',6,PAR_CCBH,4,IVOL)
 
      CALL GSPOS('CCTH',1,'CCMT',0.00000,12.27582,1.524,13,'MANY') 
      CALL GSPOS('CCBH',1,'CCMT',0.00000,-7.16280,1.524,14,'MANY') 
 
      END
c-----------------------------------------------------------------------
 

      subroutine legs


      call geom_legs

      call gspos('CL00',1,'CCMT',0.0,21.214,3.8169,21,'MANY')
      call gspos('CL00',2,'CCMT',18.437,-10.645,3.8169,22,'MANY')
      call gspos('CL00',3,'CCMT',-18.437,-10.645,3.8169,23,'MANY')
      call gspos('CLTX',1,'CCMT',0.0, -3.2418+21.214,
     +            -1.44780,21,'ONLY')
      call gspos('CLTX',2,'CCMT',-2.80748+18.437,1.6209-10.645,
     +            -1.44780,22,'ONLY')
      call gspos('CLTX',3,'CCMT',2.80748-18.437,1.6209-10.645,
     +            -1.44780,23,'ONLY')

      end

c-----------------------------------------------------------------------

      subroutine geom_legs
c  SHAPE PARAMETERS OF THE three coldplate supports
c  ANYTHING WHOSE THIRD LETTER IS 'S' DENOTES A PIECE OF THE SIDE
C  ANYTHING WHOSE THIRD LETTER IS 'T' DENOTES A PIECE OF THE STRAP
C  clt1 through clt6 are the individual fiberglass straps 

c  CLTX: this is separate to keep the legs mother volume from
c  intersecting the coldplate mother volume, since they both
c  have to be "many" to deal with other overlaps.

      dimension par_clsa(3),par_clsb(3),par_clsc(3),par_clsd(4),
     +          par_clse(11),par_clsf(6),par_clsg(3),par_clsh(3),
     +          par_clsi(3),par_clsm(11),par_clsn(6),par_clto(3),
     +          par_cltp(3),par_clt1(3),par_clty(4),par_cltz(4),
     +          par_cltw(3),par_cltx(3),par_cl00(3)

      data par_cl00/11.0,9.75,1.62/
      data par_clsa/0.2193, 7.6835, 0.6350/
      data par_clsb/0.4826, 7.6835, 0.0508/
      data par_clsc/0.0762, 8.9294, 0.6350/
      data par_clsd/1.3818, 2.0066, 0.6350, 0.6350/
      data par_clse/0.6350,    0.,    0.,
     +              1.1930, 0.9634, 1.1455,
     +              184.36, 1.1930, 0.9634,
     +              1.1455, 184.36/
      data par_clsf/0.9779, 1.4477, 0.6350,
     +              330.,      0.,        0./
      data par_clsg/7.5197, 0.1841, 0.6350/
      data par_clsh/7.5197, 0.5080, 0.0508/
      data par_clsi/7.5197, 0.0635, 0.6350/
      data par_clsm/ 0.6350,    0.,    0.,
     +               1.1930, 0.9634, 1.1455,
     +               175.64, 1.1930, 0.9634,
     +               1.1455, 175.64/
      data par_clsn/0.9779, 1.4478, 0.6350,
     +              30.,     0.,    0./
      data par_clto/1.4224, 0.5301, 0.5625/
      data par_cltp/0.0000, 0.6375, 0.5080/
      data par_clt1/0.0635, 3.4607, 0.3175/
      data par_clty/1.4724, .635,0.7366,.7252/
      data par_cltz/.8374, 1.4724,0.7366,.5499/
      data par_cltw/0.0000, 1.1557, 0.44094/
      data par_cltx/0.9525, 0.6350, 1.5875/
c NOW CREATE VOLUMES

c Until 6/21/02 this was accidentally made of aluminum:
      call gsvolu ('CL00','BOX ',1,par_cl00,3,ivol)

      call gsvolu ('CLSA','BOX ',6,par_clsa,3,ivol)
      call gsvolu ('CLSB','BOX ',6,par_clsb,3,ivol)
      call gsvolu ('CLSC','BOX ',6,par_clsc,3,ivol)
      call gsvolu ('CLSD','TRD1',6,par_clsd,4,ivol)
      call gsvolu ('CLSE','TRAP',6,par_clse,11,ivol)
      call gsvolu ('CLSF','PARA',6,par_clsf,6,ivol)
      call gsvolu ('CLSG','BOX ',6,par_clsg,3,ivol)
      call gsvolu ('CLSH','BOX ',6,par_clsh,3,ivol)
      call gsvolu ('CLSI','BOX ',6,par_clsi,3,ivol)
      call gsvolu ('CLSM','TRAP',6,par_clsm,11,ivol)
      call gsvolu ('CLSN','PARA',6,par_clsn,6,ivol)
      call gsvolu ('CLTO','BOX ',3,par_clto,3,ivol)
      call gsvolu ('CLTP','TUBE',3,par_cltp,3,ivol)
      call gsvolu ('CLT1','BOX ',64,par_clt1,3,ivol)
      call gsvolu ('CLTY','TRD1',3,par_clty,4,ivol)
      call gsvolu ('CLTZ','TRD1',3,par_cltz,4,ivol)
      call gsvolu ('CLTW','TUBE',3,par_cltw,3,ivol)
      call gsvolu ('CLTX','BOX ',3,par_cltx,3,ivol)

C NOW POSITION THE OUTER sides
c subtract 9.75 cm from original y coordinate to obtain current y coordinate

      call gspos('CLSA',1,'CL00',-5.3698,2.3770,0.0000,16,'ONLY')
      call gspos('CLSB',1,'CL00',-4.9883,2.2116,0.0000,16,'ONLY')
      call gspos('CLSC',1,'CL00',-4.9700,0.8476,0.0000,16,'ONLY')
      call gspos('CLSD',1,'CL00',0.0000,9.0968,0.0000,17,'ONLY')
      call gspos('CLSE',1,'CL00',-9.6126,-5.6408,0.0000,0,'ONLY')
      call gspos('CLSF',1,'CL00',-8.8532,-8.3014,0.0000,0,'MANY')
      call gspos('CLSG',1,'CL00',0.0000,-8.6647,0.0000,0,'ONLY')
      call gspos('CLSH',1,'CL00',0.0000,-9.1150,0.0000,0,'ONLY')
      call gspos('CLSI',1,'CL00',0.0000,-9.6865,0.0000,0,'ONLY')
C POSITION AREA J: THIS AREA HAS SAME SHAPE PARAMETERS AS AREA A
      call gspos('CLSA',2,'CL00',5.3698,2.3770,0.0000,18,'ONLY')
C POSITION AREA K; THIS AREA HAS SAME SHAPE PARAMETERS AS AREA B
      call gspos('CLSB',2,'CL00',4.9883,2.2116,0,18,'ONLY')
C POSITION AREA L; THIS AREA HAS SAME SHAPE PARAMETERS AS AREAC
      call gspos('CLSC',2,'CL00',4.9700,0.8476,0.0000,18,'ONLY')
      call gspos('CLSM',1,'CL00',9.5217,-5.6464,0.0000,0,'ONLY')
      call gspos('CLSN',1,'CL00',8.8532,-8.3014,0.0000,0,'MANY')
      call gspos('CLTO',1,'CL00',0.0000,7.5245,0.0000,0,'ONLY')
      call gspos('CLTP',1,'CL00',0.0000,5.8387,0.0000,0,'ONLY')
C POSITION THE OTHER FIVE CYLINDERS WHICH HAVE SAME SHAPE PARAMETERS
C AS 'CLTP'
      call gspos('CLTP',2,'CL00',0.0000,-1.0828,0.0000,0,'ONLY')
      call gspos('CLTP',3,'CL00',-7.8638,-7.7820,0.0000,0,'ONLY')
      call gspos('CLTP',4,'CL00',-1.8697,-4.3213,0.0000,0,'ONLY')
      call gspos('CLTP',5,'CL00',1.8697,-4.3213,0.0000,0,'ONLY')
      call gspos('CLTP',6,'CL00',7.8638,-7.7820,0.0000,0,'ONLY')
 
C POSITION THE PIECES OF THE CENTER, WHERE THE STRAPS ATTACH TO THE
C COLD PLATE
      call gspos('CLTZ',1,'CL00',0.0000,-3.9085,0.0000,17,'ONLY')
      call gspos('CLTY',1,'CL00',0.0000,-2.6334,0.0000,17,'ONLY')
      call gspos('CLTW',1,'CL00',0.0000,-3.2418,1.1775,0,'ONLY')
 
C POSITION THE STRAPS; ALL STRAPS HAVE SAME SHAPE PARAMETER AS 'CLT1'
 
      call gspos('CLT1',1,'CL00',-0.5728,2.3780,0.0000,0,'MANY')
      call gspos('CLT1',2,'CL00',0.5728,2.3780,0.0000,0,'MANY')
      call gspos('CLT1',3,'CL00',5.1532,-5.5557,0.0000,19,'MANY')
      call gspos('CLT1',4,'CL00',4.5804,-6.5478,0.0000,19,'MANY')
      call gspos('CLT1',5,'CL00',-5.1532,-5.5557,0.0000,20,'MANY')
      call gspos('CLT1',6,'CL00',-4.5804,-6.5478,0.0000,20,'MANY')
      return
      end

c-----------------------------------------------------------------------

      SUBROUTINE BESCATT
C this subroutine defines and positions the shape parameters of the Be
c scatterer;  All the coordinates are the same as the cryostats

      DIMENSION PAR_CCBE(3)
      DATA PAR_CCBE/0.0858,1.4986,1.7501/
      CALL GSVOLU('CCBE','TUBE',9,PAR_CCBE,3,IVOL)
      CALL GSPOS('CCBE',1,'CCMT',0.0000,-6.4000,4.73202,0,'ONLY')
      
      END
c-----------------------------------------------------------------------

      SUBROUTINE MOUNT
C this subroutine defines and positions the shape parameters of the
c Be scatterer mount; all the coordinates are the same as the cryostats

      DIMENSION PAR_CCMA(3),PAR_CCMB(3),PAR_CCMC(3)
      DATA PAR_CCMA/0.0000,1.4999,0.1016/
      DATA PAR_CCMB/1.0465,0.4115,0.5893/
      DATA PAR_CCMC/0.1587,1.4999,0.5893/

c The mount is made out of Al

      CALL GSVOLU('CCMA','TUBE',6,PAR_CCMA,3,IVOL)
      CALL GSVOLU('CCMB','BOX ',6,PAR_CCMB,3,IVOL)
      CALL GSVOLU('CCMC','BOX ',6,PAR_CCMC,3,IVOL)
      CALL GSPOS('CCMA',1,'CCMT',0.0000,-6.4000,2.8809,0,'ONLY')
      CALL GSPOS('CCMB',1,'CCMT',0.0000,-6.4000,2.1900,0,'ONLY')
      CALL GSPOS('CCMC',1,'CCMT',0.0000,-6.4000,2.1900,0,'ONLY')
      
      END
c-----------------------------------------------------------------------

      SUBROUTINE N2TANK
C this subroutine defines and positions the shape parameters of the
c N2 tank and the tubes in it; all the cooridinates are in N2 tank`s mother

      DIMENSION PAR_CCNC(3),PAR_CCN1(3),PAR_CCN2(3),PAR_CCNT(3)
      DIMENSION PAR_CCWN(3),PAR_CCCI(3),PAR_CCCO(3)
      DATA PAR_CCWN/0.0,2.5401,7.01675/
      DATA PAR_CCNC/2.4638,2.5400,6.1913/
      DATA PAR_CCN1/.2413,.3175,6.6231/
      DATA PAR_CCN2/.2413,.3175,6.8517/
      DATA PAR_CCNT/0.0000,2.5400,0.0762/
      DATA PAR_CCCI/0.0,.9525,.51435/
      DATA PAR_CCCO/1.5875,2.4638,.51435/
c define mother region for N2 tank.  Then place mother into mother for cold
c plate(CCMT).
      CALL GSVOLU('CCWN','TUBE',1,PAR_CCWN,3,IVOL)
      CALL GSVOLU('CCNC','TUBE',6,PAR_CCNC,3,IVOL)
      CALL GSVOLU('CCN1','TUBE',3,PAR_CCN1,3,IVOL)
      CALL GSVOLU('CCN2','TUBE',3,PAR_CCN2,3,IVOL)
      CALL GSVOLU('CCNT','TUBE',6,PAR_CCNT,3,IVOL)
      CALL GSVOLU('CCCI','TUBE',6,PAR_CCCI,3,IVOL)
      CALL GSVOLU('CCCO','TUBE',6,PAR_CCCO,3,IVOL)

      CALL GSPOS('CCNC',1,'CCWN',0.0000,0.0,.67437,0,'ONLY')
      CALL GSPOS('CCN1',1,'CCWN',-1.2700,0.0,-.39243,0,'ONLY')
      CALL GSPOS('CCN2',1,'CCWN',1.2700,0.0,-.16383,0,'ONLY')
      CALL GSPOS('CCNT',1,'CCWN',0.0000,0.0,6.94182,0,'ONLY')
      CALL GSPOS('CCCI',1,'CCWN',0.0,0.0,-5.77723,0,'ONLY')
      CALL GSPOS('CCCO',1,'CCWN',0.0,0.0,-5.77723,0,'ONLY')
      END
 
c-----------------------------------------------------------------------
      SUBROUTINE POS_N2TANK
c position N2TANK
      CALL GSPOS('CCWN',1,'CCMT',0.0,-1.7369,4.3879,0,'ONLY') 
      END
c-----------------------------------------------------------------------

      SUBROUTINE CRYOSORB
      DIMENSION PAR_CCCA(3),PAR_CCCB(3),PAR_CCCC(3),PAR_CCCD(3),
     +          PAR_CCCE(3),PAR_CCCF(3)
      DATA PAR_CCCA/3.2258,3.81,0.508/
      DATA PAR_CCCB/0.0000,3.2258,0.0381/
      DATA PAR_CCCC/3.2258,3.3020,1.2751/
      DATA PAR_CCCD/0.3429,0.4191,1.7031/
      DATA PAR_CCCE/3.2258,3.3985,0.2388/
      DATA PAR_CCCF/.4191,3.2258,1.5558/

      CALL GSVOLU('CCCA','TUBE',6,PAR_CCCA,3,IVOL)
      CALL GSVOLU('CCCB','TUBE',6,PAR_CCCB,3,IVOL)
      CALL GSVOLU('CCCC','TUBE',6,PAR_CCCC,3,IVOL)
      CALL GSVOLU('CCCD','TUBE',6,PAR_CCCD,3,IVOL)
      CALL GSVOLU('CCCE','TUBE',6,PAR_CCCE,3,IVOL)
      CALL GSVOLU('CCCF','TUBE',63,PAR_CCCF,3,IVOL)

      CALL GSPOS('CCCA',1,'CCMT',0.0000,14.0409,2.1082,0,'ONLY')
      CALL GSPOS('CCCB',1,'CCMT',0.0000,14.0409,1.6383,0,'ONLY')
      CALL GSPOS('CCCC',1,'CCMT',0.0000,14.0409,3.2563,0,'ONLY')
      CALL GSPOS('CCCD',1,'CCMT',0.0000,14.0409,3.3033,0,'ONLY')
      CALL GSPOS('CCCE',1,'CCMT',0.0000,14.0409,4.7727,0,'ONLY')
      CALL GSPOS('CCCF',1,'CCMT',0.0000,14.0409,3.2322,0,'ONLY')

      END

c-----------------------------------------------------------------------
 
      SUBROUTINE RING
      DIMENSION PAR_CCRA(3),PAR_CCRB(3),PAR_CCRC(3)
c this subrouine creates the piece on top of the preamp ring that
c surrounds the cryostat 
      DATA PAR_CCRA/23.9268,24.0792,7.2707/
      DATA PAR_CCRB/24.0792,25.4000,0.3175/
      DATA PAR_CCRC/24.0792,24.4602,0.0762/
 
C note that two of the rings are the same (the top and bottom), and the three
c middle rings are the same

      CALL GSVOLU('CCRA','TUBE',6,PAR_CCRA,3,IVOL)
      CALL GSVOLU('CCRB','TUBE',6,PAR_CCRB,3,IVOL)
      CALL GSVOLU('CCRC','TUBE',6,PAR_CCRC,3,IVOL)

      CALL GSPOS('CCRA',1,'CCMT',0.0000,0.0,6.3818,0,'ONLY')
      CALL GSPOS('CCRB',1,'CCMT',0.0000,0.0,-0.5715,0,'ONLY')
      CALL GSPOS('CCRC',1,'CCMT',0.0000,0.0,3.0074,0,'ONLY')
c copy 2 of CCRC corresponds to CCRD
      CALL GSPOS('CCRC',2,'CCMT',0.0000,0.0,6.3818,0,'ONLY')
c copy 3 of CCRC corresponds to CCRE
      CALL GSPOS('CCRC',3,'CCMT',0.0000,0.0,9.7561,0,'ONLY')
c copy 2 of CCRB corresponds to CCRF
      CALL GSPOS('CCRB',2,'CCMT',0.0000,0.0,13.3350,0,'ONLY')

      END

c-----------------------------------------------------------------------

      SUBROUTINE BEAMS
c this subroutine creates and positions
c the cross-beams in the cryostat housing cover; the beams are
c all positioned in the same mother:  CCMH
 
      DIMENSION PAR_CCHA(3),PAR_CCHB(3),PAR_CCHD(3),PAR_CCHF(3),
     +          PAR_CCHI(3),PAR_CCHK(3),PAR_CCHM(3),PAR_CCHN(3),
     +           par_ccmh(3),par_cchp(3)

c define the mother for the cryostat top plate
      data par_ccmh/0.0,25.5,1.59/
      call gsvolu('CCMH','TUBE',1,par_ccmh,3,IVOL)

      DATA PAR_CCHA/14.6016,0.3880,1.5875/
      DATA PAR_CCHB/21.6454,0.3175,1.5875/
      DATA PAR_CCHD/11.6474,0.3693,1.5875/
      DATA PAR_CCHF/4.1662,0.2904,1.5875/
      DATA PAR_CCHI/0.8527,0.3175,1.5875/
      DATA PAR_CCHK/17.1214,0.3175,1.5875/
      DATA PAR_CCHM/21.7722,0.3759,1.5875/
      DATA PAR_CCHN/0.4060,2.44315,1.5875/
      DATA PAR_CCHP/0.4060,7.59335,1.5875/

      CALL GSVOLU('CCHA','BOX ',6,PAR_CCHA,3,IVOL)
      CALL GSVOLU('CCHB','BOX ',6,PAR_CCHB,3,IVOL)
      CALL GSVOLU('CCHD','BOX ',6,PAR_CCHD,3,IVOL)
      CALL GSVOLU('CCHF','BOX ',6,PAR_CCHF,3,IVOL)
      CALL GSVOLU('CCHI','BOX ',6,PAR_CCHI,3,IVOL)
      CALL GSVOLU('CCHK','BOX ',6,PAR_CCHK,3,IVOL)
      CALL GSVOLU('CCHM','BOX ',6,PAR_CCHM,3,IVOL)
      CALL GSVOLU('CCHN','BOX ',6,PAR_CCHN,3,IVOL)
      CALL GSVOLU('CCHP','BOX ',6,PAR_CCHP,3,IVOL)

      CALL GSPOS('CCHA',1,'CCMH',0.0000,18.6759,0.0000,0,'ONLY')
      CALL GSPOS('CCHB',1,'CCMH',-8.1100,4.8730,0.0000,24,'ONLY')
c position CCHC which is same geometry as CCHB
      CALL GSPOS('CCHB',2,'CCMH',8.1100,4.8730,0.0000,25,'ONLY')
      CALL GSPOS('CCHD',1,'CCMH',-10.0503,6.9863,0.0000,26,'ONLY')
c position CCHE which is same geometry as CCHD
      CALL GSPOS('CCHD',2,'CCMH',10.0503,6.9863,0.0000,27,'ONLY')
      CALL GSPOS('CCHF',1,'CCMH',0.0000,10.6322,0.0000,0,'ONLY')
      CALL GSPOS('CCHI',1,'CCMH',-11.3302,9.3685,0.0000,28,'ONLY')
c position CCHJ which is same geometry as CCHI
      CALL GSPOS('CCHI',2,'CCMH',11.3302,9.3685,0.0000,29,'ONLY')
      CALL GSPOS('CCHK',1,'CCMH',-14.7084,-7.2062,0.0000,30,'ONLY')
c position CCHL which is same geometry as CCHL
      CALL GSPOS('CCHK',2,'CCMH',14.7084,-7.2062,0.0000,31,'ONLY')
      CALL GSPOS('CCHM',1,'CCMH',0.0000,-9.4031,0.0000,0,'ONLY')
c CCHN has to be interrupted by the Be scatterer volume
      CALL GSPOS('CCHN',1,'CCMH',0.0000,-1.85685,0.0000,0,'ONLY')
      CALL GSPOS('CCHP',1,'CCMH',0.0000,-16.1434,0.0000,0,'ONLY')
      END

c-----------------------------------------------------------------------
      SUBROUTINE OUTSID
c this subroutine defines the inner and outer ring around the shell
      DIMENSION PAR_CCOR(3),PAR_CCIR(3)
      DATA PAR_CCOR/24.1554,25.4000,0.4064/
      DATA PAR_CCIR/23.9014,24.1554,1.5875/
      CALL GSVOLU('CCOR','TUBE',6,PAR_CCOR,3,IVOL)
      CALL GSVOLU('CCIR','TUBE',6,PAR_CCIR,3,IVOL)
      CALL GSPOS('CCOR',1,'CCMH',0.0000,0.0000,-1.1811,0,'ONLY')
      CALL GSPOS('CCIR',1,'CCMH',0.0000,0.0000,0.0000,0,'ONLY')
      END

c-----------------------------------------------------------------------

      SUBROUTINE SCATTHOLE
c this subroutine defines the top plate region above the Be scatterer
      DIMENSION PAR_BSH0(3),PAR_BSH1(3),PAR_BSH2(3)
      DATA PAR_BSH0/0.0000,2.1,1.59/
      DATA PAR_BSH1/1.5,2.1,1.5875/
      DATA PAR_BSH2/0.0000,1.5,0.0254/
      CALL GSVOLU('BSH0','TUBE',1,PAR_BSH0,3,IVOL)
      CALL GSVOLU('BSH1','TUBE',6,PAR_BSH1,3,IVOL)
      CALL GSVOLU('BSH2','TUBE',6,PAR_BSH2,3,IVOL)
      CALL GSPOS('BSH1',1,'BSH0',0.0000,0.00000,0.0000,0,'ONLY')
      CALL GSPOS('BSH2',1,'BSH0',0.0000,0.00000,0.0000,0,'ONLY')
      CALL GSPOS('BSH0',1,'CCMH',0.0000,-6.4000,0.0000,0,'ONLY')
      END

c-----------------------------------------------------------------------
      SUBROUTINE CYLNDR
c place pieces of cylinder in their own mother,then place mother into CCMH
c which is mother of top plate
      DIMENSION PAR_CCH1(3),PAR_CCH2(3),PAR_CCH3(3),PAR_CCMO(3),
     +          PAR_CCH4(3),PAR_CCH5(3),PAR_CCH6(3),
     +          PAR_CCH8(9),PAR_CCH9(3),PAR_CCH0(3),
     +          PAR_CCHV(3),PAR_CCHW(3)
c first define mother volume(CCMO)
      DATA PAR_CCMO/0.0000,4.6421,1.5875/
      CALL GSVOLU('CCMO','TUBE',1,PAR_CCMO,3,IVOL)
      CALL GSVOLU('CCMP','TUBE',1,PAR_CCMO,3,IVOL) ! Version for G3 and G7

      DATA PAR_CCH1/2.925,4.6418,0.1016/
      DATA PAR_CCH2/4.0068,4.6418,0.2413/
      DATA PAR_CCH3/4.3878,4.6418,1.2446/
      DATA PAR_CCH4/0.0000,3.9687,0.0254/
      DATA PAR_CCH5/2.925,4.0068,0.0254/
      DATA PAR_CCH6/2.925,4.0068,0.0508/
c CCHV and CCHV are like 5 and 6 but for G3 and G7,which have smaller IDs.
      DATA PAR_CCHV/2.875,4.0068,0.0254/
      DATA PAR_CCHW/2.875,4.0068,0.0508/

      DATA PAR_CCH8/0.0,     360.0,    2.0,
     +              -1.0046, 2.97434,  4.00685,
     +              -.643383,3.99415,  4.00685/
      DATA PAR_CCH9/2.925,4.0068,0.0381/
      DATA PAR_CCH0/4.0068,4.3751,0.1143/

      CALL GSVOLU('CCH1','TUBE',6,PAR_CCH1,3,IVOL)
      CALL GSVOLU('CCH2','TUBE',6,PAR_CCH2,3,IVOL)
      CALL GSVOLU('CCH3','TUBE',6,PAR_CCH3,3,IVOL)
c CCH4 is Be window
      CALL GSVOLU('CCH4','TUBE',9,PAR_CCH4,3,IVOL)
      CALL GSVOLU('CCH5','TUBE',3,PAR_CCH5,3,IVOL)
      CALL GSVOLU('CCH6','TUBE',43,PAR_CCH6,3,IVOL)
      CALL GSVOLU('CCHV','TUBE',3,PAR_CCHV,3,IVOL)
      CALL GSVOLU('CCHW','TUBE',43,PAR_CCHW,3,IVOL)
c CCH7 has same shape parameters as CCH5, CCHX as CCHV:
      CALL GSVOLU('CCH7','TUBE',44,PAR_CCH5,3,IVOL)
      CALL GSVOLU('CCHX','TUBE',44,PAR_CCHV,3,IVOL)
      CALL GSVOLU('CCH8','PCON',6,PAR_CCH8,9,IVOL)
      CALL GSVOLU('CCH9','TUBE',6,PAR_CCH9,3,IVOL)
      CALL GSVOLU('CCH0','TUBE',6,PAR_CCH0,3,IVOL)

      CALL GSPOS('CCH1',1,'CCMO',0.0000,0.0000,-1.4859,0,'ONLY')
      CALL GSPOS('CCH2',1,'CCMO',0.0000,0.0000,-1.1430,0,'ONLY')
      CALL GSPOS('CCH3',1,'CCMO',0.0000,0.0000,0.3429,0,'ONLY')
      CALL GSPOS('CCH4',1,'CCMO',0.0000,0.0000,-1.3589,0,'ONLY')
      CALL GSPOS('CCH5',1,'CCMO',0.0000,0.0000,-1.2573,0,'ONLY')
      CALL GSPOS('CCH6',1,'CCMO',0.0000,0.0000,-1.1819,0,'ONLY')
      CALL GSPOS('CCH7',1,'CCMO',0.0000,0.0000,-1.1062,0,'ONLY')
      CALL GSPOS('CCH8',1,'CCMO',0.0000,0.0000,0.0000,0,'ONLY')
      CALL GSPOS('CCH9',1,'CCMO',0.0000,0.0000,-1.0427,0,'ONLY')
      CALL GSPOS('CCH0',1,'CCMO',0.0000,0.0000,-0.7620,0,'ONLY')
c Make CCMP: version with smaller I.D. rings (see above):
      CALL GSPOS('CCH1',1,'CCMP',0.0000,0.0000,-1.4859,0,'ONLY')
      CALL GSPOS('CCH2',1,'CCMP',0.0000,0.0000,-1.1430,0,'ONLY')
      CALL GSPOS('CCH3',1,'CCMP',0.0000,0.0000,0.3429,0,'ONLY')
      CALL GSPOS('CCH4',1,'CCMP',0.0000,0.0000,-1.3589,0,'ONLY')
      CALL GSPOS('CCHV',1,'CCMP',0.0000,0.0000,-1.2573,0,'ONLY')
      CALL GSPOS('CCHW',1,'CCMP',0.0000,0.0000,-1.1819,0,'ONLY')
      CALL GSPOS('CCHX',1,'CCMP',0.0000,0.0000,-1.1062,0,'ONLY')
      CALL GSPOS('CCH8',1,'CCMP',0.0000,0.0000,0.0000,0,'ONLY')
      CALL GSPOS('CCH9',1,'CCMP',0.0000,0.0000,-1.0427,0,'ONLY')
      CALL GSPOS('CCH0',1,'CCMP',0.0000,0.0000,-0.7620,0,'ONLY')
      END
c-----------------------------------------------------------------------

      SUBROUTINE POSCYL
c this subroutine positions the cylinders into the mother of the top(CCMH)
c G3 and G7 have small IDs on their graded-z rings, so get another object:

       dimension centx(9),centy(9)
       common/centers/centx,centy
       do i=1,9
          if (i .EQ. 3 .or. i .eq. 7) then 
           CALL GSPOS('CCMP',i,'CCMH',centx(i),centy(i),0.0000,0,'ONLY')
          else
           CALL GSPOS('CCMO',i,'CCMH',centx(i),centy(i),0.0000,0,'ONLY')
          end if
       end do
       end
 
c-----------------------------------------------------------------------
      SUBROUTINE SHELL
c this subroutine creates and positions the spherical shell that is part of the
c top plate

      DIMENSION PAR_CCHS(6)
      DATA PAR_CCHS/96.2025,96.3549,0.0,14.4,0.0,360./
      CALL GSVOLU('CCHS','SPHE',6,PAR_CCHS,6,IVOL)
      CALL GSPOS('CCHS',1,'CCMH',0.0000,0.0000,-94.7674,0,'MANY')
      END

c-----------------------------------------------------------------------
      SUBROUTINE GRADEDZ
c The graded-z top shield (coffin-shaped like the coldplate, with
c lots of holes).  We will use a many/only rather than mother/daughter
c formalism for the holes, since some holes overlap the two halves
c of the "coffin".  Shapes are similar to "coldplate-plate".

      DIMENSION PAR_CGZA(4),PAR_CGZB(4),PAR_CGZC(4),PAR_CGZD(4),
     .          PAR_CGZE(4),PAR_CGZF(4),PAR_CGZG(4),PAR_CGZH(4),
     .          par_cgz0(3),par_cgzi(3),par_cgzj(3),par_cgzk(3),
     .          par_cgzl(3),par_cgzm(3),par_cgzn(3)
      DIMENSION centx(9),centy(9),gzkx(7),gzky(7),gzlx(8),gzly(8)

      common/centers/centx,centy

c  Mother      
      data par_cgz0/0.0,25.0,0.108/
c Holes of various sizes:
      data par_cgzi/0.0,3.90650,0.108/
      data par_cgzj/0.0,1.50000,0.108/
      data par_cgzk/0.0,0.39624,0.108/
      data par_cgzl/0.0,0.47752,0.108/
      data par_cgzm/0.0,0.45314,0.108/
      data par_cgzn/0.0,0.79502,0.108/
      data gzkx/-10.69,-10.69,-9.18,0.737,9.18,
     .           10.62,10.62/
      data gzky/8.45,  9.78,  9.15, 17.29, 9.15,  9.78, 8.45/
      data gzlx/0.000000,0.000000,0.000000,0.000000,-15.60,
     .          20.35,15.6,11.07/
      data gzly/-1.46, -9.41,-11.77,-15.40,-5.11, 4.71, -5.11,-12.73/


      DATA PAR_CGZA/22.50,11.06,0.00635,7.132/ 
      DATA PAR_CGZB/22.50,8.76808,0.00635,13.318/ 

      DATA PAR_CGZC/22.50,11.06,0.0254,7.132/ 
      DATA PAR_CGZD/22.50,8.76808,0.0254,13.318/ 

      DATA PAR_CGZE/22.50,11.06,0.0508,7.132/ 
      DATA PAR_CGZF/22.50,8.76808,0.0508,13.318/ 

      DATA PAR_CGZG/22.50,11.06,0.0254,7.132/ 
      DATA PAR_CGZH/22.50,8.76808,0.0254,13.318/ 
 
c Mother for the upper graded-z shielding:
      call gsvolu('CGZ0','TUBE',3,par_cgz0,3,IVOL)
      CALL GSPOS('CGZ0',1,'C000',0.0,0.0,16.948,0,'ONLY')

c The shield trapezoids:
      CALL GSVOLU('CGZA','TRD1',3,PAR_CGZA,4,IVOL)
      CALL GSVOLU('CGZB','TRD1',3,PAR_CGZB,4,IVOL)
      CALL GSVOLU('CGZC','TRD1',44,PAR_CGZC,4,IVOL)
      CALL GSVOLU('CGZD','TRD1',44,PAR_CGZD,4,IVOL)
      CALL GSVOLU('CGZE','TRD1',43,PAR_CGZE,4,IVOL)
      CALL GSVOLU('CGZF','TRD1',43,PAR_CGZF,4,IVOL)
      CALL GSVOLU('CGZG','TRD1',3,PAR_CGZG,4,IVOL)
      CALL GSVOLU('CGZH','TRD1',3,PAR_CGZH,4,IVOL)
 
      CALL GSPOS('CGZA',1,'CGZ0',0.00000,12.732,0.10165,13,'MANY') 
      CALL GSPOS('CGZB',1,'CGZ0',0.00000,-7.718,0.10165,14,'MANY') 
      CALL GSPOS('CGZC',1,'CGZ0',0.00000,12.732,0.0699,13,'MANY') 
      CALL GSPOS('CGZD',1,'CGZ0',0.00000,-7.718,0.0699,14,'MANY') 
      CALL GSPOS('CGZE',1,'CGZ0',0.00000,12.732,-.0063,13,'MANY') 
      CALL GSPOS('CGZF',1,'CGZ0',0.00000,-7.718,-.0063,14,'MANY') 
      CALL GSPOS('CGZG',1,'CGZ0',0.00000,12.732,-.0825,13,'MANY') 
      CALL GSPOS('CGZH',1,'CGZ0',0.00000,-7.718,-.0825,14,'MANY') 

c The holes for the detectors:
      call gsvolu('CGZI','TUBE',1,par_cgzi,3,IVOL)
      do i=1,9
         call gspos('CGZI',i,'CGZ0',centx(i),centy(i),0.,0,'ONLY')
      end do

c The hole for the scatterer:
      call gsvolu('CGZJ','TUBE',1,par_cgzj,3,IVOL)
      call gspos('CGZJ',1,'CGZ0',0.0,-6.4,0.,0,'ONLY')

c Various little holes:
      call gsvolu('CGZK','TUBE',1,par_cgzk,3,IVOL)
      call gsvolu('CGZL','TUBE',1,par_cgzl,3,IVOL)
      call gsvolu('CGZM','TUBE',1,par_cgzm,3,IVOL)
      call gsvolu('CGZN','TUBE',1,par_cgzn,3,IVOL)
      do i=1,7
         call gspos('CGZK',i,'CGZ0',gzkx(i),gzky(i),0.,0,'ONLY')
      end do
      do i=1,8
         call gspos('CGZL',i,'CGZ0',gzlx(i),gzly(i),0.,0,'ONLY')
      end do
      call gspos('CGZM',1,'CGZ0',6.48,6.74,0.,0,'ONLY')
      call gspos('CGZN',1,'CGZ0',15.3,-8.34,0.,0,'ONLY')
      call gspos('CGZN',2,'CGZ0',-15.3,-8.34,0.,0,'ONLY')
      

      END

c-----------------------------------------------------------------------
      SUBROUTINE POS_TOPPLATE
c position the cryostat top plate
      CALL GSPOS('CCMH',1,'C000',0.0,0.0,15.25,0,'ONLY')
      END
c-----------------------------------------------------------------------

      
      SUBROUTINE HOUSE
 
c all parts for the cryocooler, cryocooler housing and associated parts start
c with cy##, where ## are two numbers that suffix cy
 
 
      DIMENSION PAR_CY01(5),PAR_CY02(3),PAR_CY03(3),
     +          PAR_CY04(3),PAR_CY05(3),PAR_CY06(3),PAR_CY07(3),
     +          PAR_CY08(3),PAR_CY09(3),PAR_CY10(5),PAR_CY11(3),
     +          PAR_CY12(3),PAR_CY13(3)
 
      DATA PAR_CY01/4.3180,4.4704,14.7008,0.0000,180.0/
      DATA PAR_CY02/0.0762,14.7008,1.7780/
      DATA PAR_CY03/0.3175,13.8925,2.9337/
      DATA PAR_CY04/0.5782,13.8925,0.3586/
      DATA PAR_CY05/0.4889,16.0338,0.3175/
      DATA PAR_CY06/0.5782,0.3586,1.2880/
      DATA PAR_CY07/0.5782,0.2390,1.7973/
      DATA PAR_CY08/0.5782,0.2390,2.3823/
      DATA PAR_CY09/0.5782,0.2390,2.9690/
      DATA PAR_CY10/0.0000,4.4704,0.0762,0.0000,180.0/
      DATA PAR_CY11/4.4704,0.0762,1.7780/
      DATA PAR_CY12/0.7303,0.3175,4.0132/
      DATA PAR_CY13/5.2959,0.3175,0.3175/
 
 
      CALL GSVOLU('CY01','TUBS',6,PAR_CY01,5,IVOL)
      CALL GSVOLU('CY02','BOX ',6,PAR_CY02,3,IVOL)
      CALL GSVOLU('CY03','BOX ',6,PAR_CY03,3,IVOL)
      CALL GSVOLU('CY04','BOX ',6,PAR_CY04,3,IVOL)
      CALL GSVOLU('CY05','BOX ',6,PAR_CY05,3,IVOL)
      CALL GSVOLU('CY06','BOX ',6,PAR_CY06,3,IVOL)
      CALL GSVOLU('CY07','BOX ',6,PAR_CY07,3,IVOL)
      CALL GSVOLU('CY08','BOX ',6,PAR_CY08,3,IVOL)
      CALL GSVOLU('CY09','BOX ',6,PAR_CY09,3,IVOL)
      CALL GSVOLU('CY10','TUBS',6,PAR_CY10,5,IVOL)
      CALL GSVOLU('CY11','BOX ',6,PAR_CY11,3,IVOL)
      CALL GSVOLU('CY12','BOX ',6,PAR_CY12,3,IVOL)
      CALL GSVOLU('CY13','BOX ',6,PAR_CY13,3,IVOL)
  

c add .1875 inches (.47625 cm) to z coordinate of all parts of cryocooler 

      CALL GSPOS('CY01',1,'CCMT',0.0000,-7.3807,-8.98525,32,'ONLY')

      CALL GSPOS('CY02',1,'CCMT',4.3942,-7.3807,-10.76325,0,'ONLY')
      CALL GSPOS('CY02',2,'CCMT',-4.3942,-7.3807,-10.76325,0,'ONLY')

      CALL GSPOS('CY03',1,'CCMT',4.7879,-7.2075,-9.60755,0,'ONLY')
      CALL GSPOS('CY03',2,'CCMT',-4.7879,-7.2075,-9.60755,0,'ONLY')

      CALL GSPOS('CY04',1,'CCMT',4.9022,-7.2075,-6.86435,0,'ONLY')
      CALL GSPOS('CY04',2,'CCMT',-4.9022,-7.2075,-6.86435,0,'ONLY')

      CALL GSPOS('CY05',1,'CCMT',4.8069,-8.7137,-12.22375,0,'ONLY') 
      CALL GSPOS('CY05',2,'CCMT',-4.8069,-8.7137,-12.22375,0,'ONLY')
  
      CALL GSPOS('CY06',1,'CCMT',4.9022,-20.7391,-10.51785,0,'ONLY')
      CALL GSPOS('CY06',2,'CCMT',-4.9022,-20.7391,-10.51785,0,'ONLY')
 
      CALL GSPOS('CY07',1,'CCMT',4.9022,-14.3485,-10.00865,0,'ONLY')
      CALL GSPOS('CY07',2,'CCMT',-4.9022,-14.3485,-10.00865,0,'ONLY')
 
      CALL GSPOS('CY08',1,'CCMT',4.9022,-6.8191,-9.41335,0,'ONLY')
      CALL GSPOS('CY08',2,'CCMT',-4.9022,-6.8191,-9.41335,0,'ONLY')
 
      CALL GSPOS('CY09',1,'CCMT',4.9022,0.8421,-8.83795,0,'ONLY')
      CALL GSPOS('CY09',2,'CCMT',-4.9022,0.8421,-8.83795,0,'ONLY')
 
      CALL GSPOS('CY10',1,'CCMT',0.0000,7.3962,-8.98525,32,'ONLY')
      CALL GSPOS('CY10',2,'CCMT',0.0000,-22.1577,-8.98525,32,'ONLY')
 
      CALL GSPOS('CY11',1,'CCMT',0.0000,7.3962,-10.76325,0,'ONLY')
      CALL GSPOS('CY11',2,'CCMT',0.0000,-22.1577,-10.76325,0,'ONLY')
 
      CALL GSPOS('CY12',1,'CCMT',4.5656,7.0025,-8.52805,0,'ONLY')
      CALL GSPOS('CY12',2,'CCMT',-4.5656,7.0025,-8.52805,0,'ONLY')
 
      CALL GSPOS('CY13',1,'CCMT',0.0000,7.0025,-4.49735,0,'ONLY')
      CALL GSPOS('CY13',2,'CCMT',0.0000,7.0025,-12.02375,0,'ONLY')
 
      END
 
c-----------------------------------------------------------------------
      SUBROUTINE COOLER
 
      DIMENSION PAR_CY14(3),PAR_CY15(9),PAR_CY16(3),PAR_CY17(3),
     +          PAR_CY18(9),PAR_CY19(3),PAR_CY20(3),PAR_CY21(3)
 
 
      DATA PAR_CY14/0.0000,3.8900,10.0000/
      DATA PAR_CY15/0.0000,360.0,2.0,
     +              -0.4341,0.0000,3.2067,
     +               0.4341,0.0000,3.8900/
      DATA PAR_CY16/0.0000,3.2067,0.0930/
      DATA PAR_CY17/0.0000,3.1305,1.6065/
      DATA PAR_CY18/0.0000,360.0,2.0,
     +              -0.0775,0.0000,2.7432,
     +               0.0775,0.0000,2.1653/
      DATA PAR_CY21/0.0000,2.1653,0.5728/
      DATA PAR_CY19/0.0000,2.7432,0.1524/
      DATA PAR_CY20/0.0000,1.2700,4.1694/
 
      CALL GSVOLU('CY14','TUBE',57,PAR_CY14,3,IVOL)
      CALL GSVOLU('CY15','PCON',57,PAR_CY15,9,IVOL)
      CALL GSVOLU('CY16','TUBE',57,PAR_CY16,3,IVOL)
      CALL GSVOLU('CY17','TUBE',57,PAR_CY17,3,IVOL)
      CALL GSVOLU('CY18','PCON',57,PAR_CY18,9,IVOL)
      CALL GSVOLU('CY19','TUBE',57,PAR_CY19,3,IVOL)
      CALL GSVOLU('CY20','TUBE',57,PAR_CY20,3,IVOL)
      CALL GSVOLU('CY21','TUBE',57,PAR_CY21,3,IVOL)
 
      CALL GSPOS('CY14',1,'CCMT',0.0000,-10.5783,-8.98525,32,'0NLY')
      CALL GSPOS('CY15',1,'CCMT',0.0000,-0.1443,-8.98525,32,'ONLY')
      CALL GSPOS('CY16',1,'CCMT',0.0000,0.3828,-8.98525,32,'ONLY')
      CALL GSPOS('CY17',1,'CCMT',0.0000,2.0823,-8.98525,32,'ONLY')
      CALL GSPOS('CY18',1,'CCMT',0.0000,4.9119,-8.98525,32,'ONLY')
      CALL GSPOS('CY19',1,'CCMT',0.0000,5.1417,-8.98525,32,'ONLY')
      CALL GSPOS('CY20',1,'CCMT',0.0000,9.4635,-8.98525,32,'ONLY')
      CALL GSPOS('CY21',1,'CCMT',0.0000,4.2616,-8.98525,32,'ONLY')
      
      END

c-----------------------------------------------------------------------
       SUBROUTINE COOLER_LEGS
      DIMENSION PAR_CY22(4),PAR_CY23(4),PAR_CY24(3),PAR_CY25(3),
     +          PAR_CY26(4)
 
 
 
      DATA PAR_CY22/3.6322,0.1101,0.2015,4.0909/
c for leg on other side switch DX1 and DX2, call CY26
      DATA PAR_CY23/8.1305,0.2776,0.2015,1.4910/
      DATA PAR_CY24/8.8057,0.4762,0.3810/
      DATA PAR_CY25/9.4143,0.4762,0.3810/
c other leg
      DATA PAR_CY26/0.1101,3.6322,0.2015,4.0909/
 
 
      CALL GSVOLU('CY22','TRD1',6,PAR_CY22,4,IVOL)
      CALL GSVOLU('CY23','TRD1',6,PAR_CY23,4,IVOL)
      CALL GSVOLU('CY24','BOX ',6,PAR_CY24,3,IVOL)
      CALL GSVOLU('CY25','BOX ',6,PAR_CY25,3,IVOL)
      CALL GSVOLU('CY26','TRD1',6,PAR_CY26,4,IVOL)
 
      CALL GSPOS('CY22',1,'CCMT',9.3355,7.0025,-8.62205,33,'ONLY')
      CALL GSPOS('CY23',1,'CCMT',13.7861,7.0025,-10.33095,0,'ONLY')
      CALL GSPOS('CY24',1,'CCMT',14.0503,7.0025,-12.16025,0,'ONLY')
      CALL GSPOS('CY25',1,'CCMT',13.8557,7.0025,-8.33755,34,'ONLY')
 
C CY26 is the mirror image of CY22;  need to define new volume
c because this is a trapezoid
      CALL GSPOS('CY26',1,'CCMT',-9.3355, 7.0025,-8.62205,33,'ONLY')
      CALL GSPOS('CY23',2,'CCMT',-13.7861,7.0025,-10.33095,0,'ONLY')
      CALL GSPOS('CY24',2,'CCMT',-14.0503,7.0025,-12.16025,0,'ONLY')
      CALL GSPOS('CY25',2,'CCMT',-13.8557,7.0025,-8.33755,35,'ONLY')
 
      END
c-----------------------------------------------------------------------
 
      SUBROUTINE N2_TUBES
c this subroutine creates the tubes leading out of the nitrogen tank

       DIMENSION PAR_CT01(3),PAR_CT02(3),PAR_CT03(3),
     +           PAR_CT04(3),PAR_CT05(3),PAR_CT07(3),PAR_CT08(3)


      DATA PAR_CT01/0.2413,0.3175,2.9718/
      DATA PAR_CT02/0.2413,0.3175,3.5496/
      DATA PAR_CT03/0.2413,0.3175,3.9687/
      DATA PAR_CT04/0.2413,0.3175,4.2863/
      DATA PAR_CT05/0.2413,0.3175,4.3378/
      DATA PAR_CT07/0.2413,0.3175,5.080/
      DATA PAR_CT08/0.2413,0.3175,5.842/

      CALL GSVOLU('CT01','TUBE',3,PAR_CT01,3,IVOL)
      CALL GSVOLU('CT02','TUBE',3,PAR_CT02,3,IVOL)
      CALL GSVOLU('CT03','TUBE',3,PAR_CT03,3,IVOL)
      CALL GSVOLU('CT04','TUBE',3,PAR_CT04,3,IVOL)
      CALL GSVOLU('CT05','TUBE',3,PAR_CT05,3,IVOL)
c CT06 is identical to CT05
      CALL GSVOLU('CT07','TUBE',3,PAR_CT07,3,IVOL)
      CALL GSVOLU('CT08','TUBE',3,PAR_CT08,3,IVOL)
 

      CALL GSPOS('CT01',1,'CCMT',-1.2700,-4.1018,-2.9464,36,'ONLY')
      CALL GSPOS('CT02',1,'CCMT',1.2700,-4.7368,-2.9464,36,'ONLY')
      CALL GSPOS('CT03',1,'CCMT',-4.9212,-7.7059,-2.9464,33,'ONLY')
      CALL GSPOS('CT04',1,'CCMT',-2.6987,-8.9759,-2.9464,33,'ONLY')
      CALL GSPOS('CT05',1,'CCMT',-8.8900,-7.7059,-7.6017,0,'ONLY')
      CALL GSPOS('CT05',2,'CCMT',-6.9850,-8.9759,-7.6017,0,'ONLY')
      CALL GSPOS('CT08',1,'CCMT',-8.8900,-12.7000,-9.223,37,'ONLY')
      CALL GSPOS('CT07',1,'CCMT',-6.9850,-13.3350,-9.906,37,'ONLY')

      END

c-----------------------------------------------------------------------
c now put in N2 ports

      SUBROUTINE N2_PORT

      DIMENSION PAR_CT09(3),PAR_CT10(3),PAR_CT11(3),PAR_CT12(3),
     +          PAR_CT13(3),PAR_CT14(3),PAR_CT15(3),PAR_CT16(3),
     +          PAR_CT17(3)

      DATA PAR_CT09/0.2413,0.3175,2.9/
      DATA PAR_CT10/0.2413,0.3175,3.2/
      DATA PAR_CT11/0.3175,0.5334,1.1049/
      DATA PAR_CT12/1.5748,1.8639,1.016/
      DATA PAR_CT13/0.5695,0.6350,2.50/
      DATA PAR_CT14/0.2413,0.3175,.98316/
      DATA PAR_CT15/0.2413,0.3175,1.7686/
      DATA PAR_CT16/0.5695,0.6350,2.50/
      DATA PAR_CT17/1.5748,1.8639,1.0795/

      CALL GSVOLU('CT09','TUBE',3,PAR_CT09,3,IVOL)
      CALL GSVOLU('CT10','TUBE',3,PAR_CT10,3,IVOL)
      CALL GSVOLU('CT11','TUBE',3,PAR_CT11,3,IVOL)
      CALL GSVOLU('CT12','TUBE',3,PAR_CT12,3,IVOL)
      CALL GSVOLU('CT13','TUBE',3,PAR_CT13,3,IVOL)
      CALL GSVOLU('CT14','TUBE',3,PAR_CT14,3,IVOL)
      CALL GSVOLU('CT15','TUBE',3,PAR_CT15,3,IVOL)
      CALL GSVOLU('CT16','TUBE',3,PAR_CT16,3,IVOL)
      CALL GSVOLU('CT17','TUBE',3,PAR_CT17,3,IVOL)

c shortened CT09 and added on to it CT14; shortened CT10 and added
c CT15 to it;shorten CT13 and add CT16 on to it; shorten CT12 and add
c CT16 to it;  The purpose is to 
c make no parts in the cryostat unit protrude through CCMT

      CALL GSPOS('CT09',1,'CCMT',-8.8900,-21.1399,-7.0020,36,'ONLY')
      CALL GSPOS('CT10',1,'CCMT',-6.9850,-21.3267,-7.0020,36,'ONLY')
      CALL GSPOS('CT11',1,'CCMT',-8.8900,-27.1112,-7.0020,36,'ONLY')
      CALL GSPOS('CT11',2,'C000',-6.9850,-29.4099,-7.0020,36,'ONLY')
      CALL GSPOS('CT12',1,'C000',-7.9502,-22.45,-7.0020,36,'ONLY')
      CALL GSPOS('CT13',1,'CCMT',-8.8900,-20.886,-7.0020,36,'ONLY')
      CALL GSPOS('CT13',2,'CCMT',-6.9850,-20.886,-7.0020,36,'ONLY')
      CALL GSPOS('CT14',1,'C000',-8.8900,-26.1581,-7.0020,36,'ONLY')
      CALL GSPOS('CT15',1,'C000',-6.985,-27.429,-7.002,36,'ONLY')
      CALL GSPOS('CT16',1,'C000',-8.89,-27.94,-7.002,36,'ONLY')
      CALL GSPOS('CT16',2,'C000',-6.985,-28.575,-7.002,36,'ONLY')
      CALL GSPOS('CT17',1,'C000',-7.9502,-27.20,-7.002,36,'ONLY')
      END
c-----------------------------------------------------------------------
 
      SUBROUTINE INNER_SHIELD
      DIMENSION PAR_CI01(3),PAR_CI02(3),PAR_CI03(3),PAR_CI04(3),
     +          PAR_CI05(4),PAR_CI06(4),PAR_CI07(3),PAR_CI08(3),
     +          PAR_CI23(3),PAR_CI10(3),PAR_CI24(3),PAR_CI09(3)

      DATA PAR_CI01/0.0254,8.5583,6.7056/
      DATA PAR_CI02/10.6434,0.0254,6.7056/
      DATA PAR_CI03/0.0254,14.2806,6.7056/
      DATA PAR_CI04/8.8105,0.0254,6.7056/
      DATA PAR_CI05/21.3169,10.6190,0.0254,6.6863/
      DATA PAR_CI06/8.7787,21.3169,0.0254,12.7954/
      DATA PAR_CI07/0.0000,3.050,0.0254/
      DATA PAR_CI08/0.0000,3.0480,0.0063/
      DATA PAR_CI09/0.0000,1.7000,0.0063/
      DATA PAR_CI10/0.0000,1.7000,0.0254/
      DATA PAR_CI23/0.0,3.048,.01016/    
      DATA PAR_CI24/0.0,1.7000,.01016/   

      CALL GSVOLU('CI01','BOX ',59,PAR_CI01,3,IVOL)
      CALL GSVOLU('CI02','BOX ',59,PAR_CI02,3,IVOL)
      CALL GSVOLU('CI03','BOX ',59,PAR_CI03,3,IVOL)
      CALL GSVOLU('CI04','BOX ',59,PAR_CI04,3,IVOL)
      CALL GSVOLU('CI05','TRD1',59,PAR_CI05,4,IVOL)
      CALL GSVOLU('CI06','TRD1',59,PAR_CI06,4,IVOL)
c 'CI07' is mother region for CI08 and CI23; 'CI07' is mostly vacuum
      CALL GSVOLU('CI07','TUBE',1,PAR_CI07,3,IVOL)
c 'CI10' is mother region for CI09 and CI24; 'CI10' is mostly vacuum
      CALL GSVOLU('CI10','TUBE',1,PAR_CI10,3,IVOL)
c 'CI08' is Be window
      CALL GSVOLU('CI08','TUBE',9,PAR_CI08,3,IVOL)
c 'CI09' is Be window for Be scatterer
      CALL GSVOLU('CI09','TUBE',9,PAR_CI09,3,IVOL)
c 'CI24' is Mylar in Be hole in top of inner shield      
      CALL GSVOLU('CI24','TUBE',42,PAR_CI24,3,IVOL)


      CALL GSPOS('CI01',1,'CCMT',-15.9675,12.3474,5.1054,38,'ONLY')
      CALL GSPOS('CI01',2,'CCMT',15.9675,12.3474,5.1054,39,'ONLY')
      CALL GSPOS('CI02',1,'CCMT',0.0000,19.0177,5.1054,0,'ONLY')
      CALL GSPOS('CI03',1,'CCMT',15.0762,-7.1755,5.1054,40,'ONLY')
      CALL GSPOS('CI03',2,'CCMT',-15.0762,-7.1755,5.1054,41,'ONLY')
      CALL GSPOS('CI04',1,'CCMT',0.0000,-19.9964,5.1054,0,'ONLY')
      CALL GSPOS('CI05',1,'CCMT',0.0000,12.3314,11.8364,13,'MANY')
      CALL GSPOS('CI06',1,'CCMT',0.0000,-7.2009,11.8364,13,'MANY')

c put Be windows into 'CI07' and place 'CI07' into 'CCMT'
      CALL GSPOS('CI08',1,'CI07',0.0000,0.0000,-.0075,0,'ONLY')

c 'CI23' is Mylar in holes in top of inner shield -- we currently don't
c   include it, but call it in another part of the response matrix.
c      CALL GSVOLU('CI23','TUBE',42,PAR_CI23,3,IVOL)
c      CALL GSPOS('CI23',1,'CI07',0.0,0.0,.002,0,'ONLY') 

      CALL GSPOS('CI07',1,'CCMT',-8.2393,14.0409,11.8364,0,'ONLY')
      CALL GSPOS('CI07',2,'CCMT',8.2393,14.0409,11.8364,0,'ONLY')
      CALL GSPOS('CI07',3,'CCMT',15.4737,4.9977,11.8364,0,'ONLY')
      CALL GSPOS('CI07',4,'CCMT',0.0000,5.8016,11.8364,0,'ONLY')
      CALL GSPOS('CI07',5,'CCMT',-15.4737,4.9977,11.8364,0,'ONLY')
      CALL GSPOS('CI07',6,'CCMT',-7.4353,-3.0404,11.8364,0,'ONLY')
      CALL GSPOS('CI07',7,'CCMT',7.4353,-3.0404,11.8364,0,'ONLY')
      CALL GSPOS('CI07',8,'CCMT',5.6769,-14.9972,11.8364,0,'ONLY')
      CALL GSPOS('CI07',9,'CCMT',-5.6769,-14.9972,11.8364,0,'ONLY')

c put Be window into 'CI10' and place 'CI10' into 'CCMT'
      CALL GSPOS('CI09',1,'CI10',0.0000,0.0000,-.0075,0,'ONLY')
      CALL GSPOS('CI24',1,'CI10',0.0,0.0,.002,0,'ONLY') 
      CALL GSPOS('CI10',1,'CCMT',0.0,-6.4,11.8364,0,'ONLY')

      END

c-----------------------------------------------------------------------
      SUBROUTINE OUTER_SHIELD
      DIMENSION PAR_CI11(3),PAR_CI12(3),PAR_CI13(3),PAR_CI14(3),
     +          PAR_CI15(3),PAR_CI16(4),PAR_CI17(4),PAR_CI18(3),
     +          PAR_CI19(3),PAR_CI21(3),PAR_CI22(3)

      DATA PAR_CI11/0.0254,8.8694,8.2804/
      DATA PAR_CI12/11.4201,0.0254,8.2804/
      DATA PAR_CI13/5.9690,0.0254,4.4704/
      DATA PAR_CI14/0.0254,14.6548,8.2804/
      DATA PAR_CI15/9.5118,0.0254,8.2804/
      DATA PAR_CI16/22.1242,11.3692,0.0254,6.9847/
      DATA PAR_CI17/9.4611,22.1242,0.0254,13.1839/
      DATA PAR_CI18/0.0254,4.5212,4.4704/
      DATA PAR_CI19/5.9690,4.5212,0.0254/     
      DATA PAR_CI21/0.0000,3.048,0.008255/
      DATA PAR_CI22/0.0000,3.050,0.0254/
c CI11,CI12,CI14,CI15 are the sides. 
c CI13,CI18,CI19,CI20 are the notch; CI20 must be vacuum.
c CI16,CI17 are the top and bottom.
c CI21 is mylar

      CALL GSVOLU('CI11','BOX ',58,PAR_CI11,3,IVOL)
      CALL GSVOLU('CI12','BOX ',58,PAR_CI12,3,IVOL)
      CALL GSVOLU('CI13','BOX ',58,PAR_CI13,3,IVOL)
      CALL GSVOLU('CI14','BOX ',58,PAR_CI14,3,IVOL)
      CALL GSVOLU('CI15','BOX ',58,PAR_CI15,3,IVOL)
      CALL GSVOLU('CI16','TRD1',58,PAR_CI16,4,IVOL)
      CALL GSVOLU('CI17','TRD1',58,PAR_CI17,4,IVOL)
      CALL GSVOLU('CI18','BOX ',58,PAR_CI18,3,IVOL)
      CALL GSVOLU('CI19','BOX ',58,PAR_CI19,3,IVOL)

c CI20 has same shape parameters as CI19 but made out of vacuum.CI20 is
c part of the bottom that should be vacuum(top of notch)
      CALL GSVOLU('CI20','BOX ',1,PAR_CI19,3,IVOL)
      CALL GSVOLU('CI22','TUBE',1,PAR_CI22,3,IVOL)

      CALL GSPOS('CI11',1,'CCMT',-16.7721,12.5857,4.2799,38,'ONLY')
      CALL GSPOS('CI11',2,'CCMT',16.7721,12.5857,4.2799,39,'ONLY')
      CALL GSPOS('CI12',1,'CCMT',0.0000,19.7035,4.2799,0,'ONLY')
      CALL GSPOS('CI13',1,'CCMT',-0.8890,19.7035,-8.4084,0,'ONLY')
      CALL GSPOS('CI14',1,'CCMT',15.8181,-7.4041,4.2799,40,'ONLY')
      CALL GSPOS('CI14',2,'CCMT',-15.8181,-7.4041,4.2799,41,'ONLY')
      CALL GSPOS('CI15',1,'CCMT',0.0000,-20.6822,4.2799,0,'ONLY')
c position top
      CALL GSPOS('CI16',1,'CCMT',0.0000,12.7188,12.5857,13,'MANY')
      CALL GSPOS('CI17',1,'CCMT',0.0000,-7.4994,12.5857,13,'MANY')

c put in Be windows, use same shape parameter as before; CI08 is Be window.

c We currently do not put Mylar into CI22; we cover it in another part of
c  the response matrix generator
c      CALL GSVOLU('CI21','TUBE',42,PAR_CI21,3,IVOL)      
c      CALL GSPOS('CI21',2,'CI22',0.,0.,0.0,0,'ONLY')

      CALL GSPOS('CI08',1,'CI22',0.0000,0.0000,-.0075,0,'ONLY')
 
      CALL GSPOS('CI22',1,'CCMT',-8.2393,14.0409,12.5857,0,'ONLY')
      CALL GSPOS('CI22',2,'CCMT',8.2393,14.0409,12.5857,0,'ONLY')
      CALL GSPOS('CI22',3,'CCMT',15.4737,4.9977,12.5857,0,'ONLY')
      CALL GSPOS('CI22',4,'CCMT',0.0000,5.8016,12.5857,0,'ONLY')
      CALL GSPOS('CI22',5,'CCMT',-15.4737,4.9977,12.5857,0,'ONLY')
      CALL GSPOS('CI22',6,'CCMT',-7.4353,-3.0404,12.5857,0,'ONLY')
      CALL GSPOS('CI22',7,'CCMT',7.4353,-3.0404,12.5857,0,'ONLY')
      CALL GSPOS('CI22',8,'CCMT',5.6769,-14.9972,12.5857,0,'ONLY')
      CALL GSPOS('CI22',9,'CCMT',-5.6769,-14.9972,12.5857,0,'ONLY')

c put Be window assembly 'CI10' defined in INNER_SHIELD into 'CCMT'
      CALL GSPOS('CI10',2,'CCMT',0.0,-6.4,12.5857,0,'ONLY')

c position bottom; same shape parameters as top

      CALL GSPOS('CI16',2,'CCMT',0.0000,12.7188,-4.0259,13,'MANY')
      CALL GSPOS('CI17',2,'CCMT',0.0000,-7.4994,-4.0259,13,'ONLY')

c put in notch; 3 sides, 1 bottom

      CALL GSPOS('CI18',1,'CCMT',5.1054,15.1315,-8.4084,0,'ONLY')
      CALL GSPOS('CI18',2,'CCMT',-6.8834,15.1315,-8.4084,0,'ONLY')
c this copy of CI13 has the cooler going through it, hence it is a 'MANY'
      CALL GSPOS('CI13',2,'CCMT',-0.8890,10.5595,-8.4084,0,'MANY')
      CALL GSPOS('CI19',1,'CCMT',-0.8890,15.1315,-12.9042,0,'ONLY')
      CALL GSPOS('CI20',1,'CCMT',-0.8890,15.1315,-4.0259,0,'ONLY')
      END

c----------------------------------------------------------------------

      SUBROUTINE SLINK

c this is the S Link that the sapphire piece is attached to

      DIMENSION PAR_CB01(3),PAR_CB02(3),PAR_CB03(3),PAR_CB04(3),
     +          PAR_CB05(3),PAR_CB06(3)

c Where Dan put this overlaps a FET package, so we`re shrinking & moving
c it a bit.
c OLD:      DATA PAR_CB01/5.3071,2.3843,0.4127/
      DATA PAR_CB01/5.09,2.3843,0.4127/
      DATA PAR_CB02/0.7965,4.8810,0.5715/
      DATA PAR_CB03/1.0025,1.0160,1.6921/
      DATA PAR_CB04/0.6350,1.0160,1.5748/
      DATA PAR_CB05/1.8491,3.2408,2.8702/
      DATA PAR_CB06/1.8288,3.9641,0.1460/
 
      CALL GSVOLU('CB01','BOX ',6,PAR_CB01,3,IVOL)
      CALL GSVOLU('CB02','BOX ',64,PAR_CB02,3,IVOL)
      CALL GSVOLU('CB03','BOX ',6,PAR_CB03,3,IVOL)
      CALL GSVOLU('CB04','BOX ',6,PAR_CB04,3,IVOL)
      CALL GSVOLU('CB05','BOX ',63,PAR_CB05,3,IVOL)
      CALL GSVOLU('CB06','BOX ',6,PAR_CB06,3,IVOL)

c OLD: CALL GSPOS('CB01',1,'CCMT',-0.8890,13.3350,-2.1590,0,'ONLY')
      CALL GSPOS('CB01',1,'CCMT',0.0,13.3350,-2.1590,0,'ONLY')
      CALL GSPOS('CB02',1,'CCMT',-2.6543,13.9700,-3.1432,0,'ONLY')
      CALL GSPOS('CB03',1,'CCMT',-1.3271,14.7251,-5.9914,0,'ONLY')
      CALL GSPOS('CB04',1,'CCMT',0.0000,14.7251,-9.2583,0,'ONLY')
      CALL GSPOS('CB05',1,'CCMT',-4.5720,15.1315,-7.6200,0,'ONLY')
      CALL GSPOS('CB06',1,'CCMT',-4.5720,15.1315,-10.6426,0,'ONLY')

      END

c-----------------------------------------------------------------------

      SUBROUTINE LEGS_OUTER
      DIMENSION PAR_CK00(3),PAR_CK01(3),PAR_CK02(3),PAR_CK03(3),
     +          PAR_CK04(3),PAR_CK05(3),PAR_CK06(3),PAR_CK07(4),
     +          PAR_CK08(4),PAR_CK09(3),PAR_CK10(3)

      DATA PAR_CK00/9.5077,0.9528,6.8580/
      DATA PAR_CK01/10.0655,0.9525,0.1587/
      DATA PAR_CK02/0.1587,0.9525,1.4288/
      DATA PAR_CK03/4.6309,0.9525,0.1587/
      DATA PAR_CK04/0.1587,0.9525,1.9050/
      DATA PAR_CK05/4.8768,0.9525,0.1587/
      DATA PAR_CK06/0.1905,0.9525,6.8580/
      DATA PAR_CK07/3.4181,0.0000,0.2779,4.5720/
      DATA PAR_CK08/9.1440,0.0000,0.2779,1.7090/
      DATA PAR_CK09/4.4577,0.2779,1.3184/
      DATA PAR_CK10/4.6863,0.2779,3.0702/


c create mother
      CALL GSVOLU('CK00','BOX ',1,PAR_CK00,3,IVOL)

      CALL GSVOLU('CK01','BOX ',6,PAR_CK01,3,IVOL)
      CALL GSVOLU('CK02','BOX ',6,PAR_CK02,3,IVOL)
      CALL GSVOLU('CK03','BOX ',6,PAR_CK03,3,IVOL)
      CALL GSVOLU('CK04','BOX ',6,PAR_CK04,3,IVOL)
      CALL GSVOLU('CK05','BOX ',6,PAR_CK05,3,IVOL)
      CALL GSVOLU('CK06','BOX ',6,PAR_CK06,3,IVOL)
      CALL GSVOLU('CK07','TRD1',6,PAR_CK07,4,IVOL)
      CALL GSVOLU('CK08','TRD1',6,PAR_CK08,4,IVOL)
      CALL GSVOLU('CK09','BOX ',6,PAR_CK09,3,IVOL)
      CALL GSVOLU('CK10','BOX ',6,PAR_CK10,3,IVOL)


      CALL GSPOS('CK01',1,'CK00',-0.0239,0.0000,3.1852,42,'ONLY')
      CALL GSPOS('CK02',1,'CK00',-9.3200,0.0000,-1.6193,0,'ONLY')
      CALL GSPOS('CK03',1,'CK00',-4.8768,0.0000,-2.8892,0,'ONLY')
      CALL GSPOS('CK04',1,'CK00',-0.4046,0.0000,-4.9530,0,'ONLY')
      CALL GSPOS('CK05',1,'CK00',4.6309,0.0000,-6.6992,0,'ONLY')
      CALL GSPOS('CK06',1,'CK00',9.3175,0.0000,0.0000,0,'ONLY')
      CALL GSPOS('CK07',1,'CK00',4.5547,0.0000,3.0180,43,'ONLY')
      CALL GSPOS('CK08',1,'CK00',-0.0173,0.0000,1.3091,0,'ONLY')
      CALL GSPOS('CK09',1,'CK00',-4.7036,0.0000,-1.7239,0,'ONLY')
      CALL GSPOS('CK10',1,'CK00',4.4404,0.0000,-3.4701,0,'ONLY')

c now position CK00 IN C000

      CALL GSPOS('CK00',1,'C000',30.9268,-17.9299,-7.7470,46,'ONLY')
      CALL GSPOS('CK00',2,'C000',30.9268,17.9299,-7.7470,47,'ONLY')
      CALL GSPOS('CK00',3,'C000',0.0000,35.7856,-7.7470,10,'ONLY')
      CALL GSPOS('CK00',4,'C000',-30.9268,17.9299,-7.7470,44,'ONLY')
      CALL GSPOS('CK00',5,'C000',-30.9268,-17.9299,-7.7470,45,'ONLY')
      CALL GSPOS('CK00',6,'C000',0.0000,-35.7856,-7.7470,8,'ONLY')
      END
c-----------------------------------------------------------------------

      SUBROUTINE PREAMP
      INTEGER N
      REAL ALPHA,R,X,Y,PI,S,X1,Y1
      PARAMETER(PI=3.14159265359)
      DIMENSION PAR_CM01(3),PAR_CM02(3),PAR_CM03(3),
     +          PAR_CM04(3),PAR_CM05(3),PAR_CM06(3),PAR_CM07(3),
     +          PAR_CM09(3),PAR_CM10(3),PAR_CM11(3),PAR_CM12(3)

      DATA PAR_CM01/23.9268,24.0805,6.0642/
      DATA PAR_CM02/24.0805,25.6794,0.3175/
      DATA PAR_CM03/24.0805,25.6794,0.1270/
      DATA PAR_CM04/0.7995,0.9482,6.0642/
      DATA PAR_CM05/1.6429,0.4522,0.5911/
      DATA PAR_CM06/0.1177,0.9402,0.9402/
      DATA PAR_CM07/2.7788,5.0394,1.7272/
      DATA PAR_CM09/1.2700,1.4288,0.8763/
      DATA PAR_CM10/1.2700,1.4288,4.6256/
      DATA PAR_CM11/1.2700,1.4288,1.1430/
      DATA PAR_CM12/1.9050,2.0638,1.4376/

      CALL GSVOLU('CM01','TUBE',6,PAR_CM01,3,IVOL)
      CALL GSVOLU('CM02','TUBE',6,PAR_CM02,3,IVOL)
      CALL GSVOLU('CM03','TUBE',6,PAR_CM03,3,IVOL)
      CALL GSVOLU('CM04','BOX ',6,PAR_CM04,3,IVOL)
      CALL GSVOLU('CM05','BOX ',6,PAR_CM05,3,IVOL)
c define brass feed-thru 
      CALL GSVOLU('CM06','BOX ',62,PAR_CM06,3,IVOL)
c define high voltage box and preamp box;cm07 is preamp,cm08 is high voltage
      CALL GSVOLU('CM07','BOX ',61,PAR_CM07,3,IVOL)
      CALL GSVOLU('CM08','BOX ',60,PAR_CM07,3,IVOL)
c define parts of vacuum port
      CALL GSVOLU('CM09','TUBE',3,PAR_CM09,3,IVOL)
      CALL GSVOLU('CM10','TUBE',3,PAR_CM10,3,IVOL)
      CALL GSVOLU('CM11','TUBE',3,PAR_CM11,3,IVOL)
      CALL GSVOLU('CM12','TUBE',3,PAR_CM12,3,IVOL)


      CALL GSPOS('CM01',1,'CCMT',0.0000,0.0,-6.9532,0,'MANY')
      CALL GSPOS('CM02',1,'CCMT',0.0000,0.0,-1.2065,0,'MANY')
      CALL GSPOS('CM02',2,'CCMT',0.0000,0.0,-12.7000,0,'MANY')
      CALL GSPOS('CM03',1,'CCMT',0.0000,0.0,-9.2456,0,'MANY')
      CALL GSPOS('CM03',2,'CCMT',0.0000,0.0,-5.6007,0,'MANY')

c position the preamp, hv, and 12 'struts' around the preamp
      R=24.8799
      S=29.2100
      ALPHA=75.
      DO N=0,11
        X= -R*SIN(ALPHA*(PI/180))
        Y=R*COS(ALPHA*(PI/180))
        X1=-S*SIN(ALPHA*(PI/180))
        Y1=S*COS(ALPHA*(PI/180))
        CALL GSPOS('CM04',N+1,'CCMT',X,Y,-6.9532,48+N,'MANY')
        IF (ALPHA .NE. -165. .AND. ALPHA .NE. -195. 
     +  .AND. ALPHA .NE. -15. ) THEN
           CALL GSPOS('CM08',N+1,'C000',X1,Y1,-7.4549,48+N,'ONLY')
        END IF
        IF (ALPHA .NE. -195 .AND. ALPHA .NE. -15.) THEN
           CALL GSPOS('CM07',N+1,'C000',X1,Y1,-11.0363,48+N,'ONLY')
        END IF
        ALPHA=ALPHA-30
      END DO

c now position the flanges
      CALL GSPOS('CM05',1,'CCMT',-13.3838,-19.2723,-1.4923,60,'ONLY')
      CALL GSPOS('CM05',2,'CCMT',-23.3180,-2.06629,-1.4923,61,'ONLY')
      CALL GSPOS('CM05',3,'CCMT',-9.9337,21.115,-1.4923,62,'ONLY')
      CALL GSPOS('CM05',4,'CCMT',9.9332,21.1154,-1.4923,63,'ONLY')
      CALL GSPOS('CM05',5,'CCMT',23.317,-2.06629,-1.4923,64,'ONLY')
      CALL GSPOS('CM05',6,'CCMT',13.3838,-19.2720,-1.4923,65,'ONLY')

c position brass feed thrus

      R=25.6794
      ALPHA=70.
      DO N=0,11
        X= -R*SIN(ALPHA*(PI/180))
        Y=R*COS(ALPHA*(PI/180))
        IF (ALPHA .NE. -170. .AND. ALPHA .NE. -200.
     +  .AND. ALPHA .NE. -20.) THEN
           CALL GSPOS('CM06',N+1,'CCMT',X,Y,-7.4549,48+N,'ONLY')
        END IF
        ALPHA=ALPHA-30
      END DO

      ALPHA=70.
      DO N=0,11
        X= -R*SIN(ALPHA*(PI/180))
        Y=R*COS(ALPHA*(PI/180))
        IF (ALPHA .NE. -200. .AND. ALPHA .NE. -20.) THEN
           CALL GSPOS('CM06',N+13,'CCMT',X,Y,-11.0363,48+N,'ONLY')
        END IF
        ALPHA=ALPHA-30
      END DO

      ALPHA=80.
      DO N=0,11
        X= -R*SIN(ALPHA*(PI/180))
        Y=R*COS(ALPHA*(PI/180))
        IF (ALPHA .NE. -190. .AND. ALPHA .NE. -10.) THEN
          CALL GSPOS('CM06',N+25,'CCMT',X,Y,-11.0363,48+N,'ONLY')
        END IF
        ALPHA=ALPHA-30
      END DO

c position vacuum port
      CALL GSPOS('CM09',1,'C000',-15.9926,-18.9847,-3.2258,66,'ONLY')
      CALL GSPOS('CM10',1,'C000',-20.0002,-23.7609,-3.2258,66,'ONLY')
      CALL GSPOS('CM11',1,'C000',-23.3949,-27.8054,-2.8981,67,'ONLY')
      CALL GSPOS('CM12',1,'C000',-24.3464,-29.0144,-0.7849,67,'ONLY')

      END

c-----------------------------------------------------------------------

      SUBROUTINE RADIATOR
      DIMENSION PAR_CE00(3),PAR_CE01(3),PAR_CE02(3),PAR_CE03(3),
     +          PAR_CE04(3),PAR_CE05(3),PAR_CE06(3),PAR_CE07(3),
     +          PAR_CE08(3),PAR_CE09(3),PAR_CE10(3),PAR_CE11(3),
     +          PAR_CE12(3),PAR_CE13(3),PAR_CE14(3),PAR_CE15(3),
     +          PAR_CE16(3),PAR_CE17(3),PAR_CE18(3),PAR_CE19(3),
     +          PAR_CE20(3)


      DATA PAR_CE00/0.0000,43.5254,1.2725/
      DATA PAR_CE01/0.0000,43.5229,0.0508/
      DATA PAR_CE02/0.8727,43.3619,1.2700/
      DATA PAR_CE03/24.2758,0.5668,1.2700/
      DATA PAR_CE04/24.2758,0.5014,1.2700/
      DATA PAR_CE05/0.6490,8.0086,0.3175/
      DATA PAR_CE06/6.5862,0.6490,0.3175/
      DATA PAR_CE07/15.3947,0.4889,1.2700/
      DATA PAR_CE08/7.3966,4.3180,1.2700/
      DATA PAR_CE09/0.7981,4.3180,1.2700/
      DATA PAR_CE10/11.3005,11.6332,1.2700/
      DATA PAR_CE11/17.5666,17.8943,1.2700/
      DATA PAR_CE12/24.2748,25.8166,1.2700/
      DATA PAR_CE13/31.6738,31.9430,1.0085/
      DATA PAR_CE14/37.8257,38.1000,0.7308/
      DATA PAR_CE15/43.2410,43.5229,0.4762/
      DATA PAR_CE16/4.2926,2.3305,1.2700/
      DATA PAR_CE17/6.8580,2.9362,1.2700/
      DATA PAR_CE18/6.9850,6.5024,1.2700/
      DATA PAR_CE19/2.2019,6.1399,1.2700/
      DATA PAR_CE20/0.2840,43.2392,1.2700/

c create mother volume of radiator (CE00)
      CALL GSVOLU('CE00','TUBE',1,PAR_CE00,3,IVOL)

c create cross-beams
      CALL GSVOLU('CE01','TUBE',6,PAR_CE01,3,IVOL)
      CALL GSVOLU('CE02','BOX ',6,PAR_CE02,3,IVOL)
      CALL GSVOLU('CE03','BOX ',6,PAR_CE03,3,IVOL)
      CALL GSVOLU('CE04','BOX ',6,PAR_CE04,3,IVOL)
      CALL GSVOLU('CE20','BOX ',6,PAR_CE20,3,IVOL)

c create beams for attachment of cover for hatch
      CALL GSVOLU('CE05','BOX ',6,PAR_CE05,3,IVOL)
      CALL GSVOLU('CE06','BOX ',6,PAR_CE06,3,IVOL)

c create bars and base-plate for cooler
      CALL GSVOLU('CE07','BOX ',6,PAR_CE07,3,IVOL)
      CALL GSVOLU('CE08','BOX ',6,PAR_CE08,3,IVOL)
      CALL GSVOLU('CE09','BOX ',6,PAR_CE09,3,IVOL)

c create rings
      CALL GSVOLU('CE10','TUBE',6,PAR_CE10,3,IVOL)
      CALL GSVOLU('CE11','TUBE',6,PAR_CE11,3,IVOL)
      CALL GSVOLU('CE12','TUBE',6,PAR_CE12,3,IVOL)
      CALL GSVOLU('CE13','TUBE',6,PAR_CE13,3,IVOL)
      CALL GSVOLU('CE14','TUBE',6,PAR_CE14,3,IVOL)
      CALL GSVOLU('CE15','TUBE',6,PAR_CE15,3,IVOL)

c create vacuum boxes
      CALL GSVOLU('CE16','BOX ',1,PAR_CE16,3,IVOL)
      CALL GSVOLU('CE17','BOX ',1,PAR_CE17,3,IVOL)
      CALL GSVOLU('CE18','BOX ',1,PAR_CE18,3,IVOL)
      CALL GSVOLU('CE19','BOX ',6,PAR_CE19,3,IVOL)



      CALL GSPOS('CE01',1,'CE00',0.0,0.0,-1.2192,0,'ONLY')
      CALL GSPOS('CE02',1,'CE00',0.0,0.0,0.0,68,'ONLY')
      CALL GSPOS('CE02',2,'CE00',0.0000,0.0000,0.0000,69,'ONLY')
      CALL GSPOS('CE03',1,'CE00',0.0,0.0,0.0,70,'ONLY')
      CALL GSPOS('CE04',1,'CE00',0.0,0.0,0.0,69,'ONLY')
      CALL GSPOS('CE05',1,'CE00',9.1199,0.0,-0.9525,0,'ONLY')
      CALL GSPOS('CE05',2,'CE00',20.9944,0.0,-0.9525,0,'ONLY')
      CALL GSPOS('CE06',1,'CE00',15.0571,7.3596,-0.9525,0,'ONLY')
      CALL GSPOS('CE06',2,'CE00',15.0571,-7.3596,-0.9525,0,'ONLY')
      CALL GSPOS('CE07',1,'CE00',-8.9200,4.8069,0.0000,0,'ONLY')
      CALL GSPOS('CE07',2,'CE00',-8.9200,-4.8069,0.0000,0,'ONLY')
      CALL GSPOS('CE08',1,'CE00',0.0559,0.0000,0.0000,0,'ONLY')
      CALL GSPOS('CE09',1,'CE00',-23.5166,0.0000,0.0000,0,'ONLY')
      CALL GSPOS('CE10',1,'CE00',0.0000,0.0000,0.0000,0,'ONLY')
      CALL GSPOS('CE11',1,'CE00',0.0000,0.0000,0.0000,0,'ONLY')
      CALL GSPOS('CE12',1,'CE00',0.0000,0.0000,0.0000,0,'ONLY')
      CALL GSPOS('CE13',1,'CE00',0.0000,0.0000,-0.2615,0,'ONLY')
      CALL GSPOS('CE14',1,'CE00',0.0000,0.0000,-0.5392,0,'ONLY')
      CALL GSPOS('CE15',1,'CE00',0.0000,0.0000,-0.7937,0,'ONLY')
      CALL GSPOS('CE16',1,'CE00',29.1795,-29.0749,0.0000,71,'ONLY')
      CALL GSPOS('CE16',2,'CE00',-29.1742,-29.1737,0.0000,72,'ONLY')
      CALL GSPOS('CE16',3,'CE00',-29.1770,29.1643,0.0000,71,'ONLY')
      CALL GSPOS('CE16',4,'CE00',29.1742,29.1737,0.0000,72,'ONLY')
      CALL GSPOS('CE17',1,'CE00',0.0000,40.5867,0.0000,0.000,'ONLY')
      CALL GSPOS('CE17',2,'CE00',0.0000,-40.5867,0.0000,0,'ONLY')
      CALL GSPOS('CE18',1,'CE00',-35.3045,9.4480,0.0000,73,'ONLY')
      CALL GSPOS('CE18',2,'CE00',35.3045,-9.4480,0.0000,73,'ONLY')
      CALL GSPOS('CE19',1,'CE00',2.7462,17.6677,0.0000,0,'ONLY')
      CALL GSPOS('CE20',1,'CE00',0.0000,0.0000,0.0000,0,'ONLY')

c position radiator into mother for cryostat (c000)
      CALL GSPOS('CE00',1,'C000',0.,0.0,-14.2875,74,'ONLY')      

      END

c-----------------------------------------------------------------------

      subroutine prep_detectors
c REAR SEGMENT:
       call gsvolu('MDTR','PCON',21,0,0,ivol)
c FRONT SEGMENT:
       call gsvolu('MDTF','PCON',21,0,0,ivol)
c TOP OF INNER BORE (HOLE):
       call gsvolu('MDTH','SPHE',1,0,0,ivol)
c DEAD REGIONS: BOTTOM (SURFACE CHANNELS)
       call gsvolu('MDDE','PCON',45,0,0,ivol)
c DEAD REGIONS: INNER BORE (REAR)
       call gsvolu('MDDR','PCON',45,0,0,ivol)
c DEAD REGIONS: INNER BORE (FRONT, EXCEPT FOR SPHERE)
       call gsvolu('MDDF','TUBE',45,0,0,ivol)
c DEAD REGIONS: INNER BORE (FRONT, SPHERE PORTION)
       call gsvolu('MDDS','SPHE',45,0,0,ivol)
      end

c--------------------------------------------------------------------

       subroutine geom_dets(modname,nth)

       real diameter(9),length(9),cone_diam(9),
     +      minor_diam(9),shoulder(9)
       real deadbottom(9),deadbore(9),extrabore(9)
       real z_adjust(9)
       
c Parameters below updated 6 Feb 2001 cPbL from "segment" code.

c DIMENSIONS IN MM FROM DIMENSION SHEET
c Position/grid numbers G# 1,2,3,4,5,6,7,8,9 map onto detectors:
c            OLD:       HESSI#   11,10,3,6,4,8,13,9,12
c            NEW:       HESSI#   11,2,13,6,1,10,3,9,12

       data diameter/70.6, 70.7, 69.8, 70.7, 71.0, 70.8,
     +               69.9, 70.6, 70.3/
       data length/  84.9, 83.6, 82.0, 84.2, 82.1, 85.0,
     +               84.0, 84.5, 83.5/
       data cone_diam/ 30.5, 29.0, 28.0, 28.8, 29.0, 31.0,
     +                 30.5, 29.8, 29.6/
       data minor_diam/60.7, 60.6, 60.0, 60.8, 61.0, 60.9,
     +                 59.8, 60.8, 60.3/
       data shoulder/ 13.0, 13.0, 13.0, 13.0, 13.0, 13.0,
     +                15.0, 13.0, 13.0/
       data z_adjust/.10742,.11758,.06424,.0871,.05662,.11758,
     +               -.00942,.10742,.09726/

c DEADBOTTOM AND DEADBORE IN CM
       data deadbottom/0.01,0.01,0.01,0.01,0.01,0.01,
     +                 0.01,0.01,0.01/
       data deadbore/0.14,0.14,0.14,0.14,0.14,0.14,
     +               0.14,0.14,0.14/

c EXTRABORE (extra depth of segmentation step) in CM
C Only G5 =HESSI1 has an odd value:
       data extrabore/0.3,0.3,0.3,0.3,0.0,0.3,
     +                0.3,0.3,0.3/

       common/detshape/diameter,length,cone_diam,minor_diam,
     +                 shoulder
       common/adjust/z_adjust

       real par_mdtr(18),par_mdtf(27),par_mdth(6)
       real par_mddf(3), par_mddr(15), par_mdde(9)
       real par_mdds(6)

c VERTICAL OFFSET DUE TO A SHORT DETECTOR:
       dz = 8.5-length(nth)/10.

c Active front volume MDTF:
       par_mdtf(1)= 0.0
       par_mdtf(2)= 360.0
       par_mdtf(3)= 8.0

       par_mdtf(4)=  6.1 + extrabore(nth)
       par_mdtf(5)=  0.5 + deadbore(nth)
       par_mdtf(6)=  0.75 + deadbore(nth)

       par_mdtf(7)= 8.5 - shoulder(nth)/10. - 0.4
       par_mdtf(8)= par_mdtf(5)
       par_mdtf(9)= diameter(nth)/20.

       par_mdtf(10)= 7.0
       par_mdtf(11)= par_mdtf(5)
       par_mdtf(12)= par_mdtf(9) - (par_mdtf(10)-par_mdtf(7))

       par_mdtf(13)= 8.5 - shoulder(nth)/10.
       if (par_mdtf(10) .GT. par_mdtf(13)) 
     +                       par_mdtf(10) = par_mdtf(13)-0.001
       par_mdtf(14)= 0.0
       par_mdtf(15)= par_mdtf(9) - 0.4

       par_mdtf(16)= par_mdtf(13) + 0.001
       par_mdtf(17)= 0.0
       par_mdtf(18)= minor_diam(nth)/20.

       par_mdtf(19)= 8.1
       par_mdtf(20)= 0.0
       par_mdtf(21)= par_mdtf(18)

       par_mdtf(22)= 8.4
       par_mdtf(23)= 0.0
       par_mdtf(24)= 0.9672 * par_mdtf(18)

       par_mdtf(25)= 8.5
       par_mdtf(26)= 0.0
       par_mdtf(27)= 0.8689 * par_mdtf(18)

c Active rear volume MDTR:
       par_mdtr(1)= 0.0
       par_mdtr(2)= 360.0
       par_mdtr(3)= 5.0

       par_mdtr(4)= deadbottom(nth) + dz
       par_mdtr(5)= cone_diam(nth)/20. - deadbottom(nth) +
     +                                   deadbore(nth)*sqrt(2.)
       par_mdtr(6)= diameter(nth)/20.

       par_mdtr(7)= (cone_diam(nth) - 15.0)/20.0 + dz
       par_mdtr(8)= 0.75 + deadbore(nth)*sqrt(2.)
       par_mdtr(9)= par_mdtr(6)

       par_mdtr(10)= par_mdtr(7) + 0.001
       par_mdtr(11)= 0.75 + deadbore(nth)
       par_mdtr(12)= par_mdtr(6)

       par_mdtr(13)= 6.1 + extrabore(nth)
       par_mdtr(14)= par_mdtr(11)
       par_mdtr(15)= par_mdtr(6)

       par_mdtr(16)= 8.5 - shoulder(nth)/10. - 0.4
       par_mdtr(17)= par_mdtr(6)
       par_mdtr(18)= par_mdtr(6) + 0.001
       
c Dead layer inside bore, MDDR:
       par_mddr(1)= 0.0
       par_mddr(2)= 360.0
       par_mddr(3)= 4.0

       par_mddr(4)= deadbottom(nth) + dz
       par_mddr(5)= cone_diam(nth)/20. - deadbottom(nth)
       par_mddr(6)= par_mddr(5) + deadbore(nth)*sqrt(2.)

       par_mddr(7)= (cone_diam(nth) - 15.0)/20.0 + dz
       par_mddr(8)= 0.75
       par_mddr(9)= 0.75 + deadbore(nth)*sqrt(2.)

       par_mddr(10)= par_mddr(7) + 0.001
       par_mddr(11)= 0.75
       par_mddr(12)= 0.75 + deadbore(nth)

       par_mddr(13)= 6.1 + extrabore(nth)
       par_mddr(14)= 0.75
       par_mddr(15)= 0.75 + deadbore(nth)

c Dead layer inside bore, front part: MDDF
       par_mddf(1) = 0.5
       par_mddf(2) = 0.5 + deadbore(nth)
       par_mddf(3) = (0.9 - extrabore(nth))/2.

c Dead layer inside bore, spherical part of front part: MDDS
       par_mdds(1) = 0.5
       par_mdds(2) = 0.5 + deadbore(nth)
       par_mdds(3) = 0.
       par_mdds(4) = 90.
       par_mdds(5) = 0.
       par_mdds(6) = 360.

c Dead layer at back of detector (surface channels): MODE
       par_mdde(1) = 0.0
       par_mdde(2) = 360.0
       par_mdde(3) = 2.0

       par_mdde(4) = dz
       par_mdde(5) = cone_diam(nth)/20.
       par_mdde(6) = diameter(nth)/20.

       par_mdde(7) = deadbottom(nth) + dz
       par_mdde(8) = cone_diam(nth)/20. - deadbottom(nth)
       par_mdde(9) = diameter(nth)/20.
       
c Spherical hole to clear out the end of the bore: MDTH
       par_mdth(1) = 0.0
       par_mdth(2) = 0.5
       par_mdth(3) = 0.
       par_mdth(4) = 90.
       par_mdth(5) = 0.
       par_mdth(6) = 360.
       
c REAR SEGMENT:
       call gsposp('MDTR',nth,modname,0.0,0.0,-4.0-z_adjust(nth),
     +             0,'MANY',par_mdtr,18)
c
c FRONT SEGMENT:
       call gsposp('MDTF',nth,modname,0.0,0.0,-4.0-z_adjust(nth),
     +             0,'MANY',par_mdtf,27)
c
c TOP OF INNER BORE (HOLE):
       call gsposp('MDTH',nth,modname,0.0,0.0,3.0-z_adjust(nth),
     +             0,'ONLY',par_mdth,6)
c
c DEAD REGIONS: BOTTOM (SURFACE CHANNELS)
       call gsposp('MDDE',nth,modname,0.0,0.0,-4.0-z_adjust(nth),
     +             0,'ONLY',par_mdde,9)
c
c DEAD REGIONS: INNER BORE (REAR)
       call gsposp('MDDR',nth,modname,0.0,0.0,-4.0-z_adjust(nth),
     +             0,'ONLY',par_mddr,15)
c
c DEAD REGIONS: INNER BORE (FRONT, EXCEPT FOR SPHERE)
       call gsposp('MDDF',nth,modname,0.0,0.0,
     +             2.55+extrabore(nth)/2.-z_adjust(nth),
     +             0,'ONLY',par_mddf,3)
c
c DEAD REGIONS: INNER BORE (FRONT, SPHERE PORTION)
       call gsposp('MDDS',nth,modname,0.0,0.0,3.0-z_adjust(nth),
     +             0,'ONLY',par_mdds,6)
c
       end

c--------------------------------------------------------------------

       subroutine prep_modules

       real par_mwnd(3),par_mbez(33),
     +           par_mwav(5),par_mnut(24),par_mcn1(24),
     +           par_mcn2(27),par_mshm(3),par_mwed(18),par_msap(18),
     +           par_mccr(3),par_mccn(3), par_mgz1(3),
     +           par_mgz2(3),par_mgz3(3), par_mfpb(15), par_mfpl(3),
     +           par_mfet(3)
       real z_adjust(9)
       common/adjust/z_adjust

       data par_mwnd/0.0, 3.4925, 0.0127/
       data par_mbez/0., 360., 10.,
     +               4.666900, 3.467100, 3.987800,
     +               5.047900, 3.467100, 3.987800,
     +               5.048154, 3.467100, 4.089400,
     +               5.124100, 3.467100, 4.089400,
     +               5.124354, 3.149600, 4.089400,
     +               5.213000, 3.149600, 4.089400,
     +               5.213254, 3.149600, 3.746500,
     +               5.276500, 3.149600, 3.746500,
     +               5.276754, 3.530600, 3.746500,
     +               5.378100, 3.530600, 3.746500/
       data par_mwav/3.467100, 3.937000, 0.045720, 0., 350./
       data par_mnut/0., 360., 7.,
     +               4.235100, 4.117340, 4.381500,
     +               4.984400, 4.117340, 4.381500,
     +               5.060600, 4.174490, 4.381500,
     +               5.136800, 4.174490, 4.381500,
     +               5.213000, 4.117340, 4.381500,
     +               5.213254, 3.886200, 4.381500,
     +               5.378100, 3.886200, 4.381500/


       data par_mcn1/0., 360., 7.,
     +               -5.670900, 1.422400, 4.051300,
     +               -5.518500, 1.270000, 4.203700,
     +               -5.264500, 1.270000, 4.203700,
     +               -5.264246, 4.013200, 4.203700,
     +               -5.162900, 4.114800, 4.203700,
     +               1.999900, 4.114800, 4.203700,
     +               2.114200, 4.000500, 4.203700/
       data par_mcn2/0., 360., 8.,
     +               2.114200, 4.000500, 4.203700,
     +               2.584100, 4.000500, 4.203700,
     +               2.584354, 4.000500, 4.762500,
     +               2.749200, 4.000500, 4.762500,
     +               2.751740, 4.000500, 4.445000,
     +               3.777900, 4.000500, 4.445000,
     +               3.778154, 4.000500, 4.203700,
     +               5.047900, 4.000500, 4.203700/
       data par_mshm/3.441700, 3.994150, 0.101600/
       data par_mwed/0., 360., 5.,
     +               2.914300, 3.994150, 4.000500,
     +               3.600100, 3.302000, 4.000500,
     +               4.209700, 3.302000, 4.000500,
     +               4.209954, 3.302000, 3.429000,
     +               4.997100, 3.302000, 3.429000/
       data par_msap/0., 360., 5.,
     +               -5.264500, 1.231900, 1.905000,
     +               -5.112100, 1.079500, 1.905000,
     +               -4.604100, 1.079500, 1.905000,
     +               -4.603846, 0.713740, 1.905000,
     +               -4.324700, 0.713740, 1.587500/
       data par_mccr/0.47625, 0.63500, 1.524/
       data par_mccn/0.58547, 0.9525, .127/
       
      

       data par_mgz1/4.595,4.645,0.925/
       data par_mgz2/4.495,4.595,0.925/
       data par_mgz3/4.445,4.495,0.925/
       data par_mfpb/0., 360., 4.,
     +               -6.4583,  0., 2.159,
     +               -5.9757,  0., 2.159,
     +               -5.9756,  0., 2.75,
     +               -5.6709,  0., 2.75/   
       data par_mfpl/0., 2.4, 0.225/
       data par_mfet/0., 1.0, 0.65/
c
c
c Beryllium Window (module):
       call gsvolu('MWND','TUBE',9,par_mwnd,3,ivol)
c
c Be Window Bezel (Aluminum):
       call gsvolu('MBEZ','PCON',6,par_mbez,33,ivol)
c
c Wavy Spring (stainless)
       call gsvolu('MWAV','TUBS',3,par_mwav,5,ivol)
c
c Retainer Nut (stainless)
       call gsvolu('MNUT','PCON',3,par_mnut,24,ivol)
c
c Detector Retainer (teflon)
       call gsvolu('MRET','PCON',11,0,0,ivol)
c
c Detector Can Bottom (aluminum)
       call gsvolu('MCN1','PCON',6,par_mcn1,24,ivol)
c
c Detector Can Top (aluminum)
       call gsvolu('MCN2','PCON',6,par_mcn2,27,ivol)
c
c Spring Shim (vespel) (6 with thicknesses from 0.08 to 0.13)
       call gsvolu('MSHM','TUBE',5,par_mshm,3,ivol)
c
c  Detector retainer wedge (vespel)
       call gsvolu('MWED','PCON',5,par_mwed,18,ivol)
c
c  Sapphire bridge
       call gsvolu('MSAP','PCON',10,par_msap,18,ivol)
c
c  Detector Module Coax Contact (Al)
       call gsvolu('MCC1','PCON',6,0,0,ivol)
c
c  Coax Contact Retainer (vespel)
       call gsvolu('MCCR','TUBE',5,par_mccr,3,ivol)
c
c  Coax contact nut (al6061 or copper/tellurium CDA #145 ?)
       call gsvolu('MCCN','TUBE',6,par_mccn,3,ivol)

c  Signal Lead Shield (teflon - but includes vespel shell)
       call gsvolu('MSLS','TUBE',11,0,0,ivol)

c  FET platform base: (Al)
       call gsvolu('MFPB','PCON',6,par_mfpb,15,ivol)

c  FET platform: (Al)
       call gsvolu('MFPL','TUBE',6,par_mfpl,3,ivol)

c  FET can: (vespel????)
       call gsvolu('MFET','TUBE',5,par_mfet,3,ivol)

c  Graded-Z shield
       call gsvolu('MGZ1','TUBE',44,par_mgz1,3,ivol)
       call gsvolu('MGZ2','TUBE',43,par_mgz2,3,ivol)
       call gsvolu('MGZ3','TUBE',3,par_mgz3,3,ivol)
       end
      
c-----------------------------------------------------------------------

       subroutine geom_module(modname,nth)

       character*4 modname
       real par_dmod(21),par_mcc1(18),par_mret(24),par_msls(3)

       data par_mret/0., 360., 7.,
     +               1.453800, 3.549650, 3.765550,
     +               2.241200, 3.549650, 3.765550,
     +               2.482500, 3.549650, 4.000500,
     +               2.800000, 3.549650, 4.000500,
     +               2.914300, 3.435350, 4.000500,
     +               3.198780, 3.150870, 3.714750,
     +               3.612800, 3.150870, 3.302000/ 
       data par_dmod/0., 360., 6.,
     +        -9.95,  0.0, 3.1000,
     +        -5.672, 0.0, 3.1000,
     +        -5.671, 0.0, 4.2038,
     +        2.57,   0.0, 4.2038,
     +        2.58,   0.0, 4.7626, 
     +        5.3782, 0.0, 4.7626/

c par_mcc1(13) and (16) TBD on an individual basis (see below)
       data par_mcc1/0., 360., 5.,
     +               -4.502500, 0.636270, 0.712470,
     +               -4.324700, 0.636270, 0.712470,
     +               -4.324446, 0.636270, 1.587500,
     +               0.0, 0.636270, 1.587500,
     +               0.0, 0.636270, 0.850900/
     
       real diameter(9),length(9),cone_diam(9),
     +      minor_diam(9),shoulder(9)
       
       common/detshape/diameter,length,cone_diam,minor_diam,
     +                 shoulder
       real z_adjust(9)
       common/adjust/z_adjust
       real z_adjust2(9)
       data z_adjust2/.10742,.11758,.19058,.0871,.05662,.17346,
     +               .06424,.10742,.09726/


c MODULE MOTHER:
       call gsvolu(modname,'PCON',1,par_dmod,21,ivol)

c Daughters (defined in prep_module):
       call gspos('MWND',nth,modname,0.0,0.0,5.2895,0,'ONLY')
       call gspos('MBEZ',nth,modname,0.0,0.0,0.0,0,'ONLY')
       call gspos('MWAV',nth,modname,0.0,0.0,4.62118,0,'ONLY')
       call gspos('MNUT',nth,modname,0.0,0.0,0.0,0,'ONLY')
       
       call gsposp('MRET',nth,modname,0.0,0.0,-z_adjust2(nth),
     +             0,'ONLY',par_mret,24)
       call gspos('MCN1',nth,modname,0.0,0.0,0.0,0,'ONLY')
       call gspos('MCN2',nth,modname,0.0,0.0,0.0,0,'ONLY')
       call gspos('MSHM',nth,modname,0.0,0.0,4.3116,0,'ONLY')
       call gspos('MWED',nth,modname,0.0,0.0,-z_adjust2(nth),0,'ONLY')
       call gspos('MSAP',nth,modname,0.0,0.0,0.0,0,'ONLY')

       call gspos('MFPB',nth,modname,0.0,0.0,0.0,0,'ONLY')
       call gspos('MFPL',nth,modname,0.0,-0.7,-7.825,0,'ONLY')
       call gspos('MFET',nth*2-1,modname,1.2,0.0,-8.70,0,'ONLY')
       call gspos('MFET',nth*2,modname,-1.2,0.0,-8.70,0,'ONLY')

       raise_shim =  (85.0-length(nth))/10. + (cone_diam(nth)-29.0)/20.
       par_mcc1(13) = -4.172300 + raise_shim - z_adjust(nth)
       par_mcc1(16) = -3.435700 + raise_shim - z_adjust(nth)
       call gsposp('MCC1',nth,modname,0.0,0.0,0.0,0,'ONLY',par_mcc1,18)

       call gspos('MCCR',nth,modname,0.0,0.0,-3.3341,0,'ONLY')
       call gspos('MCCN',nth,modname,0.0,0.0,-4.7311,0,'ONLY')
       
       par_msls(1)=0.0
       par_msls(2)=0.40
       par_msls(3)=3.75-z_adjust(nth)/2. 
       call gsposp('MSLS',nth,modname,0.0,0.0,-1.25-z_adjust(nth)/2.,0,
     +            'ONLY',par_msls,3)

       call gspos('MGZ1',nth,modname,0.0,0.0,3.677,0,'ONLY')
       call gspos('MGZ2',nth,modname,0.0,0.0,3.677,0,'ONLY')
       call gspos('MGZ3',nth,modname,0.0,0.0,3.677,0,'ONLY')
       
       end

