Geant4  10.02.p03
GammaRayTelPrimaryGeneratorAction Class Reference

#include <GammaRayTelPrimaryGeneratorAction.hh>

Inheritance diagram for GammaRayTelPrimaryGeneratorAction:
Collaboration diagram for GammaRayTelPrimaryGeneratorAction:

Public Member Functions

 GammaRayTelPrimaryGeneratorAction ()
 
 ~GammaRayTelPrimaryGeneratorAction ()
 
void GeneratePrimaries (G4Event *)
 
void SetRndmFlag (G4String val)
 
void SetSourceType (G4int val)
 
void SetSpectrumType (G4int val)
 
void SetVertexRadius (G4double val)
 
void SetSourceGen (G4bool val)
 
- Public Member Functions inherited from G4VUserPrimaryGeneratorAction
 G4VUserPrimaryGeneratorAction ()
 
virtual ~G4VUserPrimaryGeneratorAction ()
 

Private Attributes

G4ParticleGunparticleGun
 
G4GeneralParticleSourceparticleSource
 
const GammaRayTelDetectorConstructionGammaRayTelDetector
 
GammaRayTelPrimaryGeneratorMessengergunMessenger
 
G4String rndmFlag
 
G4int nSourceType
 
G4double dVertexRadius
 
G4int nSpectrumType
 
G4bool sourceGun
 

Detailed Description

Definition at line 58 of file GammaRayTelPrimaryGeneratorAction.hh.

Constructor & Destructor Documentation

◆ GammaRayTelPrimaryGeneratorAction()

GammaRayTelPrimaryGeneratorAction::GammaRayTelPrimaryGeneratorAction ( )

Definition at line 58 of file GammaRayTelPrimaryGeneratorAction.cc.

59  :rndmFlag("off"),nSourceType(0),nSpectrumType(0),sourceGun(false)
60 {
63 
64  //create a messenger for this class
65 
67 
68  G4int n_particle = 1;
69 
70  particleGun = new G4ParticleGun(n_particle);
71  // default particle kinematic
72 
74  G4String particleName;
75  G4ParticleDefinition* particle
76  = particleTable->FindParticle(particleName="e-");
83 
84 }
static const double cm
Definition: G4SIunits.hh:118
static const double MeV
Definition: G4SIunits.hh:211
G4ParticleDefinition * FindParticle(G4int PDGEncoding)
CLHEP::Hep3Vector G4ThreeVector
void SetParticleMomentumDirection(G4ParticleMomentum aMomentumDirection)
int G4int
Definition: G4Types.hh:78
void SetParticlePosition(G4ThreeVector aPosition)
GammaRayTelPrimaryGeneratorMessenger * gunMessenger
const GammaRayTelDetectorConstruction * GammaRayTelDetector
void SetParticleEnergy(G4double aKineticEnergy)
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:79
static G4ParticleTable * GetParticleTable()
double G4double
Definition: G4Types.hh:76
const G4VUserDetectorConstruction * GetUserDetectorConstruction() const
void SetParticleDefinition(G4ParticleDefinition *aParticleDefinition)
Here is the call graph for this function:

◆ ~GammaRayTelPrimaryGeneratorAction()

GammaRayTelPrimaryGeneratorAction::~GammaRayTelPrimaryGeneratorAction ( )

Definition at line 88 of file GammaRayTelPrimaryGeneratorAction.cc.

89 {
90 
91  delete particleGun;
92  delete particleSource;
93 
94  delete gunMessenger;
95 }
GammaRayTelPrimaryGeneratorMessenger * gunMessenger

Member Function Documentation

◆ GeneratePrimaries()

void GammaRayTelPrimaryGeneratorAction::GeneratePrimaries ( G4Event anEvent)
virtual

Implements G4VUserPrimaryGeneratorAction.

Definition at line 99 of file GammaRayTelPrimaryGeneratorAction.cc.

100 {
101  if (sourceGun)
102  {
103 
104  //this function is called at the begining of event
105  //
107  G4double x0 = 0.*cm, y0 = 0.*cm;
108 
109  G4ThreeVector pos0;
110  G4ThreeVector dir0;
111  G4ThreeVector vertex0 = G4ThreeVector(x0,y0,z0);
112 
113  dir0 = G4ThreeVector(0.,0.,-1.);
114 
115  G4double theta, phi, y, f;
116  G4double theta0=0.;
117  G4double phi0=0.;
118 
119  switch(nSourceType) {
120  case 0:
123  break;
124  case 1:
125  // GS: Generate random position on the 4PIsphere to create a unif. distrib.
126  // GS: on the sphere
127  phi = G4UniformRand() * twopi;
128  do {
129  y = G4UniformRand()*1.0;
130  theta = G4UniformRand() * pi;
131  f = std::sin(theta);
132  } while (y > f);
133  vertex0 = G4ThreeVector(1.,0.,0.);
134  vertex0.setMag(dVertexRadius);
135  vertex0.setTheta(theta);
136  vertex0.setPhi(phi);
138 
139  dir0 = G4ThreeVector(1.,0.,0.);
140  do {
141  phi = G4UniformRand() * twopi;
142  do {
143  y = G4UniformRand()*1.0;
144  theta = G4UniformRand() * pi;
145  f = std::sin(theta);
146  } while (y > f);
147  dir0.setPhi(phi);
148  dir0.setTheta(theta);
149  } while (vertex0.dot(dir0) >= -0.7 * vertex0.mag());
151 
152  break;
153  case 2:
154  // GS: Generate random position on the upper semi-sphere z>0 to create a unif. distrib.
155  // GS: on a plane
156  phi = G4UniformRand() * twopi;
157  do {
158  y = G4UniformRand()*1.0;
159  theta = G4UniformRand() * halfpi;
160  f = std::sin(theta) * std::cos(theta);
161  } while (y > f);
162  vertex0 = G4ThreeVector(1.,0.,0.);
163 
166 
167  if (dVertexRadius > xy*0.5)
168  {
169  G4cout << "vertexRadius too big " << G4endl;
170  G4cout << "vertexRadius setted to " << xy*0.45 << G4endl;
171  dVertexRadius = xy*0.45;
172  }
173 
174  if (dVertexRadius > z*0.5)
175  {
176  G4cout << "vertexRadius too high " << G4endl;
177  G4cout << "vertexRadius setted to " << z*0.45 << G4endl;
178  dVertexRadius = z*0.45;
179  }
180 
181 
182  vertex0.setMag(dVertexRadius);
183  vertex0.setTheta(theta);
184  vertex0.setPhi(phi);
185 
186  // GS: Get the user defined direction for the primaries and
187  // GS: Rotate the random position according to the user defined direction for the particle
188 
190  if (dir0.mag() > 0.001)
191  {
192  theta0 = dir0.theta();
193  phi0 = dir0.phi();
194  }
195 
196  if (theta0!=0.)
197  {
198  G4ThreeVector rotationAxis(1.,0.,0.);
199  rotationAxis.setPhi(phi0+halfpi);
200  vertex0.rotate(theta0+pi,rotationAxis);
201  }
203  break;
204  }
205 
206 
207  G4double pEnergy;
208 
209  switch(nSpectrumType) {
210  case 0:
211  break;
212  case 1:
213  break;
214  case 2:
215  do {
216  y = G4UniformRand()*100000.0;
217  pEnergy = G4UniformRand() * 10. * GeV;
218  f = std::pow(pEnergy * (1/GeV), -4.);
219  } while (y > f);
220 
221  particleGun->SetParticleEnergy(pEnergy);
222 
223  break;
224  case 3:
225  break;
226  }
227 
229  }
230  else
231  {
233  }
234 
235 }
static const double cm
Definition: G4SIunits.hh:118
void setPhi(double)
static const double halfpi
Definition: G4SIunits.hh:76
double phi() const
CLHEP::Hep3Vector G4ThreeVector
void SetParticleMomentumDirection(G4ParticleMomentum aMomentumDirection)
virtual void GeneratePrimaryVertex(G4Event *evt)
G4ParticleMomentum GetParticleMomentumDirection() const
Double_t y
void SetParticlePosition(G4ThreeVector aPosition)
#define G4UniformRand()
Definition: Randomize.hh:97
G4GLOB_DLL std::ostream G4cout
double theta() const
double mag() const
static const double twopi
Definition: G4SIunits.hh:75
static const double GeV
Definition: G4SIunits.hh:214
void setTheta(double)
const GammaRayTelDetectorConstruction * GammaRayTelDetector
double dot(const Hep3Vector &) const
void SetParticleEnergy(G4double aKineticEnergy)
static const double pi
Definition: G4SIunits.hh:74
#define G4endl
Definition: G4ios.hh:61
void setMag(double)
Definition: ThreeVector.cc:25
double G4double
Definition: G4Types.hh:76
Hep3Vector & rotate(double, const Hep3Vector &)
Definition: ThreeVectorR.cc:28
Here is the call graph for this function:

◆ SetRndmFlag()

void GammaRayTelPrimaryGeneratorAction::SetRndmFlag ( G4String  val)
inline

Definition at line 67 of file GammaRayTelPrimaryGeneratorAction.hh.

Here is the caller graph for this function:

◆ SetSourceGen()

void GammaRayTelPrimaryGeneratorAction::SetSourceGen ( G4bool  val)
inline

Definition at line 71 of file GammaRayTelPrimaryGeneratorAction.hh.

Here is the caller graph for this function:

◆ SetSourceType()

void GammaRayTelPrimaryGeneratorAction::SetSourceType ( G4int  val)
inline

Definition at line 68 of file GammaRayTelPrimaryGeneratorAction.hh.

Here is the caller graph for this function:

◆ SetSpectrumType()

void GammaRayTelPrimaryGeneratorAction::SetSpectrumType ( G4int  val)
inline

Definition at line 69 of file GammaRayTelPrimaryGeneratorAction.hh.

Here is the caller graph for this function:

◆ SetVertexRadius()

void GammaRayTelPrimaryGeneratorAction::SetVertexRadius ( G4double  val)
inline

Definition at line 70 of file GammaRayTelPrimaryGeneratorAction.hh.

Here is the caller graph for this function:

Member Data Documentation

◆ dVertexRadius

G4double GammaRayTelPrimaryGeneratorAction::dVertexRadius
private

Definition at line 80 of file GammaRayTelPrimaryGeneratorAction.hh.

◆ GammaRayTelDetector

const GammaRayTelDetectorConstruction* GammaRayTelPrimaryGeneratorAction::GammaRayTelDetector
private

Definition at line 76 of file GammaRayTelPrimaryGeneratorAction.hh.

◆ gunMessenger

GammaRayTelPrimaryGeneratorMessenger* GammaRayTelPrimaryGeneratorAction::gunMessenger
private

Definition at line 77 of file GammaRayTelPrimaryGeneratorAction.hh.

◆ nSourceType

G4int GammaRayTelPrimaryGeneratorAction::nSourceType
private

Definition at line 79 of file GammaRayTelPrimaryGeneratorAction.hh.

◆ nSpectrumType

G4int GammaRayTelPrimaryGeneratorAction::nSpectrumType
private

Definition at line 81 of file GammaRayTelPrimaryGeneratorAction.hh.

◆ particleGun

G4ParticleGun* GammaRayTelPrimaryGeneratorAction::particleGun
private

Definition at line 74 of file GammaRayTelPrimaryGeneratorAction.hh.

◆ particleSource

G4GeneralParticleSource* GammaRayTelPrimaryGeneratorAction::particleSource
private

Definition at line 75 of file GammaRayTelPrimaryGeneratorAction.hh.

◆ rndmFlag

G4String GammaRayTelPrimaryGeneratorAction::rndmFlag
private

Definition at line 78 of file GammaRayTelPrimaryGeneratorAction.hh.

◆ sourceGun

G4bool GammaRayTelPrimaryGeneratorAction::sourceGun
private

Definition at line 82 of file GammaRayTelPrimaryGeneratorAction.hh.


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