70 NumberOfParticlesToBeGenerated = 1;
71 particle_definition = NULL;
74 particle_energy = 1.0*
MeV;
75 particle_position = zero;
77 particle_polarization = zero;
78 particle_charge = 0.0;
80 SourcePosType =
"Volume";
94 EnergyDisType =
"Mono";
111 SourcePosType = PosType;
121 CentreCoords = coordsOfCentre;
142 G4String theRequiredVolumeName = VolName;
146 if(verbosityLevel == 2)
G4cout << PVStore->size() <<
G4endl;
149 while (!found && i<(
G4int)PVStore->size())
151 tempPV = (*PVStore)[i];
152 found = tempPV->
GetName() == theRequiredVolumeName;
153 if(verbosityLevel == 2)
155 <<
" " << theRequiredVolumeName <<
" " << found <<
G4endl;
162 if(verbosityLevel >= 1)
166 else if(VolName==
"NULL")
169 G4cout <<
" **** Error: Volume does not exist **** " <<
G4endl;
187 if(SourcePosType ==
"Point")
188 particle_position = CentreCoords;
190 if(verbosityLevel >= 1)
191 G4cout <<
"Error SourcePosType is not set to Point" <<
G4endl;
200 if(SourcePosType !=
"Volume" && verbosityLevel >= 1)
203 if(Shape ==
"Sphere") {
207 while(((x*x)+(
y*
y)+(
z*
z)) > (Radius*Radius)) {
212 x = (x*2.*Radius) - Radius;
213 y = (y*2.*Radius) - Radius;
214 z = (z*2.*Radius) - Radius;
218 else if(Shape ==
"Cylinder") {
221 while(((x*x)+(
y*
y)) > (Radius*Radius)) {
225 x = (x*2.*Radius) - Radius;
226 y = (
y*2.*Radius) - Radius;
227 z = (
z*2.*halfz) - halfz;
232 G4cout <<
"Error: Volume Shape Does Not Exist" <<
G4endl;
237 particle_position = CentreCoords + RandPos;
256 if(theVolName == VolName) {
257 if(verbosityLevel >= 1)
258 G4cout <<
"Particle is in volume " << VolName <<
G4endl;
269 particle_momentum_direction = aDirection.
unit();
279 G4double sintheta, sinphi, costheta, cosphi;
281 costheta = std::cos(MinTheta) - rndm * (std::cos(MinTheta) - std::cos(MaxTheta));
282 sintheta = std::sqrt(1. - costheta*costheta);
285 Phi = MinPhi + (MaxPhi - MinPhi) * rndm2;
286 sinphi = std::sin(Phi);
287 cosphi = std::cos(Phi);
289 px = -sintheta * cosphi;
290 py = -sintheta * sinphi;
293 G4double ResMag = std::sqrt((px*px) + (py*py) + (pz*pz));
298 particle_momentum_direction.
setX(px);
299 particle_momentum_direction.
setY(py);
300 particle_momentum_direction.
setZ(pz);
303 if(verbosityLevel >= 2)
304 G4cout <<
"Generating isotropic vector: " << particle_momentum_direction <<
G4endl;
310 EnergyDisType = DisType;
315 MonoEnergy = menergy;
320 particle_energy = MonoEnergy;
327 G4cout <<
"Verbosity Set to: " << verbosityLevel <<
G4endl;
333 particle_definition = aParticleDefinition;
341 if(particle_definition==NULL) {
350 while(srcconf ==
false) {
351 if(SourcePosType ==
"Point")
353 else if(SourcePosType ==
"Volume")
360 if(Confine ==
true) {
365 else if(Confine ==
false)
369 if(LoopCount == 100000) {
370 G4cout <<
"*************************************" <<
G4endl;
372 G4cout <<
"Either the source distribution >> confinement" <<
G4endl;
373 G4cout <<
"or any confining volume may not overlap with" <<
G4endl;
374 G4cout <<
"the source distribution or any confining volumes" <<
G4endl;
376 G4cout <<
"If you have set confine then this will be ignored" <<
G4endl;
378 G4cout <<
"*************************************" <<
G4endl;
384 if(AngDistType ==
"iso")
386 else if(AngDistType ==
"direction")
389 G4cout <<
"Error: AngDistType has unusual value" <<
G4endl;
391 if(EnergyDisType ==
"Mono")
394 G4cout <<
"Error: EnergyDisType has unusual value" <<
G4endl;
400 if(verbosityLevel >= 2)
401 G4cout <<
"Creating primaries and assigning to vertex" <<
G4endl;
405 G4double pmom = std::sqrt(energy*energy-mass*mass);
406 G4double px = pmom*particle_momentum_direction.
x();
407 G4double py = pmom*particle_momentum_direction.
y();
408 G4double pz = pmom*particle_momentum_direction.
z();
410 if(verbosityLevel >= 1){
411 G4cout <<
"Particle name: "
415 G4cout <<
" Direction: "<<particle_momentum_direction <<
G4endl;
416 G4cout <<
" NumberOfParticlesToBeGenerated: "
417 << NumberOfParticlesToBeGenerated <<
G4endl;
421 for(
G4int i=0; i<NumberOfParticlesToBeGenerated; i++ ) {
427 particle_polarization.
y(),
428 particle_polarization.
z());
432 if(verbosityLevel > 1)
void SetCentreCoords(G4ThreeVector)
void SetAngDistType(G4String)
DOUBLE PRECISION function rndm(RDUMMY)
void AddPrimaryVertex(G4PrimaryVertex *aPrimaryVertex)
G4Navigator * GetNavigatorForTracking() const
void GenerateIsotropicFlux()
const G4String & GetParticleName() const
void GeneratePointsInVolume()
void SetParticleMomentumDirection(G4ParticleMomentum)
void GenerateMonoEnergetic()
static G4PhysicalVolumeStore * GetInstance()
void GeneratePrimaryVertex(G4Event *evt)
G4GLOB_DLL std::ostream G4cout
void SetPosDisType(G4String)
const G4String & GetName() const
void SetMass(G4double mas)
void GeneratePointSource()
static G4TransportationManager * GetTransportationManager()
G4double GetPDGMass() const
void SetPosDisShape(G4String)
void SetCharge(G4double chg)
virtual G4VPhysicalVolume * LocateGlobalPointAndSetup(const G4ThreeVector &point, const G4ThreeVector *direction=0, const G4bool pRelativeSearch=true, const G4bool ignoreDirection=true)
void SetPrimary(G4PrimaryParticle *pp)
void SetEnergyDisType(G4String)
G4bool IsSourceConfined()
G4double GetPDGCharge() const
G4ThreeVector G4ParticleMomentum
void SetParticleDefinition(G4ParticleDefinition *aParticleDefinition)
void SetPolarization(const G4ThreeVector &pol)
void ConfineSourceToVolume(G4String)
void SetMonoEnergy(G4double)