Message: particle Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Question particle 

Forum: Event and Track Management
Date: 20 Jul, 2013
From: shayma nader <shayma nader>

please i need to generate positron particle in space to study then position spatial resolution please i use this code in primary generation action

please tell me why when i run geant 4 i obtain a figure not the same to that i obtained by root x,y,z, please i need your help

#include "PSPrimaryGeneratorAction.hh"

#include "PSDetectorConstruction.hh"

#include "G4Event.hh"
#include "G4ParticleGun.hh"
#include "G4ParticleTable.hh"
#include "G4ParticleDefinition.hh"
#include "G4ChargedGeantino.hh"
#include "Randomize.hh"
#include <iostream>
#include <fstream>
using namespace std; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

PSPrimaryGeneratorAction::PSPrimaryGeneratorAction(PSDetectorConstruction* DC)
:Detector(DC)
{
G4int n_particle = 1;
  particleGun  = new G4ParticleGun(n_particle);

  G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
  G4String particleName;
  G4ParticleDefinition* particle
                    = particleTable->FindParticle(particleName="e+");
  particleGun->SetParticleDefinition(particle);
  particleGun->SetParticleEnergy(1.*MeV);
 particleGun->SetParticlePosition(G4ThreeVector(0.0*cm,0.0*cm,-0.0150*cm));   

 }

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

PSPrimaryGeneratorAction::~PSPrimaryGeneratorAction()
{
  delete particleGun;
}

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

void PSPrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
{
  //this function is called at the begining of event
  // 

   G4double Px,Py,Pz, sinTheta, cosTheta;
 G4double Pi = 3.14159;//acos(-1.);

   G4double phi= 2.*Pi* G4UniformRand();
    cosTheta = -1. + 2. * G4UniformRand();
    sinTheta = sqrt(1. - cosTheta * cosTheta);
    Px= sinTheta * cos(phi);
    Py= sinTheta * sin(phi);
    Pz =cosTheta;

particleGun->SetParticleMomentumDirection(G4ThreeVector(Px,Py,Pz)); particleGun->GeneratePrimaryVertex(anEvent);}

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

 Add Message Add Message
to: "particle"

 Subscribe Subscribe

This site runs SLAC HyperNews version 1.11-slac-98, derived from the original HyperNews


[ Geant 4 Home | Geant 4 HyperNews | Search | Request New Forum | Feedback ]