Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4GeneralParticleSource Class Reference

#include <G4GeneralParticleSource.hh>

+ Inheritance diagram for G4GeneralParticleSource:

Public Member Functions

 G4GeneralParticleSource ()
 
 ~G4GeneralParticleSource ()
 
void GeneratePrimaryVertex (G4Event *)
 
G4int GetNumberofSource ()
 
void ListSource ()
 
void SetCurrentSourceto (G4int)
 
void SetCurrentSourceIntensity (G4double)
 
G4SingleParticleSourceGetCurrentSource ()
 
G4int GetCurrentSourceIndex ()
 
G4double GetCurrentSourceIntensity ()
 
void ClearAll ()
 
void AddaSource (G4double)
 
void DeleteaSource (G4int)
 
void SetVerbosity (G4int i)
 
void SetMultipleVertex (G4bool av)
 
void SetFlatSampling (G4bool av)
 
void SetParticleDefinition (G4ParticleDefinition *aParticleDefinition)
 
G4ParticleDefinitionGetParticleDefinition ()
 
void SetParticleCharge (G4double aCharge)
 
void SetParticlePolarization (G4ThreeVector aVal)
 
G4ThreeVector GetParticlePolarization ()
 
void SetParticleTime (G4double aTime)
 
G4double GetParticleTime ()
 
void SetNumberOfParticles (G4int i)
 
G4int GetNumberOfParticles ()
 
G4ThreeVector GetParticlePosition ()
 
G4ThreeVector GetParticleMomentumDirection ()
 
G4double GetParticleEnergy ()
 
- Public Member Functions inherited from G4VPrimaryGenerator
 G4VPrimaryGenerator ()
 
virtual ~G4VPrimaryGenerator ()
 
virtual void GeneratePrimaryVertex (G4Event *evt)=0
 
G4ThreeVector GetParticlePosition ()
 
G4double GetParticleTime ()
 
void SetParticlePosition (G4ThreeVector aPosition)
 
void SetParticleTime (G4double aTime)
 

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

Definition at line 151 of file G4GeneralParticleSource.hh.

Constructor & Destructor Documentation

◆ G4GeneralParticleSource()

G4GeneralParticleSource::G4GeneralParticleSource ( )

Definition at line 64 of file G4GeneralParticleSource.cc.

65 : multiple_vertex(false), flat_sampling(false), weight_change(1.)
66{
67 sourceVector.clear();
68 sourceIntensity.clear();
69 sourceProbability.clear();
70 currentSource = new G4SingleParticleSource();
71 sourceVector.push_back(currentSource);
72 sourceIntensity.push_back(1.);
73 currentSourceIdx = G4int(sourceVector.size() - 1);
74 theMessenger = new G4GeneralParticleSourceMessenger(this);
75 theMessenger->SetParticleGun(currentSource);
76 IntensityNormalization();
77}
int G4int
Definition: G4Types.hh:66
void SetParticleGun(G4SingleParticleSource *fpg)

◆ ~G4GeneralParticleSource()

G4GeneralParticleSource::~G4GeneralParticleSource ( )

Definition at line 79 of file G4GeneralParticleSource.cc.

80{
81 delete theMessenger;
82}

Member Function Documentation

◆ AddaSource()

void G4GeneralParticleSource::AddaSource ( G4double  aV)

Definition at line 84 of file G4GeneralParticleSource.cc.

85{
86 currentSource = new G4SingleParticleSource();
87 theMessenger->SetParticleGun(currentSource);
88 sourceVector.push_back(currentSource);
89 sourceIntensity.push_back(aV);
90 currentSourceIdx = G4int(sourceVector.size() - 1);
91 IntensityNormalization();
92}

Referenced by G4GeneralParticleSourceMessenger::SetNewValue().

◆ ClearAll()

void G4GeneralParticleSource::ClearAll ( )

Definition at line 152 of file G4GeneralParticleSource.cc.

153{
154 currentSourceIdx = -1;
155 currentSource = 0;
156 sourceVector.clear();
157 sourceIntensity.clear();
158 sourceProbability.clear();
159}

Referenced by G4GeneralParticleSourceMessenger::SetNewValue().

◆ DeleteaSource()

void G4GeneralParticleSource::DeleteaSource ( G4int  aV)

Definition at line 161 of file G4GeneralParticleSource.cc.

162{
163 size_t id = size_t (aV) ;
164 if ( id <= sourceIntensity.size() ) {
165 sourceVector.erase(sourceVector.begin()+aV);
166 sourceIntensity.erase(sourceIntensity.begin()+aV);
167 normalised = false ;
168 if (currentSourceIdx == aV ) {
169 if ( sourceIntensity.size() > 0 ) {
170 currentSource = sourceVector[0];
171 currentSourceIdx = 1;
172 } else {
173 currentSource = 0;
174 currentSourceIdx = -1;
175 }
176 }
177 } else {
178 G4cout << " source index is invalid " << G4endl;
179 G4cout << " it shall be <= " << sourceIntensity.size() << G4endl;
180 }
181}
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cout

Referenced by G4GeneralParticleSourceMessenger::SetNewValue().

◆ GeneratePrimaryVertex()

void G4GeneralParticleSource::GeneratePrimaryVertex ( G4Event evt)
virtual

Implements G4VPrimaryGenerator.

Definition at line 183 of file G4GeneralParticleSource.cc.

184{
185 if (!multiple_vertex){
186 if (sourceIntensity.size() > 1) {
187 if (!normalised) IntensityNormalization();
188 G4double rndm = G4UniformRand();
189 size_t i = 0 ;
190 if (!flat_sampling) {
191 while ( rndm > sourceProbability[i] ) i++;
192 (currentSource = sourceVector[i]);
193 } else {
194 i = size_t (sourceIntensity.size()*rndm);
195 currentSource = sourceVector[i];
196 }
197 }
198 currentSource-> GeneratePrimaryVertex(evt);
199 }
200 else {
201 for (size_t i = 0; i < sourceIntensity.size(); i++) {
202 sourceVector[i]->GeneratePrimaryVertex(evt);
203 }
204 }
205}
double G4double
Definition: G4Types.hh:64
#define G4UniformRand()
Definition: Randomize.hh:53

Referenced by GeneratePrimaryVertex().

◆ GetCurrentSource()

G4SingleParticleSource * G4GeneralParticleSource::GetCurrentSource ( )
inline

Definition at line 165 of file G4GeneralParticleSource.hh.

165{return currentSource;};

◆ GetCurrentSourceIndex()

G4int G4GeneralParticleSource::GetCurrentSourceIndex ( )
inline

Definition at line 166 of file G4GeneralParticleSource.hh.

166{ return currentSourceIdx; };

Referenced by G4GeneralParticleSourceMessenger::SetNewValue().

◆ GetCurrentSourceIntensity()

G4double G4GeneralParticleSource::GetCurrentSourceIntensity ( )
inline

Definition at line 167 of file G4GeneralParticleSource.hh.

167{ return sourceIntensity[currentSourceIdx]; };

Referenced by G4GeneralParticleSourceMessenger::SetNewValue().

◆ GetNumberOfParticles()

G4int G4GeneralParticleSource::GetNumberOfParticles ( )
inline

Definition at line 200 of file G4GeneralParticleSource.hh.

200{ return currentSource->GetNumberOfParticles(); };

◆ GetNumberofSource()

G4int G4GeneralParticleSource::GetNumberofSource ( )
inline

Definition at line 161 of file G4GeneralParticleSource.hh.

161{ return G4int(sourceVector.size()); };

◆ GetParticleDefinition()

G4ParticleDefinition * G4GeneralParticleSource::GetParticleDefinition ( )
inline

Definition at line 186 of file G4GeneralParticleSource.hh.

186{ return currentSource->GetParticleDefinition();} ;
G4ParticleDefinition * GetParticleDefinition()

◆ GetParticleEnergy()

G4double G4GeneralParticleSource::GetParticleEnergy ( )
inline

Definition at line 203 of file G4GeneralParticleSource.hh.

203{return currentSource->GetParticleEnergy();};

◆ GetParticleMomentumDirection()

G4ThreeVector G4GeneralParticleSource::GetParticleMomentumDirection ( )
inline

Definition at line 202 of file G4GeneralParticleSource.hh.

202{ return currentSource->GetParticleMomentumDirection();};
G4ThreeVector GetParticleMomentumDirection()

◆ GetParticlePolarization()

G4ThreeVector G4GeneralParticleSource::GetParticlePolarization ( )
inline

Definition at line 192 of file G4GeneralParticleSource.hh.

192{return currentSource->GetParticlePolarization();};
G4ThreeVector GetParticlePolarization()

◆ GetParticlePosition()

G4ThreeVector G4GeneralParticleSource::GetParticlePosition ( )
inline

Definition at line 201 of file G4GeneralParticleSource.hh.

201{ return currentSource->GetParticlePosition();};

◆ GetParticleTime()

G4double G4GeneralParticleSource::GetParticleTime ( )
inline

Definition at line 196 of file G4GeneralParticleSource.hh.

196{ return currentSource->GetParticleTime(); };

◆ ListSource()

void G4GeneralParticleSource::ListSource ( )

Definition at line 125 of file G4GeneralParticleSource.cc.

126{
127 G4cout << " The number of particle sources is " << sourceIntensity.size() << G4endl;
128 for (size_t i = 0 ; i < sourceIntensity.size(); i++)
129 G4cout << " source " << i << " intensity is " << sourceIntensity[i] << G4endl;
130}

Referenced by G4GeneralParticleSourceMessenger::SetNewValue().

◆ SetCurrentSourceIntensity()

void G4GeneralParticleSource::SetCurrentSourceIntensity ( G4double  aV)

Definition at line 146 of file G4GeneralParticleSource.cc.

147{
148 sourceIntensity[currentSourceIdx] = aV;
149 normalised = false;
150}

Referenced by G4GeneralParticleSourceMessenger::SetNewValue().

◆ SetCurrentSourceto()

void G4GeneralParticleSource::SetCurrentSourceto ( G4int  aV)

Definition at line 132 of file G4GeneralParticleSource.cc.

133{
134 size_t id = size_t (aV) ;
135 if ( id <= sourceIntensity.size() ) {
136 currentSourceIdx = aV;
137 currentSource = sourceVector[id];
138 theMessenger->SetParticleGun(currentSource);
139 //
140 } else {
141 G4cout << " source index is invalid " << G4endl;
142 G4cout << " it shall be <= " << sourceIntensity.size() << G4endl;
143 }
144}

Referenced by G4GeneralParticleSourceMessenger::SetNewValue().

◆ SetFlatSampling()

void G4GeneralParticleSource::SetFlatSampling ( G4bool  av)
inline

Definition at line 180 of file G4GeneralParticleSource.hh.

180{flat_sampling = av; normalised = false;} ;

Referenced by G4GeneralParticleSourceMessenger::SetNewValue().

◆ SetMultipleVertex()

void G4GeneralParticleSource::SetMultipleVertex ( G4bool  av)
inline

Definition at line 176 of file G4GeneralParticleSource.hh.

176{multiple_vertex = av;} ;

Referenced by G4GeneralParticleSourceMessenger::SetNewValue().

◆ SetNumberOfParticles()

void G4GeneralParticleSource::SetNumberOfParticles ( G4int  i)
inline

Definition at line 198 of file G4GeneralParticleSource.hh.

198{ currentSource->SetNumberOfParticles(i); };

◆ SetParticleCharge()

void G4GeneralParticleSource::SetParticleCharge ( G4double  aCharge)
inline

Definition at line 188 of file G4GeneralParticleSource.hh.

188{ currentSource->SetParticleCharge(aCharge); } ;
void SetParticleCharge(G4double aCharge)

◆ SetParticleDefinition()

void G4GeneralParticleSource::SetParticleDefinition ( G4ParticleDefinition aParticleDefinition)
inline

Definition at line 183 of file G4GeneralParticleSource.hh.

184 {currentSource->SetParticleDefinition(aParticleDefinition); } ;
void SetParticleDefinition(G4ParticleDefinition *aParticleDefinition)

◆ SetParticlePolarization()

void G4GeneralParticleSource::SetParticlePolarization ( G4ThreeVector  aVal)
inline

Definition at line 191 of file G4GeneralParticleSource.hh.

191{currentSource->SetParticlePolarization(aVal);};
void SetParticlePolarization(G4ThreeVector aVal)

◆ SetParticleTime()

void G4GeneralParticleSource::SetParticleTime ( G4double  aTime)
inline

Definition at line 195 of file G4GeneralParticleSource.hh.

195{ currentSource->SetParticleTime(aTime); };
void SetParticleTime(G4double aTime)

◆ SetVerbosity()

void G4GeneralParticleSource::SetVerbosity ( G4int  i)
inline

Definition at line 173 of file G4GeneralParticleSource.hh.

173{currentSource->SetVerbosity(i);} ;

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