Import Geant4 10.7.0 source tree
This commit is contained in:
@@ -7,3 +7,4 @@ add_subdirectory(gtest04)
|
||||
add_subdirectory(gtest05)
|
||||
add_subdirectory(gtest06)
|
||||
add_subdirectory(gtest07)
|
||||
add_subdirectory(gtest08)
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
configure_file(test.py test.py)
|
||||
add_test(NAME geant4py-test08 COMMAND ${PYTHON_EXECUTABLE} test.py)
|
||||
set_tests_properties(geant4py-test08 PROPERTIES ENVIRONMENT "PYTHONPATH=${GEANT4_PYTHON_OUTPUT_DIR};${GEANT4_TEST_ENVIRONMENT}")
|
||||
Executable
+74
@@ -0,0 +1,74 @@
|
||||
#!/usr/bin/python3
|
||||
# ==================================================================
|
||||
# python script for Geant4Py test
|
||||
#
|
||||
# gtest09
|
||||
# - test for checking use of G4PhysListFactory
|
||||
# ==================================================================
|
||||
|
||||
from Geant4 import *
|
||||
|
||||
# ==================================================================
|
||||
# user actions in python
|
||||
# ==================================================================
|
||||
class MyDetectorConstruction(G4VUserDetectorConstruction):
|
||||
"My Detector Construction"
|
||||
|
||||
def __init__(self):
|
||||
G4VUserDetectorConstruction.__init__(self)
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
def Construct(self):
|
||||
# Python has automatic garbage collection system.
|
||||
# Geometry objects must be defined as GLOBAL not to be deleted.
|
||||
air= gNistManager.FindOrBuildMaterial("G4_AIR")
|
||||
|
||||
# world volume
|
||||
global sld_world, lv_world, pv_world
|
||||
sld_world= G4Box("world", 1.*m, 1.*m, 1.*m)
|
||||
lv_world= G4LogicalVolume(sld_world, air, "world")
|
||||
pv_world= G4PVPlacement(G4Transform3D(), lv_world, "world",
|
||||
None, False, 0)
|
||||
|
||||
return pv_world
|
||||
|
||||
class MyPrimaryGeneratorAction(G4VUserPrimaryGeneratorAction):
|
||||
"My Primary Generator Action"
|
||||
|
||||
def __init__(self):
|
||||
G4VUserPrimaryGeneratorAction.__init__(self)
|
||||
self.particleGun= G4ParticleGun(1)
|
||||
|
||||
def GeneratePrimaries(self, event):
|
||||
dx=0.
|
||||
self.particleGun.SetParticleMomentumDirection(G4ThreeVector(dx, 0., 1.))
|
||||
self.particleGun.GeneratePrimaryVertex(event)
|
||||
|
||||
# ==================================================================
|
||||
# main
|
||||
# ==================================================================
|
||||
# set geometry
|
||||
myDC = MyDetectorConstruction()
|
||||
gRunManager.SetUserInitialization(myDC)
|
||||
|
||||
# Create physics list
|
||||
factory = G4PhysListFactory()
|
||||
myPhysList = factory.GetReferencePhysList("FTFP_BERT")
|
||||
|
||||
if myPhysList is None:
|
||||
raise RuntimeError("No physics list named FTFP_BERT found")
|
||||
|
||||
gRunManager.SetUserInitialization(myPhysList)
|
||||
|
||||
# Event generator
|
||||
myGenAction = MyPrimaryGeneratorAction()
|
||||
myGenAction.particleGun.SetParticleByName("e-")
|
||||
myGenAction.particleGun.SetParticleEnergy(200.*MeV)
|
||||
myGenAction.particleGun.SetParticlePosition(G4ThreeVector(0.,0.,-14.9)*cm)
|
||||
|
||||
gRunManager.SetUserAction(myGenAction)
|
||||
|
||||
# Init, run terminate
|
||||
gRunManager.Initialize()
|
||||
gRunManager.BeamOn(10)
|
||||
gTerminate()
|
||||
Reference in New Issue
Block a user