Import Geant4 9.4.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-09 16:25:56 +02:00
parent 74cad5e589
commit 89a9605df1
4440 changed files with 379508 additions and 189225 deletions
+22 -1
View File
@@ -1,4 +1,4 @@
$Id: History,v 1.40 2009/11/27 07:59:32 kmura Exp $
$Id: History,v 1.43 2010/12/02 08:06:06 kmura Exp $
-------------------------------------------------------------------
=========================================================
@@ -18,6 +18,27 @@ committal in the CVS repository !
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
envs-V09-03-02 / 2 December 2010 Koichi Murakami
[g4py]
- updates for 9.4 release
- add a new example using GTK (examples/emplot/emcalc_gui.py)
- experimental support for Python3
[momo]
- Uses QGSP_BERT physics list instead of GPE
- JAVA source codes are included. (momo-src.jar)
envs-V09-03-01 / 21 June 2010 Koichi Murakami
[g4py]
- updates for 9.4-beta-cand-02 tag (G4RunManager, physics list)
envs-V09-03-00 / 4 June 010 Koichi Murakami
[g4py]
- update for the 9.4 beta release
- revise usage of MultipleScattering classes
- bug fix in wrapping of G4GDMLParser
[momo]
- revise archaic trajectory drawing
envs-V09-02-02 27 Nov. 2009 Koichi Murakami
[g4py]
- linker option is updated.
+22
View File
@@ -0,0 +1,22 @@
How to use momo-src.jar
momo-src.jar is the Java archive file which contains all Java source files and
relevant data files, as well as a Geant4.9.4 example in ./MomoHome directory.
If you use MOMO.jar to run MOMO, momo-src.jar isn't necessary.
When you have new JDK or other JDK like OpenJDK etc, momo-src.jar can be used
to create your own MOMO.jar.
The required tools are
1) JDK-1.6 or later (OpenJDK isn't tested fully)
2) Apache ant (1.7 or later)
To compile,
1) copy momo-src.jar to any clean directory and change directory to there
2) jar fvx momo-src.jar and you have the full codes and data.
3) ant (build.xml is use by default) and you have MOMO.jar the executable MOMO jar file
4) java -jar ./MOMO.jar
you may have a warning on the unsecure use of the HashTable but you can neglect it.
+9 -1
View File
@@ -1,4 +1,4 @@
$Id: History,v 1.6 2004/11/26 04:53:21 hajime Exp $
$Id: History,v 1.8 2010/12/01 05:41:58 kmura Exp $
-------------------------------------------------------------------
=========================================================
@@ -18,6 +18,14 @@ committal in the CVS repository !
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
2010 December 1 Koichi Murakami
- MOMO.jar updated (use QGSP_BERT physics list instead of GPE)
- JAVA source codes are included. (momo-src.jar)
- MomoHome and docs directories are migrated to momo-src.jar
2010 June 4 Koichi Murakami
- revise archaic trajectory drawing (vis.mac and EventAction in MomoHome)
2004 November 26 Hajime Yoshida
- replaced MOMO.jar with minor changes
- added some example files and README
Binary file not shown.
Binary file not shown.
-48
View File
@@ -1,48 +0,0 @@
##### GNUmakefile #####
# ----------------------------------------------------------
# Script defining rules and paths for making binaries.
# ----------------------------------------------------------
# Automatic creation of GNUmakefile for Momo environment.
# with users selection of G4TARGET, UI and VIS variables
# Momo is the name of legendary samurai who conquered bad geants. ---- H. Yoshida.
name := linac
G4TARGET := $(name)
G4EXLIB := true
# Vis/GUI used
G4VIS_USE_DAWN := 1
G4VIS_USE_DAWNFILE := 1
G4VIS_USE_OPENGLX := 1
G4VIS_USE_VRML := 1
G4VIS_USE_VRMLFILE := 1
# Vis/GUI built
G4VIS_BUILD_DAWN_DRIVER := 1
G4VIS_BUILD_DAWNFILE_DRIVER := 1
G4VIS_BUILD_OPENGLX_DRIVER := 1
G4VIS_BUILD_VRML_DRIVER := 1
G4VIS_BUILD_VRMLFILE_DRIVER := 1
# General Envs defined
G4SYSTEM:=Linux-g++
G4INSTALL:=/home/yoshidah/geant4
G4WORKDIR:=/home/yoshidah/geant4
G4BINDIR:=/home/yoshidah/geant4/bin/Linux-g++
G4USE_STL:=1
G4LIB_BUILD_STATIC:=1
NeutronHPCrossSections:=/home/yoshidah/G4data/G4NDL3.7
G4LEDATA:=/home/yoshidah/G4data/G4EMLOW2.3
G4LEVELGAMMADATA:=/home/yoshidah/G4data/PhotonEvaporation
G4RADIOACTIVEDATA:=/home/yoshidah/G4data/RadiativeDecay
G4REALSURFACEDATA:=/home/yoshidah/G4data/RealSurface1.0
ifndef G4INSTALL
G4INSTALL = ../../..
endif
.PHONY: all
all: lib bin
include $(G4INSTALL)/config/binmake.gmk
-71
View File
@@ -1,71 +0,0 @@
2004 NOvember 26
A) How to use MOMO.
1) cd here where src/ and include/ are located
2) "java -version" and check that your java virtual machine is version 1.4
(1.5 works with some malfuctionning)
3) "java -jar ../MOMO.jar" and MOMO starts
4) check that "set G4WORKDIR" displays this directory. If you change this,
you will have faster access to files in that directory.
B) How to use the example of a flattening filter
1) relevant files of this example are
./linac.cc
./Momomake.gmk
./flat.his (a macro file)
./src/flatteningFilter.cc
./include/flatteningFilter.hh
All these files are generated automatically by MOMO, including the history macro file.
2) fill the tables from the persistent files
a) GPE -> load file -> MomoN02PhysicsList.g4ph
-> make C++ file -> save in src/
-> make header file -> save in include/
b) GGE -> load file -> flatteningFilter.g4dt
-> make C++ file -> save in src/
-> make header file -> savle in include/
c) type i the name of the main program in the top field of MOMO panel
3) Project menu
a) make main program -> save here
b) make Makefile -> save here
c) compile
If some errors are found, correct them
4) run
GAG -> Geant4 -> Start -> file chooser
mouse click /control/execute -> file chooser -> flat.his -> OK
and you will have OpenGL event display:
e- 10MeV, entering the flattenig filter (same as the examples/extended/linac),
changing the incident angles
Enjoy!
--------------------------------------------------------------------
2002 March
Momo's default home directory in which the default src and include
directories and the default four classes are placed.
src/MomoEventAction.cc
src/MomoRunAction.cc
src/MomoPrimaryGeneratorAction.cc
src/MomoVisManager.cc
include/MomoEventAction.hh
include/MomoRunAction.hh
include/MomoPrimaryGeneratorAction.hh
include/MomoVisManager.hh
A macro file is included to visualise events and trajectories
./vis.mac
And this file
./README
-36
View File
@@ -1,36 +0,0 @@
#Command History List
/control/execute vis.mac
/gun/particle e-
/gun/direction 0 0 -1
/gun/energy 0.01 GeV
/gun/position 0 0 110 cm
/run/beamOn 10 ***NULL*** -1
/vis/viewer/zoom 5
/vis/viewer/pan 0.1 0 m
/vis/viewer/pan 0.1 0 m
/vis/viewer/pan 0.1 0 m
/vis/viewer/pan 0.1 0 m
/vis/viewer/pan 0.1 0 m
/vis/viewer/pan 0.1 0 m
/vis/viewer/pan 0.1 0 m
/vis/viewer/pan 0.1 0 m
/vis/viewer/pan 0.1 0 m
/vis/viewer/zoom 4
/vis/viewer/pan 0.1 0 m
/vis/viewer/pan 0.1 0 m
/run/beamOn 100 ***NULL*** -1
/gun/direction 0.0 0.01 -1
/run/beamOn 100 ***NULL*** -1
/gun/direction 0.0 0.03 -1
/run/beamOn 100 ***NULL*** -1
/gun/direction 0.0 0.05 -1
/run/beamOn 100 ***NULL*** -1
/gun/direction 0.0 0.08 -1
/run/beamOn 100 ***NULL*** -1
/gun/direction 0.0 0.1 -1
/run/beamOn 100 ***NULL*** -1
/gun/direction 0.0 0.0 -1
/run/beamOn 100 ***NULL*** -1
/run/beamOn 100 ***NULL*** -1
/run/beamOn 100 ***NULL*** -1
Binary file not shown.
@@ -1,53 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// Taken from
// $Id: MomoEventAction.hh,v 1.2 2006/06/29 15:27:31 gunter Exp $
// GEANT4 tag $Name: geant4-09-02 $
//
#ifndef MomoEventAction_h
#define MomoEventAction_h 1
#include "G4UserEventAction.hh"
class G4Event;
class MomoEventAction : public G4UserEventAction
{
public:
MomoEventAction();
~MomoEventAction();
public:
void BeginOfEventAction(const G4Event*);
void EndOfEventAction(const G4Event*);
};
#endif
@@ -1,55 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// Physics List Header File
// MomoN02PhysicsList.hh generated by Geant4 Physics Editor at Thu Mar 14 10:39:12 JST 2002
#ifndef MomoN02PhysicsList_h
#define MomoN02PhysicsList_h 1
#include "G4VUserPhysicsList.hh"
class MomoN02PhysicsList: public G4VUserPhysicsList
{ public:
MomoN02PhysicsList();
virtual ~MomoN02PhysicsList();
protected:
virtual void ConstructParticle();
virtual void ConstructProcess();
virtual void SetCuts();
protected:
virtual void ConstructBosons();
virtual void ConstructLeptons();
virtual void ConstructMesons();
virtual void ConstructBaryons();
protected:
virtual void ConstructGeneral();
virtual void ConstructEM();
virtual void ConstructAllShortLiveds();
};
#endif
@@ -1,59 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// 1998 Dec 10, updated for geant4.0.0, Hajime Yoshida
// 2002 March Geant4.4.0
#ifndef MomoPrimaryGeneratorAction_h
#define MomoPrimaryGeneratorAction_h 1
#include "G4VUserPrimaryGeneratorAction.hh"
class G4ParticleGun;
class G4Event;
class MomoPrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction
{
public:
MomoPrimaryGeneratorAction();
~MomoPrimaryGeneratorAction();
public:
void GeneratePrimaries(G4Event* anEvent);
private:
G4ParticleGun* particleGun;
};
#endif
@@ -1,56 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// Taken after
// $Id: MomoRunAction.hh,v 1.2 2006/06/29 15:27:45 gunter Exp $
// GEANT4 tag $Name: geant4-09-02 $
//
#ifndef MomoRunAction_h
#define MomoRunAction_h 1
#include "G4UserRunAction.hh"
#include "globals.hh"
class G4Run;
class MomoRunAction : public G4UserRunAction
{
public:
MomoRunAction();
~MomoRunAction();
public:
void BeginOfRunAction(const G4Run*);
void EndOfRunAction(const G4Run*);
};
#endif
@@ -1,74 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// 1998 Dec 10, updated for geant4.0.0, Hajime Yoshida
//
//
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
// Example Visualization Manager implementing virtual function
// RegisterGraphicsSystems. Exploits C-pre-processor variables
// G4VIS_USE_DAWN, etc., which are set by the GNUmakefiles if
// environment variables of the same name are set.
// So all you have to do is set environment variables and compile and
// instantiate this in your main().
// Alternatively, you can implement an empty function here and just
// register the systems you want in your main(), e.g.:
// G4VisManager* myVisManager = new MyVisManager;
// myVisManager -> RegisterGraphicsSystem (new MyGraphicsSystem);
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
#ifndef MomoVisManager_h
#define MomoVisManager_h 1
#include "G4VisManager.hh"
class MomoVisManager: public G4VisManager {
public:
MomoVisManager ();
private:
void RegisterGraphicsSystems ();
};
#endif
@@ -1,45 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// Geometry Header File
// flatteningFilter.hh generated by Geant4 Geometry Editor at Thu Nov 25 21:17:02 JST 2004
#ifndef flatteningFilter_h
#define flatteningFilter_h 1
class G4VPhysicalVolume;
#include "G4VUserDetectorConstruction.hh"
class flatteningFilter: public G4VUserDetectorConstruction
{ public:
flatteningFilter();
~flatteningFilter();
public:
G4VPhysicalVolume* Construct();
};
#endif
-89
View File
@@ -1,89 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//##### MOMO Main program #####
//# ----------------------------------------------------------
//# Automatic creation of the main program for Momo environment.
// 2003 December, updated for geant4.6.0
// --------------------------------------------------------------
// linac.cc generated by Geant4 Momo
// at Sat Nov 27 12:16:36 JST 2004
// This code implementation is the intellectual property of
// the GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
//
#include "G4RunManager.hh"
#include "G4UImanager.hh"
// Your choice of User Interface driver
#include "G4UIGAG.hh"
// Detector geometry generated by Momo's GGE
#include "flatteningFilter.hh"
// Physics List generated by Momo's GPE
#include "MomoN02PhysicsList.hh"
// Momo's default PrimaryGeneratorAction
#include "MomoPrimaryGeneratorAction.hh"
#include "MomoRunAction.hh"
#include "MomoEventAction.hh"
#ifdef G4VIS_USE
#include "MomoVisManager.hh"
#endif
int main()
{
// Construct the default run manager
G4RunManager* runManager = new G4RunManager;
// set mandatory initialization classes
runManager->SetUserInitialization(new flatteningFilter);
runManager->SetUserInitialization(new MomoN02PhysicsList);
#ifdef G4VIS_USE
// visualization manager
G4VisManager* visManager = new MomoVisManager;
visManager->Initialize();
#endif
// set mandatory user action class
runManager->SetUserAction(new MomoPrimaryGeneratorAction);
// set user action classes to visualise trajectories
runManager->SetUserAction(new MomoRunAction);
runManager->SetUserAction(new MomoEventAction);
// Initialize G4 kernel
runManager->Initialize();
// get the pointer to the User Interface manager
G4UImanager* UI = G4UImanager::GetUIpointer();
G4UIsession * session = new G4UIGAG;
session->SessionStart();
delete session;
// job termination
#ifdef G4VIS_USE
delete visManager;
#endif
delete runManager;
return 0;
}
@@ -1,82 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// Taken from
// $Id: MomoEventAction.cc,v 1.2 2006/06/29 15:27:54 gunter Exp $
// GEANT4 tag $Name: geant4-09-02 $
//
#include "MomoEventAction.hh"
#include "G4Event.hh"
#include "G4EventManager.hh"
#include "G4TrajectoryContainer.hh"
#include "G4Trajectory.hh"
#include "G4VVisManager.hh"
#include "G4ios.hh"
MomoEventAction::MomoEventAction()
{}
MomoEventAction::~MomoEventAction()
{}
void MomoEventAction::BeginOfEventAction(const G4Event*)
{}
void MomoEventAction::EndOfEventAction(const G4Event* evt)
{
G4int event_id = evt->GetEventID();
// get number of stored trajectories
//
G4TrajectoryContainer* trajectoryContainer = evt->GetTrajectoryContainer();
G4int n_trajectories = 0;
if (trajectoryContainer) n_trajectories = trajectoryContainer->entries();
// periodic printing
//
if (event_id < 100 || event_id%100 == 0) {
G4cout << ">>> Event " << evt->GetEventID() << G4endl;
G4cout << " " << n_trajectories
<< " trajectories stored in this event." << G4endl;
}
// extract the trajectories and draw them
//
if (G4VVisManager::GetConcreteInstance())
{
for (G4int i=0; i<n_trajectories; i++)
{ G4Trajectory* trj = (G4Trajectory*)
((*(evt->GetTrajectoryContainer()))[i]);
trj->DrawTrajectory(50);
}
}
}
@@ -1,241 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// MomoN02PhysicsList.cc
// generated by Geant4 Physics Editor at Thu Nov 25 13:06:26 JST 2004
#include "MomoN02PhysicsList.hh"
#include "globals.hh"
#include "G4ParticleDefinition.hh"
#include "G4ParticleWithCuts.hh"
#include "G4ProcessManager.hh"
#include "G4ProcessVector.hh"
#include "G4ParticleTypes.hh"
#include "G4ParticleTable.hh"
#include "G4ShortLivedConstructor.hh"
#include "G4Material.hh"
#include "G4MaterialTable.hh"
#include "G4ios.hh"
MomoN02PhysicsList::MomoN02PhysicsList(): G4VUserPhysicsList()
{
// Here used the default cut value you have typed in
defaultCutValue = 1.0*cm;
SetVerboseLevel(1);
}
MomoN02PhysicsList::~MomoN02PhysicsList()
{}
void MomoN02PhysicsList::ConstructParticle()
{
// Here are constructed all particles you have chosen
ConstructBosons();
ConstructLeptons();
ConstructMesons();
ConstructBaryons();
ConstructAllShortLiveds();
}
// In this method, static member functions should be called for ALL particles to be used.
void MomoN02PhysicsList::ConstructBosons()
{
G4ChargedGeantino::ChargedGeantinoDefinition();
G4Gamma::GammaDefinition();
G4Geantino::GeantinoDefinition();
}
void MomoN02PhysicsList::ConstructLeptons()
{
G4Electron::ElectronDefinition();
G4Positron::PositronDefinition();
G4MuonPlus::MuonPlusDefinition();
G4MuonMinus::MuonMinusDefinition();
G4NeutrinoE::NeutrinoEDefinition();
G4AntiNeutrinoE::AntiNeutrinoEDefinition();
G4NeutrinoMu::NeutrinoMuDefinition();
G4AntiNeutrinoMu::AntiNeutrinoMuDefinition();
}
void MomoN02PhysicsList::ConstructMesons()
{
G4PionPlus::PionPlusDefinition();
G4PionMinus::PionMinusDefinition();
G4PionZero::PionZeroDefinition();
G4Eta::EtaDefinition();
G4KaonPlus::KaonPlusDefinition();
G4KaonMinus::KaonMinusDefinition();
G4KaonZeroLong::KaonZeroLongDefinition();
G4KaonZeroShort::KaonZeroShortDefinition();
G4KaonZero::KaonZeroDefinition();
}
void MomoN02PhysicsList::ConstructBaryons()
{
G4Proton::ProtonDefinition();
G4AntiProton::AntiProtonDefinition();
G4Neutron::NeutronDefinition();
G4AntiNeutron::AntiNeutronDefinition();
}
void MomoN02PhysicsList::ConstructAllShortLiveds()
{
// Here are contructed all short liveds
}
void MomoN02PhysicsList::ConstructProcess()
{
// Transportation, electromagnetic and general processes
AddTransportation();
ConstructEM();
ConstructGeneral();
}
// Here are respective header files for chosen processes
#include "G4GammaConversion.hh"
#include "G4ComptonScattering.hh"
#include "G4PhotoElectricEffect.hh"
#include "G4MultipleScattering.hh"
#include "G4eIonisation.hh"
#include "G4eBremsstrahlung.hh"
#include "G4eplusAnnihilation.hh"
#include "G4MuBremsstrahlung.hh"
#include "G4MuPairProduction.hh"
#include "G4MuIonisation.hh"
// The next two processes are always included.
#include "G4hIonisation.hh"
#include "G4MultipleScattering.hh"
void MomoN02PhysicsList::ConstructEM()
{
theParticleIterator->reset();
while( (*theParticleIterator)() ){
G4ParticleDefinition* particle = theParticleIterator->value();
G4ProcessManager* pmanager = particle->GetProcessManager();
G4String particleName = particle->GetParticleName();
// The next processes are always added.
if ((!particle->IsShortLived()) &&
(particle->GetPDGCharge() != 0.0 )&&
(particle->GetParticleName() != "e-") &&
(particle->GetParticleName() != "e+") &&
(particle->GetParticleName() != "mu-") &&
(particle->GetParticleName() != "mu+") &&
(particle->GetParticleName() != "chargedgeantino")){
pmanager->AddProcess(new G4MultipleScattering(), -1, 1, 1);
pmanager->AddProcess(new G4hIonisation(), -1, 2, 2);
}
// Each if clause corresponds to a row in the PhysicsTable
if (particleName == "gamma") {
pmanager->AddProcess(new G4GammaConversion(),ordInActive,ordInActive,ordDefault);
}
if (particleName == "gamma") {
pmanager->AddProcess(new G4ComptonScattering(),ordInActive,ordInActive,ordDefault);
}
if (particleName == "gamma") {
pmanager->AddProcess(new G4PhotoElectricEffect(),ordInActive,ordInActive,ordDefault);
}
if (particleName == "e-") {
pmanager->AddProcess(new G4MultipleScattering(),ordInActive,1,1);
}
if (particleName == "e-") {
pmanager->AddProcess(new G4eIonisation(),ordInActive,2,2);
}
if (particleName == "e-") {
pmanager->AddProcess(new G4eBremsstrahlung(),ordInActive,ordInActive,3);
}
if (particleName == "e+") {
pmanager->AddProcess(new G4eIonisation(),ordInActive,2,2);
}
if (particleName == "e+") {
pmanager->AddProcess(new G4eBremsstrahlung(),ordInActive,ordInActive,3);
}
if (particleName == "e+") {
pmanager->AddProcess(new G4eplusAnnihilation(),ordDefault,ordInActive,4);
}
if (particleName == "e+") {
pmanager->AddProcess(new G4MultipleScattering(),ordInActive,1,1);
}
if (particleName == "mu+") {
pmanager->AddProcess(new G4MultipleScattering(),ordInActive,1,1);
}
if (particleName == "mu+") {
pmanager->AddProcess(new G4MuBremsstrahlung(),ordInActive,ordInActive,3);
}
if (particleName == "mu+") {
pmanager->AddProcess(new G4MuPairProduction(),ordInActive,ordInActive,4);
}
if (particleName == "mu+") {
pmanager->AddProcess(new G4MuIonisation(),ordInActive,2,2);
}
if (particleName == "mu-") {
pmanager->AddProcess(new G4MultipleScattering(),ordInActive,1,1);
}
if (particleName == "mu-") {
pmanager->AddProcess(new G4MuBremsstrahlung(),ordInActive,ordInActive,3);
}
if (particleName == "mu-") {
pmanager->AddProcess(new G4MuIonisation(),ordInActive,2,2);
}
if (particleName == "mu-") {
pmanager->AddProcess(new G4MuPairProduction(),ordInActive,ordInActive,4);
}
}
}
#include "G4Decay.hh"
void MomoN02PhysicsList::ConstructGeneral()
{
G4Decay* theDecayProcess = new G4Decay();
theParticleIterator->reset();
while( (*theParticleIterator)() ){
G4ParticleDefinition* particle = theParticleIterator->value();
G4ProcessManager* pmanager = particle->GetProcessManager();
if (theDecayProcess->IsApplicable(*particle)) {
pmanager ->AddProcess(theDecayProcess);
pmanager ->SetProcessOrdering(theDecayProcess, idxPostStep);
pmanager ->SetProcessOrdering(theDecayProcess, idxAtRest);
}
}
}
void MomoN02PhysicsList::SetCuts()
{
// defaultCutValue you have typed in is used
if (verboseLevel >1){
G4cout << "MomoN02PhysicsList::SetCuts:";
}
SetCutsWithDefault();
}
@@ -1,81 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// 1998 Dec 10, updated for geant4-00 , Hajime Yoshida
// 2002 March update for geant4.4.0
#include "MomoPrimaryGeneratorAction.hh"
#include "G4Event.hh"
#include "G4ParticleGun.hh"
#include "G4UImanager.hh"
#include "globals.hh"
MomoPrimaryGeneratorAction::MomoPrimaryGeneratorAction()
{
G4int n_particle = 1;
particleGun = new G4ParticleGun(n_particle);
// G4UImanager* UI = G4UImanager::GetUIpointer();
//UI->ApplyCommand("/gun/particle geantino");
//UI->ApplyCommand("/gun/energy 1.0 GeV");
//UI->ApplyCommand("/gun/position -2.0 0.0 0.0 m");
}
MomoPrimaryGeneratorAction::~MomoPrimaryGeneratorAction()
{
delete particleGun;
}
void MomoPrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
{
/*
G4UImanager* UI = G4UImanager::GetUIpointer();
G4int i = anEvent->GetEventID() % 3;
switch(i)
{
case 0:
UI->ApplyCommand("/gun/direction 1.0 0.0 0.0");
break;
case 1:
UI->ApplyCommand("/gun/direction 1.0 0.1 0.0");
break;
case 2:
UI->ApplyCommand("/gun/direction 1.0 0.0 0.1");
break;
}
*/
particleGun->GeneratePrimaryVertex(anEvent);
}
@@ -1,69 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// Taken from
// $Id: MomoRunAction.cc,v 1.2 2006/06/29 15:28:02 gunter Exp $
// GEANT4 tag $Name: geant4-09-02 $
//
#include "MomoRunAction.hh"
#include "G4Run.hh"
#include "G4UImanager.hh"
#include "G4VVisManager.hh"
#include "G4ios.hh"
MomoRunAction::MomoRunAction()
{}
MomoRunAction::~MomoRunAction()
{}
void MomoRunAction::BeginOfRunAction(const G4Run* aRun)
{
G4cout << "### Run " << aRun->GetRunID() << " start." << G4endl;
if (G4VVisManager::GetConcreteInstance())
{
G4UImanager* UI = G4UImanager::GetUIpointer();
UI->ApplyCommand("/vis/scene/notifyHandlers");
}
}
void MomoRunAction::EndOfRunAction(const G4Run*)
{
if (G4VVisManager::GetConcreteInstance())
{
G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/update");
}
}
@@ -1,159 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// 2002 march, updated for geant4.4.0, Hajime Yoshida
//
//
// John Allison 24th January 1998.
#ifdef G4VIS_USE
#include "MomoVisManager.hh"
// Supported drivers...
#ifdef G4VIS_USE_DAWN
#include "G4FukuiRenderer.hh"
#endif
#ifdef G4VIS_USE_DAWNFILE
#include "G4DAWNFILE.hh"
#endif
#ifdef G4VIS_USE_OPENGLX
#include "G4OpenGLImmediateX.hh"
#include "G4OpenGLStoredX.hh"
#endif
#ifdef G4VIS_USE_VRML
#include "G4VRML1.hh"
// #include "G4VRML2.hh"
#endif
#ifdef G4VIS_USE_VRMLFILE
#include "G4VRML1File.hh"
//#include "G4VRML2File.hh"
#endif
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
MomoVisManager::MomoVisManager () {}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void MomoVisManager::RegisterGraphicsSystems () {
#ifdef G4VIS_USE_DAWN
RegisterGraphicsSystem (new G4FukuiRenderer);
#endif
#ifdef G4VIS_USE_DAWNFILE
RegisterGraphicsSystem (new G4DAWNFILE);
#endif
#ifdef G4VIS_USE_OPENGLX
RegisterGraphicsSystem (new G4OpenGLImmediateX);
RegisterGraphicsSystem (new G4OpenGLStoredX);
#endif
#ifdef G4VIS_USE_VRML
RegisterGraphicsSystem (new G4VRML1);
// RegisterGraphicsSystem (new G4VRML2);
#endif
#ifdef G4VIS_USE_VRMLFILE
RegisterGraphicsSystem (new G4VRML1File);
// RegisterGraphicsSystem (new G4VRML2File);
#endif
if (fVerbose > 0) {
G4cout <<
"\nYou have successfully chosen to use the following graphics systems."
<< G4endl;
PrintAvailableGraphicsSystems ();
}
}
#endif
@@ -1,627 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//***** Generated by Geant4 Geometry Editor at Fri Nov 26 11:51:46 JST 2004 *****
//------HeaderFile-
#include "flatteningFilter.hh"
#include "G4UnitsTable.hh"
#include "G4VUserDetectorConstruction.hh"
#include "globals.hh"
#include "G4Material.hh"
#include "G4MaterialTable.hh"
#include "G4Element.hh"
#include "G4ElementTable.hh"
#include "G4Box.hh"
#include "G4Tubs.hh"
#include "G4Cons.hh"
#include "G4LogicalVolume.hh"
#include "G4ThreeVector.hh"
#include "G4PVPlacement.hh"
#include "G4PVReplica.hh"
#include "G4SDManager.hh"
#include "G4VisAttributes.hh"
#include "G4Colour.hh"
flatteningFilter::flatteningFilter()
{ ; }
flatteningFilter::~flatteningFilter()
{ ; }
G4VPhysicalVolume* flatteningFilter::Construct( )
{
// Elements
G4Element* elementN = new G4Element( "Nitrogen", "N", 7. , 14.00674*g/mole );
G4Element* elementO = new G4Element( "Oxygen", "O", 8. , 15.9994*g/mole );
G4Element* elementH = new G4Element( "Hydrogen", "H", 1. , 1.00794*g/mole );
// Materials from Combination
G4Material* Air = new G4Material("Air", 1.205*mg/cm3, 2, kStateUndefined, 293.15*kelvin, 1.0*atmosphere );
Air->AddElement( elementN, 1 );
Air->AddElement( elementO, 0 );
G4Material* H2O = new G4Material("H2O", 1.0*g/cm3, 2, kStateUndefined, 273.15*kelvin, 1.0*atmosphere );
H2O->AddElement( elementH, 2 );
H2O->AddElement( elementO, 1 );
// Materials from Scratch
G4Material* Aluminum = new G4Material("Aluminum", 13, 26.981539*g/mole, 2.7*g/cm3,kStateSolid, 273.15*kelvin, 1.0*atmosphere );
// Visualization attributes
G4VisAttributes * b1= new G4VisAttributes( G4Colour(0/255. ,238/255. ,238/255. ));
G4VisAttributes * b2= new G4VisAttributes( G4Colour(10/255. ,238/255. ,238/255. ));
G4VisAttributes * b3= new G4VisAttributes( G4Colour(20/255. ,238/255. ,238/255. ));
G4VisAttributes * b4= new G4VisAttributes( G4Colour(30/255. ,238/255. ,238/255. ));
G4VisAttributes * b5= new G4VisAttributes( G4Colour(39/255. ,238/255. ,238/255. ));
G4VisAttributes * b6= new G4VisAttributes( G4Colour(49/255. ,238/255. ,238/255. ));
G4VisAttributes * b7= new G4VisAttributes( G4Colour(57/255. ,238/255. ,238/255. ));
G4VisAttributes * b8= new G4VisAttributes( G4Colour(67/255. ,238/255. ,238/255. ));
G4VisAttributes * b9= new G4VisAttributes( G4Colour(77/255. ,238/255. ,238/255. ));
G4VisAttributes * b10= new G4VisAttributes( G4Colour(87/255. ,238/255. ,238/255. ));
G4VisAttributes * b11= new G4VisAttributes( G4Colour(94/255. ,238/255. ,238/255. ));
G4VisAttributes * b12= new G4VisAttributes( G4Colour(101/255. ,238/255. ,238/255. ));
G4VisAttributes * b13= new G4VisAttributes( G4Colour(109/255. ,238/255. ,238/255. ));
G4VisAttributes * b14= new G4VisAttributes( G4Colour(117/255. ,238/255. ,238/255. ));
G4VisAttributes * b15= new G4VisAttributes( G4Colour(126/255. ,238/255. ,238/255. ));
G4VisAttributes * b16= new G4VisAttributes( G4Colour(135/255. ,238/255. ,238/255. ));
G4VisAttributes * b17= new G4VisAttributes( G4Colour(146/255. ,238/255. ,238/255. ));
G4VisAttributes * b18= new G4VisAttributes( G4Colour(156/255. ,238/255. ,238/255. ));
G4VisAttributes * g1= new G4VisAttributes( G4Colour(156/255. ,255/255. ,41/255. ));
G4VisAttributes * g2= new G4VisAttributes( G4Colour(156/255. ,255/255. ,64/255. ));
G4VisAttributes * g3= new G4VisAttributes( G4Colour(156/255. ,255/255. ,84/255. ));
G4VisAttributes * pink= new G4VisAttributes( G4Colour(255/255. ,153/255. ,153/255. ));
G4VisAttributes * b19= new G4VisAttributes( G4Colour(216/255. ,248/255. ,246/255. ));
// Logical Volumes
G4Box *solidworld= new G4Box("solidworld", 1000.0*mm, 1000.0*mm, 4000.0*mm );
G4LogicalVolume * world = new G4LogicalVolume(solidworld, //its solid
Air, //its material
"world" , //its name
0,0,0);
G4Box *solidwaterbox= new G4Box("solidwaterbox", 200.0*mm, 200.0*mm, 200.0*mm );
G4LogicalVolume * waterbox = new G4LogicalVolume(solidwaterbox, //its solid
H2O, //its material
"waterbox" , //its name
0,0,0);
waterbox->SetVisAttributes(pink);
G4Cons *solidcon1= new G4Cons("solidcon1", 0.0*mm, 1.0E-7*mm, 0.0*mm, 0.25*mm, 0.06*mm, 0.0*rad, 360.0*deg );
G4LogicalVolume * con1 = new G4LogicalVolume(solidcon1, //its solid
Aluminum, //its material
"con1" , //its name
0,0,0);
con1->SetVisAttributes(b1);
G4Cons *solidcon2= new G4Cons("solidcon2", 0.0*mm, 0.51*mm, 0.0*mm, 0.25*mm, 0.065*mm, 0.0*rad, 360.0*deg );
G4LogicalVolume * con2 = new G4LogicalVolume(solidcon2, //its solid
Aluminum, //its material
"con2" , //its name
0,0,0);
con2->SetVisAttributes(b2);
G4Cons *solidcon3= new G4Cons("solidcon3", 0.0*mm, 0.77*mm, 0.0*mm, 0.51*mm, 0.075*mm, 0.0*rad, 360.0*deg );
G4LogicalVolume * con3 = new G4LogicalVolume(solidcon3, //its solid
Aluminum, //its material
"con3" , //its name
0,0,0);
con3->SetVisAttributes(b3);
G4Cons *solidcon4= new G4Cons("solidcon4", 0.0*mm, 1.03*mm, 0.0*mm, 0.77*mm, 0.09*mm, 0.0*rad, 360.0*deg );
G4LogicalVolume * con4 = new G4LogicalVolume(solidcon4, //its solid
Aluminum, //its material
"con4" , //its name
0,0,0);
con4->SetVisAttributes(b4);
G4Cons *solidcon5= new G4Cons("solidcon5", 0.0*mm, 1.54*mm, 0.0*mm, 1.03*mm, 0.22*mm, 0.0*rad, 360.0*deg );
G4LogicalVolume * con5 = new G4LogicalVolume(solidcon5, //its solid
Aluminum, //its material
"con5" , //its name
0,0,0);
con5->SetVisAttributes(b5);
G4Cons *solidcon6= new G4Cons("solidcon6", 0.0*mm, 2.05*mm, 0.0*mm, 1.54*mm, 0.24*mm, 0.0*rad, 360.0*deg );
G4LogicalVolume * con6 = new G4LogicalVolume(solidcon6, //its solid
Aluminum, //its material
"con6" , //its name
0,0,0);
con6->SetVisAttributes(b6);
G4Cons *solidcon7= new G4Cons("solidcon7", 0.0*mm, 2.56*mm, 0.0*mm, 2.05*mm, 0.23*mm, 0.0*rad, 360.0*deg );
G4LogicalVolume * con7 = new G4LogicalVolume(solidcon7, //its solid
Aluminum, //its material
"con7" , //its name
0,0,0);
con7->SetVisAttributes(b7);
G4Cons *solidcon8= new G4Cons("solidcon8", 0.0*mm, 3.07*mm, 0.0*mm, 2.56*mm, 0.23*mm, 0.0*rad, 360.0*deg );
G4LogicalVolume * con8 = new G4LogicalVolume(solidcon8, //its solid
Aluminum, //its material
"con8" , //its name
0,0,0);
con8->SetVisAttributes(b8);
G4Cons *solidcon9= new G4Cons("solidcon9", 0.0*mm, 3.58*mm, 0.0*mm, 3.07*mm, 0.225*mm, 0.0*rad, 360.0*deg );
G4LogicalVolume * con9 = new G4LogicalVolume(solidcon9, //its solid
Aluminum, //its material
"con9" , //its name
0,0,0);
con9->SetVisAttributes(b9);
G4Cons *solidcon10= new G4Cons("solidcon10", 0.0*mm, 4.09*mm, 0.0*mm, 3.58*mm, 0.22*mm, 0.0*rad, 360.0*deg );
G4LogicalVolume * con10 = new G4LogicalVolume(solidcon10, //its solid
Aluminum, //its material
"con10" , //its name
0,0,0);
con10->SetVisAttributes(b10);
G4Cons *solidcon11= new G4Cons("solidcon11", 0.0*mm, 5.1*mm, 0.0*mm, 4.09*mm, 0.425*mm, 0.0*rad, 360.0*deg );
G4LogicalVolume * con11 = new G4LogicalVolume(solidcon11, //its solid
Aluminum, //its material
"con11" , //its name
0,0,0);
con11->SetVisAttributes(b11);
G4Cons *solidcon12= new G4Cons("solidcon12", 0.0*mm, 6.2*mm, 0.0*mm, 5.1*mm, 0.395*mm, 0.0*rad, 360.0*deg );
G4LogicalVolume * con12 = new G4LogicalVolume(solidcon12, //its solid
Aluminum, //its material
"con12" , //its name
0,0,0);
con12->SetVisAttributes(b12);
G4Cons *solidcon13= new G4Cons("solidcon13", 0.0*mm, 7.3*mm, 0.0*mm, 6.2*mm, 0.38*mm, 0.0*rad, 360.0*deg );
G4LogicalVolume * con13 = new G4LogicalVolume(solidcon13, //its solid
Aluminum, //its material
"con13" , //its name
0,0,0);
con13->SetVisAttributes(b13);
G4Cons *solidcon14= new G4Cons("solidcon14", 0.0*mm, 8.4*mm, 0.0*mm, 7.3*mm, 0.335*mm, 0.0*rad, 360.0*deg );
G4LogicalVolume * con14 = new G4LogicalVolume(solidcon14, //its solid
Aluminum, //its material
"con14" , //its name
0,0,0);
con14->SetVisAttributes(b14);
G4Cons *solidcon15= new G4Cons("solidcon15", 0.0*mm, 9.5*mm, 0.0*mm, 8.4*mm, 0.325*mm, 0.0*rad, 360.0*deg );
G4LogicalVolume * con15 = new G4LogicalVolume(solidcon15, //its solid
Aluminum, //its material
"con15" , //its name
0,0,0);
con15->SetVisAttributes(b15);
G4Cons *solidcon16= new G4Cons("solidcon16", 0.0*mm, 10.5*mm, 0.0*mm, 9.5*mm, 0.28*mm, 0.0*rad, 360.0*deg );
G4LogicalVolume * con16 = new G4LogicalVolume(solidcon16, //its solid
Aluminum, //its material
"con16" , //its name
0,0,0);
con16->SetVisAttributes(b16);
G4Cons *solidcon17= new G4Cons("solidcon17", 0.0*mm, 11.5*mm, 0.0*mm, 10.5*mm, 0.275*mm, 0.0*rad, 360.0*deg );
G4LogicalVolume * con17 = new G4LogicalVolume(solidcon17, //its solid
Aluminum, //its material
"con17" , //its name
0,0,0);
con17->SetVisAttributes(b17);
G4Cons *solidcon18= new G4Cons("solidcon18", 0.0*mm, 12.15*mm, 0.0*mm, 11.5*mm, 0.19*mm, 0.0*rad, 360.0*deg );
G4LogicalVolume * con18 = new G4LogicalVolume(solidcon18, //its solid
Aluminum, //its material
"con18" , //its name
0,0,0);
con18->SetVisAttributes(b18);
G4Cons *solidcons19= new G4Cons("solidcons19", 0.0*mm, 13.01*mm, 0.0*mm, 13.35*mm, 0.225*mm, 0.0*rad, 360.0*deg );
G4LogicalVolume * cons19 = new G4LogicalVolume(solidcons19, //its solid
Aluminum, //its material
"cons19" , //its name
0,0,0);
cons19->SetVisAttributes(b19);
G4Tubs *solidtub1= new G4Tubs("solidtub1", 0.0*mm, 13.35*mm, 0.4*mm, 0.0*rad, 360.0*deg );
G4LogicalVolume * tub1 = new G4LogicalVolume(solidtub1, //its solid
Aluminum, //its material
"tub1" , //its name
0,0,0);
tub1->SetVisAttributes(g1);
G4Tubs *solidtub2= new G4Tubs("solidtub2", 13.0*mm, 13.35*mm, 0.225*mm, 0.0*rad, 360.0*deg );
G4LogicalVolume * tub2 = new G4LogicalVolume(solidtub2, //its solid
Aluminum, //its material
"tub2" , //its name
0,0,0);
tub2->SetVisAttributes(g2);
G4Tubs *solidtub3= new G4Tubs("solidtub3", 13.35*mm, 16.0*mm, 0.625*mm, 0.0*rad, 360.0*deg );
G4LogicalVolume * tub3 = new G4LogicalVolume(solidtub3, //its solid
Aluminum, //its material
"tub3" , //its name
0,0,0);
tub3->SetVisAttributes(g3);
// Physical Volumes ---- Single Positioned Placement, Repeated Placement, Slicing ---------------------------
// Single Positioned Placement
G4RotationMatrix rotMatrixpworld; // unit rotation matrix
G4double anglepworld = 0.0*deg; // rotational angle
rotMatrixpworld.rotateX(anglepworld); // rot matrix
G4VPhysicalVolume * pworld= new G4PVPlacement(G4Transform3D(rotMatrixpworld, //rotation
G4ThreeVector(0.0*mm, 0.0*mm, 0.0*mm)),
"pworld", //its name (2nd constructor)
world, //its logical volume
NULL, //its mother volume
false, //no boolean operation
0); //copy number
G4RotationMatrix rotMatrixphantom; // unit rotation matrix
G4double anglephantom = 0.0*deg; // rotational angle
rotMatrixphantom.rotateX(anglephantom); // rot matrix
G4VPhysicalVolume * phantom= new G4PVPlacement(G4Transform3D(rotMatrixphantom, //rotation
G4ThreeVector(0.0*mm, 0.0*mm, 0.0*mm)),
"phantom", //its name (2nd constructor)
waterbox, //its logical volume
pworld, //its mother volume
false, //no boolean operation
0); //copy number
G4RotationMatrix rotMatrixpcon1; // unit rotation matrix
G4double anglepcon1 = 0.0*deg; // rotational angle
rotMatrixpcon1.rotateX(anglepcon1); // rot matrix
G4VPhysicalVolume * pcon1= new G4PVPlacement(G4Transform3D(rotMatrixpcon1, //rotation
G4ThreeVector(0.0*mm, 0.0*mm, 1034.04*mm)),
"pcon1", //its name (2nd constructor)
con1, //its logical volume
pworld, //its mother volume
false, //no boolean operation
0); //copy number
G4RotationMatrix rotMatrixpcon2; // unit rotation matrix
G4double anglepcon2 = 0.0*deg; // rotational angle
rotMatrixpcon2.rotateX(anglepcon2); // rot matrix
G4VPhysicalVolume * pcon2= new G4PVPlacement(G4Transform3D(rotMatrixpcon2, //rotation
G4ThreeVector(0.0*mm, 0.0*mm, 1033.888*mm)),
"pcon2", //its name (2nd constructor)
con2, //its logical volume
pworld, //its mother volume
false, //no boolean operation
0); //copy number
G4RotationMatrix rotMatrixpcon3; // unit rotation matrix
G4double anglepcon3 = 0.0*deg; // rotational angle
rotMatrixpcon3.rotateX(anglepcon3); // rot matrix
G4VPhysicalVolume * pcon3= new G4PVPlacement(G4Transform3D(rotMatrixpcon3, //rotation
G4ThreeVector(0.0*mm, 0.0*mm, 1033.748*mm)),
"pcon3", //its name (2nd constructor)
con3, //its logical volume
pworld, //its mother volume
false, //no boolean operation
0); //copy number
G4RotationMatrix rotMatrixpcon4; // unit rotation matrix
G4double anglepcon4 = 0.0*deg; // rotational angle
rotMatrixpcon4.rotateX(anglepcon4); // rot matrix
G4VPhysicalVolume * pcon4= new G4PVPlacement(G4Transform3D(rotMatrixpcon4, //rotation
G4ThreeVector(0.0*mm, 0.0*mm, 1033.583*mm)),
"pcon4", //its name (2nd constructor)
con4, //its logical volume
pworld, //its mother volume
false, //no boolean operation
0); //copy number
G4RotationMatrix rotMatrixpcon5; // unit rotation matrix
G4double anglepcon5 = 0.0*deg; // rotational angle
rotMatrixpcon5.rotateX(anglepcon5); // rot matrix
G4VPhysicalVolume * pcon5= new G4PVPlacement(G4Transform3D(rotMatrixpcon5, //rotation
G4ThreeVector(0.0*mm, 0.0*mm, 1033.273*mm)),
"pcon5", //its name (2nd constructor)
con5, //its logical volume
pworld, //its mother volume
false, //no boolean operation
0); //copy number
G4RotationMatrix rotMatrixpcon6; // unit rotation matrix
G4double anglepcon6 = 0.0*deg; // rotational angle
rotMatrixpcon6.rotateX(anglepcon6); // rot matrix
G4VPhysicalVolume * pcon6= new G4PVPlacement(G4Transform3D(rotMatrixpcon6, //rotation
G4ThreeVector(0.0*mm, 0.0*mm, 1032.813*mm)),
"pcon6", //its name (2nd constructor)
con6, //its logical volume
pworld, //its mother volume
false, //no boolean operation
0); //copy number
G4RotationMatrix rotMatrixpcon7; // unit rotation matrix
G4double anglepcon7 = 0.0*deg; // rotational angle
rotMatrixpcon7.rotateX(anglepcon7); // rot matrix
G4VPhysicalVolume * pcon7= new G4PVPlacement(G4Transform3D(rotMatrixpcon7, //rotation
G4ThreeVector(0.0*mm, 0.0*mm, 1032.343*mm)),
"pcon7", //its name (2nd constructor)
con7, //its logical volume
pworld, //its mother volume
false, //no boolean operation
0); //copy number
G4RotationMatrix rotMatrixpcon8; // unit rotation matrix
G4double anglepcon8 = 0.0*deg; // rotational angle
rotMatrixpcon8.rotateX(anglepcon8); // rot matrix
G4VPhysicalVolume * pcon8= new G4PVPlacement(G4Transform3D(rotMatrixpcon8, //rotation
G4ThreeVector(0.0*mm, 0.0*mm, 1031.883*mm)),
"pcon8", //its name (2nd constructor)
con8, //its logical volume
pworld, //its mother volume
false, //no boolean operation
0); //copy number
G4RotationMatrix rotMatrixpcon9; // unit rotation matrix
G4double anglepcon9 = 0.0*deg; // rotational angle
rotMatrixpcon9.rotateX(anglepcon9); // rot matrix
G4VPhysicalVolume * pcon9= new G4PVPlacement(G4Transform3D(rotMatrixpcon9, //rotation
G4ThreeVector(0.0*mm, 0.0*mm, 1031.428*mm)),
"pcon9", //its name (2nd constructor)
con9, //its logical volume
pworld, //its mother volume
false, //no boolean operation
0); //copy number
G4RotationMatrix rotMatrixpcon10; // unit rotation matrix
G4double anglepcon10 = 0.0*deg; // rotational angle
rotMatrixpcon10.rotateX(anglepcon10); // rot matrix
G4VPhysicalVolume * pcon10= new G4PVPlacement(G4Transform3D(rotMatrixpcon10, //rotation
G4ThreeVector(0.0*mm, 0.0*mm, 1030.983*mm)),
"pcon10", //its name (2nd constructor)
con10, //its logical volume
pworld, //its mother volume
false, //no boolean operation
0); //copy number
G4RotationMatrix rotMatrixpcon11; // unit rotation matrix
G4double anglepcon11 = 0.0*deg; // rotational angle
rotMatrixpcon11.rotateX(anglepcon11); // rot matrix
G4VPhysicalVolume * pcon11= new G4PVPlacement(G4Transform3D(rotMatrixpcon11, //rotation
G4ThreeVector(0.0*mm, 0.0*mm, 1030.338*mm)),
"pcon11", //its name (2nd constructor)
con11, //its logical volume
pworld, //its mother volume
false, //no boolean operation
0); //copy number
G4RotationMatrix rotMatrixpcon12; // unit rotation matrix
G4double anglepcon12 = 0.0*deg; // rotational angle
rotMatrixpcon12.rotateX(anglepcon12); // rot matrix
G4VPhysicalVolume * pcon12= new G4PVPlacement(G4Transform3D(rotMatrixpcon12, //rotation
G4ThreeVector(0.0*mm, 0.0*mm, 1029.518*mm)),
"pcon12", //its name (2nd constructor)
con12, //its logical volume
pworld, //its mother volume
false, //no boolean operation
0); //copy number
G4RotationMatrix rotMatrixpcon13; // unit rotation matrix
G4double anglepcon13 = 0.0*deg; // rotational angle
rotMatrixpcon13.rotateX(anglepcon13); // rot matrix
G4VPhysicalVolume * pcon13= new G4PVPlacement(G4Transform3D(rotMatrixpcon13, //rotation
G4ThreeVector(0.0*mm, 0.0*mm, 1028.743*mm)),
"pcon13", //its name (2nd constructor)
con13, //its logical volume
pworld, //its mother volume
false, //no boolean operation
0); //copy number
G4RotationMatrix rotMatrixpcon14; // unit rotation matrix
G4double anglepcon14 = 0.0*deg; // rotational angle
rotMatrixpcon14.rotateX(anglepcon14); // rot matrix
G4VPhysicalVolume * pcon14= new G4PVPlacement(G4Transform3D(rotMatrixpcon14, //rotation
G4ThreeVector(0.0*mm, 0.0*mm, 1028.028*mm)),
"pcon14", //its name (2nd constructor)
con14, //its logical volume
pworld, //its mother volume
false, //no boolean operation
0); //copy number
G4RotationMatrix rotMatrixpcon15; // unit rotation matrix
G4double anglepcon15 = 0.0*deg; // rotational angle
rotMatrixpcon15.rotateX(anglepcon15); // rot matrix
G4VPhysicalVolume * pcon15= new G4PVPlacement(G4Transform3D(rotMatrixpcon15, //rotation
G4ThreeVector(0.0*mm, 0.0*mm, 1027.368*mm)),
"pcon15", //its name (2nd constructor)
con15, //its logical volume
pworld, //its mother volume
false, //no boolean operation
0); //copy number
G4RotationMatrix rotMatrixpcon16; // unit rotation matrix
G4double anglepcon16 = 0.0*deg; // rotational angle
rotMatrixpcon16.rotateX(anglepcon16); // rot matrix
G4VPhysicalVolume * pcon16= new G4PVPlacement(G4Transform3D(rotMatrixpcon16, //rotation
G4ThreeVector(0.0*mm, 0.0*mm, 1026.763*mm)),
"pcon16", //its name (2nd constructor)
con16, //its logical volume
pworld, //its mother volume
false, //no boolean operation
0); //copy number
G4RotationMatrix rotMatrixpcon17; // unit rotation matrix
G4double anglepcon17 = 0.0*deg; // rotational angle
rotMatrixpcon17.rotateX(anglepcon17); // rot matrix
G4VPhysicalVolume * pcon17= new G4PVPlacement(G4Transform3D(rotMatrixpcon17, //rotation
G4ThreeVector(0.0*mm, 0.0*mm, 1025.6208*mm)),
"pcon17", //its name (2nd constructor)
con17, //its logical volume
pworld, //its mother volume
false, //no boolean operation
0); //copy number
G4RotationMatrix rotMatrixpcon18; // unit rotation matrix
G4double anglepcon18 = 0.0*deg; // rotational angle
rotMatrixpcon18.rotateX(anglepcon18); // rot matrix
G4VPhysicalVolume * pcon18= new G4PVPlacement(G4Transform3D(rotMatrixpcon18, //rotation
G4ThreeVector(0.0*mm, 0.0*mm, 1024.743*mm)),
"pcon18", //its name (2nd constructor)
con18, //its logical volume
pworld, //its mother volume
false, //no boolean operation
0); //copy number
G4RotationMatrix rotMatrixpcon19; // unit rotation matrix
G4double anglepcon19 = 0.0*deg; // rotational angle
rotMatrixpcon19.rotateX(anglepcon19); // rot matrix
G4VPhysicalVolume * pcon19= new G4PVPlacement(G4Transform3D(rotMatrixpcon19, //rotation
G4ThreeVector(0.0*mm, 0.0*mm, 1024.778*mm)),
"pcon19", //its name (2nd constructor)
cons19, //its logical volume
pworld, //its mother volume
false, //no boolean operation
0); //copy number
G4RotationMatrix rotMatrixptub1; // unit rotation matrix
G4double angleptub1 = 0.0*deg; // rotational angle
rotMatrixptub1.rotateX(angleptub1); // rot matrix
G4VPhysicalVolume * ptub1= new G4PVPlacement(G4Transform3D(rotMatrixptub1, //rotation
G4ThreeVector(0.0*mm, 0.0*mm, 1024.153*mm)),
"ptub1", //its name (2nd constructor)
tub1, //its logical volume
pworld, //its mother volume
false, //no boolean operation
0); //copy number
G4RotationMatrix rotMatrixptub2; // unit rotation matrix
G4double angleptub2 = 0.0*deg; // rotational angle
rotMatrixptub2.rotateX(angleptub2); // rot matrix
G4VPhysicalVolume * ptub2= new G4PVPlacement(G4Transform3D(rotMatrixptub2, //rotation
G4ThreeVector(0.0*mm, 0.0*mm, 1024.153*mm)),
"ptub2", //its name (2nd constructor)
tub2, //its logical volume
pworld, //its mother volume
false, //no boolean operation
0); //copy number
G4RotationMatrix rotMatrixptub3; // unit rotation matrix
G4double angleptub3 = 0.0*deg; // rotational angle
rotMatrixptub3.rotateX(angleptub3); // rot matrix
G4VPhysicalVolume * ptub3= new G4PVPlacement(G4Transform3D(rotMatrixptub3, //rotation
G4ThreeVector(0.0*mm, 0.0*mm, 1024.378*mm)),
"ptub3", //its name (2nd constructor)
tub3, //its logical volume
pworld, //its mother volume
false, //no boolean operation
0); //copy number
// Repeated Placement Translation
// Repeated Placement AxialSymmetoric
// Slicing Translation
// Slicing AxialSymmetric
// return the physical World
return pworld;
}
-49
View File
@@ -1,49 +0,0 @@
#
# Macro file for the initialization phase of "exampleN03.cc"
# when running in interactive mode
#
# Sets some default verbose
#
/control/verbose 2
/control/saveHistory
/run/verbose 2
#
# create empty scene
#
/vis/scene/create
#
# Create a scene handler for a specific graphics system
# (Edit the next line(s) to choose another graphic system)
#
# Use this open statement to get an .eps and .prim files
# suitable for viewing in DAWN.
/vis/open DAWNFILE
#
# Use this open statement instead for OpenGL in immediate mode.
/vis/open OGLIX
#
# Use this open statement instead to get a HepRep version 1 file
# suitable for viewing in WIRED.
#/vis/open HepRepFile
#
# Use this open statement instead to get a HepRep version 2 file
# suitable for viewing in WIRED.
#/vis/open HepRepXML
#
# Output an empty detector
/vis/viewer/flush
#
# for drawing the tracks
# (if too many tracks cause core dump => storeTrajectory 0)
#
/tracking/storeTrajectory 1
/vis/scene/endOfEventAction accumulate
#
# At end of each run, an automatic flush causes graphical output.
#/run/beamOn 1
# When you exit Geant4, you will find a file called scene-0.heprep.zip.
# Unzipping this will give you three separate HepRep files suitable for
# viewing in WIRED.
# The first file will contain just detector geometry.
# The second file will contain the detector plus one event.
# The third file will contain the detector plus ten events.
-28
View File
@@ -1,28 +0,0 @@
/control/verbose 2
/control/saveHistory
/run/verbose 2
/vis/scene/create
/vis/open VRML1FILE
/vis/drawVolume
/vis/scene/add/axes 0 0 0 2 m
/vis/viewer/update
/vis/viewer/set/viewpointThetaPhi 60 30 deg
/vis/viewer/zoom 5
/vis/viewer/flush
#
# draw scene/
#
#
# for drawing the tracks
/run/initialize
/tracking/storeTrajectory 1
/vis/scene/endOfEventAction accumulate
/vis/viewer/update
File diff suppressed because it is too large Load Diff
Binary file not shown.
+16 -17
View File
@@ -1,4 +1,4 @@
$Id: 00README,v 1.12 2009/11/20 03:36:51 kmura Exp $
$Id: 00README,v 1.13 2010/12/02 08:34:42 kmura Exp $
==========================================================================
Geant4Py
@@ -10,22 +10,20 @@ URL
---
http://www-geant4.kek.jp/projects/Geant4Py/
System Requirements:
-------------------
Python
- only 2.x is tested.
- Python2.x and Python 3.x (experimental)
Geant4
- 8.0 or later
- version 9.x
- should be built in "GLOBAL" and "SHARED" libraries.
- All header files should be collected into $(G4INSTALL)/include
by "make includes"
CLHEP
- 1.9.1.1 or later
- version 2.x
- should be built in shared library.
- Building shared objects is supported since version 1.9.
(Optional)
ROOT
@@ -60,15 +58,16 @@ Installation directories:
--libdir=DIR Python modules dir [PREFIX/lib]
Fine tuning of the library path:
--with-g4-incdir=DIR Geant4 header dir [$G4INCLUDE]
--with-g4-libdir=DIR Geant4 library dir [$G4LIB/$G4SYSTEM]
--with-clhep-incdir=DIR CLHEP header dir [$CLHEP_INCLUDE_DIR]
--with-clhep-libdir=DIR CLHEP library dir [$CLHEP_LIB_DIR]
--with-g4-incdir=DIR Geant4 header dir [$G4INSTALL/include]
--with-g4-libdir=DIR Geant4 library dir [$G4INSTALL/lib/$G4SYSTEM]
--with-clhep-incdir=DIR CLHEP header dir [$CLHEP_BASE_DIR/include]
--with-clhep-libdir=DIR CLHEP library dir [$CLHEP_BASE_DIR/lib]
--with-clhep-lib=LIB library name of libCLHEP.so [CLHEP|$CLHEP_LIB]
--with-python-incdir=DIR Python header dir [/usr/include/python(2.#)],
(location of pyconfig.h)
--with-python-libdir=DIR Python library dir [/usr/lib(64)]
--with-python3 Use Python3
--with-boost-incdir=DIR BOOST-C++ header dir [/usr/include],
(location of boost/)
@@ -149,18 +148,18 @@ Notes:
All users' libraries should be build in SHARED libaries.
2) Development Environment:
OS: SuSE Linux 11.1 (x86-64)
g++ : 4.3.2
OS: SuSE Linux 11.3 (x86-64)
g++ : 4.5.0
Python: 2.6
CLHEP: 2.0.4.4
ROOT: 5.20/00
CLHEP: 2.1.0.1
ROOT: 5.26/00
3) Tested environment:
Linux 32/64-bit
SuSE 11.2 11.1
SL4.5 SL5.4
SuSE 11.2 11.3 SLED11SP1
SL4.8 SL5.4
Ubuntu 8.0.4
MacOSX 10.5 (Leopard) 10.6 (Snow Leopard)
MacOSX 10.6 (Snow Leopard)
Have A Fun!!
+16 -1
View File
@@ -1,4 +1,4 @@
$Id: History,v 1.48 2009/11/27 07:56:30 kmura Exp $
$Id: History,v 1.53 2010/12/02 08:34:26 kmura Exp $
-------------------------------------------------------------------
=========================================================
@@ -13,6 +13,21 @@ Geant4Py is a Geant4-Python bridge.
----------------------------------------------------------
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
1 December 2010 K.Murakami
- update for chages of G4 classes (G4GDMLParser, physics list)
- add a new example using GTK (examples/emplot/emcalc_gui.py)
- experimentally support for Python3
21 June 2010 K.Murakami (tagged as envs-V09-03-01)
- updates for changes of G4 classes (G4RunManager, physics list)
- use G4xMultipleScattering for EMLowEpl site-pacakage module
4 June 2010 K.Murakami (tagged as envs-V09-03-00)
- update for the 9.4 beta release
- use G4xMultipleScattering instead if G4MultipleScattering class.
- bug fix in pyG4GDMLParser.cc
27 November 2009 K.Murakami
- config/g4py.gmk: add -lz as linker options
+4 -4
View File
@@ -1,5 +1,5 @@
# $Id: linux.gmk,v 1.9 2008/12/01 10:14:36 kmura Exp $
# $Name: geant4-09-02 $
# $Id: linux.gmk,v 1.10 2010/12/02 08:33:02 kmura Exp $
# $Name: geant4-09-04 $
# ===========================================================
# System specific terms
# ===========================================================
@@ -46,8 +46,8 @@ else
@$(CXX) -c -o $@ $(CXXFLAGS) $(CPPFLAGS) $*.cc
endif
%.pyc: %.py; python -c 'import py_compile; py_compile.compile( "$<" )'
%.pyo: %.py; python -O -c 'import py_compile; py_compile.compile( "$<" )'
%.pyc: %.py; $(Q_PYTHON) -c 'import py_compile; py_compile.compile( "$<" )'
%.pyo: %.py; $(Q_PYTHON) -O -c 'import py_compile; py_compile.compile( "$<" )'
# building a shared library
@@ -1,5 +1,5 @@
# $Id: linuxx8664gcc.gmk,v 1.9 2008/12/01 10:14:36 kmura Exp $
# $Name: geant4-09-02 $
# $Id: linuxx8664gcc.gmk,v 1.10 2010/12/02 08:33:02 kmura Exp $
# $Name: geant4-09-04 $
# ===========================================================
# System specific terms
# ===========================================================
@@ -46,8 +46,8 @@ else
@$(CXX) -c -o $@ $(CXXFLAGS) $(CPPFLAGS) $*.cc
endif
%.pyc: %.py; python -c 'import py_compile; py_compile.compile( "$<" )'
%.pyo: %.py; python -O -c 'import py_compile; py_compile.compile( "$<" )'
%.pyc: %.py; $(Q_PYTHON) -c 'import py_compile; py_compile.compile( "$<" )'
%.pyo: %.py; $(Q_PYTHON) -O -c 'import py_compile; py_compile.compile( "$<" )'
# building a shared library
+4 -4
View File
@@ -1,5 +1,5 @@
# $Id: macosx.gmk,v 1.5 2008/12/01 06:47:39 kmura Exp $
# $Name: geant4-09-02 $
# $Id: macosx.gmk,v 1.6 2010/12/02 08:33:02 kmura Exp $
# $Name: geant4-09-04 $
# ===========================================================
# System specific terms
#
@@ -48,8 +48,8 @@ else
@$(CXX) -c -o $@ $(CXXFLAGS) $(CPPFLAGS) $*.cc
endif
%.pyc: %.py; python -c 'import py_compile; py_compile.compile( "$<" )'
%.pyo: %.py; python -O -c 'import py_compile; py_compile.compile( "$<" )'
%.pyc: %.py; $(Q_PYTHON) -c 'import py_compile; py_compile.compile( "$<" )'
%.pyo: %.py; $(Q_PYTHON) -O -c 'import py_compile; py_compile.compile( "$<" )'
# building a shared library
+14 -2
View File
@@ -1,5 +1,5 @@
#! /bin/sh -
#$Id: configure,v 1.17 2009/11/20 03:36:51 kmura Exp $
#$Id: configure,v 1.18 2010/12/02 08:36:02 kmura Exp $
# ======================================================================
# A configure script for Geant4Py
# ======================================================================
@@ -52,6 +52,7 @@ Fine tuning of the library path:
--with-python-incdir=DIR Python header dir [/usr/include/python(2.#)],
(location of pyconfig.h)
--with-python-libdir=DIR Python library dir [/usr/lib(64)]
--with-python3 Use Python3
--with-boost-incdir=DIR BOOST-C++ header dir [/usr/include],
(location of boost/)
@@ -97,6 +98,8 @@ clhep_libdir=/zzz
clhep_lib=${CLHEP_LIB:-CLHEP}
python_incdir=/zzz
python_exe=python
with_python3=0
boost_incdir=/usr/include
boost_python_lib=boost_python
@@ -170,6 +173,9 @@ do
--with-extra-dir=*) extra_dir=$optarg ;;
--with-python-incdir=*) python_incdir=$optarg ;;
--with-python-libdir=*) python_libdir=$optarg ;;
--with-python3 ) python_exe=python3
with_python3=1
boost_python_lib=boost_python3 ;;
--with-boost-incdir=*) boost_incdir=$optarg ;;
--with-boost-libdir=*) boost_libdir=$optarg ;;
--with-boost-python-lib=*) boost_python_lib=$optarg ;;
@@ -324,7 +330,11 @@ echo "lib${clhep_lib}.${shlib}"
# ---
echo $ac_n "Checking for Python include dir (pyconfig.h) ... $ac_c"
# check version
set python python2.6 python2.5 python2.4 python2.3 python2.2
if [ $with_python3 = 0 ]; then
set python python2.7 python2.6 python2.5 python2.4 python2.3 python2.2
else
set python3.1 python3.0
fi
for aincdir in $*
do
if [ -d /usr/include/"$aincdir" ]; then
@@ -553,6 +563,8 @@ Q_CLHEP_LIB := $clhep_lib
Q_PYTHON_INCDIR := $python_incdir
Q_PYTHON_LIBDIR := $python_libdir
Q_PYTHON := $python_exe
Q_WITH_PYTHON3 := $with_python3
Q_BOOST_INCDIR := $boost_incdir
Q_BOOST_LIBDIR := $boost_libdir
Q_BOOST_PYTHON_LIB := $boost_python_lib
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: PhysListEmStandard.cc,v 1.1 2007/06/21 15:18:32 jjacquem Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: PhysListEmStandard.cc,v 1.2 2010/06/04 05:43:20 kmura Exp $
// GEANT4 tag $Name: geant4-09-04-beta-01 $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -38,7 +38,9 @@
#include "G4GammaConversion.hh"
#include "G4PhotoElectricEffect.hh"
#include "G4MultipleScattering.hh"
#include "G4eMultipleScattering.hh"
#include "G4MuMultipleScattering.hh"
#include "G4hMultipleScattering.hh"
#include "G4eIonisation.hh"
#include "G4eBremsstrahlung.hh"
@@ -82,13 +84,13 @@ void PhysListEmStandard::ConstructProcess()
} else if (particleName == "e-") {
//electron
pmanager->AddProcess(new G4MultipleScattering, -1, 1,1);
pmanager->AddProcess(new G4eMultipleScattering, -1, 1,1);
pmanager->AddProcess(new G4eIonisation, -1, 2,2);
pmanager->AddProcess(new G4eBremsstrahlung, -1, 3,3);
} else if (particleName == "e+") {
//positron
pmanager->AddProcess(new G4MultipleScattering, -1, 1,1);
pmanager->AddProcess(new G4eMultipleScattering, -1, 1,1);
pmanager->AddProcess(new G4eIonisation, -1, 2,2);
pmanager->AddProcess(new G4eBremsstrahlung, -1, 3,3);
pmanager->AddProcess(new G4eplusAnnihilation, 0,-1,4);
@@ -96,20 +98,20 @@ void PhysListEmStandard::ConstructProcess()
} else if( particleName == "mu+" ||
particleName == "mu-" ) {
//muon
pmanager->AddProcess(new G4MultipleScattering,-1, 1,1);
pmanager->AddProcess(new G4MuMultipleScattering,-1, 1,1);
pmanager->AddProcess(new G4MuIonisation, -1, 2,2);
pmanager->AddProcess(new G4MuBremsstrahlung, -1, 3,3);
pmanager->AddProcess(new G4MuPairProduction, -1, 4,4);
} else if( particleName == "alpha" || particleName == "GenericIon" ) {
pmanager->AddProcess(new G4MultipleScattering,-1, 1,1);
pmanager->AddProcess(new G4hMultipleScattering,-1, 1,1);
pmanager->AddProcess(new G4ionIonisation, -1, 2,2);
} else if ((!particle->IsShortLived()) &&
(particle->GetPDGCharge() != 0.0) &&
(particle->GetParticleName() != "chargedgeantino")) {
//all others charged particles except geantino
pmanager->AddProcess(new G4MultipleScattering,-1,1,1);
pmanager->AddProcess(new G4hMultipleScattering,-1,1,1);
pmanager->AddProcess(new G4hIonisation, -1,2,2);
}
}
+191
View File
@@ -0,0 +1,191 @@
#!/usr/bin/python3
# ==================================================================
# python script for TestEm0 python version
#
# ==================================================================
import Geant4 as g4
import TestEm0
# ==================================================================
# user actions in python
# ==================================================================
# ==================================================================
# main
# ==================================================================
myDC= TestEm0.DetectorConstruction()
g4.gRunManager.SetUserInitialization(myDC)
myPL= TestEm0.PhysicsList()
g4.gRunManager.SetUserInitialization(myPL)
# set user actions...
myPGA= TestEm0.PrimaryGeneratorAction(myDC)
g4.gRunManager.SetUserAction(myPGA)
myRA= TestEm0.RunAction(myDC,myPGA)
# set user action classes
g4.gRunManager.SetUserAction(myRA)
g4.gRunManager.Initialize()
pg = g4.G4ParticleGun()
materialList = TestEm0.getMaterialTable();
particleList = TestEm0.getParticleTable()
enrgyList = ["eV","keV","MeV","GeV","TeV","PeV"]
cutsList = ["um", "mm" , "cm", "m", "km"]
# GUI
from tkinter import *
class App(Frame):
def init(self):
# title and header
title = Label(self, text="TestEm0 empowered by Geant4Py\n\n\n")
title.grid(row=0, column=1, columnspan = 4)
# particle list box
particle_title = Label(self, text="Particle")
particle_title.grid(row=2, column=0)
particleFrame = Frame(self)
scrollbar2 = Scrollbar(particleFrame)
scrollbar2.pack(side = RIGHT, fill = Y)
self.particleListBox = Listbox(particleFrame, yscrollcommand=scrollbar2.set, exportselection=FALSE,height = 6)
self.particleListBox.pack(side = LEFT)
for item in particleList:
self.particleListBox.insert(END, item)
scrollbar2.config(command=self.particleListBox.yview)
particleFrame.grid(row=3, column=0)
self.particleListBox.select_set(0)
# separator frame
fblank = Frame(self,width = 40)
fblank.grid(row=3,column=1)
# material list box
detmaterial_title = Label(self, text="Material")
detmaterial_title.grid(row=2, column=2)
materialFrame = Frame(self)
scrollbar = Scrollbar(materialFrame)
scrollbar.pack(side = RIGHT, fill = Y)
self.materialListBox = Listbox(materialFrame, yscrollcommand=scrollbar.set, exportselection=FALSE, height = 6)
self.materialListBox.pack(side = LEFT, fill = Y)
for item in materialList:
self.materialListBox.insert(END, item)
scrollbar.config(command=self.materialListBox.yview)
materialFrame.grid(row=3, column=2)
self.materialListBox.select_set(0)
# separator frame
fblank = Frame(self,width = 40)
fblank.grid(row=3,column=3)
# energy
fEnergy = Frame(self)
energyLabel = Label(self, text="Energy")
energyLabel.grid(row = 2, column = 4)
scrollbarEnergy = Scrollbar(fEnergy)
scrollbarEnergy.pack(side = RIGHT, fill = Y)
self.energyEntry = Entry(fEnergy, width= 8 );
self.energyEntry.pack(side = TOP)
self.energyEntry.insert(0, "1.0")
self.energyListBox = Listbox(fEnergy, yscrollcommand=scrollbarEnergy.set,exportselection=FALSE,width=8,height = 5)
self.energyListBox.pack(side = BOTTOM )
for item in enrgyList:
self.energyListBox.insert(END, item)
scrollbarEnergy.config(command=self.energyListBox.yview)
fEnergy.grid(row = 3, column = 4 )
self.energyListBox.select_set(0)
# separator frame
fblank = Frame(self,width = 40)
fblank.grid(row=3,column=5)
# cuts
fCuts = Frame(self)
cutsLabel = Label(self, text="Cuts", width= 8)
cutsLabel.grid(row = 2, column = 6)
scrollbarCuts = Scrollbar(fCuts)
scrollbarCuts.pack(side = RIGHT, fill = Y)
self.cutsEntry = Entry(fCuts, width= 8);
self.cutsEntry.pack(side = TOP)
self.cutsEntry.insert(0, "1.0")
self.cutsListBox = Listbox(fCuts, width= 8 ,yscrollcommand=scrollbarCuts.set,exportselection=FALSE,height = 5)
self.cutsListBox.pack(side = BOTTOM )
for item in cutsList:
self.cutsListBox.insert(END, item)
scrollbarCuts.config(command=self.cutsListBox.yview)
fCuts.grid(row = 3, column = 6 )
self.cutsListBox.select_set(0)
# separator frame
fblank = Frame(self,height = 40)
fblank.grid(row=4,column=0)
# start a run button
startBut = Button(self, bg="green", text="Start a run", command=self.cmd_beamOn)
startBut.grid(row=5, column=2, sticky=W)
# exit button
exitBut = Button(self, bg="grey", text="Exit", command=self.quit)
exitBut.grid(row=5, column=6, sticky=E)
def __init__(self, master=None):
Frame.__init__(self, master)
self.init()
self.grid()
def cmd_beamOn(self):
# get and set particle
if self.particleListBox.curselection():
index =int(self.particleListBox.curselection()[0])
g4.gApplyUICommand("/gun/particle " + particleList[index])
# get and set detector Material
if self.materialListBox.curselection():
index =int(self.materialListBox.curselection()[0])
g4.gApplyUICommand("/testem/det/setMat " + materialList[index])
# get and set energy
energy = self.energyEntry.get()
if self.energyListBox.curselection():
index = int(self.energyListBox.curselection()[0])
unity = enrgyList[index]
g4.gApplyUICommand("/gun/energy " + energy + " " + unity)
# get and set cuts
cuts = self.cutsEntry.get()
if self.cutsListBox.curselection():
index = int(self.cutsListBox.curselection()[0])
unity = cutsList[index]
g4.gApplyUICommand("/testem/phys/setCuts " + cuts + " " + unity)
# run beamOn
g4.gRunManager.BeamOn(1)
app = App()
app.mainloop()
@@ -23,8 +23,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: PhysicsListEMstd.cc,v 1.3 2006/06/29 15:28:29 gunter Exp $
// $Name: geant4-09-02 $
// $Id: PhysicsListEMstd.cc,v 1.4 2010/06/04 05:43:47 kmura Exp $
// $Name: geant4-09-04-beta-01 $
// ====================================================================
// PhysicsListEMstd.cc
//
@@ -46,10 +46,10 @@
#include "G4ComptonScattering.hh"
#include "G4GammaConversion.hh"
#include "G4PhotoElectricEffect.hh"
#include "G4MultipleScattering.hh"
#include "G4eIonisation.hh"
#include "G4eBremsstrahlung.hh"
#include "G4eplusAnnihilation.hh"
#include "G4eMultipleScattering.hh"
// ====================================================================
//
@@ -96,7 +96,7 @@ void PhysicsListEMstd::ConstructProcess()
// ----------------------------------------------------------
// electron physics
// ----------------------------------------------------------
G4MultipleScattering* msc= new G4MultipleScattering;
G4eMultipleScattering* msc= new G4eMultipleScattering;
G4eIonisation* eion= new G4eIonisation;
G4eBremsstrahlung* ebrems= new G4eBremsstrahlung;
@@ -108,7 +108,7 @@ void PhysicsListEMstd::ConstructProcess()
// ----------------------------------------------------------
// positron physics
// ----------------------------------------------------------
msc= new G4MultipleScattering;
msc= new G4eMultipleScattering;
eion= new G4eIonisation;
ebrems= new G4eBremsstrahlung;
G4eplusAnnihilation* annihilation= new G4eplusAnnihilation;
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: PhysicsListLHad.cc,v 1.3 2006/06/29 15:28:35 gunter Exp $
// $Id: PhysicsListLHad.cc,v 1.4 2010/06/04 05:43:47 kmura Exp $
// ====================================================================
// PhysicsListLHad.cc
//
@@ -33,7 +33,7 @@
#include "G4ProcessManager.hh"
#include "G4ParticleDefinition.hh"
#include "G4MultipleScattering.hh"
#include "G4hMultipleScattering.hh"
#include "G4hIonisation.hh"
// Hadronic Processes
@@ -152,7 +152,7 @@ void PhysicsListLHad::ConstructProcess()
pManager-> AddDiscreteProcess(theProtonInelasticProcess);
// QED
G4VProcess* thepMultipleScattering = new G4MultipleScattering();
G4VProcess* thepMultipleScattering = new G4hMultipleScattering();
G4VProcess* thepIonisation = new G4hIonisation();
pManager-> AddProcess(thepIonisation);
@@ -193,7 +193,7 @@ void PhysicsListLHad::ConstructProcess()
pManager-> AddRestProcess(theAntiProtonAnnihilation);
// QED
G4VProcess* theapMultipleScattering = new G4MultipleScattering();
G4VProcess* theapMultipleScattering = new G4hMultipleScattering();
G4VProcess* theapIonisation = new G4hIonisation();
pManager-> AddProcess(theapIonisation);
@@ -232,7 +232,7 @@ void PhysicsListLHad::ConstructProcess()
pManager-> AddDiscreteProcess(thePionPlusInelasticProcess);
// QED
G4VProcess* theppMultipleScattering = new G4MultipleScattering();
G4VProcess* theppMultipleScattering = new G4hMultipleScattering();
G4VProcess* theppIonisation = new G4hIonisation();
pManager-> AddProcess(theppIonisation);
@@ -266,7 +266,7 @@ void PhysicsListLHad::ConstructProcess()
pManager-> AddDiscreteProcess(thePionMinusInelasticProcess);
// QED
G4VProcess* thepmMultipleScattering = new G4MultipleScattering();
G4VProcess* thepmMultipleScattering = new G4hMultipleScattering();
G4VProcess* thepmIonisation = new G4hIonisation();
pManager-> AddProcess(thepmIonisation);
@@ -300,7 +300,7 @@ void PhysicsListLHad::ConstructProcess()
pManager-> AddDiscreteProcess(theKaonPlusInelasticProcess);
// QED
G4VProcess* thekpMultipleScattering = new G4MultipleScattering();
G4VProcess* thekpMultipleScattering = new G4hMultipleScattering();
G4VProcess* thekpIonisation = new G4hIonisation();
pManager-> AddProcess(thekpIonisation);
@@ -334,7 +334,7 @@ void PhysicsListLHad::ConstructProcess()
pManager->AddDiscreteProcess(theKaonMinusInelasticProcess);
// QED
G4VProcess* thekmMultipleScattering = new G4MultipleScattering();
G4VProcess* thekmMultipleScattering = new G4hMultipleScattering();
G4VProcess* thekmIonisation = new G4hIonisation();
pManager-> AddProcess(thekmIonisation);
@@ -0,0 +1,294 @@
#!/usr/bin/python3
# ==================================================================
# python script for "measurement" of mass attenuation coefficient
#
#
# - using site-module packages
# ==================================================================
from Geant4 import *
import g4py.NISTmaterials
import g4py.ezgeom
from g4py.ezgeom import G4EzVolume
import g4py.EMSTDpl
import g4py.ParticleGun
from time import *
import sys
# ==================================================================
# intialize
# ==================================================================
def Configure():
# ------------------------------------------------------------------
# setup for materials
# ------------------------------------------------------------------
# simple materials for Qgeom
g4py.NISTmaterials.Construct()
# ------------------------------------------------------------------
# setup for geometry
# ------------------------------------------------------------------
#g4py.Qgeom.Construct()
g4py.ezgeom.Construct() # initialize
# ------------------------------------------------------------------
# setup for physics list
# ------------------------------------------------------------------
g4py.EMSTDpl.Construct()
# ------------------------------------------------------------------
# setup for primary generator action
# ------------------------------------------------------------------
g4py.ParticleGun.Construct()
gControlExecute("gun.mac")
# ==================================================================
# constructing geometry
# ==================================================================
def ConstructGeom():
print("* Constructing geometry...")
# reset world material
global absorber
air= G4Material.GetMaterial("G4_AIR", 1)
galactic = G4Material.GetMaterial("G4_Galactic", 1)
absorber = {} # material's dictionary to be used by a radiobutton
aluminum = G4Material.GetMaterial("G4_Al", 1)
iron = G4Material.GetMaterial("G4_Fe", 1)
silver = G4Material.GetMaterial("G4_Ag", 1)
gold = G4Material.GetMaterial("G4_Au", 1)
lead = G4Material.GetMaterial("G4_Pb", 1)
water = G4Material.GetMaterial("G4_WATER", 1)
absorber = {"air":air, "aluminum":aluminum, "iron":iron, "lead":lead, "water":water, "gold":gold}
g4py.ezgeom.SetWorldMaterial(galactic)
g4py.ezgeom.ResizeWorld(120.*cm, 120.*cm, 100.*cm)
# water phantom
global water_phantom, water_phantom_pv
water_phantom= G4EzVolume("WaterPhantom")
water_phantom.CreateBoxVolume(water, 110.*cm, 110.*cm, 10.*cm)
water_phantom_pv = water_phantom.PlaceIt(G4ThreeVector(0.,0.,0.*cm))
# ==================================================================
# main
# ==================================================================
# ------------------------------------------------------------------
# randum number
# ------------------------------------------------------------------
print("Random numbers...")
rand_engine= Ranlux64Engine()
HepRandom.setTheEngine(rand_engine)
HepRandom.setTheSeed(20050830)
# setup...
Configure()
ConstructGeom()
# ------------------------------------------------------------------
# go...
# ------------------------------------------------------------------
gRunManager.Initialize()
# visualization not here but after "Start a run" button
gControlExecute("oglx.mac")
#gControlExecute("vrml.mac")
# creating widgets using grid layout
from tkinter import *
class App(Frame):
def init(self):
#title and header row=0, 1
title = Label(self, text="Geant4Py for Education @ H. Yoshida Naruto Univ. of Education")
title.grid(row=0, column=1, columnspan=5)
header = Label(self, text="Measurement of Mass Attenuation Coefficient")
header.grid(row=1, column=1, columnspan=5)
#material selection row=2
materialLabel = Label(self, bg="green", text="Material")
materialLabel.grid(row=2, column=0, sticky=W)
self.materialVar = StringVar()
self.materialVar.set("water")
ra1 = { }
pos=1
for i in absorber.keys():
ra1[i] = Radiobutton(self, text=i, variable=self.materialVar, value=i)
ra1[i].grid(row=2, column=pos, sticky=W)
pos=pos+1
#absorber thickness row=3
thickLabel = Label(self, bg="green", text="Thickness (mm)")
self.thickVar = DoubleVar()
self.thickVar.set(100.0)
thick = Scale(self, orient=HORIZONTAL, length=400, from_=0., to=100., resolution=0.05, tickinterval=10.0, digits=4, variable=self.thickVar)
thickLabel.grid(row=3, column=0, sticky=W)
thick.grid(row=3, column=1, columnspan=5, sticky=W)
#get logical volume and set its half length
self.solid = g4py.ezgeom.G4EzVolume.GetSold(water_phantom)
#particle row=4
particleLabel = Label(self, bg="green", text="Particle")
particleLabel.grid(row=4, column=0, sticky=W)
self.particleVar = StringVar()
self.particleVar.set("gamma")
ra1 = { }
pos1=1
for i in ("gamma", "e-"):
ra1[i] = Radiobutton(self, text=i, variable=self.particleVar, value=i)
ra1[i].grid(row=4, column=pos1, sticky=W)
pos1=pos1+1
#energy row=5
energyLabel = Label(self, bg="green", text="Energy (MeV)")
self.energyVar=StringVar()
self.energyVar.set(1)
energy = Scale(self, orient=HORIZONTAL, length=400, from_=0., to=100., tickinterval=10.0, resolution=0.1, variable=self.energyVar, digits=4 )
energyLabel.grid(row=5, column=0, sticky=W)
energy.grid(row=5, column=1, columnspan=5, sticky=W)
#number of event row=6
eventLabel = Label(self, bg="green", text="Events")
self.eventVar=IntVar()
event = Scale(self, orient=HORIZONTAL, length=400, from_=1, to=100, tickinterval=10, resolution=1, variable=self.eventVar )
eventLabel.grid(row=6, column=0, sticky=W)
event.grid(row=6, column=1, columnspan=5, sticky=W)
#start a run button row=7
startBut = Button(self, bg="orange", text="Start a run", command=self.cmd_beamOn)
startBut.grid(row=0, column=0, sticky=W)
#Zoom in/out Pan X Y row=8
visLabel = Label(self, text="viewer", bg="orange")
expandBut = Button(self, text="Zoom in", command=self.cmd_expand)
shrinkBut = Button(self, text="Zoom out", command=self.cmd_shrink)
visLabel.grid(row=8, column=0, sticky=W)
expandBut.grid(row=8, column=1, sticky=W)
shrinkBut.grid(row=8, column=2, sticky=W)
upBut = Button(self, text="Up", command=self.cmd_up)
downBut = Button(self, text="Down", command=self.cmd_down)
upBut.grid(row=8, column=3, sticky=W)
downBut.grid(row=8, column=4, sticky=W)
leftBut = Button(self, text="Left", command=self.cmd_left)
rightBut = Button(self, text="Right", command=self.cmd_right)
leftBut.grid(row=8, column=5, sticky=W)
rightBut.grid(row=8, column=6, sticky=W)
# later
# resetBut = Button(self, text="Reset", command=self.cmd_reset)
# resetBut.grid(row=8, column=7, sticky=W)
# panLabel = Label(self, text="Pan X Y (mm)")
# self.panXYVar = StringVar()
# panXYEnt = Entry(self, textvariable=self.panXYVar)
# panBut = Button(self, bg="orange", text="OK", command=self.cmd_pan)
# panLabel.grid(row=8, column=3, sticky=W)
# panXYEnt.grid(row=8, column=4)
# panBut.grid(row=8, column=5)
#Geant4 command entry row = 9
# g4comLabel = Label(self, text="Geant4 command")
# self.g4commandVar = StringVar()
# commandEntry = Entry(self, textvariable=self.g4commandVar)
# comBut = Button(self, bg="orange", text="Execute", command=self.cmd_g4command)
# g4comLabel.grid(row=9, column=0, sticky=W)
# commandEntry.grid(row=9, column=1, columnspan=4, sticky=E+W)
# comBut.grid(row=9, column=5)
#exit row = 10
exitBut = Button(self, bg="red", text="End all", command=sys.exit)
exitBut.grid(row=0, column=6, sticky=W)
#on Run butto do...
def cmd_beamOn(self):
materialChosen = self.materialVar.get()
water_phantom.SetMaterial(absorber[materialChosen])
if materialChosen == "water":
water_phantom.SetColor(0., 0.9, 1.0)
if materialChosen == "air":
water_phantom.SetColor(0.9, 0.9, 1.0)
if materialChosen == "lead":
water_phantom.SetColor(0.2, 0.2, 0.2)
if materialChosen == "iron":
water_phantom.SetColor(0.7, 0.5, 0.7)
if materialChosen == "aluminum":
water_phantom.SetColor(.7, 0.9, 1.0)
if materialChosen == "gold":
water_phantom.SetColor(1., 0.9, .0)
self.solid.SetZHalfLength(self.thickVar.get() * mm/2.0)
# gControlExecute("oglx.mac") #draw for each run
gApplyUICommand("/vis/viewer/flush")
self.cmd_particle(self.particleVar.get())
self.cmd_energy(self.energyVar.get())
# TODO later to reflesh text
gApplyUICommand("/vis/scene/add/text 0 610 610 mm 20 0 0 " + " ")
gApplyUICommand("/vis/scene/add/text 0 610 610 mm 20 0 0 " + self.materialVar.get() + " = " + str(self.thickVar.get()) + "mm " + self.particleVar.get() + " = "+self.energyVar.get() + "MeV")
eventNum = self.eventVar.get()
for i in range(eventNum):
gunYZpos = str(i-eventNum/2) + ". -20. cm"
gApplyUICommand("/gun/position 0. " + gunYZpos)
gRunManager.BeamOn(1)
sleep(0.01)
# self.cmd_expand() #Zoom in to the last diaplayed OGLSX
# self.cmd_shrink()
def cmd_g4command(self):
gApplyUICommand(self.g4commandVar.get())
def cmd_particle(self, particle):
gApplyUICommand("/gun/particle " + particle)
def cmd_energy(self, penergy):
gApplyUICommand("/gun/energy " + penergy + " MeV")
def cmd_expand(self):
gApplyUICommand("/vis/viewer/zoom 1.2")
def cmd_up(self):
gApplyUICommand("/vis/viewer/pan " + " 0. 10. mm")
def cmd_down(self):
gApplyUICommand("/vis/viewer/pan " + " 0. -10. mm")
def cmd_right(self):
gApplyUICommand("/vis/viewer/pan " + " -1. 0. mm")
def cmd_left(self):
gApplyUICommand("/vis/viewer/pan " + " 1. 0. mm")
def cmd_shrink(self):
gApplyUICommand("/vis/viewer/zoom 0.8")
# def cmd_reset(self):
# gApplyUICommand("/vis/viewer/pan " + " 0. 0. mm")
def __init__(self, master=None):
Frame.__init__(self, master)
self.init()
self.grid()
app = App()
app.mainloop()
@@ -0,0 +1,426 @@
#!/usr/bin/python3
# ==================================================================
# python script for Geant4Py
#
# ExN03 : geant4/examples/novice/N03
# using site-module packages
# ==================================================================
from Geant4 import *
import g4py.Qmaterials, g4py.NISTmaterials
import g4py.ExN03geom
import g4py.ExN03pl
import g4py.ParticleGun, g4py.MedicalBeam
import sys
from time import *
from subprocess import *
import os
# ==================================================================
# main
# ==================================================================
# ------------------------------------------------------------------
# randum number
# ------------------------------------------------------------------
rand_engine= Ranlux64Engine()
HepRandom.setTheEngine(rand_engine)
HepRandom.setTheSeed(20050830)
# ------------------------------------------------------------------
# setup for materials
# ------------------------------------------------------------------
# NIST materials
#g4py.NISTmaterials.Construct()
# ------------------------------------------------------------------
# setup for geometry
# ------------------------------------------------------------------
# normal way for constructing user geometry
exN03geom= g4py.ExN03geom.ExN03DetectorConstruction()
gRunManager.SetUserInitialization(exN03geom)
# 2nd way, short-cut way
#g4py.ExN01geom.Construct()
#g4py.ExN03geom.Construct()
# magnetic field
#exN03geom.SetMagField(0.1 * tesla)
# ------------------------------------------------------------------
# setup for physics list
# ------------------------------------------------------------------
# normal way for constructing user physics list
exN03PL= g4py.ExN03pl.ExN03PhysicsList()
gRunManager.SetUserInitialization(exN03PL)
# 2nd way, short-cut way
#g4py.ExN01pl.Construct()
#g4py.EMSTDpl.Construct()
# ------------------------------------------------------------------
# setup for primary generator action
# ------------------------------------------------------------------
# normal way for constructing user physics list
#pgPGA= g4py.ParticleGun.ParticleGunAction()
#gRunManager.SetUserAction(pgPGA)
#pg= pgPGA.GetParticleGun()
# 2nd way, short-cut way
pg= g4py.ParticleGun.Construct()
# set parameters of particle gun
pg.SetParticleByName("e-")
pg.SetParticleEnergy(50.*MeV)
pg.SetParticlePosition(G4ThreeVector(-40.,0.,0.)*cm)
pg.SetParticleMomentumDirection(G4ThreeVector(1.,0.,0.))
# medical beam
#beam= MedicalBeam.Construct()
# ------------------------------------------------------------------
# go...
# ------------------------------------------------------------------
gRunManager.Initialize()
# beamOn
#gRunManager.BeamOn(3)
#TEST
#gProcessTable.SetProcessActivation("msc", 0)
#gProcessTable.SetProcessActivation("conv", 0)
#gProcessTable.SetProcessActivation("eBrem", 0)
#gProcessTable.SetProcessActivation("eIoni", 0)
#gProcessTable.SetProcessActivation("annihil", 0)
# visualization
# OGLSX, VRML and HEPREP sceneHandlers are all created with names
gApplyUICommand("/vis/sceneHandler/create OGLSX OGLSX")
gApplyUICommand("/vis/sceneHandler/create VRML2FILE VRML")
gApplyUICommand("/vis/sceneHandler/create HepRepFile HEPREP")
# OGLSX is the default so, viewer is created and volume is drawn
gApplyUICommand("/vis/viewer/create OGLSX oglsxviewer")
gApplyUICommand("/vis/drawVolume")
gApplyUICommand("/vis/scene/add/trajectories")
gApplyUICommand("/tracking/storeTrajectory 1")
gApplyUICommand("/vis/scene/endOfEventAction accumulate")
gApplyUICommand("/vis/scene/endOfRunAction accumulate")
gApplyUICommand("/vis/viewer/select oglsxviewer")
# viewers VRML and Wired are tested by their envs vars
# if their envs var are set, then viewers are created and drawVolume
global heprepViewer, heprepDir, heprepName
heprepViewer = os.environ.get("G4HEPREPFILE_VIEWER")
heprepDir = os.environ.get("G4HEPREPFILE_DIR")
heprepName = os.environ.get("G4HEPREPFILE_NAME")
if heprepViewer is not None:
gApplyUICommand("/vis/viewer/create HEPREP wired")
gApplyUICommand("/vis/drawVolume")
# VRML viewers name is user defined
vrmlDir = os.environ.get("G4VRML_DEST_DIR")
vrmlViewer = os.environ.get("G4VRMLFILE_VIEWER")
if vrmlViewer is not None:
gApplyUICommand("/vis/viewer/create VRML vrmlviewer")
gApplyUICommand("/vis/drawVolume")
# creating widgets using grid layout
from tkinter import *
class App(Frame):
g4pipe = 0
def init(self):
#title and header row=0, 1
title = Label(self, text="exampleN03")
title.grid(row=0, column=1, columnspan=3)
header = Label(self, text="empowered by \n Geant4Py")
header.grid(row=1, column=1, columnspan=3)
# number of layers
layerLabel = Label(self, bg="green", text="No of layers")
self.layerVar=IntVar()
self.layerVar.set(10)
layer = Scale(self, orient=HORIZONTAL, length=400, from_=0, to=10, tickinterval=1, resolution=1, variable=self.layerVar )
layerLabel.grid(row=2, column=0, sticky=W)
layer.grid(row=2, column=1, columnspan=5, sticky=W)
#absorber material selection row=3
absorbermaterialLabel = Label(self, bg="green", text="Absorber Material")
absorbermaterialLabel.grid(row=3, column=0, sticky=W)
self.absorbermaterialVar = StringVar()
self.absorbermaterialVar.set("Lead")
ra1 = { }
pos=1
for i in ("Aluminium", "Lead"):
ra1[i] = Radiobutton(self, text=i, variable=self.absorbermaterialVar, value=i)
ra1[i].grid(row=3, column=pos, sticky=W)
pos=pos+1
#absorber thickness row=4
absorberthickLabel = Label(self, bg="green", text="Thickness (mm)")
self.absorberthickVar = DoubleVar()
self.absorberthickVar.set(10.0)
absorberthick = Scale(self, orient=HORIZONTAL, length=400, from_=0., to=100., resolution=0.05, tickinterval=10.0, digits=4, variable=self.absorberthickVar)
absorberthickLabel.grid(row=4, column=0, sticky=W)
absorberthick.grid(row=4, column=1, columnspan=5, sticky=W)
#gap material selection row=5
gapmaterialLabel = Label(self, bg="green", text="Gap Material")
gapmaterialLabel.grid(row=5, column=0, sticky=W)
self.gapmaterialVar = StringVar()
self.gapmaterialVar.set("liquidArgon")
ra2 = { }
pos=1
for i in ("liquidArgon","Scintillator", "Air", "Aerogel", "Galactic" ):
ra2[i] = Radiobutton(self, text=i, variable=self.gapmaterialVar, value=i)
ra2[i].grid(row=5, column=pos, sticky=W)
pos=pos+1
#gap thickness row=6
gapthickLabel = Label(self, bg="green", text="Thickness (mm)")
self.gapthickVar = DoubleVar()
self.gapthickVar.set(5.0)
gapthick = Scale(self, orient=HORIZONTAL, length=400, from_=0., to=100., resolution=0.05, tickinterval=10.0, digits=4, variable=self.gapthickVar)
gapthickLabel.grid(row=6, column=0, sticky=W)
gapthick.grid(row=6, column=1, columnspan=5, sticky=W)
#calorSizeYZ row=7
calorsizeYZLabel = Label(self, bg="green", text="SizeYZ (mm)")
self.calorsizeYZVar = DoubleVar()
self.calorsizeYZVar.set(100.0)
calorsizeYZ = Scale(self, orient=HORIZONTAL, length=400, from_=0., to=200., resolution=0.05, tickinterval=20.0, digits=4, variable=self.calorsizeYZVar)
calorsizeYZLabel.grid(row=7, column=0, sticky=W)
calorsizeYZ.grid(row=7, column=1, columnspan=5, sticky=W)
#particle row=8
particleLabel = Label(self, bg="green", text="Particle")
particleLabel.grid(row=8, column=0, sticky=W)
self.particleVar = StringVar()
self.particleVar.set("e-")
ra1 = { }
pos1=1
for i in ("proton", "gamma", "e-", "e+", "mu-", "mu+"):
ra1[i] = Radiobutton(self, text=i, variable=self.particleVar, value=i)
ra1[i].grid(row=8, column=pos1, sticky=W)
pos1=pos1+1
#energy row=9
energyLabel = Label(self, bg="green", text="Energy (MeV)")
self.energyVar=StringVar()
self.energyVar.set(50)
energy = Scale(self, orient=HORIZONTAL, length=400, from_=0., to=1000., tickinterval=100.0, resolution=0.1, variable=self.energyVar, digits=5 )
energyLabel.grid(row=9, column=0, sticky=W)
energy.grid(row=9, column=1, columnspan=5, sticky=W)
#number of event row=10
eventLabel = Label(self, bg="green", text="Events")
self.eventVar=IntVar()
self.eventVar.set(3)
event = Scale(self, orient=HORIZONTAL, length=400, from_=0, to=100, tickinterval=10, resolution=1, variable=self.eventVar )
eventLabel.grid(row=10, column=0, sticky=W)
event.grid(row=10, column=1, columnspan=5, sticky=W)
#start a run button row=0
startBut = Button(self, bg="orange", text="Start a run", command=self.cmd_beamOn)
startBut.grid(row=0, column=0, sticky=W)
#Zoom in/out Pan X Y row=13
# visLabel = Label(self, text="viewer", bg="orange")
# expandBut = Button(self, text="Zoom in", command=self.cmd_expand)
# shrinkBut = Button(self, text="Zoom out", command=self.cmd_shrink)
# visLabel.grid(row=13, column=0, sticky=W)
# expandBut.grid(row=13, column=1, sticky=W)
# shrinkBut.grid(row=13, column=2, sticky=W)
# panLabel = Label(self, text="Pan X Y(mm)")
# self.panXYVar = StringVar()
# panXYEnt = Entry(self, textvariable=self.panXYVar, width=6)
# panBut = Button(self, bg="orange", text="OK", command=self.cmd_pan)
# panLabel.grid(row=13, column=3, sticky=W)
# panXYEnt.grid(row=13, column=4)
# panBut.grid(row=13, column=5)
# process activate row 11 - 13
processLabel=Label(self, text="Process on/off", bg="green")
processLabel.grid(row=11, column=0, sticky=W)
procTab = {}
self.processList = ["phot", "compt", "conv", "msc", "eIoni", "eBrem", "annihil","muIoni", "muBrems", "hIoni"]
pos=1
self.processVar = {}
for i in self.processList:
self.processVar[i] = IntVar()
procTab[i] = Checkbutton(self, text=i, variable=self.processVar[i], command=self.cmd_setProcess)
if pos <= 3:
procTab[i].grid(row=11, column=pos, sticky=W)
if 4<= pos <= 7:
procTab[i].grid(row=12, column=pos-3, sticky=W)
if pos >= 8:
procTab[i].grid(row=13, column=pos-7, sticky=W)
pos=pos+1
procTab[i].select()
# set cuts row 14
cutLabel = Label(self, bg="green", text="Cut (mm)")
self.cutVar=DoubleVar()
self.cutVar.set(1.)
cut = Scale(self, orient=HORIZONTAL, length=400, from_=0., to=10., tickinterval=1., resolution=0.005, variable=self.cutVar, digits=5 )
cutLabel.grid(row=14, column=0, sticky=W)
cut.grid(row=14, column=1, columnspan=5, sticky=W)
# set mag field row 15
magLabel = Label(self, bg="green", text="Magnetic (T)")
self.magVar=DoubleVar()
self.magVar.set(0.)
mag = Scale(self, orient=HORIZONTAL, length=400, from_=0., to=5., tickinterval=1., resolution=0.1, variable=self.magVar, digits=3 )
magLabel.grid(row=15, column=0, sticky=W)
mag.grid(row=15, column=1, columnspan=5, sticky=W)
# viewer selection row=16
viewerLabel = Label(self, bg="green", text="Viewer")
viewerLabel.grid(row=16, column=0, sticky=W)
self.viewerVar = StringVar()
self.viewerVar.set("")
stateOfViewer = {"OpenGL":"normal", "VRML":"normal", "Wired":"normal"}
if vrmlViewer is None: stateOfViewer["VRML"] = "disabled"
if heprepViewer is None: stateOfViewer["Wired"] = "disabled"
viewers = { }
pos=1
for i in ("OpenGL", "VRML", "Wired"):
viewers[i] = Radiobutton(self, text=i, variable=self.viewerVar, value=i, command=self.cmd_viewer, state=stateOfViewer[i])
viewers[i].grid(row=16, column=pos, sticky=W)
pos=pos+1
#Geant4 command entry row = 17
g4comLabel = Label(self, text="Geant4 command", bg="orange")
self.g4commandVar = StringVar()
commandEntry = Entry(self, textvariable=self.g4commandVar, width=15)
self.g4commandVar.set("/vis/viewer/zoom 1.2")
comBut = Button(self, bg="orange", text="Execute", command=self.cmd_g4command)
g4comLabel.grid(row=17, column=0, sticky=W)
commandEntry.grid(row=17, column=1, columnspan=3, sticky=E+W)
comBut.grid(row=17, column=5)
#exit row = 0
exitBut = Button(self, bg="red", text="End all", command=sys.exit)
exitBut.grid(row=0, column=5, sticky=W)
#on Run butto do...
def cmd_beamOn(self):
exN03geom.SetNbOfLayers(self.layerVar.get())
exN03geom.SetAbsorberMaterial(self.absorbermaterialVar.get())
exN03geom.SetAbsorberThickness(self.absorberthickVar.get() * mm/2.0)
exN03geom.SetGapMaterial(self.gapmaterialVar.get())
exN03geom.SetGapThickness(self.gapthickVar.get() * mm/2.0)
exN03geom.SetCalorSizeYZ(self.calorsizeYZVar.get() * mm)
position = -self.layerVar.get()*(self.absorberthickVar.get() + self.gapthickVar.get())*1.2
exN03geom.UpdateGeometry()
exN03PL.SetDefaultCutValue(self.cutVar.get() * mm)
exN03PL.SetCutsWithDefault()
exN03geom.SetMagField(self.magVar.get() * tesla)
print("Now geometry updated")
self.cmd_particle(self.particleVar.get())
self.cmd_energy(self.energyVar.get())
print(position)
eventNum = self.eventVar.get()
for i in range(eventNum):
pg.SetParticlePosition(G4ThreeVector(position*mm, (i-eventNum/2)*5.*mm, 0.*cm))
gRunManager.BeamOn(1)
sleep(0.01)
gApplyUICommand("/vis/viewer/update")
def cmd_setProcess(self):
for i in self.processList:
if self.processVar[i].get() == 0:
gProcessTable.SetProcessActivation(i, 0)
print("Process " + i + " inactivated")
else:
gProcessTable.SetProcessActivation(i, 1)
print("Process " + i + " activated")
def cmd_g4command(self):
gApplyUICommand(self.g4commandVar.get())
def cmd_particle(self, particle):
gApplyUICommand("/gun/particle " + particle)
def cmd_energy(self, penergy):
gApplyUICommand("/gun/energy " + penergy + " MeV")
def cmd_viewer(self):
if self.viewerVar.get() == "OpenGL":
gApplyUICommand("/vis/viewer/select oglsxviewer")
gApplyUICommand("/vis/scene/add/trajectories")
gApplyUICommand("/tracking/storeTrajectory 1")
gApplyUICommand("/vis/scene/endOfEventAction accumulate")
gApplyUICommand("/vis/scene/endOfRunAction accumulate")
if self.viewerVar.get() == "VRML":
gApplyUICommand("/vis/viewer/select vrmlviewer")
gApplyUICommand("/vis/scene/add/trajectories")
gApplyUICommand("/tracking/storeTrajectory 1")
gApplyUICommand("/vis/scene/endOfEventAction accumulate")
gApplyUICommand("/vis/scene/endOfRunAction accumulate")
if self.viewerVar.get() == "Wired":
gApplyUICommand("/vis/viewer/select wired")
gApplyUICommand("/vis/scene/add/trajectories")
gApplyUICommand("/tracking/storeTrajectory 1")
gApplyUICommand("/vis/scene/endOfEventAction accumulate")
gApplyUICommand("/vis/scene/endOfRunAction accumulate")
if self.g4pipe == 0:
Popen(heprepViewer + " -file " + heprepDir + "/" + heprepName +".heprep", shell=True)
self.g4pipe = 1
def cmd_expand(self):
gApplyUICommand("/vis/viewer/zoom 1.2")
def cmd_pan(self):
gApplyUICommand("/vis/viewer/pan " + self.panXYVar.get() + " " + " mm")
def cmd_shrink(self):
gApplyUICommand("/vis/viewer/zoom 0.8")
def __init__(self, master=None):
Frame.__init__(self, master)
self.init()
self.grid()
app = App()
app.mainloop()
+364
View File
@@ -0,0 +1,364 @@
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# ==================================================================
# EM Calculator (GTK)
#
# Koichi Murakami (KEK/CRC)
# ==================================================================
from Geant4 import *
import g4py.ExN03pl
import g4py.emcalculator
import EmPlot
import ROOT
import sys
from cStringIO import StringIO
# ==================================================================
# Geant4
# ==================================================================
def g4_configure() :
EmPlot.Configure()
g4py.ExN03pl.Construct()
# -------------------------------------------------------------------
# plot for chaged particles
# -------------------------------------------------------------------
def plot_charged(material, pname) :
EmPlot.SetMaterial(material)
# initialize G4 kernel
gRunManager.Initialize()
gRunManagerKernel.RunInitialization()
# energy
elist= []
for n in range(-3, 3):
for i in range(10,99):
elist.append(i/10.*10.**n *MeV)
# calculate stopping power
global mycout
mycout.close()
sys.stdout = mycout = StringIO()
dedx_list= g4py.emcalculator.CalculateDEDX(pname, material, elist, 1)
xlist_tot=[]
xlist_ioni=[]
xlist_brems=[]
for x in dedx_list:
xlist_tot.append((x[0], x[1]["tot"]/(MeV*cm2/g)))
xlist_ioni.append((x[0], x[1]["ioni"]/(MeV*cm2/g)))
xlist_brems.append((x[0], x[1]["brems"]/(MeV*cm2/g)))
# make plot
global myCanvas, aplot, bplot, cplot
myCanvas = EmPlot.init_root()
aplot = EmPlot.make_plot(xlist_tot, pname+" Stopping Power ("+material+")",
"dE/dX (MeV cm^{2}/g)")
bplot = EmPlot.make_plot(xlist_ioni, "Stopping Power ("+material+")",
"dE/dX (MeV cm^{2}/g)", 1)
cplot = EmPlot.make_plot(xlist_brems, "Stopping Power ("+material+")",
"dE/dX (MeV cm^{2}/g)", 3)
myCanvas.SaveAs("/tmp/sp.png")
# -------------------------------------------------------------------
# plot for gamma
# -------------------------------------------------------------------
def plot_gamma(material) :
EmPlot.SetMaterial(material)
# initialize G4 kernel
gRunManager.Initialize()
gRunManagerKernel.RunInitialization()
# energy
elist= []
for n in range(-3, 4):
for i in range(10,99):
elist.append(i/10.*10.**n *MeV)
# calculate cross sections
global mycout
mycout.close()
sys.stdout = mycout = StringIO()
xsection_list= g4py.emcalculator.CalculatePhotonCrossSection(material,
elist, 1)
xlist_tot=[]
xlist_comp=[]
xlist_pe=[]
xlist_conv=[]
for x in xsection_list:
xlist_tot.append((x[0]/MeV, x[1]["tot"]/(cm2/g)))
xlist_comp.append((x[0]/MeV, x[1]["compt"]/(cm2/g)))
xlist_pe.append((x[0]/MeV, x[1]["phot"]/(cm2/g)))
xlist_conv.append((x[0]/MeV, x[1]["conv"]/(cm2/g)))
# make plots
global myCanvas, aplot, bplot, cplot, dplot
myCanvas = EmPlot.init_root()
aplot = EmPlot.make_plot(xlist_tot, "Photon Cross Section ("+material+")",
"Cross Section (cm^{2}/g)")
bplo = EmPlot.make_plot(xlist_comp, "Photon Cross Section ("+material+")",
"Cross Section (cm^{2}/g)", 1)
cplot = EmPlot.make_plot(xlist_pe, "Photon Cross Section ("+material+")",
"Cross Section (cm^{2}/g)", 7)
dplot = EmPlot.make_plot(xlist_conv, "Photon Cross Section ("+material+")",
"Cross Section (cm^{2}/g)", 3)
myCanvas.SaveAs("/tmp/cs.png")
# ==================================================================
# GUI
# ==================================================================
import pygtk
pygtk.require20()
import gtk
# -------------------------------------------------------------------
# main window
# -------------------------------------------------------------------
class MainWindow :
def __init__(self) :
self.__margin = 8
# main window
self.mainwindow = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.mainwindow.set_title('Em Calculator')
self.mainwindow.set_position(gtk.WIN_POS_MOUSE)
self.mainwindow.set_default_size(500, 300)
self.mainwindow.connect('delete-event', lambda w,d: gtk.main_quit())
self.mainwindow.connect('destroy-event',lambda w,d: gtk.main_quit())
# components
header = self.create_header()
particle_frame = self.create_particle_frame()
particle_frame.set_border_width(self.__margin)
material_frame = self.create_material_frame()
material_frame.set_border_width(self.__margin)
separator = gtk.HSeparator()
action_box = self.create_action_box()
action_box.set_border_width(self.__margin)
# layout
vbox = gtk.VBox()
vbox.pack_start(header)
vbox.pack_start(particle_frame)
vbox.pack_start(material_frame)
vbox.pack_start(separator)
vbox.pack_start(action_box)
self.mainwindow.add(vbox)
self.mainwindow.show_all()
# text view
self.textview = TextView()
# error dialog
self.error_dialog = gtk.MessageDialog(parent=self.mainwindow,
buttons=gtk.BUTTONS_CLOSE, type=gtk.MESSAGE_ERROR,
message_format="Material is not defined in G4Nist materials")
self.error_dialog.connect("response", self.cb_close_dialog)
def create_header(self) :
hbox = gtk.HBox()
label = gtk.Label()
label.set_markup("<big><b>EM Calculator</b></big>")
hbox.pack_start(label)
label = gtk.Label()
text = """
Shows
- stopping power for e/mu/proton
- cross sections for gamma
"""
label.set_markup(text)
hbox.pack_start(label)
return hbox
def create_particle_frame(self) :
frame = gtk.Frame("Particle")
hbox = gtk.HBox()
frame.add(hbox)
hbox.set_border_width(self.__margin)
button = gtk.RadioButton(None, "electron")
button.connect("toggled", self.cb_select_particle, "e-")
hbox.pack_start(button, True, True, 0)
button.show()
self.particle = "e-"
button = gtk.RadioButton(button, "positron")
button.connect("toggled", self.cb_select_particle, "e+")
hbox.pack_start(button, True, True, 0)
button.show()
button = gtk.RadioButton(button, "mu-")
button.connect("toggled", self.cb_select_particle, "mu-")
hbox.pack_start(button, True, True, 0)
button.show()
button = gtk.RadioButton(button, "mu+")
button.connect("toggled", self.cb_select_particle, "mu+")
hbox.pack_start(button, True, True, 0)
button.show()
button = gtk.RadioButton(button, "proton")
button.connect("toggled", self.cb_select_particle, "proton")
hbox.pack_start(button, True, True, 0)
button.show()
button = gtk.RadioButton(button, "gamma")
button.connect("toggled", self.cb_select_particle, "gamma")
hbox.pack_start(button, True, True, 0)
button.show()
return frame
def create_material_frame(self) :
frame = gtk.Frame("Material (G4Nist)")
hbox = gtk.HBox()
frame.add(hbox)
hbox.set_border_width(self.__margin)
self.material_list = [ "G4_Al", "G4_Si", "G4_Ar", "G4_Cu", "G4_Fe",
"G4_Ge", "G4_Ag", "G4_W", "G4_Au", "G4_Pb",
"G4_AIR", "G4_Galactic", "G4_WATER", "G4_CESIUM_IODIDE",
"G4_SODIUM_IODIDE", "G4_PLASTIC_SC_VINYLTOLUENE",
"G4_MYLAR" ]
self.material_combo = gtk.combo_box_entry_new_text()
hbox.pack_start(self.material_combo)
for name in self.material_list :
self.material_combo.append_text(name)
self.material_combo.set_active(0)
self.material = self.material_list[0]
self.material_combo.connect("changed", self.cb_select_material)
return frame
def create_action_box(self) :
box = gtk.HButtonBox()
box.set_layout(gtk.BUTTONBOX_END)
box.set_spacing(self.__margin)
exec_button = gtk.Button(stock = gtk.STOCK_EXECUTE)
text_button = gtk.Button("Text View")
quit_button = gtk.Button(stock = gtk.STOCK_QUIT)
box.add(exec_button)
box.add(text_button)
box.add(quit_button)
exec_button.connect("clicked", self.cb_show_plot)
text_button.connect("clicked", self.cb_show_textview)
quit_button.connect("clicked", lambda w: gtk.main_quit())
return box
# callbacks
def cb_show_textview(self, widget, data=None) :
window = self.textview.get_window()
window.show_all()
def cb_select_particle(self, widget, data=None) :
self.particle = data
def cb_select_material(self, widget, data=None) :
entry = widget.get_child()
self.material = entry.get_text()
def cb_show_plot(self, widget, data=None) :
g4mate = gNistManager.FindOrBuildMaterial(self.material)
if (g4mate == None) :
self.error_dialog.show_all()
return
if (self.material_list.count(self.material) == 0) :
self.material_combo.append_text(self.material)
if (self.particle == "gamma" ) :
plot_gamma(self.material)
else :
plot_charged(self.material, self.particle)
self.textview.textbuffer.set_text(mycout.getvalue())
def cb_close_dialog(self, widget, data=None) :
widget.hide_all()
# -------------------------------------------------------------------
# text view
# -------------------------------------------------------------------
class TextView :
def __init__(self) :
self.__margin = 8
self.text_window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.text_window.set_title('Value with Text')
self.text_window.set_position(gtk.WIN_POS_MOUSE)
self.text_window.set_default_size(500, 300)
vbox = gtk.VBox()
self.text_window.add(vbox)
sw = gtk.ScrolledWindow()
sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
sw.set_border_width(self.__margin)
vbox.pack_start(sw)
textview = gtk.TextView()
self.textbuffer = textview.get_buffer()
sw.add(textview)
hbox = gtk.HButtonBox()
hbox.set_layout(gtk.BUTTONBOX_END)
hbox.set_border_width(self.__margin)
vbox.pack_start(hbox, expand=False)
close_button = gtk.Button(stock = gtk.STOCK_CLOSE)
close_button.connect("clicked", self.cb_hide_window)
hbox.add(close_button)
def get_window(self) :
return self.text_window
def cb_hide_window(self, widget, data=None) :
self.text_window.hide_all()
return False
# ==================================================================
# main
# ==================================================================
def main() :
SetG4PyCoutDestination()
default_stdout = sys.stdout
global mycout
sys.stdout = mycout = StringIO()
# G4 setup
g4_configure()
# start GUI
application = MainWindow()
gtk.main()
gTerminate()
sys.stdout = default_stdout
if __name__ == "__main__":
try :
main()
except KeyboardInterrupt :
pass
@@ -6,6 +6,7 @@
<xs:element maxOccurs="unbounded" ref="Solid"/>
<xs:element name="volume" type="VolumeType"/>
<xs:element name="physvol" type="SinglePlacementType"/>
<xs:element name="loop" maxOccurs="unbounded"/>
</xs:choice>
<xs:attribute name="for" type="xs:string">
<xs:annotation>
@@ -19,7 +20,7 @@
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="to" type="xs:positiveInteger">
<xs:attribute name="to" type="ExpressionOrIDREFType">
<xs:annotation>
<xs:documentation>
</xs:documentation>
@@ -17,35 +17,194 @@
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:complexType name="BoxDimensionsType">
<xs:annotation>
<xs:documentation>Dimensions for parametrised boxes. </xs:documentation>
<xs:documentation>Dimensions for parametrised Boxes. </xs:documentation>
</xs:annotation>
<xs:complexContent>
<xs:extension base="DimensionsType">
<xs:attribute default="1.0" name="x" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="y" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="z" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="x" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="y" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="z" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="mm" name="lunit" type="xs:string"></xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="box_dimensions" substitutionGroup="Dimensions" type="BoxDimensionsType"/>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:complexType name="TrdDimensionsType">
<xs:annotation>
<xs:documentation>Dimensions for parametrised Trd. </xs:documentation>
</xs:annotation>
<xs:complexContent>
<xs:extension base="DimensionsType">
<xs:attribute default="1.0" name="x1" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="x2" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="y1" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="y2" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="z" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="mm" name="lunit" type="xs:string"></xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="trd_dimensions" substitutionGroup="Dimensions" type="TrdDimensionsType"/>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:complexType name="TrapDimensionsType">
<xs:annotation>
<xs:documentation>Dimensions for parametrised Trap. </xs:documentation>
</xs:annotation>
<xs:complexContent>
<xs:extension base="DimensionsType">
<xs:attribute default="1.0" name="z" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="theta" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="phi" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="y1" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="x1" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="x2" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="alpha1" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="y2" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="x3" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="x4" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="alpha2" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="mm" name="lunit" type="xs:string"></xs:attribute>
<xs:attribute default="radian" name="aunit" type="xs:string"></xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="trap_dimensions" substitutionGroup="Dimensions" type="TrapDimensionsType"/>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:complexType name="TubeDimensionsType">
<xs:annotation>
<xs:documentation>Dimensions for parametrised boxes. </xs:documentation>
<xs:documentation>Dimensions for parametrised Tubes. </xs:documentation>
</xs:annotation>
<xs:complexContent>
<xs:extension base="DimensionsType">
<xs:attribute default="1.0" name="DeltaPhi" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="InR" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="OutR" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="StartPhi" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="hz" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="InR" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="OutR" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="0.0" name="StartPhi" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="hz" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="mm" name="lunit" type="xs:string"></xs:attribute>
<xs:attribute default="radian" name="aunit" type="xs:string"></xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="tube_dimensions" substitutionGroup="Dimensions" type="TubeDimensionsType"/>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:complexType name="ConeDimensionsType">
<xs:annotation>
<xs:documentation>Dimensions for parametrised Cones. </xs:documentation>
</xs:annotation>
<xs:complexContent>
<xs:extension base="DimensionsType">
<xs:attribute default="1.0" name="rmin1" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="rmax1" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="rmin2" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="rmax2" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="z" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="0.0" name="startphi" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="deltaphi" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="mm" name="lunit" type="xs:string"></xs:attribute>
<xs:attribute default="radian" name="aunit" type="xs:string"></xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="cone_dimensions" substitutionGroup="Dimensions" type="ConeDimensionsType"/>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:complexType name="SphereDimensionsType">
<xs:annotation>
<xs:documentation>Dimensions for parametrised Spheres. </xs:documentation>
</xs:annotation>
<xs:complexContent>
<xs:extension base="DimensionsType">
<xs:attribute default="1.0" name="rmin" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="rmax" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="0.0" name="starttheta" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="deltatheta" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="0.0" name="startphi" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="deltaphi" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="mm" name="lunit" type="xs:string"></xs:attribute>
<xs:attribute default="radian" name="aunit" type="xs:string"></xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="sphere_dimensions" substitutionGroup="Dimensions" type="SphereDimensionsType"/>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:complexType name="OrbDimensionsType">
<xs:annotation>
<xs:documentation>Dimensions for parametrised Orbs. </xs:documentation>
</xs:annotation>
<xs:complexContent>
<xs:extension base="DimensionsType">
<xs:attribute default="1.0" name="r" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="mm" name="lunit" type="xs:string"></xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="orb_dimensions" substitutionGroup="Dimensions" type="OrbDimensionsType"/>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:complexType name="TorusDimensionsType">
<xs:annotation>
<xs:documentation>Dimensions for parametrised Torus. </xs:documentation>
</xs:annotation>
<xs:complexContent>
<xs:extension base="DimensionsType">
<xs:attribute default="1.0" name="rmin" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="rmax" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="rtor" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="0.0" name="startphi" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="deltaphi" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="mm" name="lunit" type="xs:string"></xs:attribute>
<xs:attribute default="radian" name="aunit" type="xs:string"></xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="torus_dimensions" substitutionGroup="Dimensions" type="TorusDimensionsType"/>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:complexType name="ParaDimensionsType">
<xs:annotation>
<xs:documentation>Dimensions for parametrised Paras. </xs:documentation>
</xs:annotation>
<xs:complexContent>
<xs:extension base="DimensionsType">
<xs:attribute default="1.0" name="x" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="y" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="z" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="alpha" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="theta" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="phi" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="mm" name="lunit" type="xs:string"></xs:attribute>
<xs:attribute default="radian" name="aunit" type="xs:string"></xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="para_dimensions" substitutionGroup="Dimensions" type="ParaDimensionsType"/>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:complexType name="HypeDimensionsType">
<xs:annotation>
<xs:documentation>Dimensions for parametrised Hypes. </xs:documentation>
</xs:annotation>
<xs:complexContent>
<xs:extension base="DimensionsType">
<xs:attribute default="1.0" name="rmin" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="rmax" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="inst" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="outst" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="1.0" name="z" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute default="mm" name="lunit" type="xs:string"></xs:attribute>
<xs:attribute default="radian" name="aunit" type="xs:string"></xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="hype_dimensions" substitutionGroup="Dimensions" type="HypeDimensionsType"/>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:complexType abstract="false" name="ParameterisationAlgorithmType">
<xs:annotation>
@@ -421,6 +421,28 @@
</xs:complexType>
</xs:element>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="elcone" substitutionGroup="Solid">
<xs:annotation>
<xs:documentation>CSG cone with elliptical cross section
dx semiaxis in X
dy semiaxis in Y
zmax height of elliptical cone
zcut upper cut plane level
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:complexContent>
<xs:extension base="SolidType">
<xs:attribute name="dx" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute name="dy" type="ExpressionOrIDREFType"></xs:attribute>
<xs:attribute name="zmax" type="ExpressionOrIDREFType" use="required"></xs:attribute>
<xs:attribute name="zcut" type="ExpressionOrIDREFType" use="required"></xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<xs:element name="polycone" substitutionGroup="Solid">
<xs:annotation>
+54
View File
@@ -0,0 +1,54 @@
#!/usr/bin/python3
# ==================================================================
# An example for reading a GDML file
#
# ==================================================================
from Geant4 import *
import g4py.ExN01pl, g4py.ParticleGun
# ==================================================================
# user actions in python
# ==================================================================
class MyDetectorConstruction(G4VUserDetectorConstruction):
"My Detector Construction"
def __init__(self):
G4VUserDetectorConstruction.__init__(self)
self.world= None
self.gdml_parser= G4GDMLParser()
# -----------------------------------------------------------------
def __del__(self):
pass
# -----------------------------------------------------------------
def Construct(self):
self.gdml_parser.Read("qgeom.gdml")
self.world= self.gdml_parser.GetWorldVolume()
return self.world
# ==================================================================
# main
# ==================================================================
# set geometry
myDC= MyDetectorConstruction()
gRunManager.SetUserInitialization(myDC)
# minimal physics list
g4py.ExN01pl.Construct()
# set primary generator action
g4py.ParticleGun.Construct()
# initialize
gRunManager.Initialize()
# visualization
gApplyUICommand("/vis/open OGLIX")
gApplyUICommand("/vis/scene/create")
gApplyUICommand("/vis/scene/add/volume")
gApplyUICommand("/vis/sceneHandler/attach")
gApplyUICommand("/vis/viewer/set/viewpointThetaPhi 90. -90.")
+41
View File
@@ -0,0 +1,41 @@
#!/usr/bin/python3
# ==================================================================
# An example of writing a GDML file
#
# ==================================================================
from Geant4 import *
import g4py.Qmaterials, g4py.Qgeom
import g4py.ExN01pl, g4py.ParticleGun
# ==================================================================
# main
# ==================================================================
# set geometry
g4py.Qmaterials.Construct()
g4py.Qgeom.Construct()
# minimal physics list
g4py.ExN01pl.Construct()
# set primary generator action
g4py.ParticleGun.Construct()
# initialize
gRunManager.Initialize()
# visualization
gApplyUICommand("/vis/open OGLIX")
gApplyUICommand("/vis/scene/create")
gApplyUICommand("/vis/scene/add/volume")
gApplyUICommand("/vis/sceneHandler/attach")
gApplyUICommand("/vis/viewer/set/viewpointThetaPhi 90. -90.")
# write to a GDML file
print("\n*** write to a GDML file...")
navigator= gTransportationManager.GetNavigatorForTracking()
world_volume= navigator.GetWorldVolume()
gdml_parser = G4GDMLParser()
gdml_parser.Write("qgeom.gdml", world_volume)
+272 -272
View File
@@ -1,389 +1,389 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<gdml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://service-spi.web.cern.ch/service-spi/app/releases/GDML/GDML_2_10_0/src/GDMLSchema/gdml.xsd">
<gdml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://service-spi.web.cern.ch/service-spi/app/releases/GDML/schema/gdml.xsd">
<define/>
<materials>
<material Z="13" name="Al0x932cf0" state="solid">
<material Z="13" name="Al0xa76fc0" state="solid">
<D unit="g/cm3" value="2.7"/>
<atom unit="g/mole" value="26.98"/>
</material>
<element Z="7" name="Nitrogen0x90fe50">
<element Z="7" name="Nitrogen0xa43c30">
<atom unit="g/mole" value="14.00674"/>
</element>
<element Z="8" name="Oxygen0x91dc40">
<element Z="8" name="Oxygen0xa49f90">
<atom unit="g/mole" value="15.9994"/>
</element>
<material name="Vacuum0x916cf0" state="gas">
<material name="Vacuum0xa3cb70" state="gas">
<D unit="g/cm3" value="1e-25"/>
<fraction n="0.7" ref="Nitrogen0x90fe50"/>
<fraction n="0.3" ref="Oxygen0x91dc40"/>
<fraction n="0.7" ref="Nitrogen0xa43c30"/>
<fraction n="0.3" ref="Oxygen0xa49f90"/>
</material>
<element Z="55" name="Cesium0x90eed0">
<element Z="55" name="Cesium0xa39e20">
<atom unit="g/mole" value="132.90543"/>
</element>
<element Z="53" name="Iodine0x61aa70">
<element Z="53" name="Iodine0xa3b2f0">
<atom unit="g/mole" value="126.90447"/>
</element>
<material name="CsI0x935a90" state="solid">
<material name="CsI0xa7a000" state="solid">
<D unit="g/cm3" value="4.51"/>
<fraction n="0.511548751606463" ref="Cesium0x90eed0"/>
<fraction n="0.488451248393537" ref="Iodine0x61aa70"/>
<fraction n="0.511548751606463" ref="Cesium0xa39e20"/>
<fraction n="0.488451248393537" ref="Iodine0xa3b2f0"/>
</material>
</materials>
<solids>
<tube aunit="deg" deltaphi="360" lunit="mm" name="tube0x941cb0" rmax="9.5" rmin="0" startphi="0" z="200"/>
<box lunit="mm" name="voxel0x93f120" x="20" y="200" z="20"/>
<box lunit="mm" name="cal0x941f60" x="50" y="50" z="60"/>
<box lunit="mm" name="AREA0x93e380" x="300" y="300" z="300"/>
<tube aunit="deg" deltaphi="360" lunit="mm" name="tube0xa86680" rmax="9.5" rmin="0" startphi="0" z="200"/>
<box lunit="mm" name="voxel0xa83b40" x="20" y="200" z="20"/>
<box lunit="mm" name="cal0xa86990" x="50" y="50" z="60"/>
<box lunit="mm" name="AREA0xa7fde0" x="300" y="300" z="300"/>
</solids>
<structure>
<volume name="tube0x941d60">
<materialref ref="Al0x932cf0"/>
<solidref ref="tube0x941cb0"/>
<volume name="tube0xa86770">
<materialref ref="Al0xa76fc0"/>
<solidref ref="tube0xa86680"/>
</volume>
<volume name="voxel0x93f1a0">
<materialref ref="Vacuum0x916cf0"/>
<solidref ref="voxel0x93f120"/>
<physvol name="tube0x941ee0">
<volumeref ref="tube0x941d60"/>
<rotation name="tube0x941ee0_rot" unit="deg" x="-90" y="0" z="0"/>
<volume name="voxel0xa83bc0">
<materialref ref="Vacuum0xa3cb70"/>
<solidref ref="voxel0xa83b40"/>
<physvol name="tube0xa868f0">
<volumeref ref="tube0xa86770"/>
<rotation name="tube0xa868f0_rot" unit="deg" x="-90" y="0" z="0"/>
</physvol>
</volume>
<volume name="cal0x941fe0">
<materialref ref="CsI0x935a90"/>
<solidref ref="cal0x941f60"/>
<volume name="cal0xa86a10">
<materialref ref="CsI0xa7a000"/>
<solidref ref="cal0xa86990"/>
</volume>
<volume name="AREA_LV0x93e970">
<materialref ref="Vacuum0x916cf0"/>
<solidref ref="AREA0x93e380"/>
<physvol name="voxel0x93f2d0">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x93f2d0_pos" unit="mm" x="-140" y="0" z="-130"/>
<volume name="AREA_LV0xa833f0">
<materialref ref="Vacuum0xa3cb70"/>
<solidref ref="AREA0xa7fde0"/>
<physvol name="voxel0xa83cf0">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa83cf0_pos" unit="mm" x="-140" y="0" z="-130"/>
</physvol>
<physvol name="voxel0x93f370">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x93f370_pos" unit="mm" x="-120" y="0" z="-130"/>
<physvol name="voxel0xa83d70">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa83d70_pos" unit="mm" x="-120" y="0" z="-130"/>
</physvol>
<physvol name="voxel0x93f3f0">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x93f3f0_pos" unit="mm" x="-100" y="0" z="-130"/>
<physvol name="voxel0xa83df0">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa83df0_pos" unit="mm" x="-100" y="0" z="-130"/>
</physvol>
<physvol name="voxel0x93f4a0">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x93f4a0_pos" unit="mm" x="-80" y="0" z="-130"/>
<physvol name="voxel0xa83ea0">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa83ea0_pos" unit="mm" x="-80" y="0" z="-130"/>
</physvol>
<physvol name="voxel0x93f520">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x93f520_pos" unit="mm" x="-60" y="0" z="-130"/>
<physvol name="voxel0xa83f20">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa83f20_pos" unit="mm" x="-60" y="0" z="-130"/>
</physvol>
<physvol name="voxel0x93f5c0">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x93f5c0_pos" unit="mm" x="-40" y="0" z="-130"/>
<physvol name="voxel0xa83fc0">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa83fc0_pos" unit="mm" x="-40" y="0" z="-130"/>
</physvol>
<physvol name="voxel0x93f640">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x93f640_pos" unit="mm" x="-20" y="0" z="-130"/>
<physvol name="voxel0xa84040">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa84040_pos" unit="mm" x="-20" y="0" z="-130"/>
</physvol>
<physvol name="voxel0x93f6c0">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x93f6c0_pos" unit="mm" x="0" y="0" z="-130"/>
<physvol name="voxel0xa840c0">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa840c0_pos" unit="mm" x="0" y="0" z="-130"/>
</physvol>
<physvol name="voxel0x93f740">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x93f740_pos" unit="mm" x="20" y="0" z="-130"/>
<physvol name="voxel0xa84140">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa84140_pos" unit="mm" x="20" y="0" z="-130"/>
</physvol>
<physvol name="voxel0x93f570">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x93f570_pos" unit="mm" x="40" y="0" z="-130"/>
<physvol name="voxel0xa83f70">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa83f70_pos" unit="mm" x="40" y="0" z="-130"/>
</physvol>
<physvol name="voxel0x93f880">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x93f880_pos" unit="mm" x="60" y="0" z="-130"/>
<physvol name="voxel0xa84280">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa84280_pos" unit="mm" x="60" y="0" z="-130"/>
</physvol>
<physvol name="voxel0x93f900">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x93f900_pos" unit="mm" x="80" y="0" z="-130"/>
<physvol name="voxel0xa84300">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa84300_pos" unit="mm" x="80" y="0" z="-130"/>
</physvol>
<physvol name="voxel0x93f980">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x93f980_pos" unit="mm" x="100" y="0" z="-130"/>
<physvol name="voxel0xa84380">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa84380_pos" unit="mm" x="100" y="0" z="-130"/>
</physvol>
<physvol name="voxel0x93fa00">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x93fa00_pos" unit="mm" x="120" y="0" z="-130"/>
<physvol name="voxel0xa84400">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa84400_pos" unit="mm" x="120" y="0" z="-130"/>
</physvol>
<physvol name="voxel0x93fa80">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x93fa80_pos" unit="mm" x="140" y="0" z="-130"/>
<physvol name="voxel0xa84480">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa84480_pos" unit="mm" x="140" y="0" z="-130"/>
</physvol>
<physvol name="voxel0x93fb00">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x93fb00_pos" unit="mm" x="-140" y="0" z="-110"/>
<physvol name="voxel0xa84500">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa84500_pos" unit="mm" x="-140" y="0" z="-110"/>
</physvol>
<physvol name="voxel0x93fb80">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x93fb80_pos" unit="mm" x="-120" y="0" z="-110"/>
<physvol name="voxel0xa84580">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa84580_pos" unit="mm" x="-120" y="0" z="-110"/>
</physvol>
<physvol name="voxel0x93f7c0">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x93f7c0_pos" unit="mm" x="-100" y="0" z="-110"/>
<physvol name="voxel0xa841c0">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa841c0_pos" unit="mm" x="-100" y="0" z="-110"/>
</physvol>
<physvol name="voxel0x93fd10">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x93fd10_pos" unit="mm" x="-80" y="0" z="-110"/>
<physvol name="voxel0xa84710">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa84710_pos" unit="mm" x="-80" y="0" z="-110"/>
</physvol>
<physvol name="voxel0x93fd90">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x93fd90_pos" unit="mm" x="-60" y="0" z="-110"/>
<physvol name="voxel0xa84790">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa84790_pos" unit="mm" x="-60" y="0" z="-110"/>
</physvol>
<physvol name="voxel0x93fe10">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x93fe10_pos" unit="mm" x="-40" y="0" z="-110"/>
<physvol name="voxel0xa84810">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa84810_pos" unit="mm" x="-40" y="0" z="-110"/>
</physvol>
<physvol name="voxel0x93fe90">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x93fe90_pos" unit="mm" x="-20" y="0" z="-110"/>
<physvol name="voxel0xa84890">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa84890_pos" unit="mm" x="-20" y="0" z="-110"/>
</physvol>
<physvol name="voxel0x93ff10">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x93ff10_pos" unit="mm" x="0" y="0" z="-110"/>
<physvol name="voxel0xa84910">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa84910_pos" unit="mm" x="0" y="0" z="-110"/>
</physvol>
<physvol name="voxel0x93ff90">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x93ff90_pos" unit="mm" x="20" y="0" z="-110"/>
<physvol name="voxel0xa84990">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa84990_pos" unit="mm" x="20" y="0" z="-110"/>
</physvol>
<physvol name="voxel0x940010">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x940010_pos" unit="mm" x="40" y="0" z="-110"/>
<physvol name="voxel0xa84a10">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa84a10_pos" unit="mm" x="40" y="0" z="-110"/>
</physvol>
<physvol name="voxel0x940090">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x940090_pos" unit="mm" x="60" y="0" z="-110"/>
<physvol name="voxel0xa84a90">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa84a90_pos" unit="mm" x="60" y="0" z="-110"/>
</physvol>
<physvol name="voxel0x940110">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x940110_pos" unit="mm" x="80" y="0" z="-110"/>
<physvol name="voxel0xa84b10">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa84b10_pos" unit="mm" x="80" y="0" z="-110"/>
</physvol>
<physvol name="voxel0x940190">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x940190_pos" unit="mm" x="100" y="0" z="-110"/>
<physvol name="voxel0xa84b90">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa84b90_pos" unit="mm" x="100" y="0" z="-110"/>
</physvol>
<physvol name="voxel0x940210">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x940210_pos" unit="mm" x="120" y="0" z="-110"/>
<physvol name="voxel0xa84c10">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa84c10_pos" unit="mm" x="120" y="0" z="-110"/>
</physvol>
<physvol name="voxel0x940290">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x940290_pos" unit="mm" x="140" y="0" z="-110"/>
<physvol name="voxel0xa84c90">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa84c90_pos" unit="mm" x="140" y="0" z="-110"/>
</physvol>
<physvol name="voxel0x940310">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x940310_pos" unit="mm" x="-140" y="0" z="-90"/>
<physvol name="voxel0xa84d10">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa84d10_pos" unit="mm" x="-140" y="0" z="-90"/>
</physvol>
<physvol name="voxel0x940390">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x940390_pos" unit="mm" x="-120" y="0" z="-90"/>
<physvol name="voxel0xa84d90">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa84d90_pos" unit="mm" x="-120" y="0" z="-90"/>
</physvol>
<physvol name="voxel0x940410">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x940410_pos" unit="mm" x="-100" y="0" z="-90"/>
<physvol name="voxel0xa84e10">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa84e10_pos" unit="mm" x="-100" y="0" z="-90"/>
</physvol>
<physvol name="voxel0x93fc00">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x93fc00_pos" unit="mm" x="-80" y="0" z="-90"/>
<physvol name="voxel0xa84600">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa84600_pos" unit="mm" x="-80" y="0" z="-90"/>
</physvol>
<physvol name="voxel0x93fc80">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x93fc80_pos" unit="mm" x="-60" y="0" z="-90"/>
<physvol name="voxel0xa84680">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa84680_pos" unit="mm" x="-60" y="0" z="-90"/>
</physvol>
<physvol name="voxel0x9406a0">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x9406a0_pos" unit="mm" x="-40" y="0" z="-90"/>
<physvol name="voxel0xa850a0">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa850a0_pos" unit="mm" x="-40" y="0" z="-90"/>
</physvol>
<physvol name="voxel0x940720">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x940720_pos" unit="mm" x="-20" y="0" z="-90"/>
<physvol name="voxel0xa85120">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa85120_pos" unit="mm" x="-20" y="0" z="-90"/>
</physvol>
<physvol name="voxel0x9407a0">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x9407a0_pos" unit="mm" x="0" y="0" z="-90"/>
<physvol name="voxel0xa851a0">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa851a0_pos" unit="mm" x="0" y="0" z="-90"/>
</physvol>
<physvol name="voxel0x940820">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x940820_pos" unit="mm" x="20" y="0" z="-90"/>
<physvol name="voxel0xa85220">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa85220_pos" unit="mm" x="20" y="0" z="-90"/>
</physvol>
<physvol name="voxel0x9408a0">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x9408a0_pos" unit="mm" x="40" y="0" z="-90"/>
<physvol name="voxel0xa852a0">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa852a0_pos" unit="mm" x="40" y="0" z="-90"/>
</physvol>
<physvol name="voxel0x940920">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x940920_pos" unit="mm" x="60" y="0" z="-90"/>
<physvol name="voxel0xa85320">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa85320_pos" unit="mm" x="60" y="0" z="-90"/>
</physvol>
<physvol name="voxel0x9409a0">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x9409a0_pos" unit="mm" x="80" y="0" z="-90"/>
<physvol name="voxel0xa853a0">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa853a0_pos" unit="mm" x="80" y="0" z="-90"/>
</physvol>
<physvol name="voxel0x940a20">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x940a20_pos" unit="mm" x="100" y="0" z="-90"/>
<physvol name="voxel0xa85420">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa85420_pos" unit="mm" x="100" y="0" z="-90"/>
</physvol>
<physvol name="voxel0x940aa0">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x940aa0_pos" unit="mm" x="120" y="0" z="-90"/>
<physvol name="voxel0xa854a0">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa854a0_pos" unit="mm" x="120" y="0" z="-90"/>
</physvol>
<physvol name="voxel0x940b20">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x940b20_pos" unit="mm" x="140" y="0" z="-90"/>
<physvol name="voxel0xa85520">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa85520_pos" unit="mm" x="140" y="0" z="-90"/>
</physvol>
<physvol name="voxel0x940ba0">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x940ba0_pos" unit="mm" x="-140" y="0" z="-70"/>
<physvol name="voxel0xa855a0">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa855a0_pos" unit="mm" x="-140" y="0" z="-70"/>
</physvol>
<physvol name="voxel0x940c20">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x940c20_pos" unit="mm" x="-120" y="0" z="-70"/>
<physvol name="voxel0xa85620">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa85620_pos" unit="mm" x="-120" y="0" z="-70"/>
</physvol>
<physvol name="voxel0x940ca0">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x940ca0_pos" unit="mm" x="-100" y="0" z="-70"/>
<physvol name="voxel0xa856a0">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa856a0_pos" unit="mm" x="-100" y="0" z="-70"/>
</physvol>
<physvol name="voxel0x940d20">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x940d20_pos" unit="mm" x="-80" y="0" z="-70"/>
<physvol name="voxel0xa85720">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa85720_pos" unit="mm" x="-80" y="0" z="-70"/>
</physvol>
<physvol name="voxel0x940da0">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x940da0_pos" unit="mm" x="-60" y="0" z="-70"/>
<physvol name="voxel0xa857a0">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa857a0_pos" unit="mm" x="-60" y="0" z="-70"/>
</physvol>
<physvol name="voxel0x940e20">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x940e20_pos" unit="mm" x="-40" y="0" z="-70"/>
<physvol name="voxel0xa85820">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa85820_pos" unit="mm" x="-40" y="0" z="-70"/>
</physvol>
<physvol name="voxel0x940ea0">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x940ea0_pos" unit="mm" x="-20" y="0" z="-70"/>
<physvol name="voxel0xa858a0">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa858a0_pos" unit="mm" x="-20" y="0" z="-70"/>
</physvol>
<physvol name="voxel0x940f20">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x940f20_pos" unit="mm" x="0" y="0" z="-70"/>
<physvol name="voxel0xa85920">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa85920_pos" unit="mm" x="0" y="0" z="-70"/>
</physvol>
<physvol name="voxel0x940fa0">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x940fa0_pos" unit="mm" x="20" y="0" z="-70"/>
<physvol name="voxel0xa859a0">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa859a0_pos" unit="mm" x="20" y="0" z="-70"/>
</physvol>
<physvol name="voxel0x941020">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x941020_pos" unit="mm" x="40" y="0" z="-70"/>
<physvol name="voxel0xa85a20">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa85a20_pos" unit="mm" x="40" y="0" z="-70"/>
</physvol>
<physvol name="voxel0x9410a0">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x9410a0_pos" unit="mm" x="60" y="0" z="-70"/>
<physvol name="voxel0xa85aa0">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa85aa0_pos" unit="mm" x="60" y="0" z="-70"/>
</physvol>
<physvol name="voxel0x941120">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x941120_pos" unit="mm" x="80" y="0" z="-70"/>
<physvol name="voxel0xa85b20">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa85b20_pos" unit="mm" x="80" y="0" z="-70"/>
</physvol>
<physvol name="voxel0x9411a0">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x9411a0_pos" unit="mm" x="100" y="0" z="-70"/>
<physvol name="voxel0xa85ba0">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa85ba0_pos" unit="mm" x="100" y="0" z="-70"/>
</physvol>
<physvol name="voxel0x941220">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x941220_pos" unit="mm" x="120" y="0" z="-70"/>
<physvol name="voxel0xa85c20">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa85c20_pos" unit="mm" x="120" y="0" z="-70"/>
</physvol>
<physvol name="voxel0x9412a0">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x9412a0_pos" unit="mm" x="140" y="0" z="-70"/>
<physvol name="voxel0xa85ca0">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa85ca0_pos" unit="mm" x="140" y="0" z="-70"/>
</physvol>
<physvol name="voxel0x941320">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x941320_pos" unit="mm" x="-140" y="0" z="-50"/>
<physvol name="voxel0xa85d20">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa85d20_pos" unit="mm" x="-140" y="0" z="-50"/>
</physvol>
<physvol name="voxel0x9413a0">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x9413a0_pos" unit="mm" x="-120" y="0" z="-50"/>
<physvol name="voxel0xa85da0">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa85da0_pos" unit="mm" x="-120" y="0" z="-50"/>
</physvol>
<physvol name="voxel0x941420">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x941420_pos" unit="mm" x="-100" y="0" z="-50"/>
<physvol name="voxel0xa85e20">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa85e20_pos" unit="mm" x="-100" y="0" z="-50"/>
</physvol>
<physvol name="voxel0x9414a0">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x9414a0_pos" unit="mm" x="-80" y="0" z="-50"/>
<physvol name="voxel0xa85ea0">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa85ea0_pos" unit="mm" x="-80" y="0" z="-50"/>
</physvol>
<physvol name="voxel0x941520">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x941520_pos" unit="mm" x="-60" y="0" z="-50"/>
<physvol name="voxel0xa85f20">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa85f20_pos" unit="mm" x="-60" y="0" z="-50"/>
</physvol>
<physvol name="voxel0x940490">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x940490_pos" unit="mm" x="-40" y="0" z="-50"/>
<physvol name="voxel0xa84e60">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa84e60_pos" unit="mm" x="-40" y="0" z="-50"/>
</physvol>
<physvol name="voxel0x940510">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x940510_pos" unit="mm" x="-20" y="0" z="-50"/>
<physvol name="voxel0xa84ee0">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa84ee0_pos" unit="mm" x="-20" y="0" z="-50"/>
</physvol>
<physvol name="voxel0x940590">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x940590_pos" unit="mm" x="0" y="0" z="-50"/>
<physvol name="voxel0xa84f60">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa84f60_pos" unit="mm" x="0" y="0" z="-50"/>
</physvol>
<physvol name="voxel0x940610">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x940610_pos" unit="mm" x="20" y="0" z="-50"/>
<physvol name="voxel0xa84fe0">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa84fe0_pos" unit="mm" x="20" y="0" z="-50"/>
</physvol>
<physvol name="voxel0x9419b0">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x9419b0_pos" unit="mm" x="40" y="0" z="-50"/>
<physvol name="voxel0xa86380">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa86380_pos" unit="mm" x="40" y="0" z="-50"/>
</physvol>
<physvol name="voxel0x941a30">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x941a30_pos" unit="mm" x="60" y="0" z="-50"/>
<physvol name="voxel0xa86400">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa86400_pos" unit="mm" x="60" y="0" z="-50"/>
</physvol>
<physvol name="voxel0x941ab0">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x941ab0_pos" unit="mm" x="80" y="0" z="-50"/>
<physvol name="voxel0xa86480">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa86480_pos" unit="mm" x="80" y="0" z="-50"/>
</physvol>
<physvol name="voxel0x941b30">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x941b30_pos" unit="mm" x="100" y="0" z="-50"/>
<physvol name="voxel0xa86500">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa86500_pos" unit="mm" x="100" y="0" z="-50"/>
</physvol>
<physvol name="voxel0x941bb0">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x941bb0_pos" unit="mm" x="120" y="0" z="-50"/>
<physvol name="voxel0xa86580">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa86580_pos" unit="mm" x="120" y="0" z="-50"/>
</physvol>
<physvol name="voxel0x941c30">
<volumeref ref="voxel0x93f1a0"/>
<position name="voxel0x941c30_pos" unit="mm" x="140" y="0" z="-50"/>
<physvol name="voxel0xa86600">
<volumeref ref="voxel0xa83bc0"/>
<position name="voxel0xa86600_pos" unit="mm" x="140" y="0" z="-50"/>
</physvol>
<physvol name="cal0x942110">
<volumeref ref="cal0x941fe0"/>
<position name="cal0x942110_pos" unit="mm" x="-100" y="0" z="20"/>
<physvol name="cal0xa86b40">
<volumeref ref="cal0xa86a10"/>
<position name="cal0xa86b40_pos" unit="mm" x="-100" y="0" z="20"/>
</physvol>
<physvol name="cal0x942190">
<volumeref ref="cal0x941fe0"/>
<position name="cal0x942190_pos" unit="mm" x="-50" y="0" z="20"/>
<physvol name="cal0xa86bc0">
<volumeref ref="cal0xa86a10"/>
<position name="cal0xa86bc0_pos" unit="mm" x="-50" y="0" z="20"/>
</physvol>
<physvol name="cal0x942210">
<volumeref ref="cal0x941fe0"/>
<position name="cal0x942210_pos" unit="mm" x="0" y="0" z="20"/>
<physvol name="cal0xa86c40">
<volumeref ref="cal0xa86a10"/>
<position name="cal0xa86c40_pos" unit="mm" x="0" y="0" z="20"/>
</physvol>
<physvol name="cal0x942290">
<volumeref ref="cal0x941fe0"/>
<position name="cal0x942290_pos" unit="mm" x="50" y="0" z="20"/>
<physvol name="cal0xa86cc0">
<volumeref ref="cal0xa86a10"/>
<position name="cal0xa86cc0_pos" unit="mm" x="50" y="0" z="20"/>
</physvol>
<physvol name="cal0x942310">
<volumeref ref="cal0x941fe0"/>
<position name="cal0x942310_pos" unit="mm" x="100" y="0" z="20"/>
<physvol name="cal0xa86d40">
<volumeref ref="cal0xa86a10"/>
<position name="cal0xa86d40_pos" unit="mm" x="100" y="0" z="20"/>
</physvol>
</volume>
</structure>
<setup name="Default" version="1.0">
<world ref="AREA_LV0x93e970"/>
<world ref="AREA_LV0xa833f0"/>
</setup>
</gdml>
@@ -23,8 +23,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: PhysicsListEMlowE.cc,v 1.1 2006/07/12 08:46:18 kmura Exp $
// $Name: geant4-09-02 $
// $Id: PhysicsListEMlowE.cc,v 1.2 2010/06/21 12:29:42 kmura Exp $
// $Name: geant4-09-04-beta-01 $
// ====================================================================
// PhysicsListEMlowE.cc
//
@@ -46,7 +46,7 @@
#include "G4LowEnergyIonisation.hh"
#include "G4LowEnergyBremsstrahlung.hh"
#include "G4eplusAnnihilation.hh"
#include "G4MultipleScattering.hh"
#include "G4eMultipleScattering.hh"
// ====================================================================
//
@@ -88,7 +88,7 @@ void PhysicsListEMlowE::ConstructProcess()
G4ProcessManager* pm;
// ----------------------------------------------------------
// ----------------------------------------------------------
// gamma physics
// ----------------------------------------------------------
pm= G4Gamma::Gamma()-> GetProcessManager();
@@ -102,7 +102,7 @@ void PhysicsListEMlowE::ConstructProcess()
// ----------------------------------------------------------
G4LowEnergyIonisation* eion= new G4LowEnergyIonisation;
G4LowEnergyBremsstrahlung* ebrems= new G4LowEnergyBremsstrahlung;
G4MultipleScattering* msc= new G4MultipleScattering;
G4eMultipleScattering* msc= new G4eMultipleScattering;
pm= G4Electron::Electron()-> GetProcessManager();
pm-> AddProcess(msc, ordInActive, 1, 1);
@@ -114,7 +114,7 @@ void PhysicsListEMlowE::ConstructProcess()
// ----------------------------------------------------------
eion= new G4LowEnergyIonisation;
ebrems= new G4LowEnergyBremsstrahlung;
msc= new G4MultipleScattering;
msc= new G4eMultipleScattering;
G4eplusAnnihilation* annihilation= new G4eplusAnnihilation;
pm= G4Positron::Positron()-> GetProcessManager();
@@ -23,8 +23,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: PhysicsListEMstd.cc,v 1.5 2006/07/11 09:55:01 kmura Exp $
// $Name: geant4-09-02 $
// $Id: PhysicsListEMstd.cc,v 1.6 2010/06/04 05:45:57 kmura Exp $
// $Name: geant4-09-04-beta-01 $
// ====================================================================
// PhysicsListEMstd.cc
//
@@ -42,7 +42,7 @@
#include "G4ComptonScattering.hh"
#include "G4GammaConversion.hh"
#include "G4PhotoElectricEffect.hh"
#include "G4MultipleScattering.hh"
#include "G4eMultipleScattering.hh"
#include "G4eIonisation.hh"
#include "G4eBremsstrahlung.hh"
#include "G4eplusAnnihilation.hh"
@@ -99,7 +99,7 @@ void PhysicsListEMstd::ConstructProcess()
// ----------------------------------------------------------
// electron physics
// ----------------------------------------------------------
G4MultipleScattering* msc= new G4MultipleScattering;
G4eMultipleScattering* msc= new G4eMultipleScattering;
G4eIonisation* eion= new G4eIonisation;
G4eBremsstrahlung* ebrems= new G4eBremsstrahlung;
@@ -111,7 +111,7 @@ void PhysicsListEMstd::ConstructProcess()
// ----------------------------------------------------------
// positron physics
// ----------------------------------------------------------
msc= new G4MultipleScattering;
msc= new G4eMultipleScattering;
eion= new G4eIonisation;
ebrems= new G4eBremsstrahlung;
G4eplusAnnihilation* annihilation= new G4eplusAnnihilation;
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: ExN03PhysicsList.cc,v 1.4 2006/06/29 15:30:01 gunter Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: ExN03PhysicsList.cc,v 1.5 2010/06/04 05:45:57 kmura Exp $
// GEANT4 tag $Name: geant4-09-04-beta-01 $
//
//
@@ -141,7 +141,9 @@ void ExN03PhysicsList::ConstructProcess()
#include "G4GammaConversion.hh"
#include "G4PhotoElectricEffect.hh"
#include "G4MultipleScattering.hh"
#include "G4eMultipleScattering.hh"
#include "G4MuMultipleScattering.hh"
#include "G4hMultipleScattering.hh"
#include "G4eIonisation.hh"
#include "G4eBremsstrahlung.hh"
@@ -171,13 +173,13 @@ void ExN03PhysicsList::ConstructEM()
} else if (particleName == "e-") {
//electron
pmanager->AddProcess(new G4MultipleScattering,-1, 1,1);
pmanager->AddProcess(new G4eMultipleScattering,-1, 1,1);
pmanager->AddProcess(new G4eIonisation, -1, 2,2);
pmanager->AddProcess(new G4eBremsstrahlung, -1, 3,3);
} else if (particleName == "e+") {
//positron
pmanager->AddProcess(new G4MultipleScattering,-1, 1,1);
pmanager->AddProcess(new G4eMultipleScattering,-1, 1,1);
pmanager->AddProcess(new G4eIonisation, -1, 2,2);
pmanager->AddProcess(new G4eBremsstrahlung, -1, 3,3);
pmanager->AddProcess(new G4eplusAnnihilation, 0,-1,4);
@@ -185,7 +187,7 @@ void ExN03PhysicsList::ConstructEM()
} else if( particleName == "mu+" ||
particleName == "mu-" ) {
//muon
pmanager->AddProcess(new G4MultipleScattering,-1, 1,1);
pmanager->AddProcess(new G4MuMultipleScattering,-1, 1,1);
pmanager->AddProcess(new G4MuIonisation, -1, 2,2);
pmanager->AddProcess(new G4MuBremsstrahlung, -1, 3,3);
pmanager->AddProcess(new G4MuPairProduction, -1, 4,4);
@@ -194,7 +196,7 @@ void ExN03PhysicsList::ConstructEM()
(particle->GetPDGCharge() != 0.0) &&
(particle->GetParticleName() != "chargedgeantino")) {
//all others charged particles except geantino
pmanager->AddProcess(new G4MultipleScattering,-1, 1,1);
pmanager->AddProcess(new G4hMultipleScattering,-1, 1,1);
pmanager->AddProcess(new G4hIonisation, -1, 2,2);
}
}
@@ -1,13 +1,28 @@
# $Id: GNUmakefile,v 1.2 2008/12/03 07:40:49 kmura Exp $
# $Name: geant4-09-02 $
# $Id: GNUmakefile,v 1.3 2010/12/02 08:34:07 kmura Exp $
# $Name: geant4-09-04 $
# ===========================================================
# Makefile for building Geant4Py modules
# ===========================================================
include ../../../config/config.gmk
install_dir := $(Q_LIBDIR)/g4py
ifeq ($(Q_WITH_PYTHON3), 0)
install_dir := $(Q_LIBDIR)/g4py
include $(G4PY_INSTALL)/config/g4py.gmk
include $(G4PY_INSTALL)/config/sys/$(Q_SYSTEM).gmk
include $(G4PY_INSTALL)/config/script-install.gmk
include $(G4PY_INSTALL)/config/g4py.gmk
include $(G4PY_INSTALL)/config/sys/$(Q_SYSTEM).gmk
include $(G4PY_INSTALL)/config/script-install.gmk
else
.PHONY: all install clean
all:
@cd python3 && $(MAKE)
install:
@cd python3 && $(MAKE) install
clean:
@cd python3 && $(MAKE) clean
endif
@@ -0,0 +1,13 @@
# $Id: GNUmakefile,v 1.1 2010/12/02 08:43:22 kmura Exp $
# $Name: geant4-09-04 $
# ===========================================================
# Makefile for building Geant4Py modules
# ===========================================================
include ../../../../config/config.gmk
install_dir := $(Q_LIBDIR)/g4py
include $(G4PY_INSTALL)/config/g4py.gmk
include $(G4PY_INSTALL)/config/sys/$(Q_SYSTEM).gmk
include $(G4PY_INSTALL)/config/script-install.gmk
@@ -0,0 +1,150 @@
#$Id: emcalculator.py,v 1.1 2010/12/02 08:43:22 kmura Exp $
"""
# ==================================================================
# Python module (Python3)
#
# 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,13 +1,28 @@
# $Id: GNUmakefile,v 1.3 2008/12/03 07:40:49 kmura Exp $
# $Name: geant4-09-02 $
# $Id: GNUmakefile,v 1.4 2010/12/02 08:34:07 kmura Exp $
# $Name: geant4-09-04 $
# ===========================================================
# Makefile for building Geant4Py modules
# ===========================================================
include ../../../config/config.gmk
install_dir := $(Q_LIBDIR)/g4py
ifeq ($(Q_WITH_PYTHON3), 0)
install_dir := $(Q_LIBDIR)/g4py
include $(G4PY_INSTALL)/config/g4py.gmk
include $(G4PY_INSTALL)/config/sys/$(Q_SYSTEM).gmk
include $(G4PY_INSTALL)/config/script-install.gmk
include $(G4PY_INSTALL)/config/g4py.gmk
include $(G4PY_INSTALL)/config/sys/$(Q_SYSTEM).gmk
include $(G4PY_INSTALL)/config/script-install.gmk
else
.PHONY: all install clean
all:
@cd python3 && $(MAKE)
install:
@cd python3 && $(MAKE) install
clean:
@cd python3 && $(MAKE) clean
endif
@@ -0,0 +1,13 @@
# $Id: GNUmakefile,v 1.1 2010/12/02 08:44:17 kmura Exp $
# $Name: geant4-09-04 $
# ===========================================================
# Makefile for building Geant4Py modules
# ===========================================================
include ../../../../config/config.gmk
install_dir := $(Q_LIBDIR)/g4py
include $(G4PY_INSTALL)/config/g4py.gmk
include $(G4PY_INSTALL)/config/sys/$(Q_SYSTEM).gmk
include $(G4PY_INSTALL)/config/script-install.gmk
@@ -0,0 +1,136 @@
"""
Python module (Python3)
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()
+8 -3
View File
@@ -1,5 +1,5 @@
# $Id: GNUmakefile,v 1.8 2008/12/03 07:33:39 kmura Exp $
# $Name: geant4-09-02 $
# $Id: GNUmakefile,v 1.9 2010/12/02 08:21:04 kmura Exp $
# $Name: geant4-09-04 $
# ===========================================================
# Makefile for building Geant4Py modules
# ===========================================================
@@ -8,7 +8,12 @@ include ../config/config.gmk
SUBDIR1 := global interface intercoms run event tracking track
SUBDIR1 += geometry materials particles processes digits_hits
SUBDIR2 := visualization graphics_reps physics_lists gdml
SUBDIR3 := python
ifeq ($(Q_WITH_PYTHON3), 0)
SUBDIR3 := python
else
SUBDIR3 := python3
endif
.PHONY: all install clean
@@ -23,8 +23,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: pyG4GDMLParser.cc,v 1.3 2008/12/12 02:26:34 kmura Exp $
// $Name: geant4-09-03 $
// $Id: pyG4GDMLParser.cc,v 1.5 2010/12/02 08:24:22 kmura Exp $
// $Name: geant4-09-04 $
// ====================================================================
// pyG4GDMLParser.cc
//
@@ -34,6 +34,8 @@
#include <boost/python.hpp>
#include "G4GDMLParser.hh"
#include "G4LogicalVolume.hh"
#include "G4Material.hh"
#include "G4Version.hh"
using namespace boost::python;
@@ -43,14 +45,28 @@ using namespace boost::python;
// ====================================================================
namespace pyG4GDMLParser {
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_GetWorldVolume,
GetWorldVolume, 0, 1);
#if G4VERSION_NUMBER >= 940
void (G4GDMLParser::*f1_Write)
(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);
#endif
#if G4VERSION_NUMBER >= 920
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);
#endif
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_GetWorldVolume,
GetWorldVolume, 0, 1);
}
using namespace pyG4GDMLParser;
@@ -63,15 +79,24 @@ void export_G4GDMLParser()
class_<G4GDMLParser, boost::noncopyable>
("G4GDMLParser", "GDML parser")
// ---
#if G4VERSION_NUMBNER < 920
#if G4VERSION_NUMBER < 920
.def("Read", &G4GDMLParser::Read)
#else
.def("Read", &G4GDMLParser::Read, f_Read())
.def("ReadModule", &G4GDMLParser::ReadModule, f_ReadModule())
.def("Write", &G4GDMLParser::Write, f_Write())
.def("ParseST", &G4GDMLParser::ParseST,
return_value_policy<reference_existing_object>())
#endif
#if G4VERSION_NUMBER >= 920
#if G4VERSION_NUMBER >= 940
.def("Write", f1_Write, f_Write())
.def("Write", f2_Write, g_Write())
#else
.def("Write", &G4GDMLParser::Write, f_Write())
#endif
#endif
.def("GetWorldVolume", &G4GDMLParser::GetWorldVolume,
f_GetWorldVolume()
[return_value_policy<reference_existing_object>()])
@@ -23,14 +23,15 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: pyG4VisAttributes.cc,v 1.4 2006/06/29 15:33:57 gunter Exp $
// $Name: geant4-09-02 $
// $Id: pyG4VisAttributes.cc,v 1.5 2010/12/02 08:23:49 kmura Exp $
// $Name: geant4-09-04 $
// ====================================================================
// pyG4VisAttributes.cc
//
// 2005 Q
// ====================================================================
#include <boost/python.hpp>
#include "G4AttDef.hh"
#include "G4VisAttributes.hh"
using namespace boost::python;
@@ -23,8 +23,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: pyPhysicsLists.cc,v 1.9 2009/11/20 03:36:51 kmura Exp $
// $Name: geant4-09-03 $
// $Id: pyPhysicsLists.cc,v 1.13 2010/12/02 08:24:22 kmura Exp $
// $Name: geant4-09-04 $
// ====================================================================
// pyPhysicsLists.cc
//
@@ -35,62 +35,46 @@
#include <vector>
#include <algorithm>
#if G4VERSION_NUMBER >= 820
#include "G4HadronCaptureProcess.hh"
#include "G4HadronQElasticPhysics.hh"
#include "G4HadronInelasticQBBC.hh"
#include "G4HadronInelasticQLHEP.hh"
#include "FTFC.hh"
#include "FTFP.hh"
#include "LBE.hh"
#include "LHEP.hh"
#include "LHEP_BERT.hh"
#include "LHEP_BERT_HP.hh"
#include "LHEP_EMV.hh"
#include "LHEP_PRECO_HP.hh"
#include "QBBC.hh"
#include "QGSC.hh"
#include "QGSC_EFLOW.hh"
#include "QGSC_EMV.hh"
#include "QGSP.hh"
#include "QGSP_BERT.hh"
#include "QGSP_BERT_HP.hh"
#include "QGSP_BIC.hh"
#include "QGSP_BIC_HP.hh"
#include "QGSP_EMV.hh"
#include "QGSP_EMX.hh"
#include "QGSP_QEL.hh"
#if G4VERSION_NUMBER <= 830
#include "LHEP_BIC.hh"
#include "LHEP_BIC_HP.hh"
#include "LHEP_HP.hh"
#include "LHEP_LEAD.hh"
#include "LHEP_LEAD_HP.hh"
#include "LHEP_PRECO.hh"
#include "QGSC_LEAD.hh"
#include "QGSC_LEAD_HP.hh"
#include "QGSP_HP.hh"
#endif
#endif
#if G4VERSION_NUMBER >= 830
#include "FTFP_EMV.hh"
#include "QGSP_BERT_EMV.hh"
#include "QGSP_BERT_NQE.hh"
#include "QGSP_BERT_TRV.hh"
#include "QGSP_EMV_NQE.hh"
#include "QGSP_NQE.hh"
#endif
// dropped at 9.4
//#include "FTFC.hh"
//#include "FTFP.hh"
//#include "LHEP_BERT.hh"
//#include "LHEP_BERT_HP.hh"
//#include "LHEP_PRECO_HP.hh"
//#include "QGSC.hh"
//#include "QGSC_EMV.hh"
//#include "QGSP_EMV.hh"
//#include "QGSC_EFLOW.hh"
//#include "QGSP_EMX.hh"
//#include "FTFP_EMV.hh"
//#include "QGSP_BERT_NQE.hh"
//#include "QGSP_EMV_NQE.hh"
//#include "QGSP_NQE.hh"
#if G4VERSION_NUMBER >= 910
#include "FTFP_BERT.hh"
#include "FTF_BIC.hh"
#include "QGSC_BERT.hh"
#include "QGS_BIC.hh"
#include "QGSP_DIF.hh"
#include "QGSP_BERT_DIF.hh"
// dropped at 9.4
//#include "QGSP_DIF.hh"
//#include "QGSP_BERT_DIF.hh"
#endif
#if G4VERSION_NUMBER >= 930
@@ -99,12 +83,17 @@
#include "FTFP_BERT_EMX.hh"
#include "FTFP_BERT_TRV.hh"
#include "QGSC_CHIPS.hh"
#include "QGSC_QGSC.hh"
#include "QGSP_BERT_EMX.hh"
#include "QGSP_BERT_NOLEP.hh"
#include "QGSP_BIC_EMY.hh"
#include "QGSP_FTFP_BERT.hh"
#include "QGSP_INCL_ABLA.hh"
// dropped at 9.4
//#include "QGSC_QGSC.hh"
#endif
#if G4VERSION_NUMBER >= 940
#include "QGSP_BERT_CHIPS.hh"
#endif
// macro for adding physics lists
@@ -144,58 +133,41 @@ void export_PhysicsLists()
{
def("ListPhysicsList", ListPhysicsList);
#if G4VERSION_NUMBER >= 820
ADD_PHYSICS_LIST(FTFC);
ADD_PHYSICS_LIST(FTFP);
ADD_PHYSICS_LIST(LBE);
ADD_PHYSICS_LIST(LHEP);
ADD_PHYSICS_LIST(LHEP_BERT);
ADD_PHYSICS_LIST(LHEP_BERT_HP);
ADD_PHYSICS_LIST(LHEP_EMV);
ADD_PHYSICS_LIST(LHEP_PRECO_HP);
ADD_PHYSICS_LIST(QBBC);
ADD_PHYSICS_LIST(QGSC);
ADD_PHYSICS_LIST(QGSC_EFLOW);
ADD_PHYSICS_LIST(QGSC_EMV);
ADD_PHYSICS_LIST(QGSP);
ADD_PHYSICS_LIST(QGSP_BERT);
ADD_PHYSICS_LIST(QGSP_BERT_HP);
ADD_PHYSICS_LIST(QGSP_BIC);
ADD_PHYSICS_LIST(QGSP_BIC_HP);
ADD_PHYSICS_LIST(QGSP_EMV);
ADD_PHYSICS_LIST(QGSP_EMX);
ADD_PHYSICS_LIST(QGSP_QEL);
#if G4VERSION_NUMBER <= 830
ADD_PHYSICS_LIST(LHEP_BIC);
ADD_PHYSICS_LIST(LHEP_BIC_HP);
ADD_PHYSICS_LIST(LHEP_HP);
ADD_PHYSICS_LIST(LHEP_LEAD);
ADD_PHYSICS_LIST(LHEP_LEAD_HP);
ADD_PHYSICS_LIST(LHEP_PRECO);
ADD_PHYSICS_LIST(QGSC_LEAD);
ADD_PHYSICS_LIST(QGSC_LEAD_HP);
ADD_PHYSICS_LIST(QGSP_HP);
#endif
#endif
#if G4VERSION_NUMBER >= 830
ADD_PHYSICS_LIST(FTFP_EMV);
ADD_PHYSICS_LIST(QGSP_BERT_EMV);
ADD_PHYSICS_LIST(QGSP_BERT_NQE);
ADD_PHYSICS_LIST(QGSP_BERT_TRV);
ADD_PHYSICS_LIST(QGSP_EMV_NQE);
ADD_PHYSICS_LIST(QGSP_NQE);
#endif
//ADD_PHYSICS_LIST(FTFC);
//ADD_PHYSICS_LIST(FTFP);
//ADD_PHYSICS_LIST(LHEP_BERT);
//ADD_PHYSICS_LIST(LHEP_BERT_HP);
//ADD_PHYSICS_LIST(LHEP_PRECO_HP);
//ADD_PHYSICS_LIST(QGSC);
//ADD_PHYSICS_LIST(QGSC_EMV);
//ADD_PHYSICS_LIST(QGSP_EMV);
//ADD_PHYSICS_LIST(QGSC_EFLOW);
//ADD_PHYSICS_LIST(QGSP_EMX);
//ADD_PHYSICS_LIST(FTFP_EMV);
//ADD_PHYSICS_LIST(QGSP_BERT_NQE);
//ADD_PHYSICS_LIST(QGSP_EMV_NQE);
//ADD_PHYSICS_LIST(QGSP_NQE);
#if G4VERSION_NUMBER >= 910
ADD_PHYSICS_LIST(FTFP_BERT);
ADD_PHYSICS_LIST(FTF_BIC);
ADD_PHYSICS_LIST(QGSC_BERT);
ADD_PHYSICS_LIST(QGS_BIC);
ADD_PHYSICS_LIST(QGSP_DIF);
ADD_PHYSICS_LIST(QGSP_BERT_DIF);
//ADD_PHYSICS_LIST(QGSP_DIF);
//ADD_PHYSICS_LIST(QGSP_BERT_DIF);
#endif
#if G4VERSION_NUMBER >= 930
@@ -204,12 +176,16 @@ void export_PhysicsLists()
ADD_PHYSICS_LIST(FTFP_BERT_EMX);
ADD_PHYSICS_LIST(FTFP_BERT_TRV);
ADD_PHYSICS_LIST(QGSC_CHIPS);
ADD_PHYSICS_LIST(QGSC_QGSC);
ADD_PHYSICS_LIST(QGSP_BERT_EMX);
ADD_PHYSICS_LIST(QGSP_BERT_NOLEP);
ADD_PHYSICS_LIST(QGSP_BIC_EMY);
ADD_PHYSICS_LIST(QGSP_FTFP_BERT);
ADD_PHYSICS_LIST(QGSP_INCL_ABLA);
//ADD_PHYSICS_LIST(QGSC_QGSC);
#endif
#if G4VERSION_NUMBER >= 940
ADD_PHYSICS_LIST(QGSP_BERT_CHIPS);
#endif
// sort PL vector
+7 -10
View File
@@ -8,12 +8,10 @@
# Hava A Fun!
# ==================================================================
"""
# $Id: __init__.py,v 1.21 2009/11/20 03:36:51 kmura Exp $
__version__ ='9.3.0'
__date__ = '1/Dec/2009'
# $Id: __init__.py,v 1.23 2010/12/02 08:24:22 kmura Exp $
__version__ ='9.4.0'
__date__ = '17/December/2010'
__author__ = 'K.Murakami (Koichi.Murakami@kek.jp)'
__url__ = 'http://www-geant4.kek.jp/projects/Geant4Py/'
# import submodules
from G4interface import *
@@ -42,9 +40,8 @@ def print_version():
Version : %s
Date : %s
Contact : %s
WWW : %s
=============================================================
""" % ( __version__, __date__, __author__, __url__)
""" % ( __version__, __date__, __author__)
# ==================================================================
# initialize
@@ -236,12 +233,12 @@ import signal
import threading
def _run_abort(signum, frame):
state = gStateManager.GetCurrentState();
state = gStateManager.GetCurrentState()
if(state == G4ApplicationState.G4State_GeomClosed or
state == G4ApplicationState.G4State_EventProc):
print "aborting Run ...";
gRunManager.AbortRun(True);
print "aborting Run ..."
gRunManager.AbortRun(True)
else:
raise KeyboardInterrupt
@@ -0,0 +1,13 @@
# $Id: GNUmakefile,v 1.1 2010/12/02 08:22:21 kmura Exp $
# $Name: geant4-09-04 $
# ===========================================================
# Makefile for building Geant4Py modules
# ===========================================================
include ../../config/config.gmk
install_dir := $(Q_LIBDIR)/Geant4
include $(G4PY_INSTALL)/config/g4py.gmk
include $(G4PY_INSTALL)/config/sys/$(Q_SYSTEM).gmk
include $(G4PY_INSTALL)/config/script-install.gmk
@@ -0,0 +1,246 @@
"""
# ==================================================================
# [Geant4] module package
#
# Welcome to Geant4Py.
#
# This package contains a set of Python interface with Geant4.
# Hava A Fun!
# ==================================================================
"""
# $Id: __init__.py,v 1.1 2010/12/02 08:22:21 kmura Exp $
__version__ ='9.4.0'
__date__ = '17/December/2010'
__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
Contact : %s
=============================================================
""" % ( __version__, __date__, __author__) )
# ==================================================================
# 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()
# gLossTableManager
gLossTableManager = G4LossTableManager.Instance()
# 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)
@@ -0,0 +1,778 @@
"""
# ==================================================================
# Python module
#
# color table
#
# Q, 2005
# ==================================================================
"""
#$Id: colortable.py,v 1.1 2010/12/02 08:22:21 kmura Exp $
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)
@@ -0,0 +1,24 @@
"""
# ==================================================================
# Python module
#
# Geant4 threading module
#
# Q, 2005
# ==================================================================
"""
#$Id: g4thread.py,v 1.1 2010/12/02 08:22:21 kmura Exp $
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
@@ -0,0 +1,69 @@
#$Id: g4viscp.py,v 1.1 2010/12/02 08:22:21 kmura Exp $
"""
# ==================================================================
# 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]) )
+308
View File
@@ -0,0 +1,308 @@
"""
# ==================================================================
# Python module
#
# This module defines physical units and constants used in HEP,
# which are imported from CLHEP library.
#
# Q, 2005
# ==================================================================
"""
#$Id: hepunit.py,v 1.1 2010/12/02 08:22:21 kmura Exp $
# ==================================================================
# 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
+46 -33
View File
@@ -23,14 +23,15 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: pyG4RunManager.cc,v 1.4 2006/06/29 15:35:12 gunter Exp $
// $Name: geant4-09-02 $
// $Id: pyG4RunManager.cc,v 1.6 2010/12/02 08:23:05 kmura Exp $
// $Name: geant4-09-04 $
// ====================================================================
// pyG4RunManager.cc
//
// 2005 Q
// ====================================================================
#include <boost/python.hpp>
#include "G4Version.hh"
#include "G4RunManager.hh"
#include "G4VUserDetectorConstruction.hh"
#include "G4VUserPhysicsList.hh"
@@ -72,13 +73,17 @@ void (G4RunManager::*f6_SetUserAction)(G4UserSteppingAction*)
= &G4RunManager::SetUserAction;
// DumpRegion
#if G4VERSION_NUMBER >= 932
void (G4RunManager::*f1_DumpRegion)(const G4String&) const
= &G4RunManager::DumpRegion;
#else
void (G4RunManager::*f1_DumpRegion)(G4String) const
= &G4RunManager::DumpRegion;
= &G4RunManager::DumpRegion;
#endif
void (G4RunManager::*f2_DumpRegion)(G4Region*) const
= &G4RunManager::DumpRegion;
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_DumpRegion,
DumpRegion, 0, 1);
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_DumpRegion, DumpRegion, 0, 1);
// BeamOn()
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_BeamOn, BeamOn, 1, 3);
@@ -87,8 +92,8 @@ BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_BeamOn, BeamOn, 1, 3);
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_AbortRun, AbortRun, 0, 1);
// DefineWorldVolume()
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_DefineWorldVolume,
DefineWorldVolume, 1, 2);
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_DefineWorldVolume,
DefineWorldVolume, 1, 2);
};
@@ -102,18 +107,18 @@ void export_G4RunManager()
class_<G4RunManager>("G4RunManager", "run manager class")
// ---
.def("GetRunManager", &G4RunManager::GetRunManager,
"Get an instance of G4RunManager",
return_value_policy<reference_existing_object>())
"Get an instance of G4RunManager",
return_value_policy<reference_existing_object>())
.staticmethod("GetRunManager")
// ---
.def("SetVerboseLevel", &G4RunManager::SetVerboseLevel)
.def("GetVerboseLevel", &G4RunManager::GetVerboseLevel)
// ---
.def("Initialize", &G4RunManager::Initialize)
.def("BeamOn", &G4RunManager::BeamOn,
f_BeamOn((arg("n_event"), arg("macroFile")=0,
arg("n_select")=-1),
"Starts event loop."))
.def("BeamOn", &G4RunManager::BeamOn,
f_BeamOn((arg("n_event"), arg("macroFile")=0,
arg("n_select")=-1),
"Starts event loop."))
// ---
.def("SetUserInitialization", f1_SetUserInitialization)
.def("SetUserInitialization", f2_SetUserInitialization)
@@ -125,50 +130,58 @@ void export_G4RunManager()
.def("SetUserAction", f6_SetUserAction)
// ---
.def("GetUserDetectorConstruction",
&G4RunManager::GetUserDetectorConstruction,
return_internal_reference<>())
&G4RunManager::GetUserDetectorConstruction,
return_internal_reference<>())
.def("GetUserPhysicsList",
&G4RunManager::GetUserPhysicsList,
return_internal_reference<>())
&G4RunManager::GetUserPhysicsList,
return_internal_reference<>())
.def("GetUserPrimaryGeneratorAction",
&G4RunManager::GetUserPrimaryGeneratorAction,
return_internal_reference<>())
&G4RunManager::GetUserPrimaryGeneratorAction,
return_internal_reference<>())
.def("GetUserRunAction", &G4RunManager::GetUserRunAction,
return_internal_reference<>())
return_internal_reference<>())
.def("GetUserEventAction", &G4RunManager::GetUserEventAction,
return_internal_reference<>())
return_internal_reference<>())
.def("GetUserStackingAction", &G4RunManager::GetUserStackingAction,
return_internal_reference<>())
return_internal_reference<>())
.def("GetUserTrackingAction", &G4RunManager::GetUserTrackingAction,
return_internal_reference<>())
return_internal_reference<>())
.def("GetUserSteppingAction", &G4RunManager::GetUserSteppingAction,
return_internal_reference<>())
return_internal_reference<>())
// ---
.def("AbortRun", &G4RunManager::AbortRun,
f_AbortRun((arg("soft_abort")=false),
"Abort run (event loop)."))
.def("AbortEvent", &G4RunManager::AbortEvent)
.def("GetVersionString", &G4RunManager::GetVersionString)
f_AbortRun((arg("soft_abort")=false),
"Abort run (event loop)."))
.def("AbortEvent", &G4RunManager::AbortEvent)
.def("DefineWorldVolume", &G4RunManager::DefineWorldVolume,
f_DefineWorldVolume())
f_DefineWorldVolume())
.def("DumpRegion", f1_DumpRegion)
.def("DumpRegion", f2_DumpRegion, f_DumpRegion())
.def("rndmSaveThisRun", &G4RunManager::rndmSaveThisRun)
.def("rndmSaveThisEvent", &G4RunManager::rndmSaveThisEvent)
.def("RestoreRandomNumberStatus",
&G4RunManager::RestoreRandomNumberStatus)
&G4RunManager::RestoreRandomNumberStatus)
.def("SetRandomNumberStore", &G4RunManager::SetRandomNumberStore)
.def("GetRandomNumberStore", &G4RunManager::GetRandomNumberStore)
.def("SetRandomNumberStoreDir", &G4RunManager::SetRandomNumberStoreDir)
.def("GetRandomNumberStoreDir", &G4RunManager::GetRandomNumberStoreDir)
.def("GeometryHasBeenModified", &G4RunManager::GeometryHasBeenModified)
.def("PhysicsHasBeenModified", &G4RunManager::PhysicsHasBeenModified)
.def("GetGeometryToBeOptimized",&G4RunManager::GetGeometryToBeOptimized)
.def("GetCurrentRun", &G4RunManager::GetCurrentRun,
return_value_policy<reference_existing_object>())
return_value_policy<reference_existing_object>())
.def("GetCurrentEvent", &G4RunManager::GetCurrentEvent,
return_value_policy<reference_existing_object>())
return_value_policy<reference_existing_object>())
.def("SetRunIDCounter", &G4RunManager::SetRunIDCounter)
#if G4VERSION_NUMBER >= 932
.def("GetVersionString", &G4RunManager::GetVersionString,
return_value_policy<reference_existing_object>())
.def("GetRandomNumberStoreDir", &G4RunManager::GetRandomNumberStoreDir,
return_internal_reference<>())
#else
.def("GetVersionString", &G4RunManager::GetVersionString)
.def("GetRandomNumberStoreDir", &G4RunManager::GetRandomNumberStoreDir)
#endif
;
// reduced functionality...
+121
View File
@@ -0,0 +1,121 @@
#!/usr/bin/python3
# ==================================================================
# python script for Geant4Py test
#
# gtest01
# - check basic control flow
# ==================================================================
from Geant4 import *
import gtest01
import random
# ==================================================================
# user actions in python
# ==================================================================
class MyPrimaryGeneratorAction(G4VUserPrimaryGeneratorAction):
"My Primary Generator Action"
def __init__(self):
G4VUserPrimaryGeneratorAction.__init__(self)
self.particleGun= G4ParticleGun(1)
def GeneratePrimaries(self, event):
#dx= random.gauss(0., 0.1)
dx=0.
self.particleGun.SetParticleMomentumDirection(G4ThreeVector(dx, 0., 1.))
self.particleGun.GeneratePrimaryVertex(event)
# ------------------------------------------------------------------
class MyRunAction(G4UserRunAction):
"My Run Action"
def BeginOfRunAction(self, run):
print("*** #event to be processed (BRA)=",
run.GetNumberOfEventToBeProcessed())
def EndOfRunAction(self, run):
print("*** run end run(ERA)=", run.GetRunID())
# ------------------------------------------------------------------
class MyEventAction(G4UserEventAction):
"My Event Action"
#def BeginOfEventAction(self, event):
#print("*** current event (BEA)=", event.GetEventID())
# pass
#def EndOfEventAction(self, event):
#print("*** current event (EEA)=", event.GetEventID())
# ------------------------------------------------------------------
class MySteppingAction(G4UserSteppingAction):
"My Stepping Action"
def UserSteppingAction(self, step):
#print("*** dE/dx in current step=", step.GetTotalEnergyDeposit())
track= step.GetTrack()
touchable= track.GetTouchable()
pv= touchable.GetVolume()
#print(pv.GetCopyNo())
#print(touchable.GetReplicaNumber(0))
# ------------------------------------------------------------------
class MyField(G4MagneticField):
"My Magnetic Field"
def GetFieldValue(self, pos, time):
bfield= G4ThreeVector()
bfield.x= 0.
bfield.y= 5.*tesla
bfield.z= 0.
return bfield
# ==================================================================
# main
# ==================================================================
qMaterials= gtest01.QMaterials()
qMaterials.Construct()
qDC= gtest01.QDetectorConstruction()
gRunManager.SetUserInitialization(qDC)
qPL= gtest01.QPhysicsList()
gRunManager.SetUserInitialization(qPL)
# set user actions...
#qPGA= gtest01.QPrimaryGeneratorAction()
myPGA= MyPrimaryGeneratorAction()
gRunManager.SetUserAction(myPGA)
#myRA= MyRunAction()
#gRunManager.SetUserAction(myRA)
myEA= MyEventAction()
gRunManager.SetUserAction(myEA)
mySA= MySteppingAction()
gRunManager.SetUserAction(mySA)
# set particle gun
#ApplyUICommand("/control/execute gun.mac")
#pg= qPGA.GetParticleGun()
pg= myPGA.particleGun
pg.SetParticleByName("e-")
pg.SetParticleEnergy(200.*MeV)
pg.SetParticlePosition(G4ThreeVector(0.,0.,-14.9)*cm)
# magnetic field
fieldMgr= gTransportationManager.GetFieldManager()
myField= G4UniformMagField(G4ThreeVector(0.,10.*tesla,0.))
#myField= MyField()
fieldMgr.SetDetectorField(myField)
fieldMgr.CreateChordFinder(myField)
gRunManager.Initialize()
# visualization
gControlExecute("vis.mac")
# beamOn
gRunManager.BeamOn(10)
+1 -1
View File
@@ -8,7 +8,7 @@
from Geant4 import *
import gtest01
import random
import thread
#import thread
# ==================================================================
# user actions in python
+133
View File
@@ -0,0 +1,133 @@
#!/usr/bin/python3
# ==================================================================
# python script for Geant4Py test
#
# gtest02
# - test for using site-module packages
# ==================================================================
from Geant4 import *
import g4py.Qmaterials, g4py.NISTmaterials
import g4py.Qgeom, g4py.ExN01geom, g4py.ExN03geom
import g4py.ExN01pl, g4py.EMSTDpl
import g4py.ParticleGun, g4py.MedicalBeam
# ==================================================================
# user setup
# ==================================================================
# ------------------------------------------------------------------
# Setup-0 (Q)
# ------------------------------------------------------------------
def Setup0():
# simple materials for Qgeom
g4py.Qmaterials.Construct()
# NIST materials
#g4py.NISTmaterials.Construct()
# normal way for constructing user geometry
#qDC= g4py.Qgeom.QDetectorConstruction()
#gRunManager.SetUserInitialization(qDC)
# 2nd way, short-cut way
g4py.Qgeom.Construct()
# primary
global primary_position, primary_direction
primary_position= G4ThreeVector(0.,0., -14.9*cm)
primary_direction= G4ThreeVector(0.2, 0., 1.)
# ------------------------------------------------------------------
# Setup-1 (ExampleN01)
# ------------------------------------------------------------------
def Setup1():
g4py.ExN01geom.Construct()
global primary_position, primary_direction
primary_position= G4ThreeVector(-2.5*m, 0., 0.)
primary_direction= G4ThreeVector(1., 0., 0.)
# ------------------------------------------------------------------
# Setup-3 (ExampleN03)
# ------------------------------------------------------------------
def Setup3():
#exN03geom= g4py.ExN03geom.ExN03DetectorConstruction()
#gRunManager.SetUserInitialization(exN03geom)
g4py.ExN03geom.Construct()
global primary_position, primary_direction
primary_position= G4ThreeVector(-1.*m, 0., 0.)
primary_direction= G4ThreeVector(1., 0., 0.)
# ==================================================================
# main
# ==================================================================
# ------------------------------------------------------------------
# randum number
# ------------------------------------------------------------------
rand_engine= Ranlux64Engine()
HepRandom.setTheEngine(rand_engine)
HepRandom.setTheSeed(20050830)
# ------------------------------------------------------------------
# user setup
# ------------------------------------------------------------------
Setup0()
#Setup1()
#Setup3()
# ------------------------------------------------------------------
# setup for physics list
# ------------------------------------------------------------------
# normal way for constructing user physics list
#exN01PL= ExN01PhysicsList.ExN01PhysicsList()
#gRunManager.SetUserInitialization(exN01PL)
# 2nd way, short-cut way
# geantino + transportation
#g4py.ExN01pl.Construct()
# electron/gamma standard EM
g4py.EMSTDpl.Construct()
# ------------------------------------------------------------------
# setup for primary generator action
# ------------------------------------------------------------------
# ------------
# Particle Gun
# ------------
# normal way for constructing user physics list
#pgPGA= g4py.ParticleGun.ParticleGunAction()
#gRunManager.SetUserAction(pgPGA)
#pg= pgPGA.GetParticleGun()
# 2nd way, short-cut way
pg= g4py.ParticleGun.Construct()
# set parameters of particle gun
pg.SetParticleByName("e-")
pg.SetParticleEnergy(300.*MeV)
pg.SetParticlePosition(primary_position)
pg.SetParticleMomentumDirection(primary_direction)
# ------------
# Medical Beam
# ------------
#beam= g4py.MedicalBeam.Construct()
# ------------------------------------------------------------------
# go...
# ------------------------------------------------------------------
gRunManager.Initialize()
# visualization
gApplyUICommand("/control/execute vis.mac")
# beamOn
#gRunManager.BeamOn(3)
+100
View File
@@ -0,0 +1,100 @@
#!/usr/bin/python3
# ==================================================================
# python script for Geant4Py test
#
# gtest02
# - test for using site-module packages
# ==================================================================
from Geant4 import *
import g4py.NISTmaterials
import g4py.ezgeom
from g4py.ezgeom import G4EzVolume
import g4py.EMSTDpl
import g4py.ParticleGun
# ==================================================================
# intialize
# ==================================================================
def Configure():
# ------------------------------------------------------------------
# setup for materials
# ------------------------------------------------------------------
# simple materials for Qgeom
g4py.NISTmaterials.Construct()
# ------------------------------------------------------------------
# setup for geometry
# ------------------------------------------------------------------
#g4py.Qgeom.Construct()
g4py.ezgeom.Construct() # initialize
# ------------------------------------------------------------------
# setup for physics list
# ------------------------------------------------------------------
g4py.EMSTDpl.Construct()
# ------------------------------------------------------------------
# setup for primary generator action
# ------------------------------------------------------------------
g4py.ParticleGun.Construct()
gControlExecute("gun.mac")
# ==================================================================
# constructing geometry
# ==================================================================
def ConstructGeom():
print("* Constructing geometry...")
# reset world material
air= G4Material.GetMaterial("G4_AIR")
g4py.ezgeom.SetWorldMaterial(air)
# target
global target
target= G4EzVolume("Target")
au= G4Material.GetMaterial("G4_Au")
target.CreateTubeVolume(au, 0., 1.*cm, 1.*mm)
target.PlaceIt(G4ThreeVector(0.,0.,-10.*cm))
# dummy box
global detector_box, detector_box_pv
detector_box= G4EzVolume("DetectorBox")
detector_box.CreateBoxVolume(air, 20.*cm, 20.*cm, 40.*cm)
detector_box_pv= detector_box.PlaceIt(G4ThreeVector(0.,0.,20.*cm))
# calorimeter
global cal
cal= G4EzVolume("Calorimeter")
nai= G4Material.GetMaterial("G4_SODIUM_IODIDE")
cal.CreateBoxVolume(nai, 5.*cm, 5.*cm, 30.*cm)
dd= 5.*cm
for ical in range(-1, 2):
calPos= G4ThreeVector(dd*ical, 0., 0.)
print(calPos)
cal.PlaceIt(calPos, ical+1, detector_box)
# ==================================================================
# main
# ==================================================================
# ------------------------------------------------------------------
# randum number
# ------------------------------------------------------------------
rand_engine= Ranlux64Engine()
HepRandom.setTheEngine(rand_engine)
HepRandom.setTheSeed(20050830)
# setup...
Configure()
ConstructGeom()
# ------------------------------------------------------------------
# go...
# ------------------------------------------------------------------
gRunManager.Initialize()
# visualization
gControlExecute("vis.mac")
# beamOn
#gRunManager.BeamOn(3)
+36
View File
@@ -0,0 +1,36 @@
#!/usr/bin/python3
# ==================================================================
# python script for Geant4Py test
#
# gtest04
# - test for command tree and command information
# ==================================================================
from Geant4 import *
def DumpTree(atree):
print("@@", atree.GetPathName(), "::", atree.GetTitle())
ntree= atree.GetTreeEntry()
ncommand= atree.GetCommandEntry()
for i in range(1, ncommand+1):
icommand= atree.GetCommand(i)
print(" **", icommand.GetCommandPath())
print(" ", icommand.GetTitle())
x= icommand.GetStateList()
nparameter= icommand.GetParameterEntries()
for j in range(0, nparameter):
iparam= icommand.GetParameter(j)
print(" +", iparam.GetParameterName(), iparam.GetParameterType())
for i in range(1, ntree+1):
itree= atree.GetTree(i)
DumpTree(itree)
# ==================================================================
# main
# ==================================================================
root_tree= gUImanager.GetTree()
DumpTree(root_tree)
+310
View File
@@ -0,0 +1,310 @@
#!/usr/bin/python3
# ==================================================================
# python script for Geant4Py test
#
# gtest05
# - test for CSG geometry construction in Python
# ==================================================================
from Geant4 import *
import g4py.ExN01pl, g4py.ParticleGun
import os, math
# ==================================================================
# user actions in python
# ==================================================================
class MyDetectorConstruction(G4VUserDetectorConstruction):
"My Detector Construction"
def __init__(self):
G4VUserDetectorConstruction.__init__(self)
self.air= gNistManager.FindOrBuildMaterial("G4_AIR")
self.lv_object= None
self.world= self.ConstructWorld()
self.va_red= G4VisAttributes(G4Color(1.,0.,0.))
self.va_cyan= G4VisAttributes(G4Color(0.,1.,1.))
self.va_green= G4VisAttributes(G4Color(0.,1.,0.))
self.va_blue= G4VisAttributes(G4Color(0.,0.,1.))
self.va_magenta= G4VisAttributes(G4Color(1.,0.,1.))
# -----------------------------------------------------------------
def ConstructWorld(self):
# Python has automatic garbage collection system.
# Geometry objects must be defined as GLOBAL not to be deleted.
global sld_world, lv_world, pv_world, va_world
sld_world= G4Box("world", 1.*m, 1.*m, 1.*m)
lv_world= G4LogicalVolume(sld_world, self.air, "world")
pv_world= G4PVPlacement(G4Transform3D(), lv_world, "world",
None, False, 0)
va_world= G4VisAttributes()
va_world.SetVisibility(False)
lv_world.SetVisAttributes(va_world)
# solid object (dummy)
global sld_sld, lv_sld, pv_sld
sld_sld= G4Box("dummy", 10.*cm, 10.*cm, 10.*cm)
self.lv_object= lv_sld= G4LogicalVolume(sld_sld, self.air, "dummy")
pv_sld= G4PVPlacement(None, G4ThreeVector(), "dummy", lv_sld,
pv_world, False, 0)
return pv_world
# -----------------------------------------------------------------
def ConstructBox(self):
global sld_box
sld_box= G4Box("box", 30.*cm, 40.*cm, 60.*cm)
self.lv_object.SetSolid(sld_box)
self.lv_object.SetVisAttributes(self.va_red)
gRunManager.GeometryHasBeenModified()
# -----------------------------------------------------------------
def ConstructTubs(self):
global sld_tubs
sld_tubs= G4Tubs("tubs", 10.*cm, 15.*cm, 20.*cm, 0., pi)
self.lv_object.SetSolid(sld_tubs)
self.lv_object.SetVisAttributes(self.va_cyan)
gRunManager.GeometryHasBeenModified()
# -----------------------------------------------------------------
def ConstructCons(self):
global sld_cons
sld_cons= G4Cons("cons", 5.*cm, 10.*cm, 20.*cm, 25.*cm,
40.*cm, 0., 4./3.*pi)
self.lv_object.SetSolid(sld_cons)
self.lv_object.SetVisAttributes(self.va_green)
gRunManager.GeometryHasBeenModified()
# -----------------------------------------------------------------
def ConstructPara(self):
global sld_para
sld_para= G4Para("para", 30.*cm, 40.*cm, 60.*cm, pi/4., pi/8., 0.)
self.lv_object.SetSolid(sld_para)
self.lv_object.SetVisAttributes(self.va_blue)
gRunManager.GeometryHasBeenModified()
# -----------------------------------------------------------------
def ConstructTrd(self):
global sld_trd
sld_trd= G4Trd("trd", 30.*cm, 10.*cm, 40.*cm, 15.*cm, 60.*cm)
self.lv_object.SetSolid(sld_trd)
self.lv_object.SetVisAttributes(self.va_blue)
gRunManager.GeometryHasBeenModified()
# -----------------------------------------------------------------
def ConstructTrap(self):
global sld_trap
sld_trap= G4Trap("trap", 60.*cm, 20.*degree, 5.*degree,
40.*cm, 30.*cm, 40.*cm, 10.*degree,
16.*cm, 10*cm, 14.*cm, 10.*deg)
self.lv_object.SetSolid(sld_trap)
self.lv_object.SetVisAttributes(self.va_green)
gRunManager.GeometryHasBeenModified()
# -----------------------------------------------------------------
def ConstructSphere(self):
global sld_sphere
sld_sphere= G4Sphere("sphere", 100.*cm, 120.*cm, 0., 180.*deg,
0., 180.*deg)
self.lv_object.SetSolid(sld_sphere)
self.lv_object.SetVisAttributes(self.va_cyan)
gRunManager.GeometryHasBeenModified()
# -----------------------------------------------------------------
def ConstructOrb(self):
global sld_orb
sld_orb= G4Orb("orb", 100.*cm)
self.lv_object.SetSolid(sld_orb)
self.lv_object.SetVisAttributes(self.va_red)
gRunManager.GeometryHasBeenModified()
# -----------------------------------------------------------------
def ConstructTorus(self):
global sld_torus
sld_torus= G4Torus("torus", 40.*cm, 60.*cm, 200.*cm, 0., 90.*deg)
self.lv_object.SetSolid(sld_torus)
self.lv_object.SetVisAttributes(self.va_magenta)
gRunManager.GeometryHasBeenModified()
# -----------------------------------------------------------------
def ConstructPolycone(self):
zvec= G4doubleVector()
rinvec= G4doubleVector()
routvec= G4doubleVector()
zvec[:]= [ 5.*cm, 7.*cm, 9.*cm, 11.*cm, 25.*cm, 27.*cm, 29.*cm,
31.*cm, 35.*cm ]
rinvec[:]= [0.,0.,0.,0.,0.,0.,0.,0.,0.]
routvec[:]= [ 0., 10.*cm, 10.*cm, 5.*cm, 5.*cm, 10.*cm,
10.*cm, 2.*cm, 2.*cm ]
global sld_pcon
sld_pcon= CreatePolycone("pcon", 0., twopi, 9, zvec, rinvec,routvec)
self.lv_object.SetSolid(sld_pcon)
self.lv_object.SetVisAttributes(self.va_cyan)
gRunManager.GeometryHasBeenModified()
# -----------------------------------------------------------------
def ConstructPolyhedra(self):
zvec= G4doubleVector()
rinvec= G4doubleVector()
routvec= G4doubleVector()
zvec[:]= [ 0., 5.*cm, 8.*cm, 13.*cm, 30.*cm, 32.*cm, 35.*cm ]
rinvec[:]= [0.,0.,0.,0.,0.,0.,0. ]
routvec[:]= [ 0., 15.*cm, 15.*cm, 4.*cm, 4.*cm, 10.*cm, 10.*cm ]
global sld_pgon
sld_pgon= CreatePolyhedra("pgon", 0., twopi, 5, 7, zvec, rinvec,routvec)
self.lv_object.SetSolid(sld_pgon)
self.lv_object.SetVisAttributes(self.va_green)
gRunManager.GeometryHasBeenModified()
# -----------------------------------------------------------------
def ConstructEllipticalTube(self):
global sld_et
sld_et= G4EllipticalTube("ellipticaltube", 5.*cm, 10.*cm, 20.*cm)
self.lv_object.SetSolid(sld_et)
self.lv_object.SetVisAttributes(self.va_cyan)
gRunManager.GeometryHasBeenModified()
# -----------------------------------------------------------------
def ConstructEllipsoid(self):
global sld_es
sld_es= G4Ellipsoid("ellipsoid", 10.*cm, 20.*cm, 50.*cm,
-10.*cm, 40.*cm)
self.lv_object.SetSolid(sld_es)
self.lv_object.SetVisAttributes(self.va_red)
gRunManager.GeometryHasBeenModified()
# -----------------------------------------------------------------
def ConstructEllipticalCone(self):
global sld_ec
sld_ec= G4EllipticalCone("ellipticalcone", 30.*cm, 60.*cm,
50.*cm, 25.*cm)
self.lv_object.SetSolid(sld_ec)
self.lv_object.SetVisAttributes(self.va_magenta)
gRunManager.GeometryHasBeenModified()
# -----------------------------------------------------------------
def ConstructHype(self):
global sld_hype
sld_hype= G4Hype("hype", 20.*cm, 30.*cm, 0.7, 0.7, 50.*cm)
self.lv_object.SetSolid(sld_hype)
self.lv_object.SetVisAttributes(self.va_blue)
gRunManager.GeometryHasBeenModified()
# -----------------------------------------------------------------
def ConstructTet(self):
global sld_tet
p1= G4ThreeVector(0., 0., math.sqrt(3.)*cm)
p2= G4ThreeVector(0., 2*math.sqrt(2./3.)*cm, -1./math.sqrt(3)*cm)
p3= G4ThreeVector(-math.sqrt(2.)*cm, -math.sqrt(2./3.)*cm,
-1./math.sqrt(3)*cm)
p4= G4ThreeVector(math.sqrt(2)*cm, -math.sqrt(2./3.)*cm,
-1./math.sqrt(3)*cm)
sld_tet= G4Tet("tet", 20.*p1, 20.*p2, 20.*p3, 20.*p4)
self.lv_object.SetSolid(sld_tet)
self.lv_object.SetVisAttributes(self.va_green)
gRunManager.GeometryHasBeenModified()
# -----------------------------------------------------------------
def ConstructTwistedBox(self):
global sld_twb
sld_twb= G4TwistedBox("twistedbox", 30.*deg, 30.*cm, 40.*cm, 60.*cm)
self.lv_object.SetSolid(sld_twb)
self.lv_object.SetVisAttributes(self.va_cyan)
gRunManager.GeometryHasBeenModified()
# -----------------------------------------------------------------
def ConstructTwistedTrap(self):
global sld_twtrp
sld_twtrp= G4TwistedTrap("twistedtrap", 30.*deg,
60.*cm, 20.*deg, 5.*deg,
40.*cm, 30.*cm, 40.*cm,
16.*cm, 10.*cm, 14.*cm, 10.*deg)
self.lv_object.SetSolid(sld_twtrp)
self.lv_object.SetVisAttributes(self.va_blue)
gRunManager.GeometryHasBeenModified()
# -----------------------------------------------------------------
def ConstructTwistedTrd(self):
global sld_twtrd
sld_twtrd= G4TwistedTrd("twistedtrd", 30.*cm, 10.*cm,
40.*cm, 15.*cm, 60.*cm, 30.*deg)
self.lv_object.SetSolid(sld_twtrd)
self.lv_object.SetVisAttributes(self.va_green)
gRunManager.GeometryHasBeenModified()
# -----------------------------------------------------------------
def ConstructTwistedTubs(self):
global sld_twt
sld_twt= G4TwistedTubs("twistedtube", 60.*deg,
10.*cm, 15.*cm, 20.*cm, 90.*deg)
self.lv_object.SetSolid(sld_twt)
self.lv_object.SetVisAttributes(self.va_magenta)
gRunManager.GeometryHasBeenModified()
# -----------------------------------------------------------------
def Construct(self): # return the world volume
return self.world
# ==================================================================
# main
# ==================================================================
os.environ["G4VRML_DEST_DIR"]= "."
os.environ["G4VRMLFILE_MAX_FILE_NUM"]= "1"
os.environ["G4VRMLFILE_VIEWER"]= "echo"
# set geometry
myDC= MyDetectorConstruction()
gRunManager.SetUserInitialization(myDC)
# minimal physics list
g4py.ExN01pl.Construct()
# set primary generator action
g4py.ParticleGun.Construct()
# initialize
gRunManager.Initialize()
# visualization
gApplyUICommand("/vis/open VRML2FILE")
gApplyUICommand("/vis/scene/create")
gApplyUICommand("/vis/scene/add/volume")
gApplyUICommand("/vis/sceneHandler/attach")
gApplyUICommand("/vis/scene/add/axes 0. 0. 0. 10. cm")
# create a vrml file for each solid type
f_list= (
("g4box", myDC.ConstructBox),
("g4tubs", myDC.ConstructTubs),
("g4cons", myDC.ConstructCons),
("g4para", myDC.ConstructPara),
("g4trd", myDC.ConstructTrd),
("g4trap", myDC.ConstructTrap),
("g4sphere", myDC.ConstructSphere),
("g4orb", myDC.ConstructOrb),
("g4torus", myDC.ConstructTorus),
("g4polycone", myDC.ConstructPolycone),
("g4polyhedra", myDC.ConstructPolyhedra),
("g4ellipticaltube", myDC.ConstructEllipticalTube),
("g4ellipsoid", myDC.ConstructEllipsoid),
("g4ellipticalcone", myDC.ConstructEllipticalCone),
("g4hype", myDC.ConstructHype),
("g4tet", myDC.ConstructTet),
("g4twistedbox", myDC.ConstructTwistedBox),
("g4twistedtrap", myDC.ConstructTwistedTrap),
("g4twistedtrd", myDC.ConstructTwistedTrd),
("g4twistedtubs", myDC.ConstructTwistedTubs)
)
for s,f in f_list:
f.__call__()
gRunManager.BeamOn(1)
fname= "%s.wrl" % (s)
os.rename("g4_00.wrl", fname)
@@ -19,7 +19,7 @@ Viewpoint {
coord Coordinate {
point [
0 0 1200,
310.583 0 1159.11,
310.583 2.1464e-307 1159.11,
300 80.3848 1159.11,
268.973 155.291 1159.11,
219.615 219.615 1159.11,
@@ -32,7 +32,7 @@ Viewpoint {
-268.973 155.291 1159.11,
-300 80.3848 1159.11,
-310.583 3.80354e-14 1159.11,
600 0 1039.23,
600 4.14653e-307 1039.23,
579.555 155.291 1039.23,
519.615 300 1039.23,
424.264 424.264 1039.23,
@@ -45,7 +45,7 @@ Viewpoint {
-519.615 300 1039.23,
-579.555 155.291 1039.23,
-600 7.34788e-14 1039.23,
848.528 0 848.528,
848.528 5.86408e-307 848.528,
819.615 219.615 848.528,
734.847 424.264 848.528,
600 600 848.528,
@@ -58,7 +58,7 @@ Viewpoint {
-734.847 424.264 848.528,
-819.615 219.615 848.528,
-848.528 1.03915e-13 848.528,
1039.23 0 600,
1039.23 7.182e-307 600,
1003.82 268.973 600,
900 519.615 600,
734.847 734.847 600,
@@ -71,7 +71,7 @@ Viewpoint {
-900 519.615 600,
-1003.82 268.973 600,
-1039.23 1.27269e-13 600,
1159.11 0 310.583,
1159.11 8.01048e-307 310.583,
1119.62 300 310.583,
1003.82 579.555 310.583,
819.615 819.615 310.583,
@@ -84,7 +84,7 @@ Viewpoint {
-1003.82 579.555 310.583,
-1119.62 300 310.583,
-1159.11 1.4195e-13 310.583,
1200 0 7.34788e-14,
1200 8.29306e-307 7.34788e-14,
1159.11 310.583 7.34788e-14,
1039.23 600 7.34788e-14,
848.528 848.528 7.34788e-14,
@@ -97,7 +97,7 @@ Viewpoint {
-1039.23 600 7.34788e-14,
-1159.11 310.583 7.34788e-14,
-1200 1.46958e-13 7.34788e-14,
1159.11 0 -310.583,
1159.11 8.01048e-307 -310.583,
1119.62 300 -310.583,
1003.82 579.555 -310.583,
819.615 819.615 -310.583,
@@ -110,7 +110,7 @@ Viewpoint {
-1003.82 579.555 -310.583,
-1119.62 300 -310.583,
-1159.11 1.4195e-13 -310.583,
1039.23 0 -600,
1039.23 7.182e-307 -600,
1003.82 268.973 -600,
900 519.615 -600,
734.847 734.847 -600,
@@ -123,7 +123,7 @@ Viewpoint {
-900 519.615 -600,
-1003.82 268.973 -600,
-1039.23 1.27269e-13 -600,
848.528 0 -848.528,
848.528 5.86408e-307 -848.528,
819.615 219.615 -848.528,
734.847 424.264 -848.528,
600 600 -848.528,
@@ -136,7 +136,7 @@ Viewpoint {
-734.847 424.264 -848.528,
-819.615 219.615 -848.528,
-848.528 1.03915e-13 -848.528,
600 0 -1039.23,
600 4.14653e-307 -1039.23,
579.555 155.291 -1039.23,
519.615 300 -1039.23,
424.264 424.264 -1039.23,
@@ -149,7 +149,7 @@ Viewpoint {
-519.615 300 -1039.23,
-579.555 155.291 -1039.23,
-600 7.34788e-14 -1039.23,
310.583 0 -1159.11,
310.583 2.1464e-307 -1159.11,
300 80.3848 -1159.11,
268.973 155.291 -1159.11,
219.615 219.615 -1159.11,
@@ -164,7 +164,7 @@ Viewpoint {
-310.583 3.80354e-14 -1159.11,
0 0 -1200,
0 0 1000,
258.819 0 965.926,
258.819 1.78867e-307 965.926,
250 66.9873 965.926,
224.144 129.41 965.926,
183.013 183.013 965.926,
@@ -177,7 +177,7 @@ Viewpoint {
-224.144 129.41 965.926,
-250 66.9873 965.926,
-258.819 3.16962e-14 965.926,
500 0 866.025,
500 3.45544e-307 866.025,
482.963 129.41 866.025,
433.013 250 866.025,
353.553 353.553 866.025,
@@ -190,7 +190,7 @@ Viewpoint {
-433.013 250 866.025,
-482.963 129.41 866.025,
-500 6.12323e-14 866.025,
707.107 0 707.107,
707.107 4.88673e-307 707.107,
683.013 183.013 707.107,
612.372 353.553 707.107,
500 500 707.107,
@@ -203,7 +203,7 @@ Viewpoint {
-612.372 353.553 707.107,
-683.013 183.013 707.107,
-707.107 8.65956e-14 707.107,
866.025 0 500,
866.025 5.985e-307 500,
836.516 224.144 500,
750 433.013 500,
612.372 612.372 500,
@@ -216,7 +216,7 @@ Viewpoint {
-750 433.013 500,
-836.516 224.144 500,
-866.025 1.06058e-13 500,
965.926 0 258.819,
965.926 6.6754e-307 258.819,
933.013 250 258.819,
836.516 482.963 258.819,
683.013 683.013 258.819,
@@ -229,7 +229,7 @@ Viewpoint {
-836.516 482.963 258.819,
-933.013 250 258.819,
-965.926 1.18292e-13 258.819,
1000 0 6.12323e-14,
1000 6.91088e-307 6.12323e-14,
965.926 258.819 6.12323e-14,
866.025 500 6.12323e-14,
707.107 707.107 6.12323e-14,
@@ -242,7 +242,7 @@ Viewpoint {
-866.025 500 6.12323e-14,
-965.926 258.819 6.12323e-14,
-1000 1.22465e-13 6.12323e-14,
965.926 0 -258.819,
965.926 6.6754e-307 -258.819,
933.013 250 -258.819,
836.516 482.963 -258.819,
683.013 683.013 -258.819,
@@ -255,7 +255,7 @@ Viewpoint {
-836.516 482.963 -258.819,
-933.013 250 -258.819,
-965.926 1.18292e-13 -258.819,
866.025 0 -500,
866.025 5.985e-307 -500,
836.516 224.144 -500,
750 433.013 -500,
612.372 612.372 -500,
@@ -268,7 +268,7 @@ Viewpoint {
-750 433.013 -500,
-836.516 224.144 -500,
-866.025 1.06058e-13 -500,
707.107 0 -707.107,
707.107 4.88673e-307 -707.107,
683.013 183.013 -707.107,
612.372 353.553 -707.107,
500 500 -707.107,
@@ -281,7 +281,7 @@ Viewpoint {
-612.372 353.553 -707.107,
-683.013 183.013 -707.107,
-707.107 8.65956e-14 -707.107,
500 0 -866.025,
500 3.45544e-307 -866.025,
482.963 129.41 -866.025,
433.013 250 -866.025,
353.553 353.553 -866.025,
@@ -294,7 +294,7 @@ Viewpoint {
-433.013 250 -866.025,
-482.963 129.41 -866.025,
-500 6.12323e-14 -866.025,
258.819 0 -965.926,
258.819 1.78867e-307 -965.926,
250 66.9873 -965.926,
224.144 129.41 -965.926,
183.013 183.013 -965.926,
+126
View File
@@ -0,0 +1,126 @@
#!/usr/bin/python3
# ==================================================================
# python script for Geant4Py test
#
# gtest06
# - test for constructing/visualizing boolean geoemtries
# ==================================================================
from Geant4 import *
import g4py.ExN01pl, g4py.ParticleGun
# ==================================================================
# user actions in python
# ==================================================================
class MyDetectorConstruction(G4VUserDetectorConstruction):
"My Detector Construction"
def __init__(self):
G4VUserDetectorConstruction.__init__(self)
self.air= gNistManager.FindOrBuildMaterial("G4_AIR")
self.lv_object= None
self.world= self.ConstructWorld()
self.va_red= G4VisAttributes(G4Color(1.,0.,0.))
self.va_cyan= G4VisAttributes(G4Color(0.,1.,1.))
self.va_green= G4VisAttributes(G4Color(0.,1.,0.))
self.va_blue= G4VisAttributes(G4Color(0.,0.,1.))
self.va_magenta= G4VisAttributes(G4Color(1.,0.,1.))
self.sld_box= G4Box("box",20.*cm, 20.*cm, 20.*cm);
self.sld_cyl= G4Tubs("cylinder",0., 10.*cm, 30.*cm, 0., twopi)
# -----------------------------------------------------------------
def ConstructWorld(self):
# Python has automatic garbage collection system.
# Geometry objects must be defined as GLOBAL not to be deleted.
global sld_world, lv_world, pv_world, va_world
sld_world= G4Box("world", 1.*m, 1.*m, 1.*m)
lv_world= G4LogicalVolume(sld_world, self.air, "world")
pv_world= G4PVPlacement(G4Transform3D(), lv_world, "world",
None, False, 0)
va_world= G4VisAttributes()
va_world.SetVisibility(False)
lv_world.SetVisAttributes(va_world)
# solid object (dummy)
global sld_sld, lv_sld, pv_sld
sld_sld= G4Box("dummy", 10.*cm, 10.*cm, 10.*cm)
self.lv_object= lv_sld= G4LogicalVolume(sld_sld, self.air, "dummy")
pv_sld= G4PVPlacement(None, G4ThreeVector(), "dummy", lv_sld,
pv_world, False, 0)
return pv_world
# -----------------------------------------------------------------
def ConstructUnion(self):
global sld_union
sld_union= G4UnionSolid("box+cylinder", self.sld_box, self.sld_cyl);
self.lv_object.SetSolid(sld_union)
self.lv_object.SetVisAttributes(self.va_blue)
gRunManager.GeometryHasBeenModified()
# -----------------------------------------------------------------
def ConstructIntersection(self):
offset= G4ThreeVector(20.*cm, 20.*cm, 0.)
global sld_intersection
sld_intersection= G4IntersectionSolid("box*cylinder",
self.sld_box, self.sld_cyl,
None, offset)
self.lv_object.SetSolid(sld_intersection)
self.lv_object.SetVisAttributes(self.va_magenta)
gRunManager.GeometryHasBeenModified()
# -----------------------------------------------------------------
def ConstructSubtraction(self):
global sld_subtraction
sld_subtraction= G4SubtractionSolid("box-cylinder",
self.sld_box, self.sld_cyl)
self.lv_object.SetSolid(sld_subtraction)
self.lv_object.SetVisAttributes(self.va_red)
gRunManager.GeometryHasBeenModified()
# -----------------------------------------------------------------
def Construct(self): # return the world volume
return self.world
# ==================================================================
# main
# ==================================================================
# set geometry
myDC= MyDetectorConstruction()
gRunManager.SetUserInitialization(myDC)
# minimal physics list
g4py.ExN01pl.Construct()
# set primary generator action
g4py.ParticleGun.Construct()
# initialize
gRunManager.Initialize()
# visualization
gApplyUICommand("/vis/open RayTracer")
gApplyUICommand("/vis/rayTracer/headAngle 40.")
gApplyUICommand("/vis/rayTracer/eyePosition 100 100 150 cm")
# create a vrml file for each solid type
f_list= (
("union", myDC.ConstructUnion),
("intersection", myDC.ConstructIntersection),
("subtraction", myDC.ConstructSubtraction)
)
for s,f in f_list:
f.__call__()
fname= "%s.jpg" % (s)
cmdstr= "/vis/rayTracer/trace " + fname
gApplyUICommand(cmdstr)
+80
View File
@@ -0,0 +1,80 @@
#!/usr/bin/python3
# ==================================================================
# python script for Geant4Py test
#
# gtest07
# - test for checking overlapped geometries
# ==================================================================
from Geant4 import *
import g4py.ExN01pl, g4py.ParticleGun
# ==================================================================
# user actions in python
# ==================================================================
class MyDetectorConstruction(G4VUserDetectorConstruction):
"My Detector Construction"
def __init__(self):
G4VUserDetectorConstruction.__init__(self)
# -----------------------------------------------------------------
def Construct(self):
# Python has automatic garbage collection system.
# Geometry objects must be defined as GLOBAL not to be deleted.
air= gNistManager.FindOrBuildMaterial("G4_AIR")
# world volume
global sld_world, lv_world, pv_world
sld_world= G4Box("world", 1.*m, 1.*m, 1.*m)
lv_world= G4LogicalVolume(sld_world, air, "world")
pv_world= G4PVPlacement(G4Transform3D(), lv_world, "world",
None, False, 0)
# box
global sld_box, lv_box, pv_box
sld_box= G4Box("box", 10.*cm, 10.*cm, 10.*cm);
lv_box= G4LogicalVolume(sld_box, air, "box")
pv_box= G4PVPlacement(None, G4ThreeVector(), "box", lv_box,
pv_world, False, 0, True)
# cylinder
global sld_cyl, lv_cyl, pv_cyl1, pv_cyl2, pv_cyl3
sld_cyl= G4Tubs("cylinder",0., 2.*cm, 2.*cm, 0., twopi)
lv_cyl= G4LogicalVolume(sld_cyl, air, "cylinder")
#
# the following placements are !! overlapped !!
#
# doubly placed
pv_cyl1= G4PVPlacement(None, G4ThreeVector(), "cylinder", lv_cyl,
pv_world, False, 0, True)
# overlaped
pv_cyl2= G4PVPlacement(None, G4ThreeVector(10.*cm,0.,0.),
"cylinder", lv_cyl,
pv_world, False, 1, True)
# sticked out
pv_cyl3= G4PVPlacement(None, G4ThreeVector(10.*cm,0.,0.),
"cylinder", lv_cyl,
pv_box, False, 0, True)
return pv_world
# ==================================================================
# main
# ==================================================================
# set geometry
myDC= MyDetectorConstruction()
gRunManager.SetUserInitialization(myDC)
# minimal physics list
g4py.ExN01pl.Construct()
# set primary generator action
g4py.ParticleGun.Construct()
# initialize
gRunManager.Initialize() # overlap should be detected !!
@@ -2,7 +2,7 @@
# ======================================================================
# A script for Geant4 autobuild
#
# Version 2.3.1 Dec 2008
# Version 2.4.2 Apr. 2010
#
# [usage]
# g4autobuild [<options>]
@@ -16,9 +16,6 @@
# ======================================================================
export LANG=C
IFS='
'
PATH=/bin:/usr/bin
export PATH
@@ -87,6 +84,7 @@ EOF
add_ui_envs() {
aui=$1
if [ $aui = TCSH -o $aui = GAG ]; then
# for bash
cat >> g4rc.sh <<EOF
export G4UI_USE_${aui}=1
@@ -96,6 +94,19 @@ EOF
cat >> g4rc.csh <<EOF
setenv G4UI_USE_${aui} 1
EOF
else
# for bash
cat >> g4rc.sh <<EOF
export G4UI_BUILD_${aui}_SESSION=1
export G4UI_USE_${aui}=1
EOF
# for csh
cat >> g4rc.csh <<EOF
setenv G4UI_BUILD_${aui}_SESSION 1
setenv G4UI_USE_${aui} 1
EOF
fi
}
@@ -187,6 +198,7 @@ clhepbase=`grep '^CLHEPBASE' $config | awk '{print $2}'`
geant4_set=`grep '^-' $config | awk '{print $2}'`
clhep_set=`grep '^-' $config | awk '{print $3}'`
xercescroot=`grep '^XERCESCROOT' $config | awk '{print $2}'`
qthome=`grep '^QTHOME' $config | awk '{print $2}'`
vis_set=`grep '^v' $config | awk '{print $2}'`
ui_set=`grep '^u' $config | awk '{print $2}'`
opt_set=`grep '^o' $config | awk '{print $2}'`
@@ -212,6 +224,13 @@ if [ $xercescroot ]; then
fi
fi
if [ $qthome ]; then
if [ ! -d $qthome ]; then
echo "*** abort :$qthome does not exist."
exit -1
fi
fi
# ======================================================================
# building Geant4
@@ -228,7 +247,7 @@ do
fi
set $clhep_set
clhep="clhep=\$$idx"
clhep="clhep=\${$idx}"
eval $clhep
pushd $g4dir > /dev/null 2>&1
@@ -266,6 +285,11 @@ if [ $xercescroot ]; then
add_ext_env XERCESCROOT $xercescroot
fi
if [ $qthome ]; then
envval=QTHOME
add_ext_env QTHOME $qthome
fi
cat >> g4rc.sh <<EOF
# ========================================================================
+2 -2
View File
@@ -8,7 +8,7 @@
export LANG=C
IFS='
'
'
PATH=/bin:/usr/bin
export PATH
@@ -231,7 +231,7 @@ if [ $enable_glib = 1 ]; then
fi
if [ $enable_slib = 1 ]; then
cp -pR $g4dir/$slibdir/$g4system/lib* $g4packdir/lib
cp -pR $g4dir/$slibdir/$g4system/lib* $g4packdir/lib
if [ $g4system = Darwin-g++ ]; then
if [ $enable_glib = 0 ]; then