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

#include <G4GeneralParticleSourceData.hh>

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 ()
 

Detailed Description

Definition at line 56 of file G4GeneralParticleSourceData.hh.

Member Function Documentation

◆ AddASource()

void G4GeneralParticleSourceData::AddASource ( G4double  intensity)

Definition at line 115 of file G4GeneralParticleSourceData.cc.

116{
117 currentSource = new G4SingleParticleSource();
118 sourceVector.push_back(currentSource);
119 sourceIntensity.push_back(intensity);
120 currentSourceIdx = G4int(sourceVector.size() - 1);
121 normalised = false;
122}
int G4int
Definition: G4Types.hh:85

Referenced by G4GeneralParticleSource::AddaSource().

◆ ClearSources()

void G4GeneralParticleSourceData::ClearSources ( )

Definition at line 145 of file G4GeneralParticleSourceData.cc.

146{
147 currentSourceIdx = -1;
148 currentSource = nullptr;
149 for (const auto it : sourceVector)
150 {
151 delete it;
152 }
153 sourceVector.clear();
154 sourceIntensity.clear();
155 normalised = false;
156}

Referenced by G4GeneralParticleSource::ClearAll().

◆ DeleteASource()

void G4GeneralParticleSourceData::DeleteASource ( G4int  idx)

Definition at line 124 of file G4GeneralParticleSourceData.cc.

125{
126 delete sourceVector[idx];
127 sourceVector.erase(sourceVector.begin() + idx);
128 sourceIntensity.erase(sourceIntensity.begin()+idx);
129 normalised = false ;
130 if (currentSourceIdx == idx )
131 {
132 if ( GetIntensityVectorSize() > 0 )
133 {
134 currentSource = GetCurrentSource(0);
135 currentSourceIdx = 0;
136 }
137 else
138 {
139 currentSource = nullptr;
140 currentSourceIdx = -1;
141 }
142 }
143}
G4SingleParticleSource * GetCurrentSource() const

Referenced by G4GeneralParticleSource::DeleteaSource().

◆ GetCurrentSource() [1/2]

G4SingleParticleSource * G4GeneralParticleSourceData::GetCurrentSource ( ) const
inline

Definition at line 72 of file G4GeneralParticleSourceData.hh.

73 { return currentSource; }

Referenced by DeleteASource(), and IntensityNormalise().

◆ GetCurrentSource() [2/2]

◆ GetCurrentSourceIdx()

G4int G4GeneralParticleSourceData::GetCurrentSourceIdx ( ) const
inline

Definition at line 96 of file G4GeneralParticleSourceData.hh.

97 { return currentSourceIdx; }

Referenced by G4GeneralParticleSource::GetCurrentSourceIndex(), and G4GeneralParticleSource::ListSource().

◆ GetFlatSampling()

G4bool G4GeneralParticleSourceData::GetFlatSampling ( ) const
inline

Definition at line 88 of file G4GeneralParticleSourceData.hh.

89 { return flat_sampling; }

Referenced by G4GeneralParticleSource::GeneratePrimaryVertex(), and G4GeneralParticleSource::ListSource().

◆ GetIntensity()

G4double G4GeneralParticleSourceData::GetIntensity ( G4int  idx) const
inline

Definition at line 79 of file G4GeneralParticleSourceData.hh.

80 { return sourceIntensity.at(idx); }

Referenced by G4GeneralParticleSource::GetCurrentSourceIntensity(), and G4GeneralParticleSource::ListSource().

◆ GetIntensityVectorSize()

G4int G4GeneralParticleSourceData::GetIntensityVectorSize ( ) const
inline

◆ GetMultipleVertex()

G4bool G4GeneralParticleSourceData::GetMultipleVertex ( ) const
inline

Definition at line 93 of file G4GeneralParticleSourceData.hh.

94 { return multiple_vertex; }

Referenced by G4GeneralParticleSource::GeneratePrimaryVertex(), and G4GeneralParticleSource::ListSource().

◆ GetSourceProbability()

G4double G4GeneralParticleSourceData::GetSourceProbability ( G4int  idx) const
inline

Definition at line 81 of file G4GeneralParticleSourceData.hh.

82 { return sourceProbability.at(idx); }

Referenced by G4GeneralParticleSource::GeneratePrimaryVertex().

◆ GetSourceVectorSize()

G4int G4GeneralParticleSourceData::GetSourceVectorSize ( ) const
inline

Definition at line 75 of file G4GeneralParticleSourceData.hh.

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

Referenced by G4GPSModel::DescribeYourselfTo(), and G4GeneralParticleSource::GetNumberofSource().

◆ Instance()

G4GeneralParticleSourceData * G4GeneralParticleSourceData::Instance ( )
static

◆ IntensityNormalise()

void G4GeneralParticleSourceData::IntensityNormalise ( )

Definition at line 70 of file G4GeneralParticleSourceData.cc.

71{
72 G4double total = 0.;
73 std::size_t i = 0 ;
74 for (i = 0; i < sourceIntensity.size(); ++i)
75 {
76 total += sourceIntensity[i] ;
77 }
78 sourceProbability.clear();
79 std::vector <G4double> sourceNormalizedIntensity;
80 sourceNormalizedIntensity.clear();
81
82 sourceNormalizedIntensity.push_back(sourceIntensity[0]/total);
83 sourceProbability.push_back(sourceNormalizedIntensity[0]);
84
85 for (i = 1 ; i < sourceIntensity.size(); ++i)
86 {
87 sourceNormalizedIntensity.push_back(sourceIntensity[i]/total);
88 sourceProbability.push_back(sourceNormalizedIntensity[i]+sourceProbability[i-1]);
89 }
90
91 // set source weights here based on sampling scheme (analog/flat)
92 // and intensities
93 //
94 for (i = 0 ; i < sourceIntensity.size(); ++i)
95 {
96 if (!flat_sampling)
97 {
99 }
100 else
101 {
103 ->SetIntensityWeight(sourceNormalizedIntensity[i]*sourceIntensity.size());
104 }
105 }
106 normalised = true;
107}
double G4double
Definition: G4Types.hh:83
void SetIntensityWeight(G4double weight)
G4SPSRandomGenerator * GetBiasRndm() const
G4double total(Particle const *const p1, Particle const *const p2)

◆ Lock()

void G4GeneralParticleSourceData::Lock ( )

◆ Normalised()

◆ SetCurrentSourceIntensity()

void G4GeneralParticleSourceData::SetCurrentSourceIntensity ( G4double  intensity)

Definition at line 109 of file G4GeneralParticleSourceData.cc.

110{
111 sourceIntensity.at(currentSourceIdx) = intensity;
112 normalised = false;
113}

Referenced by G4GeneralParticleSource::SetCurrentSourceIntensity().

◆ SetFlatSampling()

void G4GeneralParticleSourceData::SetFlatSampling ( G4bool  fSamp)
inline

Definition at line 86 of file G4GeneralParticleSourceData.hh.

87 { flat_sampling = fSamp; }

Referenced by G4GeneralParticleSource::SetFlatSampling().

◆ SetMultipleVertex()

void G4GeneralParticleSourceData::SetMultipleVertex ( G4bool  flag)
inline

Definition at line 91 of file G4GeneralParticleSourceData.hh.

92 { multiple_vertex = flag; }

Referenced by G4GeneralParticleSource::SetMultipleVertex().

◆ SetVerbosityAllSources()

void G4GeneralParticleSourceData::SetVerbosityAllSources ( G4int  vl)

Definition at line 158 of file G4GeneralParticleSourceData.cc.

159{
160 for (const auto it : sourceVector)
161 {
162 it->SetVerbosity(vl);
163 }
164}

Referenced by G4GeneralParticleSource::SetVerbosity().

◆ Unlock()

void G4GeneralParticleSourceData::Unlock ( )

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