Import Geant4 10.3.1 source tree
This commit is contained in:
@@ -1,23 +0,0 @@
|
||||
# - build library
|
||||
|
||||
# library
|
||||
set(_TARGET ExN03pl)
|
||||
add_library(
|
||||
${_TARGET} SHARED
|
||||
PhysicsList.cc
|
||||
pyExN03pl.cc
|
||||
)
|
||||
|
||||
set_target_properties(${_TARGET} PROPERTIES PREFIX "")
|
||||
set_target_properties(${_TARGET} PROPERTIES SUFFIX ".so")
|
||||
set_target_properties(${_TARGET}
|
||||
PROPERTIES INSTALL_RPATH
|
||||
${GEANT4_LIBRARY_DIR}
|
||||
BUILD_WITH_INSTALL_RPATH TRUE)
|
||||
|
||||
target_link_libraries (${_TARGET}
|
||||
${GEANT4_LIBRARIES_WITH_VIS} boost_python
|
||||
${PYTHON_LIBRARIES})
|
||||
|
||||
# install
|
||||
install(TARGETS ${_TARGET} LIBRARY DESTINATION ${G4SITEMODULES_INSTALL_DIR})
|
||||
@@ -1,226 +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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: PhysicsList.cc 66892 2013-01-17 10:57:59Z gunter $
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "PhysicsList.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
|
||||
#include "G4ProcessManager.hh"
|
||||
|
||||
#include "G4BosonConstructor.hh"
|
||||
#include "G4LeptonConstructor.hh"
|
||||
#include "G4MesonConstructor.hh"
|
||||
#include "G4BosonConstructor.hh"
|
||||
#include "G4BaryonConstructor.hh"
|
||||
#include "G4IonConstructor.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
PhysicsList::PhysicsList(): G4VUserPhysicsList()
|
||||
{
|
||||
defaultCutValue = 1.0*mm;
|
||||
SetVerboseLevel(1);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
PhysicsList::~PhysicsList()
|
||||
{}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void PhysicsList::ConstructParticle()
|
||||
{
|
||||
// In this method, static member functions should be called
|
||||
// for all particles which you want to use.
|
||||
// This ensures that objects of these particle types will be
|
||||
// created in the program.
|
||||
|
||||
G4BosonConstructor pBosonConstructor;
|
||||
pBosonConstructor.ConstructParticle();
|
||||
|
||||
G4LeptonConstructor pLeptonConstructor;
|
||||
pLeptonConstructor.ConstructParticle();
|
||||
|
||||
G4MesonConstructor pMesonConstructor;
|
||||
pMesonConstructor.ConstructParticle();
|
||||
|
||||
G4BaryonConstructor pBaryonConstructor;
|
||||
pBaryonConstructor.ConstructParticle();
|
||||
|
||||
G4IonConstructor pIonConstructor;
|
||||
pIonConstructor.ConstructParticle();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void PhysicsList::ConstructProcess()
|
||||
{
|
||||
AddTransportation();
|
||||
ConstructEM();
|
||||
ConstructDecay();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "G4PhysicsListHelper.hh"
|
||||
|
||||
#include "G4ComptonScattering.hh"
|
||||
#include "G4GammaConversion.hh"
|
||||
#include "G4PhotoElectricEffect.hh"
|
||||
|
||||
#include "G4eMultipleScattering.hh"
|
||||
#include "G4eIonisation.hh"
|
||||
#include "G4eBremsstrahlung.hh"
|
||||
#include "G4eplusAnnihilation.hh"
|
||||
|
||||
#include "G4MuMultipleScattering.hh"
|
||||
#include "G4MuIonisation.hh"
|
||||
#include "G4MuBremsstrahlung.hh"
|
||||
#include "G4MuPairProduction.hh"
|
||||
|
||||
#include "G4hMultipleScattering.hh"
|
||||
#include "G4hIonisation.hh"
|
||||
#include "G4hBremsstrahlung.hh"
|
||||
#include "G4hPairProduction.hh"
|
||||
|
||||
#include "G4ionIonisation.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void PhysicsList::ConstructEM()
|
||||
{
|
||||
G4PhysicsListHelper* ph = G4PhysicsListHelper::GetPhysicsListHelper();
|
||||
|
||||
theParticleIterator->reset();
|
||||
while( (*theParticleIterator)() ){
|
||||
G4ParticleDefinition* particle = theParticleIterator->value();
|
||||
G4String particleName = particle->GetParticleName();
|
||||
|
||||
if (particleName == "gamma") {
|
||||
// gamma
|
||||
ph->RegisterProcess(new G4PhotoElectricEffect, particle);
|
||||
ph->RegisterProcess(new G4ComptonScattering, particle);
|
||||
ph->RegisterProcess(new G4GammaConversion, particle);
|
||||
|
||||
} else if (particleName == "e-") {
|
||||
//electron
|
||||
ph->RegisterProcess(new G4eMultipleScattering, particle);
|
||||
ph->RegisterProcess(new G4eIonisation, particle);
|
||||
//ph->RegisterProcess(new G4eBremsstrahlung, particle);
|
||||
|
||||
} else if (particleName == "e+") {
|
||||
//positron
|
||||
ph->RegisterProcess(new G4eMultipleScattering, particle);
|
||||
ph->RegisterProcess(new G4eIonisation, particle);
|
||||
//ph->RegisterProcess(new G4eBremsstrahlung, particle);
|
||||
ph->RegisterProcess(new G4eplusAnnihilation, particle);
|
||||
|
||||
} else if( particleName == "mu+" ||
|
||||
particleName == "mu-" ) {
|
||||
//muon
|
||||
ph->RegisterProcess(new G4MuMultipleScattering, particle);
|
||||
ph->RegisterProcess(new G4MuIonisation, particle);
|
||||
ph->RegisterProcess(new G4MuBremsstrahlung, particle);
|
||||
ph->RegisterProcess(new G4MuPairProduction, particle);
|
||||
|
||||
} else if( particleName == "proton" ||
|
||||
particleName == "pi-" ||
|
||||
particleName == "pi+" ) {
|
||||
//proton
|
||||
ph->RegisterProcess(new G4hMultipleScattering, particle);
|
||||
ph->RegisterProcess(new G4hIonisation, particle);
|
||||
ph->RegisterProcess(new G4hBremsstrahlung, particle);
|
||||
ph->RegisterProcess(new G4hPairProduction, particle);
|
||||
|
||||
} else if( particleName == "alpha" ||
|
||||
particleName == "He3" ) {
|
||||
//alpha
|
||||
ph->RegisterProcess(new G4hMultipleScattering, particle);
|
||||
ph->RegisterProcess(new G4ionIonisation, particle);
|
||||
|
||||
} else if( particleName == "GenericIon" ) {
|
||||
//Ions
|
||||
ph->RegisterProcess(new G4hMultipleScattering, particle);
|
||||
ph->RegisterProcess(new G4ionIonisation, particle);
|
||||
|
||||
} else if ((!particle->IsShortLived()) &&
|
||||
(particle->GetPDGCharge() != 0.0) &&
|
||||
(particle->GetParticleName() != "chargedgeantino")) {
|
||||
//all others charged particles except geantino
|
||||
ph->RegisterProcess(new G4hMultipleScattering, particle);
|
||||
ph->RegisterProcess(new G4hIonisation, particle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "G4Decay.hh"
|
||||
|
||||
void PhysicsList::ConstructDecay()
|
||||
{
|
||||
G4PhysicsListHelper* ph = G4PhysicsListHelper::GetPhysicsListHelper();
|
||||
|
||||
// Add Decay Process
|
||||
G4Decay* theDecayProcess = new G4Decay();
|
||||
theParticleIterator->reset();
|
||||
while( (*theParticleIterator)() ){
|
||||
G4ParticleDefinition* particle = theParticleIterator->value();
|
||||
if (theDecayProcess->IsApplicable(*particle)) {
|
||||
ph->RegisterProcess(theDecayProcess, particle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void PhysicsList::SetCuts()
|
||||
{
|
||||
if (verboseLevel >0){
|
||||
G4cout << "PhysicsList::SetCuts:";
|
||||
G4cout << "CutLength : " << G4BestUnit(defaultCutValue,"Length") << G4endl;
|
||||
}
|
||||
|
||||
// set cut values for gamma at first and for e- second and next for e+,
|
||||
// because some processes for e+/e- need cut values for gamma
|
||||
//
|
||||
SetCutValue(defaultCutValue, "gamma");
|
||||
SetCutValue(defaultCutValue, "e-");
|
||||
SetCutValue(defaultCutValue, "e+");
|
||||
SetCutValue(defaultCutValue, "proton");
|
||||
|
||||
if (verboseLevel>0) DumpCutValuesTable();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -1,66 +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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: PhysicsList.hh 66892 2013-01-17 10:57:59Z gunter $
|
||||
//
|
||||
//
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#ifndef PhysicsList_h
|
||||
#define PhysicsList_h 1
|
||||
|
||||
#include "G4VUserPhysicsList.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
class PhysicsList: public G4VUserPhysicsList
|
||||
{
|
||||
public:
|
||||
PhysicsList();
|
||||
virtual ~PhysicsList();
|
||||
|
||||
// Construct particle and physics
|
||||
void ConstructParticle();
|
||||
void ConstructProcess();
|
||||
|
||||
void SetCuts();
|
||||
|
||||
private:
|
||||
|
||||
// these methods Construct physics processes and register them
|
||||
void ConstructDecay();
|
||||
void ConstructEM();
|
||||
};
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -1,76 +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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: pyExN03pl.cc 76884 2013-11-18 12:54:03Z gcosmo $
|
||||
// ====================================================================
|
||||
// pyExN03pl.cc
|
||||
//
|
||||
// [ExN03pl]
|
||||
// a site-module of Geant4Py
|
||||
//
|
||||
// a physics list presnted in ExN03 of Geant4 example
|
||||
//
|
||||
// 2005 Q
|
||||
// ====================================================================
|
||||
#include <boost/python.hpp>
|
||||
#include "G4RunManager.hh"
|
||||
#include "PhysicsList.hh"
|
||||
|
||||
using namespace boost::python;
|
||||
|
||||
// ====================================================================
|
||||
// thin wrappers
|
||||
// ====================================================================
|
||||
namespace pyExN03pl {
|
||||
|
||||
PhysicsList* Construct()
|
||||
{
|
||||
PhysicsList* pl= new PhysicsList;
|
||||
|
||||
G4RunManager* runMgr= G4RunManager::GetRunManager();
|
||||
runMgr-> SetUserInitialization(pl);
|
||||
|
||||
return pl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
using namespace pyExN03pl;
|
||||
|
||||
// ====================================================================
|
||||
// Expose to Python
|
||||
// ====================================================================
|
||||
|
||||
BOOST_PYTHON_MODULE(ExN03pl) {
|
||||
|
||||
class_<PhysicsList, PhysicsList*, bases<G4VUserPhysicsList> >
|
||||
("PhysicsList", "ExN03 physics list")
|
||||
;
|
||||
|
||||
// ---
|
||||
def("Construct", Construct,
|
||||
return_value_policy<reference_existing_object>());
|
||||
|
||||
}
|
||||
@@ -1,136 +0,0 @@
|
||||
"""
|
||||
Python module
|
||||
|
||||
This module provides classes and functions for scoring reactions
|
||||
|
||||
[C] MCVertex:
|
||||
[C] MCParticle:
|
||||
[f] read_next_vertex(stream):
|
||||
|
||||
Q, 2006
|
||||
"""
|
||||
import string
|
||||
from Geant4.hepunit import *
|
||||
|
||||
# ==================================================================
|
||||
# public symbols
|
||||
# ==================================================================
|
||||
__all__ = [ 'MCParticle', 'MCVertex', 'read_next_vertex' ]
|
||||
|
||||
|
||||
# ==================================================================
|
||||
# class definition
|
||||
# ==================================================================
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# MCParticle
|
||||
# ------------------------------------------------------------------
|
||||
class MCParticle:
|
||||
"MC particle"
|
||||
def __init__(self, aname, aZ, aA, akE, apx, apy, apz):
|
||||
self.name = aname
|
||||
self.Z = aZ
|
||||
self.A = aA
|
||||
self.kineticE = akE
|
||||
self.px = apx
|
||||
self.py = apy
|
||||
self.pz = apz
|
||||
|
||||
def printout(self):
|
||||
print "--- particle: %s, Z=%2d, A=%2d, kE=%g" % \
|
||||
(self.name, self.Z, self.A, self.kineticE/MeV)
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# MCVertex
|
||||
# ------------------------------------------------------------------
|
||||
class MCVertex :
|
||||
"MC vertex"
|
||||
def __init__(self, ax, ay, az):
|
||||
self.x = ax
|
||||
self.y = ay
|
||||
self.z = az
|
||||
self.nparticle = 0
|
||||
self.particle_list = []
|
||||
|
||||
def append_particle(self, aparticle):
|
||||
self.particle_list.append(aparticle)
|
||||
self.nparticle= self.nparticle+1
|
||||
|
||||
def printout(self):
|
||||
print "@@@ vertex: x=(%g,%g,%g) Nsec=%3d" % \
|
||||
(self.x/cm, self.y/cm, self.z/cm, self.nparticle)
|
||||
for p in self.particle_list:
|
||||
p.printout()
|
||||
|
||||
def dump_vertex(self, stream):
|
||||
aline = "%g %g %g %d\n" % \
|
||||
(self.x/m, self.y/m, self.z/m, self.nparticle)
|
||||
stream.write(aline)
|
||||
for p in self.particle_list:
|
||||
aline = " %s %d %d %g %g %g %g\n" % \
|
||||
(p.name, p.Z, p.A, p.kineticE/MeV, p.px/MeV, p.py/MeV, p.pz/MeV)
|
||||
stream.write(aline)
|
||||
|
||||
def __del__(self):
|
||||
np = len(self.particle_list)
|
||||
del self.particle_list[0:np]
|
||||
|
||||
|
||||
# ==================================================================
|
||||
# I/O interface
|
||||
# ==================================================================
|
||||
def read_next_vertex(stream):
|
||||
"read next vertex from a file stream"
|
||||
line= stream.readline()
|
||||
if line == "": # EOF
|
||||
return 0
|
||||
|
||||
# reading vertex
|
||||
data = line.split()
|
||||
x = string.atof(data[0]) * m
|
||||
y = string.atof(data[1]) * m
|
||||
z = string.atof(data[2]) * m
|
||||
nsec = string.atoi(data[3])
|
||||
|
||||
vertex = MCVertex(x,y,z)
|
||||
|
||||
# reading particles
|
||||
for p in range(0, nsec):
|
||||
data = stream.readline().split()
|
||||
pname = data[0]
|
||||
Z = string.atoi(data[1])
|
||||
A = string.atoi(data[2])
|
||||
kE = string.atof(data[3]) * MeV
|
||||
px = string.atof(data[4]) * MeV
|
||||
py = string.atof(data[5]) * MeV
|
||||
pz = string.atof(data[6]) * MeV
|
||||
|
||||
particle = MCParticle(pname, Z, A, kE, px, py, pz)
|
||||
vertex.append_particle(particle)
|
||||
|
||||
return vertex
|
||||
|
||||
|
||||
# ==================================================================
|
||||
# test
|
||||
# ==================================================================
|
||||
def test():
|
||||
f = open("reaction.dat")
|
||||
f.seek(0)
|
||||
|
||||
while(1):
|
||||
vertex = read_next_vertex(f)
|
||||
if vertex == 0:
|
||||
break
|
||||
vertex.printout()
|
||||
del vertex
|
||||
f.close()
|
||||
print ">>> EOF"
|
||||
|
||||
|
||||
# ==================================================================
|
||||
# main
|
||||
# ==================================================================
|
||||
if __name__ == "__main__":
|
||||
test()
|
||||
|
||||
@@ -1,189 +0,0 @@
|
||||
"""
|
||||
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()
|
||||
|
||||
@@ -1,68 +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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: pyG4LossTableManager.cc 86749 2014-11-17 15:03:05Z gcosmo $
|
||||
// ====================================================================
|
||||
// pyG4LossTableManager.cc
|
||||
//
|
||||
// 2005 Q
|
||||
// ====================================================================
|
||||
#include <boost/python.hpp>
|
||||
#include "G4Version.hh"
|
||||
#include "G4LossTableManager.hh"
|
||||
|
||||
using namespace boost::python;
|
||||
|
||||
// ====================================================================
|
||||
// module definition
|
||||
// ====================================================================
|
||||
void export_G4LossTableManager()
|
||||
{
|
||||
class_<G4LossTableManager, boost::noncopyable>
|
||||
("G4LossTableManager", "energy loss table manager", no_init)
|
||||
.def("Instance", &G4LossTableManager::Instance,
|
||||
return_value_policy<reference_existing_object>())
|
||||
.staticmethod("Instance")
|
||||
|
||||
// internally used methods are limmitted to be exposed...
|
||||
.def("SetLossFluctuations", &G4LossTableManager::SetLossFluctuations)
|
||||
.def("SetSubCutoff", &G4LossTableManager::SetSubCutoff)
|
||||
.def("SetIntegral", &G4LossTableManager::SetIntegral)
|
||||
.def("SetRandomStep", &G4LossTableManager::SetRandomStep)
|
||||
.def("SetMinSubRange", &G4LossTableManager::SetMinSubRange)
|
||||
.def("SetMinEnergy", &G4LossTableManager::SetMinEnergy)
|
||||
.def("SetMaxEnergy", &G4LossTableManager::SetMaxEnergy)
|
||||
.def("SetMaxEnergyForCSDARange",
|
||||
&G4LossTableManager::SetMaxEnergyForCSDARange)
|
||||
.def("SetMaxEnergyForMuons", &G4LossTableManager::SetMaxEnergyForMuons)
|
||||
.def("SetStepFunction", &G4LossTableManager::SetStepFunction)
|
||||
.def("SetBuildCSDARange", &G4LossTableManager::SetBuildCSDARange)
|
||||
.def("SetVerbose", &G4LossTableManager::SetVerbose)
|
||||
.def("BuildCSDARange", &G4LossTableManager::BuildCSDARange)
|
||||
.def("SetLinearLossLimit", &G4LossTableManager::SetLinearLossLimit)
|
||||
;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,308 +0,0 @@
|
||||
"""
|
||||
# ==================================================================
|
||||
# Python module
|
||||
#
|
||||
# This module defines physical units and constants used in HEP,
|
||||
# which are imported from CLHEP library.
|
||||
#
|
||||
# Q, 2005
|
||||
# ==================================================================
|
||||
"""
|
||||
#$Id: hepunit.py 66892 2013-01-17 10:57:59Z gunter $
|
||||
|
||||
# ==================================================================
|
||||
# imported from "SystemOfUnits.h"
|
||||
# ==================================================================
|
||||
millimeter = 1.
|
||||
millimeter2 = millimeter*millimeter
|
||||
millimeter3 = millimeter*millimeter*millimeter
|
||||
|
||||
centimeter = 10.*millimeter
|
||||
centimeter2 = centimeter*centimeter
|
||||
centimeter3 = centimeter*centimeter*centimeter
|
||||
|
||||
meter = 1000.*millimeter
|
||||
meter2 = meter*meter
|
||||
meter3 = meter*meter*meter
|
||||
|
||||
kilometer = 1000.*meter
|
||||
kilometer2 = kilometer*kilometer
|
||||
kilometer3 = kilometer*kilometer*kilometer
|
||||
|
||||
parsec = 3.0856775807e+16*meter
|
||||
|
||||
micrometer = 1.e-6 *meter
|
||||
nanometer = 1.e-9 *meter
|
||||
angstrom = 1.e-10*meter
|
||||
fermi = 1.e-15*meter
|
||||
|
||||
barn = 1.e-28*meter2
|
||||
millibarn = 1.e-3 *barn
|
||||
microbarn = 1.e-6 *barn
|
||||
nanobarn = 1.e-9 *barn
|
||||
picobarn = 1.e-12*barn
|
||||
|
||||
# symbols
|
||||
mm = millimeter
|
||||
mm2 = millimeter2
|
||||
mm3 = millimeter3
|
||||
|
||||
cm = centimeter
|
||||
cm2 = centimeter2
|
||||
cm3 = centimeter3
|
||||
|
||||
m = meter
|
||||
m2 = meter2
|
||||
m3 = meter3
|
||||
|
||||
km = kilometer
|
||||
km2 = kilometer2
|
||||
km3 = kilometer3
|
||||
|
||||
pc = parsec
|
||||
|
||||
#
|
||||
# Angle
|
||||
#
|
||||
radian = 1.
|
||||
milliradian = 1.e-3*radian
|
||||
degree = (3.14159265358979323846/180.0)*radian
|
||||
|
||||
steradian = 1.
|
||||
|
||||
# symbols
|
||||
rad = radian
|
||||
mrad = milliradian
|
||||
sr = steradian
|
||||
deg = degree
|
||||
|
||||
#
|
||||
# Time [T]
|
||||
#
|
||||
nanosecond = 1.
|
||||
second = 1.e+9 *nanosecond
|
||||
millisecond = 1.e-3 *second
|
||||
microsecond = 1.e-6 *second
|
||||
picosecond = 1.e-12*second
|
||||
|
||||
hertz = 1./second
|
||||
kilohertz = 1.e+3*hertz
|
||||
megahertz = 1.e+6*hertz
|
||||
|
||||
# symbols
|
||||
ns = nanosecond
|
||||
s = second
|
||||
ms = millisecond
|
||||
|
||||
#
|
||||
# Electric charge [Q]
|
||||
#
|
||||
eplus = 1. # positron charge
|
||||
e_SI = 1.60217733e-19 # positron charge in coulomb
|
||||
coulomb = eplus/e_SI # coulomb = 6.24150 e+18 * eplus
|
||||
|
||||
#
|
||||
# Energy [E]
|
||||
#
|
||||
megaelectronvolt = 1.
|
||||
electronvolt = 1.e-6*megaelectronvolt
|
||||
kiloelectronvolt = 1.e-3*megaelectronvolt
|
||||
gigaelectronvolt = 1.e+3*megaelectronvolt
|
||||
teraelectronvolt = 1.e+6*megaelectronvolt
|
||||
petaelectronvolt = 1.e+9*megaelectronvolt
|
||||
|
||||
joule = electronvolt/e_SI # joule = 6.24150 e+12 * MeV
|
||||
|
||||
# symbols
|
||||
MeV = megaelectronvolt
|
||||
eV = electronvolt
|
||||
keV = kiloelectronvolt
|
||||
GeV = gigaelectronvolt
|
||||
TeV = teraelectronvolt
|
||||
PeV = petaelectronvolt
|
||||
|
||||
#
|
||||
# Mass [E][T^2][L^-2]
|
||||
#
|
||||
kilogram = joule*second*second/(meter*meter)
|
||||
gram = 1.e-3*kilogram
|
||||
milligram = 1.e-3*gram
|
||||
|
||||
# symbols
|
||||
kg = kilogram
|
||||
g = gram
|
||||
mg = milligram
|
||||
|
||||
#
|
||||
# Power [E][T^-1]
|
||||
#
|
||||
watt = joule/second # watt = 6.24150 e+3 * MeV/ns
|
||||
|
||||
#
|
||||
# Force [E][L^-1]
|
||||
#
|
||||
newton = joule/meter # newton = 6.24150 e+9 * MeV/mm
|
||||
|
||||
#
|
||||
# Pressure [E][L^-3]
|
||||
#
|
||||
pascal = newton/m2 # pascal = 6.24150 e+3 * MeV/mm3
|
||||
bar = 100000*pascal # bar = 6.24150 e+8 * MeV/mm3
|
||||
atmosphere = 101325*pascal # atm = 6.32420 e+8 * MeV/mm3
|
||||
|
||||
#
|
||||
# Electric current [Q][T^-1]
|
||||
#
|
||||
ampere = coulomb/second # ampere = 6.24150 e+9 * eplus/ns
|
||||
milliampere = 1.e-3*ampere
|
||||
microampere = 1.e-6*ampere
|
||||
nanoampere = 1.e-9*ampere
|
||||
|
||||
#
|
||||
# Electric potential [E][Q^-1]
|
||||
#
|
||||
megavolt = megaelectronvolt/eplus
|
||||
kilovolt = 1.e-3*megavolt
|
||||
volt = 1.e-6*megavolt
|
||||
|
||||
#
|
||||
# Electric resistance [E][T][Q^-2]
|
||||
#
|
||||
ohm = volt/ampere # ohm = 1.60217e-16*(MeV/eplus)/(eplus/ns)
|
||||
|
||||
#
|
||||
# Electric capacitance [Q^2][E^-1]
|
||||
#
|
||||
farad = coulomb/volt # farad = 6.24150e+24 * eplus/Megavolt
|
||||
millifarad = 1.e-3*farad
|
||||
microfarad = 1.e-6*farad
|
||||
nanofarad = 1.e-9*farad
|
||||
picofarad = 1.e-12*farad
|
||||
|
||||
#
|
||||
# Magnetic Flux [T][E][Q^-1]
|
||||
#
|
||||
weber = volt*second # weber = 1000*megavolt*ns
|
||||
|
||||
#
|
||||
# Magnetic Field [T][E][Q^-1][L^-2]
|
||||
#
|
||||
tesla = volt*second/meter2 # tesla =0.001*megavolt*ns/mm2
|
||||
|
||||
gauss = 1.e-4*tesla
|
||||
kilogauss = 1.e-1*tesla
|
||||
|
||||
#
|
||||
# Inductance [T^2][E][Q^-2]
|
||||
#
|
||||
henry = weber/ampere # henry = 1.60217e-7*MeV*(ns/eplus)**2
|
||||
|
||||
#
|
||||
# Temperature
|
||||
#
|
||||
kelvin = 1.
|
||||
|
||||
#
|
||||
# Amount of substance
|
||||
#
|
||||
mole = 1.
|
||||
|
||||
#
|
||||
# Activity [T^-1]
|
||||
#
|
||||
becquerel = 1./second
|
||||
curie = 3.7e+10 * becquerel
|
||||
|
||||
#
|
||||
# Absorbed dose [L^2][T^-2]
|
||||
#
|
||||
gray = joule/kilogram
|
||||
|
||||
#
|
||||
# Luminous intensity [I]
|
||||
#
|
||||
candela = 1.
|
||||
|
||||
#
|
||||
# Luminous flux [I]
|
||||
#
|
||||
lumen = candela*steradian
|
||||
|
||||
#
|
||||
# Illuminance [I][L^-2]
|
||||
#
|
||||
lux = lumen/meter2
|
||||
|
||||
#
|
||||
# Miscellaneous
|
||||
#
|
||||
perCent = 0.01
|
||||
perThousand = 0.001
|
||||
perMillion = 0.000001
|
||||
|
||||
|
||||
# ==================================================================
|
||||
# imported from "PhysicalConstants.h"
|
||||
# ==================================================================
|
||||
pi = 3.14159265358979323846
|
||||
twopi = 2.*pi
|
||||
halfpi = pi/2.
|
||||
pi2 = pi*pi
|
||||
|
||||
#
|
||||
Avogadro = 6.0221367e+23/mole
|
||||
|
||||
# c = 299.792458 mm/ns
|
||||
# c^2 = 898.7404 (mm/ns)^2
|
||||
c_light = 2.99792458e+8 * m/s
|
||||
c_squared = c_light * c_light
|
||||
|
||||
# h = 4.13566e-12 MeV*ns
|
||||
# hbar = 6.58212e-13 MeV*ns
|
||||
# hbarc = 197.32705e-12 MeV*mm
|
||||
h_Planck = 6.6260755e-34 * joule*s
|
||||
hbar_Planck = h_Planck/twopi
|
||||
hbarc = hbar_Planck * c_light
|
||||
hbarc_squared = hbarc * hbarc
|
||||
|
||||
#
|
||||
electron_charge = - eplus # see SystemOfUnits.h
|
||||
e_squared = eplus * eplus
|
||||
|
||||
# amu_c2 - atomic equivalent mass unit
|
||||
# amu - atomic mass unit
|
||||
electron_mass_c2 = 0.51099906 * MeV
|
||||
proton_mass_c2 = 938.27231 * MeV
|
||||
neutron_mass_c2 = 939.56563 * MeV
|
||||
amu_c2 = 931.49432 * MeV
|
||||
amu = amu_c2/c_squared
|
||||
|
||||
# permeability of free space mu0 = 2.01334e-16 Mev*(ns*eplus)^2/mm
|
||||
# permittivity of free space epsil0 = 5.52636e+10 eplus^2/(MeV*mm)
|
||||
mu0 = 4*pi*1.e-7 * henry/m
|
||||
epsilon0 = 1./(c_squared*mu0)
|
||||
|
||||
# electromagnetic coupling = 1.43996e-12 MeV*mm/(eplus^2)
|
||||
elm_coupling = e_squared/(4*pi*epsilon0)
|
||||
fine_structure_const = elm_coupling/hbarc
|
||||
classic_electr_radius = elm_coupling/electron_mass_c2
|
||||
electron_Compton_length = hbarc/electron_mass_c2
|
||||
Bohr_radius = electron_Compton_length/fine_structure_const
|
||||
|
||||
alpha_rcl2 = fine_structure_const * classic_electr_radius \
|
||||
* classic_electr_radius
|
||||
twopi_mc2_rcl2 = twopi * electron_mass_c2 \
|
||||
* classic_electr_radius \
|
||||
* classic_electr_radius
|
||||
|
||||
#
|
||||
k_Boltzmann = 8.617385e-11 * MeV/kelvin
|
||||
|
||||
#
|
||||
STP_Temperature = 273.15*kelvin
|
||||
STP_Pressure = 1.*atmosphere
|
||||
kGasThreshold = 10.*mg/cm3
|
||||
|
||||
#
|
||||
universe_mean_density = 1.e-25*g/cm3
|
||||
|
||||
Reference in New Issue
Block a user