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

#include <G4SPSEneDistribution.hh>

Public Member Functions

 G4SPSEneDistribution ()
 
 ~G4SPSEneDistribution ()
 
void SetEnergyDisType (G4String)
 
G4String GetEnergyDisType ()
 
void SetEmin (G4double)
 
G4double GetEmin ()
 
G4double GetArbEmin ()
 
void SetEmax (G4double)
 
G4double GetEmax ()
 
G4double GetArbEmax ()
 
void SetMonoEnergy (G4double)
 
void SetAlpha (G4double)
 
void SetBiasAlpha (G4double)
 
void SetTemp (G4double)
 
void SetBeamSigmaInE (G4double)
 
void SetEzero (G4double)
 
void SetGradient (G4double)
 
void SetInterCept (G4double)
 
void UserEnergyHisto (G4ThreeVector)
 
void ArbEnergyHisto (G4ThreeVector)
 
void ArbEnergyHistoFile (G4String)
 
void EpnEnergyHisto (G4ThreeVector)
 
void InputEnergySpectra (G4bool)
 
void InputDifferentialSpectra (G4bool)
 
void ArbInterpolate (G4String)
 
G4String GetIntType ()
 
void Calculate ()
 
void SetBiasRndm (G4SPSRandomGenerator *a)
 
void ReSetHist (G4String)
 
void SetVerbosity (G4int a)
 
G4double GetWeight ()
 
G4double GetMonoEnergy ()
 
G4double GetSE ()
 
G4double Getalpha ()
 
G4double GetEzero ()
 
G4double GetTemp ()
 
G4double Getgrad ()
 
G4double Getcept ()
 
G4PhysicsOrderedFreeVector GetUserDefinedEnergyHisto ()
 
G4PhysicsOrderedFreeVector GetArbEnergyHisto ()
 
G4double GenerateOne (G4ParticleDefinition *)
 
G4double GetProbability (G4double)
 

Detailed Description

Definition at line 146 of file G4SPSEneDistribution.hh.

Constructor & Destructor Documentation

◆ G4SPSEneDistribution()

G4SPSEneDistribution::G4SPSEneDistribution ( )

Definition at line 53 of file G4SPSEneDistribution.cc.

54 : particle_definition(0), eneRndm(0), Splinetemp(0)
55{
56 //
57 // Initialise all variables
58 particle_energy = 1.0 * MeV;
59
60 EnergyDisType = "Mono";
61 weight = 1.;
62 MonoEnergy = 1 * MeV;
63 Emin = 0.;
64 Emax = 1.e30;
65 alpha = 0.;
66 biasalpha = 0.;
67 prob_norm = 1.0;
68 Ezero = 0.;
69 SE = 0.;
70 Temp = 0.;
71 grad = 0.;
72 cept = 0.;
73 Biased = false; // not biased
74 EnergySpec = true; // true - energy spectra, false - momentum spectra
75 DiffSpec = true; // true - differential spec, false integral spec
76 IntType = "NULL"; // Interpolation type
77 IPDFEnergyExist = false;
78 IPDFArbExist = false;
79
80 ArbEmin = 0.;
81 ArbEmax = 1.e30;
82
83 verbosityLevel = 0;
84
85}

◆ ~G4SPSEneDistribution()

G4SPSEneDistribution::~G4SPSEneDistribution ( )

Definition at line 87 of file G4SPSEneDistribution.cc.

87 {
88}

Member Function Documentation

◆ ArbEnergyHisto()

void G4SPSEneDistribution::ArbEnergyHisto ( G4ThreeVector  input)

Definition at line 157 of file G4SPSEneDistribution.cc.

157 {
158 G4double ehi, val;
159 ehi = input.x();
160 val = input.y();
161 if (verbosityLevel > 1) {
162 G4cout << "In ArbEnergyHisto" << G4endl;
163 G4cout << " " << ehi << " " << val << G4endl;
164 }
165 ArbEnergyH.InsertValues(ehi, val);
166}
double G4double
Definition: G4Types.hh:64
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cout
double x() const
double y() const
void InsertValues(G4double energy, G4double value)

Referenced by G4GeneralParticleSourceMessenger::SetNewValue().

◆ ArbEnergyHistoFile()

void G4SPSEneDistribution::ArbEnergyHistoFile ( G4String  filename)

Definition at line 168 of file G4SPSEneDistribution.cc.

168 {
169 std::ifstream infile(filename, std::ios::in);
170 if (!infile)
171 G4Exception("G4SPSEneDistribution::ArbEnergyHistoFile",
172 "Event0301",FatalException,
173 "Unable to open the histo ASCII file");
174 G4double ehi, val;
175 while (infile >> ehi >> val) {
176 ArbEnergyH.InsertValues(ehi, val);
177 }
178}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41

Referenced by G4GeneralParticleSourceMessenger::SetNewValue().

◆ ArbInterpolate()

void G4SPSEneDistribution::ArbInterpolate ( G4String  IType)

Definition at line 295 of file G4SPSEneDistribution.cc.

295 {
296 if (EnergyDisType != "Arb")
297 G4cout << "Error: this is for arbitrary distributions" << G4endl;
298 IntType = IType;
299 ArbEmax = ArbEnergyH.GetMaxLowEdgeEnergy();
300 ArbEmin = ArbEnergyH.GetMinLowEdgeEnergy();
301
302 // Now interpolate points
303 if (IntType == "Lin")
304 LinearInterpolation();
305 if (IntType == "Log")
306 LogInterpolation();
307 if (IntType == "Exp")
308 ExpInterpolation();
309 if (IntType == "Spline")
310 SplineInterpolation();
311}

Referenced by G4GeneralParticleSourceMessenger::SetNewValue().

◆ Calculate()

void G4SPSEneDistribution::Calculate ( )

Definition at line 193 of file G4SPSEneDistribution.cc.

193 {
194 if (EnergyDisType == "Cdg")
195 CalculateCdgSpectrum();
196 else if (EnergyDisType == "Bbody")
197 CalculateBbodySpectrum();
198}

Referenced by G4GeneralParticleSourceMessenger::SetNewValue().

◆ EpnEnergyHisto()

void G4SPSEneDistribution::EpnEnergyHisto ( G4ThreeVector  input)

Definition at line 180 of file G4SPSEneDistribution.cc.

180 {
181 G4double ehi, val;
182 ehi = input.x();
183 val = input.y();
184 if (verbosityLevel > 1) {
185 G4cout << "In EpnEnergyHisto" << G4endl;
186 G4cout << " " << ehi << " " << val << G4endl;
187 }
188 EpnEnergyH.InsertValues(ehi, val);
189 Emax = ehi;
190 Epnflag = true;
191}

Referenced by G4GeneralParticleSourceMessenger::SetNewValue().

◆ GenerateOne()

G4double G4SPSEneDistribution::GenerateOne ( G4ParticleDefinition a)

Definition at line 1217 of file G4SPSEneDistribution.cc.

1217 {
1218 particle_definition = a;
1219 particle_energy = -1.;
1220
1221 while ((EnergyDisType == "Arb") ? (particle_energy < ArbEmin
1222 || particle_energy > ArbEmax) : (particle_energy < Emin
1223 || particle_energy > Emax)) {
1224 if (Biased) {
1225 GenerateBiasPowEnergies();
1226 } else {
1227 if (EnergyDisType == "Mono")
1228 GenerateMonoEnergetic();
1229 else if (EnergyDisType == "Lin")
1230 GenerateLinearEnergies();
1231 else if (EnergyDisType == "Pow")
1232 GeneratePowEnergies();
1233 else if (EnergyDisType == "Exp")
1234 GenerateExpEnergies();
1235 else if (EnergyDisType == "Gauss")
1236 GenerateGaussEnergies();
1237 else if (EnergyDisType == "Brem")
1238 GenerateBremEnergies();
1239 else if (EnergyDisType == "Bbody")
1240 GenerateBbodyEnergies();
1241 else if (EnergyDisType == "Cdg")
1242 GenerateCdgEnergies();
1243 else if (EnergyDisType == "User")
1244 GenUserHistEnergies();
1245 else if (EnergyDisType == "Arb")
1246 GenArbPointEnergies();
1247 else if (EnergyDisType == "Epn")
1248 GenEpnHistEnergies();
1249 else
1250 G4cout << "Error: EnergyDisType has unusual value" << G4endl;
1251 }
1252 }
1253 return particle_energy;
1254}

Referenced by G4SingleParticleSource::GeneratePrimaryVertex().

◆ Getalpha()

G4double G4SPSEneDistribution::Getalpha ( )
inline

Definition at line 220 of file G4SPSEneDistribution.hh.

220 {
221 return alpha;
222 }

◆ GetArbEmax()

G4double G4SPSEneDistribution::GetArbEmax ( )
inline

Definition at line 170 of file G4SPSEneDistribution.hh.

170 {
171 return ArbEmax;
172 }

◆ GetArbEmin()

G4double G4SPSEneDistribution::GetArbEmin ( )
inline

Definition at line 161 of file G4SPSEneDistribution.hh.

161 {
162 return ArbEmin;
163 }

◆ GetArbEnergyHisto()

G4PhysicsOrderedFreeVector G4SPSEneDistribution::GetArbEnergyHisto ( )
inline

Definition at line 245 of file G4SPSEneDistribution.hh.

245 {
246 return ArbEnergyH;
247 }

◆ Getcept()

G4double G4SPSEneDistribution::Getcept ( )
inline

Definition at line 236 of file G4SPSEneDistribution.hh.

236 {
237 return cept;
238 }

◆ GetEmax()

G4double G4SPSEneDistribution::GetEmax ( )
inline

Definition at line 166 of file G4SPSEneDistribution.hh.

166 {
167 return Emax;
168 }

◆ GetEmin()

G4double G4SPSEneDistribution::GetEmin ( )
inline

Definition at line 157 of file G4SPSEneDistribution.hh.

157 {
158 return Emin;
159 }

◆ GetEnergyDisType()

G4String G4SPSEneDistribution::GetEnergyDisType ( )
inline

Definition at line 152 of file G4SPSEneDistribution.hh.

152 {
153 return EnergyDisType;
154 }

◆ GetEzero()

G4double G4SPSEneDistribution::GetEzero ( )
inline

Definition at line 224 of file G4SPSEneDistribution.hh.

224 {
225 return Ezero;
226 }

◆ Getgrad()

G4double G4SPSEneDistribution::Getgrad ( )
inline

Definition at line 232 of file G4SPSEneDistribution.hh.

232 {
233 return grad;
234 }

◆ GetIntType()

G4String G4SPSEneDistribution::GetIntType ( )
inline

Definition at line 190 of file G4SPSEneDistribution.hh.

190 {
191 return IntType;
192 }

◆ GetMonoEnergy()

G4double G4SPSEneDistribution::GetMonoEnergy ( )
inline

Definition at line 212 of file G4SPSEneDistribution.hh.

212 {
213 return MonoEnergy;
214 }

◆ GetProbability()

G4double G4SPSEneDistribution::GetProbability ( G4double  ene)

Definition at line 1256 of file G4SPSEneDistribution.cc.

1256 {
1257 G4double prob = 1.;
1258
1259 if (EnergyDisType == "Lin") {
1260 if (prob_norm == 1.) {
1261 prob_norm = 0.5*grad*Emax*Emax + cept*Emax - 0.5*grad*Emin*Emin - cept*Emin;
1262 }
1263 prob = cept + grad * ene;
1264 prob /= prob_norm;
1265 }
1266 else if (EnergyDisType == "Pow") {
1267 if (prob_norm == 1.) {
1268 if (alpha != -1.) {
1269 G4double emina = std::pow(Emin, alpha + 1);
1270 G4double emaxa = std::pow(Emax, alpha + 1);
1271 prob_norm = 1./(1.+alpha) * (emaxa - emina);
1272 } else {
1273 prob_norm = std::log(Emax) - std::log(Emin) ;
1274 }
1275 }
1276 prob = std::pow(ene, alpha)/prob_norm;
1277 }
1278 else if (EnergyDisType == "Exp"){
1279 if (prob_norm == 1.) {
1280 prob_norm = -Ezero*(std::exp(-Emax/Ezero) - std::exp(Emin/Ezero));
1281 }
1282 prob = std::exp(-ene / Ezero);
1283 prob /= prob_norm;
1284 }
1285 else if (EnergyDisType == "Arb") {
1286 prob = ArbEnergyH.Value(ene);
1287 // prob = ArbEInt->CubicSplineInterpolation(ene);
1288 //G4double deltaY;
1289 //prob = ArbEInt->PolynomInterpolation(ene, deltaY);
1290 if (prob <= 0.) {
1291 //G4cout << " Warning:G4SPSEneDistribution::GetProbability: prob<= 0. "<<prob <<" "<<ene << " " <<deltaY<< G4endl;
1292 G4cout << " Warning:G4SPSEneDistribution::GetProbability: prob<= 0. "<<prob <<" "<<ene << G4endl;
1293 prob = 1e-30;
1294 }
1295 // already normalised
1296 }
1297 else
1298 G4cout << "Error: EnergyDisType not supported" << G4endl;
1299
1300 return prob;
1301}
G4double Value(G4double theEnergy)

◆ GetSE()

G4double G4SPSEneDistribution::GetSE ( )
inline

Definition at line 216 of file G4SPSEneDistribution.hh.

216 {
217 return SE;
218 }

◆ GetTemp()

G4double G4SPSEneDistribution::GetTemp ( )
inline

Definition at line 228 of file G4SPSEneDistribution.hh.

228 {
229 return Temp;
230 }

◆ GetUserDefinedEnergyHisto()

G4PhysicsOrderedFreeVector G4SPSEneDistribution::GetUserDefinedEnergyHisto ( )
inline

Definition at line 241 of file G4SPSEneDistribution.hh.

241 {
242 return UDefEnergyH;
243 }

◆ GetWeight()

G4double G4SPSEneDistribution::GetWeight ( )
inline

Definition at line 208 of file G4SPSEneDistribution.hh.

208 {
209 return weight;
210 }

Referenced by G4SingleParticleSource::GeneratePrimaryVertex().

◆ InputDifferentialSpectra()

void G4SPSEneDistribution::InputDifferentialSpectra ( G4bool  value)

Definition at line 288 of file G4SPSEneDistribution.cc.

288 {
289 // Allows user to specify integral or differential spectra
290 DiffSpec = value; // true = differential, false = integral
291 if (verbosityLevel > 1)
292 G4cout << "Diffspec has value " << DiffSpec << G4endl;
293}

Referenced by G4GeneralParticleSourceMessenger::SetNewValue().

◆ InputEnergySpectra()

void G4SPSEneDistribution::InputEnergySpectra ( G4bool  value)

Definition at line 281 of file G4SPSEneDistribution.cc.

281 {
282 // Allows user to specifiy spectrum is momentum
283 EnergySpec = value; // false if momentum
284 if (verbosityLevel > 1)
285 G4cout << "EnergySpec has value " << EnergySpec << G4endl;
286}

Referenced by G4GeneralParticleSourceMessenger::SetNewValue().

◆ ReSetHist()

void G4SPSEneDistribution::ReSetHist ( G4String  atype)

Definition at line 1199 of file G4SPSEneDistribution.cc.

1199 {
1200 if (atype == "energy") {
1201 UDefEnergyH = IPDFEnergyH = ZeroPhysVector;
1202 IPDFEnergyExist = false;
1203 Emin = 0.;
1204 Emax = 1e30;
1205 } else if (atype == "arb") {
1206 ArbEnergyH = IPDFArbEnergyH = ZeroPhysVector;
1207 IPDFArbExist = false;
1208 } else if (atype == "epn") {
1209 UDefEnergyH = IPDFEnergyH = ZeroPhysVector;
1210 IPDFEnergyExist = false;
1211 EpnEnergyH = ZeroPhysVector;
1212 } else {
1213 G4cout << "Error, histtype not accepted " << G4endl;
1214 }
1215}

Referenced by G4GeneralParticleSourceMessenger::SetNewValue().

◆ SetAlpha()

void G4SPSEneDistribution::SetAlpha ( G4double  alp)

◆ SetBeamSigmaInE()

void G4SPSEneDistribution::SetBeamSigmaInE ( G4double  e)

Definition at line 117 of file G4SPSEneDistribution.cc.

117 {
118 SE = e;
119}

Referenced by G4GeneralParticleSourceMessenger::SetNewValue().

◆ SetBiasAlpha()

void G4SPSEneDistribution::SetBiasAlpha ( G4double  alp)

Definition at line 124 of file G4SPSEneDistribution.cc.

124 {
125 biasalpha = alp;
126 Biased = true;
127}

Referenced by G4GeneralParticleSourceMessenger::SetNewValue().

◆ SetBiasRndm()

void G4SPSEneDistribution::SetBiasRndm ( G4SPSRandomGenerator a)
inline

Definition at line 196 of file G4SPSEneDistribution.hh.

196 {
197 eneRndm = a;
198 }

Referenced by G4SingleParticleSource::G4SingleParticleSource().

◆ SetEmax()

void G4SPSEneDistribution::SetEmax ( G4double  ema)

◆ SetEmin()

void G4SPSEneDistribution::SetEmin ( G4double  emi)

◆ SetEnergyDisType()

void G4SPSEneDistribution::SetEnergyDisType ( G4String  DisType)

Definition at line 90 of file G4SPSEneDistribution.cc.

90 {
91 EnergyDisType = DisType;
92 if (EnergyDisType == "User") {
93 UDefEnergyH = IPDFEnergyH = ZeroPhysVector;
94 IPDFEnergyExist = false;
95 } else if (EnergyDisType == "Arb") {
96 ArbEnergyH = IPDFArbEnergyH = ZeroPhysVector;
97 IPDFArbExist = false;
98 } else if (EnergyDisType == "Epn") {
99 UDefEnergyH = IPDFEnergyH = ZeroPhysVector;
100 IPDFEnergyExist = false;
101 EpnEnergyH = ZeroPhysVector;
102 }
103}

Referenced by G4AdjointPrimaryGenerator::G4AdjointPrimaryGenerator(), and G4GeneralParticleSourceMessenger::SetNewValue().

◆ SetEzero()

void G4SPSEneDistribution::SetEzero ( G4double  eze)

Definition at line 133 of file G4SPSEneDistribution.cc.

133 {
134 Ezero = eze;
135}

Referenced by G4GeneralParticleSourceMessenger::SetNewValue().

◆ SetGradient()

void G4SPSEneDistribution::SetGradient ( G4double  gr)

Definition at line 137 of file G4SPSEneDistribution.cc.

137 {
138 grad = gr;
139}

Referenced by G4GeneralParticleSourceMessenger::SetNewValue().

◆ SetInterCept()

void G4SPSEneDistribution::SetInterCept ( G4double  c)

Definition at line 141 of file G4SPSEneDistribution.cc.

141 {
142 cept = c;
143}

Referenced by G4GeneralParticleSourceMessenger::SetNewValue().

◆ SetMonoEnergy()

void G4SPSEneDistribution::SetMonoEnergy ( G4double  menergy)

Definition at line 113 of file G4SPSEneDistribution.cc.

113 {
114 MonoEnergy = menergy;
115}

Referenced by G4GeneralParticleSourceMessenger::SetNewValue().

◆ SetTemp()

void G4SPSEneDistribution::SetTemp ( G4double  tem)

Definition at line 129 of file G4SPSEneDistribution.cc.

129 {
130 Temp = tem;
131}

Referenced by G4GeneralParticleSourceMessenger::SetNewValue().

◆ SetVerbosity()

void G4SPSEneDistribution::SetVerbosity ( G4int  a)
inline

Definition at line 203 of file G4SPSEneDistribution.hh.

203 {
204 verbosityLevel = a;
205 }

Referenced by G4SingleParticleSource::SetVerbosity().

◆ UserEnergyHisto()

void G4SPSEneDistribution::UserEnergyHisto ( G4ThreeVector  input)

Definition at line 145 of file G4SPSEneDistribution.cc.

145 {
146 G4double ehi, val;
147 ehi = input.x();
148 val = input.y();
149 if (verbosityLevel > 1) {
150 G4cout << "In UserEnergyHisto" << G4endl;
151 G4cout << " " << ehi << " " << val << G4endl;
152 }
153 UDefEnergyH.InsertValues(ehi, val);
154 Emax = ehi;
155}

Referenced by G4GeneralParticleSourceMessenger::SetNewValue().


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