45 AngDistType =
"planar";
57 UserDistType =
"NULL";
58 UserWRTSurface =
true;
60 IPDFThetaExist =
false;
75 if(atype !=
"iso" && atype !=
"cos" && atype !=
"user" && atype !=
"planar"
76 && atype !=
"beam1d" && atype !=
"beam2d" && atype !=
"focused")
78 G4cout <<
"Error, distribution must be iso, cos, planar, beam1d, beam2d, focused or user"
85 if (AngDistType ==
"cos") { MaxTheta = pi/2.; }
86 if (AngDistType ==
"user")
88 UDefThetaH = IPDFThetaH = ZeroPhysVector;
89 IPDFThetaExist =
false;
90 UDefPhiH = IPDFPhiH = ZeroPhysVector;
99 if (refname ==
"angref1")
100 AngRef1 = ref.
unit();
101 else if (refname ==
"angref2")
102 AngRef2 = ref.
unit();
109 AngRef3 = AngRef1.
cross(AngRef2);
110 AngRef2 = AngRef3.
cross(AngRef1);
112 if(verbosityLevel == 2)
114 G4cout <<
"Angular distribution rotation axes " << AngRef1
115 <<
" " << AngRef2 <<
" " << AngRef3 <<
G4endl;
165 particle_momentum_direction = aMomentumDirection.
unit();
189 if(UserDistType ==
"NULL") UserDistType =
"theta";
190 if(UserDistType ==
"phi") UserDistType =
"both";
194 if(verbosityLevel >= 1)
G4cout <<
"In UserDefAngTheta" <<
G4endl;
231 return particle_momentum_direction;
237 if(UserDistType ==
"NULL") UserDistType =
"phi";
238 if(UserDistType ==
"theta") UserDistType =
"both";
242 if(verbosityLevel >= 1)
G4cout <<
"In UserDefAngPhi" <<
G4endl;
261 UserWRTSurface = wrtSurf;
271 UserAngRef = userang;
278 if (AngDistType ==
"beam1d")
280 theta = G4RandGauss::shoot(0.0,DR);
285 px = G4RandGauss::shoot(0.0,DX);
286 py = G4RandGauss::shoot(0.0,DY);
287 theta = std::sqrt (px*px + py*py);
290 phi = std::acos(px/theta);
291 if ( py < 0.) phi = -phi;
298 px = -std::sin(theta) * std::cos(phi);
299 py = -std::sin(theta) * std::sin(phi);
300 pz = -std::cos(theta);
302 finx=px, finy=py, finz=pz;
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));
321 if(verbosityLevel >= 1)
333 if(verbosityLevel >= 1)
335 G4cout <<
"Generating focused vector: " << mom <<
G4endl;
347 G4double sintheta, sinphi,costheta,cosphi;
349 costheta = std::cos(MinTheta) - rndm * (std::cos(MinTheta)
350 - std::cos(MaxTheta));
351 sintheta = std::sqrt(1. - costheta*costheta);
354 Phi = MinPhi + (MaxPhi - MinPhi) * rndm2;
355 sinphi = std::sin(Phi);
356 cosphi = std::cos(Phi);
358 px = -sintheta * cosphi;
359 py = -sintheta * sinphi;
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());
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());
408 G4double ResMag = std::sqrt((finx*finx) + (finy*finy) + (finz*finz));
419 if(verbosityLevel >= 1)
421 G4cout <<
"Generating isotropic vector: " << mom <<
G4endl;
432 G4double sintheta, sinphi,costheta,cosphi;
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);
440 Phi = MinPhi + (MaxPhi - MinPhi) * rndm2;
441 sinphi = std::sin(Phi);
442 cosphi = std::cos(Phi);
444 px = -sintheta * cosphi;
445 py = -sintheta * sinphi;
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());
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());
492 G4double ResMag = std::sqrt((finx*finx) + (finy*finy) + (finz*finz));
503 if(verbosityLevel >= 1)
505 G4cout <<
"Resultant cosine-law unit momentum vector " << mom <<
G4endl;
515 if(verbosityLevel >= 1)
517 G4cout <<
"Resultant Planar wave momentum vector " << mom <<
G4endl;
525 if(UserDistType ==
"NULL")
529 else if(UserDistType ==
"theta")
532 while(Theta > MaxTheta || Theta < MinTheta)
534 Theta = GenerateUserDefTheta();
537 while(Phi > MaxPhi || Phi < MinPhi)
543 else if(UserDistType ==
"phi")
546 while(Theta > MaxTheta || Theta < MinTheta)
549 Theta = std::acos(1. - (2. * rndm));
552 while(Phi > MaxPhi || Phi < MinPhi)
554 Phi = GenerateUserDefPhi();
557 else if(UserDistType ==
"both")
560 while(Theta > MaxTheta || Theta < MinTheta)
562 Theta = GenerateUserDefTheta();
565 while(Phi > MaxPhi || Phi < MinPhi)
567 Phi = GenerateUserDefPhi();
570 px = -std::sin(Theta) * std::cos(Phi);
571 py = -std::sin(Theta) * std::sin(Phi);
572 pz = -std::cos(Theta);
574 pmag = std::sqrt((px*px) + (py*py) + (pz*pz));
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());
593 G4double ResMag = std::sqrt((finx*finx) + (finy*finy) + (finz*finz));
607 if(verbosityLevel > 1)
612 G4cout <<
"Raw Unit vector " << pxh
613 <<
"," << pyh <<
"," << pzh <<
G4endl;
627 G4double ResMag = std::sqrt((resultx*resultx)
629 + (resultz*resultz));
630 resultx = resultx/ResMag;
631 resulty = resulty/ResMag;
632 resultz = resultz/ResMag;
641 if(verbosityLevel > 0 )
643 G4cout <<
"Final User Defined momentum vector "
644 << particle_momentum_direction <<
G4endl;
648G4double G4SPSAngDistribution::GenerateUserDefTheta()
653 if(UserDistType ==
"NULL" || UserDistType ==
"phi")
665 if(IPDFThetaExist ==
false)
669 G4double bins[1024],vals[1024], sum;
673 vals[0] = UDefThetaH(std::size_t(0));
675 for(ii=1; ii<maxbin; ++ii)
678 vals[ii] = UDefThetaH(std::size_t(ii)) + vals[ii-1];
679 sum = sum + UDefThetaH(std::size_t(ii));
681 for(ii=0; ii<maxbin; ++ii)
683 vals[ii] = vals[ii]/sum;
686 IPDFThetaExist =
true;
697G4double G4SPSAngDistribution::GenerateUserDefPhi()
702 if(UserDistType ==
"NULL" || UserDistType ==
"theta")
714 if(IPDFPhiExist ==
false)
718 G4double bins[1024],vals[1024], sum;
722 vals[0] = UDefPhiH(std::size_t(0));
724 for(ii=1; ii<maxbin; ++ii)
727 vals[ii] = UDefPhiH(std::size_t(ii)) + vals[ii-1];
728 sum = sum + UDefPhiH(std::size_t(ii));
730 for(ii=0; ii<maxbin; ++ii)
732 vals[ii] = vals[ii]/sum;
750 if (atype ==
"theta")
752 UDefThetaH = IPDFThetaH = ZeroPhysVector ;
753 IPDFThetaExist = false ;
755 else if (atype ==
"phi")
757 UDefPhiH = IPDFPhiH = ZeroPhysVector ;
758 IPDFPhiExist = false ;
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);
787 G4cout <<
"Error: AngDistType has unusual value" <<
G4endl;
G4ThreeVector G4ParticleMomentum
#define G4MUTEXDESTROY(mutex)
#define G4MUTEXINIT(mutex)
CLHEP::Hep3Vector G4ThreeVector
G4GLOB_DLL std::ostream G4cout
Hep3Vector cross(const Hep3Vector &) const
void InsertValues(G4double energy, G4double value)
G4double GetEnergy(G4double aValue)
G4double GetLowEdgeEnergy(std::size_t binNumber) const
std::size_t GetVectorLength() const
void SetBeamSigmaInAngX(G4double)
void SetBeamSigmaInAngR(G4double)
G4ThreeVector GetDirection()
void SetPosDistribution(G4SPSPosDistribution *a)
void UserDefAngTheta(const G4ThreeVector &)
void SetFocusPoint(const G4ThreeVector &)
void SetAngDistType(const G4String &)
void UserDefAngPhi(const G4ThreeVector &)
G4ParticleMomentum GenerateOne()
void SetMaxTheta(G4double)
void SetUseUserAngAxis(G4bool)
void SetMinTheta(G4double)
void SetParticleMomentumDirection(const G4ParticleMomentum &aMomDirection)
void SetBeamSigmaInAngY(G4double)
void ReSetHist(const G4String &)
void SetBiasRndm(G4SPSRandomGenerator *a)
void SetVerbosity(G4int a)
void DefineAngRefAxes(const G4String &, const G4ThreeVector &)
void SetUserWRTSurface(G4bool)
const G4ThreeVector & GetParticlePos() const
const G4String & GetSourcePosType() const
const G4ThreeVector & GetSideRefVec2() const
const G4ThreeVector & GetSideRefVec3() const
const G4ThreeVector & GetSideRefVec1() const
DLL_API const Hep3Vector HepZHat
DLL_API const Hep3Vector HepXHat
DLL_API const Hep3Vector HepYHat