Import Geant4 10.7.0.beta source tree
This commit is contained in:
@@ -23,10 +23,11 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4ParticleGun class implementation
|
||||
//
|
||||
//
|
||||
// Author: Makoto Asai, 1997
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
// G4ParticleGun
|
||||
#include "G4ParticleGun.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4PrimaryParticle.hh"
|
||||
@@ -45,8 +46,8 @@ G4ParticleGun::G4ParticleGun(G4int numberofparticles)
|
||||
NumberOfParticlesToBeGenerated = numberofparticles;
|
||||
}
|
||||
|
||||
G4ParticleGun::G4ParticleGun
|
||||
(G4ParticleDefinition * particleDef, G4int numberofparticles)
|
||||
G4ParticleGun::G4ParticleGun(G4ParticleDefinition* particleDef,
|
||||
G4int numberofparticles)
|
||||
{
|
||||
SetInitialValues();
|
||||
NumberOfParticlesToBeGenerated = numberofparticles;
|
||||
@@ -73,48 +74,25 @@ G4ParticleGun::~G4ParticleGun()
|
||||
delete theMessenger;
|
||||
}
|
||||
|
||||
//G4ParticleGun::G4ParticleGun(const G4ParticleGun& /*right*/)
|
||||
//:G4VPrimaryGenerator()
|
||||
//{ G4Exception(
|
||||
// "G4ParticleGun::G4ParticleGun","Event0191",FatalException,
|
||||
// "G4ParticleGun : Copy constructor should not be used."); }
|
||||
//
|
||||
//const G4ParticleGun& G4ParticleGun::operator=(const G4ParticleGun& right)
|
||||
//{ G4Exception(
|
||||
// "G4ParticleGun::operator=","Event0192",FatalException,
|
||||
// "G4ParticleGun : Equal operator should not be used.");
|
||||
// return right; }
|
||||
//
|
||||
//G4bool G4ParticleGun::operator==(const G4ParticleGun& /*right*/) const
|
||||
//{ G4Exception(
|
||||
// "G4ParticleGun::operator==","Event0193",FatalException,
|
||||
// "G4ParticleGun : == operator should not be used.");
|
||||
// return true; }
|
||||
//
|
||||
//G4bool G4ParticleGun::operator!=(const G4ParticleGun& /*right*/) const
|
||||
//{ G4Exception(
|
||||
// "G4ParticleGun::operator!=","Event0193",FatalException,
|
||||
// "G4ParticleGun : != operator should not be used.");
|
||||
// return false; }
|
||||
|
||||
void G4ParticleGun::SetParticleDefinition
|
||||
(G4ParticleDefinition * aParticleDefinition)
|
||||
void G4ParticleGun::
|
||||
SetParticleDefinition(G4ParticleDefinition* aParticleDefinition)
|
||||
{
|
||||
if(!aParticleDefinition)
|
||||
if(aParticleDefinition == nullptr)
|
||||
{
|
||||
G4Exception("G4ParticleGun::SetParticleDefinition()","Event0101",
|
||||
FatalException,"Null pointer is given.");
|
||||
G4Exception("G4ParticleGun::SetParticleDefinition()", "Event0101",
|
||||
FatalException, "Null pointer is given.");
|
||||
}
|
||||
if(aParticleDefinition->IsShortLived())
|
||||
{
|
||||
if(!(aParticleDefinition->GetDecayTable()))
|
||||
if(aParticleDefinition->GetDecayTable() == nullptr)
|
||||
{
|
||||
G4ExceptionDescription ED;
|
||||
ED << "G4ParticleGun does not support shooting a short-lived particle without a valid decay table." << G4endl;
|
||||
ED << "G4ParticleGun does not support shooting a short-lived "
|
||||
<< "particle without a valid decay table." << G4endl;
|
||||
ED << "G4ParticleGun::SetParticleDefinition for "
|
||||
<< aParticleDefinition->GetParticleName() << " is ignored." << G4endl;
|
||||
G4Exception("G4ParticleGun::SetParticleDefinition()","Event0102",
|
||||
JustWarning,ED);
|
||||
G4Exception("G4ParticleGun::SetParticleDefinition()", "Event0102",
|
||||
JustWarning, ED);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -122,20 +100,24 @@ void G4ParticleGun::SetParticleDefinition
|
||||
particle_charge = particle_definition->GetPDGCharge();
|
||||
if(particle_momentum>0.0)
|
||||
{
|
||||
G4double mass = particle_definition->GetPDGMass();
|
||||
G4double mass = particle_definition->GetPDGMass();
|
||||
particle_energy =
|
||||
std::sqrt(particle_momentum*particle_momentum+mass*mass)-mass;
|
||||
std::sqrt(particle_momentum*particle_momentum+mass*mass)-mass;
|
||||
}
|
||||
}
|
||||
|
||||
void G4ParticleGun::SetParticleEnergy(G4double aKineticEnergy)
|
||||
{
|
||||
particle_energy = aKineticEnergy;
|
||||
if(particle_momentum>0.0){
|
||||
if(particle_definition){
|
||||
if(particle_momentum>0.0)
|
||||
{
|
||||
if(particle_definition != nullptr)
|
||||
{
|
||||
G4cout << "G4ParticleGun::" << particle_definition->GetParticleName()
|
||||
<< G4endl;
|
||||
}else{
|
||||
}
|
||||
else
|
||||
{
|
||||
G4cout << "G4ParticleGun::" << " " << G4endl;
|
||||
}
|
||||
G4cout << " was defined in terms of Momentum: "
|
||||
@@ -148,11 +130,15 @@ void G4ParticleGun::SetParticleEnergy(G4double aKineticEnergy)
|
||||
|
||||
void G4ParticleGun::SetParticleMomentum(G4double aMomentum)
|
||||
{
|
||||
if(particle_energy>0.0){
|
||||
if(particle_definition){
|
||||
if(particle_energy>0.0)
|
||||
{
|
||||
if(particle_definition != nullptr)
|
||||
{
|
||||
G4cout << "G4ParticleGun::" << particle_definition->GetParticleName()
|
||||
<< G4endl;
|
||||
}else{
|
||||
}
|
||||
else
|
||||
{
|
||||
G4cout << "G4ParticleGun::" << " " << G4endl;
|
||||
}
|
||||
G4cout << " was defined in terms of KineticEnergy: "
|
||||
@@ -160,29 +146,34 @@ void G4ParticleGun::SetParticleMomentum(G4double aMomentum)
|
||||
G4cout << " is now defined in terms Momentum: "
|
||||
<< aMomentum/GeV << "GeV/c" << G4endl;
|
||||
}
|
||||
if(!particle_definition)
|
||||
if(particle_definition == nullptr)
|
||||
{
|
||||
G4cout <<"Particle Definition not defined yet for G4ParticleGun"<< G4endl;
|
||||
G4cout <<"Zero Mass is assumed"<<G4endl;
|
||||
G4cout << "Particle Definition not defined yet for G4ParticleGun"
|
||||
<< G4endl;
|
||||
G4cout << "Zero Mass is assumed" << G4endl;
|
||||
particle_momentum = aMomentum;
|
||||
particle_energy = aMomentum;
|
||||
}
|
||||
else
|
||||
{
|
||||
G4double mass = particle_definition->GetPDGMass();
|
||||
G4double mass = particle_definition->GetPDGMass();
|
||||
particle_momentum = aMomentum;
|
||||
particle_energy =
|
||||
std::sqrt(particle_momentum*particle_momentum+mass*mass)-mass;
|
||||
std::sqrt(particle_momentum*particle_momentum+mass*mass)-mass;
|
||||
}
|
||||
}
|
||||
|
||||
void G4ParticleGun::SetParticleMomentum(G4ParticleMomentum aMomentum)
|
||||
{
|
||||
if(particle_energy>0.0){
|
||||
if(particle_definition){
|
||||
if(particle_energy>0.0)
|
||||
{
|
||||
if(particle_definition != nullptr)
|
||||
{
|
||||
G4cout << "G4ParticleGun::" << particle_definition->GetParticleName()
|
||||
<< G4endl;
|
||||
}else{
|
||||
}
|
||||
else
|
||||
{
|
||||
G4cout << "G4ParticleGun::" << " " << G4endl;
|
||||
}
|
||||
G4cout << " was defined in terms of KineticEnergy: "
|
||||
@@ -190,11 +181,12 @@ void G4ParticleGun::SetParticleMomentum(G4ParticleMomentum aMomentum)
|
||||
G4cout << " is now defined in terms Momentum: "
|
||||
<< aMomentum.mag()/GeV << "GeV/c" << G4endl;
|
||||
}
|
||||
if(!particle_definition)
|
||||
if(particle_definition == nullptr)
|
||||
{
|
||||
G4cout <<"Particle Definition not defined yet for G4ParticleGun"<< G4endl;
|
||||
G4cout <<"Zero Mass is assumed"<<G4endl;
|
||||
particle_momentum_direction = aMomentum.unit();
|
||||
G4cout << "Particle Definition not defined yet for G4ParticleGun"
|
||||
<< G4endl;
|
||||
G4cout << "Zero Mass is assumed" << G4endl;
|
||||
particle_momentum_direction = aMomentum.unit();
|
||||
particle_momentum = aMomentum.mag();
|
||||
particle_energy = aMomentum.mag();
|
||||
}
|
||||
@@ -202,31 +194,35 @@ void G4ParticleGun::SetParticleMomentum(G4ParticleMomentum aMomentum)
|
||||
{
|
||||
G4double mass = particle_definition->GetPDGMass();
|
||||
particle_momentum = aMomentum.mag();
|
||||
particle_momentum_direction = aMomentum.unit();
|
||||
particle_momentum_direction = aMomentum.unit();
|
||||
particle_energy =
|
||||
std::sqrt(particle_momentum*particle_momentum+mass*mass)-mass;
|
||||
std::sqrt(particle_momentum*particle_momentum+mass*mass)-mass;
|
||||
}
|
||||
}
|
||||
|
||||
void G4ParticleGun::GeneratePrimaryVertex(G4Event* evt)
|
||||
{
|
||||
if(!particle_definition)
|
||||
if(particle_definition == nullptr)
|
||||
{
|
||||
G4ExceptionDescription ED;
|
||||
ED << "Particle definition is not defined." << G4endl;
|
||||
ED << "G4ParticleGun::SetParticleDefinition() has to be invoked beforehand." << G4endl;
|
||||
G4Exception("G4ParticleGun::GeneratePrimaryVertex()","Event0109",
|
||||
FatalException, ED);
|
||||
ED << "G4ParticleGun::SetParticleDefinition() has to be invoked beforehand."
|
||||
<< G4endl;
|
||||
G4Exception("G4ParticleGun::GeneratePrimaryVertex()", "Event0109",
|
||||
FatalException, ED);
|
||||
return;
|
||||
}
|
||||
|
||||
// create a new vertex
|
||||
// Create a new vertex
|
||||
//
|
||||
G4PrimaryVertex* vertex =
|
||||
new G4PrimaryVertex(particle_position,particle_time);
|
||||
|
||||
// create new primaries and set them to the vertex
|
||||
// Create new primaries and set them to the vertex
|
||||
//
|
||||
G4double mass = particle_definition->GetPDGMass();
|
||||
for( G4int i=0; i<NumberOfParticlesToBeGenerated; i++ ){
|
||||
for( G4int i=0; i<NumberOfParticlesToBeGenerated; ++i )
|
||||
{
|
||||
G4PrimaryParticle* particle =
|
||||
new G4PrimaryParticle(particle_definition);
|
||||
particle->SetKineticEnergy( particle_energy );
|
||||
@@ -234,12 +230,9 @@ void G4ParticleGun::GeneratePrimaryVertex(G4Event* evt)
|
||||
particle->SetMomentumDirection( particle_momentum_direction );
|
||||
particle->SetCharge( particle_charge );
|
||||
particle->SetPolarization(particle_polarization.x(),
|
||||
particle_polarization.y(),
|
||||
particle_polarization.z());
|
||||
particle_polarization.y(),
|
||||
particle_polarization.z());
|
||||
vertex->SetPrimary( particle );
|
||||
}
|
||||
|
||||
evt->AddPrimaryVertex( vertex );
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user