Import Geant4 10.6.2 source tree
This commit is contained in:
@@ -1,46 +1,5 @@
|
||||
# - add tests components
|
||||
|
||||
set(TEST_MODULES_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}/tests)
|
||||
|
||||
# tests for boost_python
|
||||
add_subdirectory(test00/module)
|
||||
add_subdirectory(test01/module)
|
||||
add_subdirectory(test02/module)
|
||||
add_subdirectory(test03/module EXCLUDE_FROM_ALL)
|
||||
add_subdirectory(test04/module)
|
||||
add_subdirectory(test05/module)
|
||||
add_subdirectory(test06/module)
|
||||
add_subdirectory(test07/module)
|
||||
add_subdirectory(test08/module)
|
||||
add_subdirectory(test09/module)
|
||||
add_subdirectory(test10/module)
|
||||
add_subdirectory(test11/module)
|
||||
add_subdirectory(test12/module)
|
||||
add_subdirectory(test13/module)
|
||||
|
||||
# tests for g4py
|
||||
add_subdirectory(gtest01/module)
|
||||
|
||||
# testing
|
||||
add_subdirectory(test00)
|
||||
add_subdirectory(test01)
|
||||
|
||||
if (${PYTHON_VERSION_MAJOR} MATCHES "2")
|
||||
add_subdirectory(test02)
|
||||
add_subdirectory(test03)
|
||||
add_subdirectory(test04)
|
||||
add_subdirectory(test05)
|
||||
add_subdirectory(test06)
|
||||
add_subdirectory(test07)
|
||||
add_subdirectory(test08)
|
||||
add_subdirectory(test09)
|
||||
add_subdirectory(test10)
|
||||
add_subdirectory(test11)
|
||||
add_subdirectory(test12)
|
||||
add_subdirectory(test13)
|
||||
endif()
|
||||
|
||||
#
|
||||
add_subdirectory(g4pytest)
|
||||
add_subdirectory(gtest01)
|
||||
add_subdirectory(gtest02)
|
||||
add_subdirectory(gtest03)
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
# - Function to build the C++ modules
|
||||
function(g4pytest_add_module _TARGET)
|
||||
g4py_add_module(${_TARGET} ${ARGN})
|
||||
|
||||
# Filthy temp hack for submodule paths....
|
||||
string(REGEX REPLACE "^_" "" _SUBMODULE "${_TARGET}")
|
||||
set_property(TARGET ${_TARGET} APPEND_STRING PROPERTY LIBRARY_OUTPUT_DIRECTORY "/g4pytest/${_SUBMODULE}")
|
||||
foreach(_conftype ${CMAKE_CONFIGURATION_TYPES})
|
||||
string(TOUPPER ${_conftype} _conftype_uppercase)
|
||||
set_property(TARGET ${_TARGET} APPEND_STRING PROPERTY LIBRARY_OUTPUT_DIRECTORY_${_conftype_uppercase} "/g4pytest/${_SUBMODULE}")
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
|
||||
# - add libs components
|
||||
add_subdirectory(ExN01geom)
|
||||
add_subdirectory(ExN03geom)
|
||||
add_subdirectory(Qgeom)
|
||||
add_subdirectory(ezgeom)
|
||||
add_subdirectory(NISTmaterials)
|
||||
add_subdirectory(Qmaterials)
|
||||
add_subdirectory(EMSTDpl)
|
||||
add_subdirectory(ExN01pl)
|
||||
add_subdirectory(MedicalBeam)
|
||||
add_subdirectory(ParticleGun)
|
||||
# Remainder are pure python
|
||||
|
||||
# Copy/configure pure python components
|
||||
file(GLOB_RECURSE PY_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.py)
|
||||
foreach(_pyfile ${PY_FILES})
|
||||
file(GENERATE
|
||||
OUTPUT ${GEANT4_PYTHON_OUTPUT_DIR}/g4pytest/${_pyfile}
|
||||
INPUT ${CMAKE_CURRENT_SOURCE_DIR}/${_pyfile}
|
||||
)
|
||||
endforeach()
|
||||
@@ -0,0 +1,4 @@
|
||||
# - build library
|
||||
set(_TARGET _EMSTDpl)
|
||||
g4pytest_add_module(${_TARGET} PhysicsListEMstd.cc pyEMSTDpl.cc)
|
||||
target_link_libraries(${_TARGET} PRIVATE G4particles G4processes G4run)
|
||||
@@ -0,0 +1,133 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// ====================================================================
|
||||
// PhysicsListEMstd.cc
|
||||
//
|
||||
// 2006 Q
|
||||
// ====================================================================
|
||||
#include "PhysicsListEMstd.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
|
||||
#include "G4ProcessManager.hh"
|
||||
#include "G4ParticleDefinition.hh"
|
||||
|
||||
#include "G4Gamma.hh"
|
||||
#include "G4Electron.hh"
|
||||
#include "G4Positron.hh"
|
||||
|
||||
#include "G4ComptonScattering.hh"
|
||||
#include "G4GammaConversion.hh"
|
||||
#include "G4PhotoElectricEffect.hh"
|
||||
#include "G4eMultipleScattering.hh"
|
||||
#include "G4eIonisation.hh"
|
||||
#include "G4eBremsstrahlung.hh"
|
||||
#include "G4eplusAnnihilation.hh"
|
||||
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// class description
|
||||
//
|
||||
// ====================================================================
|
||||
|
||||
////////////////////////////////////
|
||||
PhysicsListEMstd::PhysicsListEMstd()
|
||||
////////////////////////////////////
|
||||
{
|
||||
SetVerboseLevel(1);
|
||||
defaultCutValue = 1.*mm; // default cut value (1.0mm)
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////
|
||||
PhysicsListEMstd::~PhysicsListEMstd()
|
||||
/////////////////////////////////////
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////
|
||||
void PhysicsListEMstd::ConstructParticle()
|
||||
//////////////////////////////////////////
|
||||
{
|
||||
G4Gamma::GammaDefinition();
|
||||
G4Electron::ElectronDefinition();
|
||||
G4Positron::PositronDefinition();
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////
|
||||
void PhysicsListEMstd::ConstructProcess()
|
||||
/////////////////////////////////////////
|
||||
{
|
||||
AddTransportation();
|
||||
|
||||
G4ProcessManager* pm;
|
||||
|
||||
// ----------------------------------------------------------
|
||||
// gamma physics
|
||||
// ----------------------------------------------------------
|
||||
pm= G4Gamma::Gamma()-> GetProcessManager();
|
||||
pm-> AddDiscreteProcess(new G4PhotoElectricEffect);
|
||||
pm-> AddDiscreteProcess(new G4ComptonScattering);
|
||||
pm-> AddDiscreteProcess(new G4GammaConversion);
|
||||
|
||||
// ----------------------------------------------------------
|
||||
// electron physics
|
||||
// ----------------------------------------------------------
|
||||
G4eMultipleScattering* msc= new G4eMultipleScattering;
|
||||
G4eIonisation* eion= new G4eIonisation;
|
||||
G4eBremsstrahlung* ebrems= new G4eBremsstrahlung;
|
||||
|
||||
pm= G4Electron::Electron()->GetProcessManager();
|
||||
pm-> AddProcess(msc, ordInActive, 1, 1);
|
||||
pm-> AddProcess(eion, ordInActive, 2, 2);
|
||||
pm-> AddProcess(ebrems, ordInActive, ordInActive, 3);
|
||||
|
||||
// ----------------------------------------------------------
|
||||
// positron physics
|
||||
// ----------------------------------------------------------
|
||||
msc= new G4eMultipleScattering;
|
||||
eion= new G4eIonisation;
|
||||
ebrems= new G4eBremsstrahlung;
|
||||
G4eplusAnnihilation* annihilation= new G4eplusAnnihilation;
|
||||
|
||||
pm= G4Positron::Positron()-> GetProcessManager();
|
||||
pm-> AddProcess(msc, ordInActive, 1, 1);
|
||||
pm-> AddProcess(eion, ordInActive, 2, 2);
|
||||
pm-> AddProcess(ebrems, ordInActive, ordInActive, 3);
|
||||
pm-> AddProcess(annihilation, 0, ordInActive, 4);
|
||||
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////
|
||||
void PhysicsListEMstd::SetCuts()
|
||||
////////////////////////////////
|
||||
{
|
||||
SetCutsWithDefault();
|
||||
}
|
||||
|
||||
+15
-11
@@ -24,12 +24,17 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
// ====================================================================
|
||||
// AClass.hh
|
||||
// PhysicsListEMstd.hh
|
||||
//
|
||||
// 2004 Q
|
||||
// Physics list for electron/positron/gamma
|
||||
// EM-standard package
|
||||
//
|
||||
// 2006 Q
|
||||
// ====================================================================
|
||||
#ifndef ACLASS_H
|
||||
#define ACLASS_H
|
||||
#ifndef PHYSICS_LIST_EMSTD_H
|
||||
#define PHYSICS_LIST_EMSTD_H
|
||||
|
||||
#include "G4VUserPhysicsList.hh"
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
@@ -37,15 +42,14 @@
|
||||
//
|
||||
// ====================================================================
|
||||
|
||||
class AClass {
|
||||
protected:
|
||||
static AClass* thePointer;
|
||||
AClass();
|
||||
|
||||
class PhysicsListEMstd: public G4VUserPhysicsList {
|
||||
public:
|
||||
~AClass();
|
||||
PhysicsListEMstd();
|
||||
~PhysicsListEMstd();
|
||||
|
||||
static AClass* GetPointer();
|
||||
virtual void ConstructParticle();
|
||||
virtual void ConstructProcess();
|
||||
virtual void SetCuts();
|
||||
|
||||
};
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
from ._EMSTDpl import *
|
||||
+39
-33
@@ -24,46 +24,52 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
// ====================================================================
|
||||
// XBase.hh
|
||||
// pyEMSTDpl.cc
|
||||
//
|
||||
// 2004 Q
|
||||
// ====================================================================
|
||||
#ifndef XBASE_H
|
||||
#define XBASE_H
|
||||
|
||||
// ====================================================================
|
||||
// [Qgeom]
|
||||
// a site-module of Geant4Py
|
||||
//
|
||||
// class definition
|
||||
// Electron/Gamma EM-standard physics list
|
||||
//
|
||||
// 2005 Q
|
||||
// ====================================================================
|
||||
#include <boost/python.hpp>
|
||||
#include "G4RunManager.hh"
|
||||
#include "PhysicsListEMstd.hh"
|
||||
|
||||
class XBase {
|
||||
protected:
|
||||
int ival;
|
||||
double dval;
|
||||
|
||||
public:
|
||||
XBase();
|
||||
virtual ~XBase();
|
||||
|
||||
void SetIVal(int aval);
|
||||
int GetIVal() const;
|
||||
|
||||
void SetDVal(double aval);
|
||||
double GetDVal() const;
|
||||
|
||||
void AMethod();
|
||||
virtual int VMethod(const XBase* abase) const=0;
|
||||
|
||||
};
|
||||
using namespace boost::python;
|
||||
|
||||
// ====================================================================
|
||||
// inline functions
|
||||
// thin wrappers
|
||||
// ====================================================================
|
||||
inline void XBase::SetIVal(int i) { ival= i; }
|
||||
inline int XBase::GetIVal() const { return ival; }
|
||||
namespace pyEMSTDpl {
|
||||
|
||||
inline void XBase::SetDVal(double d) { dval= d; }
|
||||
inline double XBase::GetDVal() const { return dval; }
|
||||
PhysicsListEMstd* Construct()
|
||||
{
|
||||
PhysicsListEMstd* pl= new PhysicsListEMstd;
|
||||
|
||||
#endif
|
||||
G4RunManager* runMgr= G4RunManager::GetRunManager();
|
||||
runMgr-> SetUserInitialization(pl);
|
||||
|
||||
return pl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
using namespace pyEMSTDpl;
|
||||
|
||||
// ====================================================================
|
||||
// Expose to Python
|
||||
// ====================================================================
|
||||
|
||||
BOOST_PYTHON_MODULE(_EMSTDpl) {
|
||||
|
||||
class_<PhysicsListEMstd, PhysicsListEMstd*, bases<G4VUserPhysicsList> >
|
||||
("PhysicsListEMstd", "Electron/Gamma EM-standard physics list")
|
||||
;
|
||||
|
||||
// ---
|
||||
def("Construct", Construct,
|
||||
return_value_policy<reference_existing_object>());
|
||||
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
# - build library
|
||||
set(_TARGET _ExN01geom)
|
||||
g4pytest_add_module(${_TARGET} ExN01DetectorConstruction.cc pyExN01geom.cc)
|
||||
target_link_libraries(${_TARGET} PRIVATE G4materials G4geometry G4run)
|
||||
@@ -0,0 +1,155 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// ====================================================================
|
||||
// ExN01DetectorConstruction.cc
|
||||
//
|
||||
// 2005 Q
|
||||
// ====================================================================
|
||||
#include "ExN01DetectorConstruction.hh"
|
||||
|
||||
#include "G4Material.hh"
|
||||
#include "G4Box.hh"
|
||||
#include "G4Tubs.hh"
|
||||
#include "G4LogicalVolume.hh"
|
||||
#include "G4ThreeVector.hh"
|
||||
#include "G4PVPlacement.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// class description
|
||||
//
|
||||
// ====================================================================
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
ExN01DetectorConstruction::ExN01DetectorConstruction()
|
||||
: experimentalHall_log(0), tracker_log(0),
|
||||
calorimeterBlock_log(0), calorimeterLayer_log(0),
|
||||
experimentalHall_phys(0), calorimeterLayer_phys(0),
|
||||
calorimeterBlock_phys(0), tracker_phys(0)
|
||||
//////////////////////////////////////////////////////
|
||||
{
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////
|
||||
ExN01DetectorConstruction::~ExN01DetectorConstruction()
|
||||
///////////////////////////////////////////////////////
|
||||
{
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
G4VPhysicalVolume* ExN01DetectorConstruction::Construct()
|
||||
/////////////////////////////////////////////////////////
|
||||
{
|
||||
//------------------------------------------------------ materials
|
||||
G4double a; // atomic mass
|
||||
G4double z; // atomic number
|
||||
G4double density;
|
||||
|
||||
G4Material* Ar =
|
||||
new G4Material("ArgonGas", z= 18., a= 39.95*g/mole, density= 1.782*mg/cm3);
|
||||
|
||||
G4Material* Al =
|
||||
new G4Material("Aluminum", z= 13., a= 26.98*g/mole, density= 2.7*g/cm3);
|
||||
|
||||
G4Material* Pb =
|
||||
new G4Material("Lead", z= 82., a= 207.19*g/mole, density= 11.35*g/cm3);
|
||||
|
||||
//------------------------------------------------------ volumes
|
||||
|
||||
//------------------------------ experimental hall (world volume)
|
||||
//------------------------------ beam line along x axis
|
||||
|
||||
G4double expHall_x = 3.0*m;
|
||||
G4double expHall_y = 1.0*m;
|
||||
G4double expHall_z = 1.0*m;
|
||||
G4Box* experimentalHall_box
|
||||
= new G4Box("expHall_box",expHall_x,expHall_y,expHall_z);
|
||||
experimentalHall_log = new G4LogicalVolume(experimentalHall_box,
|
||||
Ar,"expHall_log",0,0,0);
|
||||
experimentalHall_phys = new G4PVPlacement(0,G4ThreeVector(),
|
||||
experimentalHall_log,
|
||||
"expHall",0,false,0);
|
||||
|
||||
//------------------------------ a tracker tube
|
||||
|
||||
G4double innerRadiusOfTheTube = 0.*cm;
|
||||
G4double outerRadiusOfTheTube = 60.*cm;
|
||||
G4double hightOfTheTube = 50.*cm;
|
||||
G4double startAngleOfTheTube = 0.*deg;
|
||||
G4double spanningAngleOfTheTube = 360.*deg;
|
||||
G4Tubs* tracker_tube = new G4Tubs("tracker_tube",innerRadiusOfTheTube,
|
||||
outerRadiusOfTheTube,hightOfTheTube,
|
||||
startAngleOfTheTube,
|
||||
spanningAngleOfTheTube);
|
||||
tracker_log = new G4LogicalVolume(tracker_tube,Al,"tracker_log",0,0,0);
|
||||
G4double trackerPos_x = -1.0*m;
|
||||
G4double trackerPos_y = 0.*m;
|
||||
G4double trackerPos_z = 0.*m;
|
||||
tracker_phys = new G4PVPlacement(0,
|
||||
G4ThreeVector(trackerPos_x,trackerPos_y,trackerPos_z),
|
||||
tracker_log,"tracker",experimentalHall_log,false,0);
|
||||
|
||||
//------------------------------ a calorimeter block
|
||||
|
||||
G4double block_x = 1.0*m;
|
||||
G4double block_y = 50.0*cm;
|
||||
G4double block_z = 50.0*cm;
|
||||
G4Box* calorimeterBlock_box = new G4Box("calBlock_box",block_x,
|
||||
block_y,block_z);
|
||||
calorimeterBlock_log = new G4LogicalVolume(calorimeterBlock_box,
|
||||
Pb,"caloBlock_log",0,0,0);
|
||||
G4double blockPos_x = 1.0*m;
|
||||
G4double blockPos_y = 0.0*m;
|
||||
G4double blockPos_z = 0.0*m;
|
||||
calorimeterBlock_phys = new G4PVPlacement(0,
|
||||
G4ThreeVector(blockPos_x,blockPos_y,blockPos_z),
|
||||
calorimeterBlock_log,"caloBlock",experimentalHall_log,false,0);
|
||||
|
||||
//------------------------------ calorimeter layers
|
||||
|
||||
G4double calo_x = 1.*cm;
|
||||
G4double calo_y = 40.*cm;
|
||||
G4double calo_z = 40.*cm;
|
||||
G4Box* calorimeterLayer_box = new G4Box("caloLayer_box",
|
||||
calo_x,calo_y,calo_z);
|
||||
calorimeterLayer_log = new G4LogicalVolume(calorimeterLayer_box,
|
||||
Al,"caloLayer_log",0,0,0);
|
||||
for(G4int i=0;i<19;i++) // loop for 19 layers
|
||||
{
|
||||
G4double caloPos_x = (i-9)*10.*cm;
|
||||
G4double caloPos_y = 0.0*m;
|
||||
G4double caloPos_z = 0.0*m;
|
||||
calorimeterLayer_phys = new G4PVPlacement(0,
|
||||
G4ThreeVector(caloPos_x,caloPos_y,caloPos_z),
|
||||
calorimeterLayer_log,"caloLayer",calorimeterBlock_log,false,i);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
|
||||
return experimentalHall_phys;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// ====================================================================
|
||||
// ExN01DetectorConstruction.hh
|
||||
//
|
||||
// 2005 Q
|
||||
// ====================================================================
|
||||
#ifndef EXN01_DETECTOR_CONSTRUCTION_H
|
||||
#define EXN01_DETECTOR_CONSTRUCTION_H
|
||||
|
||||
#include "G4VUserDetectorConstruction.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// class definition
|
||||
//
|
||||
// ====================================================================
|
||||
class G4LogicalVolume;
|
||||
class G4VPhysicalVolume;
|
||||
|
||||
#include "G4VUserDetectorConstruction.hh"
|
||||
|
||||
class ExN01DetectorConstruction : public G4VUserDetectorConstruction {
|
||||
public:
|
||||
|
||||
ExN01DetectorConstruction();
|
||||
~ExN01DetectorConstruction();
|
||||
|
||||
G4VPhysicalVolume* Construct();
|
||||
|
||||
private:
|
||||
// Logical volumes
|
||||
//
|
||||
G4LogicalVolume* experimentalHall_log;
|
||||
G4LogicalVolume* tracker_log;
|
||||
G4LogicalVolume* calorimeterBlock_log;
|
||||
G4LogicalVolume* calorimeterLayer_log;
|
||||
|
||||
// Physical volumes
|
||||
//
|
||||
G4VPhysicalVolume* experimentalHall_phys;
|
||||
G4VPhysicalVolume* calorimeterLayer_phys;
|
||||
G4VPhysicalVolume* calorimeterBlock_phys;
|
||||
G4VPhysicalVolume* tracker_phys;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
from ._ExN01geom import *
|
||||
+30
-23
@@ -24,41 +24,48 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
// ====================================================================
|
||||
// XBase.hh
|
||||
// pyExN01geom.cc
|
||||
//
|
||||
// [Qgeom]
|
||||
// a site-module of Geant4Py
|
||||
//
|
||||
// geometry presented in ExN01 of Geant4 example
|
||||
//
|
||||
// 2005 Q
|
||||
// ====================================================================
|
||||
#ifndef XBASE_H
|
||||
#define XBASE_H
|
||||
#include <boost/python.hpp>
|
||||
#include "G4RunManager.hh"
|
||||
#include "ExN01DetectorConstruction.hh"
|
||||
|
||||
#include <string>
|
||||
using namespace boost::python;
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// class definition
|
||||
//
|
||||
// thin wrappers
|
||||
// ====================================================================
|
||||
namespace pyExN03geom {
|
||||
|
||||
class XBase {
|
||||
protected:
|
||||
int ival;
|
||||
void Construct()
|
||||
{
|
||||
G4RunManager* runMgr= G4RunManager::GetRunManager();
|
||||
runMgr-> SetUserInitialization(new ExN01DetectorConstruction);
|
||||
}
|
||||
|
||||
public:
|
||||
XBase();
|
||||
virtual ~XBase();
|
||||
}
|
||||
|
||||
inline void SetIVal(int i);
|
||||
inline int GetIVal() const;
|
||||
|
||||
virtual std::string PVMethod()=0;
|
||||
|
||||
};
|
||||
using namespace pyExN03geom;
|
||||
|
||||
// ====================================================================
|
||||
// inline functions
|
||||
// Expose to Python
|
||||
// ====================================================================
|
||||
|
||||
inline void XBase::SetIVal(int i) { ival= i; }
|
||||
inline int XBase::GetIVal() const { return ival; }
|
||||
BOOST_PYTHON_MODULE(_ExN01geom) {
|
||||
|
||||
class_<ExN01DetectorConstruction, ExN01DetectorConstruction*,
|
||||
bases<G4VUserDetectorConstruction> >
|
||||
("ExN01DetectorConstruction", "ExN01 detector")
|
||||
;
|
||||
|
||||
// ---
|
||||
def("Construct", Construct);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,4 @@
|
||||
# - build library
|
||||
set(_TARGET _ExN01pl)
|
||||
g4pytest_add_module(${_TARGET} ExN01PhysicsList.cc pyExN01pl.cc)
|
||||
target_link_libraries(${_TARGET} PRIVATE G4particles G4processes G4run)
|
||||
+27
-57
@@ -24,12 +24,12 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
// ====================================================================
|
||||
// AClass.cc
|
||||
// ExN01PhysicsList.cc
|
||||
//
|
||||
// 2005 Q
|
||||
// ====================================================================
|
||||
#include "AClass.hh"
|
||||
#include <iostream>
|
||||
#include "ExN01PhysicsList.hh"
|
||||
#include "G4ParticleTypes.hh"
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
@@ -37,71 +37,41 @@
|
||||
//
|
||||
// ====================================================================
|
||||
|
||||
////////////////
|
||||
AClass::AClass()
|
||||
: ival(0)
|
||||
////////////////
|
||||
{
|
||||
}
|
||||
|
||||
///////////////////////////////
|
||||
AClass::AClass(int i, double d)
|
||||
: ival(i)
|
||||
///////////////////////////////
|
||||
{
|
||||
std::cout << "*** AClass constructor, d= "<< d << std::endl;
|
||||
}
|
||||
|
||||
/////////////////
|
||||
AClass::~AClass()
|
||||
/////////////////
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/////////////////////
|
||||
int AClass::AMethod()
|
||||
/////////////////////
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
//////////////////////////
|
||||
int AClass::AMethod(int i)
|
||||
//////////////////////////
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////
|
||||
int AClass::AMethod(int i, double d)
|
||||
ExN01PhysicsList::ExN01PhysicsList()
|
||||
////////////////////////////////////
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//////////////////////
|
||||
int AClass::BMethod()
|
||||
//////////////////////
|
||||
/////////////////////////////////////
|
||||
ExN01PhysicsList::~ExN01PhysicsList()
|
||||
/////////////////////////////////////
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////
|
||||
void ExN01PhysicsList::ConstructParticle()
|
||||
//////////////////////////////////////////
|
||||
{
|
||||
G4Geantino::GeantinoDefinition();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////
|
||||
void ExN01PhysicsList::ConstructProcess()
|
||||
/////////////////////////////////////////
|
||||
{
|
||||
AddTransportation();
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
double AClass::BMethod(double d)
|
||||
void ExN01PhysicsList::SetCuts()
|
||||
////////////////////////////////
|
||||
{
|
||||
return 1.;
|
||||
G4int temp = GetVerboseLevel();
|
||||
SetVerboseLevel(0);
|
||||
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////
|
||||
double AClass::CMethod(int i, double d1, double d2)
|
||||
///////////////////////////////////////////////////
|
||||
{
|
||||
return i*d1*d2;
|
||||
SetCutsWithDefault();
|
||||
|
||||
SetVerboseLevel(temp);
|
||||
}
|
||||
|
||||
+20
-21
@@ -24,34 +24,33 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
// ====================================================================
|
||||
// Step.cc
|
||||
// ExN01PhysicsList.hh
|
||||
//
|
||||
// 2005 Q
|
||||
// ====================================================================
|
||||
#include "Step.hh"
|
||||
#include <iostream>
|
||||
#ifndef EXN01_PHYSICS_LIST_H
|
||||
#define EXN01_PHYSICS_LIST_H
|
||||
|
||||
#include "G4VUserPhysicsList.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// class description
|
||||
// class definition
|
||||
//
|
||||
// ====================================================================
|
||||
|
||||
////////////
|
||||
Step::Step()
|
||||
: x(0)
|
||||
////////////
|
||||
{
|
||||
std::cout << "Step is created. @"
|
||||
<< this << std::endl;
|
||||
}
|
||||
|
||||
|
||||
/////////////
|
||||
Step::~Step()
|
||||
/////////////
|
||||
{
|
||||
std::cout << "Step is deleted. @"
|
||||
<< this << std::endl;
|
||||
}
|
||||
class ExN01PhysicsList: public G4VUserPhysicsList {
|
||||
public:
|
||||
ExN01PhysicsList();
|
||||
~ExN01PhysicsList();
|
||||
|
||||
protected:
|
||||
// Construct particle and physics process
|
||||
void ConstructParticle();
|
||||
void ConstructProcess();
|
||||
void SetCuts();
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1 @@
|
||||
from ._ExN01pl import *
|
||||
@@ -0,0 +1,75 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// ====================================================================
|
||||
// pyExN01pl.cc
|
||||
//
|
||||
// [ExN01pl]
|
||||
// a site-module of Geant4Py
|
||||
//
|
||||
// minimal physics list, which is presnted in ExN01 of Geant4 example
|
||||
//
|
||||
// 2005 Q
|
||||
// ====================================================================
|
||||
#include <boost/python.hpp>
|
||||
#include "G4RunManager.hh"
|
||||
#include "ExN01PhysicsList.hh"
|
||||
|
||||
using namespace boost::python;
|
||||
|
||||
// ====================================================================
|
||||
// thin wrappers
|
||||
// ====================================================================
|
||||
namespace pyExN01pl {
|
||||
|
||||
ExN01PhysicsList* Construct()
|
||||
{
|
||||
ExN01PhysicsList* pl= new ExN01PhysicsList;
|
||||
|
||||
G4RunManager* runMgr= G4RunManager::GetRunManager();
|
||||
runMgr-> SetUserInitialization(pl);
|
||||
|
||||
return pl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
using namespace pyExN01pl;
|
||||
|
||||
// ====================================================================
|
||||
// Expose to Python
|
||||
// ====================================================================
|
||||
|
||||
BOOST_PYTHON_MODULE(_ExN01pl) {
|
||||
|
||||
class_<ExN01PhysicsList, ExN01PhysicsList*, bases<G4VUserPhysicsList> >
|
||||
("ExN01PhysicsList", "ExN01 physics list")
|
||||
;
|
||||
|
||||
// ---
|
||||
def("Construct", Construct,
|
||||
return_value_policy<reference_existing_object>());
|
||||
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
# - build library
|
||||
set(_TARGET _ExN03geom)
|
||||
g4pytest_add_module(${_TARGET} ExN03DetectorConstruction.cc ExN03DetectorMessenger.cc pyExN03geom.cc)
|
||||
target_link_libraries(${_TARGET} PRIVATE G4materials G4geometry G4run)
|
||||
@@ -0,0 +1,473 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "ExN03DetectorConstruction.hh"
|
||||
#include "ExN03DetectorMessenger.hh"
|
||||
|
||||
#include "G4Material.hh"
|
||||
#include "G4Box.hh"
|
||||
#include "G4LogicalVolume.hh"
|
||||
#include "G4PVPlacement.hh"
|
||||
#include "G4PVReplica.hh"
|
||||
#include "G4UniformMagField.hh"
|
||||
|
||||
#include "G4GeometryManager.hh"
|
||||
#include "G4PhysicalVolumeStore.hh"
|
||||
#include "G4LogicalVolumeStore.hh"
|
||||
#include "G4SolidStore.hh"
|
||||
|
||||
#include "G4VisAttributes.hh"
|
||||
#include "G4Colour.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4PhysicalConstants.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
ExN03DetectorConstruction::ExN03DetectorConstruction()
|
||||
:AbsorberMaterial(0),GapMaterial(0),defaultMaterial(0),
|
||||
solidWorld(0),logicWorld(0),physiWorld(0),
|
||||
solidCalor(0),logicCalor(0),physiCalor(0),
|
||||
solidLayer(0),logicLayer(0),physiLayer(0),
|
||||
solidAbsorber(0),logicAbsorber(0),physiAbsorber(0),
|
||||
solidGap (0),logicGap (0),physiGap (0),
|
||||
magField(0)
|
||||
{
|
||||
// default parameter values of the calorimeter
|
||||
AbsorberThickness = 10.*mm;
|
||||
GapThickness = 5.*mm;
|
||||
NbOfLayers = 10;
|
||||
CalorSizeYZ = 10.*cm;
|
||||
ComputeCalorParameters();
|
||||
|
||||
// materials
|
||||
DefineMaterials();
|
||||
SetAbsorberMaterial("Lead");
|
||||
SetGapMaterial("liquidArgon");
|
||||
|
||||
// create commands for interactive definition of the calorimeter
|
||||
detectorMessenger = new ExN03DetectorMessenger(this);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
ExN03DetectorConstruction::~ExN03DetectorConstruction()
|
||||
{ delete detectorMessenger;}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
G4VPhysicalVolume* ExN03DetectorConstruction::Construct()
|
||||
{
|
||||
return ConstructCalorimeter();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void ExN03DetectorConstruction::DefineMaterials()
|
||||
{
|
||||
//This function illustrates the possible ways to define materials
|
||||
|
||||
G4String symbol; //a=mass of a mole;
|
||||
G4double a, z, density; //z=mean number of protons;
|
||||
G4int iz, n; //iz=number of protons in an isotope;
|
||||
// n=number of nucleons in an isotope;
|
||||
|
||||
G4int ncomponents, natoms;
|
||||
G4double abundance, fractionmass;
|
||||
|
||||
//
|
||||
// define Elements
|
||||
//
|
||||
|
||||
G4Element* H = new G4Element("Hydrogen",symbol="H" , z= 1., a= 1.01*g/mole);
|
||||
G4Element* C = new G4Element("Carbon" ,symbol="C" , z= 6., a= 12.01*g/mole);
|
||||
G4Element* N = new G4Element("Nitrogen",symbol="N" , z= 7., a= 14.01*g/mole);
|
||||
G4Element* O = new G4Element("Oxygen" ,symbol="O" , z= 8., a= 16.00*g/mole);
|
||||
G4Element* Si = new G4Element("Silicon",symbol="Si" , z= 14., a= 28.09*g/mole);
|
||||
|
||||
//
|
||||
// define an Element from isotopes, by relative abundance
|
||||
//
|
||||
|
||||
G4Isotope* U5 = new G4Isotope("U235", iz=92, n=235, a=235.01*g/mole);
|
||||
G4Isotope* U8 = new G4Isotope("U238", iz=92, n=238, a=238.03*g/mole);
|
||||
|
||||
G4Element* U = new G4Element("enriched Uranium",symbol="U",ncomponents=2);
|
||||
U->AddIsotope(U5, abundance= 90.*perCent);
|
||||
U->AddIsotope(U8, abundance= 10.*perCent);
|
||||
|
||||
//
|
||||
// define simple materials
|
||||
//
|
||||
|
||||
new G4Material("Aluminium", z=13., a=26.98*g/mole, density=2.700*g/cm3);
|
||||
new G4Material("liquidArgon", z=18., a= 39.95*g/mole, density= 1.390*g/cm3);
|
||||
new G4Material("Lead" , z=82., a= 207.19*g/mole, density= 11.35*g/cm3);
|
||||
|
||||
//
|
||||
// define a material from elements. case 1: chemical molecule
|
||||
//
|
||||
|
||||
G4Material* H2O =
|
||||
new G4Material("Water", density= 1.000*g/cm3, ncomponents=2);
|
||||
H2O->AddElement(H, natoms=2);
|
||||
H2O->AddElement(O, natoms=1);
|
||||
// overwrite computed meanExcitationEnergy with ICRU recommended value
|
||||
H2O->GetIonisation()->SetMeanExcitationEnergy(75.0*eV);
|
||||
|
||||
G4Material* Sci =
|
||||
new G4Material("Scintillator", density= 1.032*g/cm3, ncomponents=2);
|
||||
Sci->AddElement(C, natoms=9);
|
||||
Sci->AddElement(H, natoms=10);
|
||||
|
||||
G4Material* Myl =
|
||||
new G4Material("Mylar", density= 1.397*g/cm3, ncomponents=3);
|
||||
Myl->AddElement(C, natoms=10);
|
||||
Myl->AddElement(H, natoms= 8);
|
||||
Myl->AddElement(O, natoms= 4);
|
||||
|
||||
G4Material* SiO2 =
|
||||
new G4Material("quartz",density= 2.200*g/cm3, ncomponents=2);
|
||||
SiO2->AddElement(Si, natoms=1);
|
||||
SiO2->AddElement(O , natoms=2);
|
||||
|
||||
//
|
||||
// define a material from elements. case 2: mixture by fractional mass
|
||||
//
|
||||
|
||||
G4Material* Air =
|
||||
new G4Material("Air" , density= 1.290*mg/cm3, ncomponents=2);
|
||||
Air->AddElement(N, fractionmass=0.7);
|
||||
Air->AddElement(O, fractionmass=0.3);
|
||||
|
||||
//
|
||||
// define a material from elements and/or others materials (mixture of mixtures)
|
||||
//
|
||||
|
||||
G4Material* Aerog =
|
||||
new G4Material("Aerogel", density= 0.200*g/cm3, ncomponents=3);
|
||||
Aerog->AddMaterial(SiO2, fractionmass=62.5*perCent);
|
||||
Aerog->AddMaterial(H2O , fractionmass=37.4*perCent);
|
||||
Aerog->AddElement (C , fractionmass= 0.1*perCent);
|
||||
|
||||
//
|
||||
// examples of gas in non STP conditions
|
||||
//
|
||||
|
||||
G4Material* CO2 =
|
||||
new G4Material("CarbonicGas", density= 27.*mg/cm3, ncomponents=2,
|
||||
kStateGas, 325.*kelvin, 50.*atmosphere);
|
||||
CO2->AddElement(C, natoms=1);
|
||||
CO2->AddElement(O, natoms=2);
|
||||
|
||||
G4Material* steam =
|
||||
new G4Material("WaterSteam", density= 0.3*mg/cm3, ncomponents=1,
|
||||
kStateGas, 500.*kelvin, 2.*atmosphere);
|
||||
steam->AddMaterial(H2O, fractionmass=1.);
|
||||
|
||||
//
|
||||
// examples of vacuum
|
||||
//
|
||||
|
||||
G4Material* Vacuum =
|
||||
new G4Material("Galactic", z=1., a=1.01*g/mole,density= universe_mean_density,
|
||||
kStateGas, 2.73*kelvin, 3.e-18*pascal);
|
||||
|
||||
G4Material* beam =
|
||||
new G4Material("Beam", density= 1.e-5*g/cm3, ncomponents=1,
|
||||
kStateGas, STP_Temperature, 2.e-2*bar);
|
||||
beam->AddMaterial(Air, fractionmass=1.);
|
||||
|
||||
G4cout << *(G4Material::GetMaterialTable()) << G4endl;
|
||||
|
||||
//default materials of the World
|
||||
defaultMaterial = Vacuum;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
G4VPhysicalVolume* ExN03DetectorConstruction::ConstructCalorimeter()
|
||||
{
|
||||
|
||||
// Clean old geometry, if any
|
||||
//
|
||||
G4GeometryManager::GetInstance()->OpenGeometry();
|
||||
G4PhysicalVolumeStore::GetInstance()->Clean();
|
||||
G4LogicalVolumeStore::GetInstance()->Clean();
|
||||
G4SolidStore::GetInstance()->Clean();
|
||||
|
||||
// complete the Calor parameters definition
|
||||
ComputeCalorParameters();
|
||||
|
||||
//
|
||||
// World
|
||||
//
|
||||
solidWorld = new G4Box("World", //its name
|
||||
WorldSizeX/2,WorldSizeYZ/2,WorldSizeYZ/2); //its size
|
||||
|
||||
logicWorld = new G4LogicalVolume(solidWorld, //its solid
|
||||
defaultMaterial, //its material
|
||||
"World"); //its name
|
||||
|
||||
physiWorld = new G4PVPlacement(0, //no rotation
|
||||
G4ThreeVector(), //at (0,0,0)
|
||||
logicWorld, //its logical volume
|
||||
"World", //its name
|
||||
0, //its mother volume
|
||||
false, //no boolean operation
|
||||
0); //copy number
|
||||
|
||||
//
|
||||
// Calorimeter
|
||||
//
|
||||
solidCalor=0; logicCalor=0; physiCalor=0;
|
||||
solidLayer=0; logicLayer=0; physiLayer=0;
|
||||
|
||||
if (CalorThickness > 0.)
|
||||
{ solidCalor = new G4Box("Calorimeter", //its name
|
||||
CalorThickness/2,CalorSizeYZ/2,CalorSizeYZ/2);//size
|
||||
|
||||
logicCalor = new G4LogicalVolume(solidCalor, //its solid
|
||||
defaultMaterial, //its material
|
||||
"Calorimeter"); //its name
|
||||
|
||||
physiCalor = new G4PVPlacement(0, //no rotation
|
||||
G4ThreeVector(), //at (0,0,0)
|
||||
logicCalor, //its logical volume
|
||||
"Calorimeter", //its name
|
||||
logicWorld, //its mother volume
|
||||
false, //no boolean operation
|
||||
0); //copy number
|
||||
|
||||
//
|
||||
// Layer
|
||||
//
|
||||
solidLayer = new G4Box("Layer", //its name
|
||||
LayerThickness/2,CalorSizeYZ/2,CalorSizeYZ/2); //size
|
||||
|
||||
logicLayer = new G4LogicalVolume(solidLayer, //its solid
|
||||
defaultMaterial, //its material
|
||||
"Layer"); //its name
|
||||
if (NbOfLayers > 1)
|
||||
physiLayer = new G4PVReplica("Layer", //its name
|
||||
logicLayer, //its logical volume
|
||||
logicCalor, //its mother
|
||||
kXAxis, //axis of replication
|
||||
NbOfLayers, //number of replica
|
||||
LayerThickness); //witdth of replica
|
||||
else
|
||||
physiLayer = new G4PVPlacement(0, //no rotation
|
||||
G4ThreeVector(), //at (0,0,0)
|
||||
logicLayer, //its logical volume
|
||||
"Layer", //its name
|
||||
logicCalor, //its mother volume
|
||||
false, //no boolean operation
|
||||
0); //copy number
|
||||
}
|
||||
|
||||
//
|
||||
// Absorber
|
||||
//
|
||||
solidAbsorber=0; logicAbsorber=0; physiAbsorber=0;
|
||||
|
||||
if (AbsorberThickness > 0.)
|
||||
{ solidAbsorber = new G4Box("Absorber", //its name
|
||||
AbsorberThickness/2,CalorSizeYZ/2,CalorSizeYZ/2);
|
||||
|
||||
logicAbsorber = new G4LogicalVolume(solidAbsorber, //its solid
|
||||
AbsorberMaterial, //its material
|
||||
AbsorberMaterial->GetName()); //name
|
||||
|
||||
physiAbsorber = new G4PVPlacement(0, //no rotation
|
||||
G4ThreeVector(-GapThickness/2,0.,0.), //its position
|
||||
logicAbsorber, //its logical volume
|
||||
AbsorberMaterial->GetName(), //its name
|
||||
logicLayer, //its mother
|
||||
false, //no boulean operat
|
||||
0); //copy number
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Gap
|
||||
//
|
||||
solidGap=0; logicGap=0; physiGap=0;
|
||||
|
||||
if (GapThickness > 0.)
|
||||
{ solidGap = new G4Box("Gap",
|
||||
GapThickness/2,CalorSizeYZ/2,CalorSizeYZ/2);
|
||||
|
||||
logicGap = new G4LogicalVolume(solidGap,
|
||||
GapMaterial,
|
||||
GapMaterial->GetName());
|
||||
|
||||
physiGap = new G4PVPlacement(0, //no rotation
|
||||
G4ThreeVector(AbsorberThickness/2,0.,0.), //its position
|
||||
logicGap, //its logical volume
|
||||
GapMaterial->GetName(), //its name
|
||||
logicLayer, //its mother
|
||||
false, //no boulean operat
|
||||
0); //copy number
|
||||
}
|
||||
|
||||
PrintCalorParameters();
|
||||
|
||||
//
|
||||
// Visualization attributes
|
||||
//
|
||||
logicWorld->SetVisAttributes (G4VisAttributes::GetInvisible());
|
||||
|
||||
G4VisAttributes* simpleBoxVisAtt= new G4VisAttributes(G4Colour(1.0,1.0,1.0));
|
||||
simpleBoxVisAtt->SetVisibility(true);
|
||||
logicCalor->SetVisAttributes(simpleBoxVisAtt);
|
||||
|
||||
/*
|
||||
// Below are vis attributes that permits someone to test / play
|
||||
// with the interactive expansion / contraction geometry system of the
|
||||
// vis/OpenInventor driver :
|
||||
{G4VisAttributes* simpleBoxVisAtt= new G4VisAttributes(G4Colour(1.0,1.0,0.0));
|
||||
simpleBoxVisAtt->SetVisibility(true);
|
||||
delete logicCalor->GetVisAttributes();
|
||||
logicCalor->SetVisAttributes(simpleBoxVisAtt);}
|
||||
|
||||
{G4VisAttributes* atb= new G4VisAttributes(G4Colour(1.0,0.0,0.0));
|
||||
logicLayer->SetVisAttributes(atb);}
|
||||
|
||||
{G4VisAttributes* atb= new G4VisAttributes(G4Colour(0.0,1.0,0.0));
|
||||
atb->SetForceSolid(true);
|
||||
logicAbsorber->SetVisAttributes(atb);}
|
||||
|
||||
{//Set opacity = 0.2 then transparency = 1 - 0.2 = 0.8
|
||||
G4VisAttributes* atb= new G4VisAttributes(G4Colour(0.0,0.0,1.0,0.2));
|
||||
atb->SetForceSolid(true);
|
||||
logicGap->SetVisAttributes(atb);}
|
||||
*/
|
||||
|
||||
//
|
||||
//always return the physical World
|
||||
//
|
||||
return physiWorld;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void ExN03DetectorConstruction::PrintCalorParameters()
|
||||
{
|
||||
G4cout << "\n------------------------------------------------------------"
|
||||
<< "\n---> The calorimeter is " << NbOfLayers << " layers of: [ "
|
||||
<< AbsorberThickness/mm << "mm of " << AbsorberMaterial->GetName()
|
||||
<< " + "
|
||||
<< GapThickness/mm << "mm of " << GapMaterial->GetName() << " ] "
|
||||
<< "\n------------------------------------------------------------\n";
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void ExN03DetectorConstruction::SetAbsorberMaterial(G4String materialChoice)
|
||||
{
|
||||
// search the material by its name
|
||||
G4Material* pttoMaterial = G4Material::GetMaterial(materialChoice);
|
||||
if (pttoMaterial) AbsorberMaterial = pttoMaterial;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void ExN03DetectorConstruction::SetGapMaterial(G4String materialChoice)
|
||||
{
|
||||
// search the material by its name
|
||||
G4Material* pttoMaterial = G4Material::GetMaterial(materialChoice);
|
||||
if (pttoMaterial) GapMaterial = pttoMaterial;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void ExN03DetectorConstruction::SetAbsorberThickness(G4double val)
|
||||
{
|
||||
// change Absorber thickness and recompute the calorimeter parameters
|
||||
AbsorberThickness = val;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void ExN03DetectorConstruction::SetGapThickness(G4double val)
|
||||
{
|
||||
// change Gap thickness and recompute the calorimeter parameters
|
||||
GapThickness = val;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void ExN03DetectorConstruction::SetCalorSizeYZ(G4double val)
|
||||
{
|
||||
// change the transverse size and recompute the calorimeter parameters
|
||||
CalorSizeYZ = val;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void ExN03DetectorConstruction::SetNbOfLayers(G4int val)
|
||||
{
|
||||
NbOfLayers = val;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "G4FieldManager.hh"
|
||||
#include "G4TransportationManager.hh"
|
||||
|
||||
void ExN03DetectorConstruction::SetMagField(G4double fieldValue)
|
||||
{
|
||||
//apply a global uniform magnetic field along Z axis
|
||||
G4FieldManager* fieldMgr
|
||||
= G4TransportationManager::GetTransportationManager()->GetFieldManager();
|
||||
|
||||
if(magField) delete magField; //delete the existing magn field
|
||||
|
||||
if(fieldValue!=0.) // create a new one if non nul
|
||||
{ magField = new G4UniformMagField(G4ThreeVector(0.,0.,fieldValue));
|
||||
fieldMgr->SetDetectorField(magField);
|
||||
fieldMgr->CreateChordFinder(magField);
|
||||
} else {
|
||||
magField = 0;
|
||||
fieldMgr->SetDetectorField(magField);
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "G4RunManager.hh"
|
||||
|
||||
void ExN03DetectorConstruction::UpdateGeometry()
|
||||
{
|
||||
G4RunManager::GetRunManager()->DefineWorldVolume(ConstructCalorimeter());
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -0,0 +1,157 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#ifndef ExN03DetectorConstruction_h
|
||||
#define ExN03DetectorConstruction_h 1
|
||||
|
||||
#include "G4VUserDetectorConstruction.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
class G4Box;
|
||||
class G4LogicalVolume;
|
||||
class G4VPhysicalVolume;
|
||||
class G4Material;
|
||||
class G4UniformMagField;
|
||||
class ExN03DetectorMessenger;
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
class ExN03DetectorConstruction : public G4VUserDetectorConstruction
|
||||
{
|
||||
public:
|
||||
|
||||
ExN03DetectorConstruction();
|
||||
~ExN03DetectorConstruction();
|
||||
|
||||
public:
|
||||
|
||||
void SetAbsorberMaterial (G4String);
|
||||
void SetAbsorberThickness(G4double);
|
||||
|
||||
void SetGapMaterial (G4String);
|
||||
void SetGapThickness(G4double);
|
||||
|
||||
void SetCalorSizeYZ(G4double);
|
||||
void SetNbOfLayers (G4int);
|
||||
|
||||
void SetMagField(G4double);
|
||||
|
||||
G4VPhysicalVolume* Construct();
|
||||
|
||||
void UpdateGeometry();
|
||||
|
||||
public:
|
||||
|
||||
void PrintCalorParameters();
|
||||
|
||||
G4double GetWorldSizeX() {return WorldSizeX;};
|
||||
G4double GetWorldSizeYZ() {return WorldSizeYZ;};
|
||||
|
||||
G4double GetCalorThickness() {return CalorThickness;};
|
||||
G4double GetCalorSizeYZ() {return CalorSizeYZ;};
|
||||
|
||||
G4int GetNbOfLayers() {return NbOfLayers;};
|
||||
|
||||
G4Material* GetAbsorberMaterial() {return AbsorberMaterial;};
|
||||
G4double GetAbsorberThickness() {return AbsorberThickness;};
|
||||
|
||||
G4Material* GetGapMaterial() {return GapMaterial;};
|
||||
G4double GetGapThickness() {return GapThickness;};
|
||||
|
||||
const G4VPhysicalVolume* GetphysiWorld() {return physiWorld;};
|
||||
const G4VPhysicalVolume* GetAbsorber() {return physiAbsorber;};
|
||||
const G4VPhysicalVolume* GetGap() {return physiGap;};
|
||||
|
||||
private:
|
||||
|
||||
G4Material* AbsorberMaterial;
|
||||
G4double AbsorberThickness;
|
||||
|
||||
G4Material* GapMaterial;
|
||||
G4double GapThickness;
|
||||
|
||||
G4int NbOfLayers;
|
||||
G4double LayerThickness;
|
||||
|
||||
G4double CalorSizeYZ;
|
||||
G4double CalorThickness;
|
||||
|
||||
G4Material* defaultMaterial;
|
||||
G4double WorldSizeYZ;
|
||||
G4double WorldSizeX;
|
||||
|
||||
G4Box* solidWorld; //pointer to the solid World
|
||||
G4LogicalVolume* logicWorld; //pointer to the logical World
|
||||
G4VPhysicalVolume* physiWorld; //pointer to the physical World
|
||||
|
||||
G4Box* solidCalor; //pointer to the solid Calor
|
||||
G4LogicalVolume* logicCalor; //pointer to the logical Calor
|
||||
G4VPhysicalVolume* physiCalor; //pointer to the physical Calor
|
||||
|
||||
G4Box* solidLayer; //pointer to the solid Layer
|
||||
G4LogicalVolume* logicLayer; //pointer to the logical Layer
|
||||
G4VPhysicalVolume* physiLayer; //pointer to the physical Layer
|
||||
|
||||
G4Box* solidAbsorber; //pointer to the solid Absorber
|
||||
G4LogicalVolume* logicAbsorber; //pointer to the logical Absorber
|
||||
G4VPhysicalVolume* physiAbsorber; //pointer to the physical Absorber
|
||||
|
||||
G4Box* solidGap; //pointer to the solid Gap
|
||||
G4LogicalVolume* logicGap; //pointer to the logical Gap
|
||||
G4VPhysicalVolume* physiGap; //pointer to the physical Gap
|
||||
|
||||
G4UniformMagField* magField; //pointer to the magnetic field
|
||||
|
||||
ExN03DetectorMessenger* detectorMessenger; //pointer to the Messenger
|
||||
|
||||
private:
|
||||
|
||||
void DefineMaterials();
|
||||
void ComputeCalorParameters();
|
||||
G4VPhysicalVolume* ConstructCalorimeter();
|
||||
};
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
inline void ExN03DetectorConstruction::ComputeCalorParameters()
|
||||
{
|
||||
// Compute derived parameters of the calorimeter
|
||||
LayerThickness = AbsorberThickness + GapThickness;
|
||||
CalorThickness = NbOfLayers*LayerThickness;
|
||||
|
||||
WorldSizeX = 1.2*CalorThickness; WorldSizeYZ = 1.2*CalorSizeYZ;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,148 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "ExN03DetectorMessenger.hh"
|
||||
|
||||
#include "ExN03DetectorConstruction.hh"
|
||||
#include "G4UIdirectory.hh"
|
||||
#include "G4UIcmdWithAString.hh"
|
||||
#include "G4UIcmdWithAnInteger.hh"
|
||||
#include "G4UIcmdWithADoubleAndUnit.hh"
|
||||
#include "G4UIcmdWithoutParameter.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
ExN03DetectorMessenger::ExN03DetectorMessenger(
|
||||
ExN03DetectorConstruction* ExN03Det)
|
||||
:ExN03Detector(ExN03Det)
|
||||
{
|
||||
N03Dir = new G4UIdirectory("/N03/");
|
||||
N03Dir->SetGuidance("UI commands of this example");
|
||||
|
||||
detDir = new G4UIdirectory("/N03/det/");
|
||||
detDir->SetGuidance("detector control");
|
||||
|
||||
AbsMaterCmd = new G4UIcmdWithAString("/N03/det/setAbsMat",this);
|
||||
AbsMaterCmd->SetGuidance("Select Material of the Absorber.");
|
||||
AbsMaterCmd->SetParameterName("choice",false);
|
||||
AbsMaterCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
|
||||
GapMaterCmd = new G4UIcmdWithAString("/N03/det/setGapMat",this);
|
||||
GapMaterCmd->SetGuidance("Select Material of the Gap.");
|
||||
GapMaterCmd->SetParameterName("choice",false);
|
||||
GapMaterCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
|
||||
AbsThickCmd = new G4UIcmdWithADoubleAndUnit("/N03/det/setAbsThick",this);
|
||||
AbsThickCmd->SetGuidance("Set Thickness of the Absorber");
|
||||
AbsThickCmd->SetParameterName("Size",false);
|
||||
AbsThickCmd->SetRange("Size>=0.");
|
||||
AbsThickCmd->SetUnitCategory("Length");
|
||||
AbsThickCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
|
||||
GapThickCmd = new G4UIcmdWithADoubleAndUnit("/N03/det/setGapThick",this);
|
||||
GapThickCmd->SetGuidance("Set Thickness of the Gap");
|
||||
GapThickCmd->SetParameterName("Size",false);
|
||||
GapThickCmd->SetRange("Size>=0.");
|
||||
GapThickCmd->SetUnitCategory("Length");
|
||||
GapThickCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
|
||||
SizeYZCmd = new G4UIcmdWithADoubleAndUnit("/N03/det/setSizeYZ",this);
|
||||
SizeYZCmd->SetGuidance("Set tranverse size of the calorimeter");
|
||||
SizeYZCmd->SetParameterName("Size",false);
|
||||
SizeYZCmd->SetRange("Size>0.");
|
||||
SizeYZCmd->SetUnitCategory("Length");
|
||||
SizeYZCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
|
||||
NbLayersCmd = new G4UIcmdWithAnInteger("/N03/det/setNbOfLayers",this);
|
||||
NbLayersCmd->SetGuidance("Set number of layers.");
|
||||
NbLayersCmd->SetParameterName("NbLayers",false);
|
||||
NbLayersCmd->SetRange("NbLayers>0 && NbLayers<500");
|
||||
NbLayersCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
|
||||
UpdateCmd = new G4UIcmdWithoutParameter("/N03/det/update",this);
|
||||
UpdateCmd->SetGuidance("Update calorimeter geometry.");
|
||||
UpdateCmd->SetGuidance("This command MUST be applied before \"beamOn\" ");
|
||||
UpdateCmd->SetGuidance("if you changed geometrical value(s).");
|
||||
UpdateCmd->AvailableForStates(G4State_Idle);
|
||||
|
||||
MagFieldCmd = new G4UIcmdWithADoubleAndUnit("/N03/det/setField",this);
|
||||
MagFieldCmd->SetGuidance("Define magnetic field.");
|
||||
MagFieldCmd->SetGuidance("Magnetic field will be in Z direction.");
|
||||
MagFieldCmd->SetParameterName("Bz",false);
|
||||
MagFieldCmd->SetUnitCategory("Magnetic flux density");
|
||||
MagFieldCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
ExN03DetectorMessenger::~ExN03DetectorMessenger()
|
||||
{
|
||||
delete NbLayersCmd;
|
||||
delete AbsMaterCmd; delete GapMaterCmd;
|
||||
delete AbsThickCmd; delete GapThickCmd;
|
||||
delete SizeYZCmd; delete UpdateCmd;
|
||||
delete MagFieldCmd;
|
||||
delete detDir;
|
||||
delete N03Dir;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void ExN03DetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue)
|
||||
{
|
||||
if( command == AbsMaterCmd )
|
||||
{ ExN03Detector->SetAbsorberMaterial(newValue);}
|
||||
|
||||
if( command == GapMaterCmd )
|
||||
{ ExN03Detector->SetGapMaterial(newValue);}
|
||||
|
||||
if( command == AbsThickCmd )
|
||||
{ ExN03Detector->SetAbsorberThickness(AbsThickCmd
|
||||
->GetNewDoubleValue(newValue));}
|
||||
|
||||
if( command == GapThickCmd )
|
||||
{ ExN03Detector->SetGapThickness(GapThickCmd->GetNewDoubleValue(newValue));}
|
||||
|
||||
if( command == SizeYZCmd )
|
||||
{ ExN03Detector->SetCalorSizeYZ(SizeYZCmd->GetNewDoubleValue(newValue));}
|
||||
|
||||
if( command == NbLayersCmd )
|
||||
{ ExN03Detector->SetNbOfLayers(NbLayersCmd->GetNewIntValue(newValue));}
|
||||
|
||||
if( command == UpdateCmd )
|
||||
{ ExN03Detector->UpdateGeometry(); }
|
||||
|
||||
if( command == MagFieldCmd )
|
||||
{ ExN03Detector->SetMagField(MagFieldCmd->GetNewDoubleValue(newValue));}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -0,0 +1,74 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#ifndef ExN03DetectorMessenger_h
|
||||
#define ExN03DetectorMessenger_h 1
|
||||
|
||||
#include "globals.hh"
|
||||
#include "G4UImessenger.hh"
|
||||
|
||||
class ExN03DetectorConstruction;
|
||||
class G4UIdirectory;
|
||||
class G4UIcmdWithAString;
|
||||
class G4UIcmdWithAnInteger;
|
||||
class G4UIcmdWithADoubleAndUnit;
|
||||
class G4UIcmdWithoutParameter;
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
class ExN03DetectorMessenger: public G4UImessenger
|
||||
{
|
||||
public:
|
||||
ExN03DetectorMessenger(ExN03DetectorConstruction* );
|
||||
~ExN03DetectorMessenger();
|
||||
|
||||
void SetNewValue(G4UIcommand*, G4String);
|
||||
|
||||
private:
|
||||
ExN03DetectorConstruction* ExN03Detector;
|
||||
|
||||
G4UIdirectory* N03Dir;
|
||||
G4UIdirectory* detDir;
|
||||
G4UIcmdWithAString* AbsMaterCmd;
|
||||
G4UIcmdWithAString* GapMaterCmd;
|
||||
G4UIcmdWithADoubleAndUnit* AbsThickCmd;
|
||||
G4UIcmdWithADoubleAndUnit* GapThickCmd;
|
||||
G4UIcmdWithADoubleAndUnit* SizeYZCmd;
|
||||
G4UIcmdWithAnInteger* NbLayersCmd;
|
||||
G4UIcmdWithADoubleAndUnit* MagFieldCmd;
|
||||
G4UIcmdWithoutParameter* UpdateCmd;
|
||||
};
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
from ._ExN03geom import *
|
||||
@@ -0,0 +1,101 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// ====================================================================
|
||||
// pyExN03geom.cc
|
||||
//
|
||||
// [ExN03geom]
|
||||
// a site-module of Geant4Py
|
||||
//
|
||||
// geometry presented in ExN03 of Geant4 example
|
||||
//
|
||||
// 2005 Q
|
||||
// ====================================================================
|
||||
#include <boost/python.hpp>
|
||||
#include "G4RunManager.hh"
|
||||
#include "ExN03DetectorConstruction.hh"
|
||||
|
||||
using namespace boost::python;
|
||||
|
||||
typedef ExN03DetectorConstruction XXX;
|
||||
|
||||
// ====================================================================
|
||||
// thin wrappers
|
||||
// ====================================================================
|
||||
namespace pyExN03geom {
|
||||
|
||||
void Construct()
|
||||
{
|
||||
G4RunManager* runMgr= G4RunManager::GetRunManager();
|
||||
runMgr-> SetUserInitialization(new ExN03DetectorConstruction);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
using namespace pyExN03geom;
|
||||
|
||||
// ====================================================================
|
||||
// Expose to Python
|
||||
// ====================================================================
|
||||
|
||||
BOOST_PYTHON_MODULE(_ExN03geom) {
|
||||
class_<ExN03DetectorConstruction, ExN03DetectorConstruction*,
|
||||
bases<G4VUserDetectorConstruction> >
|
||||
("ExN03DetectorConstruction", "ExN03 detector")
|
||||
// ---
|
||||
.def("SetAbsorberMaterial", &XXX::SetAbsorberMaterial)
|
||||
.def("SetAbsorberThickness", &XXX::SetAbsorberThickness)
|
||||
.def("SetGapMaterial", &XXX::SetGapMaterial)
|
||||
.def("SetGapThickness", &XXX::SetGapThickness)
|
||||
.def("SetCalorSizeYZ", &XXX::SetCalorSizeYZ)
|
||||
.def("SetNbOfLayers", &XXX::SetNbOfLayers)
|
||||
.def("SetMagField", &XXX::SetMagField)
|
||||
// ---
|
||||
.def("GetWorldSizeX", &XXX::GetWorldSizeX)
|
||||
.def("GetWorldSizeYZ", &XXX::GetWorldSizeYZ)
|
||||
.def("GetCalorThickness", &XXX::GetCalorThickness)
|
||||
.def("GetCalorSizeYZ", &XXX::GetCalorSizeYZ)
|
||||
.def("GetNbOfLayers", &XXX::GetNbOfLayers)
|
||||
.def("GetAbsorberMaterial", &XXX::GetAbsorberMaterial,
|
||||
return_value_policy<reference_existing_object>())
|
||||
.def("GetAbsorberThickness", &XXX::GetAbsorberThickness)
|
||||
.def("GetGapMaterial", &XXX::GetGapMaterial,
|
||||
return_value_policy<reference_existing_object>())
|
||||
.def("GetGapThickness", &XXX::GetGapThickness)
|
||||
.def("GetphysiWorld", &XXX::GetphysiWorld,
|
||||
return_value_policy<reference_existing_object>())
|
||||
.def("GetAbsorber", &XXX::GetAbsorber,
|
||||
return_value_policy<reference_existing_object>())
|
||||
.def("GetGap", &XXX::GetGap,
|
||||
return_value_policy<reference_existing_object>())
|
||||
// ---
|
||||
.def("UpdateGeometry", &XXX::UpdateGeometry)
|
||||
.def("PrintCalorParameters", &XXX::PrintCalorParameters)
|
||||
;
|
||||
|
||||
// ---
|
||||
def("Construct", Construct);
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -0,0 +1,189 @@
|
||||
"""
|
||||
Python module
|
||||
|
||||
This module provides ROOT IO interface for MCScore data
|
||||
|
||||
[C] MCScoreROOTIO
|
||||
[f] loop_tree(tfile, analyze_vertex):
|
||||
|
||||
Q, 2006
|
||||
"""
|
||||
from array import array
|
||||
import string
|
||||
from Geant4.hepunit import *
|
||||
import mcscore
|
||||
import ROOT
|
||||
|
||||
# ==================================================================
|
||||
# public symbols
|
||||
# ==================================================================
|
||||
__all__ = [ 'MCScoreROOTIO', 'loop_tree' ]
|
||||
|
||||
|
||||
# ==================================================================
|
||||
# class definition
|
||||
# ==================================================================
|
||||
# ------------------------------------------------------------------
|
||||
# MCScoreROOTIO
|
||||
# ------------------------------------------------------------------
|
||||
class MCScoreROOTIO:
|
||||
"ROOT IO interface for MCScore"
|
||||
def __init__(self, bsize=250):
|
||||
self.maxparticle = bsize # buffer size for #particles/vertex
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
def define_tree(self):
|
||||
"define ROOT tree"
|
||||
# defining tree header...
|
||||
self.vtree = ROOT.TTree('vertex', 'mc vertex')
|
||||
self.ptree = ROOT.TTree('particle', 'mc particle')
|
||||
|
||||
# vertex...
|
||||
self.a_x = array('d', [0.]); self.vtree.Branch('x', self.a_x, 'x/d')
|
||||
self.a_y = array('d', [0.]); self.vtree.Branch('y', self.a_y, 'y/d')
|
||||
self.a_z = array('d', [0.]); self.vtree.Branch('z', self.a_z, 'z/d')
|
||||
|
||||
#global a_np, a_namelist, a_Z, a_A, a_ke, a_px, a_py, a_pz
|
||||
self.a_np = array('i', [0]); self.ptree.Branch('np', self.a_np, 'np/i')
|
||||
|
||||
self.a_namelist = array('c', self.maxparticle*10*['\0'])
|
||||
# 10 characters/particle
|
||||
self.ptree.Branch('namelist', self.a_namelist, 'namelist/C')
|
||||
|
||||
self.a_Z = array('i', self.maxparticle*[0])
|
||||
self.ptree.Branch('Z', self.a_Z, 'Z[np]/I')
|
||||
|
||||
self.a_A = array('i', self.maxparticle*[0])
|
||||
self.ptree.Branch('A', self.a_A, 'A[np]/i')
|
||||
|
||||
self.a_ke = array('d', self.maxparticle*[0.])
|
||||
self.ptree.Branch('kE', self.a_ke, 'kE[np]/d')
|
||||
|
||||
self.a_px = array('d', self.maxparticle*[0.])
|
||||
self.ptree.Branch('px', self.a_px, 'px[np]/d')
|
||||
|
||||
self.a_py = array('d', self.maxparticle*[0.])
|
||||
self.ptree.Branch('py', self.a_py, 'py[np]/d')
|
||||
|
||||
self.a_pz = array('d', self.maxparticle*[0.])
|
||||
self.ptree.Branch('pz', self.a_pz, 'pz[np]/d')
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
def fill_tree(self, vertex):
|
||||
"fill vertex information to ROOT tree"
|
||||
# ------------------------------------------------------------------
|
||||
def push_pname(i0, pname): # local function
|
||||
n = len(pname)
|
||||
for i in xrange(n):
|
||||
self.a_namelist[i0+i] = pname[i]
|
||||
self.a_namelist[i0+n] = ' '
|
||||
|
||||
self.a_x[0] = vertex.x
|
||||
self.a_y[0] = vertex.y
|
||||
self.a_z[0] = vertex.z
|
||||
self.vtree.Fill()
|
||||
|
||||
if vertex.nparticle > self.maxparticle:
|
||||
raise """
|
||||
*** buffer overflow in #particles/vertex.
|
||||
*** please increment buffersize in MCScoreROOTIO(bsize).
|
||||
""", self.maxparticle
|
||||
|
||||
idx_namelist = 0
|
||||
self.a_np[0] = vertex.nparticle
|
||||
for ip in range(vertex.nparticle):
|
||||
particle = vertex.particle_list[ip]
|
||||
push_pname(idx_namelist, particle.name)
|
||||
idx_namelist += (len(particle.name)+1)
|
||||
self.a_Z[ip] = particle.Z
|
||||
self.a_A[ip] = particle.A
|
||||
self.a_ke[ip] = particle.kineticE
|
||||
self.a_px[ip] = particle.px
|
||||
self.a_py[ip] = particle.py
|
||||
self.a_pz[ip] = particle.pz
|
||||
|
||||
self.a_namelist[idx_namelist] = '\0'
|
||||
self.ptree.Fill()
|
||||
|
||||
|
||||
# ==================================================================
|
||||
# functions
|
||||
# ==================================================================
|
||||
def loop_tree(tfile, analyze_vertex):
|
||||
"""
|
||||
loop ROOT tree in a ROOT file.
|
||||
* analyze_vertex: user function : analyze_vertex(MCVertex)
|
||||
"""
|
||||
avtree = tfile.Get("vertex")
|
||||
aptree = tfile.Get("particle")
|
||||
|
||||
# reading vertex...
|
||||
n_vertex = avtree.GetEntries()
|
||||
for ivtx in xrange(n_vertex):
|
||||
avtree.GetEntry(ivtx)
|
||||
aptree.GetEntry(ivtx)
|
||||
|
||||
# vertex
|
||||
vertex = MCScore.MCVertex(avtree.x, avtree.y, avtree.z)
|
||||
|
||||
# reading secondary particles...
|
||||
nsec = aptree.np
|
||||
namelist = aptree.namelist
|
||||
pname = namelist.split()
|
||||
for ip in xrange(nsec):
|
||||
particle = MCScore.MCParticle(pname[ip], aptree.Z[ip], aptree.A[ip],
|
||||
aptree.kE[ip], aptree.px[ip],
|
||||
aptree.py[ip], aptree.pz[ip])
|
||||
vertex.append_particle(particle)
|
||||
|
||||
analyze_vertex(vertex)
|
||||
|
||||
return n_vertex
|
||||
|
||||
|
||||
# ==================================================================
|
||||
# test
|
||||
# ==================================================================
|
||||
def test_t2root():
|
||||
g = ROOT.TFile("reaction.root", 'recreate')
|
||||
|
||||
rootio = MCScoreROOTIO()
|
||||
rootio.define_tree()
|
||||
|
||||
f = open("reaction.dat")
|
||||
f.seek(0)
|
||||
|
||||
while(1):
|
||||
vertex = MCScore.read_next_vertex(f)
|
||||
if vertex == 0:
|
||||
break
|
||||
|
||||
# filling ...
|
||||
rootio.fill_tree(vertex)
|
||||
|
||||
del vertex
|
||||
|
||||
print ">>> EOF"
|
||||
f.close()
|
||||
|
||||
# closing ROOT file
|
||||
g.Write()
|
||||
g.Close()
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
def test_loop():
|
||||
def my_analysis(vertex):
|
||||
vertex.printout()
|
||||
|
||||
f = ROOT.TFile("reaction.root", 'read')
|
||||
nv = loop_tree(f, my_analysis)
|
||||
print "*** # of vertex= ", nv
|
||||
|
||||
|
||||
# ==================================================================
|
||||
# main
|
||||
# ==================================================================
|
||||
if __name__ == "__main__":
|
||||
test_t2root()
|
||||
test_loop()
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,4 @@
|
||||
# - build library
|
||||
set(_TARGET _MedicalBeam)
|
||||
g4pytest_add_module(${_TARGET} MedicalBeam.cc pyMedicalBeam.cc)
|
||||
target_link_libraries(${_TARGET} PRIVATE G4run G4particles)
|
||||
@@ -0,0 +1,136 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// ====================================================================
|
||||
// MedicalBeam.cc
|
||||
//
|
||||
// 2005 Q
|
||||
// ====================================================================
|
||||
#include "MedicalBeam.hh"
|
||||
#include "Randomize.hh"
|
||||
#include "G4Event.hh"
|
||||
#include "G4ParticleTable.hh"
|
||||
#include "G4PrimaryVertex.hh"
|
||||
|
||||
using namespace CLHEP;
|
||||
|
||||
#include <cmath>
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// class description
|
||||
//
|
||||
// ====================================================================
|
||||
|
||||
///////////////////////////////////
|
||||
MedicalBeam::MedicalBeam()
|
||||
: particle(0),
|
||||
kineticE(1.*MeV),
|
||||
sourcePosition(G4ThreeVector()),
|
||||
SSD(1.*m),
|
||||
fieldShape(MedicalBeam::SQUARE),
|
||||
fieldR(10.*cm)
|
||||
///////////////////////////////////
|
||||
{
|
||||
fieldXY[0]= fieldXY[1]= 10.*cm;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////
|
||||
MedicalBeam::~MedicalBeam()
|
||||
///////////////////////////
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
G4ThreeVector MedicalBeam::GenerateBeamDirection() const
|
||||
////////////////////////////////////////////////////////
|
||||
{
|
||||
// uniform distribution in a limitted solid angle
|
||||
G4double dr;
|
||||
if(fieldShape == MedicalBeam::SQUARE) {
|
||||
dr= std::sqrt(sqr(fieldXY[0]/2.)+sqr(fieldXY[1]/2.));
|
||||
} else {
|
||||
dr= fieldR;
|
||||
}
|
||||
|
||||
G4double sin0= dr/SSD;
|
||||
G4double cos0= std::sqrt(1.-sqr(sin0));
|
||||
|
||||
G4double x= DBL_MAX;
|
||||
G4double y= DBL_MAX;
|
||||
|
||||
G4double xmax, ymax;
|
||||
if(fieldShape == MedicalBeam::SQUARE) {
|
||||
xmax= fieldXY[0]/2./SSD;
|
||||
ymax= fieldXY[1]/2./SSD;
|
||||
} else {
|
||||
xmax= ymax= DBL_MAX-1.;
|
||||
}
|
||||
|
||||
G4double dcos{0.0};
|
||||
G4double dsin{0.0};
|
||||
G4double dphi{0.0};
|
||||
|
||||
while(! (std::abs(x)< xmax && std::abs(y)< ymax) ) {
|
||||
dcos= RandFlat::shoot(cos0, 1.);
|
||||
dsin= std::sqrt(1.-sqr(dcos));
|
||||
dphi= RandFlat::shoot(0., twopi);
|
||||
|
||||
x= std::cos(dphi)*dsin*dcos;
|
||||
y= std::sin(dphi)*dsin*dcos;
|
||||
}
|
||||
|
||||
G4double z= dcos;
|
||||
|
||||
return G4ThreeVector(x,y,z);
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
void MedicalBeam::GeneratePrimaries(G4Event* anEvent)
|
||||
/////////////////////////////////////////////////////
|
||||
{
|
||||
if(particle==0) return;
|
||||
|
||||
// create a new vertex
|
||||
G4PrimaryVertex* vertex= new G4PrimaryVertex(sourcePosition, 0.*ns);
|
||||
|
||||
// momentum
|
||||
G4double mass= particle-> GetPDGMass();
|
||||
G4double p= std::sqrt(sqr(mass+kineticE)-sqr(mass));
|
||||
G4ThreeVector pmon= p*GenerateBeamDirection();
|
||||
G4PrimaryParticle* primary= new G4PrimaryParticle(particle,
|
||||
pmon.x(),
|
||||
pmon.y(),
|
||||
pmon.z());
|
||||
// set primary to vertex
|
||||
vertex-> SetPrimary(primary);
|
||||
|
||||
// set vertex to event
|
||||
anEvent-> AddPrimaryVertex(vertex);
|
||||
}
|
||||
|
||||
@@ -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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// ====================================================================
|
||||
// MedicalBeam.hh
|
||||
//
|
||||
// 2005 Q
|
||||
// ====================================================================
|
||||
#ifndef MEDICAL_BEAM_H
|
||||
#define MEDICAL_BEAM_H
|
||||
|
||||
#include "globals.hh"
|
||||
#include "G4ThreeVector.hh"
|
||||
#include "G4VUserPrimaryGeneratorAction.hh"
|
||||
|
||||
class G4ParticleDefinition;
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// class definition
|
||||
//
|
||||
// ====================================================================
|
||||
class MedicalBeam : public G4VUserPrimaryGeneratorAction {
|
||||
public:
|
||||
enum FieldShape{ SQUARE=0, CIRCLE };
|
||||
|
||||
protected:
|
||||
G4ParticleDefinition* particle;
|
||||
G4double kineticE;
|
||||
G4ThreeVector sourcePosition;
|
||||
|
||||
G4double SSD; // (SSD= Source Skin Depth)
|
||||
FieldShape fieldShape;
|
||||
G4double fieldXY[2];
|
||||
G4double fieldR;
|
||||
|
||||
// local methods...
|
||||
G4ThreeVector GenerateBeamDirection() const;
|
||||
|
||||
public:
|
||||
MedicalBeam();
|
||||
~MedicalBeam();
|
||||
|
||||
// set/get functions...
|
||||
void SetParticleDefinition(G4ParticleDefinition* pd);
|
||||
const G4ParticleDefinition* GetParticleDefinition() const;
|
||||
|
||||
void SetKineticE(G4double e);
|
||||
G4double GetKineticE() const;
|
||||
|
||||
void SetSourcePosition(const G4ThreeVector& pos);
|
||||
G4ThreeVector GetSourcePosition() const;
|
||||
|
||||
void SetFieldShape(FieldShape shape);
|
||||
FieldShape GetFieldShape() const;
|
||||
|
||||
void SetSSD(G4double ssd);
|
||||
G4double GetSSD() const;
|
||||
|
||||
void SetFieldXY(G4double fx, G4double fy);
|
||||
G4double GetFieldX() const;
|
||||
G4double GetFieldY() const;
|
||||
|
||||
void SetFieldR(G4double r);
|
||||
G4double GetFieldR() const;
|
||||
|
||||
// methods...
|
||||
virtual void GeneratePrimaries(G4Event* anEvent);
|
||||
|
||||
};
|
||||
|
||||
// ====================================================================
|
||||
// inline functions
|
||||
// ====================================================================
|
||||
inline void MedicalBeam::SetParticleDefinition(G4ParticleDefinition* pd)
|
||||
{ particle= pd; }
|
||||
|
||||
inline const G4ParticleDefinition* MedicalBeam::GetParticleDefinition() const
|
||||
{ return particle; }
|
||||
|
||||
inline void MedicalBeam::SetKineticE(G4double e)
|
||||
{ kineticE= e; }
|
||||
|
||||
inline G4double MedicalBeam::GetKineticE() const
|
||||
{ return kineticE; }
|
||||
|
||||
inline void MedicalBeam::SetSourcePosition(const G4ThreeVector& pos)
|
||||
{ sourcePosition= pos; }
|
||||
|
||||
inline G4ThreeVector MedicalBeam::GetSourcePosition() const
|
||||
{ return sourcePosition; }
|
||||
|
||||
inline void MedicalBeam::SetFieldShape(MedicalBeam::FieldShape shape)
|
||||
{ fieldShape= shape; }
|
||||
|
||||
inline MedicalBeam::FieldShape MedicalBeam::GetFieldShape() const
|
||||
{ return fieldShape; }
|
||||
|
||||
inline void MedicalBeam::SetSSD(G4double ssd)
|
||||
{ SSD= ssd; }
|
||||
|
||||
inline G4double MedicalBeam::GetSSD() const
|
||||
{ return SSD; }
|
||||
|
||||
inline void MedicalBeam::SetFieldXY(G4double fx, G4double fy)
|
||||
{ fieldXY[0]= fx; fieldXY[1]= fy; }
|
||||
|
||||
inline G4double MedicalBeam::GetFieldX() const
|
||||
{ return fieldXY[0]; }
|
||||
|
||||
inline G4double MedicalBeam::GetFieldY() const
|
||||
{ return fieldXY[1]; }
|
||||
|
||||
inline void MedicalBeam::SetFieldR(G4double r)
|
||||
{ fieldR= r; }
|
||||
|
||||
inline G4double MedicalBeam::GetFieldR() const
|
||||
{ return fieldR; }
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
from ._MedicalBeam import *
|
||||
@@ -0,0 +1,162 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// ====================================================================
|
||||
// pyMedicalBeam.cc
|
||||
//
|
||||
// [MedicalBeam]
|
||||
// a site-module of Geant4Py
|
||||
//
|
||||
// primary generator action for medical beam
|
||||
//
|
||||
// 2005 Q
|
||||
// ====================================================================
|
||||
#include <boost/python.hpp>
|
||||
#include "MedicalBeam.hh"
|
||||
#include "G4ParticleTable.hh"
|
||||
#include "G4RunManager.hh"
|
||||
|
||||
using namespace boost::python;
|
||||
|
||||
// ====================================================================
|
||||
// thin wrappers
|
||||
// ====================================================================
|
||||
namespace pyMedicalBeam {
|
||||
|
||||
MedicalBeam* Construct()
|
||||
{
|
||||
G4RunManager* runMgr= G4RunManager::GetRunManager();
|
||||
|
||||
MedicalBeam* medicalbeam= new MedicalBeam();
|
||||
runMgr-> SetUserAction(medicalbeam);
|
||||
|
||||
return medicalbeam;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
void SetParticleByName(MedicalBeam* beam, const std::string& pname)
|
||||
///////////////////////////////////////////////////////////////////
|
||||
{
|
||||
G4ParticleTable* particleTable= G4ParticleTable::GetParticleTable();
|
||||
G4ParticleDefinition* pd= particleTable-> FindParticle(pname);
|
||||
if (pd != 0) {
|
||||
beam-> SetParticleDefinition(pd);
|
||||
} else {
|
||||
G4cout << "*** \"" << pname << "\" is not registered "
|
||||
<< "in available particle list" << G4endl;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////
|
||||
std::string GetParticleByName(MedicalBeam* beam)
|
||||
////////////////////////////////////////////////
|
||||
{
|
||||
const G4ParticleDefinition* pd= beam-> GetParticleDefinition();
|
||||
|
||||
if(pd==0) return std::string("None");
|
||||
else return (pd-> GetParticleName()).c_str();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
void f_SetFieldXY(MedicalBeam* beam, const list& listXY)
|
||||
////////////////////////////////////////////////////////
|
||||
{
|
||||
G4double fx= extract<double>(listXY[0]);
|
||||
G4double fy= extract<double>(listXY[1]);
|
||||
beam-> SetFieldXY(fx, fy);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////
|
||||
list f_GetFieldXY(MedicalBeam* beam)
|
||||
////////////////////////////////////
|
||||
{
|
||||
list listFieldXY;
|
||||
|
||||
listFieldXY.append(beam-> GetFieldX());
|
||||
listFieldXY.append(beam-> GetFieldY());
|
||||
|
||||
return listFieldXY;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
using namespace pyMedicalBeam;
|
||||
|
||||
// ====================================================================
|
||||
// Expose to Python
|
||||
// ====================================================================
|
||||
|
||||
BOOST_PYTHON_MODULE(_MedicalBeam) {
|
||||
class_<MedicalBeam, MedicalBeam*,
|
||||
bases<G4VUserPrimaryGeneratorAction> >
|
||||
("MedicalBeam", "primary generator action with medical beam")
|
||||
// ---
|
||||
.add_property("particle", GetParticleByName, SetParticleByName)
|
||||
.def("SetParticleByName", SetParticleByName)
|
||||
.def("GetParticleByName", GetParticleByName)
|
||||
// ---
|
||||
.add_property("kineticE", &MedicalBeam::GetKineticE,
|
||||
&MedicalBeam::SetKineticE)
|
||||
.def("SetKineticE", &MedicalBeam::SetKineticE)
|
||||
.def("GetKineticE", &MedicalBeam::GetKineticE)
|
||||
// ---
|
||||
.add_property("sourcePosition", &MedicalBeam::GetSourcePosition,
|
||||
&MedicalBeam::SetSourcePosition)
|
||||
.def("SetSourcePosition", &MedicalBeam::SetSourcePosition)
|
||||
.def("GetSourcePosition", &MedicalBeam::GetSourcePosition)
|
||||
// ---
|
||||
.add_property("fieldShape", &MedicalBeam::GetFieldShape,
|
||||
&MedicalBeam::SetFieldShape)
|
||||
.def("SetFieldShape", &MedicalBeam::SetFieldShape)
|
||||
.def("GetFieldShape", &MedicalBeam::GetFieldShape)
|
||||
// ---
|
||||
.add_property("SSD", &MedicalBeam::GetSSD, &MedicalBeam::SetSSD)
|
||||
.def("SetSSD", &MedicalBeam::SetSSD)
|
||||
.def("GetSSD", &MedicalBeam::GetSSD)
|
||||
// ----
|
||||
.add_property("fieldXY", f_GetFieldXY, f_SetFieldXY)
|
||||
.def("SetFieldXY", f_SetFieldXY)
|
||||
.def("GetFieldXY", f_GetFieldXY)
|
||||
.def("GetFieldX", &MedicalBeam::GetFieldX)
|
||||
.def("GetFieldY", &MedicalBeam::GetFieldY)
|
||||
// ---
|
||||
.add_property("fieldR", &MedicalBeam::GetFieldR, &MedicalBeam::SetFieldR)
|
||||
.def("SetFieldR", &MedicalBeam::SetFieldR)
|
||||
.def("GetFieldR", &MedicalBeam::GetFieldR)
|
||||
;
|
||||
|
||||
// enums...
|
||||
enum_<MedicalBeam::FieldShape>("FieldShape")
|
||||
.value("SQUARE", MedicalBeam::SQUARE)
|
||||
.value("CIRCLE", MedicalBeam::CIRCLE)
|
||||
;
|
||||
|
||||
// ---
|
||||
def("Construct", Construct,
|
||||
return_value_policy<reference_existing_object>());
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
# - build library
|
||||
set(_TARGET _NISTmaterials)
|
||||
g4pytest_add_module(${_TARGET} NISTmaterials.cc pyNISTmaterials.cc)
|
||||
target_link_libraries(${_TARGET} PRIVATE G4materials)
|
||||
@@ -0,0 +1,61 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// ====================================================================
|
||||
// NISTmaterials.cc
|
||||
//
|
||||
// 2005 Q
|
||||
// ====================================================================
|
||||
#include "G4NistManager.hh"
|
||||
|
||||
////////////////
|
||||
void Construct()
|
||||
////////////////
|
||||
{
|
||||
G4NistManager* NistMgr = G4NistManager::Instance();
|
||||
|
||||
// define typically used materials
|
||||
NistMgr-> FindOrBuildMaterial("G4_Al");
|
||||
NistMgr-> FindOrBuildMaterial("G4_Si");
|
||||
NistMgr-> FindOrBuildMaterial("G4_Ar");
|
||||
NistMgr-> FindOrBuildMaterial("G4_Cu");
|
||||
NistMgr-> FindOrBuildMaterial("G4_Fe");
|
||||
NistMgr-> FindOrBuildMaterial("G4_Ge");
|
||||
NistMgr-> FindOrBuildMaterial("G4_Ag");
|
||||
NistMgr-> FindOrBuildMaterial("G4_W");
|
||||
NistMgr-> FindOrBuildMaterial("G4_Au");
|
||||
NistMgr-> FindOrBuildMaterial("G4_Pb");
|
||||
|
||||
NistMgr-> FindOrBuildMaterial("G4_AIR");
|
||||
NistMgr-> FindOrBuildMaterial("G4_Galactic");
|
||||
NistMgr-> FindOrBuildMaterial("G4_WATER");
|
||||
NistMgr-> FindOrBuildMaterial("G4_CESIUM_IODIDE");
|
||||
NistMgr-> FindOrBuildMaterial("G4_SODIUM_IODIDE");
|
||||
NistMgr-> FindOrBuildMaterial("G4_PLASTIC_SC_VINYLTOLUENE");
|
||||
NistMgr-> FindOrBuildMaterial("G4_MYLAR");
|
||||
//NistMgr-> FindOrBuildMaterial("G4_GRAPHITE");
|
||||
// bug in G4 (element isnot defined. should be fixed.)
|
||||
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
from ._NISTmaterials import *
|
||||
+14
-17
@@ -24,29 +24,26 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
// ====================================================================
|
||||
// XBase.cc
|
||||
// pyNISTmaterials.cc
|
||||
//
|
||||
// [NISTmaterials]
|
||||
// a site-module of Geant4Py
|
||||
//
|
||||
// NIST materials
|
||||
//
|
||||
// 2005 Q
|
||||
// ====================================================================
|
||||
#include "XBase.hh"
|
||||
#include <iostream>
|
||||
#include <boost/python.hpp>
|
||||
|
||||
using namespace boost::python;
|
||||
|
||||
void Construct();
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// class description
|
||||
//
|
||||
// Expose to Python
|
||||
// ====================================================================
|
||||
|
||||
//////////////
|
||||
XBase::XBase()
|
||||
: ival(100)
|
||||
//////////////
|
||||
{
|
||||
}
|
||||
|
||||
///////////////
|
||||
XBase::~XBase()
|
||||
///////////////
|
||||
{
|
||||
BOOST_PYTHON_MODULE(_NISTmaterials) {
|
||||
def("Construct", Construct);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
# - build library
|
||||
set(_TARGET _ParticleGun)
|
||||
g4pytest_add_module(${_TARGET} ParticleGunAction.cc pyParticleGun.cc)
|
||||
target_link_libraries(${_TARGET} PRIVATE G4run G4particles)
|
||||
+16
-23
@@ -24,44 +24,37 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
// ====================================================================
|
||||
// ZBase.cc
|
||||
// ParticleGunAction.cc
|
||||
//
|
||||
// 2005 Q
|
||||
// ====================================================================
|
||||
#include "ZBase.hh"
|
||||
#include <iostream>
|
||||
|
||||
#include "ParticleGunAction.hh"
|
||||
#include "G4ParticleGun.hh"
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// class description
|
||||
//
|
||||
// ====================================================================
|
||||
|
||||
//////////////
|
||||
ZBase::ZBase()
|
||||
//////////////
|
||||
//////////////////////////////////////
|
||||
ParticleGunAction::ParticleGunAction()
|
||||
//////////////////////////////////////
|
||||
{
|
||||
particleGun= new G4ParticleGun;
|
||||
}
|
||||
|
||||
///////////////
|
||||
ZBase::~ZBase()
|
||||
///////////////
|
||||
///////////////////////////////////////
|
||||
ParticleGunAction::~ParticleGunAction()
|
||||
///////////////////////////////////////
|
||||
{
|
||||
delete particleGun;
|
||||
}
|
||||
|
||||
/////////////////////
|
||||
void ZBase::AMethod()
|
||||
/////////////////////
|
||||
///////////////////////////////////////////////////////////
|
||||
void ParticleGunAction::GeneratePrimaries(G4Event* anEvent)
|
||||
///////////////////////////////////////////////////////////
|
||||
{
|
||||
std::cout << "ZBase::AMethod is called." << std::endl;
|
||||
}
|
||||
|
||||
////////////////////////////////////////
|
||||
void ZBase::VMethod(std::string message)
|
||||
////////////////////////////////////////
|
||||
{
|
||||
std::cout << "ZBase::VMethod is called:"
|
||||
<< message
|
||||
<< std::endl;
|
||||
particleGun-> GeneratePrimaryVertex(anEvent);
|
||||
}
|
||||
|
||||
+17
-25
@@ -24,48 +24,40 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
// ====================================================================
|
||||
// AClass.hh
|
||||
// ParticleGunAction.hh
|
||||
//
|
||||
// 2005 Q
|
||||
// ====================================================================
|
||||
#ifndef ACLASS_H
|
||||
#define ACLASS_H
|
||||
#ifndef PARTICLE_GUN_ACTION_H
|
||||
#define PARTICLE_GUN_ACTION_H
|
||||
|
||||
#include "G4VUserPrimaryGeneratorAction.hh"
|
||||
|
||||
class G4ParticleGun;
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// class definition
|
||||
//
|
||||
// ====================================================================
|
||||
|
||||
class AClass {
|
||||
class ParticleGunAction : public G4VUserPrimaryGeneratorAction {
|
||||
private:
|
||||
int ival;
|
||||
// use G4 particle gun
|
||||
G4ParticleGun* particleGun;
|
||||
|
||||
public:
|
||||
AClass();
|
||||
AClass(int i, double d=0.);
|
||||
~AClass();
|
||||
ParticleGunAction();
|
||||
~ParticleGunAction();
|
||||
|
||||
void SetIVal(int i);
|
||||
int GetIVal() const;
|
||||
|
||||
int AMethod();
|
||||
int AMethod(int i);
|
||||
int AMethod(int i, double d);
|
||||
|
||||
int BMethod();
|
||||
double BMethod(double d);
|
||||
|
||||
double CMethod(int i, double d1=1., double d2=2.);
|
||||
G4ParticleGun* GetParticleGun() const;
|
||||
|
||||
virtual void GeneratePrimaries(G4Event* anEvent);
|
||||
};
|
||||
|
||||
// ====================================================================
|
||||
// inline functions
|
||||
// inline functions
|
||||
// ====================================================================
|
||||
|
||||
inline void AClass::SetIVal(int i) { ival= i; }
|
||||
inline int AClass::GetIVal() const { return ival; }
|
||||
inline G4ParticleGun* ParticleGunAction::GetParticleGun() const
|
||||
{ return particleGun; }
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
from ._ParticleGun import *
|
||||
@@ -0,0 +1,79 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// ====================================================================
|
||||
// pyParticleGun.cc
|
||||
//
|
||||
// [ParticleGun]
|
||||
// a site-module of Geant4Py
|
||||
//
|
||||
// primary generator action with particle gun
|
||||
//
|
||||
// 2005 Q
|
||||
// ====================================================================
|
||||
#include <boost/python.hpp>
|
||||
#include "ParticleGunAction.hh"
|
||||
#include "G4ParticleGun.hh"
|
||||
#include "G4RunManager.hh"
|
||||
|
||||
using namespace boost::python;
|
||||
|
||||
// ====================================================================
|
||||
// thin wrappers
|
||||
// ====================================================================
|
||||
namespace pyParticleGun {
|
||||
|
||||
G4ParticleGun* Construct()
|
||||
{
|
||||
G4RunManager* runMgr= G4RunManager::GetRunManager();
|
||||
|
||||
ParticleGunAction* pga= new ParticleGunAction;
|
||||
runMgr-> SetUserAction(pga);
|
||||
|
||||
return pga-> GetParticleGun();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
using namespace pyParticleGun;
|
||||
|
||||
// ====================================================================
|
||||
// Expose to Python
|
||||
// ====================================================================
|
||||
|
||||
BOOST_PYTHON_MODULE(_ParticleGun) {
|
||||
class_<ParticleGunAction, ParticleGunAction*,
|
||||
bases<G4VUserPrimaryGeneratorAction> >
|
||||
("ParticleGunAction", "primary generator action with particle gun")
|
||||
.def("GetParticleGun", &ParticleGunAction::GetParticleGun,
|
||||
return_internal_reference<>())
|
||||
;
|
||||
|
||||
// ---
|
||||
def("Construct", Construct,
|
||||
return_value_policy<reference_existing_object>());
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
# - build library
|
||||
set(_TARGET _Qgeom)
|
||||
g4pytest_add_module(${_TARGET} QDetectorConstruction.cc pyQgeom.cc)
|
||||
target_link_libraries(${_TARGET} PRIVATE G4materials G4geometry G4run)
|
||||
@@ -0,0 +1,144 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// ====================================================================
|
||||
// QDetectorConstruction.cc
|
||||
//
|
||||
// 2005 Q
|
||||
// ====================================================================
|
||||
#include "QDetectorConstruction.hh"
|
||||
|
||||
#include "G4Material.hh"
|
||||
#include "G4Tubs.hh"
|
||||
#include "G4Box.hh"
|
||||
#include "G4LogicalVolume.hh"
|
||||
#include "G4PVPlacement.hh"
|
||||
#include "G4VisAttributes.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// class description
|
||||
//
|
||||
// ====================================================================
|
||||
|
||||
// constants (detector parameters)
|
||||
static const G4double DXYZ_AREA= 30.*cm;
|
||||
|
||||
//////////////////////////////////////////////
|
||||
QDetectorConstruction::QDetectorConstruction()
|
||||
//////////////////////////////////////////////
|
||||
{
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////
|
||||
QDetectorConstruction::~QDetectorConstruction()
|
||||
///////////////////////////////////////////////
|
||||
{
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
G4VPhysicalVolume* QDetectorConstruction::Construct()
|
||||
/////////////////////////////////////////////////////
|
||||
{
|
||||
G4Material* mate;
|
||||
G4VisAttributes* va;
|
||||
|
||||
// ==============================================================
|
||||
// world volume
|
||||
// ==============================================================
|
||||
G4Box* areaSolid= new G4Box("AREA",
|
||||
DXYZ_AREA/2., DXYZ_AREA/2., DXYZ_AREA/2.);
|
||||
|
||||
G4Material* vacuum= G4Material::GetMaterial("Vacuum");
|
||||
G4LogicalVolume* areaLV= new G4LogicalVolume(areaSolid, vacuum, "AREA_LV");
|
||||
G4PVPlacement* area= new G4PVPlacement(0, G4ThreeVector(), "AREA_PV",
|
||||
areaLV, 0, false, 0);
|
||||
// vis. attributes
|
||||
va= new G4VisAttributes(G4Color(1.,1.,1.));
|
||||
va-> SetForceWireframe(true);
|
||||
areaLV-> SetVisAttributes(va);
|
||||
|
||||
// ==============================================================
|
||||
// detectors
|
||||
// ==============================================================
|
||||
// voxel
|
||||
const G4double dvoxel= 10.*mm;
|
||||
const G4double dl= 10.*cm;
|
||||
|
||||
G4Box* svoxel= new G4Box("voxel", dvoxel, dl, dvoxel);
|
||||
mate= G4Material::GetMaterial("Vacuum");
|
||||
G4LogicalVolume* lvoxel= new G4LogicalVolume(svoxel, mate, "voxel");
|
||||
va= new G4VisAttributes(G4Color(0.,0.8,0.8));
|
||||
va-> SetVisibility(false);
|
||||
lvoxel-> SetVisAttributes(va);
|
||||
|
||||
G4int ix, iz;
|
||||
G4int index=0;
|
||||
for (iz=0; iz<5; iz++) {
|
||||
for (ix=-7; ix<=7; ix++) {
|
||||
G4double x0= (2.*ix)*cm;
|
||||
G4double z0= (-13.+2.*iz)*cm;
|
||||
/*G4PVPlacement* pvoxel=*/ new G4PVPlacement(0, G4ThreeVector(x0, 0., z0),
|
||||
lvoxel, "voxel", areaLV, false, index);
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
// tube
|
||||
//G4Tubs* stube= new G4Tubs("tube", 15./2.*mm, 19./2.*mm, dl,
|
||||
G4Tubs* stube= new G4Tubs("tube", 0.*mm, 19./2.*mm, dl,
|
||||
0., 360.*deg);
|
||||
mate= G4Material::GetMaterial("Al");
|
||||
G4LogicalVolume* ltube= new G4LogicalVolume(stube, mate, "tube");
|
||||
va= new G4VisAttributes(G4Color(0.,0.8,0.8));
|
||||
ltube-> SetVisAttributes(va);
|
||||
|
||||
G4RotationMatrix* rmtube= new G4RotationMatrix;
|
||||
rmtube-> rotateX(-90.*deg);
|
||||
/*G4PVPlacement* ptube=*/ new G4PVPlacement(rmtube, G4ThreeVector(),
|
||||
ltube, "tube", lvoxel, false, 0);
|
||||
|
||||
// cal
|
||||
const G4double dxycal= 25.*mm;
|
||||
const G4double dzcal= 3.*cm;
|
||||
|
||||
G4Box* scal= new G4Box("cal", dxycal, dxycal, dzcal);
|
||||
mate= G4Material::GetMaterial("CsI");
|
||||
G4LogicalVolume* lcal= new G4LogicalVolume(scal, mate, "cal");
|
||||
va= new G4VisAttributes(G4Color(0.5,0.5,0.));
|
||||
lcal-> SetVisAttributes(va);
|
||||
|
||||
index= 0;
|
||||
for (ix=-2; ix<=2; ix++) {
|
||||
G4double x0= (5.*ix)*cm;
|
||||
/*G4PVPlacement* pcal=*/ new G4PVPlacement(0, G4ThreeVector(x0, 0., 2.*cm),
|
||||
lcal, "cal", areaLV, false, index);
|
||||
index++;
|
||||
}
|
||||
|
||||
return area;
|
||||
}
|
||||
|
||||
+8
-14
@@ -24,34 +24,28 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
// ====================================================================
|
||||
// Track.hh
|
||||
// QDetectorConstruction.hh
|
||||
//
|
||||
// 2005 Q
|
||||
// ====================================================================
|
||||
#ifndef TRACK_H
|
||||
#define TRACK_H
|
||||
#ifndef Q_DETECTOR_CONSTRUCTION_H
|
||||
#define Q_DETECTOR_CONSTRUCTION_H
|
||||
|
||||
#include "G4VUserDetectorConstruction.hh"
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// class definition
|
||||
//
|
||||
// ====================================================================
|
||||
class Step;
|
||||
|
||||
class Track {
|
||||
private:
|
||||
Step* step;
|
||||
class QDetectorConstruction : public G4VUserDetectorConstruction {
|
||||
|
||||
public:
|
||||
Track();
|
||||
~Track();
|
||||
QDetectorConstruction();
|
||||
~QDetectorConstruction();
|
||||
|
||||
const Step* GetStep() const;
|
||||
const Step* GetStep1() const;
|
||||
const Step* GetStep2() const;
|
||||
const Step* GetStep3() const;
|
||||
const Step* GetStep4() const;
|
||||
virtual G4VPhysicalVolume* Construct();
|
||||
|
||||
};
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
from ._Qgeom import *
|
||||
+30
-30
@@ -24,48 +24,48 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
// ====================================================================
|
||||
// AClass.hh
|
||||
// pyQgeom.cc
|
||||
//
|
||||
// [Qgeom]
|
||||
// a site-module of Geant4Py
|
||||
//
|
||||
// A sample geometry
|
||||
//
|
||||
// 2005 Q
|
||||
// ====================================================================
|
||||
#ifndef ACLASS_H
|
||||
#define ACLASS_H
|
||||
#include <boost/python.hpp>
|
||||
#include "G4RunManager.hh"
|
||||
#include "QDetectorConstruction.hh"
|
||||
|
||||
using namespace boost::python;
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// class definition
|
||||
//
|
||||
// thin wrappers
|
||||
// ====================================================================
|
||||
namespace pyQgeom {
|
||||
|
||||
class AClass {
|
||||
private:
|
||||
int ival;
|
||||
double dval;
|
||||
|
||||
public:
|
||||
AClass();
|
||||
AClass(int i, double d=0.);
|
||||
void Construct()
|
||||
{
|
||||
G4RunManager* runMgr= G4RunManager::GetRunManager();
|
||||
runMgr-> SetUserInitialization(new QDetectorConstruction);
|
||||
}
|
||||
|
||||
~AClass();
|
||||
}
|
||||
|
||||
inline void SetIVal(int i);
|
||||
inline int GetIVal() const;
|
||||
|
||||
inline void SetDVal(double d);
|
||||
inline double GetDVal() const;
|
||||
|
||||
void AMethod();
|
||||
|
||||
};
|
||||
using namespace pyQgeom;
|
||||
|
||||
// ====================================================================
|
||||
// inline functions
|
||||
// Expose to Python
|
||||
// ====================================================================
|
||||
|
||||
inline void AClass::SetIVal(int i) { ival= i; }
|
||||
inline int AClass::GetIVal() const { return ival; }
|
||||
BOOST_PYTHON_MODULE(_Qgeom) {
|
||||
|
||||
inline void AClass::SetDVal(double d) { dval= d; }
|
||||
inline double AClass::GetDVal() const { return dval; }
|
||||
class_<QDetectorConstruction, QDetectorConstruction*,
|
||||
bases<G4VUserDetectorConstruction> >
|
||||
("QDetectorConstruction", "my detector")
|
||||
;
|
||||
|
||||
// ---
|
||||
def("Construct", Construct);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,4 @@
|
||||
# - build library
|
||||
set(_TARGET _Qmaterials)
|
||||
g4pytest_add_module(${_TARGET} Qmaterials.cc pyQmaterials.cc)
|
||||
target_link_libraries(${_TARGET} PRIVATE G4materials)
|
||||
@@ -0,0 +1,142 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// ====================================================================
|
||||
// Qmaterials.cc
|
||||
//
|
||||
// 2005 Q
|
||||
// ====================================================================
|
||||
#include "G4Material.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4PhysicalConstants.hh"
|
||||
|
||||
////////////////
|
||||
void Construct()
|
||||
////////////////
|
||||
{
|
||||
G4double A, Z;
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Elements
|
||||
// ------------------------------------------------------------------------
|
||||
G4Element* elH = new G4Element("Hydrogen","H", Z=1., A=1.00794*g/mole);
|
||||
G4Element* elC = new G4Element("Carbon", "C", Z=6., A= 12.011 *g/mole);
|
||||
G4Element* elN = new G4Element("Nitrogen","N", Z=7., A= 14.00674*g/mole);
|
||||
G4Element* elO = new G4Element("Oxygen", "O", Z=8., A= 15.9994*g/mole);
|
||||
G4Element* elNa = new G4Element("Sodium", "Na", Z=11., A= 22.989768*g/mole);
|
||||
G4Element* elSi = new G4Element("Silicon", "Si", Z=14., A= 28.0855*g/mole);
|
||||
G4Element* elAr = new G4Element("Argon", "Ar", Z=18., A= 39.948*g/mole);
|
||||
G4Element* elI = new G4Element("Iodine", "I", Z=53., A= 126.90447*g/mole);
|
||||
G4Element* elCs = new G4Element("Cesium", "Cs", Z=55., A= 132.90543*g/mole);
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Materials
|
||||
// ------------------------------------------------------------------------
|
||||
G4double density, massfraction;
|
||||
G4int natoms, nel;
|
||||
|
||||
// temperature of experimental hall is controlled at 20 degree.
|
||||
const G4double expTemp= STP_Temperature+20.*kelvin;
|
||||
|
||||
// vacuum
|
||||
density= universe_mean_density;
|
||||
G4Material* Vacuum= new G4Material("Vacuum", density, nel=2);
|
||||
Vacuum-> AddElement(elN, .7);
|
||||
Vacuum-> AddElement(elO, .3);
|
||||
|
||||
// air
|
||||
density= 1.2929e-03 *g/cm3; // at 20 degree
|
||||
G4Material* Air= new G4Material("Air", density, nel=3,
|
||||
kStateGas, expTemp);
|
||||
G4double ttt= 75.47+23.20+1.28;
|
||||
Air-> AddElement(elN, massfraction= 75.47/ttt);
|
||||
Air-> AddElement(elO, massfraction= 23.20/ttt);
|
||||
Air-> AddElement(elAr, massfraction= 1.28/ttt);
|
||||
|
||||
// Ar gas
|
||||
A= 39.948 *g/mole;
|
||||
const G4double denAr= 1.782e-03 *g/cm3 * STP_Temperature/expTemp;
|
||||
G4Material* Ar= new G4Material("ArgonGas", Z=18., A, denAr,
|
||||
kStateGas, expTemp);
|
||||
|
||||
// ethane (C2H6)
|
||||
const G4double denEthane= 1.356e-3 *g/cm3 * STP_Temperature/expTemp;
|
||||
G4Material* Ethane= new G4Material("Ethane", denEthane, nel=2,
|
||||
kStateGas, expTemp);
|
||||
Ethane-> AddElement(elC, natoms=2);
|
||||
Ethane-> AddElement(elH, natoms=6);
|
||||
|
||||
// Ar(50%) + ethane(50%) mixture
|
||||
density= (denAr+denEthane)/2.;
|
||||
G4Material* ArEthane= new G4Material("ArEthane", density, nel=2,
|
||||
kStateGas, expTemp);
|
||||
ArEthane-> AddMaterial(Ar, massfraction= denAr/density/2.);
|
||||
ArEthane-> AddMaterial(Ethane, massfraction= denEthane/density/2.);
|
||||
|
||||
// silicon
|
||||
A= 28.0855 *g/mole;
|
||||
density= 2.33 *g/cm3;
|
||||
/*G4Material* Si=*/ new G4Material("SiliconWafer", Z=14., A, density);
|
||||
|
||||
// alminium
|
||||
A= 26.98 *g/mole;
|
||||
density= 2.70 *g/cm3;
|
||||
/*G4Material* Al=*/ new G4Material("Al", Z=13., A, density);
|
||||
|
||||
// iron
|
||||
A= 55.847 *g/mole;
|
||||
density= 7.87 *g/cm3;
|
||||
/*G4Material* Fe=*/ new G4Material("Iron", Z=26., A, density);
|
||||
|
||||
// lead
|
||||
A= 207.2 *g/mole;
|
||||
density= 11.35 *g/cm3;
|
||||
/*G4Material* Pb=*/ new G4Material("Lead", Z=82., A, density);
|
||||
|
||||
// scintillator (Polystyene(C6H5CH=CH2))
|
||||
density= 1.032 *g/cm3;
|
||||
G4Material* Scinti= new G4Material("Scinti", density, nel=2);
|
||||
Scinti-> AddElement(elC, natoms=8);
|
||||
Scinti-> AddElement(elH, natoms=8);
|
||||
|
||||
// quartz (SiO2, crystalline)
|
||||
density= 2.64 *g/cm3;
|
||||
G4Material* Quartz= new G4Material("Quartz", density, nel= 2);
|
||||
Quartz-> AddElement(elSi, natoms=1);
|
||||
Quartz-> AddElement(elO, natoms=2);
|
||||
|
||||
// NaI crystal
|
||||
density= 3.67 *g/cm3;
|
||||
G4Material* NaI= new G4Material("NaI", density, nel= 2);
|
||||
NaI-> AddElement(elNa, natoms=1);
|
||||
NaI-> AddElement(elI, natoms=1);
|
||||
|
||||
// CsI crystal
|
||||
density= 4.51 *g/cm3;
|
||||
G4Material* CsI= new G4Material("CsI", density, nel= 2);
|
||||
CsI-> AddElement(elCs, natoms=1);
|
||||
CsI-> AddElement(elI, natoms=1);
|
||||
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
from ._Qmaterials import *
|
||||
+14
-17
@@ -24,29 +24,26 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
// ====================================================================
|
||||
// ZBase.hh
|
||||
// pyQmaterials.cc
|
||||
//
|
||||
// [Qmaterials]
|
||||
// a site-module of Geant4Py
|
||||
//
|
||||
// A sample set of materials
|
||||
//
|
||||
// 2005 Q
|
||||
// ====================================================================
|
||||
#ifndef ZBASE_H
|
||||
#define ZBASE_H
|
||||
#include <boost/python.hpp>
|
||||
|
||||
#include <string>
|
||||
using namespace boost::python;
|
||||
|
||||
void Construct();
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// class definition
|
||||
//
|
||||
// Expose to Python
|
||||
// ====================================================================
|
||||
|
||||
class ZBase {
|
||||
public:
|
||||
ZBase();
|
||||
virtual ~ZBase();
|
||||
BOOST_PYTHON_MODULE(_Qmaterials) {
|
||||
def("Construct", Construct);
|
||||
}
|
||||
|
||||
void AMethod();
|
||||
virtual void VMethod(std::string message);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,3 @@
|
||||
|
||||
# Geant4Py site-modules
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
"""
|
||||
# ==================================================================
|
||||
# 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
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
# - build library
|
||||
set(_TARGET _ezgeom)
|
||||
g4pytest_add_module(${_TARGET}
|
||||
EzDetectorConstruction.cc
|
||||
G4EzVolume.cc
|
||||
G4EzVoxelParameterization.cc
|
||||
G4EzWorld.cc
|
||||
pyEzgeom.cc
|
||||
)
|
||||
target_link_libraries(${_TARGET} PRIVATE G4materials G4geometry G4run)
|
||||
+13
-27
@@ -24,12 +24,12 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
// ====================================================================
|
||||
// AClass.cc
|
||||
// EzDetectorConstruction.cc
|
||||
//
|
||||
// 2005 Q
|
||||
// ====================================================================
|
||||
#include "AClass.hh"
|
||||
#include <iostream>
|
||||
#include "EzDetectorConstruction.hh"
|
||||
#include "G4EzWorld.hh"
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
@@ -37,36 +37,22 @@
|
||||
//
|
||||
// ====================================================================
|
||||
|
||||
////////////////
|
||||
AClass::AClass()
|
||||
: ival(-1),
|
||||
dval(-1.)
|
||||
////////////////
|
||||
////////////////////////////////////////////////
|
||||
EzDetectorConstruction::EzDetectorConstruction()
|
||||
////////////////////////////////////////////////
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////
|
||||
AClass::AClass(int i, double d)
|
||||
: ival(i), dval(d)
|
||||
///////////////////////////////
|
||||
/////////////////////////////////////////////////
|
||||
EzDetectorConstruction::~EzDetectorConstruction()
|
||||
/////////////////////////////////////////////////
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/////////////////
|
||||
AClass::~AClass()
|
||||
/////////////////
|
||||
//////////////////////////////////////////////////////
|
||||
G4VPhysicalVolume* EzDetectorConstruction::Construct()
|
||||
//////////////////////////////////////////////////////
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//////////////////////
|
||||
void AClass::AMethod()
|
||||
//////////////////////
|
||||
{
|
||||
std::cout << "%%% AClass::AMethod is called."
|
||||
<< " (ival, dval)= (" << ival << "," << dval << ")"
|
||||
<< std::endl;
|
||||
return G4EzWorld::GetWorldVolume();
|
||||
}
|
||||
|
||||
+13
-30
@@ -24,46 +24,29 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
// ====================================================================
|
||||
// XFunc.cc
|
||||
// EzDetectorConstruction.hh
|
||||
//
|
||||
// 2005 Q
|
||||
// ====================================================================
|
||||
#include "XFunc.hh"
|
||||
#ifndef EZ_DETECTOR_CONSTRUCTION_H
|
||||
#define EZ_DETECTOR_CONSTRUCTION_H
|
||||
|
||||
#include "G4VUserDetectorConstruction.hh"
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// class description
|
||||
// class definition
|
||||
//
|
||||
// ====================================================================
|
||||
|
||||
int func1(int i)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
class EzDetectorConstruction : public G4VUserDetectorConstruction {
|
||||
|
||||
double func1(int i, double d)
|
||||
{
|
||||
return i*d;
|
||||
}
|
||||
public:
|
||||
EzDetectorConstruction();
|
||||
~EzDetectorConstruction();
|
||||
|
||||
virtual G4VPhysicalVolume* Construct();
|
||||
|
||||
int func2(int i)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
|
||||
int func2(int i0, int i1)
|
||||
{
|
||||
return i0*i1;
|
||||
}
|
||||
|
||||
int func3(int i)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int func3(double d)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,311 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// ====================================================================
|
||||
// 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,165 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// ====================================================================
|
||||
// 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
|
||||
+39
-45
@@ -24,13 +24,13 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
// ====================================================================
|
||||
// Track.cc
|
||||
// G4EzVoxelParameterization.cc
|
||||
//
|
||||
// 2005 Q
|
||||
// ====================================================================
|
||||
#include "Track.hh"
|
||||
#include "Step.hh"
|
||||
#include <iostream>
|
||||
#include "G4EzVoxelParameterization.hh"
|
||||
#include "G4Box.hh"
|
||||
#include "G4VPhysicalVolume.hh"
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
@@ -38,58 +38,52 @@
|
||||
//
|
||||
// ====================================================================
|
||||
|
||||
//////////////
|
||||
Track::Track()
|
||||
//////////////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
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)
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
{
|
||||
std::cout << "Track is created. @"
|
||||
<< this << std::endl;
|
||||
step= new Step();
|
||||
}
|
||||
|
||||
///////////////
|
||||
Track::~Track()
|
||||
///////////////
|
||||
{
|
||||
std::cout << "Track is deleted. @"
|
||||
<< this << std::endl;
|
||||
delete step;
|
||||
nvoxels[0]= nx;
|
||||
nvoxels[1]= ny;
|
||||
nvoxels[2]= nz;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////
|
||||
const Step* Track::GetStep() const
|
||||
//////////////////////////////////
|
||||
///////////////////////////////////////////////////////
|
||||
G4EzVoxelParameterization::~G4EzVoxelParameterization()
|
||||
///////////////////////////////////////////////////////
|
||||
{
|
||||
return step;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////
|
||||
const Step* Track::GetStep1() const
|
||||
///////////////////////////////////
|
||||
///////////////////////////////////////////////////////////
|
||||
void G4EzVoxelParameterization::ComputeTransformation
|
||||
(const G4int copyNo, G4VPhysicalVolume* physVol) const
|
||||
///////////////////////////////////////////////////////////
|
||||
{
|
||||
return GetStep();
|
||||
// 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));
|
||||
|
||||
}
|
||||
|
||||
///////////////////////////////////
|
||||
const Step* Track::GetStep2() const
|
||||
///////////////////////////////////
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
void G4EzVoxelParameterization::ComputeDimensions
|
||||
(G4Box& /*aBox*/, const G4int /*copyNo*/, const G4VPhysicalVolume* /*physVol*/) const
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
{
|
||||
return GetStep();
|
||||
}
|
||||
|
||||
///////////////////////////////////
|
||||
const Step* Track::GetStep3() const
|
||||
///////////////////////////////////
|
||||
{
|
||||
return GetStep();
|
||||
}
|
||||
|
||||
///////////////////////////////////
|
||||
const Step* Track::GetStep4() const
|
||||
///////////////////////////////////
|
||||
{
|
||||
return GetStep();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// ====================================================================
|
||||
// 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;
|
||||
|
||||
using G4VPVParameterisation::ComputeDimensions;
|
||||
virtual void ComputeDimensions(G4Box& aBox, const G4int copyNo,
|
||||
const G4VPhysicalVolume* physVol) const;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,137 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// ====================================================================
|
||||
// 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 "G4PhysicalConstants.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"
|
||||
G4Material* vacuum= G4Material::GetMaterial("_Vacuum", false);
|
||||
|
||||
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,75 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// ====================================================================
|
||||
// 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"
|
||||
#include "G4SystemOfUnits.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 @@
|
||||
from ._ezgeom import *
|
||||
@@ -0,0 +1,158 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// ====================================================================
|
||||
// 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);
|
||||
|
||||
}
|
||||
@@ -1,14 +1,4 @@
|
||||
# add teting
|
||||
|
||||
add_test(gtest01 python test.py)
|
||||
|
||||
if (${PYTHON_VERSION_MAJOR} MATCHES "2")
|
||||
configure_file(test.py test.py)
|
||||
elseif (${PYTHON_VERSION_MAJOR} MATCHES "3")
|
||||
configure_file(python3/test.py test.py)
|
||||
endif()
|
||||
|
||||
set_property(TEST gtest01
|
||||
PROPERTY ENVIRONMENT
|
||||
PYTHONPATH=./module:${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}
|
||||
)
|
||||
add_subdirectory(module)
|
||||
configure_file(test.py test.py)
|
||||
add_test(NAME geant4py-test01 COMMAND ${PYTHON_EXECUTABLE} test.py)
|
||||
set_tests_properties(geant4py-test01 PROPERTIES ENVIRONMENT "PYTHONPATH=${GEANT4_PYTHON_OUTPUT_DIR};${GEANT4_TEST_ENVIRONMENT}")
|
||||
|
||||
@@ -1,17 +1,8 @@
|
||||
# - build test library
|
||||
|
||||
include_directories(
|
||||
${PYTHON_INCLUDE_PATH}
|
||||
${Boost_INCLUDE_DIRS}
|
||||
${GEANT4_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
link_directories (${GEANT4_LIBRARY_DIR} ${Boost_LIBRARY_DIRS})
|
||||
|
||||
# library
|
||||
set(_TARGET gtest01)
|
||||
add_library(
|
||||
${_TARGET} SHARED
|
||||
g4py_add_module(${_TARGET}
|
||||
Particles.cc
|
||||
PhysicsListEMstd.cc
|
||||
QDetectorConstruction.cc
|
||||
@@ -21,14 +12,5 @@ add_library(
|
||||
QPrimaryGeneratorAction.cc
|
||||
gtest01.cc
|
||||
)
|
||||
target_link_libraries(${_TARGET} PRIVATE G4particles G4processes G4run)
|
||||
|
||||
set_target_properties(${_TARGET} PROPERTIES PREFIX "")
|
||||
set_target_properties(${_TARGET} PROPERTIES OUTPUT_NAME "gtest01")
|
||||
set_target_properties(${_TARGET} PROPERTIES SUFFIX ".so")
|
||||
|
||||
target_link_libraries (${_TARGET}
|
||||
${GEANT4_LIBRARIES_WITH_VIS} ${BOOST_PYTHON_LIB}
|
||||
${PYTHON_LIBRARIES})
|
||||
|
||||
# install
|
||||
install(TARGETS ${_TARGET} LIBRARY DESTINATION ${TEST_MODULES_INSTALL_DIR})
|
||||
|
||||
@@ -46,7 +46,6 @@
|
||||
|
||||
// constants (detector parameters)
|
||||
static const G4double DXYZ_AREA= 30.*cm;
|
||||
static const G4double DW= 10.*cm;
|
||||
|
||||
//////////////////////////////////////////////
|
||||
QDetectorConstruction::QDetectorConstruction()
|
||||
@@ -70,18 +69,18 @@ G4VPhysicalVolume* QDetectorConstruction::Construct()
|
||||
// ==============================================================
|
||||
// world volume
|
||||
// ==============================================================
|
||||
G4Box* areaSolid= new G4Box("AREA",
|
||||
G4Box* areaSolid= new G4Box("AREA",
|
||||
DXYZ_AREA/2., DXYZ_AREA/2., DXYZ_AREA/2.);
|
||||
|
||||
G4Material* vacuum= G4Material::GetMaterial("Vacuum");
|
||||
G4LogicalVolume* areaLV= new G4LogicalVolume(areaSolid, vacuum, "AREA_LV");
|
||||
G4PVPlacement* area= new G4PVPlacement(0, G4ThreeVector(), "AREA_PV",
|
||||
G4PVPlacement* area= new G4PVPlacement(0, G4ThreeVector(), "AREA_PV",
|
||||
areaLV, 0, false, 0);
|
||||
// vis. attributes
|
||||
va= new G4VisAttributes(G4Color(1.,1.,1.));
|
||||
va-> SetForceWireframe(true);
|
||||
areaLV-> SetVisAttributes(va);
|
||||
|
||||
|
||||
// ==============================================================
|
||||
// detectors
|
||||
// ==============================================================
|
||||
@@ -102,8 +101,7 @@ G4VPhysicalVolume* QDetectorConstruction::Construct()
|
||||
for (ix=-7; ix<=7; ix++) {
|
||||
G4double x0= (2.*ix)*cm;
|
||||
G4double z0= (-13.+2.*iz)*cm;
|
||||
G4PVPlacement* pvoxel= new
|
||||
G4PVPlacement(0, G4ThreeVector(x0, 0., z0),
|
||||
/*G4PVPlacement* pvoxel=*/ new G4PVPlacement(0, G4ThreeVector(x0, 0., z0),
|
||||
lvoxel, "voxel", areaLV, false, index);
|
||||
index++;
|
||||
}
|
||||
@@ -120,10 +118,9 @@ G4VPhysicalVolume* QDetectorConstruction::Construct()
|
||||
|
||||
G4RotationMatrix* rmtube= new G4RotationMatrix;
|
||||
rmtube-> rotateX(-90.*deg);
|
||||
G4PVPlacement* ptube= new
|
||||
G4PVPlacement(rmtube, G4ThreeVector(),
|
||||
/*G4PVPlacement* ptube=*/ new G4PVPlacement(rmtube, G4ThreeVector(),
|
||||
ltube, "tube", lvoxel, false, 0);
|
||||
|
||||
|
||||
// cal
|
||||
const G4double dxycal= 25.*mm;
|
||||
const G4double dzcal= 3.*cm;
|
||||
@@ -137,8 +134,7 @@ G4VPhysicalVolume* QDetectorConstruction::Construct()
|
||||
index= 0;
|
||||
for (ix=-2; ix<=2; ix++) {
|
||||
G4double x0= (5.*ix)*cm;
|
||||
G4PVPlacement* pcal= new
|
||||
G4PVPlacement(0, G4ThreeVector(x0, 0., 2.*cm),
|
||||
/*G4PVPlacement* pcal=*/ new G4PVPlacement(0, G4ThreeVector(x0, 0., 2.*cm),
|
||||
lcal, "cal", areaLV, false, index);
|
||||
index++;
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ QEventAction::~QEventAction()
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void QEventAction::BeginOfEventAction(const G4Event* aevent)
|
||||
void QEventAction::BeginOfEventAction(const G4Event* /*aevent*/)
|
||||
////////////////////////////////////////////////////////////
|
||||
{
|
||||
G4cout << "QEventAction::BofEA is called." << G4endl;
|
||||
@@ -60,7 +60,7 @@ void QEventAction::BeginOfEventAction(const G4Event* aevent)
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
void QEventAction::EndOfEventAction(const G4Event* aevent)
|
||||
void QEventAction::EndOfEventAction(const G4Event* /*aevent*/)
|
||||
//////////////////////////////////////////////////////////
|
||||
{
|
||||
G4cout << "QEventAction::EofEA is called." << G4endl;
|
||||
|
||||
@@ -71,7 +71,7 @@ void QMaterials::Construct()
|
||||
G4Element* elAr = new G4Element("Argon", "Ar", Z=18., A= 39.948*g/mole);
|
||||
G4Element* elI = new G4Element("Iodine", "I", Z=53., A= 126.90447*g/mole);
|
||||
G4Element* elCs = new G4Element("Cesium", "Cs", Z=55., A= 132.90543*g/mole);
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Materials
|
||||
// ------------------------------------------------------------------------
|
||||
@@ -79,7 +79,7 @@ void QMaterials::Construct()
|
||||
G4int natoms, nel;
|
||||
|
||||
// temperature of experimental hall is controlled at 20 degree.
|
||||
const G4double expTemp= STP_Temperature+20.*kelvin;
|
||||
const G4double expTemp= STP_Temperature+20.*kelvin;
|
||||
|
||||
// vacuum
|
||||
density= universe_mean_density;
|
||||
@@ -89,7 +89,7 @@ void QMaterials::Construct()
|
||||
|
||||
// air
|
||||
density= 1.2929e-03 *g/cm3; // at 20 degree
|
||||
G4Material* Air= new G4Material("Air", density, nel=3,
|
||||
G4Material* Air= new G4Material("Air", density, nel=3,
|
||||
kStateGas, expTemp);
|
||||
G4double ttt= 75.47+23.20+1.28;
|
||||
Air-> AddElement(elN, massfraction= 75.47/ttt);
|
||||
@@ -112,29 +112,29 @@ void QMaterials::Construct()
|
||||
// Ar(50%) + ethane(50%) mixture
|
||||
density= (denAr+denEthane)/2.;
|
||||
G4Material* ArEthane= new G4Material("ArEthane", density, nel=2,
|
||||
kStateGas, expTemp);
|
||||
kStateGas, expTemp);
|
||||
ArEthane-> AddMaterial(Ar, massfraction= denAr/density/2.);
|
||||
ArEthane-> AddMaterial(Ethane, massfraction= denEthane/density/2.);
|
||||
|
||||
// silicon
|
||||
A= 28.0855 *g/mole;
|
||||
density= 2.33 *g/cm3;
|
||||
G4Material* Si= new G4Material("SiliconWafer", Z=14., A, density);
|
||||
/*G4Material* Si=*/ new G4Material("SiliconWafer", Z=14., A, density);
|
||||
|
||||
// alminium
|
||||
A= 26.98 *g/mole;
|
||||
density= 2.70 *g/cm3;
|
||||
G4Material* Al= new G4Material("Al", Z=13., A, density);
|
||||
/*G4Material* Al=*/ new G4Material("Al", Z=13., A, density);
|
||||
|
||||
// iron
|
||||
A= 55.847 *g/mole;
|
||||
density= 7.87 *g/cm3;
|
||||
G4Material* Fe= new G4Material("Iron", Z=26., A, density);
|
||||
/*G4Material* Fe=*/ new G4Material("Iron", Z=26., A, density);
|
||||
|
||||
// lead
|
||||
A= 207.2 *g/mole;
|
||||
density= 11.35 *g/cm3;
|
||||
G4Material* Pb= new G4Material("Lead", Z=82., A, density);
|
||||
/*G4Material* Pb=*/ new G4Material("Lead", Z=82., A, density);
|
||||
|
||||
// scintillator (Polystyene(C6H5CH=CH2))
|
||||
density= 1.032 *g/cm3;
|
||||
|
||||
@@ -1,118 +0,0 @@
|
||||
#!/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()
|
||||
|
||||
# beamOn
|
||||
gRunManager.BeamOn(10)
|
||||
gTerminate()
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/python
|
||||
#!/usr/bin/python3
|
||||
# ==================================================================
|
||||
# python script for Geant4Py test
|
||||
#
|
||||
@@ -30,34 +30,34 @@ class MyRunAction(G4UserRunAction):
|
||||
"My Run Action"
|
||||
|
||||
def BeginOfRunAction(self, run):
|
||||
print "*** #event to be processed (BRA)=",
|
||||
run.GetNumberOfEventToBeProcessed()
|
||||
print("*** #event to be processed (BRA)=",
|
||||
run.GetNumberOfEventToBeProcessed())
|
||||
|
||||
def EndOfRunAction(self, run):
|
||||
print "*** run end run(ERA)=", run.GetRunID()
|
||||
print("*** run end run(ERA)=", run.GetRunID())
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
class MyEventAction(G4UserEventAction):
|
||||
"My Event Action"
|
||||
|
||||
#def BeginOfEventAction(self, event):
|
||||
#print "*** current event (BEA)=", event.GetEventID()
|
||||
#print("*** current event (BEA)=", event.GetEventID())
|
||||
# pass
|
||||
|
||||
#def EndOfEventAction(self, event):
|
||||
# print "*** current event (EEA)=", event.GetEventID()
|
||||
#print("*** current event (EEA)=", event.GetEventID())
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
class MySteppingAction(G4UserSteppingAction):
|
||||
"My Stepping Action"
|
||||
|
||||
def UserSteppingAction(self, step):
|
||||
#print "*** dE/dx in current step=", step.GetTotalEnergyDeposit()
|
||||
#print("*** dE/dx in current step=", step.GetTotalEnergyDeposit())
|
||||
track= step.GetTrack()
|
||||
touchable= track.GetTouchable()
|
||||
pv= touchable.GetVolume()
|
||||
#print pv.GetCopyNo()
|
||||
#print touchable.GetReplicaNumber(0)
|
||||
#print(pv.GetCopyNo())
|
||||
#print(touchable.GetReplicaNumber(0))
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
class MyField(G4MagneticField):
|
||||
@@ -115,3 +115,4 @@ gRunManager.Initialize()
|
||||
|
||||
# beamOn
|
||||
gRunManager.BeamOn(10)
|
||||
gTerminate()
|
||||
|
||||
@@ -1,14 +1,3 @@
|
||||
# add teting
|
||||
|
||||
add_test(gtest02 python test.py)
|
||||
|
||||
if (${PYTHON_VERSION_MAJOR} MATCHES "2")
|
||||
configure_file(test.py test.py)
|
||||
elseif (${PYTHON_VERSION_MAJOR} MATCHES "3")
|
||||
configure_file(python3/test.py test.py)
|
||||
endif()
|
||||
|
||||
set_property(TEST gtest02
|
||||
PROPERTY ENVIRONMENT
|
||||
PYTHONPATH=./module:${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}
|
||||
)
|
||||
configure_file(test.py test.py)
|
||||
add_test(NAME geant4py-test02 COMMAND ${PYTHON_EXECUTABLE} test.py)
|
||||
set_tests_properties(geant4py-test02 PROPERTIES ENVIRONMENT "PYTHONPATH=${GEANT4_PYTHON_OUTPUT_DIR};${GEANT4_TEST_ENVIRONMENT}")
|
||||
|
||||
@@ -1,133 +0,0 @@
|
||||
#!/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)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/python
|
||||
#!/usr/bin/python3
|
||||
# ==================================================================
|
||||
# python script for Geant4Py test
|
||||
#
|
||||
@@ -6,10 +6,10 @@
|
||||
# - 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
|
||||
import g4pytest.Qmaterials, g4pytest.NISTmaterials
|
||||
import g4pytest.Qgeom, g4pytest.ExN01geom, g4pytest.ExN03geom
|
||||
import g4pytest.ExN01pl, g4pytest.EMSTDpl
|
||||
import g4pytest.ParticleGun, g4pytest.MedicalBeam
|
||||
|
||||
# ==================================================================
|
||||
# user setup
|
||||
@@ -20,17 +20,17 @@ import g4py.ParticleGun, g4py.MedicalBeam
|
||||
# ------------------------------------------------------------------
|
||||
def Setup0():
|
||||
# simple materials for Qgeom
|
||||
g4py.Qmaterials.Construct()
|
||||
g4pytest.Qmaterials.Construct()
|
||||
|
||||
# NIST materials
|
||||
#g4py.NISTmaterials.Construct()
|
||||
|
||||
#g4pytest.NISTmaterials.Construct()
|
||||
|
||||
# normal way for constructing user geometry
|
||||
#qDC= g4py.Qgeom.QDetectorConstruction()
|
||||
#qDC= g4pytest.Qgeom.QDetectorConstruction()
|
||||
#gRunManager.SetUserInitialization(qDC)
|
||||
|
||||
# 2nd way, short-cut way
|
||||
g4py.Qgeom.Construct()
|
||||
g4pytest.Qgeom.Construct()
|
||||
|
||||
# primary
|
||||
global primary_position, primary_direction
|
||||
@@ -42,7 +42,7 @@ def Setup0():
|
||||
# Setup-1 (ExampleN01)
|
||||
# ------------------------------------------------------------------
|
||||
def Setup1():
|
||||
g4py.ExN01geom.Construct()
|
||||
g4pytest.ExN01geom.Construct()
|
||||
|
||||
global primary_position, primary_direction
|
||||
primary_position= G4ThreeVector(-2.5*m, 0., 0.)
|
||||
@@ -53,10 +53,10 @@ def Setup1():
|
||||
# Setup-3 (ExampleN03)
|
||||
# ------------------------------------------------------------------
|
||||
def Setup3():
|
||||
#exN03geom= g4py.ExN03geom.ExN03DetectorConstruction()
|
||||
#exN03geom= g4pytest.ExN03geom.ExN03DetectorConstruction()
|
||||
#gRunManager.SetUserInitialization(exN03geom)
|
||||
|
||||
g4py.ExN03geom.Construct()
|
||||
g4pytest.ExN03geom.Construct()
|
||||
|
||||
global primary_position, primary_direction
|
||||
primary_position= G4ThreeVector(-1.*m, 0., 0.)
|
||||
@@ -71,7 +71,7 @@ def Setup3():
|
||||
# ------------------------------------------------------------------
|
||||
rand_engine= Ranlux64Engine()
|
||||
HepRandom.setTheEngine(rand_engine)
|
||||
HepRandom.setTheSeed(20050830L)
|
||||
HepRandom.setTheSeed(20050830)
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# user setup
|
||||
@@ -90,10 +90,10 @@ Setup0()
|
||||
|
||||
# 2nd way, short-cut way
|
||||
# geantino + transportation
|
||||
#g4py.ExN01pl.Construct()
|
||||
#g4pytest.ExN01pl.Construct()
|
||||
|
||||
# electron/gamma standard EM
|
||||
g4py.EMSTDpl.Construct()
|
||||
g4pytest.EMSTDpl.Construct()
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# setup for primary generator action
|
||||
@@ -102,12 +102,12 @@ g4py.EMSTDpl.Construct()
|
||||
# Particle Gun
|
||||
# ------------
|
||||
# normal way for constructing user physics list
|
||||
#pgPGA= g4py.ParticleGun.ParticleGunAction()
|
||||
#pgPGA= g4pytest.ParticleGun.ParticleGunAction()
|
||||
#gRunManager.SetUserAction(pgPGA)
|
||||
#pg= pgPGA.GetParticleGun()
|
||||
|
||||
# 2nd way, short-cut way
|
||||
pg= g4py.ParticleGun.Construct()
|
||||
pg= g4pytest.ParticleGun.Construct()
|
||||
|
||||
# set parameters of particle gun
|
||||
pg.SetParticleByName("e-")
|
||||
@@ -118,12 +118,16 @@ pg.SetParticleMomentumDirection(primary_direction)
|
||||
# ------------
|
||||
# Medical Beam
|
||||
# ------------
|
||||
#beam= g4py.MedicalBeam.Construct()
|
||||
#beam= g4pytest.MedicalBeam.Construct()
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# go...
|
||||
# ------------------------------------------------------------------
|
||||
gRunManager.Initialize()
|
||||
|
||||
# visualization
|
||||
gApplyUICommand("/control/execute vis.mac")
|
||||
|
||||
# beamOn
|
||||
gRunManager.BeamOn(10)
|
||||
#gRunManager.BeamOn(3)
|
||||
|
||||
|
||||
@@ -1,14 +1,3 @@
|
||||
# add teting
|
||||
|
||||
add_test(gtest03 python test.py)
|
||||
|
||||
if (${PYTHON_VERSION_MAJOR} MATCHES "2")
|
||||
configure_file(test.py test.py)
|
||||
elseif (${PYTHON_VERSION_MAJOR} MATCHES "3")
|
||||
configure_file(python3/test.py test.py)
|
||||
endif()
|
||||
|
||||
set_property(TEST gtest03
|
||||
PROPERTY ENVIRONMENT
|
||||
PYTHONPATH=./module:${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}
|
||||
)
|
||||
configure_file(test.py test.py)
|
||||
add_test(NAME geant4py-test03 COMMAND ${PYTHON_EXECUTABLE} test.py)
|
||||
set_tests_properties(geant4py-test03 PROPERTIES ENVIRONMENT "PYTHONPATH=${GEANT4_PYTHON_OUTPUT_DIR};${GEANT4_TEST_ENVIRONMENT}")
|
||||
|
||||
@@ -1,100 +0,0 @@
|
||||
#!/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)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/python
|
||||
#!/usr/bin/python3
|
||||
# ==================================================================
|
||||
# python script for Geant4Py test
|
||||
#
|
||||
@@ -6,11 +6,11 @@
|
||||
# - 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
|
||||
import g4pytest.NISTmaterials
|
||||
import g4pytest.ezgeom
|
||||
from g4pytest.ezgeom import G4EzVolume
|
||||
import g4pytest.EMSTDpl
|
||||
import g4pytest.ParticleGun
|
||||
|
||||
# ==================================================================
|
||||
# intialize
|
||||
@@ -20,33 +20,33 @@ def Configure():
|
||||
# setup for materials
|
||||
# ------------------------------------------------------------------
|
||||
# simple materials for Qgeom
|
||||
g4py.NISTmaterials.Construct()
|
||||
g4pytest.NISTmaterials.Construct()
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# setup for geometry
|
||||
# ------------------------------------------------------------------
|
||||
#g4py.Qgeom.Construct()
|
||||
g4py.ezgeom.Construct() # initialize
|
||||
#g4pytest.Qgeom.Construct()
|
||||
g4pytest.ezgeom.Construct() # initialize
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# setup for physics list
|
||||
# ------------------------------------------------------------------
|
||||
g4py.EMSTDpl.Construct()
|
||||
g4pytest.EMSTDpl.Construct()
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# setup for primary generator action
|
||||
# ------------------------------------------------------------------
|
||||
g4py.ParticleGun.Construct()
|
||||
g4pytest.ParticleGun.Construct()
|
||||
gControlExecute("gun.mac")
|
||||
|
||||
# ==================================================================
|
||||
# constructing geometry
|
||||
# ==================================================================
|
||||
def ConstructGeom():
|
||||
print "* Constructing geometry..."
|
||||
print("* Constructing geometry...")
|
||||
# reset world material
|
||||
air= G4Material.GetMaterial("G4_AIR")
|
||||
g4py.ezgeom.SetWorldMaterial(air)
|
||||
g4pytest.ezgeom.SetWorldMaterial(air)
|
||||
|
||||
# target
|
||||
global target
|
||||
@@ -69,7 +69,7 @@ def ConstructGeom():
|
||||
dd= 5.*cm
|
||||
for ical in range(-1, 2):
|
||||
calPos= G4ThreeVector(dd*ical, 0., 0.)
|
||||
print calPos
|
||||
print(calPos)
|
||||
cal.PlaceIt(calPos, ical+1, detector_box)
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ def ConstructGeom():
|
||||
# ------------------------------------------------------------------
|
||||
rand_engine= Ranlux64Engine()
|
||||
HepRandom.setTheEngine(rand_engine)
|
||||
HepRandom.setTheSeed(20050830L)
|
||||
HepRandom.setTheSeed(20050830)
|
||||
|
||||
# setup...
|
||||
Configure()
|
||||
@@ -92,5 +92,9 @@ ConstructGeom()
|
||||
# ------------------------------------------------------------------
|
||||
gRunManager.Initialize()
|
||||
|
||||
# visualization
|
||||
gControlExecute("vis.mac")
|
||||
|
||||
# beamOn
|
||||
gRunManager.BeamOn(10)
|
||||
#gRunManager.BeamOn(3)
|
||||
|
||||
|
||||
@@ -1,14 +1,3 @@
|
||||
# add teting
|
||||
|
||||
add_test(gtest04 python test.py)
|
||||
|
||||
if (${PYTHON_VERSION_MAJOR} MATCHES "2")
|
||||
configure_file(test.py test.py)
|
||||
elseif (${PYTHON_VERSION_MAJOR} MATCHES "3")
|
||||
configure_file(python3/test.py test.py)
|
||||
endif()
|
||||
|
||||
set_property(TEST gtest04
|
||||
PROPERTY ENVIRONMENT
|
||||
PYTHONPATH=./module:${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}
|
||||
)
|
||||
configure_file(test.py test.py)
|
||||
add_test(NAME geant4py-test04 COMMAND ${PYTHON_EXECUTABLE} test.py)
|
||||
set_tests_properties(geant4py-test04 PROPERTIES ENVIRONMENT "PYTHONPATH=${GEANT4_PYTHON_OUTPUT_DIR};${GEANT4_TEST_ENVIRONMENT}")
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
#!/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)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/python
|
||||
#!/usr/bin/env python
|
||||
# ==================================================================
|
||||
# python script for Geant4Py test
|
||||
#
|
||||
@@ -8,20 +8,20 @@
|
||||
from Geant4 import *
|
||||
|
||||
def DumpTree(atree):
|
||||
print "@@", atree.GetPathName(), "::", atree.GetTitle()
|
||||
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()
|
||||
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()
|
||||
print(" +", iparam.GetParameterName(), iparam.GetParameterType())
|
||||
|
||||
for i in range(1, ntree+1):
|
||||
itree= atree.GetTree(i)
|
||||
|
||||
@@ -1,14 +1,3 @@
|
||||
# add teting
|
||||
|
||||
add_test(gtest05 python test.py)
|
||||
|
||||
if (${PYTHON_VERSION_MAJOR} MATCHES "2")
|
||||
configure_file(test.py test.py)
|
||||
elseif (${PYTHON_VERSION_MAJOR} MATCHES "3")
|
||||
configure_file(python3/test.py test.py)
|
||||
endif()
|
||||
|
||||
set_property(TEST gtest05
|
||||
PROPERTY ENVIRONMENT
|
||||
PYTHONPATH=./module:${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}
|
||||
)
|
||||
configure_file(test.py test.py)
|
||||
add_test(NAME geant4py-test05 COMMAND ${PYTHON_EXECUTABLE} test.py)
|
||||
set_tests_properties(geant4py-test05 PROPERTIES ENVIRONMENT "PYTHONPATH=${GEANT4_PYTHON_OUTPUT_DIR};${GEANT4_TEST_ENVIRONMENT}")
|
||||
|
||||
@@ -1,311 +0,0 @@
|
||||
#!/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)
|
||||
|
||||
gTerminate()
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/python
|
||||
#!/usr/bin/python3
|
||||
# ==================================================================
|
||||
# python script for Geant4Py test
|
||||
#
|
||||
@@ -6,7 +6,7 @@
|
||||
# - test for CSG geometry construction in Python
|
||||
# ==================================================================
|
||||
from Geant4 import *
|
||||
import g4py.ExN01pl, g4py.ParticleGun
|
||||
import g4pytest.ExN01pl, g4pytest.ParticleGun
|
||||
import os, math
|
||||
|
||||
# ==================================================================
|
||||
@@ -20,7 +20,7 @@ class MyDetectorConstruction(G4VUserDetectorConstruction):
|
||||
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.))
|
||||
@@ -34,7 +34,7 @@ class MyDetectorConstruction(G4VUserDetectorConstruction):
|
||||
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")
|
||||
lv_world= G4LogicalVolume(sld_world, self.air, "world")
|
||||
pv_world= G4PVPlacement(G4Transform3D(), lv_world, "world",
|
||||
None, False, 0)
|
||||
|
||||
@@ -58,7 +58,7 @@ class MyDetectorConstruction(G4VUserDetectorConstruction):
|
||||
self.lv_object.SetSolid(sld_box)
|
||||
self.lv_object.SetVisAttributes(self.va_red)
|
||||
gRunManager.GeometryHasBeenModified()
|
||||
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
def ConstructTubs(self):
|
||||
global sld_tubs
|
||||
@@ -66,7 +66,7 @@ class MyDetectorConstruction(G4VUserDetectorConstruction):
|
||||
self.lv_object.SetSolid(sld_tubs)
|
||||
self.lv_object.SetVisAttributes(self.va_cyan)
|
||||
gRunManager.GeometryHasBeenModified()
|
||||
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
def ConstructCons(self):
|
||||
global sld_cons
|
||||
@@ -114,7 +114,7 @@ class MyDetectorConstruction(G4VUserDetectorConstruction):
|
||||
# -----------------------------------------------------------------
|
||||
def ConstructOrb(self):
|
||||
global sld_orb
|
||||
sld_orb= G4Orb("orb", 100.*cm)
|
||||
sld_orb= G4Orb("orb", 100.*cm)
|
||||
self.lv_object.SetSolid(sld_orb)
|
||||
self.lv_object.SetVisAttributes(self.va_red)
|
||||
gRunManager.GeometryHasBeenModified()
|
||||
@@ -122,7 +122,7 @@ class MyDetectorConstruction(G4VUserDetectorConstruction):
|
||||
# -----------------------------------------------------------------
|
||||
def ConstructTorus(self):
|
||||
global sld_torus
|
||||
sld_torus= G4Torus("torus", 40.*cm, 60.*cm, 200.*cm, 0., 90.*deg)
|
||||
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()
|
||||
@@ -164,7 +164,7 @@ class MyDetectorConstruction(G4VUserDetectorConstruction):
|
||||
# -----------------------------------------------------------------
|
||||
def ConstructEllipticalTube(self):
|
||||
global sld_et
|
||||
sld_et= G4EllipticalTube("ellipticaltube", 5.*cm, 10.*cm, 20.*cm)
|
||||
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()
|
||||
@@ -182,7 +182,7 @@ class MyDetectorConstruction(G4VUserDetectorConstruction):
|
||||
def ConstructEllipticalCone(self):
|
||||
global sld_ec
|
||||
sld_ec= G4EllipticalCone("ellipticalcone", 30.*cm, 60.*cm,
|
||||
50.*cm, 25.*cm)
|
||||
50.*cm, 25.*cm)
|
||||
self.lv_object.SetSolid(sld_ec)
|
||||
self.lv_object.SetVisAttributes(self.va_magenta)
|
||||
gRunManager.GeometryHasBeenModified()
|
||||
@@ -249,8 +249,8 @@ class MyDetectorConstruction(G4VUserDetectorConstruction):
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
def Construct(self): # return the world volume
|
||||
return self.world
|
||||
|
||||
return self.world
|
||||
|
||||
# ==================================================================
|
||||
# main
|
||||
# ==================================================================
|
||||
@@ -263,10 +263,10 @@ myDC= MyDetectorConstruction()
|
||||
gRunManager.SetUserInitialization(myDC)
|
||||
|
||||
# minimal physics list
|
||||
g4py.ExN01pl.Construct()
|
||||
g4pytest.ExN01pl.Construct()
|
||||
|
||||
# set primary generator action
|
||||
g4py.ParticleGun.Construct()
|
||||
g4pytest.ParticleGun.Construct()
|
||||
|
||||
# initialize
|
||||
gRunManager.Initialize()
|
||||
@@ -304,7 +304,8 @@ f_list= (
|
||||
|
||||
for s,f in f_list:
|
||||
f.__call__()
|
||||
gRunManager.BeamOn(1)
|
||||
gRunManager.BeamOn(1)
|
||||
fname= "%s.wrl" % (s)
|
||||
os.rename("g4_00.wrl", fname)
|
||||
|
||||
|
||||
gTerminate()
|
||||
|
||||
@@ -1,14 +1,3 @@
|
||||
# add teting
|
||||
|
||||
add_test(gtest06 python test.py)
|
||||
|
||||
if (${PYTHON_VERSION_MAJOR} MATCHES "2")
|
||||
configure_file(test.py test.py)
|
||||
elseif (${PYTHON_VERSION_MAJOR} MATCHES "3")
|
||||
configure_file(python3/test.py test.py)
|
||||
endif()
|
||||
|
||||
set_property(TEST gtest06
|
||||
PROPERTY ENVIRONMENT
|
||||
PYTHONPATH=./module:${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}
|
||||
)
|
||||
configure_file(test.py test.py)
|
||||
add_test(NAME geant4py-test06 COMMAND ${PYTHON_EXECUTABLE} test.py)
|
||||
set_tests_properties(geant4py-test06 PROPERTIES ENVIRONMENT "PYTHONPATH=${GEANT4_PYTHON_OUTPUT_DIR};${GEANT4_TEST_ENVIRONMENT}")
|
||||
|
||||
@@ -1,126 +0,0 @@
|
||||
#!/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)
|
||||
|
||||
gTerminate()
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/python
|
||||
#!/usr/bin/python3
|
||||
# ==================================================================
|
||||
# python script for Geant4Py test
|
||||
#
|
||||
@@ -6,7 +6,7 @@
|
||||
# - test for constructing/visualizing boolean geoemtries
|
||||
# ==================================================================
|
||||
from Geant4 import *
|
||||
import g4py.ExN01pl, g4py.ParticleGun
|
||||
import g4pytest.ExN01pl, g4pytest.ParticleGun
|
||||
|
||||
# ==================================================================
|
||||
# user actions in python
|
||||
@@ -19,7 +19,7 @@ class MyDetectorConstruction(G4VUserDetectorConstruction):
|
||||
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.))
|
||||
@@ -36,7 +36,7 @@ class MyDetectorConstruction(G4VUserDetectorConstruction):
|
||||
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")
|
||||
lv_world= G4LogicalVolume(sld_world, self.air, "world")
|
||||
pv_world= G4PVPlacement(G4Transform3D(), lv_world, "world",
|
||||
None, False, 0)
|
||||
|
||||
@@ -56,16 +56,16 @@ class MyDetectorConstruction(G4VUserDetectorConstruction):
|
||||
# -----------------------------------------------------------------
|
||||
def ConstructUnion(self):
|
||||
global sld_union
|
||||
sld_union= G4UnionSolid("box+cylinder", self.sld_box, self.sld_cyl);
|
||||
|
||||
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
|
||||
global sld_intersection
|
||||
sld_intersection= G4IntersectionSolid("box*cylinder",
|
||||
self.sld_box, self.sld_cyl,
|
||||
None, offset)
|
||||
@@ -76,18 +76,18 @@ class MyDetectorConstruction(G4VUserDetectorConstruction):
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
def ConstructSubtraction(self):
|
||||
global sld_subtraction
|
||||
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
|
||||
|
||||
return self.world
|
||||
|
||||
# ==================================================================
|
||||
# main
|
||||
# ==================================================================
|
||||
@@ -96,10 +96,10 @@ myDC= MyDetectorConstruction()
|
||||
gRunManager.SetUserInitialization(myDC)
|
||||
|
||||
# minimal physics list
|
||||
g4py.ExN01pl.Construct()
|
||||
g4pytest.ExN01pl.Construct()
|
||||
|
||||
# set primary generator action
|
||||
g4py.ParticleGun.Construct()
|
||||
g4pytest.ParticleGun.Construct()
|
||||
|
||||
# initialize
|
||||
gRunManager.Initialize()
|
||||
@@ -116,11 +116,11 @@ f_list= (
|
||||
("subtraction", myDC.ConstructSubtraction)
|
||||
)
|
||||
|
||||
|
||||
for s,f in f_list:
|
||||
f.__call__()
|
||||
fname= "%s.jpg" % (s)
|
||||
cmdstr= "/vis/rayTracer/trace " + fname
|
||||
# This causes a segfault in MT mode...
|
||||
gApplyUICommand(cmdstr)
|
||||
|
||||
|
||||
gTerminate()
|
||||
|
||||
@@ -1,14 +1,3 @@
|
||||
# add teting
|
||||
|
||||
add_test(gtest07 python test.py)
|
||||
|
||||
if (${PYTHON_VERSION_MAJOR} MATCHES "2")
|
||||
configure_file(test.py test.py)
|
||||
elseif (${PYTHON_VERSION_MAJOR} MATCHES "3")
|
||||
configure_file(python3/test.py test.py)
|
||||
endif()
|
||||
|
||||
set_property(TEST gtest07
|
||||
PROPERTY ENVIRONMENT
|
||||
PYTHONPATH=./module:${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}
|
||||
)
|
||||
configure_file(test.py test.py)
|
||||
add_test(NAME geant4py-test07 COMMAND ${PYTHON_EXECUTABLE} test.py)
|
||||
set_tests_properties(geant4py-test07 PROPERTIES ENVIRONMENT "PYTHONPATH=${GEANT4_PYTHON_OUTPUT_DIR};${GEANT4_TEST_ENVIRONMENT}")
|
||||
|
||||
@@ -1,80 +0,0 @@
|
||||
#!/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 !!
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/python
|
||||
#!/usr/bin/python3
|
||||
# ==================================================================
|
||||
# python script for Geant4Py test
|
||||
#
|
||||
@@ -6,7 +6,7 @@
|
||||
# - test for checking overlapped geometries
|
||||
# ==================================================================
|
||||
from Geant4 import *
|
||||
import g4py.ExN01pl, g4py.ParticleGun
|
||||
import g4pytest.ExN01pl, g4pytest.ParticleGun
|
||||
|
||||
# ==================================================================
|
||||
# user actions in python
|
||||
@@ -69,10 +69,10 @@ myDC= MyDetectorConstruction()
|
||||
gRunManager.SetUserInitialization(myDC)
|
||||
|
||||
# minimal physics list
|
||||
g4py.ExN01pl.Construct()
|
||||
g4pytest.ExN01pl.Construct()
|
||||
|
||||
# set primary generator action
|
||||
g4py.ParticleGun.Construct()
|
||||
g4pytest.ParticleGun.Construct()
|
||||
|
||||
# initialize
|
||||
gRunManager.Initialize() # overlap should be detected !!
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
# add teting
|
||||
|
||||
add_test(test00 python test.py)
|
||||
|
||||
if (${PYTHON_VERSION_MAJOR} MATCHES "2")
|
||||
configure_file(test.py test.py)
|
||||
elseif (${PYTHON_VERSION_MAJOR} MATCHES "3")
|
||||
configure_file(python3/test.py test.py)
|
||||
endif()
|
||||
|
||||
set_property(TEST test00 PROPERTY ENVIRONMENT PYTHONPATH=./module)
|
||||
@@ -1,25 +0,0 @@
|
||||
# - build test library
|
||||
|
||||
include_directories(
|
||||
${PYTHON_INCLUDE_PATH}
|
||||
${Boost_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
link_directories(${Boost_LIBRARY_DIRS})
|
||||
|
||||
# library
|
||||
set(_TARGET test00)
|
||||
add_library(
|
||||
${_TARGET} SHARED
|
||||
test00.cc
|
||||
)
|
||||
|
||||
set_target_properties(${_TARGET} PROPERTIES PREFIX "")
|
||||
set_target_properties(${_TARGET} PROPERTIES OUTPUT_NAME "test00")
|
||||
set_target_properties(${_TARGET} PROPERTIES SUFFIX ".so")
|
||||
|
||||
|
||||
target_link_libraries (${_TARGET} ${BOOST_PYTHON_LIB} ${PYTHON_LIBRARIES})
|
||||
|
||||
# install
|
||||
install(TARGETS ${_TARGET} LIBRARY DESTINATION ${TEST_MODULES_INSTALL_DIR})
|
||||
@@ -1,48 +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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// ====================================================================
|
||||
// test00.cc
|
||||
// Hallo World of Boost.Python
|
||||
// 2005 Q
|
||||
// ====================================================================
|
||||
|
||||
// C function to be wrappred
|
||||
char const* greet()
|
||||
{
|
||||
return "Hallo World!!";
|
||||
}
|
||||
|
||||
|
||||
// Boost.Python...
|
||||
#include <boost/python.hpp>
|
||||
|
||||
using namespace boost::python;
|
||||
|
||||
BOOST_PYTHON_MODULE(test00)
|
||||
{
|
||||
def("greet", greet);
|
||||
}
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
#!/usr/bin/python3
|
||||
# ==================================================================
|
||||
# python script for Geant4Py test
|
||||
#
|
||||
#
|
||||
# ==================================================================
|
||||
import test00
|
||||
|
||||
print("importing created module...\n")
|
||||
|
||||
print(test00.greet())
|
||||
@@ -1,12 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
# ==================================================================
|
||||
# python script for Geant4Py test
|
||||
#
|
||||
#
|
||||
# ==================================================================
|
||||
import test00
|
||||
|
||||
print "importing created module...\n"
|
||||
|
||||
print test00.greet()
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
# add teting
|
||||
|
||||
add_test(test01 python test.py)
|
||||
|
||||
if (${PYTHON_VERSION_MAJOR} MATCHES "2")
|
||||
configure_file(test.py test.py)
|
||||
elseif (${PYTHON_VERSION_MAJOR} MATCHES "3")
|
||||
configure_file(python3/test.py test.py)
|
||||
endif()
|
||||
|
||||
set_property(TEST test01 PROPERTY ENVIRONMENT PYTHONPATH=./module)
|
||||
@@ -1,26 +0,0 @@
|
||||
# - build test library
|
||||
|
||||
include_directories(
|
||||
${PYTHON_INCLUDE_PATH}
|
||||
${Boost_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
link_directories(${Boost_LIBRARY_DIRS})
|
||||
|
||||
# library
|
||||
set(_TARGET test01)
|
||||
add_library(
|
||||
${_TARGET} SHARED
|
||||
AClass.cc
|
||||
test01.cc
|
||||
)
|
||||
|
||||
set_target_properties(${_TARGET} PROPERTIES PREFIX "")
|
||||
set_target_properties(${_TARGET} PROPERTIES OUTPUT_NAME "test01")
|
||||
set_target_properties(${_TARGET} PROPERTIES SUFFIX ".so")
|
||||
|
||||
|
||||
target_link_libraries (${_TARGET} ${BOOST_PYTHON_LIB} ${PYTHON_LIBRARIES})
|
||||
|
||||
# install
|
||||
install(TARGETS ${_TARGET} LIBRARY DESTINATION ${TEST_MODULES_INSTALL_DIR})
|
||||
@@ -1,54 +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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// ====================================================================
|
||||
// test01.cc
|
||||
//
|
||||
// exposure of a simple class
|
||||
// - constructor
|
||||
// - multiple constructors
|
||||
// - default value in function arguments
|
||||
// - setter/getter
|
||||
// - method
|
||||
//
|
||||
// 2005 Q
|
||||
// ====================================================================
|
||||
#include <boost/python.hpp>
|
||||
|
||||
#include "AClass.hh"
|
||||
|
||||
using namespace boost::python;
|
||||
|
||||
BOOST_PYTHON_MODULE(test01) {
|
||||
class_<AClass>( "AClass", "a simple class")
|
||||
.def(init<>())
|
||||
.def(init<int>())
|
||||
.def(init<int, double>())
|
||||
.add_property("ival", &AClass::GetIVal, &AClass::SetIVal)
|
||||
.add_property("dval", &AClass::GetDVal, &AClass::SetDVal)
|
||||
.def("AMethod", &AClass::AMethod)
|
||||
;
|
||||
}
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
#!/usr/bin/python3
|
||||
# ==================================================================
|
||||
# python script for Geant4Py test
|
||||
#
|
||||
#
|
||||
# ==================================================================
|
||||
import test01
|
||||
|
||||
print("importing created module...\n")
|
||||
|
||||
a= test01.AClass()
|
||||
b= test01.AClass(0)
|
||||
c= test01.AClass(1, 1.)
|
||||
|
||||
print(" >>a<<", a.AMethod())
|
||||
print(" >>b<<", b.AMethod())
|
||||
print(" >>c<<", c.AMethod())
|
||||
@@ -1,23 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
# ==================================================================
|
||||
# python script for Geant4Py test
|
||||
#
|
||||
#
|
||||
# ==================================================================
|
||||
import test01
|
||||
|
||||
print "importing created module...\n"
|
||||
|
||||
a= test01.AClass()
|
||||
b= test01.AClass(0)
|
||||
c= test01.AClass(1, 1.)
|
||||
|
||||
print " >>a<<",
|
||||
a.AMethod()
|
||||
|
||||
print ">>b<<",
|
||||
b.AMethod()
|
||||
|
||||
print ">>c<<",
|
||||
c.AMethod()
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
# add teting
|
||||
|
||||
add_test(test02 python test.py)
|
||||
configure_file(test.py test.py)
|
||||
set_property(TEST test02 PROPERTY ENVIRONMENT PYTHONPATH=./module)
|
||||
@@ -1,70 +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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// ====================================================================
|
||||
// AClass.cc
|
||||
//
|
||||
// 2004 Q
|
||||
// ====================================================================
|
||||
#include "AClass.hh"
|
||||
#include <iostream>
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// class description
|
||||
//
|
||||
// ====================================================================
|
||||
|
||||
////////////////
|
||||
AClass::AClass()
|
||||
: XBase()
|
||||
////////////////
|
||||
{
|
||||
ival= -2;
|
||||
dval= -2.;
|
||||
}
|
||||
|
||||
/////////////////
|
||||
AClass::~AClass()
|
||||
/////////////////
|
||||
{
|
||||
}
|
||||
|
||||
//////////////////////
|
||||
void AClass::AMethod()
|
||||
//////////////////////
|
||||
{
|
||||
std::cout << "%%% AClass:::AMethod is called."
|
||||
<< " (ival, dval)= (" << ival << "," << dval << ")"
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////
|
||||
int AClass::VMethod(const XBase* abase) const
|
||||
/////////////////////////////////////////////
|
||||
{
|
||||
return abase-> GetIVal();
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user