Import Geant4 7.0.0 source tree
This commit is contained in:
@@ -107,49 +107,53 @@ void G4SingleParticleSource::GeneratePrimaryVertex(G4Event *evt)
|
||||
{
|
||||
if(particle_definition==NULL) return;
|
||||
|
||||
if(verbosityLevel > 1)
|
||||
G4cout << " NumberOfParticlesToBeGenerated: "<<NumberOfParticlesToBeGenerated << G4endl;
|
||||
|
||||
// Position stuff
|
||||
particle_position = posGenerator->GenerateOne();
|
||||
// Angular stuff
|
||||
particle_momentum_direction = angGenerator->GenerateOne();
|
||||
// Energy stuff
|
||||
particle_energy = eneGenerator->GenerateOne(particle_definition);
|
||||
|
||||
// create a new vertex
|
||||
G4PrimaryVertex* vertex = new G4PrimaryVertex(particle_position,particle_time);
|
||||
|
||||
if(verbosityLevel >= 2)
|
||||
G4cout << "Creating primaries and assigning to vertex" << G4endl;
|
||||
// create new primaries and set them to the vertex
|
||||
G4double mass = particle_definition->GetPDGMass();
|
||||
G4double energy = particle_energy + mass;
|
||||
G4double pmom = sqrt(energy*energy-mass*mass);
|
||||
G4double px = pmom*particle_momentum_direction.x();
|
||||
G4double py = pmom*particle_momentum_direction.y();
|
||||
G4double pz = pmom*particle_momentum_direction.z();
|
||||
for( G4int i=0; i<NumberOfParticlesToBeGenerated; i++ ) {
|
||||
// Angular stuff
|
||||
particle_momentum_direction = angGenerator->GenerateOne();
|
||||
// Energy stuff
|
||||
particle_energy = eneGenerator->GenerateOne(particle_definition);
|
||||
|
||||
if(verbosityLevel >= 2)
|
||||
G4cout << "Creating primaries and assigning to vertex" << G4endl;
|
||||
// create new primaries and set them to the vertex
|
||||
G4double mass = particle_definition->GetPDGMass();
|
||||
G4double energy = particle_energy + mass;
|
||||
G4double pmom = std::sqrt(energy*energy-mass*mass);
|
||||
G4double px = pmom*particle_momentum_direction.x();
|
||||
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 =
|
||||
new G4PrimaryParticle(particle_definition,px,py,pz);
|
||||
particle->SetMass( mass );
|
||||
particle->SetCharge( particle_charge );
|
||||
particle->SetPolarization(particle_polarization.x(),
|
||||
particle_polarization.y(),
|
||||
particle_polarization.z());
|
||||
vertex->SetPrimary( particle );
|
||||
|
||||
// Set bweight equal to the multiple of all non-zero weights
|
||||
particle_weight = biasRndm->GetBiasWeight();
|
||||
// now pass it to the primary vertex
|
||||
vertex->SetWeight(particle_weight);
|
||||
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;
|
||||
}
|
||||
G4PrimaryParticle* particle =
|
||||
new G4PrimaryParticle(particle_definition,px,py,pz);
|
||||
particle->SetMass( mass );
|
||||
particle->SetCharge( particle_charge );
|
||||
particle->SetPolarization(particle_polarization.x(),
|
||||
particle_polarization.y(),
|
||||
particle_polarization.z());
|
||||
vertex->SetPrimary( particle );
|
||||
|
||||
// Set bweight equal to the multiple of all non-zero weights
|
||||
particle_weight = biasRndm->GetBiasWeight();
|
||||
// pass it to primary particle
|
||||
particle->SetWeight(particle_weight);
|
||||
}
|
||||
// now pass the weight to the primary vertex
|
||||
vertex->SetWeight(particle_weight);
|
||||
evt->AddPrimaryVertex( vertex );
|
||||
if(verbosityLevel > 1)
|
||||
G4cout << " Primary Vetex generated !"<< G4endl;
|
||||
|
||||
Reference in New Issue
Block a user