source: trunk/environments/g4py/tests/gtest07/test.py @ 1358

Last change on this file since 1358 was 1337, checked in by garnier, 14 years ago

tag geant4.9.4 beta 1 + modifs locales

  • Property svn:executable set to *
File size: 2.6 KB
Line 
1#!/usr/bin/python
2# ==================================================================
3# python script for Geant4Py test
4#
5#   gtest07
6#   - test for checking overlapped geometries
7# ==================================================================
8from Geant4 import *
9import g4py.ExN01pl, g4py.ParticleGun
10
11# ==================================================================
12# user actions in python
13# ==================================================================
14class MyDetectorConstruction(G4VUserDetectorConstruction):
15  "My Detector Construction"
16
17  def __init__(self):
18    G4VUserDetectorConstruction.__init__(self)
19
20  # -----------------------------------------------------------------
21  def Construct(self):
22    # Python has automatic garbage collection system.
23    # Geometry objects must be defined as GLOBAL not to be deleted.
24    air= gNistManager.FindOrBuildMaterial("G4_AIR")
25
26    # world volume
27    global sld_world, lv_world, pv_world
28    sld_world= G4Box("world", 1.*m, 1.*m, 1.*m)
29    lv_world= G4LogicalVolume(sld_world, air, "world")   
30    pv_world= G4PVPlacement(G4Transform3D(), lv_world, "world",
31                            None, False, 0)
32
33    # box
34    global sld_box, lv_box, pv_box
35    sld_box= G4Box("box", 10.*cm, 10.*cm, 10.*cm);
36    lv_box= G4LogicalVolume(sld_box, air, "box")
37    pv_box= G4PVPlacement(None, G4ThreeVector(), "box", lv_box,
38                          pv_world, False, 0, True)
39
40    # cylinder
41    global sld_cyl, lv_cyl, pv_cyl1, pv_cyl2, pv_cyl3
42    sld_cyl= G4Tubs("cylinder",0., 2.*cm, 2.*cm, 0., twopi)
43    lv_cyl= G4LogicalVolume(sld_cyl, air, "cylinder")
44
45    #
46    # the following placements are !! overlapped !!
47    #
48    # doubly placed
49    pv_cyl1= G4PVPlacement(None, G4ThreeVector(), "cylinder", lv_cyl,
50                           pv_world, False, 0, True)
51
52    # overlaped
53    pv_cyl2= G4PVPlacement(None, G4ThreeVector(10.*cm,0.,0.),
54                           "cylinder", lv_cyl,
55                           pv_world, False, 1, True)
56
57    # sticked out
58    pv_cyl3= G4PVPlacement(None, G4ThreeVector(10.*cm,0.,0.),
59                           "cylinder", lv_cyl,
60                           pv_box, False, 0, True)
61
62    return pv_world
63 
64# ==================================================================
65# main
66# ==================================================================
67# set geometry
68myDC= MyDetectorConstruction()
69gRunManager.SetUserInitialization(myDC)
70
71# minimal physics list
72g4py.ExN01pl.Construct()
73
74# set primary generator action
75g4py.ParticleGun.Construct()
76
77# initialize
78gRunManager.Initialize() # overlap should be detected !!
79
80
Note: See TracBrowser for help on using the repository browser.