I have a detector to get the gamma spectrum from a Cs-137 (662 KeV) point source. But, now I have to change my point source into a line source (at least 2 cm long line source)?
I have attached my generator.cc code, is it correct? does my code will simulate 20 Cs-137 with 2 mm separations?
MyPrimaryGenerator::MyPrimaryGenerator()
{
fParticleGun = new G4ParticleGun(1);
}
MyPrimaryGenerator::~MyPrimaryGenerator()
{
delete fParticleGun;
}
void MyPrimaryGenerator::GeneratePrimaries(G4Event *anEvent)
{
G4int Z = 55;
G4int A = 137;
G4double charge = 0.*eplus;
G4double energy = 0.662*MeV;
G4ParticleDefinition* particle;
G4ParticleDefinition* ion = G4IonTable::GetIonTable()->GetIon(Z,A,energy);
G4double x0 = 0.0*mm;
G4double x1 = 2.0*mm;
G4double x = x0 + (x1-x0)*G4UniformRand()*20;
G4ThreeVector pos(0., 0., x);
G4ThreeVector mom(0., 0., 1.);
fParticleGun->SetParticlePosition(pos);
fParticleGun->SetParticleDefinition(ion);
fParticleGun->SetParticleCharge(charge);
fParticleGun->GeneratePrimaryVertex(anEvent);
}