Geant4.10
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions
FCALPrimaryGeneratorAction Class Reference

#include <FCALPrimaryGeneratorAction.hh>

Inheritance diagram for FCALPrimaryGeneratorAction:
G4VUserPrimaryGeneratorAction

Public Member Functions

 FCALPrimaryGeneratorAction ()
 
 ~FCALPrimaryGeneratorAction ()
 
void GeneratePrimaries (G4Event *)
 
void SetVerbosity (G4int ver)
 
- Public Member Functions inherited from G4VUserPrimaryGeneratorAction
 G4VUserPrimaryGeneratorAction ()
 
virtual ~G4VUserPrimaryGeneratorAction ()
 

Detailed Description

Definition at line 45 of file FCALPrimaryGeneratorAction.hh.

Constructor & Destructor Documentation

FCALPrimaryGeneratorAction::FCALPrimaryGeneratorAction ( )

Definition at line 48 of file FCALPrimaryGeneratorAction.cc.

References G4ParticleTable::FindParticle(), G4ParticleTable::GetParticleTable(), python.hepunit::GeV, G4ParticleGun::SetParticleDefinition(), and G4ParticleGun::SetParticleEnergy().

48  :
49  isFileRead(false),fVerbosity(0),nEvent(0)
50 {
51  fX = new G4DataVector();
52  fY = new G4DataVector();
53  fZ = new G4DataVector();
54  fCosX = new G4DataVector();
55  fCosY = new G4DataVector();
56  fCosZ = new G4DataVector();
57 
58  particleGun = new G4ParticleGun();
59 
60  // default Particle
61  G4String particleName;
63  G4ParticleDefinition* particle = particleTable->FindParticle(particleName="e-");
64  particleGun->SetParticleDefinition(particle);
65 
66  // default Energy
67  particleGun->SetParticleEnergy(20*GeV);
68 }
G4ParticleDefinition * FindParticle(G4int PDGEncoding)
void SetParticleEnergy(G4double aKineticEnergy)
static G4ParticleTable * GetParticleTable()
void SetParticleDefinition(G4ParticleDefinition *aParticleDefinition)
FCALPrimaryGeneratorAction::~FCALPrimaryGeneratorAction ( )

Definition at line 72 of file FCALPrimaryGeneratorAction.cc.

73 {
74  delete particleGun;
75  delete fX;
76  delete fY;
77  delete fZ;
78  delete fCosX;
79  delete fCosY;
80  delete fCosZ;
81 }

Member Function Documentation

void FCALPrimaryGeneratorAction::GeneratePrimaries ( G4Event anEvent)
virtual

Implements G4VUserPrimaryGeneratorAction.

Definition at line 130 of file FCALPrimaryGeneratorAction.cc.

References G4cout, G4endl, G4Exception(), G4ParticleGun::GeneratePrimaryVertex(), G4Event::GetEventID(), G4ParticleGun::GetParticleEnergy(), JustWarning, G4ParticleGun::SetParticleMomentumDirection(), and G4VPrimaryGenerator::SetParticlePosition().

131 {
132  //this function is called at the begining of event
133  if (!isFileRead)
134  ReadKinematicFromFile(particleGun->GetParticleEnergy());
135 
136  if (nEvent >= fX->size()) //file data are over, restart file
137  {
138  G4Exception("FCALPrimaryGeneratorAction::GeneratePrimaries","lAr002",
139  JustWarning,"Data file with kinematics is over, restart it");
140  nEvent=0;
141  }
142 
143  particleGun->SetParticlePosition(G4ThreeVector(fX->at(nEvent),fY->at(nEvent),fZ->at(nEvent)));
144  particleGun->SetParticleMomentumDirection(G4ThreeVector(-1.0*fCosX->at(nEvent),
145  fCosY->at(nEvent),
146  -1.0*fCosZ->at(nEvent)));
147  nEvent++;
148 
149  particleGun->GeneratePrimaryVertex(anEvent);
150 
151  if (fVerbosity)
152  {
153  G4cout << "--------------------------------------------" << G4endl;
154  G4cout << " Event, X,Y,Z Generated Vertex : " << G4endl;
155  G4cout << anEvent->GetEventID() << " " << (*fX)[nEvent] << " " <<
156  (*fY)[nEvent] << " " << (*fZ)[nEvent]<< G4endl;
157  G4cout << -1.*(*fCosX)[nEvent] << " " << (*fCosY)[nEvent] <<
158  " " << -1.*(*fCosZ)[nEvent] << G4endl;
159  G4cout << "--------------------------------------------" << G4endl;
160  }
161 
162 }
CLHEP::Hep3Vector G4ThreeVector
void SetParticleMomentumDirection(G4ParticleMomentum aMomentumDirection)
virtual void GeneratePrimaryVertex(G4Event *evt)
G4int GetEventID() const
Definition: G4Event.hh:140
void SetParticlePosition(G4ThreeVector aPosition)
G4GLOB_DLL std::ostream G4cout
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
#define G4endl
Definition: G4ios.hh:61
G4double GetParticleEnergy() const
void FCALPrimaryGeneratorAction::SetVerbosity ( G4int  ver)
inline

Definition at line 53 of file FCALPrimaryGeneratorAction.hh.

53 {fVerbosity = ver;};

The documentation for this class was generated from the following files: