Geant4  10.02.p03
G4SingleParticleSource Class Reference

#include <G4SingleParticleSource.hh>

Inheritance diagram for G4SingleParticleSource:
Collaboration diagram for G4SingleParticleSource:

Classes

struct  part_prop_t
 

Public Member Functions

 G4SingleParticleSource ()
 
 ~G4SingleParticleSource ()
 
void GeneratePrimaryVertex (G4Event *evt)
 
G4SPSPosDistributionGetPosDist () const
 
G4SPSAngDistributionGetAngDist () const
 
G4SPSEneDistributionGetEneDist () const
 
G4SPSRandomGeneratorGetBiasRndm () const
 
void SetVerbosity (G4int)
 
void SetParticleDefinition (G4ParticleDefinition *aParticleDefinition)
 
G4ParticleDefinitionGetParticleDefinition () const
 
void SetParticleCharge (G4double aCharge)
 
void SetParticlePolarization (G4ThreeVector aVal)
 
G4ThreeVector GetParticlePolarization () const
 
void SetParticleTime (G4double aTime)
 
G4double GetParticleTime () const
 
void SetNumberOfParticles (G4int i)
 
G4int GetNumberOfParticles () const
 
G4ThreeVector GetParticlePosition () const
 
G4ThreeVector GetParticleMomentumDirection () const
 
G4double GetParticleEnergy () const
 
- Public Member Functions inherited from G4VPrimaryGenerator
 G4VPrimaryGenerator ()
 
virtual ~G4VPrimaryGenerator ()
 
G4ThreeVector GetParticlePosition ()
 
G4double GetParticleTime ()
 
void SetParticlePosition (G4ThreeVector aPosition)
 
void SetParticleTime (G4double aTime)
 

Private Attributes

G4SPSPosDistributionposGenerator
 
G4SPSAngDistributionangGenerator
 
G4SPSEneDistributioneneGenerator
 
G4SPSRandomGeneratorbiasRndm
 
G4Cache< part_prop_tParticleProperties
 
G4int NumberOfParticlesToBeGenerated
 
G4ParticleDefinitiondefinition
 
G4double charge
 
G4double time
 
G4ThreeVector polarization
 
G4int verbosityLevel
 
G4Mutex mutex
 

Additional Inherited Members

- Static Public Member Functions inherited from G4VPrimaryGenerator
static G4bool CheckVertexInsideWorld (const G4ThreeVector &pos)
 
- Protected Attributes inherited from G4VPrimaryGenerator
G4ThreeVector particle_position
 
G4double particle_time
 

Detailed Description

Andrea Dotti Feb 2015 Important: This is a shared class between threads. Only one thread should use the set-methods here. Note that this is exactly what is achieved using UI commands. If you use the set methods to set defaults in your application take care that only one thread is executing them. In addition take care of calling these methods before the run is started Do not use these setters during the event loop

Definition at line 141 of file G4SingleParticleSource.hh.

Constructor & Destructor Documentation

◆ G4SingleParticleSource()

G4SingleParticleSource::G4SingleParticleSource ( )

Definition at line 71 of file G4SingleParticleSource.cc.

71  {
72 // // Initialise all variables
73 // // Position distribution Variables
74 //
77 // G4ThreeVector zero;
78 // particle_momentum_direction = G4ParticleMomentum(1, 0, 0);
79 // particle_energy = 1.0 * MeV;
80 // particle_position = zero;
81 // particle_time = 0.0;
82 // particle_polarization = zero;
83  charge = 0.0;
84  time = 0;
86 
95 
96  // verbosity
97  verbosityLevel = 0;
98 
100 
101 }
static G4Geantino * GeantinoDefinition()
Definition: G4Geantino.cc:82
G4ParticleDefinition * definition
void SetBiasRndm(G4SPSRandomGenerator *a)
CLHEP::Hep3Vector G4ThreeVector
#define G4MUTEXINIT(mutex)
Definition: G4Threading.hh:177
G4SPSEneDistribution * eneGenerator
G4SPSPosDistribution * posGenerator
void SetBiasRndm(G4SPSRandomGenerator *a)
G4SPSRandomGenerator * biasRndm
void SetBiasRndm(G4SPSRandomGenerator *a)
void SetPosDistribution(G4SPSPosDistribution *a)
G4SPSAngDistribution * angGenerator
Here is the call graph for this function:

◆ ~G4SingleParticleSource()

G4SingleParticleSource::~G4SingleParticleSource ( )

Definition at line 103 of file G4SingleParticleSource.cc.

103  {
104  delete biasRndm;
105  delete posGenerator;
106  delete angGenerator;
107  delete eneGenerator;
109 }
G4SPSEneDistribution * eneGenerator
G4SPSPosDistribution * posGenerator
G4SPSRandomGenerator * biasRndm
#define G4MUTEXDESTROY(mutex)
Definition: G4Threading.hh:178
G4SPSAngDistribution * angGenerator

Member Function Documentation

◆ GeneratePrimaryVertex()

void G4SingleParticleSource::GeneratePrimaryVertex ( G4Event evt)
virtual

Implements G4VPrimaryGenerator.

Definition at line 126 of file G4SingleParticleSource.cc.

126  {
127 
128  //G4AutoLock l(&mutex);
129  //part_prop_t& pp = ParticleProperties.Get();
130  if (definition == NULL) {
131  //TODO: Should this rise an exception???
132  return ;
133  }
134  //return;
135 
136  if (verbosityLevel > 1)
137  G4cout << " NumberOfParticlesToBeGenerated: "
139 
140  part_prop_t& pp = ParticleProperties.Get();
141  // Position stuff
142  pp.position = posGenerator->GenerateOne();
143 
144  // create a new vertex
145  G4PrimaryVertex* vertex = new G4PrimaryVertex(pp.position,time);
146 
147  for (G4int i = 0; i < NumberOfParticlesToBeGenerated; i++) {
148  // Angular stuff
149  pp.momentum_direction = angGenerator->GenerateOne();
150  // Energy stuff
151  pp.energy = eneGenerator->GenerateOne(definition);
152 
153  if (verbosityLevel >= 2)
154  G4cout << "Creating primaries and assigning to vertex" << G4endl;
155  // create new primaries and set them to the vertex
156  G4double mass = definition->GetPDGMass();
157  G4PrimaryParticle* particle =
159  particle->SetKineticEnergy(pp.energy );
160  particle->SetMass( mass );
161  particle->SetMomentumDirection( pp.momentum_direction );
162  particle->SetCharge( charge );
163  particle->SetPolarization(polarization.x(),
164  polarization.y(),
165  polarization.z());
166  if (verbosityLevel > 1) {
167  G4cout << "Particle name: "
169  G4cout << " Energy: " << pp.energy << G4endl;
170  G4cout << " Position: " << pp.position << G4endl;
171  G4cout << " Direction: " << pp.momentum_direction
172  << G4endl;
173  }
174  // Set bweight equal to the multiple of all non-zero weights
176  // pass it to primary particle
177  particle->SetWeight(weight);
178 
179  vertex->SetPrimary(particle);
180 
181  }
182  // now pass the weight to the primary vertex. CANNOT be used here!
183  // vertex->SetWeight(particle_weight);
184  evt->AddPrimaryVertex(vertex);
185  if (verbosityLevel > 1)
186  G4cout << " Primary Vetex generated !" << G4endl;
187 }
G4Cache< part_prop_t > ParticleProperties
G4ParticleDefinition * definition
void AddPrimaryVertex(G4PrimaryVertex *aPrimaryVertex)
Definition: G4Event.hh:154
double weight
Definition: plottest35.C:25
G4SPSEneDistribution * eneGenerator
int G4int
Definition: G4Types.hh:78
void SetKineticEnergy(G4double eKin)
G4SPSPosDistribution * posGenerator
const G4String & GetParticleName() const
G4GLOB_DLL std::ostream G4cout
G4ParticleMomentum GenerateOne()
G4SPSRandomGenerator * biasRndm
void SetMass(G4double mas)
G4double GenerateOne(G4ParticleDefinition *)
double x() const
double y() const
void SetMomentumDirection(const G4ThreeVector &p)
void SetWeight(G4double w)
void SetCharge(G4double chg)
double z() const
void SetPrimary(G4PrimaryParticle *pp)
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
void SetPolarization(const G4ThreeVector &pol)
G4SPSAngDistribution * angGenerator
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetAngDist()

G4SPSAngDistribution* G4SingleParticleSource::GetAngDist ( ) const
inline

Definition at line 153 of file G4SingleParticleSource.hh.

153  {
154  return angGenerator;
155  }
G4SPSAngDistribution * angGenerator
Here is the caller graph for this function:

◆ GetBiasRndm()

G4SPSRandomGenerator* G4SingleParticleSource::GetBiasRndm ( ) const
inline

Definition at line 161 of file G4SingleParticleSource.hh.

161  {
162  return biasRndm;
163  }
G4SPSRandomGenerator * biasRndm
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetEneDist()

G4SPSEneDistribution* G4SingleParticleSource::GetEneDist ( ) const
inline

Definition at line 157 of file G4SingleParticleSource.hh.

157  {
158  return eneGenerator;
159  }
G4SPSEneDistribution * eneGenerator
Here is the caller graph for this function:

◆ GetNumberOfParticles()

G4int G4SingleParticleSource::GetNumberOfParticles ( ) const
inline

Definition at line 206 of file G4SingleParticleSource.hh.

206  {
208  }
Here is the caller graph for this function:

◆ GetParticleDefinition()

G4ParticleDefinition* G4SingleParticleSource::GetParticleDefinition ( ) const
inline

Definition at line 171 of file G4SingleParticleSource.hh.

171  {
172  return definition;
173  }
G4ParticleDefinition * definition
Here is the caller graph for this function:

◆ GetParticleEnergy()

G4double G4SingleParticleSource::GetParticleEnergy ( ) const
inline

Definition at line 218 of file G4SingleParticleSource.hh.

218  {
219  return ParticleProperties.Get().energy;
220  }
G4Cache< part_prop_t > ParticleProperties
Here is the caller graph for this function:

◆ GetParticleMomentumDirection()

G4ThreeVector G4SingleParticleSource::GetParticleMomentumDirection ( ) const
inline

Definition at line 214 of file G4SingleParticleSource.hh.

214  {
215  return ParticleProperties.Get().momentum_direction;
216  }
G4Cache< part_prop_t > ParticleProperties
Here is the caller graph for this function:

◆ GetParticlePolarization()

G4ThreeVector G4SingleParticleSource::GetParticlePolarization ( ) const
inline

Definition at line 186 of file G4SingleParticleSource.hh.

186  {
187  return polarization;
188  }
Here is the caller graph for this function:

◆ GetParticlePosition()

G4ThreeVector G4SingleParticleSource::GetParticlePosition ( ) const
inline

Definition at line 210 of file G4SingleParticleSource.hh.

210  {
211  return ParticleProperties.Get().position;
212  }
G4Cache< part_prop_t > ParticleProperties
Here is the caller graph for this function:

◆ GetParticleTime()

G4double G4SingleParticleSource::GetParticleTime ( ) const
inline

Definition at line 196 of file G4SingleParticleSource.hh.

196  {
197  return time;
198  }
Here is the caller graph for this function:

◆ GetPosDist()

G4SPSPosDistribution* G4SingleParticleSource::GetPosDist ( ) const
inline

Definition at line 149 of file G4SingleParticleSource.hh.

149  {
150  return posGenerator;
151  }
G4SPSPosDistribution * posGenerator
Here is the caller graph for this function:

◆ SetNumberOfParticles()

void G4SingleParticleSource::SetNumberOfParticles ( G4int  i)
inline

Definition at line 201 of file G4SingleParticleSource.hh.

201  {
203  }
Here is the caller graph for this function:

◆ SetParticleCharge()

void G4SingleParticleSource::SetParticleCharge ( G4double  aCharge)
inline

Definition at line 176 of file G4SingleParticleSource.hh.

176  {
177  charge = aCharge;
178  }
Here is the caller graph for this function:

◆ SetParticleDefinition()

void G4SingleParticleSource::SetParticleDefinition ( G4ParticleDefinition aParticleDefinition)

Definition at line 120 of file G4SingleParticleSource.cc.

121  {
122  definition = aParticleDefinition;
123  charge = aParticleDefinition->GetPDGCharge();
124 }
G4ParticleDefinition * definition
G4double GetPDGCharge() const
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetParticlePolarization()

void G4SingleParticleSource::SetParticlePolarization ( G4ThreeVector  aVal)
inline

Definition at line 182 of file G4SingleParticleSource.hh.

182  {
183  polarization = aVal;
184  }
Here is the caller graph for this function:

◆ SetParticleTime()

void G4SingleParticleSource::SetParticleTime ( G4double  aTime)
inline

Definition at line 192 of file G4SingleParticleSource.hh.

192  {
193  time = aTime;
194  }
Here is the caller graph for this function:

◆ SetVerbosity()

void G4SingleParticleSource::SetVerbosity ( G4int  vL)

Definition at line 111 of file G4SingleParticleSource.cc.

111  {
112  G4AutoLock l(&mutex);
113  verbosityLevel = vL;
117  //G4cout << "Verbosity Set to: " << verbosityLevel << G4endl;
118 }
G4SPSEneDistribution * eneGenerator
G4SPSPosDistribution * posGenerator
G4SPSAngDistribution * angGenerator
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ angGenerator

G4SPSAngDistribution* G4SingleParticleSource::angGenerator
private

Definition at line 226 of file G4SingleParticleSource.hh.

◆ biasRndm

G4SPSRandomGenerator* G4SingleParticleSource::biasRndm
private

Definition at line 228 of file G4SingleParticleSource.hh.

◆ charge

G4double G4SingleParticleSource::charge
private

Definition at line 243 of file G4SingleParticleSource.hh.

◆ definition

G4ParticleDefinition* G4SingleParticleSource::definition
private

Definition at line 242 of file G4SingleParticleSource.hh.

◆ eneGenerator

G4SPSEneDistribution* G4SingleParticleSource::eneGenerator
private

Definition at line 227 of file G4SingleParticleSource.hh.

◆ mutex

G4Mutex G4SingleParticleSource::mutex
private

Definition at line 251 of file G4SingleParticleSource.hh.

◆ NumberOfParticlesToBeGenerated

G4int G4SingleParticleSource::NumberOfParticlesToBeGenerated
private

Definition at line 241 of file G4SingleParticleSource.hh.

◆ ParticleProperties

G4Cache<part_prop_t> G4SingleParticleSource::ParticleProperties
private

Definition at line 240 of file G4SingleParticleSource.hh.

◆ polarization

G4ThreeVector G4SingleParticleSource::polarization
private

Definition at line 245 of file G4SingleParticleSource.hh.

◆ posGenerator

G4SPSPosDistribution* G4SingleParticleSource::posGenerator
private

Definition at line 221 of file G4SingleParticleSource.hh.

◆ time

G4double G4SingleParticleSource::time
private

Definition at line 244 of file G4SingleParticleSource.hh.

◆ verbosityLevel

G4int G4SingleParticleSource::verbosityLevel
private

Definition at line 248 of file G4SingleParticleSource.hh.


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