63 static G4bool onlyOnce =
false;
66 theMessenger->SetParticleGun(GPSData->GetCurrentSource());
67 IntensityNormalization();
74 theMessenger->Destroy();
81 GPSData->AddASource(aV);
82 theMessenger->SetParticleGun(GPSData->GetCurrentSource());
85 IntensityNormalization();
90void G4GeneralParticleSource::IntensityNormalization()
98 G4cout <<
"The number of particle sources is: "
99 << GPSData->GetIntensityVectorSize() <<
G4endl;
100 G4cout <<
" Multiple Vertex sources: " << GPSData->GetMultipleVertex();
101 G4cout <<
" Flat Sampling flag: " << GPSData->GetFlatSampling() <<
G4endl;
102 const G4int currentIdx = GPSData->GetCurrentSourceIdx();
103 for(
G4int i=0; i<GPSData->GetIntensityVectorSize(); ++i)
105 G4cout <<
"\tsource " << i <<
" with intensity: "
106 << GPSData->GetIntensity(i) <<
G4endl;
109 <<
"; Particle type: "
113 G4cout <<
" \t\tDirection: "
117 G4cout <<
" \t\tAngular Distribution: "
119 G4cout <<
" \t\tEnergy Distribution: "
121 G4cout <<
" \t\tPosition Distribution Type: "
123 G4cout <<
"; Position Shape: "
128 GPSData->GetCurrentSource(currentIdx);
134 if ( id < GPSData->GetIntensityVectorSize() )
138 theMessenger->SetParticleGun(GPSData->GetCurrentSource(
id));
143 msg <<
"Trying to set source to index " << aV <<
" but only "
144 << GPSData->GetIntensityVectorSize() <<
" sources are defined.";
145 G4Exception(
"G4GeneralParticleSoruce::SetCurrentSourceto",
"G4GPS004",
153 GPSData->SetCurrentSourceIntensity(aV);
155 normalised = GPSData->Normalised();
160 GPSData->ClearSources();
161 normalised=GPSData->Normalised();
167 if ( id <= GPSData->GetIntensityVectorSize() )
169 GPSData->DeleteASource(aV);
170 normalised=GPSData->Normalised();
175 G4cout <<
" it shall be <= "
176 << GPSData->GetIntensityVectorSize() <<
G4endl;
182 if (!GPSData->GetMultipleVertex())
185 if (GPSData->GetIntensityVectorSize() > 1)
194 G4bool norm = GPSData->Normalised();
197 IntensityNormalization();
201 normalised = GPSData->Normalised();
206 if (! GPSData->GetFlatSampling() )
208 while ( rndm > GPSData->GetSourceProbability(i) ) ++i;
209 currentSource = GPSData->GetCurrentSource(i);
213 i =
G4int (GPSData->GetIntensityVectorSize()*rndm);
214 currentSource = GPSData->GetCurrentSource(i);
221 for (
G4int i = 0; i < GPSData->GetIntensityVectorSize(); ++i)
223 GPSData->GetCurrentSource(i)->GeneratePrimaryVertex(evt);
G4TemplateAutoLock< G4Mutex > G4AutoLock
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
#define G4MUTEX_INITIALIZER
G4GLOB_DLL std::ostream G4cout
G4bool Normalised() const
void IntensityNormalise()
static G4GeneralParticleSourceData * Instance()
static G4GeneralParticleSourceMessenger * GetInstance(G4GeneralParticleSource *)
void AddaSource(G4double)
void SetCurrentSourceIntensity(G4double)
void GeneratePrimaryVertex(G4Event *) override
void SetCurrentSourceto(G4int)
~G4GeneralParticleSource() override
void DeleteaSource(G4int)
G4GeneralParticleSource()
const G4String & GetParticleName() const
G4ThreeVector GetDirection()
const G4String & GetEnergyDisType()
const G4ThreeVector & GetCentreCoords() const
const G4String & GetPosDisType() const
const G4String & GetPosDisShape() const
void GeneratePrimaryVertex(G4Event *evt) override
G4int GetNumberOfParticles() const
G4SPSAngDistribution * GetAngDist() const
G4SPSEneDistribution * GetEneDist() const
G4ParticleDefinition * GetParticleDefinition() const
G4SPSPosDistribution * GetPosDist() const