Import Geant4 8.1.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-09 14:44:26 +02:00
parent 8a51e0bc40
commit 216a75eeb1
8717 changed files with 360418 additions and 141343 deletions
@@ -0,0 +1,60 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// $Id: EzDetectorConstruction.cc,v 1.3 2006/06/29 15:28:43 gunter Exp $
// $Name: geant4-08-01 $
// ====================================================================
// EzDetectorConstruction.cc
//
// 2005 Q
// ====================================================================
#include "EzDetectorConstruction.hh"
#include "G4EzWorld.hh"
// ====================================================================
//
// class description
//
// ====================================================================
////////////////////////////////////////////////
EzDetectorConstruction::EzDetectorConstruction()
////////////////////////////////////////////////
{
}
/////////////////////////////////////////////////
EzDetectorConstruction::~EzDetectorConstruction()
/////////////////////////////////////////////////
{
}
//////////////////////////////////////////////////////
G4VPhysicalVolume* EzDetectorConstruction::Construct()
//////////////////////////////////////////////////////
{
return G4EzWorld::GetWorldVolume();
}
@@ -0,0 +1,54 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// $Id: EzDetectorConstruction.hh,v 1.3 2006/06/29 15:28:46 gunter Exp $
// $Name: geant4-08-01 $
// ====================================================================
// EzDetectorConstruction.hh
//
// 2005 Q
// ====================================================================
#ifndef EZ_DETECTOR_CONSTRUCTION_H
#define EZ_DETECTOR_CONSTRUCTION_H
#include "G4VUserDetectorConstruction.hh"
// ====================================================================
//
// class definition
//
// ====================================================================
class EzDetectorConstruction : public G4VUserDetectorConstruction {
public:
EzDetectorConstruction();
~EzDetectorConstruction();
virtual G4VPhysicalVolume* Construct();
};
#endif
@@ -0,0 +1,44 @@
# $Id: GNUmakefile,v 1.2 2006/04/25 08:58:18 kmura Exp $
# $Name: geant4-08-01 $
# ===========================================================
# Makefile for building Geant4Py modules
# ===========================================================
include ../../../config/config.gmk
# -----------------------------------------------------------
# library
# -----------------------------------------------------------
SUBDIR := ezgeom
.PHONY: all cleanall
all:
@cd $(SUBDIR) && $(MAKE)
@$(MAKE) $(module_name)
installall:
@cd $(SUBDIR) && $(MAKE) install
@$(MAKE) install
cleanall:
@cd $(SUBDIR) && $(MAKE) clean
@-rm -f $(module_name)
@-rm -f *.o
# -----------------------------------------------------------
# module
# -----------------------------------------------------------
# python module name
PACKAGE := EZsim#
MODULE := EZgeom#
# location of exposured library
G4PY_EXLIB_LIBDIR := $(Q_LIBDIR)
include $(G4PY_INSTALL)/config/g4py.gmk
include $(G4PY_INSTALL)/config/module.gmk
include $(G4PY_INSTALL)/config/site-install.gmk
CXXFLAGS += -I./$(SUBDIR)
LOPT += -L./$(SUBDIR) -lezgeom
@@ -0,0 +1,313 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// $Id: G4EzVolume.cc,v 1.3 2006/06/29 15:28:52 gunter Exp $
// $Name: geant4-08-01 $
// ====================================================================
// G4EzVolume.cc
//
// 2005 Q
// ====================================================================
#include "G4Material.hh"
#include "G4Box.hh"
#include "G4Tubs.hh"
#include "G4Cons.hh"
#include "G4Sphere.hh"
#include "G4Orb.hh"
#include "G4PVPlacement.hh"
#include "G4PVReplica.hh"
#include "G4PVParameterised.hh"
#include "G4VisAttributes.hh"
#include "G4EzWorld.hh"
#include "G4EzVolume.hh"
#include "G4EzVoxelParameterization.hh"
// ====================================================================
//
// class description
//
// ====================================================================
////////////////////////
G4EzVolume::G4EzVolume()
: name("MyVolume"),
solid(0),
lv(0), lvsub(0),
nplacement(0)
////////////////////////
{
}
/////////////////////////////////////////////
G4EzVolume::G4EzVolume(const G4String& aname)
: name(aname), solid(0), lv(0), lvsub(0),
nplacement(0)
/////////////////////////////////////////////
{
}
/////////////////////////
G4EzVolume::~G4EzVolume()
/////////////////////////
{
}
///////////////////////////////////////////////////////////////////////
void G4EzVolume::CreateBoxVolume(G4Material* amaterial,
G4double dx, G4double dy, G4double dz)
///////////////////////////////////////////////////////////////////////
{
if(lv !=0 ) {
G4cout << "%%% Warning (G4EzVolume): volume is already created."
<< G4endl;
return;
}
solid= new G4Box(name, dx/2., dy/2., dz/2.);
lv= new G4LogicalVolume(solid, amaterial, name);
// vis. attributes
va= new G4VisAttributes();
lv-> SetVisAttributes(va);
}
////////////////////////////////////////////////////////////////////////////
void G4EzVolume::CreateTubeVolume(G4Material* amaterial,
G4double rmin, G4double rmax, G4double dz,
G4double phi0, G4double dphi)
////////////////////////////////////////////////////////////////////////////
{
if(lv !=0 ) {
G4cout << "%%% Warning (G4EzVolume): volume is already created."
<< G4endl;
return;
}
solid= new G4Tubs(name, rmin, rmax, dz, phi0, dphi);
lv= new G4LogicalVolume(solid, amaterial, name);
// vis. attributes
va= new G4VisAttributes();
lv-> SetVisAttributes(va);
}
/////////////////////////////////////////////////////////////////
void G4EzVolume::CreateConeVolume(G4Material* amaterial,
G4double rmin1, G4double rmax1,
G4double rmin2, G4double rmax2,
G4double dz,
G4double phi0, G4double dphi)
/////////////////////////////////////////////////////////////////
{
if(lv !=0 ) {
G4cout << "%%% Warning (G4EzVolume): volume is already created."
<< G4endl;
return;
}
solid= new G4Cons(name, rmin1, rmax1, rmin2, rmax2,
dz, phi0, dphi);
lv= new G4LogicalVolume(solid, amaterial, name);
// vis. attributes
va= new G4VisAttributes();
lv-> SetVisAttributes(va);
}
/////////////////////////////////////////////////////////////////////
void G4EzVolume::CreateSphereVolume(G4Material* amaterial,
G4double rmin, G4double rmax,
G4double phi0, G4double dphi,
G4double theta0, G4double dtheta)
/////////////////////////////////////////////////////////////////////
{
if(lv !=0 ) {
G4cout << "%%% Warning (G4EzVolume): volume is already created."
<< G4endl;
return;
}
solid= new G4Sphere(name, rmin, rmax, phi0, dphi, theta0, dtheta);
lv= new G4LogicalVolume(solid, amaterial, name);
// vis. attributes
va= new G4VisAttributes();
lv-> SetVisAttributes(va);
}
//////////////////////////////////////////////////////////////////////
void G4EzVolume::CreateOrbVolume(G4Material* amaterial, G4double rmax)
//////////////////////////////////////////////////////////////////////
{
if(lv !=0 ) {
G4cout << "%%% Warning (G4EzVolume): volume is already created."
<< G4endl;
return;
}
solid= new G4Orb(name, rmax);
lv= new G4LogicalVolume(solid, amaterial, name);
// vis. attributes
va= new G4VisAttributes();
lv-> SetVisAttributes(va);
}
////////////////////////////////////////////////////////////////
G4VPhysicalVolume* G4EzVolume::PlaceIt(const G4ThreeVector& pos,
G4int ncopy,
G4EzVolume* parent)
////////////////////////////////////////////////////////////////
{
if(lv==0) {
G4cout << "%%% Warning (G4EzVolume): volume is not yet created."
<< G4endl;
return 0;
}
G4PVPlacement* pv;
if(parent==0) { // place it in the world
G4VPhysicalVolume* world= G4EzWorld::GetWorldVolume();
pv= new G4PVPlacement(0, pos, name, lv, world, false, ncopy);
} else {
pv= new G4PVPlacement(0, pos, lv, name, parent->lv, false, ncopy);
}
nplacement++;
return pv;
}
//////////////////////////////////////////////////////////////////////
G4VPhysicalVolume* G4EzVolume::PlaceIt(const G4Transform3D& transform,
G4int ncopy,
G4EzVolume* parent)
//////////////////////////////////////////////////////////////////////
{
if(lv==0) {
G4cout << "%%% Warning (G4EzVolume): volume is not yet created."
<< G4endl;
return 0;
}
G4PVPlacement* pv;
if(parent==0) { // place it in the world
G4VPhysicalVolume* world= G4EzWorld::GetWorldVolume();
pv= new G4PVPlacement(transform, name, lv, world, false, ncopy);
} else {
pv= new G4PVPlacement(transform, lv, name, parent->lv, false, ncopy);
}
nplacement++;
return pv;
}
///////////////////////////////////////////////////////////////////////////
G4VPhysicalVolume* G4EzVolume::ReplicateIt(G4EzVolume* parent,
EAxis pAxis, G4int nReplicas,
G4double width, G4double offset)
///////////////////////////////////////////////////////////////////////////
{
if(lv==0) {
G4cout << "%%% Warning (G4EzVolume): volume is not yet created."
<< G4endl;
return 0;
}
G4PVReplica* pv=
new G4PVReplica(name, lv, parent->lv, pAxis, nReplicas, width, offset);
nplacement += nReplicas;
return pv;
}
//////////////////////////////////////////////////////////////////
G4ThreeVector G4EzVolume::VoxelizeIt(G4int nx, G4int ny, G4int nz)
//////////////////////////////////////////////////////////////////
{
// creating voxel volume...
G4Box* avolume= dynamic_cast<G4Box*>(solid);
if(avolume ==0 ) {
G4cout << "%%% Error (G4EzVolume): voxelization is valid "
<< "only for Box geometry." << G4endl;
return G4ThreeVector();
}
if(lvsub !=0) {
G4cout << "%%% Error (G4EzVolume): already voxelized." << G4endl;
return G4ThreeVector();
}
G4double dx= (avolume-> GetXHalfLength())*2.;
G4double dy= (avolume-> GetYHalfLength())*2.;
G4double dz= (avolume-> GetZHalfLength())*2.;
// voxel size
G4double ddx= dx/nx;
G4double ddy= dy/ny;
G4double ddz= dz/nz;
G4Box* voxel= new G4Box("voxel", ddx/2., ddy/2., ddz/2.);
G4Material* voxelMaterial= lv-> GetMaterial();
lvsub= new G4LogicalVolume(voxel, voxelMaterial, "voxel");
G4VisAttributes* vavoxel= new G4VisAttributes(G4Color(1.,0.,0.));
lvsub-> SetVisAttributes(vavoxel);
G4EzVoxelParameterization* voxelParam=
new G4EzVoxelParameterization(ddx, ddy, ddz, nx, ny, nz);
G4int nvoxel= nx*ny*nz;
new G4PVParameterised(name+"_voxel", lvsub, lv, kXAxis,
nvoxel, voxelParam);
return G4ThreeVector(ddx, ddy, ddz);
}
////////////////////////////////////////////////////////////////
void G4EzVolume::SetSensitiveDetector(G4VSensitiveDetector* asd)
////////////////////////////////////////////////////////////////
{
if(lvsub!=0) {
lvsub-> SetSensitiveDetector(asd);
return;
}
if(lv!=0) lv-> SetSensitiveDetector(asd);
}
@@ -0,0 +1,167 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// $Id: G4EzVolume.hh,v 1.3 2006/06/29 15:28:55 gunter Exp $
// $Name: geant4-08-01 $
// ====================================================================
// G4EzVolume.hh
//
// Utility class for supporting creating user geometry
//
// * wrapper of logical volume
//
// 2005 Q
// ====================================================================
#ifndef G4_EZ_VOLUME_H
#define G4_EZ_VOLUME_H
#include "G4LogicalVolume.hh"
#include "G4VisAttributes.hh"
#include "G4Transform3D.hh"
// ====================================================================
//
// class definition
//
// ====================================================================
class G4Material;
class G4VSolid;
class G4VPhysicalVolume;
class G4EzVolume {
protected:
// volume information
G4String name;
G4VSolid* solid;
G4LogicalVolume* lv;
G4LogicalVolume* lvsub; // logical volume for voxels
G4VisAttributes* va;
G4int nplacement; // # of placements
public:
G4EzVolume();
G4EzVolume(const G4String& aname);
~G4EzVolume();
// createing volume
void CreateBoxVolume(G4Material* amaterial,
G4double dx, G4double dy, G4double dz);
void CreateTubeVolume(G4Material* amaterial,
G4double rmin, G4double rmax,
G4double dz,
G4double phi0=0., G4double dphi=360*deg);
void CreateConeVolume(G4Material* amaterial,
G4double rmin1, G4double rmax1,
G4double rmin2, G4double rmax2,
G4double dz,
G4double phi0=0., G4double dphi=360.*deg);
void CreateSphereVolume(G4Material* amaterial,
G4double rmin, G4double rmax,
G4double phi0=0., G4double dphi=360.*deg,
G4double theta0=0., G4double dtheta=180.*deg);
void CreateOrbVolume(G4Material* amaterial, G4double rmax);
// placement
G4VPhysicalVolume* PlaceIt(const G4ThreeVector& pos, G4int ncopy=0,
G4EzVolume* parent=0);
G4VPhysicalVolume* PlaceIt(const G4Transform3D& transform, G4int ncopy=0,
G4EzVolume* parent=0);
// replica
// parent volume should be exactly filled with replicated volumes.
G4VPhysicalVolume* ReplicateIt(G4EzVolume* parent,
EAxis pAxis, G4int nReplicas,
G4double width, G4double offset=0);
// voxelize
// volume should be "BOX". otherwise, error.
// returning voxel size in each dimension
G4ThreeVector VoxelizeIt(G4int nx, G4int ny, G4int nz);
// sensitivity
// in the case of voxelized, SD will be set to a voxel.
void SetSensitiveDetector(G4VSensitiveDetector* asd);
// direct access to properties
const G4String& GetName() const;
void SetSolid(G4VSolid* asolid);
const G4VSolid* GetSolid() const;
void SetMaterial(G4Material* amaterial);
G4Material* GetMaterial() const;
G4int GetNofPlacements() const;
void SetVisibility(G4bool qvisible);
void SetColor(const G4Color& color);
void SetColor(G4double red, G4double green, G4double blue);
};
// ====================================================================
// inline functions
// ====================================================================
inline const G4String& G4EzVolume::GetName() const { return name; }
inline void G4EzVolume::SetSolid(G4VSolid* asolid) { solid= asolid; }
inline const G4VSolid* G4EzVolume::GetSolid() const { return solid; }
inline void G4EzVolume::SetMaterial(G4Material* amaterial)
{
if(lv!= 0) lv-> SetMaterial(amaterial);
if(lvsub!= 0) lvsub-> SetMaterial(amaterial);
}
inline G4Material* G4EzVolume::GetMaterial() const
{
if(lv!=0) return lv-> GetMaterial();
else return 0;
}
inline G4int G4EzVolume::GetNofPlacements() const { return nplacement; }
inline void G4EzVolume::SetVisibility(G4bool qvisible)
{
if(va!=0) va-> SetVisibility(qvisible);
}
inline void G4EzVolume::SetColor(const G4Color& color)
{
if(va!=0) va-> SetColor(color);
}
inline void G4EzVolume::SetColor(G4double red, G4double green, G4double blue)
{
if(va!=0) va-> SetColor(red, green, blue);
}
#endif
@@ -0,0 +1,91 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// $Id: G4EzVoxelParameterization.cc,v 1.3 2006/06/29 15:28:58 gunter Exp $
// $Name: geant4-08-01 $
// ====================================================================
// G4EzVoxelParameterization.cc
//
// 2005 Q
// ====================================================================
#include "G4EzVoxelParameterization.hh"
#include "G4Box.hh"
#include "G4VPhysicalVolume.hh"
// ====================================================================
//
// class description
//
// ====================================================================
//////////////////////////////////////////////////////////////////////////
G4EzVoxelParameterization::G4EzVoxelParameterization
(G4double ddx, G4double ddy, G4double ddz, G4int nx, G4int ny, G4int nz)
: voxelSize(ddx, ddy, ddz), motherSize(ddx*nx, ddy*ny, ddz*nz)
//////////////////////////////////////////////////////////////////////////
{
nvoxels[0]= nx;
nvoxels[1]= ny;
nvoxels[2]= nz;
}
///////////////////////////////////////////////////////
G4EzVoxelParameterization::~G4EzVoxelParameterization()
///////////////////////////////////////////////////////
{
}
///////////////////////////////////////////////////////////
void G4EzVoxelParameterization::ComputeTransformation
(const G4int copyNo, G4VPhysicalVolume* physVol) const
///////////////////////////////////////////////////////////
{
// copyNo-> index
G4int nxy= nvoxels[0]*nvoxels[1];
G4int iz= copyNo/nxy;
G4int ixy= copyNo - iz*nxy;
G4int iy= ixy/nvoxels[0];
G4int ix= ixy-iy*nvoxels[0];
// voxel position
G4double px= voxelSize[0]*(ix+0.5) - motherSize[0]/2.;
G4double py= voxelSize[1]*(iy+0.5) - motherSize[1]/2.;
G4double pz= voxelSize[2]*(iz+0.5) - motherSize[2]/2.;
physVol-> SetTranslation(G4ThreeVector(px, py, pz));
}
//////////////////////////////////////////////////////////////////////////////
void G4EzVoxelParameterization::ComputeDimensions
(G4Box& aBox, const G4int copyNo, const G4VPhysicalVolume* physVol) const
//////////////////////////////////////////////////////////////////////////////
{
return;
}
@@ -0,0 +1,64 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// $Id: G4EzVoxelParameterization.hh,v 1.3 2006/06/29 15:29:01 gunter Exp $
// $Name: geant4-08-01 $
// ====================================================================
// G4EzVoxelParameterization.hh
//
// 2005 Q
// ====================================================================
#ifndef G4EZ_VOXEL_PARAMETERIZATION_H
#define G4EZ_VOXEL_PARAMETERIZATION_H
#include "G4VPVParameterisation.hh"
#include "G4ThreeVector.hh"
// ====================================================================
//
// class definition
//
// ====================================================================
class G4EzVoxelParameterization : public G4VPVParameterisation {
protected:
G4ThreeVector voxelSize;
G4ThreeVector motherSize;
G4int nvoxels[3];
public:
G4EzVoxelParameterization(G4double ddx, G4double ddy, G4double ddz,
G4int nx, G4int ny, G4int nz);
~G4EzVoxelParameterization();
virtual void ComputeTransformation(const G4int copyNo,
G4VPhysicalVolume* physVol) const;
virtual void ComputeDimensions(G4Box& aBox, const G4int copyNo,
const G4VPhysicalVolume* physVol) const;
};
#endif
@@ -0,0 +1,143 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// $Id: G4EzWorld.cc,v 1.3 2006/06/29 15:29:04 gunter Exp $
// $Name: geant4-08-01 $
// ====================================================================
// G4EzWorld.cc
//
// 2005 Q
// ====================================================================
#include "G4EzWorld.hh"
#include "G4Element.hh"
#include "G4Material.hh"
#include "G4Box.hh"
#include "G4LogicalVolume.hh"
#include "G4PVPlacement.hh"
#include "G4VisAttributes.hh"
#include "G4RunManager.hh"
#include "G4Version.hh"
G4VPhysicalVolume* G4EzWorld::world= G4EzWorld::CreateWorld();
// ====================================================================
//
// class description
//
// ====================================================================
//////////////////////
G4EzWorld::G4EzWorld()
//////////////////////
{
}
///////////////////////
G4EzWorld::~G4EzWorld()
///////////////////////
{
world= 0;
}
//////////////////////////////////////////////////////////
G4VPhysicalVolume* G4EzWorld::CreateWorld
(G4double dx, G4double dy, G4double dz)
//////////////////////////////////////////////////////////
{
// default matetial is "vacuum"
#if G4VERSION_NUMBER >= 800
G4Material* vacuum= G4Material::GetMaterial("_Vacuum", false);
#else
G4Material* vacuum= G4Material::GetMaterial("_Vacuum");
#endif
if(vacuum==0) {
G4Element* elN= new G4Element("_N", "", 7., 14.00674*g/mole);
G4Element* elO= new G4Element("_O", "", 8., 15.9994*g/mole);
vacuum= new G4Material("_Vacuum", universe_mean_density, 2);
vacuum-> AddElement(elN, 0.7);
vacuum-> AddElement(elO, 0.3);
}
G4Box* sdworld= new G4Box("world", dx/2., dy/2., dz/2.);
G4LogicalVolume* lvworld= new G4LogicalVolume(sdworld, vacuum, "word");
G4PVPlacement* aworld= new G4PVPlacement(0, G4ThreeVector(), "world",
lvworld, 0, false, 0);
// vis. attributes
G4VisAttributes* vaworld= new G4VisAttributes(G4Color(1.,1.,1.));
vaworld-> SetForceWireframe(true);
lvworld-> SetVisAttributes(vaworld);
return aworld;
}
////////////////////////////////////////////////////////////
void G4EzWorld::Reset(G4double dx, G4double dy, G4double dz)
////////////////////////////////////////////////////////////
{
delete world;
world= CreateWorld(dx, dy, dz);
G4RunManager* runManager= G4RunManager::GetRunManager();
runManager-> DefineWorldVolume(world);
}
/////////////////////////////////////////////////////////////
void G4EzWorld::Resize(G4double dx, G4double dy, G4double dz)
/////////////////////////////////////////////////////////////
{
G4Box* box= dynamic_cast<G4Box*>(world-> GetLogicalVolume()-> GetSolid());
box-> SetXHalfLength(dx/2.);
box-> SetYHalfLength(dy/2.);
box-> SetZHalfLength(dz/2.);
G4RunManager* runManager= G4RunManager::GetRunManager();
runManager-> GeometryHasBeenModified();
}
//////////////////////////////////////////////////
void G4EzWorld::SetMaterial(G4Material* amaterial)
//////////////////////////////////////////////////
{
world-> GetLogicalVolume()-> SetMaterial(amaterial);
}
//////////////////////////////////////////
void G4EzWorld::SetVisibility(G4bool qvis)
//////////////////////////////////////////
{
G4VisAttributes* vaworld= const_cast<G4VisAttributes*>(
world-> GetLogicalVolume()-> GetVisAttributes());
vaworld-> SetVisibility(qvis);
}
@@ -0,0 +1,76 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// $Id: G4EzWorld.hh,v 1.3 2006/06/29 15:29:07 gunter Exp $
// $Name: geant4-08-01 $
// ====================================================================
// G4EzWorld.hh
//
// Utility class for supporting creating user geometry
//
// management of a world volume
//
// 2005 Q
// ====================================================================
#ifndef G4_EZ_WORLD_H
#define G4_EZ_WORLD_H
#include "globals.hh"
// ====================================================================
//
// class definition
//
// ====================================================================
class G4Material;
class G4VPhysicalVolume;
class G4EzWorld {
protected:
// world volume is automatically presented.
static G4VPhysicalVolume* world;
static G4VPhysicalVolume* CreateWorld(G4double dx=1.*m,
G4double dy=1.*m,
G4double dz=1.*m);
public:
G4EzWorld();
~G4EzWorld();
static G4VPhysicalVolume* GetWorldVolume();
static void Reset(G4double dx, G4double dy, G4double dz);
static void Resize(G4double dx, G4double dy, G4double dz);
static void SetMaterial(G4Material* amaterial);
static void SetVisibility(G4bool qvis);
};
// ====================================================================
// inline functions
// ====================================================================
inline G4VPhysicalVolume* G4EzWorld::GetWorldVolume() { return world; }
#endif
@@ -0,0 +1,17 @@
# $Id: GNUmakefile,v 1.1 2006/04/25 09:00:01 kmura Exp $
# $Name: geant4-08-01 $
# ===========================================================
# Makefile for building Geant4Py site-modules
# ===========================================================
include ../../../../config/config.gmk
MODULE := libezgeom#
include $(G4PY_INSTALL)/config/g4py.gmk
include $(G4PY_INSTALL)/config/module.gmk
install:
@echo ... intall $(lib_name) into $(Q_LIBDIR)
@if [ ! -d $(Q_LIBDIR) ]; then install -d $(Q_LIBDIR); fi
@install -m 755 $(MODULE).$(soext) $(Q_LIBDIR)
@@ -0,0 +1,160 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// $Id: pyEzgeom.cc,v 1.3 2006/06/29 15:28:49 gunter Exp $
// $Name: geant4-08-01 $
// ====================================================================
// pyEZgeom.cc
//
// [EZgeom]
// a site-module of Geant4Py
//
// An easy way to build geometry
//
// 2005 Q
// ====================================================================
#include <boost/python.hpp>
#include "EzDetectorConstruction.hh"
#include "G4EzWorld.hh"
#include "G4EzVolume.hh"
#include "G4RunManager.hh"
#include "G4VSensitiveDetector.hh"
using namespace boost::python;
// ====================================================================
// thin wrappers
// ====================================================================
namespace pyEZgeom {
// methods in global namespace
void Construct()
{
G4RunManager* runMgr= G4RunManager::GetRunManager();
runMgr-> SetUserInitialization(new EzDetectorConstruction);
}
void ResetWorld(G4double dx, G4double dy, G4double dz)
{
G4EzWorld::Reset(dx, dy, dz);
}
void ResizeWorld(G4double dx, G4double dy, G4double dz)
{
G4EzWorld::Resize(dx, dy, dz);
}
void SetWorldMaterial(G4Material* amaterial)
{
G4EzWorld::SetMaterial(amaterial);
}
void SetWorldVisibility(G4bool qvis)
{
G4EzWorld::SetVisibility(qvis);
}
// CreateTubeVolume
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_CreateTubeVolume,
CreateTubeVolume, 4, 6);
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_CreateConeVolume,
CreateConeVolume, 6, 8);
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_CreateSphereVolume,
CreateSphereVolume, 3, 7);
// PlaceIt
G4VPhysicalVolume*(G4EzVolume::*f1_PlaceIt)
(const G4ThreeVector&, G4int, G4EzVolume*) = &G4EzVolume::PlaceIt;
G4VPhysicalVolume*(G4EzVolume::*f2_PlaceIt)
(const G4Transform3D&, G4int, G4EzVolume*) = &G4EzVolume::PlaceIt;
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_PlaceIt, PlaceIt, 1, 3);
// ReplicateIt
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_ReplicateIt, ReplicateIt, 4, 5);
// SetColor
void (G4EzVolume::*f1_SetColor)(const G4Color&) = &G4EzVolume::SetColor;
void (G4EzVolume::*f2_SetColor)(G4double, G4double, G4double)
= &G4EzVolume::SetColor;
};
using namespace pyEZgeom;
// ====================================================================
// Expose to Python
// ====================================================================
BOOST_PYTHON_MODULE(EZgeom) {
class_<G4EzVolume>("G4EzVolume", "an easy way of geometry configuration")
.def(init<const G4String&>())
// ---
.def("CreateBoxVolume", &G4EzVolume::CreateBoxVolume)
.def("CreateTubeVolume", &G4EzVolume::CreateTubeVolume,
f_CreateTubeVolume())
.def("CreateConeVolume", &G4EzVolume::CreateConeVolume,
f_CreateConeVolume())
.def("CreateShpereVolume", &G4EzVolume::CreateSphereVolume,
f_CreateSphereVolume())
.def("CreateOrbVolume", &G4EzVolume::CreateOrbVolume)
// ---
.def("SetSold", &G4EzVolume::SetSolid)
.def("GetSold", &G4EzVolume::GetSolid,
return_value_policy<reference_existing_object>())
.def("SetMaterial", &G4EzVolume::SetMaterial)
.def("GetMaterial", &G4EzVolume::GetMaterial,
return_value_policy<reference_existing_object>())
// ---
.def("PlaceIt", f1_PlaceIt,
f_PlaceIt()[return_value_policy<reference_existing_object>()])
.def("PlaceIt", f2_PlaceIt,
f_PlaceIt()[return_value_policy<reference_existing_object>()])
.def("ReplicateIt", &G4EzVolume::ReplicateIt,
f_ReplicateIt()[return_value_policy<reference_existing_object>()])
.def("VoxelizeIt", &G4EzVolume::VoxelizeIt)
// ---
.def("SetSensitiveDetector", &G4EzVolume::SetSensitiveDetector)
// ---
.def("SetColor", f1_SetColor)
.def("SetColor", f2_SetColor)
.def("SetVisibility", &G4EzVolume::SetVisibility)
;
// -------------------------------------------------------------------
def("Construct", Construct);
def("ResetWorld", ResetWorld);
def("ResizeWorld", ResizeWorld);
def("SetWorldMaterial", SetWorldMaterial);
def("SetWorldVisibility", SetWorldVisibility);
}
@@ -0,0 +1,24 @@
# $Id: GNUmakefile,v 1.2 2006/04/25 10:17:30 kmura Exp $
# $Name: geant4-08-01 $
# ===========================================================
# Makefile for building Geant4Py site-modules
# ===========================================================
#SUBDIR := EZdetector EZgeom python
SUBDIR := python
SUBDIR2 := EZgeom
.PHONY: all install clean cleanlib
all:
@for dir in $(SUBDIR); do (cd $$dir && $(MAKE)); done;:
@for dir in $(SUBDIR2); do (cd $$dir && $(MAKE)); done;:
install:
@for dir in $(SUBDIR); do (cd $$dir && $(MAKE) install); done;:
@for dir in $(SUBDIR2); do (cd $$dir && $(MAKE) installall); done;:
clean:
@for dir in $(SUBDIR); do (cd $$dir && $(MAKE) clean); done;:
@for dir in $(SUBDIR2); do (cd $$dir && $(MAKE) cleanall); done;:
@@ -0,0 +1,29 @@
# $Id: GNUmakefile,v 1.3 2006/06/14 08:23:52 kmura Exp $
# $Name: geant4-08-01 $
# ===========================================================
# Makefile for building Geant4Py modules
# ===========================================================
include ../../../config/config.gmk
include $(G4PY_INSTALL)/config/g4py.gmk
include $(G4PY_INSTALL)/config/sys/$(Q_SYSTEM).gmk
install_dir := $(Q_LIBDIR)/EZsim
pys := $(wildcard *.py)
pycs := $(patsubst %.py, %.pyc, $(pys))
pyos := $(patsubst %.py, %.pyo, $(pys))
.PHONY: clean
all: $(pycs) $(pyos)
install: $(pycs) $(pyos)
@echo ... intall "*.py" into $(install_dir)
@if [ ! -d $(install_dir) ]; then install -d $(install_dir); fi
@install -m 755 $(pys) $(pycs) $(pyos) $(install_dir)
clean:
@-\rm -f $(pycs) $(pyos)
@@ -0,0 +1,20 @@
# $Id: __init__.py,v 1.1 2006/02/27 09:46:31 kmura Exp $
"""
# ==================================================================
# [EZsim]
# a site-module of Geant4Py
#
# A package for easy simulation
#
# ==================================================================
"""
# ==================================================================
# import submodules
# ==================================================================
import EZgeom
#import EZdetector
# ==================================================================
# globals, which start with "g"
# ==================================================================