2 # ================================================================== 
    3 #  [Geant4] module package 
    7 #  This package contains a set of Python interface with Geant4. 
    8 # ================================================================== 
   12 __date__ = 
'November/2016' 
   13 __author__ = 
'K.Murakami (Koichi.Murakami@kek.jp)' 
   16 from G4interface 
import *
 
   17 from G4intercoms 
import *
 
   18 from G4global 
import *
 
   21 from G4tracking 
import *
 
   23 from G4particles 
import *
 
   24 from G4processes 
import *
 
   25 from G4geometry 
import *
 
   26 from G4materials 
import *
 
   27 from G4physicslists 
import *
 
   28 from G4digits_hits 
import *
 
   29 from G4visualization 
import *
 
   31 from G4graphics_reps 
import *
 
   33 from colortable 
import *
 
   36   print """============================================================= 
   37   Welcome to Geant4Py (A Geant4-Python Bridge) 
   42 ============================================================= 
   43 """ % ( __version__, __date__, __author__)
 
   68 gStackManager = gEventManager.GetStackManager()
 
   71 gTrackingManager = gEventManager.GetTrackingManager()
 
  101 _material_class_list = dir(G4materials)
 
  102 _qfind = _material_class_list.count(
"G4NistManager") > 0
 
  107 _visdriver_list = dir(G4visualization)
 
  108 _q_opengl_ix = 
"G4OpenGLImmediateX" in _visdriver_list
 
  109 _q_opengl_sx = 
"G4OpenGLStoredX" in _visdriver_list
 
  110 _q_opengl_ixm = 
"G4OpenGLImmediateXm" in _visdriver_list
 
  111 _q_opengl_sxm = 
"G4OpenGLStoredXm" in _visdriver_list
 
  112 _q_raytracer_x = 
"G4RayTracerX" in _visdriver_list
 
  125     _raytracer_x = G4RayTracerX()
 
  136     gVisManager.RegisterGraphicsSystem(_opengl_ix)
 
  138     gVisManager.RegisterGraphicsSystem(_opengl_sx)
 
  140     gVisManager.RegisterGraphicsSystem(_opengl_ixm)
 
  142     gVisManager.RegisterGraphicsSystem(_opengl_sxm)
 
  144     gVisManager.RegisterGraphicsSystem(_raytracer_x)
 
  146   gVisManager.RegisterGraphicsSystem(_vrml1)
 
  147   gVisManager.RegisterGraphicsSystem(_vrml2)
 
  148   gVisManager.RegisterGraphicsSystem(_dawn)
 
  149   gVisManager.RegisterGraphicsSystem(_heprep_xml)
 
  150   gVisManager.RegisterGraphicsSystem(_heprep_file)
 
  151   gVisManager.RegisterGraphicsSystem(_atree)
 
  152   gVisManager.RegisterGraphicsSystem(_raytracer)
 
  154   gVisManager.Initialize()
 
  157 gG4Version = G4Version
 
  159 gG4VERSION_NUMBER = G4VERSION_NUMBER
 
  164 gControlExecute = gUImanager.ExecuteMacroFile
 
  165 gApplyUICommand = G4intercoms.ApplyUICommand
 
  166 gGetCurrentValues = gUImanager.GetCurrentValues
 
  167 gStartUISession = G4interface.StartUISession
 
  177 def _one_event(self):
 
  178   "generate one event." 
  181 G4RunManager.OneEvent = _one_event
 
  186 def _list_material(self):
 
  188   n_materials = len(gMaterialTable)
 
  189   print " +------------------------------------------------------------------" 
  190   print " |       Table of G4Material-s (%d materails defined)" % (n_materials)
 
  191   for i 
in range(0, n_materials) :
 
  192     material = gMaterialTable[i]
 
  193     print " |--------------------------------------------------------"\
 
  195     print " | %s: %s" % (material.GetName(),
 
  196                          G4BestUnit(material.GetDensity(),
"Volumic Mass"))
 
  198     elementVec = material.GetElementVector()
 
  199     fractionVec = material.GetFractionVector()
 
  200     abundanceVec = material.GetVecNbOfAtomsPerVolume()
 
  201     totNAtoms = material.GetTotNbOfAtomsPerVolume()
 
  203     n_elements = len(elementVec)
 
  204     for j 
in range(0, n_elements):
 
  205       print " | + (%1d) %s(%s): A=%4.1f, N=%5.1f, " \
 
  206             "Frac.=(%4.1f%%m,%4.1f%%a)" % \
 
  207             (j+1, elementVec[j].GetName(), elementVec[j].GetSymbol(),
 
  208              elementVec[j].GetZ(),
 
  209              elementVec[j].GetN(),
 
  210              fractionVec[j]/hepunit.perCent,
 
  211              abundanceVec[j]/totNAtoms/hepunit.perCent)
 
  213   print " +------------------------------------------------------------------" 
  215 G4MaterialTable.ListMaterial = _list_material
 
  222     gGeometryManager.OpenGeometry()
 
  231 def _run_abort(signum, frame):
 
  232   state = gStateManager.GetCurrentState()
 
  234   if(state == G4ApplicationState.G4State_GeomClosed 
or 
  235      state == G4ApplicationState.G4State_EventProc):
 
  236     print "aborting Run ..." 
  237     gRunManager.AbortRun(
True)
 
  239     raise KeyboardInterrupt
 
  241 if (threading.activeCount() == 1):
 
  242   signal.signal(signal.SIGINT, _run_abort)
 
static G4VVisManager * GetConcreteInstance()
 
static G4MaterialTable * GetMaterialTable()
 
static G4RunManagerKernel * GetRunManagerKernel()
 
static G4NistManager * Instance()
 
static G4UImanager * GetUIpointer()
 
static G4StateManager * GetStateManager()
 
const G4ParticleDefinition const G4Material *G4double range
 
static G4GeometryManager * GetInstance()
 
static G4TransportationManager * GetTransportationManager()
 
static G4RunManager * GetRunManager()
 
static G4ProductionCutsTable * GetProductionCutsTable()
 
static G4ParticleTable * GetParticleTable()
 
static G4EventManager * GetEventManager()
 
void SetG4PyCoutDestination()
 
static G4ElementTable * GetElementTable()
 
static G4ProcessTable * GetProcessTable()