Import Geant4 4.0.0 source tree
This commit is contained in:
@@ -30,7 +30,7 @@
|
||||
// Organisation: University of Southampton / DERA
|
||||
// Customer: ESA/ESTEC
|
||||
//
|
||||
// Documentation available at http://www.space.dera.gov.uk/space_env/gspm.html
|
||||
// Documentation avaialable at http://www.space.dera.gov.uk/space_env/gspm.html
|
||||
// These include:
|
||||
// User Requirement Document (URD)
|
||||
// Software Specification Documents (SSD)
|
||||
@@ -38,12 +38,16 @@
|
||||
// Technical Note (TN) on the physics and algorithms
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// $Id: G4GeneralParticleSource.cc,v 1.9 2001/06/29 08:06:03 gcosmo Exp $
|
||||
// GEANT4 tag $Name: event-V03-01-01 $
|
||||
// $Id: G4GeneralParticleSource.cc,v 1.14 2001/10/19 16:48:28 flei Exp $
|
||||
// GEANT4 tag $Name: geant4-04-00 $
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CHANGE HISTORY
|
||||
// --------------
|
||||
// Further changes is recorded in the CVS HIstory file
|
||||
//
|
||||
// 9-May-2001 F. Lei
|
||||
// added all the g4pariclegun commands
|
||||
//
|
||||
// 26-01-2001, F. Lei
|
||||
// replace:
|
||||
@@ -51,10 +55,10 @@
|
||||
//
|
||||
// with:
|
||||
// if (posthe != 0. && posthe != pi)
|
||||
// { posphi = acos(tx/sin(posthe)); }
|
||||
// posphi = acos(tx/sin(posthe));
|
||||
// else
|
||||
// { posphi = 0.0;}
|
||||
// endif
|
||||
// posphi = 0.0;
|
||||
//
|
||||
//
|
||||
// 10-Nov-2000, F. Lei
|
||||
// some bug fixing:
|
||||
@@ -96,8 +100,8 @@ G4GeneralParticleSource::G4GeneralParticleSource()
|
||||
NumberOfParticlesToBeGenerated = 1;
|
||||
particle_definition = NULL;
|
||||
G4ThreeVector zero;
|
||||
particle_momentum_direction = (G4ParticleMomentum)zero;
|
||||
particle_energy = 0.0;
|
||||
particle_momentum_direction = G4ParticleMomentum(1,0,0);
|
||||
particle_energy = 1.0*MeV;
|
||||
particle_position = zero;
|
||||
particle_time = 0.0;
|
||||
particle_polarization = zero;
|
||||
@@ -110,10 +114,13 @@ G4GeneralParticleSource::G4GeneralParticleSource()
|
||||
halfz = 0.;
|
||||
Radius = 0.;
|
||||
Radius0 = 0.;
|
||||
SR = 0.;
|
||||
SX = 0.;
|
||||
SY = 0.;
|
||||
ParAlpha = 0.;
|
||||
ParTheta = 0.;
|
||||
ParPhi = 0.;
|
||||
CentreCoords = (0.,0.,0.);
|
||||
CentreCoords = G4ThreeVector(0., 0., 0.);
|
||||
Rotx = HepXHat;
|
||||
Roty = HepYHat;
|
||||
Rotz = HepZHat;
|
||||
@@ -122,18 +129,19 @@ G4GeneralParticleSource::G4GeneralParticleSource()
|
||||
SideRefVec1 = HepXHat; // x-axis
|
||||
SideRefVec2 = HepYHat; // y-axis
|
||||
SideRefVec3 = HepZHat; // z-axis
|
||||
UserWRTSurface = false; // Any user-defined distribution is wrt co-ordinate
|
||||
// axes.
|
||||
|
||||
// Angular distribution variables.
|
||||
AngDistType = "iso";
|
||||
AngRef1 = (1.,0.,0.);
|
||||
AngRef2 = (0.,1.,0.);
|
||||
AngRef3 = (0.,0.,1.);
|
||||
AngDistType = "planar";
|
||||
AngRef1 = HepXHat;
|
||||
AngRef2 = HepYHat;
|
||||
AngRef3 = HepZHat;
|
||||
MinTheta = 0.;
|
||||
MaxTheta = pi;
|
||||
MinPhi = 0.;
|
||||
MaxPhi = twopi;
|
||||
DR = 0.;
|
||||
DX = 0.;
|
||||
DY = 0.;
|
||||
UserDistType = "NULL";
|
||||
IPDFThetaExist = false;
|
||||
IPDFPhiExist = false;
|
||||
@@ -145,12 +153,15 @@ G4GeneralParticleSource::G4GeneralParticleSource()
|
||||
Emax = 0.;
|
||||
alpha = 0.;
|
||||
Ezero = 0.;
|
||||
SE = 0.;
|
||||
Temp = 0.;
|
||||
grad = 0.;
|
||||
cept = 0.;
|
||||
EnergySpec = true; // true - energy spectra, false - momentum spectra
|
||||
DiffSpec = true; // true - differential spec, false integral spec
|
||||
IntType = "NULL"; // Interpolation type
|
||||
UserWRTSurface = false; // Any user-defined distribution is wrt co-ordinate
|
||||
UserAngRef = false; // angular distribution is to mother or surface-normal co-or.
|
||||
IPDFEnergyExist = false;
|
||||
IPDFArbExist = false;
|
||||
|
||||
@@ -247,6 +258,21 @@ void G4GeneralParticleSource::SetRadius0(G4double rad)
|
||||
Radius0 = rad;
|
||||
}
|
||||
|
||||
void G4GeneralParticleSource::SetBeamSigmaInR(G4double r)
|
||||
{
|
||||
SR = r;
|
||||
}
|
||||
|
||||
void G4GeneralParticleSource::SetBeamSigmaInX(G4double r)
|
||||
{
|
||||
SX = r;
|
||||
}
|
||||
|
||||
void G4GeneralParticleSource::SetBeamSigmaInY(G4double r)
|
||||
{
|
||||
SY = r;
|
||||
}
|
||||
|
||||
void G4GeneralParticleSource::SetParAlpha(G4double paralp)
|
||||
{
|
||||
ParAlpha = paralp;
|
||||
@@ -291,7 +317,7 @@ void G4GeneralParticleSource::ConfineSourceToVolume(G4String Vname)
|
||||
G4bool found = false;
|
||||
if(verbosityLevel == 2)
|
||||
G4cout << PVStore->size() << G4endl;
|
||||
while (!found && i<PVStore->size()) {
|
||||
while (!found && i<G4int(PVStore->size())) {
|
||||
tempPV = (*PVStore)[i];
|
||||
found = tempPV->GetName() == theRequiredVolumeName;
|
||||
if(verbosityLevel == 2)
|
||||
@@ -326,13 +352,60 @@ void G4GeneralParticleSource::GeneratePointSource()
|
||||
G4cout << "Error SourcePosType is not set to Point" << G4endl;
|
||||
}
|
||||
|
||||
void G4GeneralParticleSource::GeneratePointsInBeam()
|
||||
{
|
||||
G4double x, y, z, r, phi;
|
||||
|
||||
G4ThreeVector RandPos;
|
||||
G4double tempx, tempy, tempz;
|
||||
z = 0.;
|
||||
// Private Method to create points in a plane
|
||||
if(Shape == "Circle")
|
||||
{
|
||||
r = G4RandGauss::shoot(0.0,SR) ;
|
||||
phi = twopi * G4UniformRand();
|
||||
x = r*cos(phi) ;
|
||||
y = r*sin(phi) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
// all other cases default to Rectangle case
|
||||
x = G4RandGauss::shoot(0.0,SX);
|
||||
y = G4RandGauss::shoot(0.0,SY);
|
||||
}
|
||||
// Apply Rotation Matrix
|
||||
// x * Rotx, y * Roty and z * Rotz
|
||||
if(verbosityLevel == 2)
|
||||
{
|
||||
G4cout << "Raw position " << x << "," << y << "," << z << G4endl;
|
||||
}
|
||||
tempx = (x * Rotx.x()) + (y * Roty.x()) + (z * Rotz.x());
|
||||
tempy = (x * Rotx.y()) + (y * Roty.y()) + (z * Rotz.y());
|
||||
tempz = (x * Rotx.z()) + (y * Roty.z()) + (z * Rotz.z());
|
||||
|
||||
RandPos.setX(tempx);
|
||||
RandPos.setY(tempy);
|
||||
RandPos.setZ(tempz);
|
||||
|
||||
// Translate
|
||||
particle_position = CentreCoords + RandPos;
|
||||
if(verbosityLevel >= 1)
|
||||
{
|
||||
if(verbosityLevel == 2)
|
||||
{
|
||||
G4cout << "Rotated Position " << RandPos << G4endl;
|
||||
}
|
||||
G4cout << "Rotated and Translated position " << particle_position << G4endl;
|
||||
}
|
||||
}
|
||||
|
||||
void G4GeneralParticleSource::GeneratePointsInPlane()
|
||||
{
|
||||
G4double x, y, z;
|
||||
G4double expression;
|
||||
G4ThreeVector RandPos;
|
||||
G4double tempx, tempy, tempz;
|
||||
z = 0.;
|
||||
x = y = z = 0.;
|
||||
|
||||
if(SourcePosType != "Plane" && verbosityLevel >= 1)
|
||||
G4cout << "Error: SourcePosType is not Plane" << G4endl;
|
||||
@@ -448,15 +521,16 @@ void G4GeneralParticleSource::GeneratePointsOnSurface()
|
||||
//Private method to create points on a surface
|
||||
G4double theta, phi;
|
||||
G4double x, y, z;
|
||||
x = y = z = 0.;
|
||||
G4ThreeVector RandPos;
|
||||
G4double tempx, tempy, tempz;
|
||||
// G4double tempx, tempy, tempz;
|
||||
|
||||
if(SourcePosType != "Surface" && verbosityLevel >= 1)
|
||||
G4cout << "Error SourcePosType not Surface" << G4endl;
|
||||
|
||||
if(Shape == "Sphere")
|
||||
{
|
||||
G4double tantheta, tanphi;
|
||||
G4double tantheta;
|
||||
theta = GenRandTheta();
|
||||
phi = GenRandPhi();
|
||||
|
||||
@@ -483,7 +557,7 @@ void G4GeneralParticleSource::GeneratePointsOnSurface()
|
||||
}
|
||||
else if(Shape == "Ellipsoid")
|
||||
{
|
||||
G4double testrand, theta, phi, minphi, maxphi, middlephi;
|
||||
G4double theta, phi, minphi, maxphi, middlephi;
|
||||
G4double answer, constant;
|
||||
|
||||
constant = pi/(halfx*halfx) + pi/(halfy*halfy) +
|
||||
@@ -854,7 +928,7 @@ void G4GeneralParticleSource::GeneratePointsInVolume()
|
||||
G4ThreeVector RandPos;
|
||||
G4double tempx, tempy, tempz;
|
||||
G4double x, y, z;
|
||||
|
||||
x = y = z = 0.;
|
||||
if(SourcePosType != "Volume" && verbosityLevel >= 1)
|
||||
G4cout << "Error SourcePosType not Volume" << G4endl;
|
||||
//Private method to create points in a volume
|
||||
@@ -990,19 +1064,27 @@ G4bool G4GeneralParticleSource::IsSourceConfined()
|
||||
|
||||
void G4GeneralParticleSource::SetAngDistType(G4String atype)
|
||||
{
|
||||
if(atype != "iso" && atype != "cos" && atype != "user")
|
||||
G4cout << "Error, distribution must be iso, cos or user" << G4endl;
|
||||
if(atype != "iso" && atype != "cos" && atype != "user" && atype != "planar"
|
||||
&& atype != "beam1d" && atype != "beam2d")
|
||||
G4cout << "Error, distribution must be iso, cos, planar, beam1d, beam2d or user" << G4endl;
|
||||
else
|
||||
AngDistType = atype;
|
||||
if (AngDistType == "cos") MaxTheta = pi/2. ;
|
||||
if (AngDistType == "user") {
|
||||
UDefThetaH = IPDFThetaH = ZeroPhysVector ;
|
||||
IPDFThetaExist = false ;
|
||||
UDefPhiH = IPDFPhiH = ZeroPhysVector ;
|
||||
IPDFPhiExist = false ;
|
||||
}
|
||||
}
|
||||
|
||||
void G4GeneralParticleSource::DefineAngRefAxes(G4String refname, G4ThreeVector ref)
|
||||
{
|
||||
|
||||
if(refname == "angref1")
|
||||
AngRef1 = ref; // x'
|
||||
AngRef1 = ref.unit(); // x'
|
||||
else if(refname == "angref2")
|
||||
AngRef2 = ref; // vector in x'y' plane
|
||||
AngRef2 = ref.unit(); // vector in x'y' plane
|
||||
|
||||
// User defines x' (AngRef1) and a vector in the x'y'
|
||||
// plane (AngRef2). Then, AngRef1 x AngRef2 = AngRef3
|
||||
@@ -1011,6 +1093,7 @@ void G4GeneralParticleSource::DefineAngRefAxes(G4String refname, G4ThreeVector r
|
||||
|
||||
AngRef3 = AngRef1.cross(AngRef2); // z'
|
||||
AngRef2 = AngRef3.cross(AngRef1); // y'
|
||||
UserAngRef = true ;
|
||||
if(verbosityLevel == 2)
|
||||
{
|
||||
G4cout << "Angular distribution rotation axes " << AngRef1 << " " << AngRef2 << " " << AngRef3 << G4endl;
|
||||
@@ -1037,6 +1120,21 @@ void G4GeneralParticleSource::SetMaxPhi(G4double maxp)
|
||||
MaxPhi = maxp;
|
||||
}
|
||||
|
||||
void G4GeneralParticleSource::SetBeamSigmaInAngR(G4double r)
|
||||
{
|
||||
DR = r;
|
||||
}
|
||||
|
||||
void G4GeneralParticleSource::SetBeamSigmaInAngX(G4double r)
|
||||
{
|
||||
DX = r;
|
||||
}
|
||||
|
||||
void G4GeneralParticleSource::SetBeamSigmaInAngY(G4double r)
|
||||
{
|
||||
DY = r;
|
||||
}
|
||||
|
||||
void G4GeneralParticleSource::UserDefAngTheta(G4ThreeVector input)
|
||||
{
|
||||
if(UserDistType == "NULL") UserDistType = "theta";
|
||||
@@ -1070,12 +1168,67 @@ void G4GeneralParticleSource::SetUserWRTSurface(G4bool wrtSurf)
|
||||
UserWRTSurface = wrtSurf;
|
||||
}
|
||||
|
||||
void G4GeneralParticleSource::SetUseUserAngAxis(G4bool userang)
|
||||
{
|
||||
// if UserAngRef = true the angular distribution is defined wrt
|
||||
// the user defined co-ordinates
|
||||
UserAngRef = userang;
|
||||
}
|
||||
|
||||
void G4GeneralParticleSource::GenerateBeamFlux()
|
||||
{
|
||||
// generates isotropic flux.
|
||||
// No vectors are needed.
|
||||
G4double theta, phi;
|
||||
G4double px, py, pz;
|
||||
if (AngDistType == "beam1d")
|
||||
{
|
||||
theta = G4RandGauss::shoot(0.0,DR);
|
||||
phi = twopi * G4UniformRand();
|
||||
}
|
||||
else
|
||||
{
|
||||
px = G4RandGauss::shoot(0.0,DX);
|
||||
py = G4RandGauss::shoot(0.0,DY);
|
||||
theta = sqrt (px*px + py*py);
|
||||
if (theta != 0.) {
|
||||
phi = acos(px/theta);
|
||||
if ( py < 0.) phi = -phi;
|
||||
}
|
||||
else
|
||||
{
|
||||
phi = 0.0;
|
||||
}
|
||||
}
|
||||
px = -sin(theta) * cos(phi);
|
||||
py = -sin(theta) * sin(phi);
|
||||
pz = -cos(theta);
|
||||
// Apply Angular Rotation Matrix
|
||||
// x * AngRef1, y * AngRef2 and z * AngRef3
|
||||
G4double finx, finy, finz;
|
||||
finx = (px * AngRef1.x()) + (py * AngRef2.x()) + (pz * AngRef3.x());
|
||||
finy = (px * AngRef1.y()) + (py * AngRef2.y()) + (pz * AngRef3.y());
|
||||
finz = (px * AngRef1.z()) + (py * AngRef2.z()) + (pz * AngRef3.z());
|
||||
G4double ResMag = sqrt((finx*finx) + (finy*finy) + (finz*finz));
|
||||
finx = finx/ResMag;
|
||||
finy = finy/ResMag;
|
||||
finz = finz/ResMag;
|
||||
|
||||
particle_momentum_direction.setX(finx);
|
||||
particle_momentum_direction.setY(finy);
|
||||
particle_momentum_direction.setZ(finz);
|
||||
|
||||
// particle_momentum_direction now holds unit momentum vector.
|
||||
if(verbosityLevel >= 1)
|
||||
G4cout << "Generating beam vector: " << particle_momentum_direction << G4endl;
|
||||
}
|
||||
|
||||
void G4GeneralParticleSource::GenerateIsotropicFlux()
|
||||
{
|
||||
// generates isotropic flux.
|
||||
// No vectors are needed.
|
||||
G4double rndm, rndm2;
|
||||
G4double px, py, pz, pmag;
|
||||
G4double px, py, pz;
|
||||
|
||||
// generate rand nos. but make sure in theta/phi limits
|
||||
/* Colin's old stuff
|
||||
@@ -1111,21 +1264,23 @@ void G4GeneralParticleSource::GenerateIsotropicFlux()
|
||||
sinphi = sin(Phi);
|
||||
cosphi = cos(Phi);
|
||||
|
||||
px = sintheta * cosphi;
|
||||
py = sintheta * sinphi;
|
||||
pz = costheta;
|
||||
px = -sintheta * cosphi;
|
||||
py = -sintheta * sinphi;
|
||||
pz = -costheta;
|
||||
|
||||
// end of F.Lei implementation
|
||||
|
||||
px = -px;
|
||||
py = -py;
|
||||
pz = -pz;
|
||||
// px = -px;
|
||||
//py = -py;
|
||||
//pz = -pz;
|
||||
|
||||
pmag = sqrt((px*px) + (py*py) + (pz*pz));
|
||||
// pmag = sqrt((px*px) + (py*py) + (pz*pz));
|
||||
|
||||
px = px/pmag;
|
||||
py = py/pmag;
|
||||
pz = pz/pmag;
|
||||
//px = px/pmag;
|
||||
//py = py/pmag;
|
||||
//pz = pz/pmag;
|
||||
|
||||
/* this implmentation is commented out by f.lei
|
||||
|
||||
//Need to rotate the particle_momentum_direction round such that the
|
||||
//start position is at the north pole, so that all particles go into
|
||||
@@ -1144,17 +1299,60 @@ void G4GeneralParticleSource::GenerateIsotropicFlux()
|
||||
ty = ty/tt;
|
||||
tz = tz/tt;
|
||||
// G4cout << "unit position " << tx << " " << ty << " " << tz << G4endl;
|
||||
posthe = acos(tz);
|
||||
if (posthe != 0. && posthe != pi)
|
||||
{ posphi = acos(tx/sin(posthe)); }
|
||||
else
|
||||
{ posphi = 0.0;}
|
||||
if (tt != 0.) {
|
||||
posthe = acos(tz);
|
||||
}
|
||||
else {
|
||||
posthe = 0.;
|
||||
}
|
||||
if (posthe != 0. && posthe != pi){
|
||||
posphi = acos(tx/sin(posthe));
|
||||
}
|
||||
else{
|
||||
posphi = 0.0;
|
||||
}
|
||||
// G4cout << "Posthe and posphi " << posthe << " " << posphi << G4endl;
|
||||
G4double finx, finy, finz;
|
||||
finx = (px*cos(posthe)*cos(posphi)) - (py*sin(posphi)) + (pz*sin(posthe)*cos(posphi));
|
||||
finy = (px*cos(posthe)*sin(posphi)) + (py*cos(posphi)) + (pz*sin(posthe)*sin(posphi));
|
||||
finz = (-px*sin(posthe)) + (pz*cos(posthe));
|
||||
// G4cout << "finx... " << finx << " " << finy << " " << finz << G4endl;
|
||||
// G4cout << "finx... " << finx << " " << finy << " " << finz << G4endl;
|
||||
*/
|
||||
|
||||
// New implementation
|
||||
// for volume and ponit source use mother or user defined co-ordinates
|
||||
// for plane and surface source user surface-normal or userdefined co-ordinates
|
||||
//
|
||||
G4double finx, finy, finz;
|
||||
if (SourcePosType == "Point" || SourcePosType == "Volume") {
|
||||
if (UserAngRef){
|
||||
// Apply Rotation Matrix
|
||||
// x * AngRef1, y * AngRef2 and z * AngRef3
|
||||
finx = (px * AngRef1.x()) + (py * AngRef2.x()) + (pz * AngRef3.x());
|
||||
finy = (px * AngRef1.y()) + (py * AngRef2.y()) + (pz * AngRef3.y());
|
||||
finz = (px * AngRef1.z()) + (py * AngRef2.z()) + (pz * AngRef3.z());
|
||||
} else {
|
||||
finx = px;
|
||||
finy = py;
|
||||
finz = pz;
|
||||
}
|
||||
} else { // for plane and surface source
|
||||
if (UserAngRef){
|
||||
// Apply Rotation Matrix
|
||||
// x * AngRef1, y * AngRef2 and z * AngRef3
|
||||
finx = (px * AngRef1.x()) + (py * AngRef2.x()) + (pz * AngRef3.x());
|
||||
finy = (px * AngRef1.y()) + (py * AngRef2.y()) + (pz * AngRef3.y());
|
||||
finz = (px * AngRef1.z()) + (py * AngRef2.z()) + (pz * AngRef3.z());
|
||||
} else {
|
||||
finx = (px*SideRefVec1.x()) + (py*SideRefVec2.x()) + (pz*SideRefVec3.x());
|
||||
finy = (px*SideRefVec1.y()) + (py*SideRefVec2.y()) + (pz*SideRefVec3.y());
|
||||
finz = (px*SideRefVec1.z()) + (py*SideRefVec2.z()) + (pz*SideRefVec3.z());
|
||||
}
|
||||
}
|
||||
G4double ResMag = sqrt((finx*finx) + (finy*finy) + (finz*finz));
|
||||
finx = finx/ResMag;
|
||||
finy = finy/ResMag;
|
||||
finz = finz/ResMag;
|
||||
|
||||
particle_momentum_direction.setX(finx);
|
||||
particle_momentum_direction.setY(finy);
|
||||
@@ -1169,9 +1367,9 @@ void G4GeneralParticleSource::GenerateCosineLawFlux()
|
||||
{
|
||||
// Method to generate flux distributed with a cosine law
|
||||
// such as is in TIMM.
|
||||
G4double px, py, pz, pmag;
|
||||
G4double px, py, pz;
|
||||
G4double rndm, rndm2;
|
||||
G4double resultx, resulty, resultz;
|
||||
// G4double resultx, resulty, resultz;
|
||||
|
||||
/* Colin's old implementation which is very slow
|
||||
|
||||
@@ -1198,7 +1396,8 @@ void G4GeneralParticleSource::GenerateCosineLawFlux()
|
||||
//
|
||||
G4double sintheta, sinphi,costheta,cosphi;
|
||||
rndm = GenRandTheta();
|
||||
sintheta = sqrt( rndm * (sin(MaxTheta)*sin(MaxTheta) - sin(MinTheta)*sin(MinTheta) ) );
|
||||
sintheta = sqrt( rndm * (sin(MaxTheta)*sin(MaxTheta) - sin(MinTheta)*sin(MinTheta) )
|
||||
+sin(MinTheta)*sin(MinTheta) );
|
||||
costheta = sqrt(1. -sintheta*sintheta);
|
||||
|
||||
rndm2 = GenRandPhi();
|
||||
@@ -1206,20 +1405,21 @@ void G4GeneralParticleSource::GenerateCosineLawFlux()
|
||||
sinphi = sin(Phi);
|
||||
cosphi = cos(Phi);
|
||||
|
||||
px = sintheta * cosphi;
|
||||
py = sintheta * sinphi;
|
||||
pz = costheta;
|
||||
px = -sintheta * cosphi;
|
||||
py = -sintheta * sinphi;
|
||||
pz = -costheta;
|
||||
|
||||
// end of F.Lei implementation
|
||||
|
||||
px = -px;
|
||||
py = -py;
|
||||
pz = -pz;
|
||||
pmag = sqrt((px*px) + (py*py) + (pz*pz));
|
||||
G4double pxh = px/pmag;
|
||||
G4double pyh = py/pmag;
|
||||
G4double pzh = pz/pmag;
|
||||
// px = -px;
|
||||
//py = -py;
|
||||
//pz = -pz;
|
||||
//pmag = sqrt((px*px) + (py*py) + (pz*pz));
|
||||
//G4double pxh = px/pmag;
|
||||
//G4double pyh = py/pmag;
|
||||
//G4double pzh = pz/pmag;
|
||||
|
||||
/* commented out by F. Lei
|
||||
if(verbosityLevel == 2)
|
||||
{
|
||||
G4cout <<"SideRefVecs " <<SideRefVec1<<SideRefVec2<<SideRefVec3<<G4endl;
|
||||
@@ -1243,6 +1443,46 @@ void G4GeneralParticleSource::GenerateCosineLawFlux()
|
||||
particle_momentum_direction.setY(resulty);
|
||||
particle_momentum_direction.setZ(resultz);
|
||||
|
||||
*/
|
||||
// New implementation
|
||||
// for volume and ponit source use mother or user defined co-ordinates
|
||||
// for plane and surface source user surface-normal or userdefined co-ordinates
|
||||
//
|
||||
G4double finx, finy, finz;
|
||||
if (SourcePosType == "Point" || SourcePosType == "Volume") {
|
||||
if (UserAngRef){
|
||||
// Apply Rotation Matrix
|
||||
// x * AngRef1, y * AngRef2 and z * AngRef3
|
||||
finx = (px * AngRef1.x()) + (py * AngRef2.x()) + (pz * AngRef3.x());
|
||||
finy = (px * AngRef1.y()) + (py * AngRef2.y()) + (pz * AngRef3.y());
|
||||
finz = (px * AngRef1.z()) + (py * AngRef2.z()) + (pz * AngRef3.z());
|
||||
} else {
|
||||
finx = px;
|
||||
finy = py;
|
||||
finz = pz;
|
||||
}
|
||||
} else { // for plane and surface source
|
||||
if (UserAngRef){
|
||||
// Apply Rotation Matrix
|
||||
// x * AngRef1, y * AngRef2 and z * AngRef3
|
||||
finx = (px * AngRef1.x()) + (py * AngRef2.x()) + (pz * AngRef3.x());
|
||||
finy = (px * AngRef1.y()) + (py * AngRef2.y()) + (pz * AngRef3.y());
|
||||
finz = (px * AngRef1.z()) + (py * AngRef2.z()) + (pz * AngRef3.z());
|
||||
} else {
|
||||
finx = (px*SideRefVec1.x()) + (py*SideRefVec2.x()) + (pz*SideRefVec3.x());
|
||||
finy = (px*SideRefVec1.y()) + (py*SideRefVec2.y()) + (pz*SideRefVec3.y());
|
||||
finz = (px*SideRefVec1.z()) + (py*SideRefVec2.z()) + (pz*SideRefVec3.z());
|
||||
}
|
||||
}
|
||||
G4double ResMag = sqrt((finx*finx) + (finy*finy) + (finz*finz));
|
||||
finx = finx/ResMag;
|
||||
finy = finy/ResMag;
|
||||
finz = finz/ResMag;
|
||||
|
||||
particle_momentum_direction.setX(finx);
|
||||
particle_momentum_direction.setY(finy);
|
||||
particle_momentum_direction.setZ(finz);
|
||||
|
||||
// particle_momentum_direction now contains unit momentum vector.
|
||||
if(verbosityLevel >= 1)
|
||||
{
|
||||
@@ -1250,6 +1490,17 @@ void G4GeneralParticleSource::GenerateCosineLawFlux()
|
||||
}
|
||||
}
|
||||
|
||||
void G4GeneralParticleSource::GeneratePlanarFlux()
|
||||
{
|
||||
// particle_momentum_direction now contains unit momentum vector.
|
||||
// nothing need be done here as the m-directions have been set directly
|
||||
// under this option
|
||||
if(verbosityLevel >= 1)
|
||||
{
|
||||
G4cout << "Resultant Planar wave momentum vector " << particle_momentum_direction << G4endl;
|
||||
}
|
||||
}
|
||||
|
||||
void G4GeneralParticleSource::GenerateUserDefFlux()
|
||||
{
|
||||
G4double rndm, px, py, pz, pmag;
|
||||
@@ -1290,9 +1541,26 @@ void G4GeneralParticleSource::GenerateUserDefFlux()
|
||||
|
||||
if(UserWRTSurface == false)
|
||||
{
|
||||
particle_momentum_direction.setX(px/pmag);
|
||||
particle_momentum_direction.setY(py/pmag);
|
||||
particle_momentum_direction.setZ(pz/pmag);
|
||||
G4double finx, finy, finz;
|
||||
if (UserAngRef) {
|
||||
// Apply Rotation Matrix
|
||||
// x * AngRef1, y * AngRef2 and z * AngRef3
|
||||
finx = (px * AngRef1.x()) + (py * AngRef2.x()) + (pz * AngRef3.x());
|
||||
finy = (px * AngRef1.y()) + (py * AngRef2.y()) + (pz * AngRef3.y());
|
||||
finz = (px * AngRef1.z()) + (py * AngRef2.z()) + (pz * AngRef3.z());
|
||||
} else { // use mother co-ordinates
|
||||
finx = px;
|
||||
finy = py;
|
||||
finz = pz;
|
||||
}
|
||||
G4double ResMag = sqrt((finx*finx) + (finy*finy) + (finz*finz));
|
||||
finx = finx/ResMag;
|
||||
finy = finy/ResMag;
|
||||
finz = finz/ResMag;
|
||||
|
||||
particle_momentum_direction.setX(finx);
|
||||
particle_momentum_direction.setY(finy);
|
||||
particle_momentum_direction.setZ(finz);
|
||||
}
|
||||
else if(UserWRTSurface == true)
|
||||
{
|
||||
@@ -1323,7 +1591,7 @@ void G4GeneralParticleSource::GenerateUserDefFlux()
|
||||
particle_momentum_direction.setY(resulty);
|
||||
particle_momentum_direction.setZ(resultz);
|
||||
}
|
||||
|
||||
|
||||
// particle_momentum_direction now contains unit momentum vector.
|
||||
if(verbosityLevel >= 1)
|
||||
{
|
||||
@@ -1427,6 +1695,17 @@ G4double G4GeneralParticleSource::GenerateUserDefPhi()
|
||||
void G4GeneralParticleSource::SetEnergyDisType(G4String DisType)
|
||||
{
|
||||
EnergyDisType = DisType;
|
||||
if (EnergyDisType == "User"){
|
||||
UDefEnergyH = IPDFEnergyH = ZeroPhysVector ;
|
||||
IPDFEnergyExist = false ;
|
||||
} else if ( EnergyDisType == "Arb"){
|
||||
ArbEnergyH =IPDFArbEnergyH = ZeroPhysVector ;
|
||||
IPDFArbExist = false;
|
||||
} else if (EnergyDisType == "Epn"){
|
||||
UDefEnergyH = IPDFEnergyH = ZeroPhysVector ;
|
||||
IPDFEnergyExist = false ;
|
||||
EpnEnergyH = ZeroPhysVector ;
|
||||
}
|
||||
}
|
||||
|
||||
void G4GeneralParticleSource::SetEmin(G4double emi)
|
||||
@@ -1446,6 +1725,10 @@ void G4GeneralParticleSource::SetMonoEnergy(G4double menergy)
|
||||
Emax = menergy;
|
||||
}
|
||||
|
||||
void G4GeneralParticleSource::SetBeamSigmaInE(G4double e)
|
||||
{
|
||||
SE = e;
|
||||
}
|
||||
void G4GeneralParticleSource::SetAlpha(G4double alp)
|
||||
{
|
||||
alpha = alp;
|
||||
@@ -1496,7 +1779,7 @@ void G4GeneralParticleSource::ArbEnergyHisto(G4ThreeVector input)
|
||||
|
||||
void G4GeneralParticleSource::EpnEnergyHisto(G4ThreeVector input)
|
||||
{
|
||||
G4double elo, ehi, val;
|
||||
G4double ehi, val;
|
||||
ehi = input.x();
|
||||
val = input.y();
|
||||
if(verbosityLevel == 2)
|
||||
@@ -1625,7 +1908,7 @@ void G4GeneralParticleSource::ArbInterpolate(G4String IType)
|
||||
if(EnergyDisType != "Arb")
|
||||
G4cout << "Error: this is for arbitrary distributions" << G4endl;
|
||||
IntType = IType;
|
||||
G4int i=0;
|
||||
|
||||
|
||||
// Calcuate Emin and Emax, mainly for use in debugging
|
||||
G4int len = G4int(ArbEnergyH.GetVectorLength());
|
||||
@@ -2099,9 +2382,16 @@ void G4GeneralParticleSource::GenerateMonoEnergetic()
|
||||
particle_energy = MonoEnergy;
|
||||
}
|
||||
|
||||
void G4GeneralParticleSource::GenerateGaussEnergies()
|
||||
{
|
||||
// Method to generate Gaussian particles.
|
||||
particle_energy = G4RandGauss::shoot(MonoEnergy,SE);
|
||||
if (particle_energy < 0) particle_energy = 0.;
|
||||
}
|
||||
|
||||
void G4GeneralParticleSource::GenerateLinearEnergies()
|
||||
{
|
||||
G4double energy, rndm;
|
||||
G4double rndm;
|
||||
G4double emaxsq = pow(Emax,2.); //Emax squared
|
||||
G4double eminsq = pow(Emin,2.); //Emin squared
|
||||
G4double intersq = pow(cept,2.); //cept squared
|
||||
@@ -2337,6 +2627,7 @@ void G4GeneralParticleSource::GenUserHistEnergies()
|
||||
G4int ii;
|
||||
G4int maxbin = G4int(UDefEnergyH.GetVectorLength());
|
||||
G4double bins[256], vals[256], sum;
|
||||
sum=0.;
|
||||
// UDefEnergyH.DumpValues();
|
||||
G4double mass = particle_definition->GetPDGMass();
|
||||
// G4cout << mass << G4endl;
|
||||
@@ -2631,6 +2922,56 @@ void G4GeneralParticleSource::SetEnergyBias(G4ThreeVector input)
|
||||
EnergyBias = true;
|
||||
}
|
||||
|
||||
|
||||
void G4GeneralParticleSource::ReSetHist(G4String atype)
|
||||
{
|
||||
if (atype == "theta") {
|
||||
UDefThetaH = IPDFThetaH = ZeroPhysVector ;
|
||||
IPDFThetaExist = false ;}
|
||||
else if (atype == "phi"){
|
||||
UDefPhiH = IPDFPhiH = ZeroPhysVector ;
|
||||
IPDFPhiExist = false ;}
|
||||
else if (atype == "energy"){
|
||||
UDefEnergyH = IPDFEnergyH = ZeroPhysVector ;
|
||||
IPDFEnergyExist = false ;}
|
||||
else if ( atype == "arb"){
|
||||
ArbEnergyH =IPDFArbEnergyH = ZeroPhysVector ;
|
||||
IPDFArbExist = false;}
|
||||
else if ( atype == "epn"){
|
||||
UDefEnergyH = IPDFEnergyH = ZeroPhysVector ;
|
||||
IPDFEnergyExist = false ;
|
||||
EpnEnergyH = ZeroPhysVector ;}
|
||||
else if ( atype == "biasx") {
|
||||
XBias = false ;
|
||||
IPDFXBias = false;
|
||||
XBiasH = IPDFXBiasH = ZeroPhysVector ;}
|
||||
else if ( atype == "biasy") {
|
||||
YBias = false ;
|
||||
IPDFYBias = false;
|
||||
YBiasH = IPDFYBiasH = ZeroPhysVector ;}
|
||||
else if ( atype == "biasz") {
|
||||
ZBias = false ;
|
||||
IPDFZBias = false;
|
||||
ZBiasH = IPDFZBiasH = ZeroPhysVector ;}
|
||||
else if ( atype == "biast") {
|
||||
ThetaBias = false ;
|
||||
IPDFThetaBias = false;
|
||||
ThetaBiasH = IPDFThetaBiasH = ZeroPhysVector ;}
|
||||
else if ( atype == "biasp") {
|
||||
PhiBias = false ;
|
||||
IPDFPhiBias = false;
|
||||
PhiBiasH = IPDFPhiBiasH = ZeroPhysVector ;}
|
||||
else if ( atype == "biase") {
|
||||
EnergyBias = false ;
|
||||
IPDFEnergyBias = false;
|
||||
EnergyBiasH = IPDFEnergyBiasH = ZeroPhysVector ;}
|
||||
else {
|
||||
G4cout << "Error, histtype not accepted " << G4endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
G4double G4GeneralParticleSource::GenRandX()
|
||||
{
|
||||
if(verbosityLevel >= 1)
|
||||
@@ -3055,6 +3396,8 @@ void G4GeneralParticleSource::GeneratePrimaryVertex(G4Event *evt)
|
||||
{
|
||||
if(SourcePosType == "Point")
|
||||
GeneratePointSource();
|
||||
else if(SourcePosType == "Beam")
|
||||
GeneratePointsInBeam();
|
||||
else if(SourcePosType == "Plane")
|
||||
GeneratePointsInPlane();
|
||||
else if(SourcePosType == "Surface")
|
||||
@@ -3096,6 +3439,10 @@ void G4GeneralParticleSource::GeneratePrimaryVertex(G4Event *evt)
|
||||
GenerateIsotropicFlux();
|
||||
else if(AngDistType == "cos")
|
||||
GenerateCosineLawFlux();
|
||||
else if(AngDistType == "planar")
|
||||
GeneratePlanarFlux();
|
||||
else if(AngDistType == "beam1d" || AngDistType == "beam2d" )
|
||||
GenerateBeamFlux();
|
||||
else if(AngDistType == "user")
|
||||
GenerateUserDefFlux();
|
||||
else
|
||||
@@ -3109,6 +3456,8 @@ void G4GeneralParticleSource::GeneratePrimaryVertex(G4Event *evt)
|
||||
GeneratePowEnergies();
|
||||
else if(EnergyDisType == "Exp")
|
||||
GenerateExpEnergies();
|
||||
else if(EnergyDisType == "Gauss")
|
||||
GenerateGaussEnergies();
|
||||
else if(EnergyDisType == "Brem")
|
||||
GenerateBremEnergies();
|
||||
else if(EnergyDisType == "Bbody")
|
||||
@@ -3138,6 +3487,13 @@ void G4GeneralParticleSource::GeneratePrimaryVertex(G4Event *evt)
|
||||
G4double py = pmom*particle_momentum_direction.y();
|
||||
G4double pz = pmom*particle_momentum_direction.z();
|
||||
|
||||
if(verbosityLevel > 1){
|
||||
G4cout << "Particle name: "<<particle_definition->GetParticleName() << G4endl;
|
||||
G4cout << " Energy: "<<particle_energy << G4endl;
|
||||
G4cout << " Position: "<<particle_position<< G4endl;
|
||||
G4cout << " Direction: "<<particle_momentum_direction << G4endl;
|
||||
G4cout << " NumberOfParticlesToBeGenerated: "<<NumberOfParticlesToBeGenerated << G4endl;
|
||||
}
|
||||
for( G4int i=0; i<NumberOfParticlesToBeGenerated; i++ )
|
||||
{
|
||||
G4PrimaryParticle* particle =
|
||||
@@ -3150,19 +3506,25 @@ void G4GeneralParticleSource::GeneratePrimaryVertex(G4Event *evt)
|
||||
vertex->SetPrimary( particle );
|
||||
|
||||
// Set bweight equal to the multiple of all non-zero weights
|
||||
bweight = 0.;
|
||||
bweight = 1.;
|
||||
for(int bib=0; bib<6; bib++)
|
||||
{
|
||||
if(bweights[bib] > 0. && bweight == 0.)
|
||||
bweight = bweight + bweights[bib];
|
||||
else if(bweights[bib] > 0.)
|
||||
bweight = bweight * bweights[bib];
|
||||
if(bweights[bib] > 0.) bweight = bweight * bweights[bib];
|
||||
}
|
||||
// bweight will now contain the events final weighting.
|
||||
// now pass it to the primary vertex
|
||||
vertex->SetWeight(bweight);
|
||||
}
|
||||
|
||||
evt->AddPrimaryVertex( vertex );
|
||||
if(verbosityLevel > 1)
|
||||
G4cout << " Primary Vetex generated !"<< G4endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user