56 lines
1.4 KiB
C++
56 lines
1.4 KiB
C++
// This code implementation is the intellectual property of
|
|
// the GEANT4 collaboration.
|
|
//
|
|
// By copying, distributing or modifying the Program (or any work
|
|
// based on the Program) you indicate your acceptance of this statement,
|
|
// and all its terms.
|
|
//
|
|
// $Id: ExN01PrimaryGeneratorAction.cc,v 1.2 1999/12/15 14:49:19 gunter Exp $
|
|
// GEANT4 tag $Name: geant4-01-01 $
|
|
//
|
|
|
|
#include "ExN01PrimaryGeneratorAction.hh"
|
|
|
|
#include "G4Event.hh"
|
|
#include "G4ParticleGun.hh"
|
|
#include "G4UImanager.hh"
|
|
#include "globals.hh"
|
|
|
|
ExN01PrimaryGeneratorAction::ExN01PrimaryGeneratorAction()
|
|
{
|
|
G4int n_particle = 1;
|
|
particleGun = new G4ParticleGun(n_particle);
|
|
|
|
G4UImanager* UI = G4UImanager::GetUIpointer();
|
|
UI->ApplyCommand("/gun/particle geantino");
|
|
UI->ApplyCommand("/gun/energy 1.0 GeV");
|
|
UI->ApplyCommand("/gun/position -2.0 0.0 0.0 m");
|
|
}
|
|
|
|
ExN01PrimaryGeneratorAction::~ExN01PrimaryGeneratorAction()
|
|
{
|
|
delete particleGun;
|
|
}
|
|
|
|
void ExN01PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
|
|
{
|
|
G4UImanager* UI = G4UImanager::GetUIpointer();
|
|
G4int i = anEvent->GetEventID() % 3;
|
|
switch(i)
|
|
{
|
|
case 0:
|
|
UI->ApplyCommand("/gun/direction 1.0 0.0 0.0");
|
|
break;
|
|
case 1:
|
|
UI->ApplyCommand("/gun/direction 1.0 0.1 0.0");
|
|
break;
|
|
case 2:
|
|
UI->ApplyCommand("/gun/direction 1.0 0.0 0.1");
|
|
break;
|
|
}
|
|
|
|
particleGun->GeneratePrimaryVertex(anEvent);
|
|
}
|
|
|
|
|