Import Geant4 10.6.2 source tree

This commit is contained in:
Gabriele Cosmo
2020-05-29 14:54:29 +02:00
parent 8c87fe78c4
commit c02c370437
448 changed files with 23779 additions and 31516 deletions
+16 -74
View File
@@ -1,82 +1,24 @@
# - Top-level CMakeLists.txt for Geant4Py
# Note that we are assuming it is always part of Geant4, never separately
# released. That's for later, if required at all.
# In particular, Geant4Py must be matched exactly to a given Geant4 release
cmake_minimum_required(VERSION 3.3 FATAL_ERROR)
#------------------------------------------------------------------------------
project(Geant4Py)
#------------------------------------------------------------------------------
# installation prefixes for libraries
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX ${PROJECT_SOURCE_DIR} CACHE
STRING "Install prefix" FORCE)
endif()
# debug mode
set(DEBUG FALSE CACHE BOOL "Debug Mode (Debug On)")
enable_testing()
#------------------------------------------------------------------------------
# Do not edit below
#------------------------------------------------------------------------------
set(CMAKE_CXX_STANDARD 11)
# cmake modules
set(CMAKE_MODULE_PATH
${PROJECT_SOURCE_DIR}/cmake/Modules
${CMAKE_MODULE_PATH})
include(SetInstallPath)
# searching packages...
find_package(Geant4 REQUIRED)
find_package(PythonInterp REQUIRED)
# Require Python 3 or newer, calling Interp before Libs to help find a consistent set
# Boost python requirement is reliant on correct user config (not yet known how to check
# which Python an install of Boost Python uses)...
find_package(PythonInterp 3.0 REQUIRED)
find_package(PythonLibs REQUIRED)
find_package(Boost)
find_package(XercesC)
find_package(ROOT)
find_package(Boost REQUIRED python)
if(NOT GEANT4_FOUND)
message(FATAL_ERROR "NOT Found Geant4.")
endif()
# Variables and Functions to help build, organise, and install modules
include(${CMAKE_CURRENT_SOURCE_DIR}/G4PythonHelpers.cmake)
if(NOT DEFINED BOOST_PYTHON_LIB)
if (${PYTHON_VERSION_MAJOR} MATCHES "2")
set(BOOST_PYTHON_LIB boost_python)
elseif (${PYTHON_VERSION_MAJOR} MATCHES "3")
set(BOOST_PYTHON_LIB boost_python3)
endif()
endif()
#------------------------------------------------------------------------------
# parameters for building
message(STATUS "--------------------------------------------------------")
message(STATUS "Parameters for building")
# build options
if(NOT CMAKE_BUILD_TYPE)
if(DEBUG)
set(CMAKE_BUILD_TYPE "Debug")
else()
set(CMAKE_BUILD_TYPE "RelWithDebInfo")
endif()
endif()
message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
message(STATUS "CMAKE_CXX_COMPILER: ${CMAKE_CXX_COMPILER}")
message(STATUS "CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}")
message(STATUS "--------------------------------------------------------")
#------------------------------------------------------------------------------
# add subdiretories...
# adding sub directories to the project
# libraries
# - Build package/modules, tests if required
add_subdirectory(source)
add_subdirectory(site-modules)
if(GEANT4_ENABLE_TESTING)
add_subdirectory(tests)
endif()
# examples
add_subdirectory(examples)
# Add the feature recording here so we can note the Python version
geant4_add_feature(GEANT4_USE_PYTHON "Building bindings for Python ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}")
# tests
add_subdirectory(tests)
+75
View File
@@ -0,0 +1,75 @@
# Try and get modules output to config dependent site-packages
# Can put all Python outputs under GEANT4_PYTHON_OUTPUT_DIR (and conf variants)
# That's the baseline, packages however need to then adjust output path for
# any substructure
set(GEANT4_PYTHON_OUTPUT_DIR "$<TARGET_FILE_DIR:G4global>/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages")
set(CMAKE_INSTALL_PYTHONDIR "${CMAKE_INSTALL_LIBDIR}/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages")
if(NOT IS_ABSOLUTE "${CMAKE_INSTALL_PYTHONDIR}")
set(CMAKE_INSTALL_FULL_PYTHONDIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_PYTHONDIR}")
else()
set(CMAKE_INSTALL_FULL_PYTHONDIR "${CMAKE_INSTALL_PYTHONDIR}")
endif()
# Extension modules link to libraries so relative RPATH modules to libraries
file(RELATIVE_PATH GEANT4_PYMODULE_RPATH
"${CMAKE_INSTALL_FULL_PYTHONDIR}/Geant4"
"${CMAKE_INSTALL_FULL_LIBDIR}")
# Basic "add module" command to wrap common functionality
# Should also help when migrating to pybind11 or FindPython builtins
function(g4py_add_module target_name)
add_library(${target_name} MODULE ${ARGN})
# Python extension module naming
set_property(TARGET ${target_name} PROPERTY PREFIX "")
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
set_property(TARGET ${target_name} PROPERTY SUFFIX ".pyd")
set_property(TARGET ${target_name} PROPERTY DEBUG_SUFFIX "_d")
endif()
# Adjust output location (may need adjustment on Windows)
set_property(TARGET ${target_name} PROPERTY LIBRARY_OUTPUT_DIRECTORY "${GEANT4_PYTHON_OUTPUT_DIR}")
foreach(_conftype ${CMAKE_CONFIGURATION_TYPES})
string(TOUPPER ${_conftype} _conftype_uppercase)
set_property(TARGET ${target_name} PROPERTY LIBRARY_OUTPUT_DIRECTORY_${_conftype_uppercase} "${GEANT4_PYTHON_OUTPUT_DIR}")
endforeach()
# Force linkage to extension system, other deps to be linked by client
# Use dynamic_lookup on Darwin to avoid direct linking to libpython (Linux has this as default,
# to be checked for Windows)
target_include_directories(${target_name} PRIVATE ${PYTHON_INCLUDE_DIRS})
target_link_libraries(${target_name} PRIVATE Boost::python "$<$<PLATFORM_ID:Darwin>:-undefined dynamic_lookup>")
endfunction()
# Handle core Geant4 modules
# Wraps g4py_add_module, because we have to avoid duplicate target names
# (e.g. "G4global" for libG4global.dylib vs G4global.so)
# It just manages the naming and output name/directory
function(geant4_add_pymodule _name)
if(NOT (_name MATCHES "^pyG4[a-zA-Z0-9_]+"))
message(FATAL_ERROR "Invalid Geant4 Python module name '${_name}'. Names must begin with 'pyG4'")
endif()
set(_module_target "${_name}")
string(REGEX REPLACE "^py" "" _module_lib "${_module_target}")
g4py_add_module(${_module_target} ${ARGN})
set_property(TARGET ${_module_target} PROPERTY OUTPUT_NAME "${_module_lib}")
set_property(TARGET ${_module_target} APPEND_STRING PROPERTY LIBRARY_OUTPUT_DIRECTORY "/Geant4")
foreach(_conftype ${CMAKE_CONFIGURATION_TYPES})
string(TOUPPER ${_conftype} _conftype_uppercase)
set_property(TARGET ${_module_target} APPEND_STRING PROPERTY LIBRARY_OUTPUT_DIRECTORY_${_conftype_uppercase} "/Geant4")
endforeach()
if(UNIX AND NOT APPLE)
set_property(TARGET ${_module_target} PROPERTY
INSTALL_RPATH "\$ORIGIN/${GEANT4_PYMODULE_RPATH}")
elseif(APPLE)
set_property(TARGET ${_module_target} PROPERTY
INSTALL_RPATH "@loader_path/${GEANT4_PYMODULE_RPATH}")
endif()
endfunction()
+4
View File
@@ -11,6 +11,10 @@ Geant4Py is a Geant4-Python bridge.
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
19 Mar. 2020 B. Morgan (geant4py-V10-05-00)
- Integrate build, test, and install of geant4py with core Geant4
CMake buildsystem.
1 Dec. 2019 K. Murakami
- update for 10.6 release
- update for Python3 support
@@ -1,82 +0,0 @@
# - Find Geant4 library
# This module sets up Geant4 information
# It defines:
# GEANT4_FOUND If the Geant4 is found
# GEANT4_INCLUDE_DIR PATH to the include directory
# GEANT4_LIBRARY_DIR PATH to the library directory
# GEANT4_LIBRARIES Most common libraries
# GEANT4_LIBRARIES_WITH_VIS Most common libraries with visualization
find_program(GEANT4_CONFIG NAMES geant4-config
PATHS $ENV{GEANT4_INSTALL}/bin
${GEANT4_INSTALL}/bin
/usr/local/bin /opt/local/bin)
if(GEANT4_CONFIG)
set(GEANT4_FOUND TRUE)
execute_process(COMMAND ${GEANT4_CONFIG} --prefix
OUTPUT_VARIABLE GEANT4_PREFIX
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND ${GEANT4_CONFIG} --version
OUTPUT_VARIABLE GEANT4_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND ${GEANT4_CONFIG} --has-feature gdml
OUTPUT_VARIABLE _TMP)
if (_TMP MATCHES "yes")
set(GEANT4_HAS_GDML TRUE)
else()
set(GEANT4_HAS_GDML FALSE)
endif()
execute_process(COMMAND ${GEANT4_CONFIG} --has-feature opengl-x11
OUTPUT_VARIABLE _TMP)
if (_TMP MATCHES "yes")
set(GEANT4_HAS_OPENGL TRUE)
else()
set(GEANT4_HAS_OPENGL FALSE)
endif()
execute_process(COMMAND ${GEANT4_CONFIG} --has-feature raytracer-x11
OUTPUT_VARIABLE _TMP)
if (_TMP MATCHES "yes")
set(GEANT4_HAS_RAYTRACER_X11 TRUE)
else()
set(GEANT4_HAS_RAYTRACER_X11 FALSE)
endif()
execute_process(COMMAND ${GEANT4_CONFIG} --has-feature motif
OUTPUT_VARIABLE _TMP)
if (_TMP MATCHES "yes")
set(GEANT4_HAS_MOTIF TRUE)
else()
set(GEANT4_HAS_MOTIF FALSE)
endif()
message(STATUS "Found Geant4: ${GEANT4_PREFIX} (${GEANT4_VERSION})")
else()
set(GEANT4_FOUND FALSE)
message(SEND_ERROR "NOT Found Geant4: set GEANT4_INSTALL env.")
endif()
set(GEANT4_INCLUDE_DIR ${GEANT4_PREFIX}/include/Geant4)
set(GEANT4_LIBRARY_DIR ${GEANT4_PREFIX}/${CMAKE_INSTALL_LIBDIR})
set(GEANT4_LIBRARIES G4interfaces G4persistency G4analysis
G4error_propagation G4readout G4physicslists
G4run G4event G4tracking G4parmodels G4processes
G4digits_hits G4track G4particles G4geometry
G4materials G4graphics_reps G4intercoms
G4global G4clhep)
set(GEANT4_LIBRARIES_WITH_VIS
G4OpenGL G4gl2ps G4Tree G4FR G4GMocren G4visHepRep
G4RayTracer G4VRML G4vis_management G4modeling
G4interfaces G4persistency G4analysis
G4error_propagation G4readout G4physicslists
G4run G4event G4tracking G4parmodels G4processes
G4digits_hits G4track G4particles G4geometry
G4materials G4graphics_reps G4intercoms
G4global G4clhep)
@@ -1,39 +0,0 @@
# - Find ROOT library
# This module sets up ROOT information
# It defines:
# ROOT_FOUND If the ROOT is found
# ROOT_INCLUDE_DIR PATH to the include directory
# ROOT_LIBRARIES Most common libraries
# ROOT_LIBRARY_DIR PATH to the library directory
find_program(ROOT_CONFIG_EXECUTABLE root-config
PATHS $ENV{ROOTSYS}/bin)
if(NOT ROOT_CONFIG_EXECUTABLE)
set(ROOT_FOUND FALSE)
message(STATUS "NOT Found ROOT.")
else()
set(ROOT_FOUND TRUE)
execute_process(COMMAND ${ROOT_CONFIG_EXECUTABLE} --prefix
OUTPUT_VARIABLE ROOTSYS
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND ${ROOT_CONFIG_EXECUTABLE} --version
OUTPUT_VARIABLE ROOT_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND ${ROOT_CONFIG_EXECUTABLE} --incdir
OUTPUT_VARIABLE ROOT_INCLUDE_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND ${ROOT_CONFIG_EXECUTABLE} --libs
OUTPUT_VARIABLE ROOT_LIBRARIES
OUTPUT_STRIP_TRAILING_WHITESPACE)
set(ROOT_LIBRARY_DIR ${ROOTSYS}/lib)
message(STATUS "Found ROOT ${ROOT_VERSION} in ${ROOTSYS}")
endif()
@@ -1,79 +0,0 @@
# - Find Xerces-C
# This module tries to find the Xerces-C library and headers.
# Once done this will define
#
# XERCESC_FOUND - system has Xerces-C headers and libraries
# XERCESC_INCLUDE_DIRS - the include directories needed for Xerces-C
# XERCESC_LIBRARIES - the libraries needed to use Xerces-C
#
# Variables used by this module, which can change the default behaviour and
# need to be set before calling find_package:
#
# XERCESC_ROOT_DIR Root directory to Xerces-C installation. Will
# be used ahead of CMake default path.
#
# The following advanced variables may be used if the module has difficulty
# locating Xerces-C or you need fine control over what is used.
#
# XERCESC_INCLUDE_DIR
#
# XERCESC_LIBRARY
#
# Copyright (c) 2009, Ben Morgan, <Ben.Morgan@warwick.ac.uk>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
# Look for the header - preferentially searching below XERCESC_ROOT_DIR
find_path(
XERCESC_INCLUDE_DIR
NAMES xercesc/util/XercesVersion.hpp
PATHS ${XERCESC_ROOT_DIR}
PATH_SUFFIXES include
NO_DEFAULT_PATH
)
# If we didn't find it there, fall back to some standard search paths
find_path(
XERCESC_INCLUDE_DIR
NAMES xercesc/util/XercesVersion.hpp
)
# Look for the library, preferentially searching below XERCESC_ROOT_DIR
find_library(
XERCESC_LIBRARY
NAMES xerces-c xerces-c_3
PATHS ${XERCESC_ROOT_DIR}
PATH_SUFFIXES lib64 lib32 lib
NO_DEFAULT_PATH
)
find_library(
XERCESC_LIBRARY
NAMES xerces-c xerces-c_3
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
XercesC
DEFAULT_MSG
XERCESC_LIBRARY
XERCESC_INCLUDE_DIR
)
if (XERCESC_FOUND)
set(XERCESC_LIBRARIES ${XERCESC_LIBRARY})
set(XERCESC_INCLUDE_DIRS ${XERCESC_INCLUDE_DIR})
else (XERCESC_FOUND)
set(XERCESC_LIBRARIES)
set(XERCESC_INCLUDE_DIRS)
endif (XERCESC_FOUND)
mark_as_advanced(
XERCESC_LIBRARY
XERCESC_INCLUDE_DIR
)
@@ -1,19 +0,0 @@
# - Set install library path
# library path
if(NOT DEFINED CMAKE_INSTALL_LIBDIR)
set(_LIBDIR_DEFAULT "lib")
if(CMAKE_SYSTEM_NAME MATCHES "Linux"
AND NOT EXISTS "/etc/debian_version")
if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
set(_LIBDIR_DEFAULT "lib64")
endif()
endif()
set(CMAKE_INSTALL_LIBDIR "${_LIBDIR_DEFAULT}")
endif()
# include path
if(NOT DEFINED CMAKE_INSTALL_INCDIR)
set(CMAKE_INSTALL_INCDIR "include")
endif()
@@ -1,19 +0,0 @@
# - add libs components
set(G4SITEMODULES_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}/g4py)
include_directories (
${PYTHON_INCLUDE_PATH}
${Boost_INCLUDE_DIRS}
${GEANT4_INCLUDE_DIR}
)
link_directories (${GEANT4_LIBRARY_DIR} ${Boost_LIBRARY_DIRS})
add_subdirectory(geometries)
add_subdirectory(materials)
add_subdirectory(processes)
add_subdirectory(physics_lists)
add_subdirectory(primaries)
add_subdirectory(utils)
add_subdirectory(python)
@@ -1,6 +0,0 @@
# - add libs components
add_subdirectory(ExN01geom)
add_subdirectory(ExN03geom)
add_subdirectory(Qgeom)
add_subdirectory(ezgeom)
@@ -1,23 +0,0 @@
# - build library
# library
set(_TARGET ExN01geom)
add_library(
${_TARGET} SHARED
ExN01DetectorConstruction.cc
pyExN01geom.cc
)
set_target_properties(${_TARGET} PROPERTIES PREFIX "")
set_target_properties(${_TARGET} PROPERTIES SUFFIX ".so")
set_target_properties(${_TARGET}
PROPERTIES INSTALL_RPATH
${GEANT4_LIBRARY_DIR}
BUILD_WITH_INSTALL_RPATH TRUE)
target_link_libraries (${_TARGET}
${GEANT4_LIBRARIES_WITH_VIS} ${BOOST_PYTHON_LIB}
${PYTHON_LIBRARIES})
# install
install(TARGETS ${_TARGET} LIBRARY DESTINATION ${G4SITEMODULES_INSTALL_DIR})
@@ -1,24 +0,0 @@
# - build library
# library
set(_TARGET ExN03geom)
add_library(
${_TARGET} SHARED
ExN03DetectorConstruction.cc
ExN03DetectorMessenger.cc
pyExN03geom.cc
)
set_target_properties(${_TARGET} PROPERTIES PREFIX "")
set_target_properties(${_TARGET} PROPERTIES SUFFIX ".so")
set_target_properties(${_TARGET}
PROPERTIES INSTALL_RPATH
${GEANT4_LIBRARY_DIR}
BUILD_WITH_INSTALL_RPATH TRUE)
target_link_libraries (${_TARGET}
${GEANT4_LIBRARIES_WITH_VIS} ${BOOST_PYTHON_LIB}
${PYTHON_LIBRARIES})
# install
install(TARGETS ${_TARGET} LIBRARY DESTINATION ${G4SITEMODULES_INSTALL_DIR})
@@ -1,23 +0,0 @@
# - build library
# library
set(_TARGET Qgeom)
add_library(
${_TARGET} SHARED
QDetectorConstruction.cc
pyQgeom.cc
)
set_target_properties(${_TARGET} PROPERTIES PREFIX "")
set_target_properties(${_TARGET} PROPERTIES SUFFIX ".so")
set_target_properties(${_TARGET}
PROPERTIES INSTALL_RPATH
${GEANT4_LIBRARY_DIR}
BUILD_WITH_INSTALL_RPATH TRUE)
target_link_libraries (${_TARGET}
${GEANT4_LIBRARIES_WITH_VIS} ${BOOST_PYTHON_LIB}
${PYTHON_LIBRARIES})
# install
install(TARGETS ${_TARGET} LIBRARY DESTINATION ${G4SITEMODULES_INSTALL_DIR})
@@ -1,26 +0,0 @@
# - build library
# library
set(_TARGET ezgeom)
add_library(
${_TARGET} SHARED
EzDetectorConstruction.cc
G4EzVolume.cc
G4EzVoxelParameterization.cc
G4EzWorld.cc
pyEzgeom.cc
)
set_target_properties(${_TARGET} PROPERTIES PREFIX "")
set_target_properties(${_TARGET} PROPERTIES SUFFIX ".so")
set_target_properties(${_TARGET}
PROPERTIES INSTALL_RPATH
${GEANT4_LIBRARY_DIR}
BUILD_WITH_INSTALL_RPATH TRUE)
target_link_libraries (${_TARGET}
${GEANT4_LIBRARIES_WITH_VIS} ${BOOST_PYTHON_LIB}
${PYTHON_LIBRARIES})
# install
install(TARGETS ${_TARGET} LIBRARY DESTINATION ${G4SITEMODULES_INSTALL_DIR})
@@ -1,4 +0,0 @@
# - add libs components
add_subdirectory(NISTmaterials)
add_subdirectory(Qmaterials)
@@ -1,23 +0,0 @@
# - build library
# library
set(_TARGET NISTmaterials)
add_library(
${_TARGET} SHARED
NISTmaterials.cc
pyNISTmaterials.cc
)
set_target_properties(${_TARGET} PROPERTIES PREFIX "")
set_target_properties(${_TARGET} PROPERTIES SUFFIX ".so")
set_target_properties(${_TARGET}
PROPERTIES INSTALL_RPATH
${GEANT4_LIBRARY_DIR}
BUILD_WITH_INSTALL_RPATH TRUE)
target_link_libraries (${_TARGET}
${GEANT4_LIBRARIES_WITH_VIS} ${BOOST_PYTHON_LIB}
${PYTHON_LIBRARIES})
# install
install(TARGETS ${_TARGET} LIBRARY DESTINATION ${G4SITEMODULES_INSTALL_DIR})
@@ -1,23 +0,0 @@
# - build library
# library
set(_TARGET Qmaterials)
add_library(
${_TARGET} SHARED
Qmaterials.cc
pyQmaterials.cc
)
set_target_properties(${_TARGET} PROPERTIES PREFIX "")
set_target_properties(${_TARGET} PROPERTIES SUFFIX ".so")
set_target_properties(${_TARGET}
PROPERTIES INSTALL_RPATH
${GEANT4_LIBRARY_DIR}
BUILD_WITH_INSTALL_RPATH TRUE)
target_link_libraries (${_TARGET}
${GEANT4_LIBRARIES_WITH_VIS} ${BOOST_PYTHON_LIB}
${PYTHON_LIBRARIES})
# install
install(TARGETS ${_TARGET} LIBRARY DESTINATION ${G4SITEMODULES_INSTALL_DIR})
@@ -1,4 +0,0 @@
# - add libs components
add_subdirectory(EMSTDpl)
add_subdirectory(ExN01pl)
@@ -1,23 +0,0 @@
# - build library
# library
set(_TARGET EMSTDpl)
add_library(
${_TARGET} SHARED
PhysicsListEMstd.cc
pyEMSTDpl.cc
)
set_target_properties(${_TARGET} PROPERTIES PREFIX "")
set_target_properties(${_TARGET} PROPERTIES SUFFIX ".so")
set_target_properties(${_TARGET}
PROPERTIES INSTALL_RPATH
${GEANT4_LIBRARY_DIR}
BUILD_WITH_INSTALL_RPATH TRUE)
target_link_libraries (${_TARGET}
${GEANT4_LIBRARIES_WITH_VIS} ${BOOST_PYTHON_LIB}
${PYTHON_LIBRARIES})
# install
install(TARGETS ${_TARGET} LIBRARY DESTINATION ${G4SITEMODULES_INSTALL_DIR})
@@ -1,23 +0,0 @@
# - build library
# library
set(_TARGET ExN01pl)
add_library(
${_TARGET} SHARED
ExN01PhysicsList.cc
pyExN01pl.cc
)
set_target_properties(${_TARGET} PROPERTIES PREFIX "")
set_target_properties(${_TARGET} PROPERTIES SUFFIX ".so")
set_target_properties(${_TARGET}
PROPERTIES INSTALL_RPATH
${GEANT4_LIBRARY_DIR}
BUILD_WITH_INSTALL_RPATH TRUE)
target_link_libraries (${_TARGET}
${GEANT4_LIBRARIES_WITH_VIS} ${BOOST_PYTHON_LIB}
${PYTHON_LIBRARIES})
# install
install(TARGETS ${_TARGET} LIBRARY DESTINATION ${G4SITEMODULES_INSTALL_DIR})
@@ -1,4 +0,0 @@
# - add libs components
add_subdirectory(MedicalBeam)
add_subdirectory(ParticleGun)
@@ -1,23 +0,0 @@
# - build library
# library
set(_TARGET MedicalBeam)
add_library(
${_TARGET} SHARED
MedicalBeam.cc
pyMedicalBeam.cc
)
set_target_properties(${_TARGET} PROPERTIES PREFIX "")
set_target_properties(${_TARGET} PROPERTIES SUFFIX ".so")
set_target_properties(${_TARGET}
PROPERTIES INSTALL_RPATH
${GEANT4_LIBRARY_DIR}
BUILD_WITH_INSTALL_RPATH TRUE)
target_link_libraries (${_TARGET}
${GEANT4_LIBRARIES_WITH_VIS} ${BOOST_PYTHON_LIB}
${PYTHON_LIBRARIES})
# install
install(TARGETS ${_TARGET} LIBRARY DESTINATION ${G4SITEMODULES_INSTALL_DIR})
@@ -1,23 +0,0 @@
# - build library
# library
set(_TARGET ParticleGun)
add_library(
${_TARGET} SHARED
ParticleGunAction.cc
pyParticleGun.cc
)
set_target_properties(${_TARGET} PROPERTIES PREFIX "")
set_target_properties(${_TARGET} PROPERTIES SUFFIX ".so")
set_target_properties(${_TARGET}
PROPERTIES INSTALL_RPATH
${GEANT4_LIBRARY_DIR}
BUILD_WITH_INSTALL_RPATH TRUE)
target_link_libraries (${_TARGET}
${GEANT4_LIBRARIES_WITH_VIS} ${BOOST_PYTHON_LIB}
${PYTHON_LIBRARIES})
# install
install(TARGETS ${_TARGET} LIBRARY DESTINATION ${G4SITEMODULES_INSTALL_DIR})
@@ -1,7 +0,0 @@
# - add libs components
if (${PYTHON_VERSION_MAJOR} MATCHES "2")
add_subdirectory(emcalculator)
elseif (${PYTHON_VERSION_MAJOR} MATCHES "3")
add_subdirectory(emcalculator/python3)
endif()
@@ -1,26 +0,0 @@
# - build library
file (GLOB PY_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.py)
foreach (_pyfile ${PY_FILES})
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/${_pyfile}
${CMAKE_CURRENT_BINARY_DIR}/${_pyfile} COPYONLY)
list (APPEND PYC_FILES "${CMAKE_CURRENT_BINARY_DIR}/${_pyfile}c")
list (APPEND PYO_FILES "${CMAKE_CURRENT_BINARY_DIR}/${_pyfile}o")
endforeach()
add_custom_target (emcalculator ALL)
add_custom_command (
TARGET emcalculator
COMMAND ${PYTHON_EXECUTABLE}
ARGS -m compileall -f ${CMAKE_CURRENT_BINARY_DIR}
COMMAND ${PYTHON_EXECUTABLE}
ARGS -O -m compileall -f ${CMAKE_CURRENT_BINARY_DIR}
)
# install
install (FILES ${PY_FILES} DESTINATION ${G4SITEMODULES_INSTALL_DIR})
install (FILES ${PYC_FILES} DESTINATION ${G4SITEMODULES_INSTALL_DIR})
install (FILES ${PYO_FILES} DESTINATION ${G4SITEMODULES_INSTALL_DIR})
@@ -1,149 +0,0 @@
"""
# ==================================================================
# Python module
#
# Calculation of photon cross section and stopping power for
# chared particles
#
# Q, 2005
# ==================================================================
"""
from Geant4 import *
# ==================================================================
# public symbols
# ==================================================================
__all__ = [ 'CalculatePhotonCrossSection', 'CalculateDEDX' ]
# ==================================================================
# Photon Cross Section
# ==================================================================
def CalculatePhotonCrossSection(mat, elist, verbose=0,
plist=["compt", "", "phot", "conv"]):
"""
Calculate photon cross section for a given material and
a list of energy, returing a list of cross sections for
the components of "Copmton scattering", "rayleigh scattering",
"photoelectric effect", "pair creation" and total one.
Arguments:
mat: material name
elist: list of energy
verbose: verbose level [0]
plist: list of process name
(compton/rayleigh/photoelectic/conversion) [StandardEM set]
Keys of index:
"compt": Compton Scattering
"rayleigh": Rayleigh Scattering
"phot" : photoelectric effect
"conv" : pair Creation
"tot" : total
Example:
xsec_list= CalculatePhotonCrossSection(...)
value= xsec_list[energy_index]["compt"]
"""
if(verbose>0):
print "-------------------------------------------------------------------"
print " Photon Cross Section (", mat, ")"
print "Energy Compton Raleigh Photo- Pair Total"
print " Scattering Scattering electric Creation"
print "(MeV) (cm2/g) (cm2/g) (cm2/g) (cm2/g) (cm2/g)"
print "-------------------------------------------------------------------"
xsection_list= []
for ekin in elist:
xsec= {}
xsec["compt"] \
= gEmCalculator.ComputeCrossSectionPerVolume(ekin, "gamma", plist[0],
mat) * cm2/g
xsec["rayleigh"] \
= gEmCalculator.ComputeCrossSectionPerVolume(ekin, "gamma", plist[1],
mat) * cm2/g
xsec["phot"] \
= gEmCalculator.ComputeCrossSectionPerVolume(ekin, "gamma", plist[2],
mat) * cm2/g
xsec["conv"] \
= gEmCalculator.ComputeCrossSectionPerVolume(ekin, "gamma", plist[3],
mat) * cm2/g
xsec["tot"]= xsec["compt"] + xsec["rayleigh"] + xsec["phot"] + xsec["conv"]
xsection_list.append((ekin, xsec))
if(verbose>0):
print " %8.3e %8.3e %8.3e %8.3e %8.3e %8.3e" \
% (ekin/MeV, xsec["compt"]/(cm2/g), xsec["rayleigh"]/(cm2/g),
xsec["phot"]/(cm2/g), xsec["conv"]/(cm2/g), xsec["tot"]/(cm2/g))
return xsection_list
# ==================================================================
# Stopping Power
# ==================================================================
def CalculateDEDX(part, mat, elist, verbose=0,
plist=["eIoni", "eBrem", "muIoni", "muBrems", "hIoni"]):
"""
Calculate stopping powers for a give particle, material and
a list of energy, returing stopping power for the components of
"Ionization", "Radiation" and total one.
Arguments:
part: particle name
mat: material name
elist: list of energy
verbose: verbose level [0]
plist: list of process name
(electron ionization/electron brems/
muon ionization/muon brems/hadron ionization) [StandardEM set]
Keys of index:
"ioni": ionization
"brems": Bremsstrahlung
"tot": total
Example:
dedx_list= CalculateDEDX(...)
value= dedx_list[energy_index]["ioni"]
"""
if(verbose>0):
print "------------------------------------------------------"
print " Stopping Power (", part, ",", mat, ")"
print " Energy Ionization Radiation Total"
print " (MeV) (MeVcm2/g) (MeVcm2/g) (MeVcm2/g)"
print "------------------------------------------------------"
procname_brems= ""
procname_ioni= ""
if ( part=="e+" or part=="e-" ):
procname_ioni= plist[0]
procname_brems= plist[1]
elif ( part=="mu+" or part=="mu-"):
procname_ioni= plist[2]
procname_brems= plist[3]
else:
procname_ioni= plist[4]
procname_brems= ""
dedx_list= []
for ekin in elist:
dedx= {}
dedx["ioni"] \
= gEmCalculator.ComputeDEDX(ekin, part, procname_ioni, mat) * MeV*cm2/g
dedx["brems"] \
= gEmCalculator.ComputeDEDX(ekin, part, procname_brems, mat) * MeV*cm2/g
dedx["tot"]= dedx["ioni"]+ dedx["brems"]
if(verbose>0):
print " %8.3e %8.3e %8.3e %8.3e" \
% (ekin/MeV, dedx["ioni"]/(MeV*cm2/g),
dedx["brems"]/(MeV*cm2/g), dedx["tot"]/(MeV*cm2/g) )
dedx_list.append((ekin, dedx))
return dedx_list
@@ -1,26 +0,0 @@
# - build library
file (GLOB PY_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.py)
foreach (_pyfile ${PY_FILES})
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/${_pyfile}
${CMAKE_CURRENT_BINARY_DIR}/${_pyfile} COPYONLY)
list (APPEND PYC_FILES "${CMAKE_CURRENT_BINARY_DIR}/${_pyfile}c")
list (APPEND PYO_FILES "${CMAKE_CURRENT_BINARY_DIR}/${_pyfile}o")
endforeach()
add_custom_target (emcalculator ALL)
add_custom_command (
TARGET emcalculator
COMMAND ${PYTHON_EXECUTABLE}
ARGS -m compileall -f ${CMAKE_CURRENT_BINARY_DIR}
COMMAND ${PYTHON_EXECUTABLE}
ARGS -O -m compileall -f ${CMAKE_CURRENT_BINARY_DIR}
)
# install
install (FILES ${PY_FILES} DESTINATION ${G4SITEMODULES_INSTALL_DIR})
#install (FILES ${PYC_FILES} DESTINATION ${G4SITEMODULES_INSTALL_DIR})
#install (FILES ${PYO_FILES} DESTINATION ${G4SITEMODULES_INSTALL_DIR})
@@ -1,26 +0,0 @@
# - build library
file (GLOB PY_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.py)
foreach (_pyfile ${PY_FILES})
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/${_pyfile}
${CMAKE_CURRENT_BINARY_DIR}/${_pyfile} COPYONLY)
list (APPEND PYC_FILES "${CMAKE_CURRENT_BINARY_DIR}/${_pyfile}c")
list (APPEND PYO_FILES "${CMAKE_CURRENT_BINARY_DIR}/${_pyfile}o")
endforeach()
add_custom_target (g4py_module ALL)
add_custom_command (
TARGET g4py_module
COMMAND ${PYTHON_EXECUTABLE}
ARGS -m compileall -f ${CMAKE_CURRENT_BINARY_DIR}
COMMAND ${PYTHON_EXECUTABLE}
ARGS -O -m compileall -f ${CMAKE_CURRENT_BINARY_DIR}
)
# install
install (FILES ${PY_FILES} DESTINATION ${G4SITEMODULES_INSTALL_DIR})
#install (FILES ${PYC_FILES} DESTINATION ${G4SITEMODULES_INSTALL_DIR})
#install (FILES ${PYO_FILES} DESTINATION ${G4SITEMODULES_INSTALL_DIR})
@@ -1,7 +0,0 @@
# - add libs components
if (${PYTHON_VERSION_MAJOR} MATCHES "2")
add_subdirectory(MCScore)
elseif (${PYTHON_VERSION_MAJOR} MATCHES "3")
add_subdirectory(MCScore/python3)
endif()
@@ -1,26 +0,0 @@
# - build library
file (GLOB PY_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.py)
foreach (_pyfile ${PY_FILES})
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/${_pyfile}
${CMAKE_CURRENT_BINARY_DIR}/${_pyfile} COPYONLY)
list (APPEND PYC_FILES "${CMAKE_CURRENT_BINARY_DIR}/${_pyfile}c")
list (APPEND PYO_FILES "${CMAKE_CURRENT_BINARY_DIR}/${_pyfile}o")
endforeach()
add_custom_target (MCScore ALL)
add_custom_command (
TARGET MCScore
COMMAND ${PYTHON_EXECUTABLE}
ARGS -m compileall -f ${CMAKE_CURRENT_BINARY_DIR}
COMMAND ${PYTHON_EXECUTABLE}
ARGS -O -m compileall -f ${CMAKE_CURRENT_BINARY_DIR}
)
# install
install (FILES ${PY_FILES} DESTINATION ${G4SITEMODULES_INSTALL_DIR})
install (FILES ${PYC_FILES} DESTINATION ${G4SITEMODULES_INSTALL_DIR})
install (FILES ${PYO_FILES} DESTINATION ${G4SITEMODULES_INSTALL_DIR})
@@ -1,136 +0,0 @@
"""
Python module
This module provides classes and functions for scoring reactions
[C] MCVertex:
[C] MCParticle:
[f] read_next_vertex(stream):
Q, 2006
"""
import string
from Geant4.hepunit import *
# ==================================================================
# public symbols
# ==================================================================
__all__ = [ 'MCParticle', 'MCVertex', 'read_next_vertex' ]
# ==================================================================
# class definition
# ==================================================================
# ------------------------------------------------------------------
# MCParticle
# ------------------------------------------------------------------
class MCParticle:
"MC particle"
def __init__(self, aname, aZ, aA, akE, apx, apy, apz):
self.name = aname
self.Z = aZ
self.A = aA
self.kineticE = akE
self.px = apx
self.py = apy
self.pz = apz
def printout(self):
print "--- particle: %s, Z=%2d, A=%2d, kE=%g" % \
(self.name, self.Z, self.A, self.kineticE/MeV)
# ------------------------------------------------------------------
# MCVertex
# ------------------------------------------------------------------
class MCVertex :
"MC vertex"
def __init__(self, ax, ay, az):
self.x = ax
self.y = ay
self.z = az
self.nparticle = 0
self.particle_list = []
def append_particle(self, aparticle):
self.particle_list.append(aparticle)
self.nparticle= self.nparticle+1
def printout(self):
print "@@@ vertex: x=(%g,%g,%g) Nsec=%3d" % \
(self.x/cm, self.y/cm, self.z/cm, self.nparticle)
for p in self.particle_list:
p.printout()
def dump_vertex(self, stream):
aline = "%g %g %g %d\n" % \
(self.x/m, self.y/m, self.z/m, self.nparticle)
stream.write(aline)
for p in self.particle_list:
aline = " %s %d %d %g %g %g %g\n" % \
(p.name, p.Z, p.A, p.kineticE/MeV, p.px/MeV, p.py/MeV, p.pz/MeV)
stream.write(aline)
def __del__(self):
np = len(self.particle_list)
del self.particle_list[0:np]
# ==================================================================
# I/O interface
# ==================================================================
def read_next_vertex(stream):
"read next vertex from a file stream"
line= stream.readline()
if line == "": # EOF
return 0
# reading vertex
data = line.split()
x = string.atof(data[0]) * m
y = string.atof(data[1]) * m
z = string.atof(data[2]) * m
nsec = string.atoi(data[3])
vertex = MCVertex(x,y,z)
# reading particles
for p in range(0, nsec):
data = stream.readline().split()
pname = data[0]
Z = string.atoi(data[1])
A = string.atoi(data[2])
kE = string.atof(data[3]) * MeV
px = string.atof(data[4]) * MeV
py = string.atof(data[5]) * MeV
pz = string.atof(data[6]) * MeV
particle = MCParticle(pname, Z, A, kE, px, py, pz)
vertex.append_particle(particle)
return vertex
# ==================================================================
# test
# ==================================================================
def test():
f = open("reaction.dat")
f.seek(0)
while(1):
vertex = read_next_vertex(f)
if vertex == 0:
break
vertex.printout()
del vertex
f.close()
print ">>> EOF"
# ==================================================================
# main
# ==================================================================
if __name__ == "__main__":
test()
@@ -1,26 +0,0 @@
# - build library
file (GLOB PY_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.py)
foreach (_pyfile ${PY_FILES})
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/${_pyfile}
${CMAKE_CURRENT_BINARY_DIR}/${_pyfile} COPYONLY)
list (APPEND PYC_FILES "${CMAKE_CURRENT_BINARY_DIR}/${_pyfile}c")
list (APPEND PYO_FILES "${CMAKE_CURRENT_BINARY_DIR}/${_pyfile}o")
endforeach()
add_custom_target (MCScore ALL)
add_custom_command (
TARGET MCScore
COMMAND ${PYTHON_EXECUTABLE}
ARGS -m compileall -f ${CMAKE_CURRENT_BINARY_DIR}
COMMAND ${PYTHON_EXECUTABLE}
ARGS -O -m compileall -f ${CMAKE_CURRENT_BINARY_DIR}
)
# install
install (FILES ${PY_FILES} DESTINATION ${G4SITEMODULES_INSTALL_DIR})
#install (FILES ${PYC_FILES} DESTINATION ${G4SITEMODULES_INSTALL_DIR})
#install (FILES ${PYO_FILES} DESTINATION ${G4SITEMODULES_INSTALL_DIR})
+42 -16
View File
@@ -1,16 +1,9 @@
# - add libs components
# Private interface library to help Boost.Python usage
add_library(pyG4Boost INTERFACE)
target_include_directories(pyG4Boost INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/boost")
set(G4MODULES_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}/Geant4)
include_directories (
${PYTHON_INCLUDE_PATH}
${Boost_INCLUDE_DIRS}
${PROJECT_SOURCE_DIR}/source/boost
${GEANT4_INCLUDE_DIR}
)
link_directories (${GEANT4_LIBRARY_DIR} ${Boost_LIBRARY_DIRS})
# Core Geant4 bindings
add_subdirectory(global)
add_subdirectory(interface)
add_subdirectory(intercoms)
@@ -26,10 +19,43 @@ add_subdirectory(digits_hits)
add_subdirectory(visualization)
add_subdirectory(graphics_reps)
add_subdirectory(physics_lists)
add_subdirectory(gdml)
if (${PYTHON_VERSION_MAJOR} MATCHES "2")
add_subdirectory(python)
elseif (${PYTHON_VERSION_MAJOR} MATCHES "3")
add_subdirectory(python3)
# Only if GDML
if(GEANT4_USE_GDML)
add_subdirectory(gdml)
endif()
# Pure Python Geant4 extensions
set(GEANT4_PYTHON_MODULES
__init__.py
colortable.py
g4thread.py
g4viscp.py
hepunit.py)
set(GEANT4_PYTHON_BYTECOMPILE_INPUT)
set(GEANT4_PYTHON_BYTECOMPILE_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/__pycache__")
foreach(_pymod ${GEANT4_PYTHON_MODULES})
# Generate used to support testing and multimode so .py/pyc files are in the
# same place as the output extensions
file(GENERATE
OUTPUT ${GEANT4_PYTHON_OUTPUT_DIR}/Geant4/${_pymod}
INPUT ${CMAKE_CURRENT_SOURCE_DIR}/${_pymod})
# Configure module for byte-compilation at install time
# We do this locally because add_custom_command cannot use genexes in
# its OUTPUT command
configure_file(${_pymod} ${CMAKE_CURRENT_BINARY_DIR}/${_pymod} COPYONLY)
list(APPEND GEANT4_PYTHON_BYTECOMPILE_INPUT ${CMAKE_CURRENT_BINARY_DIR}/${_pymod})
endforeach()
add_custom_command(
OUTPUT "${GEANT4_PYTHON_BYTECOMPILE_OUTPUT}"
COMMAND ${PYTHON_EXECUTABLE} -m compileall -q ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS ${GEANT4_PYTHON_BYTECOMPILE_INPUT}
COMMENT "Byte-compiling Geant4 .py modules")
add_custom_target(pyG4ByteCompile ALL DEPENDS "${GEANT4_PYTHON_BYTECOMPILE_OUTPUT}")
install(FILES ${GEANT4_PYTHON_BYTECOMPILE_INPUT} DESTINATION "${CMAKE_INSTALL_PYTHONDIR}/Geant4")
install(DIRECTORY ${GEANT4_PYTHON_BYTECOMPILE_OUTPUT} DESTINATION "${CMAKE_INSTALL_PYTHONDIR}/Geant4")
@@ -12,7 +12,7 @@ __date__ = 'December/2019'
__author__ = 'K.Murakami (Koichi.Murakami@kek.jp)'
# import submodules
from .G4interface import *
from .G4interfaces import *
from .G4intercoms import *
from .G4global import *
from .G4run import *
@@ -26,7 +26,6 @@ from .G4materials import *
from .G4physicslists import *
from .G4digits_hits import *
from .G4visualization import *
from .G4gdml import *
from .G4graphics_reps import *
from .hepunit import *
from .colortable import *
@@ -162,7 +161,7 @@ gG4VERSION_NUMBER = G4VERSION_NUMBER
gControlExecute = gUImanager.ExecuteMacroFile
gApplyUICommand = G4intercoms.ApplyUICommand
gGetCurrentValues = gUImanager.GetCurrentValues
gStartUISession = G4interface.StartUISession
gStartUISession = G4interfaces.StartUISession
# ==================================================================
@@ -1,25 +1,10 @@
# - build library
# library
set(_TARGET pyG4digits_hits)
add_library(
${_TARGET} SHARED
geant4_add_pymodule(pyG4digits_hits
pyG4VSensitiveDetector.cc
pymodG4digits_hits.cc
)
set_target_properties(${_TARGET} PROPERTIES PREFIX "")
set_target_properties(${_TARGET} PROPERTIES OUTPUT_NAME "G4digits_hits")
set_target_properties(${_TARGET} PROPERTIES SUFFIX ".so")
set_target_properties(${_TARGET}
PROPERTIES INSTALL_RPATH
${GEANT4_LIBRARY_DIR}
BUILD_WITH_INSTALL_RPATH TRUE)
target_link_libraries (${_TARGET}
${GEANT4_LIBRARIES_WITH_VIS} ${BOOST_PYTHON_LIB}
${PYTHON_LIBRARIES})
# install
install(TARGETS ${_TARGET} LIBRARY DESTINATION ${G4MODULES_INSTALL_DIR})
target_link_libraries(pyG4digits_hits PRIVATE G4digits_hits)
install(TARGETS pyG4digits_hits DESTINATION "${CMAKE_INSTALL_PYTHONDIR}/Geant4")
+3 -17
View File
@@ -1,9 +1,7 @@
# - build library
# library
set(_TARGET pyG4event)
add_library(
${_TARGET} SHARED
geant4_add_pymodule(pyG4event
pyG4ClassificationOfNewTrack.cc
pyG4Event.cc
pyG4EventManager.cc
@@ -14,17 +12,5 @@ add_library(
pymodG4event.cc
)
set_target_properties (${_TARGET} PROPERTIES PREFIX "" )
set_target_properties(${_TARGET} PROPERTIES OUTPUT_NAME "G4event")
set_target_properties(${_TARGET} PROPERTIES SUFFIX ".so")
set_target_properties(${_TARGET}
PROPERTIES INSTALL_RPATH
${GEANT4_LIBRARY_DIR}
BUILD_WITH_INSTALL_RPATH TRUE)
target_link_libraries (${_TARGET}
${GEANT4_LIBRARIES_WITH_VIS} ${BOOST_PYTHON_LIB}
${PYTHON_LIBRARIES})
# install
install(TARGETS ${_TARGET} LIBRARY DESTINATION ${G4MODULES_INSTALL_DIR})
target_link_libraries(pyG4event PRIVATE G4event)
install(TARGETS pyG4event DESTINATION "${CMAKE_INSTALL_PYTHONDIR}/Geant4")
+3 -25
View File
@@ -1,30 +1,8 @@
# - build library
if(GEANT4_HAS_GDML)
add_definitions(-DENABLE_GDML)
endif()
include_directories (${XERCESC_INCLUDE_DIRS})
# library
set(_TARGET pyG4gdml)
add_library(
${_TARGET} SHARED
geant4_add_pymodule(pyG4gdml
pyG4GDMLParser.cc
pymodG4g4gdml.cc
)
set_target_properties(${_TARGET} PROPERTIES PREFIX "")
set_target_properties(${_TARGET} PROPERTIES OUTPUT_NAME "G4gdml")
set_target_properties(${_TARGET} PROPERTIES SUFFIX ".so")
set_target_properties(${_TARGET}
PROPERTIES INSTALL_RPATH
${GEANT4_LIBRARY_DIR}
BUILD_WITH_INSTALL_RPATH TRUE)
target_link_libraries (${_TARGET}
${GEANT4_LIBRARIES_WITH_VIS} ${XERCESC_LIBRARY}
${BOOST_PYTHON_LIB} ${PYTHON_LIBRARIES})
# install
install(TARGETS ${_TARGET} LIBRARY DESTINATION ${G4MODULES_INSTALL_DIR})
target_link_libraries(pyG4gdml PRIVATE G4persistency)
install(TARGETS pyG4gdml DESTINATION "${CMAKE_INSTALL_PYTHONDIR}/Geant4")
@@ -28,7 +28,6 @@
//
// 2007 Q
// ====================================================================
#ifdef ENABLE_GDML
#include <boost/python.hpp>
#include "G4GDMLParser.hh"
@@ -43,21 +42,21 @@ using namespace boost::python;
// ====================================================================
namespace pyG4GDMLParser {
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_GetWorldVolume,
GetWorldVolume, 0, 1);
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_GetWorldVolume,
GetWorldVolume, 0, 1)
void (G4GDMLParser::*f1_Write)
(const G4String&, const G4VPhysicalVolume*, G4bool,
(const G4String&, const G4VPhysicalVolume*, G4bool,
const G4String&) = &G4GDMLParser::Write;
void (G4GDMLParser::*f2_Write)
(const G4String&, const G4LogicalVolume*, G4bool,
const G4String&) = &G4GDMLParser::Write;
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(g_Write, Write, 2, 4);
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_Read, Read, 1, 2);
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_ReadModule, ReadModule, 1, 2);
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_Write, Write, 1, 4);
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(g_Write, Write, 2, 4)
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_Read, Read, 1, 2)
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_ReadModule, ReadModule, 1, 2)
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_Write, Write, 1, 4)
}
@@ -83,4 +82,3 @@ void export_G4GDMLParser()
;
}
#endif
@@ -36,14 +36,10 @@ using namespace boost::python;
// module definition
// ====================================================================
#ifdef ENABLE_GDML
void export_G4GDMLParser();
#endif
BOOST_PYTHON_MODULE(G4gdml)
{
#ifdef ENABLE_GDML
export_G4GDMLParser();
#endif
}
@@ -1,9 +1,7 @@
# - build library
# library
set(_TARGET pyG4geometry)
add_library (
${_TARGET} SHARED
geant4_add_pymodule(pyG4geometry
pyG4BooleanSolid.cc
pyG4Box.cc
pyG4ChordFinder.cc
@@ -47,17 +45,5 @@ add_library (
pymodG4geometry.cc
)
set_target_properties(${_TARGET} PROPERTIES PREFIX "")
set_target_properties(${_TARGET} PROPERTIES OUTPUT_NAME "G4geometry")
set_target_properties(${_TARGET} PROPERTIES SUFFIX ".so")
set_target_properties(${_TARGET}
PROPERTIES INSTALL_RPATH
${GEANT4_LIBRARY_DIR}
BUILD_WITH_INSTALL_RPATH TRUE)
target_link_libraries (${_TARGET}
${GEANT4_LIBRARIES_WITH_VIS} ${BOOST_PYTHON_LIB}
${PYTHON_LIBRARIES})
# install
install(TARGETS ${_TARGET} LIBRARY DESTINATION ${G4MODULES_INSTALL_DIR})
target_link_libraries(pyG4geometry PRIVATE G4geometry G4track G4processes)
install(TARGETS pyG4geometry DESTINATION "${CMAKE_INSTALL_PYTHONDIR}/Geant4")
@@ -50,7 +50,7 @@ const G4ChordFinder*(G4FieldManager::*f2_GetChordFinder)() const
= &G4FieldManager::GetChordFinder;
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_SetDetectorField,
SetDetectorField, 1, 2);
SetDetectorField, 1, 2)
}
@@ -67,6 +67,8 @@ namespace pyG4MagneticField {
struct CB_PyG4MagneticField :
PyG4MagneticField, wrapper<PyG4MagneticField> {
using PyG4MagneticField::GetFieldValue;
G4ThreeVector GetFieldValue(const G4ThreeVector& pos,
const G4double time) const {
return get_override("GetFieldValue")(pos, time);
@@ -29,6 +29,7 @@
// 2007 Q
// ====================================================================
#include <boost/python.hpp>
#include <memory>
#include "G4Polycone.hh"
using namespace boost::python;
@@ -46,9 +47,9 @@ G4Polycone* f1_CreatePolycone(const G4String& name, G4double phiStart,
const std::vector<G4double>& rInner,
const std::vector<G4double>& rOuter)
{
G4double zlist[numZPlanes];
G4double r0list[numZPlanes];
G4double r1list[numZPlanes];
std::unique_ptr<G4double[]> zlist(new G4double[numZPlanes]);
std::unique_ptr<G4double[]> r0list(new G4double[numZPlanes]);
std::unique_ptr<G4double[]> r1list(new G4double[numZPlanes]);
for (G4int i=0; i< numZPlanes; i++) {
zlist[i]= zPlane[i];
@@ -57,7 +58,7 @@ G4Polycone* f1_CreatePolycone(const G4String& name, G4double phiStart,
}
return new G4Polycone(name, phiStart, phiTotal, numZPlanes,
zlist, r0list, r1list);
zlist.get(), r0list.get(), r1list.get());
}
@@ -66,8 +67,8 @@ G4Polycone* f2_CreatePolycone(const G4String& name, G4double phiStart,
const std::vector<G4double>& r,
const std::vector<G4double>& z)
{
G4double zlist[numRZ];
G4double rlist[numRZ];
std::unique_ptr<G4double[]> zlist(new G4double[numRZ]);
std::unique_ptr<G4double[]> rlist(new G4double[numRZ]);
for (G4int i=0; i< numRZ; i++) {
rlist[i]= r[i];
@@ -75,7 +76,7 @@ G4Polycone* f2_CreatePolycone(const G4String& name, G4double phiStart,
}
return new G4Polycone(name, phiStart, phiTotal, numRZ,
rlist, zlist);
rlist.get(), zlist.get());
}
@@ -29,6 +29,7 @@
// 2007 Q
// ====================================================================
#include <boost/python.hpp>
#include <memory>
#include "G4Polyhedra.hh"
using namespace boost::python;
@@ -40,16 +41,16 @@ namespace pyG4Polyhedra {
// create solid methods
G4Polyhedra* f1_CreatePolyhedra(const G4String& name,
G4double phiStart, G4double phiTotal,
G4Polyhedra* f1_CreatePolyhedra(const G4String& name,
G4double phiStart, G4double phiTotal,
G4int numSide, G4int numZPlanes,
const std::vector<G4double>& zPlane,
const std::vector<G4double>& rInner,
const std::vector<G4double>& rOuter)
{
G4double zlist[numZPlanes];
G4double r0list[numZPlanes];
G4double r1list[numZPlanes];
std::unique_ptr<G4double[]> zlist(new G4double[numZPlanes]);
std::unique_ptr<G4double[]> r0list(new G4double[numZPlanes]);
std::unique_ptr<G4double[]> r1list(new G4double[numZPlanes]);
for (G4int i=0; i< numZPlanes; i++) {
zlist[i]= zPlane[i];
@@ -58,26 +59,26 @@ G4Polyhedra* f1_CreatePolyhedra(const G4String& name,
}
return new G4Polyhedra(name, phiStart, phiTotal, numSide, numZPlanes,
zlist, r0list, r1list);
zlist.get(), r0list.get(), r1list.get());
}
G4Polyhedra* f2_CreatePolyhedra(const G4String& name,
G4double phiStart, G4double phiTotal,
G4int numSide, G4int numRZ,
const std::vector<G4double>& r,
const std::vector<G4double>& r,
const std::vector<G4double>& z)
{
G4double zlist[numRZ];
G4double rlist[numRZ];
std::unique_ptr<G4double[]> zlist(new G4double[numRZ]);
std::unique_ptr<G4double[]> rlist(new G4double[numRZ]);
for (G4int i=0; i< numRZ; i++) {
zlist[i]= z[i];
rlist[i]= r[i];
}
return new G4Polyhedra(name, phiStart, phiTotal, numSide, numRZ,
rlist, zlist);
return new G4Polyhedra(name, phiStart, phiTotal, numSide, numRZ,
rlist.get(), zlist.get());
}
+4 -20
View File
@@ -1,9 +1,5 @@
# - build library
# library
set(_TARGET pyG4global)
add_library(
${_TARGET} SHARED
# - Module
geant4_add_pymodule(pyG4global
G4PyCoutDestination.cc
pyG4ApplicationState.cc
pyG4Exception.cc
@@ -27,17 +23,5 @@ add_library(
pymodG4global.cc
)
set_target_properties(${_TARGET} PROPERTIES PREFIX "")
set_target_properties(${_TARGET} PROPERTIES OUTPUT_NAME "G4global")
set_target_properties(${_TARGET} PROPERTIES SUFFIX ".so")
set_target_properties(${_TARGET}
PROPERTIES INSTALL_RPATH
${GEANT4_LIBRARY_DIR}
BUILD_WITH_INSTALL_RPATH TRUE)
target_link_libraries (${_TARGET}
${GEANT4_LIBRARIES_WITH_VIS} ${BOOST_PYTHON_LIB}
${PYTHON_LIBRARIES})
# install
install(TARGETS ${_TARGET} LIBRARY DESTINATION ${G4MODULES_INSTALL_DIR})
target_link_libraries(pyG4global PRIVATE G4global G4track pyG4Boost)
install(TARGETS pyG4global DESTINATION "${CMAKE_INSTALL_PYTHONDIR}/Geant4")
@@ -30,6 +30,8 @@
// ====================================================================
#include <boost/python.hpp>
#include "G4UserLimits.hh"
// Needed to avoid "incomplete type" error on G4Track
#include "G4Track.hh"
using namespace boost::python;
+3 -3
View File
@@ -40,15 +40,15 @@
using namespace boost::python;
extern G4strstreambuf G4coutbuf;
extern G4strstreambuf G4cerrbuf;
//extern G4strstreambuf G4coutbuf;
//extern G4strstreambuf G4cerrbuf;
namespace pyglobals {
// G4cout/cerr are set to Python stdout
void SetG4PyCoutDestination()
{
G4UImanager* UImgr= G4UImanager::GetUIpointer();
G4UImanager::GetUIpointer();
G4PyCoutDestination* pycout= new G4PyCoutDestination();
G4coutbuf.SetDestination(pycout);
G4cerrbuf.SetDestination(pycout);
@@ -1,25 +1,11 @@
# - build library
# library
set(_TARGET pyG4graphics_reps)
add_library(
${_TARGET} SHARED
geant4_add_pymodule(pyG4graphics_reps
pyG4Colour.cc
pyG4VisAttributes.cc
pymodG4graphics_reps.cc
)
set_target_properties(${_TARGET} PROPERTIES PREFIX "")
set_target_properties(${_TARGET} PROPERTIES OUTPUT_NAME "G4graphics_reps")
set_target_properties(${_TARGET} PROPERTIES SUFFIX ".so")
set_target_properties(${_TARGET}
PROPERTIES INSTALL_RPATH
${GEANT4_LIBRARY_DIR}
BUILD_WITH_INSTALL_RPATH TRUE)
target_link_libraries (${_TARGET}
${GEANT4_LIBRARIES_WITH_VIS} ${BOOST_PYTHON_LIB}
${PYTHON_LIBRARIES})
# install
install(TARGETS ${_TARGET} LIBRARY DESTINATION ${G4MODULES_INSTALL_DIR})
target_link_libraries(pyG4graphics_reps PRIVATE G4graphics_reps)
install(TARGETS pyG4graphics_reps DESTINATION "${CMAKE_INSTALL_PYTHONDIR}/Geant4")
@@ -1,9 +1,7 @@
# - build library
# library
set(_TARGET pyG4intercoms)
add_library(
${_TARGET} SHARED
geant4_add_pymodule(pyG4intercoms
pyG4UIcommand.cc
pyG4UIcommandTree.cc
pyG4UImanager.cc
@@ -11,17 +9,5 @@ add_library(
pymodG4intercoms.cc
)
set_target_properties(${_TARGET} PROPERTIES PREFIX "")
set_target_properties(${_TARGET} PROPERTIES OUTPUT_NAME "G4intercoms")
set_target_properties(${_TARGET} PROPERTIES SUFFIX ".so")
set_target_properties(${_TARGET}
PROPERTIES INSTALL_RPATH
${GEANT4_LIBRARY_DIR}
BUILD_WITH_INSTALL_RPATH TRUE)
target_link_libraries (${_TARGET}
${GEANT4_LIBRARIES_WITH_VIS} ${BOOST_PYTHON_LIB}
${PYTHON_LIBRARIES})
# install
install(TARGETS ${_TARGET} LIBRARY DESTINATION ${G4MODULES_INSTALL_DIR})
target_link_libraries(pyG4intercoms PRIVATE G4intercoms)
install(TARGETS pyG4intercoms DESTINATION "${CMAKE_INSTALL_PYTHONDIR}/Geant4")
@@ -1,24 +1,10 @@
# - build library
# library
set(_TARGET pyG4interface)
add_library(
${_TARGET} SHARED
geant4_add_pymodule(pyG4interfaces
pyG4UIterminal.cc
pymodG4interface.cc
)
set_target_properties(${_TARGET} PROPERTIES PREFIX "")
set_target_properties(${_TARGET} PROPERTIES OUTPUT_NAME "G4interface")
set_target_properties(${_TARGET} PROPERTIES SUFFIX ".so")
set_target_properties(${_TARGET}
PROPERTIES INSTALL_RPATH
${GEANT4_LIBRARY_DIR}
BUILD_WITH_INSTALL_RPATH TRUE)
target_link_libraries (${_TARGET}
${GEANT4_LIBRARIES_WITH_VIS} ${BOOST_PYTHON_LIB}
${PYTHON_LIBRARIES})
# install
install(TARGETS ${_TARGET} LIBRARY DESTINATION ${G4MODULES_INSTALL_DIR})
target_link_libraries(pyG4interfaces PRIVATE G4interfaces)
install(TARGETS pyG4interfaces DESTINATION "${CMAKE_INSTALL_PYTHONDIR}/Geant4")
@@ -38,7 +38,7 @@ using namespace boost::python;
void export_G4UIterminal();
BOOST_PYTHON_MODULE(G4interface)
BOOST_PYTHON_MODULE(G4interfaces)
{
export_G4UIterminal();
}
@@ -1,9 +1,7 @@
# - build library
# library
set(_TARGET pyG4materials)
add_library(
${_TARGET} SHARED
geant4_add_pymodule(pyG4materials
pyG4AtomicShells.cc
pyG4Element.cc
pyG4ElementTable.cc
@@ -15,17 +13,5 @@ add_library(
pymodG4materials.cc
)
set_target_properties(${_TARGET} PROPERTIES PREFIX "")
set_target_properties(${_TARGET} PROPERTIES OUTPUT_NAME "G4materials")
set_target_properties(${_TARGET} PROPERTIES SUFFIX ".so")
set_target_properties(${_TARGET}
PROPERTIES INSTALL_RPATH
${GEANT4_LIBRARY_DIR}
BUILD_WITH_INSTALL_RPATH TRUE)
target_link_libraries (${_TARGET}
${GEANT4_LIBRARIES_WITH_VIS} ${BOOST_PYTHON_LIB}
${PYTHON_LIBRARIES})
# install
install(TARGETS ${_TARGET} LIBRARY DESTINATION ${G4MODULES_INSTALL_DIR})
target_link_libraries(pyG4materials PRIVATE G4materials pyG4Boost)
install(TARGETS pyG4materials DESTINATION "${CMAKE_INSTALL_PYTHONDIR}/Geant4")
@@ -1,9 +1,7 @@
# - build library
# library
set(_TARGET pyG4particles)
add_library(
${_TARGET} SHARED
geant4_add_pymodule(pyG4particles
pyG4DecayTable.cc
pyG4DynamicParticle.cc
pyG4ParticleDefinition.cc
@@ -14,17 +12,5 @@ add_library(
pymodG4particles.cc
)
set_target_properties(${_TARGET} PROPERTIES PREFIX "")
set_target_properties(${_TARGET} PROPERTIES OUTPUT_NAME "G4particles")
set_target_properties(${_TARGET} PROPERTIES SUFFIX ".so")
set_target_properties(${_TARGET}
PROPERTIES INSTALL_RPATH
${GEANT4_LIBRARY_DIR}
BUILD_WITH_INSTALL_RPATH TRUE)
target_link_libraries (${_TARGET}
${GEANT4_LIBRARIES_WITH_VIS} ${BOOST_PYTHON_LIB}
${PYTHON_LIBRARIES})
# install
install(TARGETS ${_TARGET} LIBRARY DESTINATION ${G4MODULES_INSTALL_DIR})
target_link_libraries(pyG4particles PRIVATE G4particles G4processes)
install(TARGETS pyG4particles DESTINATION "${CMAKE_INSTALL_PYTHONDIR}/Geant4")
@@ -46,14 +46,13 @@ public:
p_iterator p_begin() {
G4ParticleTable* particleTable= G4ParticleTable::GetParticleTable();
if(particleTableCache.size() != particleTable-> size() ) {
if(particleTableCache.size() != static_cast<size_t>(particleTable-> size()) ) {
particleTableCache.clear();
G4ParticleTable::G4PTblDicIterator*
theParticleIterator= particleTable-> GetIterator();
G4ParticleTable::G4PTblDicIterator* theParticleIterator= particleTable-> GetIterator();
theParticleIterator-> reset();
while( (*theParticleIterator)() ){
G4ParticleDefinition* particle= theParticleIterator-> value();
particleTableCache.push_back(particle);
G4ParticleDefinition* particle= theParticleIterator-> value();
particleTableCache.push_back(particle);
}
}
return particleTableCache.begin();
@@ -61,14 +60,13 @@ public:
p_iterator p_end() {
G4ParticleTable* particleTable= G4ParticleTable::GetParticleTable();
if(particleTableCache.size() != particleTable-> size() ) {
if(particleTableCache.size() != static_cast<size_t>(particleTable-> size()) ) {
particleTableCache.clear();
G4ParticleTable::G4PTblDicIterator*
theParticleIterator= particleTable-> GetIterator();
G4ParticleTable::G4PTblDicIterator* theParticleIterator= particleTable-> GetIterator();
theParticleIterator-> reset();
while( (*theParticleIterator)() ){
G4ParticleDefinition* particle= theParticleIterator-> value();
particleTableCache.push_back(particle);
G4ParticleDefinition* particle= theParticleIterator-> value();
particleTableCache.push_back(particle);
}
}
return particleTableCache.end();
@@ -85,7 +83,7 @@ void export_PyG4ParticleList()
{
class_<PyG4ParticleList>("PyG4ParticleList", "particle list")
.def("__iter__", iterator<PyG4ParticleList::ParticleList>())
.add_property("particles", range(&PyG4ParticleList::p_begin,
.add_property("particles", range(&PyG4ParticleList::p_begin,
&PyG4ParticleList::p_end))
;
}
@@ -1,24 +1,9 @@
# - build library
# library
set(_TARGET pyG4physicslists)
add_library(
${_TARGET} SHARED
geant4_add_pymodule(pyG4physicslists
pyPhysicsLists.cc
pymodG4physicslists.cc
)
set_target_properties(${_TARGET} PROPERTIES PREFIX "")
set_target_properties(${_TARGET} PROPERTIES OUTPUT_NAME "G4physicslists")
set_target_properties(${_TARGET} PROPERTIES SUFFIX ".so")
set_target_properties(${_TARGET}
PROPERTIES INSTALL_RPATH
${GEANT4_LIBRARY_DIR}
BUILD_WITH_INSTALL_RPATH TRUE)
target_link_libraries (${_TARGET}
${GEANT4_LIBRARIES_WITH_VIS} ${BOOST_PYTHON_LIB}
${PYTHON_LIBRARIES})
# install
install(TARGETS ${_TARGET} LIBRARY DESTINATION ${G4MODULES_INSTALL_DIR})
target_link_libraries(pyG4physicslists PRIVATE G4physicslists)
install(TARGETS pyG4physicslists DESTINATION "${CMAKE_INSTALL_PYTHONDIR}/Geant4")
@@ -74,8 +74,8 @@ void AddPhysicsList(const G4String& plname) {
}
void ListPhysicsList() {
for (G4int i=0; i< plList.size(); i++) {
G4cout << plList[i] << G4endl;
for (const auto& p : plList) {
G4cout << p << G4endl;
}
}
@@ -1,9 +1,7 @@
# - build library
# library
set(_TARGET pyG4processes)
add_library(
${_TARGET} SHARED
geant4_add_pymodule(pyG4processes
pyG4CrossSectionHandler.cc
pyG4EmCalculator.cc
pyG4ProcVector.cc
@@ -16,17 +14,5 @@ add_library(
pymodG4processes.cc
)
set_target_properties(${_TARGET} PROPERTIES PREFIX "")
set_target_properties(${_TARGET} PROPERTIES OUTPUT_NAME "G4processes")
set_target_properties(${_TARGET} PROPERTIES SUFFIX ".so")
set_target_properties(${_TARGET}
PROPERTIES INSTALL_RPATH
${GEANT4_LIBRARY_DIR}
BUILD_WITH_INSTALL_RPATH TRUE)
target_link_libraries (${_TARGET}
${GEANT4_LIBRARIES_WITH_VIS} ${BOOST_PYTHON_LIB}
${PYTHON_LIBRARIES})
# install
install(TARGETS ${_TARGET} LIBRARY DESTINATION ${G4MODULES_INSTALL_DIR})
target_link_libraries(pyG4processes PRIVATE G4processes pyG4Boost)
install(TARGETS pyG4processes DESTINATION "${CMAKE_INSTALL_PYTHONDIR}/Geant4")
@@ -34,6 +34,7 @@ class G4UImessenger;
using namespace boost::python;
// ====================================================================
// thin wrappers
// ====================================================================
@@ -142,8 +143,8 @@ using namespace pyG4ProcessTable;
// ====================================================================
void export_G4ProcessTable()
{
class_<G4ProcessTable, G4ProcessTable*, boost::noncopyable>
("G4ProcessTable", "process table")
class_<G4ProcessTable, boost::noncopyable>
("G4ProcessTable", "process table", no_init)
// ---
.def("GetProcessTable", &G4ProcessTable::GetProcessTable,
return_value_policy<reference_existing_object>())
@@ -1,26 +0,0 @@
# - build library
file (GLOB PY_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.py)
foreach (_pyfile ${PY_FILES})
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/${_pyfile}
${CMAKE_CURRENT_BINARY_DIR}/${_pyfile} COPYONLY)
list (APPEND PYC_FILES "${CMAKE_CURRENT_BINARY_DIR}/${_pyfile}c")
list (APPEND PYO_FILES "${CMAKE_CURRENT_BINARY_DIR}/${_pyfile}o")
endforeach()
add_custom_target (Geant4Py ALL)
add_custom_command (
TARGET Geant4Py
COMMAND ${PYTHON_EXECUTABLE}
ARGS -m compileall -f ${CMAKE_CURRENT_BINARY_DIR}
COMMAND ${PYTHON_EXECUTABLE}
ARGS -O -m compileall -f ${CMAKE_CURRENT_BINARY_DIR}
)
# install
install (FILES ${PY_FILES} DESTINATION ${G4MODULES_INSTALL_DIR})
install (FILES ${PYC_FILES} DESTINATION ${G4MODULES_INSTALL_DIR})
install (FILES ${PYO_FILES} DESTINATION ${G4MODULES_INSTALL_DIR})
-240
View File
@@ -1,240 +0,0 @@
"""
# ==================================================================
# [Geant4] module package
#
# Welcome to Geant4Py.
#
# This package contains a set of Python interface with Geant4.
# ==================================================================
"""
__version__ ='10.6'
__date__ = 'December/2019'
__author__ = 'K.Murakami (Koichi.Murakami@kek.jp)'
# import submodules
from G4interface import *
from G4intercoms import *
from G4global import *
from G4run import *
from G4event import *
from G4tracking import *
from G4track import *
from G4particles import *
from G4processes import *
from G4geometry import *
from G4materials import *
from G4physicslists import *
from G4digits_hits import *
from G4visualization import *
from G4gdml import *
from G4graphics_reps import *
from hepunit import *
from colortable import *
def print_version():
print """=============================================================
Welcome to Geant4Py (A Geant4-Python Bridge)
Version : %s
Date : %s
=============================================================
""" % ( __version__, __date__)
# ==================================================================
# initialize
# ==================================================================
# set G4cout/G4cerr to Python stdout
SetG4PyCoutDestination()
# ==================================================================
# globals, which start with "g"
# ==================================================================
# gRunManager
if G4RunManager.GetRunManager() == None:
gRunManager = G4RunManager()
else:
gRunManager = G4RunManager.GetRunManager()
gRunManagerKernel = G4RunManagerKernel.GetRunManagerKernel()
# gUImanager
gUImanager = G4UImanager.GetUIpointer()
# gEventManager
gEventManager = G4EventManager.GetEventManager()
# gStackManager
gStackManager = gEventManager.GetStackManager()
# gTrackingManager
gTrackingManager = gEventManager.GetTrackingManager()
# gStateManager
gStateManager = G4StateManager.GetStateManager()
gExceptionHandler = G4ExceptionHandler() # automatically registered
# gGeometryManager
gGeometryManager = G4GeometryManager.GetInstance()
# gTransportationManager
gTransportationManager = G4TransportationManager.GetTransportationManager()
# gParticleTable
gParticleTable = G4ParticleTable.GetParticleTable()
gParticleIterator = PyG4ParticleList()
# gProcessTable
gProcessTable = G4ProcessTable.GetProcessTable()
# gProductionCutsTable
gProductionCutsTable = G4ProductionCutsTable.GetProductionCutsTable()
# gEmCalculator
gEmCalculator = G4EmCalculator()
# gMaterial/ElementTable
gMaterialTable = G4Material.GetMaterialTable()
gElementTable = G4Element.GetElementTable()
# gNistManager (since 7.1)
_material_class_list = dir(G4materials)
_qfind = _material_class_list.count("G4NistManager") > 0
if _qfind:
gNistManager = G4NistManager.Instance()
# gVisManager
_visdriver_list = dir(G4visualization)
_q_opengl_ix = "G4OpenGLImmediateX" in _visdriver_list
_q_opengl_sx = "G4OpenGLStoredX" in _visdriver_list
_q_opengl_ixm = "G4OpenGLImmediateXm" in _visdriver_list
_q_opengl_sxm = "G4OpenGLStoredXm" in _visdriver_list
_q_raytracer_x = "G4RayTracerX" in _visdriver_list
if G4VisManager.GetConcreteInstance() == None:
gVisManager = G4VisManager()
if _q_opengl_ix:
_opengl_ix = G4OpenGLImmediateX()
if _q_opengl_sx:
_opengl_sx = G4OpenGLStoredX()
if _q_opengl_ixm:
_opengl_ixm = G4OpenGLImmediateXm()
if _q_opengl_sxm:
_opengl_sxm = G4OpenGLStoredXm()
if _q_raytracer_x:
_raytracer_x = G4RayTracerX()
_vrml1 = G4VRML1File()
_vrml2 = G4VRML2File()
_dawn = G4DAWNFILE()
_heprep_xml = G4HepRep()
_heprep_file = G4HepRepFile()
_atree = G4ASCIITree()
_raytracer = G4RayTracer()
if _q_opengl_ix:
gVisManager.RegisterGraphicsSystem(_opengl_ix)
if _q_opengl_sx:
gVisManager.RegisterGraphicsSystem(_opengl_sx)
if _q_opengl_ixm:
gVisManager.RegisterGraphicsSystem(_opengl_ixm)
if _q_opengl_sxm:
gVisManager.RegisterGraphicsSystem(_opengl_sxm)
if _q_raytracer_x:
gVisManager.RegisterGraphicsSystem(_raytracer_x)
gVisManager.RegisterGraphicsSystem(_vrml1)
gVisManager.RegisterGraphicsSystem(_vrml2)
gVisManager.RegisterGraphicsSystem(_dawn)
gVisManager.RegisterGraphicsSystem(_heprep_xml)
gVisManager.RegisterGraphicsSystem(_heprep_file)
gVisManager.RegisterGraphicsSystem(_atree)
gVisManager.RegisterGraphicsSystem(_raytracer)
gVisManager.Initialize()
# version information
gG4Version = G4Version
gG4Date = G4Date
gG4VERSION_NUMBER = G4VERSION_NUMBER
# ------------------------------------------------------------------
# functions
# ------------------------------------------------------------------
gControlExecute = gUImanager.ExecuteMacroFile
gApplyUICommand = G4intercoms.ApplyUICommand
gGetCurrentValues = gUImanager.GetCurrentValues
gStartUISession = G4interface.StartUISession
# ==================================================================
# extentions
# ==================================================================
# ------------------------------------------------------------------
# generate one event
# ------------------------------------------------------------------
def _one_event(self):
"generate one event."
self.BeamOn(1)
G4RunManager.OneEvent = _one_event
# ------------------------------------------------------------------
# list material information
# ------------------------------------------------------------------
def _list_material(self):
"list materials."
n_materials = len(gMaterialTable)
print " +------------------------------------------------------------------"
print " | Table of G4Material-s (%d materails defined)" % (n_materials)
for i in range(0, n_materials) :
material = gMaterialTable[i]
print " |--------------------------------------------------------"\
"----------"
print " | %s: %s" % (material.GetName(),
G4BestUnit(material.GetDensity(),"Volumic Mass"))
elementVec = material.GetElementVector()
fractionVec = material.GetFractionVector()
abundanceVec = material.GetVecNbOfAtomsPerVolume()
totNAtoms = material.GetTotNbOfAtomsPerVolume()
n_elements = len(elementVec)
for j in range(0, n_elements):
print " | + (%1d) %s(%s): A=%4.1f, N=%5.1f, " \
"Frac.=(%4.1f%%m,%4.1f%%a)" % \
(j+1, elementVec[j].GetName(), elementVec[j].GetSymbol(),
elementVec[j].GetZ(),
elementVec[j].GetN(),
fractionVec[j]/hepunit.perCent,
abundanceVec[j]/totNAtoms/hepunit.perCent)
print " +------------------------------------------------------------------"
G4MaterialTable.ListMaterial = _list_material
# ------------------------------------------------------------------
# termination
# ------------------------------------------------------------------
def gTerminate():
gGeometryManager.OpenGeometry()
# ------------------------------------------------------------------
# signal handler
# ------------------------------------------------------------------
import signal
import threading
def _run_abort(signum, frame):
state = gStateManager.GetCurrentState()
if(state == G4ApplicationState.G4State_GeomClosed or
state == G4ApplicationState.G4State_EventProc):
print "aborting Run ..."
gRunManager.AbortRun(True)
else:
raise KeyboardInterrupt
if (threading.activeCount() == 1):
signal.signal(signal.SIGINT, _run_abort)
@@ -1,27 +0,0 @@
# - build library
file (GLOB PY_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.py)
foreach (_pyfile ${PY_FILES})
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/${_pyfile}
${CMAKE_CURRENT_BINARY_DIR}/${_pyfile} COPYONLY)
#list (APPEND PYC_FILES "${CMAKE_CURRENT_BINARY_DIR}/${_pyfile}c")
#list (APPEND PYO_FILES "${CMAKE_CURRENT_BINARY_DIR}/${_pyfile}o")
endforeach()
add_custom_target (Geant4Py ALL)
add_custom_command (
TARGET Geant4Py
COMMAND ${PYTHON_EXECUTABLE}
ARGS -m compileall -f ${CMAKE_CURRENT_BINARY_DIR}
COMMAND ${PYTHON_EXECUTABLE}
ARGS -O -m compileall -f ${CMAKE_CURRENT_BINARY_DIR}
)
# install
install (FILES ${PY_FILES} DESTINATION ${G4MODULES_INSTALL_DIR})
install (DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/__pycache__
DESTINATION ${G4MODULES_INSTALL_DIR})
#install (FILES ${PYC_FILES} DESTINATION ${G4MODULES_INSTALL_DIR})
#install (FILES ${PYO_FILES} DESTINATION ${G4MODULES_INSTALL_DIR})
@@ -1,777 +0,0 @@
"""
# ==================================================================
# Python module
#
# color table
#
# Q, 2005
# ==================================================================
"""
def int_rgb(name):
return _colortable[name]
def float_rgb(name):
rgb = _colortable[name]
return (rgb[0]/255., rgb[1]/255., rgb[2]/255.)
# ==================================================================
# RGB color table (/usr/lib/X11/rgb.txt)
# ==================================================================
_colortable = { }
_colortable["snow"] = (255, 250, 250)
_colortable["ghost"] = (248, 248, 255)
_colortable["GhostWhite"] = (248, 248, 255)
_colortable["white"] = (245, 245, 245)
_colortable["WhiteSmoke"] = (245, 245, 245)
_colortable["gainsboro"] = (220, 220, 220)
_colortable["floral"] = (255, 250, 240)
_colortable["FloralWhite"] = (255, 250, 240)
_colortable["old"] = (253, 245, 230)
_colortable["OldLace"] = (253, 245, 230)
_colortable["linen"] = (250, 240, 230)
_colortable["antique"] = (250, 235, 215)
_colortable["AntiqueWhite"] = (250, 235, 215)
_colortable["papaya"] = (255, 239, 213)
_colortable["PapayaWhip"] = (255, 239, 213)
_colortable["blanched"] = (255, 235, 205)
_colortable["BlanchedAlmond"] = (255, 235, 205)
_colortable["bisque"] = (255, 228, 196)
_colortable["peach"] = (255, 218, 185)
_colortable["PeachPuff"] = (255, 218, 185)
_colortable["navajo"] = (255, 222, 173)
_colortable["NavajoWhite"] = (255, 222, 173)
_colortable["moccasin"] = (255, 228, 181)
_colortable["cornsilk"] = (255, 248, 220)
_colortable["ivory"] = (255, 255, 240)
_colortable["lemon"] = (255, 250, 205)
_colortable["LemonChiffon"] = (255, 250, 205)
_colortable["seashell"] = (255, 245, 238)
_colortable["honeydew"] = (240, 255, 240)
_colortable["mint"] = (245, 255, 250)
_colortable["MintCream"] = (245, 255, 250)
_colortable["azure"] = (240, 255, 255)
_colortable["alice"] = (240, 248, 255)
_colortable["AliceBlue"] = (240, 248, 255)
_colortable["lavender"] = (230, 230, 250)
_colortable["lavender"] = (255, 240, 245)
_colortable["LavenderBlush"] = (255, 240, 245)
_colortable["misty"] = (255, 228, 225)
_colortable["MistyRose"] = (255, 228, 225)
_colortable["white"] = (255, 255, 255)
_colortable["black"] = (0, 0, 0)
_colortable["dark"] = (47, 79, 79)
_colortable["DarkSlateGray"] = (47, 79, 79)
_colortable["dark"] = (47, 79, 79)
_colortable["DarkSlateGrey"] = (47, 79, 79)
_colortable["dim"] = (105, 105, 105)
_colortable["DimGray"] = (105, 105, 105)
_colortable["dim"] = (105, 105, 105)
_colortable["DimGrey"] = (105, 105, 105)
_colortable["slate"] = (112, 128, 144)
_colortable["SlateGray"] = (112, 128, 144)
_colortable["slate"] = (112, 128, 144)
_colortable["SlateGrey"] = (112, 128, 144)
_colortable["light"] = (119, 136, 153)
_colortable["LightSlateGray"] = (119, 136, 153)
_colortable["light"] = (119, 136, 153)
_colortable["LightSlateGrey"] = (119, 136, 153)
_colortable["gray"] = (190, 190, 190)
_colortable["grey"] = (190, 190, 190)
_colortable["light"] = (211, 211, 211)
_colortable["LightGrey"] = (211, 211, 211)
_colortable["light"] = (211, 211, 211)
_colortable["LightGray"] = (211, 211, 211)
_colortable["midnight"] = (25, 25, 112)
_colortable["MidnightBlue"] = (25, 25, 112)
_colortable["navy"] = (0, 0, 128)
_colortable["navy"] = (0, 0, 128)
_colortable["NavyBlue"] = (0, 0, 128)
_colortable["cornflower"] = (100, 149, 237)
_colortable["CornflowerBlue"] = (100, 149, 237)
_colortable["dark"] = (72, 61, 139)
_colortable["DarkSlateBlue"] = (72, 61, 139)
_colortable["slate"] = (106, 90, 205)
_colortable["SlateBlue"] = (106, 90, 205)
_colortable["medium"] = (123, 104, 238)
_colortable["MediumSlateBlue"] = (123, 104, 238)
_colortable["light"] = (132, 112, 255)
_colortable["LightSlateBlue"] = (132, 112, 255)
_colortable["medium"] = (0, 0, 205)
_colortable["MediumBlue"] = (0, 0, 205)
_colortable["royal"] = (65, 105, 225)
_colortable["RoyalBlue"] = (65, 105, 225)
_colortable["blue"] = (0, 0, 255)
_colortable["dodger"] = (30, 144, 255)
_colortable["DodgerBlue"] = (30, 144, 255)
_colortable["deep"] = (0, 191, 255)
_colortable["DeepSkyBlue"] = (0, 191, 255)
_colortable["sky"] = (135, 206, 235)
_colortable["SkyBlue"] = (135, 206, 235)
_colortable["light"] = (135, 206, 250)
_colortable["LightSkyBlue"] = (135, 206, 250)
_colortable["steel"] = (70, 130, 180)
_colortable["SteelBlue"] = (70, 130, 180)
_colortable["light"] = (176, 196, 222)
_colortable["LightSteelBlue"] = (176, 196, 222)
_colortable["light"] = (173, 216, 230)
_colortable["LightBlue"] = (173, 216, 230)
_colortable["powder"] = (176, 224, 230)
_colortable["PowderBlue"] = (176, 224, 230)
_colortable["pale"] = (175, 238, 238)
_colortable["PaleTurquoise"] = (175, 238, 238)
_colortable["dark"] = (0, 206, 209)
_colortable["DarkTurquoise"] = (0, 206, 209)
_colortable["medium"] = (72, 209, 204)
_colortable["MediumTurquoise"] = (72, 209, 204)
_colortable["turquoise"] = (64, 224, 208)
_colortable["cyan"] = (0, 255, 255)
_colortable["light"] = (224, 255, 255)
_colortable["LightCyan"] = (224, 255, 255)
_colortable["cadet"] = (95, 158, 160)
_colortable["CadetBlue"] = (95, 158, 160)
_colortable["medium"] = (102, 205, 170)
_colortable["MediumAquamarine"] = (102, 205, 170)
_colortable["aquamarine"] = (127, 255, 212)
_colortable["dark"] = (0, 100, 0)
_colortable["DarkGreen"] = (0, 100, 0)
_colortable["dark"] = (85, 107, 47)
_colortable["DarkOliveGreen"] = (85, 107, 47)
_colortable["dark"] = (143, 188, 143)
_colortable["DarkSeaGreen"] = (143, 188, 143)
_colortable["sea"] = (46, 139, 87)
_colortable["SeaGreen"] = (46, 139, 87)
_colortable["medium"] = (60, 179, 113)
_colortable["MediumSeaGreen"] = (60, 179, 113)
_colortable["light"] = (32, 178, 170)
_colortable["LightSeaGreen"] = (32, 178, 170)
_colortable["pale"] = (152, 251, 152)
_colortable["PaleGreen"] = (152, 251, 152)
_colortable["spring"] = (0, 255, 127)
_colortable["SpringGreen"] = (0, 255, 127)
_colortable["lawn"] = (124, 252, 0)
_colortable["LawnGreen"] = (124, 252, 0)
_colortable["green"] = (0, 255, 0)
_colortable["chartreuse"] = (127, 255, 0)
_colortable["medium"] = (0, 250, 154)
_colortable["MediumSpringGreen"] = (0, 250, 154)
_colortable["green"] = (173, 255, 47)
_colortable["GreenYellow"] = (173, 255, 47)
_colortable["lime"] = (50, 205, 50)
_colortable["LimeGreen"] = (50, 205, 50)
_colortable["yellow"] = (154, 205, 50)
_colortable["YellowGreen"] = (154, 205, 50)
_colortable["forest"] = (34, 139, 34)
_colortable["ForestGreen"] = (34, 139, 34)
_colortable["olive"] = (107, 142, 35)
_colortable["OliveDrab"] = (107, 142, 35)
_colortable["dark"] = (189, 183, 107)
_colortable["DarkKhaki"] = (189, 183, 107)
_colortable["khaki"] = (240, 230, 140)
_colortable["pale"] = (238, 232, 170)
_colortable["PaleGoldenrod"] = (238, 232, 170)
_colortable["light"] = (250, 250, 210)
_colortable["LightGoldenrodYellow"] = (250, 250, 210)
_colortable["light"] = (255, 255, 224)
_colortable["LightYellow"] = (255, 255, 224)
_colortable["yellow"] = (255, 255, 0)
_colortable["gold"] = (255, 215, 0)
_colortable["light"] = (238, 221, 130)
_colortable["LightGoldenrod"] = (238, 221, 130)
_colortable["goldenrod"] = (218, 165, 32)
_colortable["dark"] = (184, 134, 11)
_colortable["DarkGoldenrod"] = (184, 134, 11)
_colortable["rosy"] = (188, 143, 143)
_colortable["RosyBrown"] = (188, 143, 143)
_colortable["indian"] = (205, 92, 92)
_colortable["IndianRed"] = (205, 92, 92)
_colortable["saddle"] = (139, 69, 19)
_colortable["SaddleBrown"] = (139, 69, 19)
_colortable["sienna"] = (160, 82, 45)
_colortable["peru"] = (205, 133, 63)
_colortable["burlywood"] = (222, 184, 135)
_colortable["beige"] = (245, 245, 220)
_colortable["wheat"] = (245, 222, 179)
_colortable["sandy"] = (244, 164, 96)
_colortable["SandyBrown"] = (244, 164, 96)
_colortable["tan"] = (210, 180, 140)
_colortable["chocolate"] = (210, 105, 30)
_colortable["firebrick"] = (178, 34, 34)
_colortable["brown"] = (165, 42, 42)
_colortable["dark"] = (233, 150, 122)
_colortable["DarkSalmon"] = (233, 150, 122)
_colortable["salmon"] = (250, 128, 114)
_colortable["light"] = (255, 160, 122)
_colortable["LightSalmon"] = (255, 160, 122)
_colortable["orange"] = (255, 165, 0)
_colortable["dark"] = (255, 140, 0)
_colortable["DarkOrange"] = (255, 140, 0)
_colortable["coral"] = (255, 127, 80)
_colortable["light"] = (240, 128, 128)
_colortable["LightCoral"] = (240, 128, 128)
_colortable["tomato"] = (255, 99, 71)
_colortable["orange"] = (255, 69, 0)
_colortable["OrangeRed"] = (255, 69, 0)
_colortable["red"] = (255, 0, 0)
_colortable["hot"] = (255, 105, 180)
_colortable["HotPink"] = (255, 105, 180)
_colortable["deep"] = (255, 20, 147)
_colortable["DeepPink"] = (255, 20, 147)
_colortable["pink"] = (255, 192, 203)
_colortable["light"] = (255, 182, 193)
_colortable["LightPink"] = (255, 182, 193)
_colortable["pale"] = (219, 112, 147)
_colortable["PaleVioletRed"] = (219, 112, 147)
_colortable["maroon"] = (176, 48, 96)
_colortable["medium"] = (199, 21, 133)
_colortable["MediumVioletRed"] = (199, 21, 133)
_colortable["violet"] = (208, 32, 144)
_colortable["VioletRed"] = (208, 32, 144)
_colortable["magenta"] = (255, 0, 255)
_colortable["violet"] = (238, 130, 238)
_colortable["plum"] = (221, 160, 221)
_colortable["orchid"] = (218, 112, 214)
_colortable["medium"] = (186, 85, 211)
_colortable["MediumOrchid"] = (186, 85, 211)
_colortable["dark"] = (153, 50, 204)
_colortable["DarkOrchid"] = (153, 50, 204)
_colortable["dark"] = (148, 0, 211)
_colortable["DarkViolet"] = (148, 0, 211)
_colortable["blue"] = (138, 43, 226)
_colortable["BlueViolet"] = (138, 43, 226)
_colortable["purple"] = (160, 32, 240)
_colortable["medium"] = (147, 112, 219)
_colortable["MediumPurple"] = (147, 112, 219)
_colortable["thistle"] = (216, 191, 216)
_colortable["snow1"] = (255, 250, 250)
_colortable["snow2"] = (238, 233, 233)
_colortable["snow3"] = (205, 201, 201)
_colortable["snow4"] = (139, 137, 137)
_colortable["seashell1"] = (255, 245, 238)
_colortable["seashell2"] = (238, 229, 222)
_colortable["seashell3"] = (205, 197, 191)
_colortable["seashell4"] = (139, 134, 130)
_colortable["AntiqueWhite1"] = (255, 239, 219)
_colortable["AntiqueWhite2"] = (238, 223, 204)
_colortable["AntiqueWhite3"] = (205, 192, 176)
_colortable["AntiqueWhite4"] = (139, 131, 120)
_colortable["bisque1"] = (255, 228, 196)
_colortable["bisque2"] = (238, 213, 183)
_colortable["bisque3"] = (205, 183, 158)
_colortable["bisque4"] = (139, 125, 107)
_colortable["PeachPuff1"] = (255, 218, 185)
_colortable["PeachPuff2"] = (238, 203, 173)
_colortable["PeachPuff3"] = (205, 175, 149)
_colortable["PeachPuff4"] = (139, 119, 101)
_colortable["NavajoWhite1"] = (255, 222, 173)
_colortable["NavajoWhite2"] = (238, 207, 161)
_colortable["NavajoWhite3"] = (205, 179, 139)
_colortable["NavajoWhite4"] = (139, 121, 94)
_colortable["LemonChiffon1"] = (255, 250, 205)
_colortable["LemonChiffon2"] = (238, 233, 191)
_colortable["LemonChiffon3"] = (205, 201, 165)
_colortable["LemonChiffon4"] = (139, 137, 112)
_colortable["cornsilk1"] = (255, 248, 220)
_colortable["cornsilk2"] = (238, 232, 205)
_colortable["cornsilk3"] = (205, 200, 177)
_colortable["cornsilk4"] = (139, 136, 120)
_colortable["ivory1"] = (255, 255, 240)
_colortable["ivory2"] = (238, 238, 224)
_colortable["ivory3"] = (205, 205, 193)
_colortable["ivory4"] = (139, 139, 131)
_colortable["honeydew1"] = (240, 255, 240)
_colortable["honeydew2"] = (224, 238, 224)
_colortable["honeydew3"] = (193, 205, 193)
_colortable["honeydew4"] = (131, 139, 131)
_colortable["LavenderBlush1"] = (255, 240, 245)
_colortable["LavenderBlush2"] = (238, 224, 229)
_colortable["LavenderBlush3"] = (205, 193, 197)
_colortable["LavenderBlush4"] = (139, 131, 134)
_colortable["MistyRose1"] = (255, 228, 225)
_colortable["MistyRose2"] = (238, 213, 210)
_colortable["MistyRose3"] = (205, 183, 181)
_colortable["MistyRose4"] = (139, 125, 123)
_colortable["azure1"] = (240, 255, 255)
_colortable["azure2"] = (224, 238, 238)
_colortable["azure3"] = (193, 205, 205)
_colortable["azure4"] = (131, 139, 139)
_colortable["SlateBlue1"] = (131, 111, 255)
_colortable["SlateBlue2"] = (122, 103, 238)
_colortable["SlateBlue3"] = (105, 89, 205)
_colortable["SlateBlue4"] = (71, 60, 139)
_colortable["RoyalBlue1"] = (72, 118, 255)
_colortable["RoyalBlue2"] = (67, 110, 238)
_colortable["RoyalBlue3"] = (58, 95, 205)
_colortable["RoyalBlue4"] = (39, 64, 139)
_colortable["blue1"] = (0, 0, 255)
_colortable["blue2"] = (0, 0, 238)
_colortable["blue3"] = (0, 0, 205)
_colortable["blue4"] = (0, 0, 139)
_colortable["DodgerBlue1"] = (30, 144, 255)
_colortable["DodgerBlue2"] = (28, 134, 238)
_colortable["DodgerBlue3"] = (24, 116, 205)
_colortable["DodgerBlue4"] = (16, 78, 139)
_colortable["SteelBlue1"] = (99, 184, 255)
_colortable["SteelBlue2"] = (92, 172, 238)
_colortable["SteelBlue3"] = (79, 148, 205)
_colortable["SteelBlue4"] = (54, 100, 139)
_colortable["DeepSkyBlue1"] = (0, 191, 255)
_colortable["DeepSkyBlue2"] = (0, 178, 238)
_colortable["DeepSkyBlue3"] = (0, 154, 205)
_colortable["DeepSkyBlue4"] = (0, 104, 139)
_colortable["SkyBlue1"] = (135, 206, 255)
_colortable["SkyBlue2"] = (126, 192, 238)
_colortable["SkyBlue3"] = (108, 166, 205)
_colortable["SkyBlue4"] = (74, 112, 139)
_colortable["LightSkyBlue1"] = (176, 226, 255)
_colortable["LightSkyBlue2"] = (164, 211, 238)
_colortable["LightSkyBlue3"] = (141, 182, 205)
_colortable["LightSkyBlue4"] = (96, 123, 139)
_colortable["SlateGray1"] = (198, 226, 255)
_colortable["SlateGray2"] = (185, 211, 238)
_colortable["SlateGray3"] = (159, 182, 205)
_colortable["SlateGray4"] = (108, 123, 139)
_colortable["LightSteelBlue1"] = (202, 225, 255)
_colortable["LightSteelBlue2"] = (188, 210, 238)
_colortable["LightSteelBlue3"] = (162, 181, 205)
_colortable["LightSteelBlue4"] = (110, 123, 139)
_colortable["LightBlue1"] = (191, 239, 255)
_colortable["LightBlue2"] = (178, 223, 238)
_colortable["LightBlue3"] = (154, 192, 205)
_colortable["LightBlue4"] = (104, 131, 139)
_colortable["LightCyan1"] = (224, 255, 255)
_colortable["LightCyan2"] = (209, 238, 238)
_colortable["LightCyan3"] = (180, 205, 205)
_colortable["LightCyan4"] = (122, 139, 139)
_colortable["PaleTurquoise1"] = (187, 255, 255)
_colortable["PaleTurquoise2"] = (174, 238, 238)
_colortable["PaleTurquoise3"] = (150, 205, 205)
_colortable["PaleTurquoise4"] = (102, 139, 139)
_colortable["CadetBlue1"] = (152, 245, 255)
_colortable["CadetBlue2"] = (142, 229, 238)
_colortable["CadetBlue3"] = (122, 197, 205)
_colortable["CadetBlue4"] = (83, 134, 139)
_colortable["turquoise1"] = (0, 245, 255)
_colortable["turquoise2"] = (0, 229, 238)
_colortable["turquoise3"] = (0, 197, 205)
_colortable["turquoise4"] = (0, 134, 139)
_colortable["cyan1"] = (0, 255, 255)
_colortable["cyan2"] = (0, 238, 238)
_colortable["cyan3"] = (0, 205, 205)
_colortable["cyan4"] = (0, 139, 139)
_colortable["DarkSlateGray1"] = (151, 255, 255)
_colortable["DarkSlateGray2"] = (141, 238, 238)
_colortable["DarkSlateGray3"] = (121, 205, 205)
_colortable["DarkSlateGray4"] = (82, 139, 139)
_colortable["aquamarine1"] = (127, 255, 212)
_colortable["aquamarine2"] = (118, 238, 198)
_colortable["aquamarine3"] = (102, 205, 170)
_colortable["aquamarine4"] = (69, 139, 116)
_colortable["DarkSeaGreen1"] = (193, 255, 193)
_colortable["DarkSeaGreen2"] = (180, 238, 180)
_colortable["DarkSeaGreen3"] = (155, 205, 155)
_colortable["DarkSeaGreen4"] = (105, 139, 105)
_colortable["SeaGreen1"] = (84, 255, 159)
_colortable["SeaGreen2"] = (78, 238, 148)
_colortable["SeaGreen3"] = (67, 205, 128)
_colortable["SeaGreen4"] = (46, 139, 87)
_colortable["PaleGreen1"] = (154, 255, 154)
_colortable["PaleGreen2"] = (144, 238, 144)
_colortable["PaleGreen3"] = (124, 205, 124)
_colortable["PaleGreen4"] = (84, 139, 84)
_colortable["SpringGreen1"] = (0, 255, 127)
_colortable["SpringGreen2"] = (0, 238, 118)
_colortable["SpringGreen3"] = (0, 205, 102)
_colortable["SpringGreen4"] = (0, 139, 69)
_colortable["green1"] = (0, 255, 0)
_colortable["green2"] = (0, 238, 0)
_colortable["green3"] = (0, 205, 0)
_colortable["green4"] = (0, 139, 0)
_colortable["chartreuse1"] = (127, 255, 0)
_colortable["chartreuse2"] = (118, 238, 0)
_colortable["chartreuse3"] = (102, 205, 0)
_colortable["chartreuse4"] = (69, 139, 0)
_colortable["OliveDrab1"] = (192, 255, 62)
_colortable["OliveDrab2"] = (179, 238, 58)
_colortable["OliveDrab3"] = (154, 205, 50)
_colortable["OliveDrab4"] = (105, 139, 34)
_colortable["DarkOliveGreen1"] = (202, 255, 112)
_colortable["DarkOliveGreen2"] = (188, 238, 104)
_colortable["DarkOliveGreen3"] = (162, 205, 90)
_colortable["DarkOliveGreen4"] = (110, 139, 61)
_colortable["khaki1"] = (255, 246, 143)
_colortable["khaki2"] = (238, 230, 133)
_colortable["khaki3"] = (205, 198, 115)
_colortable["khaki4"] = (139, 134, 78)
_colortable["LightGoldenrod1"] = (255, 236, 139)
_colortable["LightGoldenrod2"] = (238, 220, 130)
_colortable["LightGoldenrod3"] = (205, 190, 112)
_colortable["LightGoldenrod4"] = (139, 129, 76)
_colortable["LightYellow1"] = (255, 255, 224)
_colortable["LightYellow2"] = (238, 238, 209)
_colortable["LightYellow3"] = (205, 205, 180)
_colortable["LightYellow4"] = (139, 139, 122)
_colortable["yellow1"] = (255, 255, 0)
_colortable["yellow2"] = (238, 238, 0)
_colortable["yellow3"] = (205, 205, 0)
_colortable["yellow4"] = (139, 139, 0)
_colortable["gold1"] = (255, 215, 0)
_colortable["gold2"] = (238, 201, 0)
_colortable["gold3"] = (205, 173, 0)
_colortable["gold4"] = (139, 117, 0)
_colortable["goldenrod1"] = (255, 193, 37)
_colortable["goldenrod2"] = (238, 180, 34)
_colortable["goldenrod3"] = (205, 155, 29)
_colortable["goldenrod4"] = (139, 105, 20)
_colortable["DarkGoldenrod1"] = (255, 185, 15)
_colortable["DarkGoldenrod2"] = (238, 173, 14)
_colortable["DarkGoldenrod3"] = (205, 149, 12)
_colortable["DarkGoldenrod4"] = (139, 101, 8)
_colortable["RosyBrown1"] = (255, 193, 193)
_colortable["RosyBrown2"] = (238, 180, 180)
_colortable["RosyBrown3"] = (205, 155, 155)
_colortable["RosyBrown4"] = (139, 105, 105)
_colortable["IndianRed1"] = (255, 106, 106)
_colortable["IndianRed2"] = (238, 99, 99)
_colortable["IndianRed3"] = (205, 85, 85)
_colortable["IndianRed4"] = (139, 58, 58)
_colortable["sienna1"] = (255, 130, 71)
_colortable["sienna2"] = (238, 121, 66)
_colortable["sienna3"] = (205, 104, 57)
_colortable["sienna4"] = (139, 71, 38)
_colortable["burlywood1"] = (255, 211, 155)
_colortable["burlywood2"] = (238, 197, 145)
_colortable["burlywood3"] = (205, 170, 125)
_colortable["burlywood4"] = (139, 115, 85)
_colortable["wheat1"] = (255, 231, 186)
_colortable["wheat2"] = (238, 216, 174)
_colortable["wheat3"] = (205, 186, 150)
_colortable["wheat4"] = (139, 126, 102)
_colortable["tan1"] = (255, 165, 79)
_colortable["tan2"] = (238, 154, 73)
_colortable["tan3"] = (205, 133, 63)
_colortable["tan4"] = (139, 90, 43)
_colortable["chocolate1"] = (255, 127, 36)
_colortable["chocolate2"] = (238, 118, 33)
_colortable["chocolate3"] = (205, 102, 29)
_colortable["chocolate4"] = (139, 69, 19)
_colortable["firebrick1"] = (255, 48, 48)
_colortable["firebrick2"] = (238, 44, 44)
_colortable["firebrick3"] = (205, 38, 38)
_colortable["firebrick4"] = (139, 26, 26)
_colortable["brown1"] = (255, 64, 64)
_colortable["brown2"] = (238, 59, 59)
_colortable["brown3"] = (205, 51, 51)
_colortable["brown4"] = (139, 35, 35)
_colortable["salmon1"] = (255, 140, 105)
_colortable["salmon2"] = (238, 130, 98)
_colortable["salmon3"] = (205, 112, 84)
_colortable["salmon4"] = (139, 76, 57)
_colortable["LightSalmon1"] = (255, 160, 122)
_colortable["LightSalmon2"] = (238, 149, 114)
_colortable["LightSalmon3"] = (205, 129, 98)
_colortable["LightSalmon4"] = (139, 87, 66)
_colortable["orange1"] = (255, 165, 0)
_colortable["orange2"] = (238, 154, 0)
_colortable["orange3"] = (205, 133, 0)
_colortable["orange4"] = (139, 90, 0)
_colortable["DarkOrange1"] = (255, 127, 0)
_colortable["DarkOrange2"] = (238, 118, 0)
_colortable["DarkOrange3"] = (205, 102, 0)
_colortable["DarkOrange4"] = (139, 69, 0)
_colortable["coral1"] = (255, 114, 86)
_colortable["coral2"] = (238, 106, 80)
_colortable["coral3"] = (205, 91, 69)
_colortable["coral4"] = (139, 62, 47)
_colortable["tomato1"] = (255, 99, 71)
_colortable["tomato2"] = (238, 92, 66)
_colortable["tomato3"] = (205, 79, 57)
_colortable["tomato4"] = (139, 54, 38)
_colortable["OrangeRed1"] = (255, 69, 0)
_colortable["OrangeRed2"] = (238, 64, 0)
_colortable["OrangeRed3"] = (205, 55, 0)
_colortable["OrangeRed4"] = (139, 37, 0)
_colortable["red1"] = (255, 0, 0)
_colortable["red2"] = (238, 0, 0)
_colortable["red3"] = (205, 0, 0)
_colortable["red4"] = (139, 0, 0)
_colortable["DeepPink1"] = (255, 20, 147)
_colortable["DeepPink2"] = (238, 18, 137)
_colortable["DeepPink3"] = (205, 16, 118)
_colortable["DeepPink4"] = (139, 10, 80)
_colortable["HotPink1"] = (255, 110, 180)
_colortable["HotPink2"] = (238, 106, 167)
_colortable["HotPink3"] = (205, 96, 144)
_colortable["HotPink4"] = (139, 58, 98)
_colortable["pink1"] = (255, 181, 197)
_colortable["pink2"] = (238, 169, 184)
_colortable["pink3"] = (205, 145, 158)
_colortable["pink4"] = (139, 99, 108)
_colortable["LightPink1"] = (255, 174, 185)
_colortable["LightPink2"] = (238, 162, 173)
_colortable["LightPink3"] = (205, 140, 149)
_colortable["LightPink4"] = (139, 95, 101)
_colortable["PaleVioletRed1"] = (255, 130, 171)
_colortable["PaleVioletRed2"] = (238, 121, 159)
_colortable["PaleVioletRed3"] = (205, 104, 137)
_colortable["PaleVioletRed4"] = (139, 71, 93)
_colortable["maroon1"] = (255, 52, 179)
_colortable["maroon2"] = (238, 48, 167)
_colortable["maroon3"] = (205, 41, 144)
_colortable["maroon4"] = (139, 28, 98)
_colortable["VioletRed1"] = (255, 62, 150)
_colortable["VioletRed2"] = (238, 58, 140)
_colortable["VioletRed3"] = (205, 50, 120)
_colortable["VioletRed4"] = (139, 34, 82)
_colortable["magenta1"] = (255, 0, 255)
_colortable["magenta2"] = (238, 0, 238)
_colortable["magenta3"] = (205, 0, 205)
_colortable["magenta4"] = (139, 0, 139)
_colortable["orchid1"] = (255, 131, 250)
_colortable["orchid2"] = (238, 122, 233)
_colortable["orchid3"] = (205, 105, 201)
_colortable["orchid4"] = (139, 71, 137)
_colortable["plum1"] = (255, 187, 255)
_colortable["plum2"] = (238, 174, 238)
_colortable["plum3"] = (205, 150, 205)
_colortable["plum4"] = (139, 102, 139)
_colortable["MediumOrchid1"] = (224, 102, 255)
_colortable["MediumOrchid2"] = (209, 95, 238)
_colortable["MediumOrchid3"] = (180, 82, 205)
_colortable["MediumOrchid4"] = (122, 55, 139)
_colortable["DarkOrchid1"] = (191, 62, 255)
_colortable["DarkOrchid2"] = (178, 58, 238)
_colortable["DarkOrchid3"] = (154, 50, 205)
_colortable["DarkOrchid4"] = (104, 34, 139)
_colortable["purple1"] = (155, 48, 255)
_colortable["purple2"] = (145, 44, 238)
_colortable["purple3"] = (125, 38, 205)
_colortable["purple4"] = (85, 26, 139)
_colortable["MediumPurple1"] = (171, 130, 255)
_colortable["MediumPurple2"] = (159, 121, 238)
_colortable["MediumPurple3"] = (137, 104, 205)
_colortable["MediumPurple4"] = (93, 71, 139)
_colortable["thistle1"] = (255, 225, 255)
_colortable["thistle2"] = (238, 210, 238)
_colortable["thistle3"] = (205, 181, 205)
_colortable["thistle4"] = (139, 123, 139)
_colortable["gray0"] = (0, 0, 0)
_colortable["grey0"] = (0, 0, 0)
_colortable["gray1"] = (3, 3, 3)
_colortable["grey1"] = (3, 3, 3)
_colortable["gray2"] = (5, 5, 5)
_colortable["grey2"] = (5, 5, 5)
_colortable["gray3"] = (8, 8, 8)
_colortable["grey3"] = (8, 8, 8)
_colortable["gray4"] = (10, 10, 10)
_colortable["grey4"] = (10, 10, 10)
_colortable["gray5"] = (13, 13, 13)
_colortable["grey5"] = (13, 13, 13)
_colortable["gray6"] = (15, 15, 15)
_colortable["grey6"] = (15, 15, 15)
_colortable["gray7"] = (18, 18, 18)
_colortable["grey7"] = (18, 18, 18)
_colortable["gray8"] = (20, 20, 20)
_colortable["grey8"] = (20, 20, 20)
_colortable["gray9"] = (23, 23, 23)
_colortable["grey9"] = (23, 23, 23)
_colortable["gray10"] = (26, 26, 26)
_colortable["grey10"] = (26, 26, 26)
_colortable["gray11"] = (28, 28, 28)
_colortable["grey11"] = (28, 28, 28)
_colortable["gray12"] = (31, 31, 31)
_colortable["grey12"] = (31, 31, 31)
_colortable["gray13"] = (33, 33, 33)
_colortable["grey13"] = (33, 33, 33)
_colortable["gray14"] = (36, 36, 36)
_colortable["grey14"] = (36, 36, 36)
_colortable["gray15"] = (38, 38, 38)
_colortable["grey15"] = (38, 38, 38)
_colortable["gray16"] = (41, 41, 41)
_colortable["grey16"] = (41, 41, 41)
_colortable["gray17"] = (43, 43, 43)
_colortable["grey17"] = (43, 43, 43)
_colortable["gray18"] = (46, 46, 46)
_colortable["grey18"] = (46, 46, 46)
_colortable["gray19"] = (48, 48, 48)
_colortable["grey19"] = (48, 48, 48)
_colortable["gray20"] = (51, 51, 51)
_colortable["grey20"] = (51, 51, 51)
_colortable["gray21"] = (54, 54, 54)
_colortable["grey21"] = (54, 54, 54)
_colortable["gray22"] = (56, 56, 56)
_colortable["grey22"] = (56, 56, 56)
_colortable["gray23"] = (59, 59, 59)
_colortable["grey23"] = (59, 59, 59)
_colortable["gray24"] = (61, 61, 61)
_colortable["grey24"] = (61, 61, 61)
_colortable["gray25"] = (64, 64, 64)
_colortable["grey25"] = (64, 64, 64)
_colortable["gray26"] = (66, 66, 66)
_colortable["grey26"] = (66, 66, 66)
_colortable["gray27"] = (69, 69, 69)
_colortable["grey27"] = (69, 69, 69)
_colortable["gray28"] = (71, 71, 71)
_colortable["grey28"] = (71, 71, 71)
_colortable["gray29"] = (74, 74, 74)
_colortable["grey29"] = (74, 74, 74)
_colortable["gray30"] = (77, 77, 77)
_colortable["grey30"] = (77, 77, 77)
_colortable["gray31"] = (79, 79, 79)
_colortable["grey31"] = (79, 79, 79)
_colortable["gray32"] = (82, 82, 82)
_colortable["grey32"] = (82, 82, 82)
_colortable["gray33"] = (84, 84, 84)
_colortable["grey33"] = (84, 84, 84)
_colortable["gray34"] = (87, 87, 87)
_colortable["grey34"] = (87, 87, 87)
_colortable["gray35"] = (89, 89, 89)
_colortable["grey35"] = (89, 89, 89)
_colortable["gray36"] = (92, 92, 92)
_colortable["grey36"] = (92, 92, 92)
_colortable["gray37"] = (94, 94, 94)
_colortable["grey37"] = (94, 94, 94)
_colortable["gray38"] = (97, 97, 97)
_colortable["grey38"] = (97, 97, 97)
_colortable["gray39"] = (99, 99, 99)
_colortable["grey39"] = (99, 99, 99)
_colortable["gray40"] = (102, 102, 102)
_colortable["grey40"] = (102, 102, 102)
_colortable["gray41"] = (105, 105, 105)
_colortable["grey41"] = (105, 105, 105)
_colortable["gray42"] = (107, 107, 107)
_colortable["grey42"] = (107, 107, 107)
_colortable["gray43"] = (110, 110, 110)
_colortable["grey43"] = (110, 110, 110)
_colortable["gray44"] = (112, 112, 112)
_colortable["grey44"] = (112, 112, 112)
_colortable["gray45"] = (115, 115, 115)
_colortable["grey45"] = (115, 115, 115)
_colortable["gray46"] = (117, 117, 117)
_colortable["grey46"] = (117, 117, 117)
_colortable["gray47"] = (120, 120, 120)
_colortable["grey47"] = (120, 120, 120)
_colortable["gray48"] = (122, 122, 122)
_colortable["grey48"] = (122, 122, 122)
_colortable["gray49"] = (125, 125, 125)
_colortable["grey49"] = (125, 125, 125)
_colortable["gray50"] = (127, 127, 127)
_colortable["grey50"] = (127, 127, 127)
_colortable["gray51"] = (130, 130, 130)
_colortable["grey51"] = (130, 130, 130)
_colortable["gray52"] = (133, 133, 133)
_colortable["grey52"] = (133, 133, 133)
_colortable["gray53"] = (135, 135, 135)
_colortable["grey53"] = (135, 135, 135)
_colortable["gray54"] = (138, 138, 138)
_colortable["grey54"] = (138, 138, 138)
_colortable["gray55"] = (140, 140, 140)
_colortable["grey55"] = (140, 140, 140)
_colortable["gray56"] = (143, 143, 143)
_colortable["grey56"] = (143, 143, 143)
_colortable["gray57"] = (145, 145, 145)
_colortable["grey57"] = (145, 145, 145)
_colortable["gray58"] = (148, 148, 148)
_colortable["grey58"] = (148, 148, 148)
_colortable["gray59"] = (150, 150, 150)
_colortable["grey59"] = (150, 150, 150)
_colortable["gray60"] = (153, 153, 153)
_colortable["grey60"] = (153, 153, 153)
_colortable["gray61"] = (156, 156, 156)
_colortable["grey61"] = (156, 156, 156)
_colortable["gray62"] = (158, 158, 158)
_colortable["grey62"] = (158, 158, 158)
_colortable["gray63"] = (161, 161, 161)
_colortable["grey63"] = (161, 161, 161)
_colortable["gray64"] = (163, 163, 163)
_colortable["grey64"] = (163, 163, 163)
_colortable["gray65"] = (166, 166, 166)
_colortable["grey65"] = (166, 166, 166)
_colortable["gray66"] = (168, 168, 168)
_colortable["grey66"] = (168, 168, 168)
_colortable["gray67"] = (171, 171, 171)
_colortable["grey67"] = (171, 171, 171)
_colortable["gray68"] = (173, 173, 173)
_colortable["grey68"] = (173, 173, 173)
_colortable["gray69"] = (176, 176, 176)
_colortable["grey69"] = (176, 176, 176)
_colortable["gray70"] = (179, 179, 179)
_colortable["grey70"] = (179, 179, 179)
_colortable["gray71"] = (181, 181, 181)
_colortable["grey71"] = (181, 181, 181)
_colortable["gray72"] = (184, 184, 184)
_colortable["grey72"] = (184, 184, 184)
_colortable["gray73"] = (186, 186, 186)
_colortable["grey73"] = (186, 186, 186)
_colortable["gray74"] = (189, 189, 189)
_colortable["grey74"] = (189, 189, 189)
_colortable["gray75"] = (191, 191, 191)
_colortable["grey75"] = (191, 191, 191)
_colortable["gray76"] = (194, 194, 194)
_colortable["grey76"] = (194, 194, 194)
_colortable["gray77"] = (196, 196, 196)
_colortable["grey77"] = (196, 196, 196)
_colortable["gray78"] = (199, 199, 199)
_colortable["grey78"] = (199, 199, 199)
_colortable["gray79"] = (201, 201, 201)
_colortable["grey79"] = (201, 201, 201)
_colortable["gray80"] = (204, 204, 204)
_colortable["grey80"] = (204, 204, 204)
_colortable["gray81"] = (207, 207, 207)
_colortable["grey81"] = (207, 207, 207)
_colortable["gray82"] = (209, 209, 209)
_colortable["grey82"] = (209, 209, 209)
_colortable["gray83"] = (212, 212, 212)
_colortable["grey83"] = (212, 212, 212)
_colortable["gray84"] = (214, 214, 214)
_colortable["grey84"] = (214, 214, 214)
_colortable["gray85"] = (217, 217, 217)
_colortable["grey85"] = (217, 217, 217)
_colortable["gray86"] = (219, 219, 219)
_colortable["grey86"] = (219, 219, 219)
_colortable["gray87"] = (222, 222, 222)
_colortable["grey87"] = (222, 222, 222)
_colortable["gray88"] = (224, 224, 224)
_colortable["grey88"] = (224, 224, 224)
_colortable["gray89"] = (227, 227, 227)
_colortable["grey89"] = (227, 227, 227)
_colortable["gray90"] = (229, 229, 229)
_colortable["grey90"] = (229, 229, 229)
_colortable["gray91"] = (232, 232, 232)
_colortable["grey91"] = (232, 232, 232)
_colortable["gray92"] = (235, 235, 235)
_colortable["grey92"] = (235, 235, 235)
_colortable["gray93"] = (237, 237, 237)
_colortable["grey93"] = (237, 237, 237)
_colortable["gray94"] = (240, 240, 240)
_colortable["grey94"] = (240, 240, 240)
_colortable["gray95"] = (242, 242, 242)
_colortable["grey95"] = (242, 242, 242)
_colortable["gray96"] = (245, 245, 245)
_colortable["grey96"] = (245, 245, 245)
_colortable["gray97"] = (247, 247, 247)
_colortable["grey97"] = (247, 247, 247)
_colortable["gray98"] = (250, 250, 250)
_colortable["grey98"] = (250, 250, 250)
_colortable["gray99"] = (252, 252, 252)
_colortable["grey99"] = (252, 252, 252)
_colortable["gray100"] = (255, 255, 255)
_colortable["grey100"] = (255, 255, 255)
_colortable["dark"] = (169, 169, 169)
_colortable["DarkGrey"] = (169, 169, 169)
_colortable["dark"] = (169, 169, 169)
_colortable["DarkGray"] = (169, 169, 169)
_colortable["dark"] = (0, 0, 139)
_colortable["DarkBlue"] = (0, 0, 139)
_colortable["dark"] = (0, 139, 139)
_colortable["DarkCyan"] = (0, 139, 139)
_colortable["dark"] = (139, 0, 139)
_colortable["DarkMagenta"] = (139, 0, 139)
_colortable["dark"] = (139, 0, 0)
_colortable["DarkRed"] = (139, 0, 0)
_colortable["light"] = (144, 238, 144)
_colortable["LightGreen"] = (144, 238, 144)
@@ -1,23 +0,0 @@
"""
# ==================================================================
# Python module
#
# Geant4 threading module
#
# Q, 2005
# ==================================================================
"""
import thread
from G4run import *
# ------------------------------------------------------------------
# BeamOn in a new thread
# ------------------------------------------------------------------
def _TBeamOn(self, nevent):
"generate events in a thread"
args = (nevent,)
thread.start_new_thread(self.BeamOn, args)
G4RunManager.TBeamOn= _TBeamOn
@@ -1,68 +0,0 @@
"""
# ==================================================================
# Python module
#
# Visualization Control Panel
#
# Q, 2005
# ==================================================================
"""
from G4interface import *
# ------------------------------------------------------------------
# Scene
# ------------------------------------------------------------------
class G4Scene :
"Scene"
def __init__(self, aname, vol= "world", acopyno=0,
amode=0, bmode=1):
self.name= aname
self.volume= vol
self.copyno= acopyno
self.mode_eventaction= amode # 0: accumulate / 1: refresh
self.mode_runaction= bmode # 0: accumulate / 1: refresh
self.mode= ("accumulate", "refresh")
def create_scene(self):
ApplyUICommand("/vis/scene/create " + self.name)
ApplyUICommand("/vis/scene/add/volume %s %d" %
(self.volume, self.copyno))
ApplyUICommand("/vis/scene/add/trajectories")
self.update_scene()
def update_scene(self):
ApplyUICommand("/vis/scene/select " + self.name)
ApplyUICommand("/vis/sceneHandler/attach")
ApplyUICommand("/vis/scene/endOfEventAction %s" %
(self.mode[self.mode_eventaction]) )
ApplyUICommand("/vis/scene/endOfRunAction %s" %
(self.mode[self.mode_runaction]) )
# ------------------------------------------------------------------
# Visualization Control Panel
# ------------------------------------------------------------------
class G4VisCP :
"G4 Visualization Control Panel"
def __init__(self, gsys="OGLIX"):
self.gsystem= gsys
self.scenelist= [G4Scene("default")]
self.viewpoint= [270., 90.]
rc= ApplyUICommand("/vis/open " + gsys)
if (rc != 0):
return
self.scenelist[0].create_scene()
ApplyUICommand("/vis/viewer/set/viewpointThetaPhi %f %f"
% (self.viewpoint[0], self.viewpoint[1]) )
ApplyUICommand("/tracking/storeTrajectory 1")
def add_scene(self, ascene):
self.scenelist.append(ascene)
def select_scene(self, iscene):
self.scenelist[iscene].update_scene()
ApplyUICommand("/vis/viewer/set/viewpointThetaPhi %f %f"
% (self.viewpoint[0], self.viewpoint[1]) )
-307
View File
@@ -1,307 +0,0 @@
"""
# ==================================================================
# Python module
#
# This module defines physical units and constants used in HEP,
# which are imported from CLHEP library.
#
# Q, 2005
# ==================================================================
"""
# ==================================================================
# imported from "SystemOfUnits.h"
# ==================================================================
millimeter = 1.
millimeter2 = millimeter*millimeter
millimeter3 = millimeter*millimeter*millimeter
centimeter = 10.*millimeter
centimeter2 = centimeter*centimeter
centimeter3 = centimeter*centimeter*centimeter
meter = 1000.*millimeter
meter2 = meter*meter
meter3 = meter*meter*meter
kilometer = 1000.*meter
kilometer2 = kilometer*kilometer
kilometer3 = kilometer*kilometer*kilometer
parsec = 3.0856775807e+16*meter
micrometer = 1.e-6 *meter
nanometer = 1.e-9 *meter
angstrom = 1.e-10*meter
fermi = 1.e-15*meter
barn = 1.e-28*meter2
millibarn = 1.e-3 *barn
microbarn = 1.e-6 *barn
nanobarn = 1.e-9 *barn
picobarn = 1.e-12*barn
# symbols
mm = millimeter
mm2 = millimeter2
mm3 = millimeter3
cm = centimeter
cm2 = centimeter2
cm3 = centimeter3
m = meter
m2 = meter2
m3 = meter3
km = kilometer
km2 = kilometer2
km3 = kilometer3
pc = parsec
#
# Angle
#
radian = 1.
milliradian = 1.e-3*radian
degree = (3.14159265358979323846/180.0)*radian
steradian = 1.
# symbols
rad = radian
mrad = milliradian
sr = steradian
deg = degree
#
# Time [T]
#
nanosecond = 1.
second = 1.e+9 *nanosecond
millisecond = 1.e-3 *second
microsecond = 1.e-6 *second
picosecond = 1.e-12*second
hertz = 1./second
kilohertz = 1.e+3*hertz
megahertz = 1.e+6*hertz
# symbols
ns = nanosecond
s = second
ms = millisecond
#
# Electric charge [Q]
#
eplus = 1. # positron charge
e_SI = 1.60217733e-19 # positron charge in coulomb
coulomb = eplus/e_SI # coulomb = 6.24150 e+18 * eplus
#
# Energy [E]
#
megaelectronvolt = 1.
electronvolt = 1.e-6*megaelectronvolt
kiloelectronvolt = 1.e-3*megaelectronvolt
gigaelectronvolt = 1.e+3*megaelectronvolt
teraelectronvolt = 1.e+6*megaelectronvolt
petaelectronvolt = 1.e+9*megaelectronvolt
joule = electronvolt/e_SI # joule = 6.24150 e+12 * MeV
# symbols
MeV = megaelectronvolt
eV = electronvolt
keV = kiloelectronvolt
GeV = gigaelectronvolt
TeV = teraelectronvolt
PeV = petaelectronvolt
#
# Mass [E][T^2][L^-2]
#
kilogram = joule*second*second/(meter*meter)
gram = 1.e-3*kilogram
milligram = 1.e-3*gram
# symbols
kg = kilogram
g = gram
mg = milligram
#
# Power [E][T^-1]
#
watt = joule/second # watt = 6.24150 e+3 * MeV/ns
#
# Force [E][L^-1]
#
newton = joule/meter # newton = 6.24150 e+9 * MeV/mm
#
# Pressure [E][L^-3]
#
pascal = newton/m2 # pascal = 6.24150 e+3 * MeV/mm3
bar = 100000*pascal # bar = 6.24150 e+8 * MeV/mm3
atmosphere = 101325*pascal # atm = 6.32420 e+8 * MeV/mm3
#
# Electric current [Q][T^-1]
#
ampere = coulomb/second # ampere = 6.24150 e+9 * eplus/ns
milliampere = 1.e-3*ampere
microampere = 1.e-6*ampere
nanoampere = 1.e-9*ampere
#
# Electric potential [E][Q^-1]
#
megavolt = megaelectronvolt/eplus
kilovolt = 1.e-3*megavolt
volt = 1.e-6*megavolt
#
# Electric resistance [E][T][Q^-2]
#
ohm = volt/ampere # ohm = 1.60217e-16*(MeV/eplus)/(eplus/ns)
#
# Electric capacitance [Q^2][E^-1]
#
farad = coulomb/volt # farad = 6.24150e+24 * eplus/Megavolt
millifarad = 1.e-3*farad
microfarad = 1.e-6*farad
nanofarad = 1.e-9*farad
picofarad = 1.e-12*farad
#
# Magnetic Flux [T][E][Q^-1]
#
weber = volt*second # weber = 1000*megavolt*ns
#
# Magnetic Field [T][E][Q^-1][L^-2]
#
tesla = volt*second/meter2 # tesla =0.001*megavolt*ns/mm2
gauss = 1.e-4*tesla
kilogauss = 1.e-1*tesla
#
# Inductance [T^2][E][Q^-2]
#
henry = weber/ampere # henry = 1.60217e-7*MeV*(ns/eplus)**2
#
# Temperature
#
kelvin = 1.
#
# Amount of substance
#
mole = 1.
#
# Activity [T^-1]
#
becquerel = 1./second
curie = 3.7e+10 * becquerel
#
# Absorbed dose [L^2][T^-2]
#
gray = joule/kilogram
#
# Luminous intensity [I]
#
candela = 1.
#
# Luminous flux [I]
#
lumen = candela*steradian
#
# Illuminance [I][L^-2]
#
lux = lumen/meter2
#
# Miscellaneous
#
perCent = 0.01
perThousand = 0.001
perMillion = 0.000001
# ==================================================================
# imported from "PhysicalConstants.h"
# ==================================================================
pi = 3.14159265358979323846
twopi = 2.*pi
halfpi = pi/2.
pi2 = pi*pi
#
Avogadro = 6.0221367e+23/mole
# c = 299.792458 mm/ns
# c^2 = 898.7404 (mm/ns)^2
c_light = 2.99792458e+8 * m/s
c_squared = c_light * c_light
# h = 4.13566e-12 MeV*ns
# hbar = 6.58212e-13 MeV*ns
# hbarc = 197.32705e-12 MeV*mm
h_Planck = 6.6260755e-34 * joule*s
hbar_Planck = h_Planck/twopi
hbarc = hbar_Planck * c_light
hbarc_squared = hbarc * hbarc
#
electron_charge = - eplus # see SystemOfUnits.h
e_squared = eplus * eplus
# amu_c2 - atomic equivalent mass unit
# amu - atomic mass unit
electron_mass_c2 = 0.51099906 * MeV
proton_mass_c2 = 938.27231 * MeV
neutron_mass_c2 = 939.56563 * MeV
amu_c2 = 931.49432 * MeV
amu = amu_c2/c_squared
# permeability of free space mu0 = 2.01334e-16 Mev*(ns*eplus)^2/mm
# permittivity of free space epsil0 = 5.52636e+10 eplus^2/(MeV*mm)
mu0 = 4*pi*1.e-7 * henry/m
epsilon0 = 1./(c_squared*mu0)
# electromagnetic coupling = 1.43996e-12 MeV*mm/(eplus^2)
elm_coupling = e_squared/(4*pi*epsilon0)
fine_structure_const = elm_coupling/hbarc
classic_electr_radius = elm_coupling/electron_mass_c2
electron_Compton_length = hbarc/electron_mass_c2
Bohr_radius = electron_Compton_length/fine_structure_const
alpha_rcl2 = fine_structure_const * classic_electr_radius \
* classic_electr_radius
twopi_mc2_rcl2 = twopi * electron_mass_c2 \
* classic_electr_radius \
* classic_electr_radius
#
k_Boltzmann = 8.617385e-11 * MeV/kelvin
#
STP_Temperature = 273.15*kelvin
STP_Pressure = 1.*atmosphere
kGasThreshold = 10.*mg/cm3
#
universe_mean_density = 1.e-25*g/cm3
+3 -17
View File
@@ -1,9 +1,7 @@
# - build library
# library
set(_TARGET pyG4run)
add_library(
${_TARGET} SHARED
geant4_add_pymodule(pyG4run
pyG4Run.cc
pyG4RunManager.cc
pyG4RunManagerKernel.cc
@@ -16,17 +14,5 @@ add_library(
pymodG4run.cc
)
set_target_properties(${_TARGET} PROPERTIES PREFIX "")
set_target_properties(${_TARGET} PROPERTIES OUTPUT_NAME "G4run")
set_target_properties(${_TARGET} PROPERTIES SUFFIX ".so")
set_target_properties(${_TARGET}
PROPERTIES INSTALL_RPATH
${GEANT4_LIBRARY_DIR}
BUILD_WITH_INSTALL_RPATH TRUE)
target_link_libraries (${_TARGET}
${GEANT4_LIBRARIES_WITH_VIS} ${BOOST_PYTHON_LIB}
${PYTHON_LIBRARIES})
# install
install(TARGETS ${_TARGET} LIBRARY DESTINATION ${G4MODULES_INSTALL_DIR})
target_link_libraries(pyG4run PRIVATE G4run G4readout)
install(TARGETS pyG4run DESTINATION "${CMAKE_INSTALL_PYTHONDIR}/Geant4")
+3 -17
View File
@@ -1,9 +1,7 @@
# - build library
# library
set(_TARGET pyG4track)
add_library(
${_TARGET} SHARED
geant4_add_pymodule(pyG4track
pyG4Step.cc
pyG4StepPoint.cc
pyG4StepStatus.cc
@@ -12,17 +10,5 @@ add_library(
pymodG4track.cc
)
set_target_properties(${_TARGET} PROPERTIES PREFIX "")
set_target_properties(${_TARGET} PROPERTIES OUTPUT_NAME "G4track")
set_target_properties(${_TARGET} PROPERTIES SUFFIX ".so")
set_target_properties(${_TARGET}
PROPERTIES INSTALL_RPATH
${GEANT4_LIBRARY_DIR}
BUILD_WITH_INSTALL_RPATH TRUE)
target_link_libraries (${_TARGET}
${GEANT4_LIBRARIES_WITH_VIS} ${BOOST_PYTHON_LIB}
${PYTHON_LIBRARIES})
# install
install(TARGETS ${_TARGET} LIBRARY DESTINATION ${G4MODULES_INSTALL_DIR})
target_link_libraries(pyG4track PRIVATE G4track G4processes)
install(TARGETS pyG4track DESTINATION "${CMAKE_INSTALL_PYTHONDIR}/Geant4")
@@ -1,26 +1,12 @@
# - build library
# library
set(_TARGET pyG4tracking)
add_library(
${_TARGET} SHARED
geant4_add_pymodule(pyG4tracking
pyG4TrackingManager.cc
pyG4UserSteppingAction.cc
pyG4UserTrackingAction.cc
pymodG4tracking.cc
)
set_target_properties(${_TARGET} PROPERTIES PREFIX "")
set_target_properties(${_TARGET} PROPERTIES OUTPUT_NAME "G4tracking")
set_target_properties(${_TARGET} PROPERTIES SUFFIX ".so")
set_target_properties(${_TARGET}
PROPERTIES INSTALL_RPATH
${GEANT4_LIBRARY_DIR}
BUILD_WITH_INSTALL_RPATH TRUE)
target_link_libraries (${_TARGET}
${GEANT4_LIBRARIES_WITH_VIS} ${BOOST_PYTHON_LIB}
${PYTHON_LIBRARIES})
# install
install(TARGETS ${_TARGET} LIBRARY DESTINATION ${G4MODULES_INSTALL_DIR})
target_link_libraries(pyG4tracking PRIVATE G4tracking)
install(TARGETS pyG4tracking DESTINATION "${CMAKE_INSTALL_PYTHONDIR}/Geant4")
@@ -1,21 +1,19 @@
# - build library
if(GEANT4_HAS_OPENGL)
if(GEANT4_USE_OPENGL_X11)
add_definitions(-DG4VIS_USE_OPENGLX)
endif()
if(GEANT4_HAS_RAYTRACER_X11)
if(GEANT4_USE_RAYTRACER_X11)
add_definitions(-DG4VIS_USE_RAYTRACERX)
endif()
if(GEANT4_HAS_MOTIF)
if(GEANT4_USE_XM)
add_definitions(-DG4VIS_USE_OPENGLXM)
endif()
# library
set(_TARGET pyG4visualization)
add_library(
${_TARGET} SHARED
geant4_add_pymodule(pyG4visualization
pyG4ASCIITree.cc
pyG4DAWNFILE.cc
pyG4HepRep.cc
@@ -33,17 +31,17 @@ add_library(
pymodG4visualization.cc
)
set_target_properties(${_TARGET} PROPERTIES PREFIX "")
set_target_properties(${_TARGET} PROPERTIES OUTPUT_NAME "G4visualization")
set_target_properties(${_TARGET} PROPERTIES SUFFIX ".so")
set_target_properties(${_TARGET}
PROPERTIES INSTALL_RPATH
${GEANT4_LIBRARY_DIR}
BUILD_WITH_INSTALL_RPATH TRUE)
target_link_libraries(pyG4visualization PRIVATE
G4FR
G4Tree
G4RayTracer
G4VRML
G4visHepRep
G4vis_management
)
target_link_libraries (${_TARGET}
${GEANT4_LIBRARIES_WITH_VIS} ${BOOST_PYTHON_LIB}
${PYTHON_LIBRARIES})
if(GEANT4_USE_OPENGL_X11 OR GEANT4_USE_XM)
target_link_libraries(pyG4visualization PRIVATE G4OpenGL)
endif()
# install
install(TARGETS ${_TARGET} LIBRARY DESTINATION ${G4MODULES_INSTALL_DIR})
install(TARGETS pyG4visualization DESTINATION "${CMAKE_INSTALL_PYTHONDIR}/Geant4")
+1 -42
View File
@@ -1,46 +1,5 @@
# - add tests components
set(TEST_MODULES_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}/tests)
# tests for boost_python
add_subdirectory(test00/module)
add_subdirectory(test01/module)
add_subdirectory(test02/module)
add_subdirectory(test03/module EXCLUDE_FROM_ALL)
add_subdirectory(test04/module)
add_subdirectory(test05/module)
add_subdirectory(test06/module)
add_subdirectory(test07/module)
add_subdirectory(test08/module)
add_subdirectory(test09/module)
add_subdirectory(test10/module)
add_subdirectory(test11/module)
add_subdirectory(test12/module)
add_subdirectory(test13/module)
# tests for g4py
add_subdirectory(gtest01/module)
# testing
add_subdirectory(test00)
add_subdirectory(test01)
if (${PYTHON_VERSION_MAJOR} MATCHES "2")
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)
endif()
#
add_subdirectory(g4pytest)
add_subdirectory(gtest01)
add_subdirectory(gtest02)
add_subdirectory(gtest03)
@@ -0,0 +1,35 @@
# - Function to build the C++ modules
function(g4pytest_add_module _TARGET)
g4py_add_module(${_TARGET} ${ARGN})
# Filthy temp hack for submodule paths....
string(REGEX REPLACE "^_" "" _SUBMODULE "${_TARGET}")
set_property(TARGET ${_TARGET} APPEND_STRING PROPERTY LIBRARY_OUTPUT_DIRECTORY "/g4pytest/${_SUBMODULE}")
foreach(_conftype ${CMAKE_CONFIGURATION_TYPES})
string(TOUPPER ${_conftype} _conftype_uppercase)
set_property(TARGET ${_TARGET} APPEND_STRING PROPERTY LIBRARY_OUTPUT_DIRECTORY_${_conftype_uppercase} "/g4pytest/${_SUBMODULE}")
endforeach()
endfunction()
# - add libs components
add_subdirectory(ExN01geom)
add_subdirectory(ExN03geom)
add_subdirectory(Qgeom)
add_subdirectory(ezgeom)
add_subdirectory(NISTmaterials)
add_subdirectory(Qmaterials)
add_subdirectory(EMSTDpl)
add_subdirectory(ExN01pl)
add_subdirectory(MedicalBeam)
add_subdirectory(ParticleGun)
# Remainder are pure python
# Copy/configure pure python components
file(GLOB_RECURSE PY_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.py)
foreach(_pyfile ${PY_FILES})
file(GENERATE
OUTPUT ${GEANT4_PYTHON_OUTPUT_DIR}/g4pytest/${_pyfile}
INPUT ${CMAKE_CURRENT_SOURCE_DIR}/${_pyfile}
)
endforeach()
@@ -0,0 +1,4 @@
# - build library
set(_TARGET _EMSTDpl)
g4pytest_add_module(${_TARGET} PhysicsListEMstd.cc pyEMSTDpl.cc)
target_link_libraries(${_TARGET} PRIVATE G4particles G4processes G4run)
@@ -0,0 +1 @@
from ._EMSTDpl import *
@@ -62,7 +62,7 @@ using namespace pyEMSTDpl;
// Expose to Python
// ====================================================================
BOOST_PYTHON_MODULE(EMSTDpl) {
BOOST_PYTHON_MODULE(_EMSTDpl) {
class_<PhysicsListEMstd, PhysicsListEMstd*, bases<G4VUserPhysicsList> >
("PhysicsListEMstd", "Electron/Gamma EM-standard physics list")
@@ -0,0 +1,4 @@
# - build library
set(_TARGET _ExN01geom)
g4pytest_add_module(${_TARGET} ExN01DetectorConstruction.cc pyExN01geom.cc)
target_link_libraries(${_TARGET} PRIVATE G4materials G4geometry G4run)
@@ -0,0 +1 @@
from ._ExN01geom import *
@@ -58,7 +58,7 @@ using namespace pyExN03geom;
// Expose to Python
// ====================================================================
BOOST_PYTHON_MODULE(ExN01geom) {
BOOST_PYTHON_MODULE(_ExN01geom) {
class_<ExN01DetectorConstruction, ExN01DetectorConstruction*,
bases<G4VUserDetectorConstruction> >
@@ -0,0 +1,4 @@
# - build library
set(_TARGET _ExN01pl)
g4pytest_add_module(${_TARGET} ExN01PhysicsList.cc pyExN01pl.cc)
target_link_libraries(${_TARGET} PRIVATE G4particles G4processes G4run)
@@ -0,0 +1 @@
from ._ExN01pl import *
@@ -62,7 +62,7 @@ using namespace pyExN01pl;
// Expose to Python
// ====================================================================
BOOST_PYTHON_MODULE(ExN01pl) {
BOOST_PYTHON_MODULE(_ExN01pl) {
class_<ExN01PhysicsList, ExN01PhysicsList*, bases<G4VUserPhysicsList> >
("ExN01PhysicsList", "ExN01 physics list")
@@ -0,0 +1,4 @@
# - build library
set(_TARGET _ExN03geom)
g4pytest_add_module(${_TARGET} ExN03DetectorConstruction.cc ExN03DetectorMessenger.cc pyExN03geom.cc)
target_link_libraries(${_TARGET} PRIVATE G4materials G4geometry G4run)
@@ -0,0 +1 @@
from ._ExN03geom import *
@@ -60,7 +60,7 @@ using namespace pyExN03geom;
// Expose to Python
// ====================================================================
BOOST_PYTHON_MODULE(ExN03geom) {
BOOST_PYTHON_MODULE(_ExN03geom) {
class_<ExN03DetectorConstruction, ExN03DetectorConstruction*,
bases<G4VUserDetectorConstruction> >
("ExN03DetectorConstruction", "ExN03 detector")
@@ -0,0 +1,4 @@
# - build library
set(_TARGET _MedicalBeam)
g4pytest_add_module(${_TARGET} MedicalBeam.cc pyMedicalBeam.cc)
target_link_libraries(${_TARGET} PRIVATE G4run G4particles)

Some files were not shown because too many files have changed in this diff Show More