Geant4-11
Public Member Functions | Private Member Functions | Private Attributes
G4SPSAngDistribution Class Reference

#include <G4SPSAngDistribution.hh>

Public Member Functions

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

Private Member Functions

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

Private Attributes

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

Detailed Description

Definition at line 66 of file G4SPSAngDistribution.hh.

Constructor & Destructor Documentation

◆ G4SPSAngDistribution()

G4SPSAngDistribution::G4SPSAngDistribution ( )

Definition at line 38 of file G4SPSAngDistribution.cc.

39 : Theta(0.), Phi(0.)
40{
41 // Angular distribution Variables
44
45 AngDistType = "planar";
49 MinTheta = 0.;
50 MaxTheta = pi;
51 MinPhi = 0.;
52 MaxPhi = twopi;
53 DR = 0.;
54 DX = 0.;
55 DY = 0.;
56 FocusPoint = G4ThreeVector(0., 0., 0.);
57 UserDistType = "NULL";
58 UserWRTSurface = true;
59 UserAngRef = false;
60 IPDFThetaExist = false;
61 IPDFPhiExist = false;
63
65}
G4ThreeVector G4ParticleMomentum
static constexpr double twopi
Definition: G4SIunits.hh:56
static constexpr double pi
Definition: G4SIunits.hh:55
#define G4MUTEXINIT(mutex)
Definition: G4Threading.hh:87
CLHEP::Hep3Vector G4ThreeVector
G4ParticleMomentum particle_momentum_direction
DLL_API const Hep3Vector HepZHat
Definition: ThreeVector.h:419
DLL_API const Hep3Vector HepXHat
DLL_API const Hep3Vector HepYHat
Definition: ThreeVector.h:419
static const G4LorentzVector zero(0., 0., 0., 0.)

References AngDistType, AngRef1, AngRef2, AngRef3, DR, DX, DY, FocusPoint, G4MUTEXINIT, CLHEP::HepXHat, CLHEP::HepYHat, CLHEP::HepZHat, IPDFPhiExist, IPDFThetaExist, MaxPhi, MaxTheta, MinPhi, MinTheta, particle_momentum_direction, pi, twopi, UserAngRef, UserDistType, UserWRTSurface, verbosityLevel, and anonymous_namespace{G4CascadeDeexciteBase.cc}::zero.

◆ ~G4SPSAngDistribution()

G4SPSAngDistribution::~G4SPSAngDistribution ( )

Definition at line 67 of file G4SPSAngDistribution.cc.

68{
70}
#define G4MUTEXDESTROY(mutex)
Definition: G4Threading.hh:90

References G4MUTEXDESTROY.

Member Function Documentation

◆ DefineAngRefAxes()

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

Definition at line 95 of file G4SPSAngDistribution.cc.

97{
98 G4AutoLock l(&mutex);
99 if (refname == "angref1")
100 AngRef1 = ref.unit(); // x'
101 else if (refname == "angref2")
102 AngRef2 = ref.unit(); // vector in x'y' plane
103
104 // User defines x' (AngRef1) and a vector in the x'y'
105 // plane (AngRef2). Then, AngRef1 x AngRef2 = AngRef3
106 // the z' vector. Then, AngRef3 x AngRef1 = AngRef2
107 // which will now be y'.
108
109 AngRef3 = AngRef1.cross(AngRef2); // z'
110 AngRef2 = AngRef3.cross(AngRef1); // y'
111 UserAngRef = true ;
112 if(verbosityLevel == 2)
113 {
114 G4cout << "Angular distribution rotation axes " << AngRef1
115 << " " << AngRef2 << " " << AngRef3 << G4endl;
116 }
117}
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
Hep3Vector unit() const
Hep3Vector cross(const Hep3Vector &) const

References AngRef1, AngRef2, AngRef3, CLHEP::Hep3Vector::cross(), G4cout, G4endl, CLHEP::Hep3Vector::unit(), UserAngRef, and verbosityLevel.

Referenced by G4GeneralParticleSourceMessenger::SetNewValue().

◆ GenerateBeamFlux()

void G4SPSAngDistribution::GenerateBeamFlux ( G4ParticleMomentum outputMom)
private

Definition at line 274 of file G4SPSAngDistribution.cc.

275{
276 G4double theta, phi;
277 G4double px, py, pz;
278 if (AngDistType == "beam1d")
279 {
280 theta = G4RandGauss::shoot(0.0,DR);
281 phi = twopi * G4UniformRand();
282 }
283 else
284 {
285 px = G4RandGauss::shoot(0.0,DX);
286 py = G4RandGauss::shoot(0.0,DY);
287 theta = std::sqrt (px*px + py*py);
288 if (theta != 0.)
289 {
290 phi = std::acos(px/theta);
291 if ( py < 0.) phi = -phi;
292 }
293 else
294 {
295 phi = 0.0;
296 }
297 }
298 px = -std::sin(theta) * std::cos(phi);
299 py = -std::sin(theta) * std::sin(phi);
300 pz = -std::cos(theta);
301 G4double finx, finy, finz;
302 finx=px, finy=py, finz=pz;
303 if (UserAngRef)
304 {
305 // Apply Angular Rotation Matrix
306 // x * AngRef1, y * AngRef2 and z * AngRef3
307 finx = (px * AngRef1.x()) + (py * AngRef2.x()) + (pz * AngRef3.x());
308 finy = (px * AngRef1.y()) + (py * AngRef2.y()) + (pz * AngRef3.y());
309 finz = (px * AngRef1.z()) + (py * AngRef2.z()) + (pz * AngRef3.z());
310 G4double ResMag = std::sqrt((finx*finx) + (finy*finy) + (finz*finz));
311 finx = finx/ResMag;
312 finy = finy/ResMag;
313 finz = finz/ResMag;
314 }
315 mom.setX(finx);
316 mom.setY(finy);
317 mom.setZ(finz);
318
319 // particle_momentum_direction now holds unit momentum vector
320
321 if(verbosityLevel >= 1)
322 {
323 G4cout << "Generating beam vector: " << mom << G4endl;
324 }
325}
double G4double
Definition: G4Types.hh:83
#define G4UniformRand()
Definition: Randomize.hh:52
double z() const
double x() const
double y() const
ThreeVector shoot(const G4int Ap, const G4int Af)

References AngDistType, AngRef1, AngRef2, AngRef3, DR, DX, DY, G4cout, G4endl, G4UniformRand, CLHEP::Hep3Vector::setX(), CLHEP::Hep3Vector::setY(), CLHEP::Hep3Vector::setZ(), G4INCL::DeJongSpin::shoot(), twopi, UserAngRef, verbosityLevel, CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), and CLHEP::Hep3Vector::z().

Referenced by GenerateOne().

◆ GenerateCosineLawFlux()

void G4SPSAngDistribution::GenerateCosineLawFlux ( G4ParticleMomentum outputMom)
private

Definition at line 425 of file G4SPSAngDistribution.cc.

426{
427 // Method to generate flux distributed with a cosine law
428
429 G4double px, py, pz;
430 G4double rndm, rndm2;
431
432 G4double sintheta, sinphi,costheta,cosphi;
433 rndm = angRndm->GenRandTheta();
434 sintheta = std::sqrt( rndm * (std::sin(MaxTheta)*std::sin(MaxTheta)
435 - std::sin(MinTheta)*std::sin(MinTheta) )
436 + std::sin(MinTheta)*std::sin(MinTheta) );
437 costheta = std::sqrt(1. -sintheta*sintheta);
438
439 rndm2 = angRndm->GenRandPhi();
440 Phi = MinPhi + (MaxPhi - MinPhi) * rndm2;
441 sinphi = std::sin(Phi);
442 cosphi = std::cos(Phi);
443
444 px = -sintheta * cosphi;
445 py = -sintheta * sinphi;
446 pz = -costheta;
447
448 // for volume and point source use mother or user defined coordinates
449 // for plane and surface source user surface-normal or userdefined
450 // coordinates
451 //
452 G4double finx, finy, finz;
453 if (posDist->GetSourcePosType() == "Point"
454 || posDist->GetSourcePosType() == "Volume")
455 {
456 if (UserAngRef)
457 {
458 // Apply Rotation Matrix
459 finx = (px * AngRef1.x()) + (py * AngRef2.x()) + (pz * AngRef3.x());
460 finy = (px * AngRef1.y()) + (py * AngRef2.y()) + (pz * AngRef3.y());
461 finz = (px * AngRef1.z()) + (py * AngRef2.z()) + (pz * AngRef3.z());
462 }
463 else
464 {
465 finx = px;
466 finy = py;
467 finz = pz;
468 }
469 }
470 else
471 { // for plane and surface source
472 if (UserAngRef)
473 {
474 // Apply Rotation Matrix
475 finx = (px * AngRef1.x()) + (py * AngRef2.x()) + (pz * AngRef3.x());
476 finy = (px * AngRef1.y()) + (py * AngRef2.y()) + (pz * AngRef3.y());
477 finz = (px * AngRef1.z()) + (py * AngRef2.z()) + (pz * AngRef3.z());
478 }
479 else
480 {
481 finx = (px*posDist->GetSideRefVec1().x())
482 + (py*posDist->GetSideRefVec2().x())
483 + (pz*posDist->GetSideRefVec3().x());
484 finy = (px*posDist->GetSideRefVec1().y())
485 + (py*posDist->GetSideRefVec2().y())
486 + (pz*posDist->GetSideRefVec3().y());
487 finz = (px*posDist->GetSideRefVec1().z())
488 + (py*posDist->GetSideRefVec2().z())
489 + (pz*posDist->GetSideRefVec3().z());
490 }
491 }
492 G4double ResMag = std::sqrt((finx*finx) + (finy*finy) + (finz*finz));
493 finx = finx/ResMag;
494 finy = finy/ResMag;
495 finz = finz/ResMag;
496
497 mom.setX(finx);
498 mom.setY(finy);
499 mom.setZ(finz);
500
501 // particle_momentum_direction now contains unit momentum vector.
502
503 if(verbosityLevel >= 1)
504 {
505 G4cout << "Resultant cosine-law unit momentum vector " << mom << G4endl;
506 }
507}
G4SPSRandomGenerator * angRndm
G4SPSPosDistribution * posDist
const G4String & GetSourcePosType() const
const G4ThreeVector & GetSideRefVec2() const
const G4ThreeVector & GetSideRefVec3() const
const G4ThreeVector & GetSideRefVec1() const

References AngRef1, AngRef2, AngRef3, angRndm, G4cout, G4endl, G4SPSRandomGenerator::GenRandPhi(), G4SPSRandomGenerator::GenRandTheta(), G4SPSPosDistribution::GetSideRefVec1(), G4SPSPosDistribution::GetSideRefVec2(), G4SPSPosDistribution::GetSideRefVec3(), G4SPSPosDistribution::GetSourcePosType(), MaxPhi, MaxTheta, MinPhi, MinTheta, Phi, posDist, CLHEP::Hep3Vector::setX(), CLHEP::Hep3Vector::setY(), CLHEP::Hep3Vector::setZ(), UserAngRef, verbosityLevel, CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), and CLHEP::Hep3Vector::z().

Referenced by GenerateOne().

◆ GenerateFocusedFlux()

void G4SPSAngDistribution::GenerateFocusedFlux ( G4ParticleMomentum outputMom)
private

Definition at line 327 of file G4SPSAngDistribution.cc.

328{
329 mom = (FocusPoint - posDist->GetParticlePos()).unit();
330
331 // particle_momentum_direction now holds unit momentum vector.
332
333 if(verbosityLevel >= 1)
334 {
335 G4cout << "Generating focused vector: " << mom << G4endl;
336 }
337}
const G4ThreeVector & GetParticlePos() const

References FocusPoint, G4cout, G4endl, G4SPSPosDistribution::GetParticlePos(), posDist, and verbosityLevel.

Referenced by GenerateOne().

◆ GenerateIsotropicFlux()

void G4SPSAngDistribution::GenerateIsotropicFlux ( G4ParticleMomentum outputMom)
private

Definition at line 339 of file G4SPSAngDistribution.cc.

340{
341 // generates isotropic flux.
342 // No vectors are needed.
343
344 G4double rndm, rndm2;
345 G4double px, py, pz;
346
347 G4double sintheta, sinphi,costheta,cosphi;
348 rndm = angRndm->GenRandTheta();
349 costheta = std::cos(MinTheta) - rndm * (std::cos(MinTheta)
350 - std::cos(MaxTheta));
351 sintheta = std::sqrt(1. - costheta*costheta);
352
353 rndm2 = angRndm->GenRandPhi();
354 Phi = MinPhi + (MaxPhi - MinPhi) * rndm2;
355 sinphi = std::sin(Phi);
356 cosphi = std::cos(Phi);
357
358 px = -sintheta * cosphi;
359 py = -sintheta * sinphi;
360 pz = -costheta;
361
362 // For volume and point source use mother or user defined coordinates
363 // for plane and surface source user surface-normal or user-defined
364 // coordinates
365 //
366 G4double finx, finy, finz;
367 if (posDist->GetSourcePosType() == "Point"
368 || posDist->GetSourcePosType() == "Volume")
369 {
370 if (UserAngRef)
371 {
372 // Apply Rotation Matrix
373 // x * AngRef1, y * AngRef2 and z * AngRef3
374 finx = (px * AngRef1.x()) + (py * AngRef2.x()) + (pz * AngRef3.x());
375 finy = (px * AngRef1.y()) + (py * AngRef2.y()) + (pz * AngRef3.y());
376 finz = (px * AngRef1.z()) + (py * AngRef2.z()) + (pz * AngRef3.z());
377 }
378 else
379 {
380 finx = px;
381 finy = py;
382 finz = pz;
383 }
384 }
385 else
386 { // for plane and surface source
387 if (UserAngRef)
388 {
389 // Apply Rotation Matrix
390 // x * AngRef1, y * AngRef2 and z * AngRef3
391 finx = (px * AngRef1.x()) + (py * AngRef2.x()) + (pz * AngRef3.x());
392 finy = (px * AngRef1.y()) + (py * AngRef2.y()) + (pz * AngRef3.y());
393 finz = (px * AngRef1.z()) + (py * AngRef2.z()) + (pz * AngRef3.z());
394 }
395 else
396 {
397 finx = (px*posDist->GetSideRefVec1().x())
398 + (py*posDist->GetSideRefVec2().x())
399 + (pz*posDist->GetSideRefVec3().x());
400 finy = (px*posDist->GetSideRefVec1().y())
401 + (py*posDist->GetSideRefVec2().y())
402 + (pz*posDist->GetSideRefVec3().y());
403 finz = (px*posDist->GetSideRefVec1().z())
404 + (py*posDist->GetSideRefVec2().z())
405 + (pz*posDist->GetSideRefVec3().z());
406 }
407 }
408 G4double ResMag = std::sqrt((finx*finx) + (finy*finy) + (finz*finz));
409 finx = finx/ResMag;
410 finy = finy/ResMag;
411 finz = finz/ResMag;
412
413 mom.setX(finx);
414 mom.setY(finy);
415 mom.setZ(finz);
416
417 // particle_momentum_direction now holds unit momentum vector.
418
419 if(verbosityLevel >= 1)
420 {
421 G4cout << "Generating isotropic vector: " << mom << G4endl;
422 }
423}

References AngRef1, AngRef2, AngRef3, angRndm, G4cout, G4endl, G4SPSRandomGenerator::GenRandPhi(), G4SPSRandomGenerator::GenRandTheta(), G4SPSPosDistribution::GetSideRefVec1(), G4SPSPosDistribution::GetSideRefVec2(), G4SPSPosDistribution::GetSideRefVec3(), G4SPSPosDistribution::GetSourcePosType(), MaxPhi, MaxTheta, MinPhi, MinTheta, Phi, posDist, CLHEP::Hep3Vector::setX(), CLHEP::Hep3Vector::setY(), CLHEP::Hep3Vector::setZ(), UserAngRef, verbosityLevel, CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), and CLHEP::Hep3Vector::z().

Referenced by GenerateOne().

◆ GenerateOne()

G4ParticleMomentum G4SPSAngDistribution::GenerateOne ( )

Definition at line 766 of file G4SPSAngDistribution.cc.

767{
768 // Local copy for thread safety
769 //
771
772 // Angular stuff
773 //
774 if(AngDistType == "iso")
775 GenerateIsotropicFlux(localM);
776 else if(AngDistType == "cos")
777 GenerateCosineLawFlux(localM);
778 else if(AngDistType == "planar")
779 GeneratePlanarFlux(localM);
780 else if(AngDistType == "beam1d" || AngDistType == "beam2d" )
781 GenerateBeamFlux(localM);
782 else if(AngDistType == "user")
783 GenerateUserDefFlux(localM);
784 else if(AngDistType == "focused")
785 GenerateFocusedFlux(localM);
786 else
787 G4cout << "Error: AngDistType has unusual value" << G4endl;
788 return localM;
789}
void GeneratePlanarFlux(G4ParticleMomentum &outputMom)
void GenerateFocusedFlux(G4ParticleMomentum &outputMom)
void GenerateCosineLawFlux(G4ParticleMomentum &outputMom)
void GenerateBeamFlux(G4ParticleMomentum &outputMom)
void GenerateUserDefFlux(G4ParticleMomentum &outputMom)
void GenerateIsotropicFlux(G4ParticleMomentum &outputMom)

References AngDistType, G4cout, G4endl, GenerateBeamFlux(), GenerateCosineLawFlux(), GenerateFocusedFlux(), GenerateIsotropicFlux(), GeneratePlanarFlux(), GenerateUserDefFlux(), and particle_momentum_direction.

Referenced by G4SingleParticleSource::GeneratePrimaryVertex().

◆ GeneratePlanarFlux()

void G4SPSAngDistribution::GeneratePlanarFlux ( G4ParticleMomentum outputMom)
private

Definition at line 509 of file G4SPSAngDistribution.cc.

510{
511 // particle_momentum_direction now contains unit momentum vector.
512 // nothing need be done here as the m-directions have been set directly
513 // under this option
514
515 if(verbosityLevel >= 1)
516 {
517 G4cout << "Resultant Planar wave momentum vector " << mom << G4endl;
518 }
519}

References G4cout, G4endl, and verbosityLevel.

Referenced by GenerateOne().

◆ GenerateUserDefFlux()

void G4SPSAngDistribution::GenerateUserDefFlux ( G4ParticleMomentum outputMom)
private

Definition at line 521 of file G4SPSAngDistribution.cc.

522{
523 G4double rndm, px, py, pz, pmag;
524
525 if(UserDistType == "NULL")
526 {
527 G4cout << "Error: UserDistType undefined" << G4endl;
528 }
529 else if(UserDistType == "theta")
530 {
531 Theta = 10.;
532 while(Theta > MaxTheta || Theta < MinTheta)
533 {
535 }
536 Phi = 10.;
537 while(Phi > MaxPhi || Phi < MinPhi)
538 {
539 rndm = angRndm->GenRandPhi();
540 Phi = twopi * rndm;
541 }
542 }
543 else if(UserDistType == "phi")
544 {
545 Theta = 10.;
546 while(Theta > MaxTheta || Theta < MinTheta)
547 {
548 rndm = angRndm->GenRandTheta();
549 Theta = std::acos(1. - (2. * rndm));
550 }
551 Phi = 10.;
552 while(Phi > MaxPhi || Phi < MinPhi)
553 {
555 }
556 }
557 else if(UserDistType == "both")
558 {
559 Theta = 10.;
560 while(Theta > MaxTheta || Theta < MinTheta)
561 {
563 }
564 Phi = 10.;
565 while(Phi > MaxPhi || Phi < MinPhi)
566 {
568 }
569 }
570 px = -std::sin(Theta) * std::cos(Phi);
571 py = -std::sin(Theta) * std::sin(Phi);
572 pz = -std::cos(Theta);
573
574 pmag = std::sqrt((px*px) + (py*py) + (pz*pz));
575
576 if(!UserWRTSurface)
577 {
578 G4double finx, finy, finz;
579 if (UserAngRef)
580 {
581 // Apply Rotation Matrix
582 // x * AngRef1, y * AngRef2 and z * AngRef3
583 finx = (px * AngRef1.x()) + (py * AngRef2.x()) + (pz * AngRef3.x());
584 finy = (px * AngRef1.y()) + (py * AngRef2.y()) + (pz * AngRef3.y());
585 finz = (px * AngRef1.z()) + (py * AngRef2.z()) + (pz * AngRef3.z());
586 }
587 else // use mother coordinates
588 {
589 finx = px;
590 finy = py;
591 finz = pz;
592 }
593 G4double ResMag = std::sqrt((finx*finx) + (finy*finy) + (finz*finz));
594 finx = finx/ResMag;
595 finy = finy/ResMag;
596 finz = finz/ResMag;
597
598 mom.setX(finx);
599 mom.setY(finy);
600 mom.setZ(finz);
601 }
602 else // UserWRTSurface = true
603 {
604 G4double pxh = px/pmag;
605 G4double pyh = py/pmag;
606 G4double pzh = pz/pmag;
607 if(verbosityLevel > 1)
608 {
609 G4cout << "SideRefVecs " << posDist->GetSideRefVec1()
611 << G4endl;
612 G4cout << "Raw Unit vector " << pxh
613 << "," << pyh << "," << pzh << G4endl;
614 }
615 G4double resultx = (pxh*posDist->GetSideRefVec1().x())
616 + (pyh*posDist->GetSideRefVec2().x())
617 + (pzh*posDist->GetSideRefVec3().x());
618
619 G4double resulty = (pxh*posDist->GetSideRefVec1().y())
620 + (pyh*posDist->GetSideRefVec2().y())
621 + (pzh*posDist->GetSideRefVec3().y());
622
623 G4double resultz = (pxh*posDist->GetSideRefVec1().z())
624 + (pyh*posDist->GetSideRefVec2().z())
625 + (pzh*posDist->GetSideRefVec3().z());
626
627 G4double ResMag = std::sqrt((resultx*resultx)
628 + (resulty*resulty)
629 + (resultz*resultz));
630 resultx = resultx/ResMag;
631 resulty = resulty/ResMag;
632 resultz = resultz/ResMag;
633
634 mom.setX(resultx);
635 mom.setY(resulty);
636 mom.setZ(resultz);
637 }
638
639 // particle_momentum_direction now contains unit momentum vector.
640
641 if(verbosityLevel > 0 )
642 {
643 G4cout << "Final User Defined momentum vector "
645 }
646}

References AngRef1, AngRef2, AngRef3, angRndm, G4cout, G4endl, GenerateUserDefPhi(), GenerateUserDefTheta(), G4SPSRandomGenerator::GenRandPhi(), G4SPSRandomGenerator::GenRandTheta(), G4SPSPosDistribution::GetSideRefVec1(), G4SPSPosDistribution::GetSideRefVec2(), G4SPSPosDistribution::GetSideRefVec3(), MaxPhi, MaxTheta, MinPhi, MinTheta, particle_momentum_direction, Phi, posDist, CLHEP::Hep3Vector::setX(), CLHEP::Hep3Vector::setY(), CLHEP::Hep3Vector::setZ(), Theta, twopi, UserAngRef, UserDistType, UserWRTSurface, verbosityLevel, CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), and CLHEP::Hep3Vector::z().

Referenced by GenerateOne().

◆ GenerateUserDefPhi()

G4double G4SPSAngDistribution::GenerateUserDefPhi ( )
private

Definition at line 697 of file G4SPSAngDistribution.cc.

698{
699 // Create cumulative histogram if not already done so.
700 // Then use RandFlat::shoot to generate the output Theta value.
701
702 if(UserDistType == "NULL" || UserDistType == "theta")
703 {
704 // No user defined phi distribution
705 G4cout << "Error ***********************" << G4endl;
706 G4cout << "UserDistType = " << UserDistType << G4endl;
707 return(0.);
708 }
709 else
710 {
711 // UserDistType = phi or both and so a phi distribution
712 // is defined. This should be integrated if not already done.
713 G4AutoLock l(&mutex);
714 if(IPDFPhiExist == false)
715 {
716 // IPDF has not been created, so create it
717 //
718 G4double bins[1024],vals[1024], sum;
719 G4int ii;
721 bins[0] = UDefPhiH.GetLowEdgeEnergy(std::size_t(0));
722 vals[0] = UDefPhiH(std::size_t(0));
723 sum = vals[0];
724 for(ii=1; ii<maxbin; ++ii)
725 {
726 bins[ii] = UDefPhiH.GetLowEdgeEnergy(std::size_t(ii));
727 vals[ii] = UDefPhiH(std::size_t(ii)) + vals[ii-1];
728 sum = sum + UDefPhiH(std::size_t(ii));
729 }
730 for(ii=0; ii<maxbin; ++ii)
731 {
732 vals[ii] = vals[ii]/sum;
733 IPDFPhiH.InsertValues(bins[ii], vals[ii]);
734 }
735 IPDFPhiExist = true;
736 }
737 l.unlock();
738
739 // IPDF has been create so carry on
740 //
741 G4double rndm = G4UniformRand();
742
743 return(IPDFPhiH.GetEnergy(rndm));
744 }
745}
int G4int
Definition: G4Types.hh:85
void InsertValues(const G4double energy, const G4double value)
G4double GetEnergy(const G4double value) const
G4double GetLowEdgeEnergy(const std::size_t index) const
std::size_t GetVectorLength() const
G4PhysicsFreeVector IPDFPhiH
G4PhysicsFreeVector UDefPhiH

References anonymous_namespace{G4HyperonSampler.cc}::bins, G4cout, G4endl, G4UniformRand, G4PhysicsVector::GetEnergy(), G4PhysicsVector::GetLowEdgeEnergy(), G4PhysicsVector::GetVectorLength(), G4PhysicsFreeVector::InsertValues(), IPDFPhiExist, IPDFPhiH, UDefPhiH, G4TemplateAutoLock< _Mutex_t >::unlock(), and UserDistType.

Referenced by GenerateUserDefFlux().

◆ GenerateUserDefTheta()

G4double G4SPSAngDistribution::GenerateUserDefTheta ( )
private

Definition at line 648 of file G4SPSAngDistribution.cc.

649{
650 // Create cumulative histogram if not already done so.
651 // Then use RandFlat::shoot to generate the output Theta value.
652
653 if(UserDistType == "NULL" || UserDistType == "phi")
654 {
655 // No user defined theta distribution
656 G4cout << "Error ***********************" << G4endl;
657 G4cout << "UserDistType = " << UserDistType << G4endl;
658 return (0.);
659 }
660 else
661 {
662 // UserDistType = theta or both and so a theta distribution
663 // is defined. This should be integrated if not already done.
664 G4AutoLock l(&mutex);
665 if(IPDFThetaExist == false)
666 {
667 // IPDF has not been created, so create it
668 //
669 G4double bins[1024],vals[1024], sum;
670 G4int ii;
672 bins[0] = UDefThetaH.GetLowEdgeEnergy(std::size_t(0));
673 vals[0] = UDefThetaH(std::size_t(0));
674 sum = vals[0];
675 for(ii=1; ii<maxbin; ++ii)
676 {
677 bins[ii] = UDefThetaH.GetLowEdgeEnergy(std::size_t(ii));
678 vals[ii] = UDefThetaH(std::size_t(ii)) + vals[ii-1];
679 sum = sum + UDefThetaH(std::size_t(ii));
680 }
681 for(ii=0; ii<maxbin; ++ii)
682 {
683 vals[ii] = vals[ii]/sum;
684 IPDFThetaH.InsertValues(bins[ii], vals[ii]);
685 }
686 IPDFThetaExist = true;
687 }
688 l.unlock();
689
690 // IPDF has been created so carry on
691 //
692 G4double rndm = G4UniformRand();
693 return(IPDFThetaH.GetEnergy(rndm));
694 }
695}
G4PhysicsFreeVector UDefThetaH
G4PhysicsFreeVector IPDFThetaH

References anonymous_namespace{G4HyperonSampler.cc}::bins, G4cout, G4endl, G4UniformRand, G4PhysicsVector::GetEnergy(), G4PhysicsVector::GetLowEdgeEnergy(), G4PhysicsVector::GetVectorLength(), G4PhysicsFreeVector::InsertValues(), IPDFThetaExist, IPDFThetaH, UDefThetaH, G4TemplateAutoLock< _Mutex_t >::unlock(), and UserDistType.

Referenced by GenerateUserDefFlux().

◆ GetDirection()

G4ThreeVector G4SPSAngDistribution::GetDirection ( )

Definition at line 228 of file G4SPSAngDistribution.cc.

229{
230 G4AutoLock l(&mutex);
232}

References particle_momentum_direction.

Referenced by G4GeneralParticleSource::ListSource().

◆ GetDistType()

G4String G4SPSAngDistribution::GetDistType ( )

Definition at line 198 of file G4SPSAngDistribution.cc.

199{
200 G4AutoLock l(&mutex);
201 return AngDistType;
202}

References AngDistType.

Referenced by G4GeneralParticleSource::ListSource().

◆ GetMaxPhi()

G4double G4SPSAngDistribution::GetMaxPhi ( )

Definition at line 222 of file G4SPSAngDistribution.cc.

223{
224 G4AutoLock l(&mutex);
225 return MaxPhi;
226}

References MaxPhi.

◆ GetMaxTheta()

G4double G4SPSAngDistribution::GetMaxTheta ( )

Definition at line 210 of file G4SPSAngDistribution.cc.

211{
212 G4AutoLock l(&mutex);
213 return MaxTheta;
214}

References MaxTheta.

◆ GetMinPhi()

G4double G4SPSAngDistribution::GetMinPhi ( )

Definition at line 216 of file G4SPSAngDistribution.cc.

217{
218 G4AutoLock l(&mutex);
219 return MinPhi;
220}

References MinPhi.

◆ GetMinTheta()

G4double G4SPSAngDistribution::GetMinTheta ( )

Definition at line 204 of file G4SPSAngDistribution.cc.

205{
206 G4AutoLock l(&mutex);
207 return MinTheta;
208}

References MinTheta.

◆ ReSetHist()

void G4SPSAngDistribution::ReSetHist ( const G4String atype)

Definition at line 747 of file G4SPSAngDistribution.cc.

748{
749 G4AutoLock l(&mutex);
750 if (atype == "theta")
751 {
753 IPDFThetaExist = false ;
754 }
755 else if (atype == "phi")
756 {
758 IPDFPhiExist = false ;
759 }
760 else
761 {
762 G4cout << "Error, histtype not accepted " << G4endl;
763 }
764}
G4PhysicsFreeVector ZeroPhysVector

References G4cout, G4endl, IPDFPhiExist, IPDFPhiH, IPDFThetaExist, IPDFThetaH, UDefPhiH, UDefThetaH, and ZeroPhysVector.

Referenced by G4GeneralParticleSourceMessenger::SetNewValue().

◆ SetAngDistType()

void G4SPSAngDistribution::SetAngDistType ( const G4String atype)

Definition at line 72 of file G4SPSAngDistribution.cc.

73{
74 G4AutoLock l(&mutex);
75 if(atype != "iso" && atype != "cos" && atype != "user" && atype != "planar"
76 && atype != "beam1d" && atype != "beam2d" && atype != "focused")
77 {
78 G4cout << "Error, distribution must be iso, cos, planar, beam1d, beam2d, focused or user"
79 << G4endl;
80 }
81 else
82 {
83 AngDistType = atype;
84 }
85 if (AngDistType == "cos") { MaxTheta = pi/2.; }
86 if (AngDistType == "user")
87 {
89 IPDFThetaExist = false;
91 IPDFPhiExist = false;
92 }
93}

References AngDistType, G4cout, G4endl, IPDFPhiExist, IPDFPhiH, IPDFThetaExist, IPDFThetaH, MaxTheta, pi, UDefPhiH, UDefThetaH, and ZeroPhysVector.

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

◆ SetBeamSigmaInAngR()

void G4SPSAngDistribution::SetBeamSigmaInAngR ( G4double  r)

Definition at line 143 of file G4SPSAngDistribution.cc.

144{
145 G4AutoLock l(&mutex);
146 DR = r;
147}

References DR.

Referenced by G4GeneralParticleSourceMessenger::SetNewValue().

◆ SetBeamSigmaInAngX()

void G4SPSAngDistribution::SetBeamSigmaInAngX ( G4double  r)

Definition at line 149 of file G4SPSAngDistribution.cc.

150{
151 G4AutoLock l(&mutex);
152 DX = r;
153}

References DX.

Referenced by G4GeneralParticleSourceMessenger::SetNewValue().

◆ SetBeamSigmaInAngY()

void G4SPSAngDistribution::SetBeamSigmaInAngY ( G4double  r)

Definition at line 155 of file G4SPSAngDistribution.cc.

156{
157 G4AutoLock l(&mutex);
158 DY = r;
159}

References DY.

Referenced by G4GeneralParticleSourceMessenger::SetNewValue().

◆ SetBiasRndm()

void G4SPSAngDistribution::SetBiasRndm ( G4SPSRandomGenerator a)

Definition at line 174 of file G4SPSAngDistribution.cc.

175{
176 G4AutoLock l(&mutex);
177 angRndm = a;
178}

References angRndm.

Referenced by G4SingleParticleSource::G4SingleParticleSource().

◆ SetFocusPoint()

void G4SPSAngDistribution::SetFocusPoint ( const G4ThreeVector input)

Definition at line 246 of file G4SPSAngDistribution.cc.

247{
248 G4AutoLock l(&mutex);
249 FocusPoint = input;
250}

References FocusPoint.

Referenced by G4GeneralParticleSourceMessenger::SetNewValue().

◆ SetMaxPhi()

void G4SPSAngDistribution::SetMaxPhi ( G4double  maxp)

Definition at line 137 of file G4SPSAngDistribution.cc.

138{
139 G4AutoLock l(&mutex);
140 MaxPhi = maxp;
141}

References MaxPhi.

Referenced by G4GeneralParticleSourceMessenger::SetNewValue().

◆ SetMaxTheta()

void G4SPSAngDistribution::SetMaxTheta ( G4double  maxt)

◆ SetMinPhi()

void G4SPSAngDistribution::SetMinPhi ( G4double  minp)

Definition at line 125 of file G4SPSAngDistribution.cc.

126{
127 G4AutoLock l(&mutex);
128 MinPhi = minp;
129}

References MinPhi.

Referenced by G4GeneralParticleSourceMessenger::SetNewValue().

◆ SetMinTheta()

void G4SPSAngDistribution::SetMinTheta ( G4double  mint)

◆ SetParticleMomentumDirection()

void G4SPSAngDistribution::SetParticleMomentumDirection ( const G4ParticleMomentum aMomDirection)

◆ SetPosDistribution()

void G4SPSAngDistribution::SetPosDistribution ( G4SPSPosDistribution a)

Definition at line 168 of file G4SPSAngDistribution.cc.

169{
170 G4AutoLock l(&mutex);
171 posDist = a;
172}

References posDist.

Referenced by G4SingleParticleSource::G4SingleParticleSource().

◆ SetUserWRTSurface()

void G4SPSAngDistribution::SetUserWRTSurface ( G4bool  wrtSurf)

Definition at line 252 of file G4SPSAngDistribution.cc.

253{
254 G4AutoLock l(&mutex);
255
256 // if UserWRTSurface = true then the user wants momenta with respect
257 // to the surface normals.
258 // When doing this theta has to be 0-90 only otherwise there will be
259 // errors, which currently are flagged anywhere.
260 //
261 UserWRTSurface = wrtSurf;
262}

References UserWRTSurface.

Referenced by G4GeneralParticleSourceMessenger::SetNewValue().

◆ SetUseUserAngAxis()

void G4SPSAngDistribution::SetUseUserAngAxis ( G4bool  userang)

Definition at line 264 of file G4SPSAngDistribution.cc.

265{
266 G4AutoLock l(&mutex);
267
268 // if UserAngRef = true the angular distribution is defined wrt
269 // the user defined coordinates
270 //
271 UserAngRef = userang;
272}

References UserAngRef.

Referenced by G4GeneralParticleSourceMessenger::SetNewValue().

◆ SetVerbosity()

void G4SPSAngDistribution::SetVerbosity ( G4int  a)

Definition at line 180 of file G4SPSAngDistribution.cc.

181{
182 G4AutoLock l(&mutex);
183 verbosityLevel = a;
184}

References verbosityLevel.

Referenced by G4SingleParticleSource::SetVerbosity().

◆ UserDefAngPhi()

void G4SPSAngDistribution::UserDefAngPhi ( const G4ThreeVector input)

Definition at line 234 of file G4SPSAngDistribution.cc.

235{
236 G4AutoLock l(&mutex);
237 if(UserDistType == "NULL") UserDistType = "phi";
238 if(UserDistType == "theta") UserDistType = "both";
239 G4double phhi, val;
240 phhi = input.x();
241 val = input.y();
242 if(verbosityLevel >= 1) G4cout << "In UserDefAngPhi" << G4endl;
243 UDefPhiH.InsertValues(phhi, val);
244}

References G4cout, G4endl, G4PhysicsFreeVector::InsertValues(), UDefPhiH, UserDistType, verbosityLevel, CLHEP::Hep3Vector::x(), and CLHEP::Hep3Vector::y().

Referenced by G4GeneralParticleSourceMessenger::SetNewValue().

◆ UserDefAngTheta()

void G4SPSAngDistribution::UserDefAngTheta ( const G4ThreeVector input)

Definition at line 186 of file G4SPSAngDistribution.cc.

187{
188 G4AutoLock l(&mutex);
189 if(UserDistType == "NULL") UserDistType = "theta";
190 if(UserDistType == "phi") UserDistType = "both";
191 G4double thi, val;
192 thi = input.x();
193 val = input.y();
194 if(verbosityLevel >= 1) G4cout << "In UserDefAngTheta" << G4endl;
195 UDefThetaH.InsertValues(thi, val);
196}

References G4cout, G4endl, G4PhysicsFreeVector::InsertValues(), UDefThetaH, UserDistType, verbosityLevel, CLHEP::Hep3Vector::x(), and CLHEP::Hep3Vector::y().

Referenced by G4GeneralParticleSourceMessenger::SetNewValue().

Field Documentation

◆ AngDistType

G4String G4SPSAngDistribution::AngDistType
private

◆ AngRef1

G4ThreeVector G4SPSAngDistribution::AngRef1
private

◆ AngRef2

G4ThreeVector G4SPSAngDistribution::AngRef2
private

◆ AngRef3

G4ThreeVector G4SPSAngDistribution::AngRef3
private

◆ angRndm

G4SPSRandomGenerator* G4SPSAngDistribution::angRndm = nullptr
private

◆ DR

G4double G4SPSAngDistribution::DR
private

◆ DX

G4double G4SPSAngDistribution::DX
private

◆ DY

G4double G4SPSAngDistribution::DY
private

◆ FocusPoint

G4ThreeVector G4SPSAngDistribution::FocusPoint
private

◆ IPDFPhiExist

G4bool G4SPSAngDistribution::IPDFPhiExist
private

◆ IPDFPhiH

G4PhysicsFreeVector G4SPSAngDistribution::IPDFPhiH
private

Definition at line 190 of file G4SPSAngDistribution.hh.

Referenced by GenerateUserDefPhi(), ReSetHist(), and SetAngDistType().

◆ IPDFThetaExist

G4bool G4SPSAngDistribution::IPDFThetaExist
private

◆ IPDFThetaH

G4PhysicsFreeVector G4SPSAngDistribution::IPDFThetaH
private

Definition at line 188 of file G4SPSAngDistribution.hh.

Referenced by GenerateUserDefTheta(), ReSetHist(), and SetAngDistType().

◆ MaxPhi

G4double G4SPSAngDistribution::MaxPhi
private

◆ MaxTheta

G4double G4SPSAngDistribution::MaxTheta
private

◆ MinPhi

G4double G4SPSAngDistribution::MinPhi
private

◆ MinTheta

G4double G4SPSAngDistribution::MinTheta
private

◆ mutex

G4Mutex G4SPSAngDistribution::mutex
private

Definition at line 205 of file G4SPSAngDistribution.hh.

◆ particle_momentum_direction

G4ParticleMomentum G4SPSAngDistribution::particle_momentum_direction
private

◆ Phi

G4double G4SPSAngDistribution::Phi
private

◆ posDist

G4SPSPosDistribution* G4SPSAngDistribution::posDist = nullptr
private

◆ Theta

G4double G4SPSAngDistribution::Theta
private

Definition at line 184 of file G4SPSAngDistribution.hh.

Referenced by GenerateUserDefFlux().

◆ UDefPhiH

G4PhysicsFreeVector G4SPSAngDistribution::UDefPhiH
private

◆ UDefThetaH

G4PhysicsFreeVector G4SPSAngDistribution::UDefThetaH
private

◆ UserAngRef

G4bool G4SPSAngDistribution::UserAngRef
private

◆ UserDistType

G4String G4SPSAngDistribution::UserDistType
private

◆ UserWRTSurface

G4bool G4SPSAngDistribution::UserWRTSurface
private

◆ verbosityLevel

G4int G4SPSAngDistribution::verbosityLevel
private

◆ ZeroPhysVector

G4PhysicsFreeVector G4SPSAngDistribution::ZeroPhysVector
private

Definition at line 203 of file G4SPSAngDistribution.hh.

Referenced by ReSetHist(), and SetAngDistType().


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