Message: Generating Primary Events Not Logged In (login)

## Generating Primary Events

Forum: Event and Track Management
Date: 11 Apr, 2007
From: suzanne <snowicki@umich.edu>

 Hello every one, I have a problem to generate Primary events. I would like to generate a gamma ray toward the center of my detector (it is a box) and vary the initial position of the gamma ray. To do this, I use spherical coordinates: x=r*sin(theta)*cos(phi); y=r*sin(theta)*sin(phi); z=r*cos(theta); and vary the theta and phi angles. Here is my program: ```void PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent) { G4int theta, phi, l, n; theta=phi=l=n=0; G4float r = 10.0; // in cm.``` ``` for( n=0; n<3; n++ ) { for( l=0; l<3; l++ ) {``` ` // n = anEvent->GetEventID()% 3;` ``` //G4cout << " an Event " << n << G4endl; theta=60*n; phi=120*l;``` ``` G4int i = anEvent->GetEventID(); G4cout << " an Event " << i << G4endl;``` ` G4cout << " Theta " << theta << " Phi " << phi << G4endl;` ``` particleGun->SetParticlePosition(G4ThreeVector(r*(sin(theta*deg)*cos(phi*deg))*cm, (r*sin(theta*deg)*sin(phi*deg))*cm,(r*cos(theta*deg))*cm)); ``` ``` particleGun->SetParticleMomentumDirection(G4ThreeVector(-(sin(theta*deg)*cos(phi*deg)), -(sin(theta*deg)*sin(phi*deg)),-(cos(theta*deg)))); ``` ``` particleGun->GeneratePrimaryVertex(anEvent); } } }``` Here is what I get: ```an Event 1 Theta 0 Phi 0 an Event 1 Theta 0 Phi 120 an Event 1 Theta 0 Phi 240 an Event 1 Theta 60 Phi 0 an Event 1 Theta 60 Phi 120 an Event 1 Theta 60 Phi 240 an Event 1 Theta 120 Phi 0 an Event 1 Theta 120 Phi 120 an Event 1 Theta 120 Phi 2 an Event 4 Theta 0 Phi 0 an Event 4 Theta 0 Phi 120 an Event 4 Theta 0 Phi 240 an Event 4 Theta 60 Phi 0 an Event 4 Theta 60 Phi 120 an Event 4 Theta 60 Phi 240 an Event 4 Theta 120 Phi 0 an Event 4 Theta 120 Phi 120 an Event 4 Theta 120 Phi 240 an Event 5 Theta 0 Phi 0 an Event 5 Theta 0 Phi 120 an Event 5 Theta 0 Phi 240 an Event 5 Theta 60 Phi 0 an Event 5 Theta 60 Phi 120 an Event 5 Theta 60 Phi 240 an Event 5 Theta 120 Phi 0 an Event 5 Theta 120 Phi 120 an Event 5 Theta 120 Phi 240 an Event 6 Theta 0 Phi 0 an Event 6 Theta 0 Phi 120 an Event 6 Theta 0 Phi 240 an Event 6 Theta 60 Phi 0 an Event 6 Theta 60 Phi 120 an Event 6 Theta 60 Phi 240 an Event 6 Theta 120 Phi 0 an Event 6 Theta 120 Phi 120 an Event 6 Theta 120 Phi 240 an Event 7 Theta 0 Phi 0 an Event 7 Theta 0 Phi 120 an Event 7 Theta 0 Phi 240 an Event 7 Theta 60 Phi 0 an Event 7 Theta 60 Phi 120 an Event 7 Theta 60 Phi 240 an Event 7 Theta 120 Phi 0 an Event 7 Theta 120 Phi 120 an Event 7 Theta 120 Phi 240 an Event 8 Theta 0 Phi 0 an Event 8 Theta 0 Phi 120 an Event 8 Theta 0 Phi 240 an Event 8 Theta 60 Phi 0 an Event 8 Theta 60 Phi 120 an Event 8 Theta 60 Phi 240 an Event 8 Theta 120 Phi 0 an Event 8 Theta 120 Phi 120 an Event 8 Theta 120 Phi 240``` ``` Theta 120 Phi 120 an Event 5 Theta 120 Phi 240 an Event 6 Theta 0 Phi 0 an Event 6 Theta 0 Phi 120 an Event 6 Theta 0 Phi 240 an Event 6 Theta 60 Phi 0 an Event 6 Theta 60 Phi 120 an Event 6 Theta 60 Phi 240 an Event 6 Theta 120 Phi 0 an Event 6 Theta 120 Phi 120 an Event 6 Theta 120 Phi 240 an Event 7 Theta 0 Phi 0 an Event 7 Theta 0 Phi 120 an Event 7 Theta 0 Phi 240 an Event 7 Theta 60 Phi 0 an Event 7 Theta 60 Phi 120 an Event 7 Theta 60 Phi 240 an Event 7 Theta 120 Phi 0 an Event 7 Theta 120 Phi 120 an Event 7 Theta 120 Phi 240 an Event 8 Theta 0 Phi 0 an Event 8 Theta 0 Phi 120 an Event 8 Theta 0 Phi 240 an Event 8 Theta 60 Phi 0 an Event 8 Theta 60 Phi 120 an Event 8 Theta 60 Phi 240 an Event 8 Theta 120 Phi 0 an Event 8 Theta 120 Phi 120 an Event 8 Theta 120 Phi 240``` ``` an Event 7 Theta 120 Phi 0 an Event 7 Theta 120 Phi 120 an Event 7 Theta 120 Phi 240 an Event 8 Theta 0 Phi 0 an Event 8 Theta 0 Phi 120 an Event 8 Theta 0 Phi 240 an Event 8 Theta 60 Phi 0 an Event 8 Theta 60 Phi 120 an Event 8 Theta 60 Phi 240 an Event 8 Theta 120 Phi 0 an Event 8 Theta 120 Phi 120 an Event 8 Theta 120 Phi 24040 an Event 2 Theta 0 Phi 0 an Event 2 Theta 0 Phi 120 an Event 2 Theta 0 Phi 240 an Event 2 Theta 60 Phi 0 an Event 2 Theta 60 Phi 120 an Event 2 Theta 60 Phi 240 an Event 2 Theta 120 Phi 0 an Event 2 Theta 120 Phi 120 an Event 2 Theta 120 Phi 240 an Event 3 Theta 0 Phi 0 an Event 3 Theta 0 Phi 120 an Event 3 Theta 0 Phi 240 an Event 3 Theta 60 Phi 0 an Event 3 Theta 60 Phi 120 an Event 3 Theta 60 Phi 240 an Event 3 Theta 120 Phi 0 an Event 3 Theta 120 Phi 120 an Event 3 Theta 120 Phi 240 an Event 4 Theta 0 Phi 0 an Event 4 Theta 0 Phi 120 an Event 4 Theta 0 Phi 240 an Event 4 Theta 60 Phi 0 an Event 4 Theta 60 Phi 120 an Event 4 Theta 60 Phi 240 an Event 4 Theta 120 Phi 0 an Event 4 Theta 120 Phi 120 an Event 4 Theta 120 Phi 240 an Event 5 Theta 0 Phi 0 an Event 5 Theta 0 Phi 120 an Event 5 Theta 0 Phi 240 an Event 5 Theta 60 Phi 0 an Event 5 Theta 60 Phi 120 an Event 5 Theta 60 Phi 240 an Event 5 Theta 120 Phi 0 an Event 5 Theta 120 Phi 120 an Event 5 Theta 120 Phi 240 an Event 6 Theta 0 Phi 0 an Event 6 Theta 0 Phi 120 an Event 6 Theta 0 Phi 240 an Event 6 Theta 60 Phi 0 an Event 6 Theta 60 Phi 120 an Event 6 Theta 60 Phi 240 an Event 6 Theta 120 Phi 0 an Event 6 Theta 120 Phi 120 an Event 6 Theta 120 Phi 240 an Event 7 Theta 0 Phi 0 an Event 7 Theta 0 Phi 120 an Event 7 Theta 0 Phi 240 an Event 7 Theta 60 Phi 0 an Event 7 Theta 60 Phi 120 an Event 7 Theta 60 Phi 240an Event 1 Theta 0 Phi 0 an Event 1 Theta 0 Phi 120 an Event 1 Theta 0 Phi 240 an Event 1 Theta 60 Phi 0 an Event 1 Theta 60 Phi 120 an Event 1 Theta 60 Phi 240 an Event 1 Theta 120 Phi 0 an Event 1 Theta 120 Phi 120 an Event 1 Theta 120 Phi 240 an Event 2 Theta 0 Phi 0 an Event 2 Theta 0 Phi 120 an Event 2 Theta 0 Phi 240 an Event 2 Theta 60 Phi 0 an Event 2 Theta 60 Phi 120 an Event 2 Theta 60 Phi 24 an Event 4 Theta 0 Phi 0 an Event 4 Theta 0 Phi 120 an Event 4 Theta 0 Phi 240 an Event 4 Theta 60 Phi 0 an Event 4 Theta 60 Phi 120 an Event 4 Theta 60 Phi 240 an Event 4 Theta 120 Phi 0 an Event 4 Theta 120 Phi 120 an Event 4 Theta 120 Phi 240 an Event 5 Theta 0 Phi 0 an Event 5 Theta 0 Phi 120 an Event 5 Theta 0 Phi 240 an Event 5 Theta 60 Phi 0 an Event 5 Theta 60 Phi 120 an Event 5 Theta 60 Phi 240 an Event 5 Theta 120 Phi 0 an Event 5 Theta 120 Phi 120 an Event 5 Theta 120 Phi 240 an Event 6 Theta 0 Phi 0 an Event 6 Theta 0 Phi 120 an Event 6 Theta 0 Phi 240 an Event 6 Theta 60 Phi 0 an Event 6 Theta 60 Phi 120 an Event 6 Theta 60 Phi 240 an Event 6 Theta 120 Phi 0 an Event 6 Theta 120 Phi 120 an Event 6 Theta 120 Phi 240 an Event 7 Theta 0 Phi 0 an Event 7 Theta 0 Phi 120 an Event 7 Theta 0 Phi 240 an Event 7 Theta 60 Phi 0 an Event 7 Theta 60 Phi 120 an Event 7 Theta 60 Phi 240 an Event 7 Theta 120 Phi 0 an Event 7 Theta 120 Phi 120 an Event 7 Theta 120 Phi 240 an Event 8 Theta 0 Phi 0 an Event 8 Theta 0 Phi 120 an Event 8 Theta 0 Phi 240 an Event 8 Theta 60 Phi 0 an Event 8 Theta 60 Phi 120 an Event 8 Theta 60 Phi 240 an Event 8 Theta 120 Phi 0 an Event 8 Theta 120 Phi 120 an Event 8 Theta 120 Phi 240``` ``` Theta 120 Phi 120 an Event 5 Theta 120 Phi 240 an Event 6 Theta 0 Phi 0 an Event 6 Theta 0 Phi 120 an Event 6 Theta 0 Phi 240 an Event 6 Theta 60 Phi 0 an Event 6 Theta 60 Phi 120 an Event 6 Theta 60 Phi 240 an Event 6 Theta 120 Phi 0 an Event 6 Theta 120 Phi 120 an Event 6 Theta 120 Phi 240 an Event 7 Theta 0 Phi 0 an Event 7 Theta 0 Phi 120 an Event 7 Theta 0 Phi 240 an Event 7 Theta 60 Phi 0 an Event 7 Theta 60 Phi 120 an Event 7 Theta 60 Phi 240 an Event 7 Theta 120 Phi 0 an Event 7 Theta 120 Phi 120 an Event 7 Theta 120 Phi 240 an Event 8 Theta 0 Phi 0 an Event 8 Theta 0 Phi 120 an Event 8 Theta 0 Phi 240 an Event 8 Theta 60 Phi 0 an Event 8 Theta 60 Phi 120 an Event 8 Theta 60 Phi 240 an Event 8 Theta 120 Phi 0 an Event 8 Theta 120 Phi 120 an Event 8 Theta 120 Phi 240``` ``` an Event 7 Theta 120 Phi 0 an Event 7 Theta 120 Phi 120 an Event 7 Theta 120 Phi 240 an Event 8 Theta 0 Phi 0 an Event 8 Theta 0 Phi 120 an Event 8 Theta 0 Phi 240 an Event 8 Theta 60 Phi 0 an Event 8 Theta 60 Phi 120 an Event 8 Theta 60 Phi 240 an Event 8 Theta 120 Phi 0 an Event 8 Theta 120 Phi 120 an Event 8 Theta 120 Phi 2400 an Event 2 Theta 120 Phi 0 an Event 2 Theta 120 Phi 120 an Event 2 Theta 120 Phi 240 an Event 3 Theta 0 Phi 0 an Event 3 Theta 0 Phi 120 an Event 3 Theta 0 Phi 240 an Event 3 Theta 60 Phi 0 an Event 3 Theta 60 Phi 120 an Event 3 Theta 60 Phi 240 an Event 3 Theta 120 Phi 0 an Event 3 Theta 120 Phi 120 an Event 3 Theta 120 Phi 240 an Event 4 Theta 0 Phi 0 an Event 4 Theta 0 Phi 120 an Event 4 Theta 0 Phi 240 an Event 4 Theta 60 Phi 0 an Event 4 Theta 60 Phi 120 an Event 4 Theta 60 Phi 240 an Event 4 Theta 120 Phi 0 an Event 4 Theta 120 Phi 120 an Event 4 Theta 120 Phi 240 an Event 5 Theta 0 Phi 0 an Event 5 Theta 0 Phi 120 an Event 5 Theta 0 Phi 240 an Event 5 Theta 60 Phi 0 an Event 5 Theta 60 Phi 120 an Event 5 Theta 60 Phi 240 an Event 5 Theta 120 Phi 0 an Event 5an Event 1 Theta 0 Phi 0 an Event 1 Theta 0 Phi 120 an Event 1 Theta 0 Phi 240 an Event 1 Theta 60 Phi 0 an Event 1 Theta 60 Phi 120 an Event 1 Theta 60 Phi 240 an Event 1 Theta 120 Phi 0 an Event 1 Theta 120 Phi 120 an Event 1 Theta 120 Phi 240 an Event 2 Theta 0 Phi 0 an Event 2 Theta 0 Phi 120 an Event 2 Theta 0 Phi 240 an Event 2 Theta 60 Phi 0 an Event 2 Theta 60 Phi 120 an Event 2 Theta 60 Phi 240 an Event 2 Theta 120 Phi 0 an Event 2 Theta 120 Phi 120 an Event 2 Theta 120 Phi 240 an Event 3 Theta 0 Phi 0 an Event 3 Theta 0 Phi 120 an Event 3 Theta 0 Phi 240 an Event 3 Theta 60 Phi 0 an Event 3 Theta 60 Phi 120 an Event 3 Theta 60 Phi 240 an Event 3 Theta 120 Phi 0 an Event 3 Theta 120 Phi 120 an Event 3 Theta 120 Phi 240``` Here is what I want: ```an Event 0 Theta 0 Phi 0 an Event 1 Theta 0 Phi 120 an Event 2 Theta 0 Phi 240 an Event 3 Theta 60 Phi 0 an Event 4 Theta 60 Phi 120 an Event 5 Theta 60 Phi 240 an Event 6 Theta 120 Phi 0 an Event 7 Theta 120 Phi 120 an Event 8 Theta 120 Phi 240``` Can you please help to find the solution? Thank you Suzanne

 Inline Depth: Outline Depth: Add message:

1 Re: Generating Primary Events   (Anton Korneev - 17 Apr, 2007)
 to: "Generating Primary Events"
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 ]