Import Geant4 5.1.0 source tree
This commit is contained in:
@@ -21,45 +21,79 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: ExN06PrimaryGeneratorAction.cc,v 1.2 2003/01/23 15:34:32 maire Exp $
|
||||
// GEANT4 tag $Name: geant4-05-01 $
|
||||
//
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#include "ExN06PrimaryGeneratorAction.hh"
|
||||
#include "ExN06PrimaryGeneratorMessenger.hh"
|
||||
|
||||
#include "globals.hh"
|
||||
#include "G4Event.hh"
|
||||
#include "G4ParticleGun.hh"
|
||||
#include "G4ParticleTable.hh"
|
||||
#include "G4ParticleDefinition.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
ExN06PrimaryGeneratorAction::ExN06PrimaryGeneratorAction()
|
||||
{
|
||||
G4int n_particle = 1;
|
||||
particleGun = new G4ParticleGun(n_particle);
|
||||
|
||||
//create a messenger for this class
|
||||
gunMessenger = new ExN06PrimaryGeneratorMessenger(this);
|
||||
|
||||
//default kinematic
|
||||
//
|
||||
G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
|
||||
G4ParticleDefinition* particle = particleTable->FindParticle("e-");
|
||||
|
||||
particleGun->SetParticleDefinition(particle);
|
||||
particleGun->SetParticleTime(0.0*ns);
|
||||
particleGun->SetParticlePosition(G4ThreeVector(0.0*cm,0.0*cm,0.0*cm));
|
||||
particleGun->SetParticleMomentumDirection(G4ThreeVector(1.,0.,0.));
|
||||
particleGun->SetParticleEnergy(500.0*keV);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
ExN06PrimaryGeneratorAction::~ExN06PrimaryGeneratorAction()
|
||||
{
|
||||
delete particleGun;
|
||||
delete gunMessenger;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void ExN06PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
|
||||
{
|
||||
G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
|
||||
G4String particleName;
|
||||
G4ParticleDefinition* particle
|
||||
= particleTable->FindParticle(particleName="e+");
|
||||
|
||||
particleGun->SetParticleDefinition(particle);
|
||||
particleGun->SetParticleTime(0.0*ns);
|
||||
|
||||
G4ThreeVector position(0.0*cm,0.0*cm,0.0*cm);
|
||||
particleGun->SetParticlePosition(position);
|
||||
|
||||
G4ThreeVector direction(1.0,0.0,0.0);
|
||||
particleGun->SetParticleMomentumDirection(direction.unit());
|
||||
|
||||
G4double energy = 10.0*MeV;
|
||||
particleGun->SetParticleEnergy(energy);
|
||||
|
||||
particleGun->GeneratePrimaryVertex(anEvent);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void ExN06PrimaryGeneratorAction::SetOptPhotonPolar(G4double angle)
|
||||
{
|
||||
if (particleGun->GetParticleDefinition()->GetParticleName() != "opticalphoton")
|
||||
{
|
||||
G4cout << "--> warning from PrimaryGeneratorAction::SetOptPhotonPolar() :"
|
||||
"the particleGun is not an opticalphoton" << G4endl;
|
||||
return;
|
||||
}
|
||||
|
||||
G4ThreeVector normal (1., 0., 0.);
|
||||
G4ThreeVector kphoton = particleGun->GetParticleMomentumDirection();
|
||||
G4ThreeVector product = normal.cross(kphoton);
|
||||
G4double modul2 = product*product;
|
||||
|
||||
G4ThreeVector e_perpend (0., 0., 1.);
|
||||
if (modul2 > 0.) e_perpend = (1./sqrt(modul2))*product;
|
||||
G4ThreeVector e_paralle = e_perpend.cross(kphoton);
|
||||
|
||||
G4ThreeVector polar = cos(angle)*e_paralle + sin(angle)*e_perpend;
|
||||
particleGun->SetParticlePolarization(polar);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
Reference in New Issue
Block a user