Geant4  10.02.p03
G4SPSAngDistribution Class Reference

#include <G4SPSAngDistribution.hh>

Collaboration diagram for G4SPSAngDistribution:

Public Member Functions

 G4SPSAngDistribution ()
 
 ~G4SPSAngDistribution ()
 
void SetAngDistType (G4String)
 
void DefineAngRefAxes (G4String, G4ThreeVector)
 
void SetMinTheta (G4double)
 
void SetMinPhi (G4double)
 
void SetMaxTheta (G4double)
 
void SetMaxPhi (G4double)
 
void SetBeamSigmaInAngR (G4double)
 
void SetBeamSigmaInAngX (G4double)
 
void SetBeamSigmaInAngY (G4double)
 
void UserDefAngTheta (G4ThreeVector)
 
void UserDefAngPhi (G4ThreeVector)
 
void SetFocusPoint (G4ThreeVector)
 
void SetParticleMomentumDirection (G4ParticleMomentum aMomentumDirection)
 
void SetUseUserAngAxis (G4bool)
 
void SetUserWRTSurface (G4bool)
 
void SetPosDistribution (G4SPSPosDistribution *a)
 
void SetBiasRndm (G4SPSRandomGenerator *a)
 
void ReSetHist (G4String)
 
void SetVerbosity (G4int a)
 
G4String GetDistType ()
 
G4double GetMinTheta ()
 
G4double GetMaxTheta ()
 
G4double GetMinPhi ()
 
G4double GetMaxPhi ()
 
G4ThreeVector GetDirection ()
 
G4ParticleMomentum GenerateOne ()
 

Private Member Functions

void GenerateFocusedFlux (G4ParticleMomentum &outputMom)
 
void GenerateIsotropicFlux (G4ParticleMomentum &outputMom)
 
void GenerateCosineLawFlux (G4ParticleMomentum &outputMom)
 
void GenerateBeamFlux (G4ParticleMomentum &outputMom)
 
void GeneratePlanarFlux (G4ParticleMomentum &outputMom)
 
void GenerateUserDefFlux (G4ParticleMomentum &outputMom)
 
G4double GenerateUserDefTheta ()
 
G4double GenerateUserDefPhi ()
 

Private Attributes

G4String AngDistType
 
G4ThreeVector AngRef1
 
G4ThreeVector AngRef2
 
G4ThreeVector AngRef3
 
G4double MinTheta
 
G4double MaxTheta
 
G4double MinPhi
 
G4double MaxPhi
 
G4double DR
 
G4double DX
 
G4double DY
 
G4double Theta
 
G4double Phi
 
G4ThreeVector FocusPoint
 
G4bool IPDFThetaExist
 
G4bool IPDFPhiExist
 
G4PhysicsOrderedFreeVector UDefThetaH
 
G4PhysicsOrderedFreeVector IPDFThetaH
 
G4PhysicsOrderedFreeVector UDefPhiH
 
G4PhysicsOrderedFreeVector IPDFPhiH
 
G4String UserDistType
 
G4bool UserWRTSurface
 
G4bool UserAngRef
 
G4ParticleMomentum particle_momentum_direction
 
G4SPSPosDistributionposDist
 
G4SPSRandomGeneratorangRndm
 
G4int verbosityLevel
 
G4PhysicsOrderedFreeVector ZeroPhysVector
 
G4Mutex mutex
 

Detailed Description

Andrea Dotti Feb 2015 Important: This is a shared class between threads. Only one thread should use the set-methods here. Note that this is exactly what is achieved using UI commands. If you use the set methods to set defaults in your application take care that only one thread is executing them. In addition take care of calling these methods before the run is started Do not use these setters during the event loop

Definition at line 174 of file G4SPSAngDistribution.hh.

Constructor & Destructor Documentation

◆ G4SPSAngDistribution()

G4SPSAngDistribution::G4SPSAngDistribution ( )

Definition at line 55 of file G4SPSAngDistribution.cc.

56  : Theta(0.), Phi(0.), posDist(0),angRndm(0)
57 {
58  // Angular distribution Variables
59  G4ThreeVector zero;
61 
62  AngDistType = "planar";
66  MinTheta = 0.;
67  MaxTheta = pi;
68  MinPhi = 0.;
69  MaxPhi = twopi;
70  DR = 0.;
71  DX = 0.;
72  DY = 0.;
73  FocusPoint = G4ThreeVector(0., 0., 0.);
74  UserDistType = "NULL";
75  UserWRTSurface = true;
76  UserAngRef = false;
77  IPDFThetaExist = false;
78  IPDFPhiExist = false;
79  verbosityLevel = 0 ;
80 
82 }
DLL_API const Hep3Vector HepZHat
CLHEP::Hep3Vector G4ThreeVector
#define G4MUTEXINIT(mutex)
Definition: G4Threading.hh:177
G4SPSPosDistribution * posDist
G4SPSRandomGenerator * angRndm
G4ParticleMomentum particle_momentum_direction
static const double twopi
Definition: G4SIunits.hh:75
DLL_API const Hep3Vector HepYHat
static const double pi
Definition: G4SIunits.hh:74
DLL_API const Hep3Vector HepXHat
G4ThreeVector G4ParticleMomentum

◆ ~G4SPSAngDistribution()

G4SPSAngDistribution::~G4SPSAngDistribution ( )

Definition at line 84 of file G4SPSAngDistribution.cc.

85 {
87 }
#define G4MUTEXDESTROY(mutex)
Definition: G4Threading.hh:178

Member Function Documentation

◆ DefineAngRefAxes()

void G4SPSAngDistribution::DefineAngRefAxes ( G4String  refname,
G4ThreeVector  ref 
)

Definition at line 107 of file G4SPSAngDistribution.cc.

108 {
109  G4AutoLock l(&mutex);
110  if(refname == "angref1")
111  AngRef1 = ref.unit(); // x'
112  else if(refname == "angref2")
113  AngRef2 = ref.unit(); // vector in x'y' plane
114 
115  // User defines x' (AngRef1) and a vector in the x'y'
116  // plane (AngRef2). Then, AngRef1 x AngRef2 = AngRef3
117  // the z' vector. Then, AngRef3 x AngRef1 = AngRef2
118  // which will now be y'.
119 
120  AngRef3 = AngRef1.cross(AngRef2); // z'
121  AngRef2 = AngRef3.cross(AngRef1); // y'
122  UserAngRef = true ;
123  if(verbosityLevel == 2)
124  {
125  G4cout << "Angular distribution rotation axes " << AngRef1 << " " << AngRef2 << " " << AngRef3 << G4endl;
126  }
127 }
G4GLOB_DLL std::ostream G4cout
Hep3Vector cross(const Hep3Vector &) const
Hep3Vector unit() const
#define G4endl
Definition: G4ios.hh:61
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GenerateBeamFlux()

void G4SPSAngDistribution::GenerateBeamFlux ( G4ParticleMomentum outputMom)
private

Definition at line 255 of file G4SPSAngDistribution.cc.

256 {
257  G4double theta, phi;
258  G4double px, py, pz;
259  if (AngDistType == "beam1d")
260  {
261  theta = G4RandGauss::shoot(0.0,DR);
262  phi = twopi * G4UniformRand();
263  }
264  else
265  {
266  px = G4RandGauss::shoot(0.0,DX);
267  py = G4RandGauss::shoot(0.0,DY);
268  theta = std::sqrt (px*px + py*py);
269  if (theta != 0.) {
270  phi = std::acos(px/theta);
271  if ( py < 0.) phi = -phi;
272  } else {
273  phi = 0.0;
274  }
275  }
276  px = -std::sin(theta) * std::cos(phi);
277  py = -std::sin(theta) * std::sin(phi);
278  pz = -std::cos(theta);
279  G4double finx, finy, finz ;
280  finx = px, finy =py, finz =pz;
281  if (UserAngRef){
282  // Apply Angular Rotation Matrix
283  // x * AngRef1, y * AngRef2 and z * AngRef3
284  finx = (px * AngRef1.x()) + (py * AngRef2.x()) + (pz * AngRef3.x());
285  finy = (px * AngRef1.y()) + (py * AngRef2.y()) + (pz * AngRef3.y());
286  finz = (px * AngRef1.z()) + (py * AngRef2.z()) + (pz * AngRef3.z());
287  G4double ResMag = std::sqrt((finx*finx) + (finy*finy) + (finz*finz));
288  finx = finx/ResMag;
289  finy = finy/ResMag;
290  finz = finz/ResMag;
291  }
292  mom.setX(finx);
293  mom.setY(finy);
294  mom.setZ(finz);
295 
296  // particle_momentum_direction now holds unit momentum vector.
297  if(verbosityLevel >= 1)
298  G4cout << "Generating beam vector: " << mom << G4endl;
299 }
ThreeVector shoot(const G4int Ap, const G4int Af)
#define G4UniformRand()
Definition: Randomize.hh:97
G4GLOB_DLL std::ostream G4cout
static const double twopi
Definition: G4SIunits.hh:75
double x() const
double y() const
double z() const
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GenerateCosineLawFlux()

void G4SPSAngDistribution::GenerateCosineLawFlux ( G4ParticleMomentum outputMom)
private

Definition at line 375 of file G4SPSAngDistribution.cc.

376 {
377  // Method to generate flux distributed with a cosine law
378  G4double px, py, pz;
379  G4double rndm, rndm2;
380  //
381  G4double sintheta, sinphi,costheta,cosphi;
382  rndm = angRndm->GenRandTheta();
383  sintheta = std::sqrt( rndm * (std::sin(MaxTheta)*std::sin(MaxTheta) - std::sin(MinTheta)*std::sin(MinTheta) )
384  +std::sin(MinTheta)*std::sin(MinTheta) );
385  costheta = std::sqrt(1. -sintheta*sintheta);
386 
387  rndm2 = angRndm->GenRandPhi();
388  Phi = MinPhi + (MaxPhi - MinPhi) * rndm2;
389  sinphi = std::sin(Phi);
390  cosphi = std::cos(Phi);
391 
392  px = -sintheta * cosphi;
393  py = -sintheta * sinphi;
394  pz = -costheta;
395 
396  // for volume and ponit source use mother or user defined co-ordinates
397  // for plane and surface source user surface-normal or userdefined co-ordinates
398  //
399  G4double finx, finy, finz;
400  if (posDist->GetSourcePosType() == "Point" || posDist->GetSourcePosType() == "Volume") {
401  if (UserAngRef){
402  // Apply Rotation Matrix
403  finx = (px * AngRef1.x()) + (py * AngRef2.x()) + (pz * AngRef3.x());
404  finy = (px * AngRef1.y()) + (py * AngRef2.y()) + (pz * AngRef3.y());
405  finz = (px * AngRef1.z()) + (py * AngRef2.z()) + (pz * AngRef3.z());
406  } else {
407  finx = px;
408  finy = py;
409  finz = pz;
410  }
411  } else { // for plane and surface source
412  if (UserAngRef){
413  // Apply Rotation Matrix
414  finx = (px * AngRef1.x()) + (py * AngRef2.x()) + (pz * AngRef3.x());
415  finy = (px * AngRef1.y()) + (py * AngRef2.y()) + (pz * AngRef3.y());
416  finz = (px * AngRef1.z()) + (py * AngRef2.z()) + (pz * AngRef3.z());
417  } else {
418  finx = (px*posDist->GetSideRefVec1().x()) + (py*posDist->GetSideRefVec2().x()) + (pz*posDist->GetSideRefVec3().x());
419  finy = (px*posDist->GetSideRefVec1().y()) + (py*posDist->GetSideRefVec2().y()) + (pz*posDist->GetSideRefVec3().y());
420  finz = (px*posDist->GetSideRefVec1().z()) + (py*posDist->GetSideRefVec2().z()) + (pz*posDist->GetSideRefVec3().z());
421  }
422  }
423  G4double ResMag = std::sqrt((finx*finx) + (finy*finy) + (finz*finz));
424  finx = finx/ResMag;
425  finy = finy/ResMag;
426  finz = finz/ResMag;
427 
428  mom.setX(finx);
429  mom.setY(finy);
430  mom.setZ(finz);
431 
432  // particle_momentum_direction now contains unit momentum vector.
433  if(verbosityLevel >= 1)
434  {
435  G4cout << "Resultant cosine-law unit momentum vector " << mom << G4endl;
436  }
437 }
G4ThreeVector GetSideRefVec2() const
G4SPSPosDistribution * posDist
G4SPSRandomGenerator * angRndm
G4ThreeVector GetSideRefVec3() const
G4ThreeVector GetSideRefVec1() const
G4GLOB_DLL std::ostream G4cout
double x() const
double y() const
double z() const
G4String GetSourcePosType() const
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GenerateFocusedFlux()

void G4SPSAngDistribution::GenerateFocusedFlux ( G4ParticleMomentum outputMom)
private

Definition at line 301 of file G4SPSAngDistribution.cc.

302 {
303  mom = (FocusPoint - posDist->GetParticlePos()).unit();
304  //
305  // particle_momentum_direction now holds unit momentum vector.
306  if(verbosityLevel >= 1)
307  G4cout << "Generating focused vector: " << mom << G4endl;
308 }
G4SPSPosDistribution * posDist
G4GLOB_DLL std::ostream G4cout
G4ThreeVector GetParticlePos() const
#define G4endl
Definition: G4ios.hh:61
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GenerateIsotropicFlux()

void G4SPSAngDistribution::GenerateIsotropicFlux ( G4ParticleMomentum outputMom)
private

Definition at line 310 of file G4SPSAngDistribution.cc.

311 {
312  // generates isotropic flux.
313  // No vectors are needed.
314  G4double rndm, rndm2;
315  G4double px, py, pz;
316 
317  //
318  G4double sintheta, sinphi,costheta,cosphi;
319  rndm = angRndm->GenRandTheta();
320  costheta = std::cos(MinTheta) - rndm * (std::cos(MinTheta) - std::cos(MaxTheta));
321  sintheta = std::sqrt(1. - costheta*costheta);
322 
323  rndm2 = angRndm->GenRandPhi();
324  Phi = MinPhi + (MaxPhi - MinPhi) * rndm2;
325  sinphi = std::sin(Phi);
326  cosphi = std::cos(Phi);
327 
328  px = -sintheta * cosphi;
329  py = -sintheta * sinphi;
330  pz = -costheta;
331 
332  // for volume and ponit source use mother or user defined co-ordinates
333  // for plane and surface source user surface-normal or userdefined co-ordinates
334  //
335  G4double finx, finy, finz;
336  if (posDist->GetSourcePosType() == "Point" || posDist->GetSourcePosType() == "Volume") {
337  if (UserAngRef){
338  // Apply Rotation Matrix
339  // x * AngRef1, y * AngRef2 and z * AngRef3
340  finx = (px * AngRef1.x()) + (py * AngRef2.x()) + (pz * AngRef3.x());
341  finy = (px * AngRef1.y()) + (py * AngRef2.y()) + (pz * AngRef3.y());
342  finz = (px * AngRef1.z()) + (py * AngRef2.z()) + (pz * AngRef3.z());
343  } else {
344  finx = px;
345  finy = py;
346  finz = pz;
347  }
348  } else { // for plane and surface source
349  if (UserAngRef){
350  // Apply Rotation Matrix
351  // x * AngRef1, y * AngRef2 and z * AngRef3
352  finx = (px * AngRef1.x()) + (py * AngRef2.x()) + (pz * AngRef3.x());
353  finy = (px * AngRef1.y()) + (py * AngRef2.y()) + (pz * AngRef3.y());
354  finz = (px * AngRef1.z()) + (py * AngRef2.z()) + (pz * AngRef3.z());
355  } else {
356  finx = (px*posDist->GetSideRefVec1().x()) + (py*posDist->GetSideRefVec2().x()) + (pz*posDist->GetSideRefVec3().x());
357  finy = (px*posDist->GetSideRefVec1().y()) + (py*posDist->GetSideRefVec2().y()) + (pz*posDist->GetSideRefVec3().y());
358  finz = (px*posDist->GetSideRefVec1().z()) + (py*posDist->GetSideRefVec2().z()) + (pz*posDist->GetSideRefVec3().z());
359  }
360  }
361  G4double ResMag = std::sqrt((finx*finx) + (finy*finy) + (finz*finz));
362  finx = finx/ResMag;
363  finy = finy/ResMag;
364  finz = finz/ResMag;
365 
366  mom.setX(finx);
367  mom.setY(finy);
368  mom.setZ(finz);
369 
370  // particle_momentum_direction now holds unit momentum vector.
371  if(verbosityLevel >= 1)
372  G4cout << "Generating isotropic vector: " << mom << G4endl;
373 }
G4ThreeVector GetSideRefVec2() const
G4SPSPosDistribution * posDist
G4SPSRandomGenerator * angRndm
G4ThreeVector GetSideRefVec3() const
G4ThreeVector GetSideRefVec1() const
G4GLOB_DLL std::ostream G4cout
double x() const
double y() const
double z() const
G4String GetSourcePosType() const
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GenerateOne()

G4ParticleMomentum G4SPSAngDistribution::GenerateOne ( )

Definition at line 656 of file G4SPSAngDistribution.cc.

657 {
658  //Local copy for thread safety
660  // Angular stuff
661  if(AngDistType == "iso")
662  GenerateIsotropicFlux(localM);
663  else if(AngDistType == "cos")
664  GenerateCosineLawFlux(localM);
665  else if(AngDistType == "planar")
666  GeneratePlanarFlux(localM);
667  else if(AngDistType == "beam1d" || AngDistType == "beam2d" )
668  GenerateBeamFlux(localM);
669  else if(AngDistType == "user")
670  GenerateUserDefFlux(localM);
671  else if(AngDistType == "focused")
672  GenerateFocusedFlux(localM);
673  else
674  G4cout << "Error: AngDistType has unusual value" << G4endl;
675  return localM;
676 }
void GenerateBeamFlux(G4ParticleMomentum &outputMom)
void GenerateCosineLawFlux(G4ParticleMomentum &outputMom)
G4GLOB_DLL std::ostream G4cout
G4ParticleMomentum particle_momentum_direction
void GenerateFocusedFlux(G4ParticleMomentum &outputMom)
void GenerateUserDefFlux(G4ParticleMomentum &outputMom)
#define G4endl
Definition: G4ios.hh:61
void GenerateIsotropicFlux(G4ParticleMomentum &outputMom)
void GeneratePlanarFlux(G4ParticleMomentum &outputMom)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GeneratePlanarFlux()

void G4SPSAngDistribution::GeneratePlanarFlux ( G4ParticleMomentum outputMom)
private

Definition at line 439 of file G4SPSAngDistribution.cc.

440 {
441  // particle_momentum_direction now contains unit momentum vector.
442  // nothing need be done here as the m-directions have been set directly
443  // under this option
444  if(verbosityLevel >= 1)
445  {
446  G4cout << "Resultant Planar wave momentum vector " << mom << G4endl;
447  }
448 }
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61
Here is the caller graph for this function:

◆ GenerateUserDefFlux()

void G4SPSAngDistribution::GenerateUserDefFlux ( G4ParticleMomentum outputMom)
private

Definition at line 450 of file G4SPSAngDistribution.cc.

451 {
452  G4double rndm, px, py, pz, pmag;
453 
454  if(UserDistType == "NULL")
455  G4cout << "Error: UserDistType undefined" << G4endl;
456  else if(UserDistType == "theta") {
457  Theta = 10.;
458  while(Theta > MaxTheta || Theta < MinTheta)
460  Phi = 10.;
461  while(Phi > MaxPhi || Phi < MinPhi) {
462  rndm = angRndm->GenRandPhi();
463  Phi = twopi * rndm;
464  }
465  }
466  else if(UserDistType == "phi") {
467  Theta = 10.;
468  while(Theta > MaxTheta || Theta < MinTheta)
469  {
470  rndm = angRndm->GenRandTheta();
471  Theta = std::acos(1. - (2. * rndm));
472  }
473  Phi = 10.;
474  while(Phi > MaxPhi || Phi < MinPhi)
476  }
477  else if(UserDistType == "both")
478  {
479  Theta = 10.;
480  while(Theta > MaxTheta || Theta < MinTheta)
482  Phi = 10.;
483  while(Phi > MaxPhi || Phi < MinPhi)
485  }
486  px = -std::sin(Theta) * std::cos(Phi);
487  py = -std::sin(Theta) * std::sin(Phi);
488  pz = -std::cos(Theta);
489 
490  pmag = std::sqrt((px*px) + (py*py) + (pz*pz));
491 
492  if(!UserWRTSurface) {
493  G4double finx, finy, finz;
494  if (UserAngRef) {
495  // Apply Rotation Matrix
496  // x * AngRef1, y * AngRef2 and z * AngRef3
497  finx = (px * AngRef1.x()) + (py * AngRef2.x()) + (pz * AngRef3.x());
498  finy = (px * AngRef1.y()) + (py * AngRef2.y()) + (pz * AngRef3.y());
499  finz = (px * AngRef1.z()) + (py * AngRef2.z()) + (pz * AngRef3.z());
500  } else { // use mother co-ordinates
501  finx = px;
502  finy = py;
503  finz = pz;
504  }
505  G4double ResMag = std::sqrt((finx*finx) + (finy*finy) + (finz*finz));
506  finx = finx/ResMag;
507  finy = finy/ResMag;
508  finz = finz/ResMag;
509 
510  mom.setX(finx);
511  mom.setY(finy);
512  mom.setZ(finz);
513  }
514  else { // UserWRTSurface = true
515  G4double pxh = px/pmag;
516  G4double pyh = py/pmag;
517  G4double pzh = pz/pmag;
518  if(verbosityLevel > 1) {
520  G4cout <<"Raw Unit vector "<<pxh<<","<<pyh<<","<<pzh<<G4endl;
521  }
522  G4double resultx = (pxh*posDist->GetSideRefVec1().x()) + (pyh*posDist->GetSideRefVec2().x()) +
523  (pzh*posDist->GetSideRefVec3().x());
524 
525  G4double resulty = (pxh*posDist->GetSideRefVec1().y()) + (pyh*posDist->GetSideRefVec2().y()) +
526  (pzh*posDist->GetSideRefVec3().y());
527 
528  G4double resultz = (pxh*posDist->GetSideRefVec1().z()) + (pyh*posDist->GetSideRefVec2().z()) +
529  (pzh*posDist->GetSideRefVec3().z());
530 
531  G4double ResMag = std::sqrt((resultx*resultx) + (resulty*resulty) + (resultz*resultz));
532  resultx = resultx/ResMag;
533  resulty = resulty/ResMag;
534  resultz = resultz/ResMag;
535 
536  mom.setX(resultx);
537  mom.setY(resulty);
538  mom.setZ(resultz);
539  }
540 
541  // particle_momentum_direction now contains unit momentum vector.
542  if(verbosityLevel > 0 )
543  {
544  G4cout << "Final User Defined momentum vector " << particle_momentum_direction << G4endl;
545  }
546 }
G4ThreeVector GetSideRefVec2() const
G4SPSPosDistribution * posDist
G4SPSRandomGenerator * angRndm
G4ThreeVector GetSideRefVec3() const
G4ThreeVector GetSideRefVec1() const
G4GLOB_DLL std::ostream G4cout
G4ParticleMomentum particle_momentum_direction
static const double twopi
Definition: G4SIunits.hh:75
double x() const
double y() const
double z() const
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GenerateUserDefPhi()

G4double G4SPSAngDistribution::GenerateUserDefPhi ( )
private

Definition at line 594 of file G4SPSAngDistribution.cc.

595 {
596  // Create cumulative histogram if not already done so. Then use RandFlat
597  //::shoot to generate the output Theta value.
598 
599  if(UserDistType == "NULL" || UserDistType == "theta")
600  {
601  // No user defined phi distribution
602  G4cout << "Error ***********************" << G4endl;
603  G4cout << "UserDistType = " << UserDistType << G4endl;
604  return(0.);
605  }
606  else
607  {
608  // UserDistType = phi or both and so a phi distribution
609  // is defined. This should be integrated if not already done.
610  G4AutoLock l(&mutex);
611  if(IPDFPhiExist == false)
612  {
613  // IPDF has not been created, so create it
614  G4double bins[1024],vals[1024], sum;
615  G4int ii;
616  G4int maxbin = G4int(UDefPhiH.GetVectorLength());
617  bins[0] = UDefPhiH.GetLowEdgeEnergy(size_t(0));
618  vals[0] = UDefPhiH(size_t(0));
619  sum = vals[0];
620  for(ii=1;ii<maxbin;ii++)
621  {
622  bins[ii] = UDefPhiH.GetLowEdgeEnergy(size_t(ii));
623  vals[ii] = UDefPhiH(size_t(ii)) + vals[ii-1];
624  sum = sum + UDefPhiH(size_t(ii));
625  }
626  for(ii=0;ii<maxbin;ii++)
627  {
628  vals[ii] = vals[ii]/sum;
629  IPDFPhiH.InsertValues(bins[ii], vals[ii]);
630  }
631  // Make IPDFPhiExist = true
632  IPDFPhiExist = true;
633  }
634  l.unlock();
635  // IPDF has been create so carry on
636  G4double rndm = G4UniformRand();
637  return(IPDFPhiH.GetEnergy(rndm));
638  }
639 }
G4PhysicsOrderedFreeVector UDefPhiH
G4PhysicsOrderedFreeVector IPDFPhiH
void InsertValues(G4double energy, G4double value)
int G4int
Definition: G4Types.hh:78
G4double GetLowEdgeEnergy(size_t binNumber) const
#define G4UniformRand()
Definition: Randomize.hh:97
G4GLOB_DLL std::ostream G4cout
size_t GetVectorLength() const
G4double GetEnergy(G4double aValue)
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GenerateUserDefTheta()

G4double G4SPSAngDistribution::GenerateUserDefTheta ( )
private

Definition at line 548 of file G4SPSAngDistribution.cc.

549 {
550  // Create cumulative histogram if not already done so. Then use RandFlat
551  //::shoot to generate the output Theta value.
552  if(UserDistType == "NULL" || UserDistType == "phi")
553  {
554  // No user defined theta distribution
555  G4cout << "Error ***********************" << G4endl;
556  G4cout << "UserDistType = " << UserDistType << G4endl;
557  return (0.);
558  }
559  else
560  {
561  // UserDistType = theta or both and so a theta distribution
562  // is defined. This should be integrated if not already done.
563  G4AutoLock l(&mutex);
564  if(IPDFThetaExist == false)
565  {
566  // IPDF has not been created, so create it
567  G4double bins[1024],vals[1024], sum;
568  G4int ii;
570  bins[0] = UDefThetaH.GetLowEdgeEnergy(size_t(0));
571  vals[0] = UDefThetaH(size_t(0));
572  sum = vals[0];
573  for(ii=1;ii<maxbin;ii++)
574  {
575  bins[ii] = UDefThetaH.GetLowEdgeEnergy(size_t(ii));
576  vals[ii] = UDefThetaH(size_t(ii)) + vals[ii-1];
577  sum = sum + UDefThetaH(size_t(ii));
578  }
579  for(ii=0;ii<maxbin;ii++)
580  {
581  vals[ii] = vals[ii]/sum;
582  IPDFThetaH.InsertValues(bins[ii], vals[ii]);
583  }
584  // Make IPDFThetaExist = true
585  IPDFThetaExist = true;
586  }
587  l.unlock();
588  // IPDF has been create so carry on
589  G4double rndm = G4UniformRand();
590  return(IPDFThetaH.GetEnergy(rndm));
591  }
592 }
G4PhysicsOrderedFreeVector IPDFThetaH
void InsertValues(G4double energy, G4double value)
int G4int
Definition: G4Types.hh:78
G4double GetLowEdgeEnergy(size_t binNumber) const
#define G4UniformRand()
Definition: Randomize.hh:97
G4GLOB_DLL std::ostream G4cout
G4PhysicsOrderedFreeVector UDefThetaH
size_t GetVectorLength() const
G4double GetEnergy(G4double aValue)
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetDirection()

G4ThreeVector G4SPSAngDistribution::GetDirection ( )

Definition at line 215 of file G4SPSAngDistribution.cc.

Here is the caller graph for this function:

◆ GetDistType()

G4String G4SPSAngDistribution::GetDistType ( )

Definition at line 210 of file G4SPSAngDistribution.cc.

Here is the caller graph for this function:

◆ GetMaxPhi()

G4double G4SPSAngDistribution::GetMaxPhi ( )

◆ GetMaxTheta()

G4double G4SPSAngDistribution::GetMaxTheta ( )

◆ GetMinPhi()

G4double G4SPSAngDistribution::GetMinPhi ( )

◆ GetMinTheta()

G4double G4SPSAngDistribution::GetMinTheta ( )

◆ ReSetHist()

void G4SPSAngDistribution::ReSetHist ( G4String  atype)

Definition at line 641 of file G4SPSAngDistribution.cc.

642 {
643  G4AutoLock l(&mutex);
644  if (atype == "theta") {
646  IPDFThetaExist = false ;}
647  else if (atype == "phi"){
649  IPDFPhiExist = false ;}
650  else {
651  G4cout << "Error, histtype not accepted " << G4endl;
652  }
653 }
G4PhysicsOrderedFreeVector UDefPhiH
G4PhysicsOrderedFreeVector IPDFPhiH
G4PhysicsOrderedFreeVector IPDFThetaH
G4GLOB_DLL std::ostream G4cout
G4PhysicsOrderedFreeVector UDefThetaH
G4PhysicsOrderedFreeVector ZeroPhysVector
#define G4endl
Definition: G4ios.hh:61
Here is the caller graph for this function:

◆ SetAngDistType()

void G4SPSAngDistribution::SetAngDistType ( G4String  atype)

Definition at line 90 of file G4SPSAngDistribution.cc.

91 {
92  G4AutoLock l(&mutex);
93  if(atype != "iso" && atype != "cos" && atype != "user" && atype != "planar"
94  && atype != "beam1d" && atype != "beam2d" && atype != "focused")
95  G4cout << "Error, distribution must be iso, cos, planar, beam1d, beam2d, focused or user" << G4endl;
96  else
97  AngDistType = atype;
98  if (AngDistType == "cos") MaxTheta = pi/2. ;
99  if (AngDistType == "user") {
101  IPDFThetaExist = false ;
103  IPDFPhiExist = false ;
104  }
105 }
G4PhysicsOrderedFreeVector UDefPhiH
G4PhysicsOrderedFreeVector IPDFPhiH
G4PhysicsOrderedFreeVector IPDFThetaH
G4GLOB_DLL std::ostream G4cout
G4PhysicsOrderedFreeVector UDefThetaH
G4PhysicsOrderedFreeVector ZeroPhysVector
static const double pi
Definition: G4SIunits.hh:74
#define G4endl
Definition: G4ios.hh:61
Here is the caller graph for this function:

◆ SetBeamSigmaInAngR()

void G4SPSAngDistribution::SetBeamSigmaInAngR ( G4double  r)

Definition at line 153 of file G4SPSAngDistribution.cc.

Here is the caller graph for this function:

◆ SetBeamSigmaInAngX()

void G4SPSAngDistribution::SetBeamSigmaInAngX ( G4double  r)

Definition at line 159 of file G4SPSAngDistribution.cc.

Here is the caller graph for this function:

◆ SetBeamSigmaInAngY()

void G4SPSAngDistribution::SetBeamSigmaInAngY ( G4double  r)

Definition at line 165 of file G4SPSAngDistribution.cc.

Here is the caller graph for this function:

◆ SetBiasRndm()

void G4SPSAngDistribution::SetBiasRndm ( G4SPSRandomGenerator a)

Definition at line 184 of file G4SPSAngDistribution.cc.

185 {
186  G4AutoLock l(&mutex);
187  angRndm = a;
188 }
G4SPSRandomGenerator * angRndm
Here is the caller graph for this function:

◆ SetFocusPoint()

void G4SPSAngDistribution::SetFocusPoint ( G4ThreeVector  input)

Definition at line 230 of file G4SPSAngDistribution.cc.

231 {
232  G4AutoLock l(&mutex);
233  FocusPoint = input;
234 }
Here is the caller graph for this function:

◆ SetMaxPhi()

void G4SPSAngDistribution::SetMaxPhi ( G4double  maxp)

Definition at line 147 of file G4SPSAngDistribution.cc.

Here is the caller graph for this function:

◆ SetMaxTheta()

void G4SPSAngDistribution::SetMaxTheta ( G4double  maxt)

Definition at line 141 of file G4SPSAngDistribution.cc.

Here is the caller graph for this function:

◆ SetMinPhi()

void G4SPSAngDistribution::SetMinPhi ( G4double  minp)

Definition at line 135 of file G4SPSAngDistribution.cc.

Here is the caller graph for this function:

◆ SetMinTheta()

void G4SPSAngDistribution::SetMinTheta ( G4double  mint)

Definition at line 129 of file G4SPSAngDistribution.cc.

Here is the caller graph for this function:

◆ SetParticleMomentumDirection()

void G4SPSAngDistribution::SetParticleMomentumDirection ( G4ParticleMomentum  aMomentumDirection)

Definition at line 171 of file G4SPSAngDistribution.cc.

172 {
173  G4AutoLock l(&mutex);
174  particle_momentum_direction = aMomentumDirection.unit();
175 
176 }
G4ParticleMomentum particle_momentum_direction
Hep3Vector unit() const
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetPosDistribution()

void G4SPSAngDistribution::SetPosDistribution ( G4SPSPosDistribution a)

Definition at line 178 of file G4SPSAngDistribution.cc.

179 {
180  G4AutoLock l(&mutex);
181  posDist = a;
182 }
G4SPSPosDistribution * posDist
Here is the caller graph for this function:

◆ SetUserWRTSurface()

void G4SPSAngDistribution::SetUserWRTSurface ( G4bool  wrtSurf)

Definition at line 236 of file G4SPSAngDistribution.cc.

237 {
238  G4AutoLock l(&mutex);
239  // This is only applied in user mode?
240  // if UserWRTSurface = true then the user wants momenta with respect
241  // to the surface normals.
242  // When doing this theta has to be 0-90 only otherwise there will be
243  // errors, which currently are flagged anywhere.
244  UserWRTSurface = wrtSurf;
245 }
Here is the caller graph for this function:

◆ SetUseUserAngAxis()

void G4SPSAngDistribution::SetUseUserAngAxis ( G4bool  userang)

Definition at line 247 of file G4SPSAngDistribution.cc.

248 {
249  G4AutoLock l(&mutex);
250  // if UserAngRef = true the angular distribution is defined wrt
251  // the user defined co-ordinates
252  UserAngRef = userang;
253 }
Here is the caller graph for this function:

◆ SetVerbosity()

void G4SPSAngDistribution::SetVerbosity ( G4int  a)

Definition at line 190 of file G4SPSAngDistribution.cc.

Here is the caller graph for this function:

◆ UserDefAngPhi()

void G4SPSAngDistribution::UserDefAngPhi ( G4ThreeVector  input)

Definition at line 217 of file G4SPSAngDistribution.cc.

218 {
219  G4AutoLock l(&mutex);
220  if(UserDistType == "NULL") UserDistType = "phi";
221  if(UserDistType == "theta") UserDistType = "both";
222  G4double phhi, val;
223  phhi = input.x();
224  val = input.y();
225  if(verbosityLevel >= 1)
226  G4cout << "In UserDefAngPhi" << G4endl;
227  UDefPhiH.InsertValues(phhi, val);
228 }
G4PhysicsOrderedFreeVector UDefPhiH
void InsertValues(G4double energy, G4double value)
G4GLOB_DLL std::ostream G4cout
double x() const
double y() const
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
Here is the call graph for this function:
Here is the caller graph for this function:

◆ UserDefAngTheta()

void G4SPSAngDistribution::UserDefAngTheta ( G4ThreeVector  input)

Definition at line 197 of file G4SPSAngDistribution.cc.

198 {
199  G4AutoLock l(&mutex);
200  if(UserDistType == "NULL") UserDistType = "theta";
201  if(UserDistType == "phi") UserDistType = "both";
202  G4double thi, val;
203  thi = input.x();
204  val = input.y();
205  if(verbosityLevel >= 1)
206  G4cout << "In UserDefAngTheta" << G4endl;
207  UDefThetaH.InsertValues(thi, val);
208 }
void InsertValues(G4double energy, G4double value)
G4GLOB_DLL std::ostream G4cout
G4PhysicsOrderedFreeVector UDefThetaH
double x() const
double y() const
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ AngDistType

G4String G4SPSAngDistribution::AngDistType
private

Definition at line 228 of file G4SPSAngDistribution.hh.

◆ AngRef1

G4ThreeVector G4SPSAngDistribution::AngRef1
private

Definition at line 229 of file G4SPSAngDistribution.hh.

◆ AngRef2

G4ThreeVector G4SPSAngDistribution::AngRef2
private

Definition at line 229 of file G4SPSAngDistribution.hh.

◆ AngRef3

G4ThreeVector G4SPSAngDistribution::AngRef3
private

Definition at line 229 of file G4SPSAngDistribution.hh.

◆ angRndm

G4SPSRandomGenerator* G4SPSAngDistribution::angRndm
private

Definition at line 247 of file G4SPSAngDistribution.hh.

◆ DR

G4double G4SPSAngDistribution::DR
private

Definition at line 231 of file G4SPSAngDistribution.hh.

◆ DX

G4double G4SPSAngDistribution::DX
private

Definition at line 231 of file G4SPSAngDistribution.hh.

◆ DY

G4double G4SPSAngDistribution::DY
private

Definition at line 231 of file G4SPSAngDistribution.hh.

◆ FocusPoint

G4ThreeVector G4SPSAngDistribution::FocusPoint
private

Definition at line 233 of file G4SPSAngDistribution.hh.

◆ IPDFPhiExist

G4bool G4SPSAngDistribution::IPDFPhiExist
private

Definition at line 234 of file G4SPSAngDistribution.hh.

◆ IPDFPhiH

G4PhysicsOrderedFreeVector G4SPSAngDistribution::IPDFPhiH
private

Definition at line 238 of file G4SPSAngDistribution.hh.

◆ IPDFThetaExist

G4bool G4SPSAngDistribution::IPDFThetaExist
private

Definition at line 234 of file G4SPSAngDistribution.hh.

◆ IPDFThetaH

G4PhysicsOrderedFreeVector G4SPSAngDistribution::IPDFThetaH
private

Definition at line 236 of file G4SPSAngDistribution.hh.

◆ MaxPhi

G4double G4SPSAngDistribution::MaxPhi
private

Definition at line 230 of file G4SPSAngDistribution.hh.

◆ MaxTheta

G4double G4SPSAngDistribution::MaxTheta
private

Definition at line 230 of file G4SPSAngDistribution.hh.

◆ MinPhi

G4double G4SPSAngDistribution::MinPhi
private

Definition at line 230 of file G4SPSAngDistribution.hh.

◆ MinTheta

G4double G4SPSAngDistribution::MinTheta
private

Definition at line 230 of file G4SPSAngDistribution.hh.

◆ mutex

G4Mutex G4SPSAngDistribution::mutex
private

Definition at line 254 of file G4SPSAngDistribution.hh.

◆ particle_momentum_direction

G4ParticleMomentum G4SPSAngDistribution::particle_momentum_direction
private

Definition at line 244 of file G4SPSAngDistribution.hh.

◆ Phi

G4double G4SPSAngDistribution::Phi
private

Definition at line 232 of file G4SPSAngDistribution.hh.

◆ posDist

G4SPSPosDistribution* G4SPSAngDistribution::posDist
private

Definition at line 246 of file G4SPSAngDistribution.hh.

◆ Theta

G4double G4SPSAngDistribution::Theta
private

Definition at line 232 of file G4SPSAngDistribution.hh.

◆ UDefPhiH

G4PhysicsOrderedFreeVector G4SPSAngDistribution::UDefPhiH
private

Definition at line 237 of file G4SPSAngDistribution.hh.

◆ UDefThetaH

G4PhysicsOrderedFreeVector G4SPSAngDistribution::UDefThetaH
private

Definition at line 235 of file G4SPSAngDistribution.hh.

◆ UserAngRef

G4bool G4SPSAngDistribution::UserAngRef
private

Definition at line 242 of file G4SPSAngDistribution.hh.

◆ UserDistType

G4String G4SPSAngDistribution::UserDistType
private

Definition at line 239 of file G4SPSAngDistribution.hh.

◆ UserWRTSurface

G4bool G4SPSAngDistribution::UserWRTSurface
private

Definition at line 240 of file G4SPSAngDistribution.hh.

◆ verbosityLevel

G4int G4SPSAngDistribution::verbosityLevel
private

Definition at line 250 of file G4SPSAngDistribution.hh.

◆ ZeroPhysVector

G4PhysicsOrderedFreeVector G4SPSAngDistribution::ZeroPhysVector
private

Definition at line 252 of file G4SPSAngDistribution.hh.


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