288 while (!found && i<
G4int(PVStore->size())) {
289 tempPV = (*PVStore)[i];
290 found = tempPV->
GetName() == theRequiredVolumeName;
292 G4cout << i <<
" " <<
" " << tempPV->
GetName() <<
" " << theRequiredVolumeName <<
" " << found <<
G4endl;
305 G4cout <<
" **** Error: Volume does not exist **** " <<
G4endl;
320 G4cerr <<
"Error SourcePosType is not set to Point" <<
G4endl;
332 if(
Shape ==
"Circle")
336 while(std::sqrt((x*x) + (y*y)) >
Radius)
361 G4cout <<
"Raw position " << x <<
"," << y <<
"," << z <<
G4endl;
379 G4cout <<
"Rotated and Translated position " << pos <<
G4endl;
392 G4cerr <<
"Error: SourcePosType is not Plane" <<
G4endl;
395 if(
Shape ==
"Circle")
399 while(std::sqrt((x*x) + (y*y)) >
Radius)
408 else if(
Shape ==
"Annulus")
412 while(std::sqrt((x*x) + (y*
y)) >
Radius || std::sqrt((x*x) + (y*y)) <
Radius0 )
421 else if(
Shape ==
"Ellipse")
424 while(expression > 1.)
435 else if(
Shape ==
"Square")
442 else if(
Shape ==
"Rectangle")
456 G4cout <<
"Raw position " << x <<
"," << y <<
"," << z <<
G4endl;
474 G4cout <<
"Rotated and Translated position " << pos <<
G4endl;
515 if(
Shape ==
"Sphere")
520 theta = std::acos(1. - 2.*theta);
524 x =
Radius * std::sin(theta) * std::cos(phi);
525 y =
Radius * std::sin(theta) * std::sin(phi);
526 z =
Radius * std::cos(theta);
534 zdash = zdash.
unit();
542 else if(
Shape ==
"Ellipsoid")
554 theta = std::acos(1. - 2.*theta);
557 while(maxphi-minphi > 0.)
559 middlephi = (maxphi+minphi)/2.;
560 answer = (1./(
halfx*
halfx))*(middlephi/2. + std::sin(2*middlephi)/4.)
561 + (1./(halfy*
halfy))*(middlephi/2. - std::sin(2*middlephi)/4.)
563 answer = answer/constant;
564 if(answer > phi) maxphi = middlephi;
565 if(answer < phi) minphi = middlephi;
566 if(std::fabs(answer-phi) <= 0.00001)
573 x = std::sin(theta)*std::cos(phi);
574 y = std::sin(theta)*std::sin(phi);
585 tempxvar = 1./tempxvar;
586 G4double coordx = std::sqrt(tempxvar);
594 tempyvar = 1./tempyvar;
595 G4double coordy = std::sqrt(tempyvar);
601 tempzvar=(numXinZ*numXinZ)/(halfx*halfx)
602 +(numYinZ*numYinZ)/(halfy*halfy)+1./(
halfz*
halfz);
603 tempzvar = 1./tempzvar;
604 G4double coordz = std::sqrt(tempzvar);
606 lhs = std::sqrt((coordx*coordx)/(halfx*halfx) +
607 (coordy*coordy)/(halfy*halfy) +
611 G4cout <<
"Error: theta, phi not really on ellipsoid" <<
G4endl;
615 if(TestRandVar > 0.5)
620 if(TestRandVar > 0.5)
625 if(TestRandVar > 0.5)
630 RandPos.
setX(coordx);
631 RandPos.
setY(coordy);
632 RandPos.
setZ(coordz);
636 zdash = zdash.
unit();
643 else if(
Shape ==
"Cylinder")
646 G4double AreaTotal, prob1, prob2, prob3;
655 AreaLat = 2. *
pi * Radius * 2. *
halfz;
656 AreaTotal = AreaTop + AreaBot + AreaLat;
658 prob1 = AreaTop / AreaTotal;
659 prob2 = AreaBot / AreaTotal;
660 prob3 = 1.00 - prob1 - prob2;
661 if(std::fabs(prob3 - (AreaLat/AreaTotal)) >= 0.001)
671 if(testrand <= prob1)
677 while(((x*x)+(y*y)) > (Radius*Radius))
692 else if((testrand > prob1) && (testrand <= (prob1 + prob2)))
698 while(((x*x)+(y*y)) > (Radius*Radius))
713 else if(testrand > (prob1+prob2))
719 rand = rand * 2. *
pi;
721 x = Radius * std::cos(rand);
722 y = Radius * std::sin(rand);
731 zdash = zdash.
unit();
746 else if(
Shape ==
"Para")
758 G4double AreaTotal = 2*(AreaX + AreaY + AreaZ);
760 Probs[0] = AreaX/AreaTotal;
761 Probs[1] = Probs[0] + AreaX/AreaTotal;
762 Probs[2] = Probs[1] + AreaY/AreaTotal;
763 Probs[3] = Probs[2] + AreaY/AreaTotal;
764 Probs[4] = Probs[3] + AreaZ/AreaTotal;
765 Probs[5] = Probs[4] + AreaZ/AreaTotal;
778 if(testrand < Probs[0])
789 xdash = xdash.
unit();
790 ydash = ydash.
unit();
796 else if(testrand >= Probs[0] && testrand < Probs[1])
807 xdash = xdash.
unit();
808 ydash = ydash.
unit();
814 else if(testrand >= Probs[1] && testrand < Probs[2])
824 ydash = ydash.
unit();
831 else if(testrand >= Probs[2] && testrand < Probs[3])
841 ydash = ydash.
unit();
848 else if(testrand >= Probs[3] && testrand < Probs[4])
859 else if(testrand >= Probs[4] && testrand < Probs[5])
874 G4cout <<
"testrand=" << testrand <<
" Probs[5]=" << Probs[5] <<
G4endl;
902 G4cout <<
"Rotated and translated position " << pos <<
G4endl;
919 if(
Shape ==
"Sphere")
930 x = (x*2.*
Radius) - Radius;
931 y = (y*2.*
Radius) - Radius;
932 z = (z*2.*
Radius) - Radius;
935 else if(
Shape ==
"Ellipsoid")
953 else if(
Shape ==
"Cylinder")
968 else if(
Shape ==
"Para")
1002 G4cout <<
"Raw position " << x <<
"," << y <<
"," << z <<
G4endl;
1006 G4cout <<
"Rotated and translated position " << pos <<
G4endl;
1010 zdash = zdash.
unit();
1037 if(!theVolume)
return(
false);
1054 G4int LoopCount = 0;
1055 while(srcconf ==
false)
1070 msg <<
"Error: SourcePosType undefined\n";
1071 msg <<
"Generating point source\n";
1084 if(LoopCount == 100000)
1087 msg <<
"LoopCount = 100000\n";
1088 msg <<
"Either the source distribution >> confinement\n";
1089 msg <<
"or any confining volume may not overlap with\n";
1090 msg <<
"the source distribution or any confining volumes\n";
1091 msg <<
"may not exist\n"<<
G4endl;
1092 msg <<
"If you have set confine then this will be ignored\n";
1093 msg <<
"for this event.\n" <<
G4endl;
G4ThreeVector CSideRefVec3
void GeneratePointsInPlane(G4ThreeVector &outoutPos)
ThreeVector shoot(const G4int Ap, const G4int Af)
DLL_API const Hep3Vector HepZHat
void SetBiasRndm(G4SPSRandomGenerator *a)
G4ThreeVector GetSideRefVec2() const
void SetPosDisType(G4String)
void SetParTheta(G4double)
std::ostringstream G4ExceptionDescription
void SetBeamSigmaInX(G4double)
CLHEP::Hep3Vector G4ThreeVector
void GenerateRotationMatrices()
#define G4MUTEXINIT(mutex)
void SetParAlpha(G4double)
G4ThreeVector CParticlePos
G4Cache< thread_data_t > ThreadData
G4double GetHalfX() const
G4ThreeVector GetSideRefVec3() const
static G4PhysicalVolumeStore * GetInstance()
G4ThreeVector GetSideRefVec1() const
G4ThreeVector GetCentreCoords() const
G4String GetPosDisType() const
G4GLOB_DLL std::ostream G4cout
void SetCentreCoords(G4ThreeVector)
Hep3Vector cross(const Hep3Vector &) const
void SetBeamSigmaInR(G4double)
static const double twopi
G4ThreeVector CSideRefVec2
G4Navigator * GetNavigatorForTracking() const
void SetPosRot1(G4ThreeVector)
void GeneratePointsInVolume(G4ThreeVector &outputPos)
void SetPosDisShape(G4String)
G4bool IsSourceConfined(G4ThreeVector &outputPos)
DLL_API const Hep3Vector HepYHat
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
static G4TransportationManager * GetTransportationManager()
const G4String & GetName() const
G4SPSRandomGenerator * PosRndm
DLL_API const Hep3Vector HepXHat
void SetPosRot2(G4ThreeVector)
void GeneratePointSource(G4ThreeVector &outoutPos)
G4double GetHalfZ() const
virtual G4VPhysicalVolume * LocateGlobalPointAndSetup(const G4ThreeVector &point, const G4ThreeVector *direction=0, const G4bool pRelativeSearch=true, const G4bool ignoreDirection=true)
G4String GetSourcePosType() const
G4ThreeVector GetParticlePos() const
G4double GetHalfY() const
G4ThreeVector CentreCoords
void GeneratePointsInBeam(G4ThreeVector &outoutPos)
G4ThreeVector CSideRefVec1
G4String GetPosDisShape() const
G4double GenRandPosTheta()
void ConfineSourceToVolume(G4String)
#define G4MUTEXDESTROY(mutex)
G4ThreeVector GenerateOne()
void SetRadius0(G4double)
static const G4double pos
void SetBeamSigmaInY(G4double)
void SetVerbosity(G4int a)
G4double GetRadius() const
G4GLOB_DLL std::ostream G4cerr
void GeneratePointsOnSurface(G4ThreeVector &outputPos)