Import Geant4 10.3.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-12-09 12:35:28 +01:00
parent 4ec577e5c4
commit a3452e42ac
3514 changed files with 210500 additions and 89628 deletions
+25 -1
View File
@@ -6,7 +6,7 @@ set(TEST_MODULES_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}/tests)
add_subdirectory(test00/module)
add_subdirectory(test01/module)
add_subdirectory(test02/module)
#add_subdirectory(test03/module EXCLUDE_FROM_ALL)
add_subdirectory(test03/module EXCLUDE_FROM_ALL)
add_subdirectory(test04/module)
add_subdirectory(test05/module)
add_subdirectory(test06/module)
@@ -20,3 +20,27 @@ add_subdirectory(test13/module)
# tests for g4py
add_subdirectory(gtest01/module)
# testing
add_subdirectory(test00)
add_subdirectory(test01)
add_subdirectory(test02)
add_subdirectory(test03)
add_subdirectory(test04)
add_subdirectory(test05)
add_subdirectory(test06)
add_subdirectory(test07)
add_subdirectory(test08)
add_subdirectory(test09)
add_subdirectory(test10)
add_subdirectory(test11)
add_subdirectory(test12)
add_subdirectory(test13)
#
add_subdirectory(gtest01)
add_subdirectory(gtest02)
add_subdirectory(gtest03)
add_subdirectory(gtest04)
add_subdirectory(gtest05)
add_subdirectory(gtest06)
add_subdirectory(gtest07)
File diff suppressed because one or more lines are too long
@@ -0,0 +1,8 @@
# add teting
add_test(gtest01 python test.py)
configure_file(test.py test.py)
set_property(TEST gtest01
PROPERTY ENVIRONMENT
PYTHONPATH=./module:${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}
)
+123
View File
@@ -0,0 +1,123 @@
#!/usr/bin/python
# ==================================================================
# python script for Geant4Py test
#
# gtest01
# - check basic control flow
# ==================================================================
from Geant4 import *
import gtest01
import random
#import thread
# ==================================================================
# user actions in python
# ==================================================================
class MyPrimaryGeneratorAction(G4VUserPrimaryGeneratorAction):
"My Primary Generator Action"
def __init__(self):
G4VUserPrimaryGeneratorAction.__init__(self)
self.particleGun= G4ParticleGun(1)
def GeneratePrimaries(self, event):
#dx= random.gauss(0., 0.1)
dx=0.
self.particleGun.SetParticleMomentumDirection(G4ThreeVector(dx, 0., 1.))
self.particleGun.GeneratePrimaryVertex(event)
# ------------------------------------------------------------------
class MyRunAction(G4UserRunAction):
"My Run Action"
def BeginOfRunAction(self, run):
print "*** #event to be processed (BRA)=",
run.GetNumberOfEventToBeProcessed()
def EndOfRunAction(self, run):
print "*** run end run(ERA)=", run.GetRunID()
# ------------------------------------------------------------------
class MyEventAction(G4UserEventAction):
"My Event Action"
#def BeginOfEventAction(self, event):
#print "*** current event (BEA)=", event.GetEventID()
# pass
#def EndOfEventAction(self, event):
# print "*** current event (EEA)=", event.GetEventID()
# ------------------------------------------------------------------
class MySteppingAction(G4UserSteppingAction):
"My Stepping Action"
def UserSteppingAction(self, step):
#print "*** dE/dx in current step=", step.GetTotalEnergyDeposit()
track= step.GetTrack()
touchable= track.GetTouchable()
pv= touchable.GetVolume()
#print pv.GetCopyNo()
#print touchable.GetReplicaNumber(0)
# ------------------------------------------------------------------
class MyField(G4MagneticField):
"My Magnetic Field"
def GetFieldValue(self, pos, time):
bfield= G4ThreeVector()
bfield.x= 0.
bfield.y= 5.*tesla
bfield.z= 0.
return bfield
# ==================================================================
# main
# ==================================================================
qMaterials= gtest01.QMaterials()
qMaterials.Construct()
qDC= gtest01.QDetectorConstruction()
gRunManager.SetUserInitialization(qDC)
qPL= gtest01.QPhysicsList()
gRunManager.SetUserInitialization(qPL)
# set user actions...
#qPGA= gtest01.QPrimaryGeneratorAction()
myPGA= MyPrimaryGeneratorAction()
gRunManager.SetUserAction(myPGA)
#myRA= MyRunAction()
#gRunManager.SetUserAction(myRA)
myEA= MyEventAction()
gRunManager.SetUserAction(myEA)
mySA= MySteppingAction()
gRunManager.SetUserAction(mySA)
# set particle gun
#ApplyUICommand("/control/execute gun.mac")
#pg= qPGA.GetParticleGun()
pg= myPGA.particleGun
pg.SetParticleByName("e-")
pg.SetParticleEnergy(200.*MeV)
pg.SetParticlePosition(G4ThreeVector(0.,0.,-14.9)*cm)
# magnetic field
fieldMgr= gTransportationManager.GetFieldManager()
myField= G4UniformMagField(G4ThreeVector(0.,10.*tesla,0.))
#myField= MyField()
fieldMgr.SetDetectorField(myField)
fieldMgr.CreateChordFinder(myField)
gRunManager.Initialize()
# visualization
gControlExecute("vis.mac")
# beamOn
gRunManager.BeamOn(10)
#thread.start_new_thread(gRunManager.BeamOn, (100000))
+2 -8
View File
@@ -8,7 +8,6 @@
from Geant4 import *
import gtest01
import random
#import thread
# ==================================================================
# user actions in python
@@ -70,7 +69,7 @@ class MyField(G4MagneticField):
bfield.y= 5.*tesla
bfield.z= 0.
return bfield
# ==================================================================
# main
# ==================================================================
@@ -90,7 +89,7 @@ gRunManager.SetUserAction(myPGA)
#myRA= MyRunAction()
#gRunManager.SetUserAction(myRA)
myEA= MyEventAction()
gRunManager.SetUserAction(myEA)
@@ -114,10 +113,5 @@ fieldMgr.CreateChordFinder(myField)
gRunManager.Initialize()
# visualization
gControlExecute("vis.mac")
# beamOn
gRunManager.BeamOn(10)
#thread.start_new_thread(gRunManager.BeamOn, (100000))
@@ -0,0 +1,8 @@
# add teting
add_test(gtest02 python test.py)
configure_file(test.py test.py)
set_property(TEST gtest02
PROPERTY ENVIRONMENT
PYTHONPATH=./module:${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}
)
+133
View File
@@ -0,0 +1,133 @@
#!/usr/bin/python
# ==================================================================
# python script for Geant4Py test
#
# gtest02
# - test for using site-module packages
# ==================================================================
from Geant4 import *
import g4py.Qmaterials, g4py.NISTmaterials
import g4py.Qgeom, g4py.ExN01geom, g4py.ExN03geom
import g4py.ExN01pl, g4py.EMSTDpl
import g4py.ParticleGun, g4py.MedicalBeam
# ==================================================================
# user setup
# ==================================================================
# ------------------------------------------------------------------
# Setup-0 (Q)
# ------------------------------------------------------------------
def Setup0():
# simple materials for Qgeom
g4py.Qmaterials.Construct()
# NIST materials
#g4py.NISTmaterials.Construct()
# normal way for constructing user geometry
#qDC= g4py.Qgeom.QDetectorConstruction()
#gRunManager.SetUserInitialization(qDC)
# 2nd way, short-cut way
g4py.Qgeom.Construct()
# primary
global primary_position, primary_direction
primary_position= G4ThreeVector(0.,0., -14.9*cm)
primary_direction= G4ThreeVector(0.2, 0., 1.)
# ------------------------------------------------------------------
# Setup-1 (ExampleN01)
# ------------------------------------------------------------------
def Setup1():
g4py.ExN01geom.Construct()
global primary_position, primary_direction
primary_position= G4ThreeVector(-2.5*m, 0., 0.)
primary_direction= G4ThreeVector(1., 0., 0.)
# ------------------------------------------------------------------
# Setup-3 (ExampleN03)
# ------------------------------------------------------------------
def Setup3():
#exN03geom= g4py.ExN03geom.ExN03DetectorConstruction()
#gRunManager.SetUserInitialization(exN03geom)
g4py.ExN03geom.Construct()
global primary_position, primary_direction
primary_position= G4ThreeVector(-1.*m, 0., 0.)
primary_direction= G4ThreeVector(1., 0., 0.)
# ==================================================================
# main
# ==================================================================
# ------------------------------------------------------------------
# randum number
# ------------------------------------------------------------------
rand_engine= Ranlux64Engine()
HepRandom.setTheEngine(rand_engine)
HepRandom.setTheSeed(20050830L)
# ------------------------------------------------------------------
# user setup
# ------------------------------------------------------------------
Setup0()
#Setup1()
#Setup3()
# ------------------------------------------------------------------
# setup for physics list
# ------------------------------------------------------------------
# normal way for constructing user physics list
#exN01PL= ExN01PhysicsList.ExN01PhysicsList()
#gRunManager.SetUserInitialization(exN01PL)
# 2nd way, short-cut way
# geantino + transportation
#g4py.ExN01pl.Construct()
# electron/gamma standard EM
g4py.EMSTDpl.Construct()
# ------------------------------------------------------------------
# setup for primary generator action
# ------------------------------------------------------------------
# ------------
# Particle Gun
# ------------
# normal way for constructing user physics list
#pgPGA= g4py.ParticleGun.ParticleGunAction()
#gRunManager.SetUserAction(pgPGA)
#pg= pgPGA.GetParticleGun()
# 2nd way, short-cut way
pg= g4py.ParticleGun.Construct()
# set parameters of particle gun
pg.SetParticleByName("e-")
pg.SetParticleEnergy(300.*MeV)
pg.SetParticlePosition(primary_position)
pg.SetParticleMomentumDirection(primary_direction)
# ------------
# Medical Beam
# ------------
#beam= g4py.MedicalBeam.Construct()
# ------------------------------------------------------------------
# go...
# ------------------------------------------------------------------
gRunManager.Initialize()
# visualization
gApplyUICommand("/control/execute vis.mac")
# beamOn
#gRunManager.BeamOn(3)
+2 -6
View File
@@ -24,7 +24,7 @@ def Setup0():
# NIST materials
#g4py.NISTmaterials.Construct()
# normal way for constructing user geometry
#qDC= g4py.Qgeom.QDetectorConstruction()
#gRunManager.SetUserInitialization(qDC)
@@ -125,9 +125,5 @@ pg.SetParticleMomentumDirection(primary_direction)
# ------------------------------------------------------------------
gRunManager.Initialize()
# visualization
gApplyUICommand("/control/execute vis.mac")
# beamOn
#gRunManager.BeamOn(3)
gRunManager.BeamOn(10)
@@ -0,0 +1,8 @@
# add teting
add_test(gtest03 python test.py)
configure_file(test.py test.py)
set_property(TEST gtest03
PROPERTY ENVIRONMENT
PYTHONPATH=./module:${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}
)
+100
View File
@@ -0,0 +1,100 @@
#!/usr/bin/python
# ==================================================================
# python script for Geant4Py test
#
# gtest02
# - test for using site-module packages
# ==================================================================
from Geant4 import *
import g4py.NISTmaterials
import g4py.ezgeom
from g4py.ezgeom import G4EzVolume
import g4py.EMSTDpl
import g4py.ParticleGun
# ==================================================================
# intialize
# ==================================================================
def Configure():
# ------------------------------------------------------------------
# setup for materials
# ------------------------------------------------------------------
# simple materials for Qgeom
g4py.NISTmaterials.Construct()
# ------------------------------------------------------------------
# setup for geometry
# ------------------------------------------------------------------
#g4py.Qgeom.Construct()
g4py.ezgeom.Construct() # initialize
# ------------------------------------------------------------------
# setup for physics list
# ------------------------------------------------------------------
g4py.EMSTDpl.Construct()
# ------------------------------------------------------------------
# setup for primary generator action
# ------------------------------------------------------------------
g4py.ParticleGun.Construct()
gControlExecute("gun.mac")
# ==================================================================
# constructing geometry
# ==================================================================
def ConstructGeom():
print "* Constructing geometry..."
# reset world material
air= G4Material.GetMaterial("G4_AIR")
g4py.ezgeom.SetWorldMaterial(air)
# target
global target
target= G4EzVolume("Target")
au= G4Material.GetMaterial("G4_Au")
target.CreateTubeVolume(au, 0., 1.*cm, 1.*mm)
target.PlaceIt(G4ThreeVector(0.,0.,-10.*cm))
# dummy box
global detector_box, detector_box_pv
detector_box= G4EzVolume("DetectorBox")
detector_box.CreateBoxVolume(air, 20.*cm, 20.*cm, 40.*cm)
detector_box_pv= detector_box.PlaceIt(G4ThreeVector(0.,0.,20.*cm))
# calorimeter
global cal
cal= G4EzVolume("Calorimeter")
nai= G4Material.GetMaterial("G4_SODIUM_IODIDE")
cal.CreateBoxVolume(nai, 5.*cm, 5.*cm, 30.*cm)
dd= 5.*cm
for ical in range(-1, 2):
calPos= G4ThreeVector(dd*ical, 0., 0.)
print calPos
cal.PlaceIt(calPos, ical+1, detector_box)
# ==================================================================
# main
# ==================================================================
# ------------------------------------------------------------------
# randum number
# ------------------------------------------------------------------
rand_engine= Ranlux64Engine()
HepRandom.setTheEngine(rand_engine)
HepRandom.setTheSeed(20050830L)
# setup...
Configure()
ConstructGeom()
# ------------------------------------------------------------------
# go...
# ------------------------------------------------------------------
gRunManager.Initialize()
# visualization
gControlExecute("vis.mac")
# beamOn
#gRunManager.BeamOn(3)
+1 -5
View File
@@ -92,9 +92,5 @@ ConstructGeom()
# ------------------------------------------------------------------
gRunManager.Initialize()
# visualization
gControlExecute("vis.mac")
# beamOn
#gRunManager.BeamOn(3)
gRunManager.BeamOn(10)
@@ -0,0 +1,8 @@
# add teting
add_test(gtest04 python test.py)
configure_file(test.py test.py)
set_property(TEST gtest04
PROPERTY ENVIRONMENT
PYTHONPATH=./module:${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}
)
@@ -0,0 +1,8 @@
# add teting
add_test(gtest05 python test.py)
configure_file(test.py test.py)
set_property(TEST gtest05
PROPERTY ENVIRONMENT
PYTHONPATH=./module:${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}
)
@@ -0,0 +1,8 @@
# add teting
add_test(gtest06 python test.py)
configure_file(test.py test.py)
set_property(TEST gtest06
PROPERTY ENVIRONMENT
PYTHONPATH=./module:${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}
)
@@ -0,0 +1,8 @@
# add teting
add_test(gtest07 python test.py)
configure_file(test.py test.py)
set_property(TEST gtest07
PROPERTY ENVIRONMENT
PYTHONPATH=./module:${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}
)
@@ -0,0 +1,5 @@
# add teting
add_test(test00 python test.py)
configure_file(test.py test.py)
set_property(TEST test00 PROPERTY ENVIRONMENT PYTHONPATH=./module)
@@ -0,0 +1,5 @@
# add teting
add_test(test01 python test.py)
configure_file(test.py test.py)
set_property(TEST test01 PROPERTY ENVIRONMENT PYTHONPATH=./module)
@@ -0,0 +1,5 @@
# add teting
add_test(test02 python test.py)
configure_file(test.py test.py)
set_property(TEST test02 PROPERTY ENVIRONMENT PYTHONPATH=./module)
@@ -0,0 +1,3 @@
# add teting
add_test(test03 echo ok)
@@ -0,0 +1,9 @@
# add teting
add_test(test04-1 python test1.py)
configure_file(test1.py test1.py)
set_property(TEST test04-1 PROPERTY ENVIRONMENT PYTHONPATH=./module)
#
add_test(test04-2 python test2.py)
configure_file(test2.py test2.py)
set_property(TEST test04-2 PROPERTY ENVIRONMENT PYTHONPATH=./module)
@@ -0,0 +1,5 @@
# add teting
add_test(test05 python test.py)
configure_file(test.py test.py)
set_property(TEST test05 PROPERTY ENVIRONMENT PYTHONPATH=./module)
+4 -6
View File
@@ -33,9 +33,7 @@ print "CMethod(1,10.)=", a.CMethod(1,10.)
print "CMethod(1,10.,100.)=", a.CMethod(1,10.,100.)
print ""
print "*** ERRORS!! ***"
a.AMethod(1,2,3) # error
try:
a.AMethod(1,2,3) # error
except:
print "*** ERRORS!! ***"
@@ -0,0 +1,5 @@
# add teting
add_test(test06 python test.py)
configure_file(test.py test.py)
set_property(TEST test06 PROPERTY ENVIRONMENT PYTHONPATH=./module)
+5 -5
View File
@@ -48,8 +48,8 @@ print myx.PVMethod()
print ""
x= test06.XBase()
print "*** Runtime ERROR will occur!" \
" because pure virtual function is called."
x.PVMethod()
try:
x.PVMethod()
except:
print "*** Runtime ERROR occured!" \
" because pure virtual function is called."
@@ -0,0 +1,5 @@
# add teting
add_test(test07 python test.py)
configure_file(test.py test.py)
set_property(TEST test07 PROPERTY ENVIRONMENT PYTHONPATH=./module)
@@ -0,0 +1,5 @@
# add teting
add_test(test08 python test.py)
configure_file(test.py test.py)
set_property(TEST test08 PROPERTY ENVIRONMENT PYTHONPATH=./module)
@@ -0,0 +1,5 @@
# add teting
add_test(test09 python test.py)
configure_file(test.py test.py)
set_property(TEST test09 PROPERTY ENVIRONMENT PYTHONPATH=./module)
@@ -0,0 +1,5 @@
# add teting
add_test(test10 python test.py)
configure_file(test.py test.py)
set_property(TEST test10 PROPERTY ENVIRONMENT PYTHONPATH=./module)
@@ -0,0 +1,5 @@
# add teting
add_test(test11 python test.py)
configure_file(test.py test.py)
set_property(TEST test11 PROPERTY ENVIRONMENT PYTHONPATH=./module)
+4 -1
View File
@@ -7,5 +7,8 @@
import test11
a= test11.AClass(1)
b= test11.AClass()
try:
b = test11.AClass()
except:
print "AClass default constructor is not allowed."
@@ -0,0 +1,5 @@
# add teting
add_test(test12 python test.py)
configure_file(test.py test.py)
set_property(TEST test12 PROPERTY ENVIRONMENT PYTHONPATH=./module)
@@ -0,0 +1,5 @@
# add teting
add_test(test13 python test.py)
configure_file(test.py test.py)
set_property(TEST test13 PROPERTY ENVIRONMENT PYTHONPATH=./module)