65 : multiple_vertex(false), flat_sampling(false)
68 sourceIntensity.clear();
69 sourceProbability.clear();
71 sourceVector.push_back(currentSource);
72 sourceIntensity.push_back(1.);
73 currentSourceIdx =
G4int(sourceVector.size() - 1);
75 theMessenger->SetParticleGun(currentSource);
76 IntensityNormalization();
88 sourceVector.push_back(currentSource);
89 sourceIntensity.push_back(aV);
90 currentSourceIdx =
G4int(sourceVector.size() - 1);
91 IntensityNormalization();
94 void G4GeneralParticleSource::IntensityNormalization()
98 for (i = 0; i < sourceIntensity.size(); i++)
99 total += sourceIntensity[i] ;
101 sourceProbability.clear();
102 std::vector <G4double> sourceNormalizedIntensity;
103 sourceNormalizedIntensity.clear();
105 sourceNormalizedIntensity.push_back(sourceIntensity[0]/total);
106 sourceProbability.push_back(sourceNormalizedIntensity[0]);
108 for ( i = 1 ; i < sourceIntensity.size(); i++) {
109 sourceNormalizedIntensity.push_back(sourceIntensity[i]/total);
110 sourceProbability.push_back(sourceNormalizedIntensity[i] + sourceProbability[i-1]);
114 for ( i = 0 ; i < sourceIntensity.size(); i++) {
115 if (!flat_sampling) {
116 sourceVector[i]->GetBiasRndm()->SetIntensityWeight(1.);
118 sourceVector[i]->GetBiasRndm()->SetIntensityWeight(sourceNormalizedIntensity[i]*sourceIntensity.size());
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;
134 size_t id = size_t (aV) ;
135 if (
id <= sourceIntensity.size() ) {
136 currentSourceIdx = aV;
137 currentSource = sourceVector[id];
142 G4cout <<
" it shall be <= " << sourceIntensity.size() <<
G4endl;
148 sourceIntensity[currentSourceIdx] = aV;
154 currentSourceIdx = -1;
156 sourceVector.clear();
157 sourceIntensity.clear();
158 sourceProbability.clear();
163 size_t id = size_t (aV) ;
164 if (
id <= sourceIntensity.size() ) {
165 sourceVector.erase(sourceVector.begin()+aV);
166 sourceIntensity.erase(sourceIntensity.begin()+aV);
168 if (currentSourceIdx == aV ) {
169 if ( sourceIntensity.size() > 0 ) {
170 currentSource = sourceVector[0];
171 currentSourceIdx = 1;
174 currentSourceIdx = -1;
179 G4cout <<
" it shall be <= " << sourceIntensity.size() <<
G4endl;
185 if (!multiple_vertex){
186 if (sourceIntensity.size() > 1) {
187 if (!normalised) IntensityNormalization();
190 if (!flat_sampling) {
191 while ( rndm > sourceProbability[i] ) i++;
192 (currentSource = sourceVector[i]);
194 i = size_t (sourceIntensity.size()*
rndm);
195 currentSource = sourceVector[i];
201 for (
size_t i = 0; i < sourceIntensity.size(); i++) {
202 sourceVector[i]->GeneratePrimaryVertex(evt);
~G4GeneralParticleSource()
void AddaSource(G4double)
void GeneratePrimaryVertex(G4Event *)
G4GeneralParticleSource()
DOUBLE PRECISION function rndm(RDUMMY)
void SetCurrentSourceIntensity(G4double)
G4GLOB_DLL std::ostream G4cout
void SetParticleGun(G4SingleParticleSource *fpg)
G4double total(Particle const *const p1, Particle const *const p2)
void DeleteaSource(G4int)
void SetCurrentSourceto(G4int)