Message: Re: how can I get ,using a data file, that geant4 generates more events? Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

None Re: how can I get ,using a data file, that geant4 generates more events? 

Keywords: how can I get ,using a data file, that geant4 generates more events?
Forum: Run Management
Re: Question how can I get ,using a data file, that geant4 generates more events? (Jose)
Date: 04 May, 2005
From: Makoto Asai <Makoto Asai>

G4VUserPrimaryGeneratorAction class itself is not supporsed to generate primary vertex/particle but it should invoke a G4VPrimaryGenerator class object to let it generate the primary. For your case, given your individual event has only one primary particle, I would suggest you to use G4ParticleGun (a concrete class derived from G4VPrimaryGenerator). For each event, read one line from your input file, set particle type, momentum direction and kinetic energy to ParticleGun, and invoke GeneratePrimaryVertex() method of ParticleGun.

MyPrimaryGeneratorAction::MyPrimaryGeneratorAction()
{
  gun = new G4ParticleGun(1);
  gun->SetParticlePosition(G4ThreeVector("position_of_primary_vertex");
}

MyPrimaryGeneratorAction::GeneratePrimaries(g4Event*evt)
{
  "read_one_line_from_your_file_here"
  "abort_if_end_of_file_is_detected"
  gun->SetParticleDefinition("primary_particle_type");
  gun->SetPrimaryParticleMomentumDirection("momentum_direction");
  gun->SetParticleEnergy("kinetic_energy");
  gun->GeneratePrimaryvertex(evt);
}

Inline Depth:
 1 1
 All All
Outline Depth:
 1 1
 2 2
 All All
Add message: (add)

 Add Message Add Message
to: "Re: how can I get ,using a data file, that geant4 generates more events?"

 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 ]