Import Geant4 8.1.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-09 14:44:26 +02:00
parent 8a51e0bc40
commit 216a75eeb1
8717 changed files with 360418 additions and 141343 deletions
@@ -0,0 +1,19 @@
# $Id: GNUmakefile,v 1.2 2006/04/25 10:29:52 kmura Exp $
# $Name: geant4-08-01 $
# ===========================================================
# Makefile for building Geant4Py site-modules
# ===========================================================
SUBDIR := ParticleGun MedicalBeam
.PHONY: all install clean cleanlib
all:
@for dir in $(SUBDIR); do (cd $$dir && $(MAKE)); done;:
install:
@for dir in $(SUBDIR); do (cd $$dir && $(MAKE) install); done;:
clean:
@for dir in $(SUBDIR); do (cd $$dir && $(MAKE) clean); done;:
@@ -0,0 +1,14 @@
# $Id: GNUmakefile,v 1.2 2006/04/25 10:29:52 kmura Exp $
# $Name: geant4-08-01 $
# ===========================================================
# Makefile for building Geant4Py modules
# ===========================================================
include ../../../config/config.gmk
# python module name
MODULE := MedicalBeam#
include $(G4PY_INSTALL)/config/g4py.gmk
include $(G4PY_INSTALL)/config/module.gmk
include $(G4PY_INSTALL)/config/site-install.gmk
@@ -0,0 +1,135 @@
//
// ********************************************************************
// * 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: MedicalBeam.cc,v 1.6 2006/06/29 15:30:10 gunter Exp $
// $Name: geant4-08-01 $
// ====================================================================
// 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 dcos, dsin, dphi, z;
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.;
}
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;
}
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,145 @@
//
// ********************************************************************
// * 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: MedicalBeam.hh,v 1.4 2006/06/29 15:30:12 gunter Exp $
// $Name: geant4-08-01 $
// ====================================================================
// 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,164 @@
//
// ********************************************************************
// * 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: pyMedicalBeam.cc,v 1.4 2006/06/29 15:30:14 gunter Exp $
// $Name: geant4-08-01 $
// ====================================================================
// 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,14 @@
# $Id: GNUmakefile,v 1.2 2006/04/25 10:29:52 kmura Exp $
# $Name: geant4-08-01 $
# ===========================================================
# Makefile for building Geant4Py modules
# ===========================================================
include ../../../config/config.gmk
# python module name
MODULE := ParticleGun#
include $(G4PY_INSTALL)/config/g4py.gmk
include $(G4PY_INSTALL)/config/module.gmk
include $(G4PY_INSTALL)/config/site-install.gmk
@@ -0,0 +1,62 @@
//
// ********************************************************************
// * 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: ParticleGunAction.cc,v 1.4 2006/06/29 15:30:16 gunter Exp $
// $Name: geant4-08-01 $
// ====================================================================
// ParticleGunAction.cc
//
// 2005 Q
// ====================================================================
#include "ParticleGunAction.hh"
#include "G4ParticleGun.hh"
// ====================================================================
//
// class description
//
// ====================================================================
//////////////////////////////////////
ParticleGunAction::ParticleGunAction()
//////////////////////////////////////
{
particleGun= new G4ParticleGun;
}
///////////////////////////////////////
ParticleGunAction::~ParticleGunAction()
///////////////////////////////////////
{
delete particleGun;
}
///////////////////////////////////////////////////////////
void ParticleGunAction::GeneratePrimaries(G4Event* anEvent)
///////////////////////////////////////////////////////////
{
particleGun-> GeneratePrimaryVertex(anEvent);
}
@@ -0,0 +1,65 @@
//
// ********************************************************************
// * 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: ParticleGunAction.hh,v 1.4 2006/06/29 15:30:19 gunter Exp $
// $Name: geant4-08-01 $
// ====================================================================
// ParticleGunAction.hh
//
// 2005 Q
// ====================================================================
#ifndef PARTICLE_GUN_ACTION_H
#define PARTICLE_GUN_ACTION_H
#include "G4VUserPrimaryGeneratorAction.hh"
class G4ParticleGun;
// ====================================================================
//
// class definition
//
// ====================================================================
class ParticleGunAction : public G4VUserPrimaryGeneratorAction {
private:
// use G4 particle gun
G4ParticleGun* particleGun;
public:
ParticleGunAction();
~ParticleGunAction();
G4ParticleGun* GetParticleGun() const;
virtual void GeneratePrimaries(G4Event* anEvent);
};
// ====================================================================
// inline functions
// ====================================================================
inline G4ParticleGun* ParticleGunAction::GetParticleGun() const
{ return particleGun; }
#endif
@@ -0,0 +1,81 @@
//
// ********************************************************************
// * 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: pyParticleGun.cc,v 1.4 2006/06/29 15:30:21 gunter Exp $
// $Name: geant4-08-01 $
// ====================================================================
// 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>());
}