Message: optical photon beam Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Question optical photon beam 

Forum: Particles
Date: 22 Feb, 2012
From: Antonio <Antonio>

Hello, I would like to simulate an optical photon beam. I am using G4ParticleGun and there are no problem in compilation. But when running G4 crashes

-------- EEEE ------- G4Exception-START -------- EEEE -------
*** G4Exception : Event0101
      issued by : G4ParticleGun::SetParticleDefinition()
Null pointer is given.
*** Fatal Exception *** core dump ***
-------- EEEE -------- G4Exception-END --------- EEEE -------

*** G4Exception: Aborting execution *** Abort trap: 6

Could someone provide some help?

Many thanks

Cheers, Antonio

p.s: mi generatoraction is here:

#include "PrimaryGeneratorAction.hh"
#include "PrimaryGeneratorMessenger.hh"

#include "G4Event.hh"
#include "G4ParticleGun.hh"
#include "G4ParticleTable.hh"
#include "G4ParticleDefinition.hh"

PrimaryGeneratorAction::PrimaryGeneratorAction()
{
  momentum = ((1239.84/450)*1E-9)*GeV; //for optical photons

  G4int n_particle = 1;
  particleGun  = new G4ParticleGun(n_particle);

  //create a messenger for this class
  gunMessenger = new PrimaryGeneratorMessenger(this);

  G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
  G4String particleName;
  optical = particleTable->FindParticle(particleName="OpticalPhoton");

  // default particle kinematics
  particleGun->SetParticleDefinition(optical);

}

PrimaryGeneratorAction::~PrimaryGeneratorAction()
{
  delete particleGun;
  delete gunMessenger;
}

void PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
{
  G4ParticleDefinition* particle;
  particle = particleGun->GetParticleDefinition();

  G4double pp = momentum;
  G4double mass = particle->GetPDGMass();
  G4double Ekin = std::sqrt(pp*pp+mass*mass)-mass;
  particleGun->SetParticleEnergy(Ekin);

  particleGun->SetParticleMomentumDirection(G4ThreeVector(1.,1.,0.));

  G4double xxx = -5.;
  G4double yyy = 0.; 
  G4double zzz = 0.;
  particleGun->SetParticlePosition(G4ThreeVector(xxx*cm,yyy*cm,zzz*cm));

  particleGun->GeneratePrimaryVertex(anEvent);
}

 Add Message Add Message
to: "optical photon beam"

 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 ]