67 G4GeneralParticleSourceData::G4GeneralParticleSourceData() :
68 multiple_vertex(false) ,flat_sampling(false),
69 normalised(false),currentSourceIdx(0)
74 sourceIntensity.clear();
75 sourceProbability.clear();
78 sourceVector.push_back(currentSource);
79 sourceIntensity.push_back(1.);
83 G4GeneralParticleSourceData::~G4GeneralParticleSourceData()
86 for ( std::vector<G4SingleParticleSource*>::const_iterator it = sourceVector.begin() ;
87 it != sourceVector.end() ; ++it ) {
delete *it; }
103 for (i = 0; i < sourceIntensity.size(); i++)
105 total += sourceIntensity[i] ;
107 sourceProbability.clear();
108 std::vector <G4double> sourceNormalizedIntensity;
109 sourceNormalizedIntensity.clear();
111 sourceNormalizedIntensity.push_back(sourceIntensity[0]/total);
112 sourceProbability.push_back(sourceNormalizedIntensity[0]);
114 for ( i = 1 ; i < sourceIntensity.size(); i++)
116 sourceNormalizedIntensity.push_back(sourceIntensity[i]/total);
117 sourceProbability.push_back(sourceNormalizedIntensity[i] + sourceProbability[i-1]);
121 for ( i = 0 ; i < sourceIntensity.size(); i++)
138 sourceIntensity.at(currentSourceIdx) = intensity;
145 sourceVector.push_back(currentSource);
146 sourceIntensity.push_back(intensity);
147 currentSourceIdx = sourceVector.size() - 1;
153 delete sourceVector[idx];
154 sourceVector.erase(sourceVector.begin() + idx);
155 sourceIntensity.erase(sourceIntensity.begin()+idx);
157 if (currentSourceIdx == idx )
162 currentSourceIdx = 0;
166 currentSource = NULL;
167 currentSourceIdx = -1;
175 currentSourceIdx = -1;
176 currentSource = NULL;
177 for ( std::vector<G4SingleParticleSource*>::iterator it = sourceVector.begin();
178 it != sourceVector.end() ; ++it ) {
delete *it; }
179 sourceVector.clear();
180 sourceIntensity.clear();
186 for ( std::vector<G4SingleParticleSource*>::iterator it = sourceVector.begin();
187 it != sourceVector.end() ; ++it ) {
188 (*it)->SetVerbosity(vl);
196 currentSource = sourceVector[idx];
197 currentSourceIdx = idx;
198 return sourceVector[idx];
#define G4MUTEXINIT(mutex)
G4SingleParticleSource * GetCurrentSource() const
#define G4MUTEX_INITIALIZER
void SetCurrentSourceIntensity(G4double)
void AddASource(G4double intensity)
G4SPSRandomGenerator * GetBiasRndm() const
void DeleteASource(G4int idx)
G4int GetIntensityVectorSize() const
void IntensityNormalise()
G4double total(Particle const *const p1, Particle const *const p2)
void SetIntensityWeight(G4double weight)
static MCTruthManager * instance
#define G4MUTEXDESTROY(mutex)
static G4GeneralParticleSourceData * Instance()
void SetVerbosityAllSources(G4int vl)