Geant4  10.02.p03
G4GeneralParticleSourceData Class Reference

#include <G4GeneralParticleSourceData.hh>

Collaboration diagram for G4GeneralParticleSourceData:

Public Member Functions

void AddASource (G4double intensity)
 
void DeleteASource (G4int idx)
 
void ClearSources ()
 
void IntensityNormalise ()
 
G4bool Normalised () const
 
G4SingleParticleSourceGetCurrentSource (G4int idx)
 
G4SingleParticleSourceGetCurrentSource () const
 
G4int GetSourceVectorSize () const
 
G4int GetIntensityVectorSize () const
 
G4double GetIntensity (G4int idx) const
 
G4double GetSourceProbability (G4int idx) const
 
void SetCurrentSourceIntensity (G4double)
 
void SetFlatSampling (G4bool fSamp)
 
G4bool GetFlatSampling () const
 
void SetMultipleVertex (G4bool flag)
 
G4bool GetMultipleVertex () const
 
G4int GetCurrentSourceIdx () const
 
void SetVerbosityAllSources (G4int vl)
 
void Lock ()
 
void Unlock ()
 

Static Public Member Functions

static G4GeneralParticleSourceDataInstance ()
 

Private Member Functions

 G4GeneralParticleSourceData ()
 
 ~G4GeneralParticleSourceData ()
 

Private Attributes

std::vector< G4SingleParticleSource * > sourceVector
 
std::vector< G4doublesourceIntensity
 
std::vector< G4doublesourceProbability
 
G4bool multiple_vertex
 
G4bool flat_sampling
 
G4bool normalised
 
G4int currentSourceIdx
 
G4SingleParticleSourcecurrentSource
 
G4Mutex mutex
 

Detailed Description

Definition at line 63 of file G4GeneralParticleSourceData.hh.

Constructor & Destructor Documentation

◆ G4GeneralParticleSourceData()

G4GeneralParticleSourceData::G4GeneralParticleSourceData ( )
private

Definition at line 67 of file G4GeneralParticleSourceData.cc.

67  :
68  multiple_vertex(false) ,flat_sampling(false),
70 {
72 
73  sourceVector.clear();
74  sourceIntensity.clear();
75  sourceProbability.clear();
76 
78  sourceVector.push_back(currentSource);
79  sourceIntensity.push_back(1.);
80 
81 }
#define G4MUTEXINIT(mutex)
Definition: G4Threading.hh:177
std::vector< G4SingleParticleSource * > sourceVector
Here is the caller graph for this function:

◆ ~G4GeneralParticleSourceData()

G4GeneralParticleSourceData::~G4GeneralParticleSourceData ( )
private

Definition at line 83 of file G4GeneralParticleSourceData.cc.

84 {
86  for ( std::vector<G4SingleParticleSource*>::const_iterator it = sourceVector.begin() ;
87  it != sourceVector.end() ; ++it ) { delete *it; }
88  sourceVector.clear();
89 }
#define G4MUTEXDESTROY(mutex)
Definition: G4Threading.hh:178
std::vector< G4SingleParticleSource * > sourceVector
Here is the caller graph for this function:

Member Function Documentation

◆ AddASource()

void G4GeneralParticleSourceData::AddASource ( G4double  intensity)

Definition at line 142 of file G4GeneralParticleSourceData.cc.

143 {
145  sourceVector.push_back(currentSource);
146  sourceIntensity.push_back(intensity);
147  currentSourceIdx = sourceVector.size() - 1;
148  normalised = false;
149 }
std::vector< G4SingleParticleSource * > sourceVector
Here is the caller graph for this function:

◆ ClearSources()

void G4GeneralParticleSourceData::ClearSources ( )

Definition at line 173 of file G4GeneralParticleSourceData.cc.

174 {
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();
181  normalised = false;
182 }
std::vector< G4SingleParticleSource * > sourceVector
Here is the caller graph for this function:

◆ DeleteASource()

void G4GeneralParticleSourceData::DeleteASource ( G4int  idx)

Definition at line 151 of file G4GeneralParticleSourceData.cc.

152 {
153  delete sourceVector[idx];
154  sourceVector.erase(sourceVector.begin() + idx);
155  sourceIntensity.erase(sourceIntensity.begin()+idx);
156  normalised = false ;
157  if (currentSourceIdx == idx )
158  {
159  if ( this->GetIntensityVectorSize() > 0 )
160  {
161  currentSource = this->GetCurrentSource(0);
162  currentSourceIdx = 0;
163  }
164  else
165  {
166  currentSource = NULL;
167  currentSourceIdx = -1;
168  }
169  }
170 
171 }
G4SingleParticleSource * GetCurrentSource() const
std::vector< G4SingleParticleSource * > sourceVector
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetCurrentSource() [1/2]

G4SingleParticleSource * G4GeneralParticleSourceData::GetCurrentSource ( G4int  idx)

Definition at line 194 of file G4GeneralParticleSourceData.cc.

195 {
197  currentSourceIdx = idx;
198  return sourceVector[idx];
199 }
std::vector< G4SingleParticleSource * > sourceVector
Here is the caller graph for this function:

◆ GetCurrentSource() [2/2]

G4SingleParticleSource* G4GeneralParticleSourceData::GetCurrentSource ( ) const
inline

Definition at line 77 of file G4GeneralParticleSourceData.hh.

77 {return currentSource;}
Here is the caller graph for this function:

◆ GetCurrentSourceIdx()

G4int G4GeneralParticleSourceData::GetCurrentSourceIdx ( ) const
inline

Definition at line 92 of file G4GeneralParticleSourceData.hh.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetFlatSampling()

G4bool G4GeneralParticleSourceData::GetFlatSampling ( ) const
inline

Definition at line 87 of file G4GeneralParticleSourceData.hh.

Here is the caller graph for this function:

◆ GetIntensity()

G4double G4GeneralParticleSourceData::GetIntensity ( G4int  idx) const
inline

Definition at line 81 of file G4GeneralParticleSourceData.hh.

81 {return sourceIntensity.at(idx);}
Here is the caller graph for this function:

◆ GetIntensityVectorSize()

G4int G4GeneralParticleSourceData::GetIntensityVectorSize ( ) const
inline

Definition at line 80 of file G4GeneralParticleSourceData.hh.

80 {return G4int(sourceIntensity.size());}
int G4int
Definition: G4Types.hh:78
Here is the caller graph for this function:

◆ GetMultipleVertex()

G4bool G4GeneralParticleSourceData::GetMultipleVertex ( ) const
inline

Definition at line 90 of file G4GeneralParticleSourceData.hh.

Here is the caller graph for this function:

◆ GetSourceProbability()

G4double G4GeneralParticleSourceData::GetSourceProbability ( G4int  idx) const
inline

Definition at line 82 of file G4GeneralParticleSourceData.hh.

82 {return sourceProbability.at(idx);}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetSourceVectorSize()

G4int G4GeneralParticleSourceData::GetSourceVectorSize ( ) const
inline

Definition at line 79 of file G4GeneralParticleSourceData.hh.

79 {return G4int(sourceVector.size());}
int G4int
Definition: G4Types.hh:78
std::vector< G4SingleParticleSource * > sourceVector
Here is the caller graph for this function:

◆ Instance()

G4GeneralParticleSourceData * G4GeneralParticleSourceData::Instance ( void  )
static

Definition at line 92 of file G4GeneralParticleSourceData.cc.

93 {
94  G4AutoLock lock(&singMutex);
96  return &instance;
97 }
static MCTruthManager * instance
Here is the caller graph for this function:

◆ IntensityNormalise()

void G4GeneralParticleSourceData::IntensityNormalise ( )

Definition at line 99 of file G4GeneralParticleSourceData.cc.

100 {
101  G4double total = 0.;
102  size_t i = 0 ;
103  for (i = 0; i < sourceIntensity.size(); i++)
104  {
105  total += sourceIntensity[i] ;
106  }
107  sourceProbability.clear();
108  std::vector <G4double> sourceNormalizedIntensity;
109  sourceNormalizedIntensity.clear();
110 
111  sourceNormalizedIntensity.push_back(sourceIntensity[0]/total);
112  sourceProbability.push_back(sourceNormalizedIntensity[0]);
113 
114  for ( i = 1 ; i < sourceIntensity.size(); i++)
115  {
116  sourceNormalizedIntensity.push_back(sourceIntensity[i]/total);
117  sourceProbability.push_back(sourceNormalizedIntensity[i] + sourceProbability[i-1]);
118  }
119 
120  // set source weights here based on sampling scheme (analog/flat) and intensities
121  for ( i = 0 ; i < sourceIntensity.size(); i++)
122  {
123  if (!flat_sampling)
124  {
126  }
127  else
128  {
129  this->GetCurrentSource(i)->GetBiasRndm()->SetIntensityWeight(sourceNormalizedIntensity[i]*sourceIntensity.size());
130  }
131  }
132 
133  normalised = true;
134 }
G4SingleParticleSource * GetCurrentSource() const
G4SPSRandomGenerator * GetBiasRndm() const
G4double total(Particle const *const p1, Particle const *const p2)
void SetIntensityWeight(G4double weight)
double G4double
Definition: G4Types.hh:76
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Lock()

void G4GeneralParticleSourceData::Lock ( )

Definition at line 201 of file G4GeneralParticleSourceData.cc.

202 {
203  G4MUTEXLOCK(&mutex);
204 }
#define G4MUTEXLOCK
Definition: G4Threading.hh:179
Here is the caller graph for this function:

◆ Normalised()

G4bool G4GeneralParticleSourceData::Normalised ( ) const
inline

Definition at line 74 of file G4GeneralParticleSourceData.hh.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetCurrentSourceIntensity()

void G4GeneralParticleSourceData::SetCurrentSourceIntensity ( G4double  intensity)

Definition at line 136 of file G4GeneralParticleSourceData.cc.

Here is the caller graph for this function:

◆ SetFlatSampling()

void G4GeneralParticleSourceData::SetFlatSampling ( G4bool  fSamp)
inline

Definition at line 86 of file G4GeneralParticleSourceData.hh.

Here is the caller graph for this function:

◆ SetMultipleVertex()

void G4GeneralParticleSourceData::SetMultipleVertex ( G4bool  flag)
inline

Definition at line 89 of file G4GeneralParticleSourceData.hh.

Here is the caller graph for this function:

◆ SetVerbosityAllSources()

void G4GeneralParticleSourceData::SetVerbosityAllSources ( G4int  vl)

Definition at line 184 of file G4GeneralParticleSourceData.cc.

185 {
186  for ( std::vector<G4SingleParticleSource*>::iterator it = sourceVector.begin();
187  it != sourceVector.end() ; ++it ) {
188  (*it)->SetVerbosity(vl);
189 
190  }
191 
192 }
std::vector< G4SingleParticleSource * > sourceVector
Here is the caller graph for this function:

◆ Unlock()

void G4GeneralParticleSourceData::Unlock ( )

Definition at line 206 of file G4GeneralParticleSourceData.cc.

207 {
209 }
#define G4MUTEXUNLOCK
Definition: G4Threading.hh:180
Here is the caller graph for this function:

Member Data Documentation

◆ currentSource

G4SingleParticleSource* G4GeneralParticleSourceData::currentSource
private

Definition at line 115 of file G4GeneralParticleSourceData.hh.

◆ currentSourceIdx

G4int G4GeneralParticleSourceData::currentSourceIdx
private

Definition at line 114 of file G4GeneralParticleSourceData.hh.

◆ flat_sampling

G4bool G4GeneralParticleSourceData::flat_sampling
private

Definition at line 111 of file G4GeneralParticleSourceData.hh.

◆ multiple_vertex

G4bool G4GeneralParticleSourceData::multiple_vertex
private

Definition at line 110 of file G4GeneralParticleSourceData.hh.

◆ mutex

G4Mutex G4GeneralParticleSourceData::mutex
private

Definition at line 116 of file G4GeneralParticleSourceData.hh.

◆ normalised

G4bool G4GeneralParticleSourceData::normalised
private

Definition at line 112 of file G4GeneralParticleSourceData.hh.

◆ sourceIntensity

std::vector<G4double> G4GeneralParticleSourceData::sourceIntensity
private

Definition at line 107 of file G4GeneralParticleSourceData.hh.

◆ sourceProbability

std::vector<G4double> G4GeneralParticleSourceData::sourceProbability
private

Definition at line 108 of file G4GeneralParticleSourceData.hh.

◆ sourceVector

std::vector<G4SingleParticleSource*> G4GeneralParticleSourceData::sourceVector
private

Definition at line 106 of file G4GeneralParticleSourceData.hh.


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