286 {
G4cout <<
"Volume confinement is set off." <<
G4endl; }
299 while (!found && i<
G4int(PVStore->size())) {
300 tempPV = (*PVStore)[i];
301 found = tempPV->
GetName() == theRequiredVolumeName;
303 G4cout << i <<
" " <<
" " << tempPV->
GetName() <<
" " << theRequiredVolumeName <<
" " << found <<
G4endl;
331 G4cerr <<
"Error SourcePosType is not set to Point" <<
G4endl;
343 if(
Shape ==
"Circle")
347 while(std::sqrt((x*x) + (y*y)) >
Radius)
372 G4cout <<
"Raw position " << x <<
"," << y <<
"," << z <<
G4endl;
390 G4cout <<
"Rotated and Translated position " << pos <<
G4endl;
403 G4cerr <<
"Error: SourcePosType is not Plane" <<
G4endl;
406 if(
Shape ==
"Circle")
410 while(std::sqrt((x*x) + (y*y)) >
Radius)
419 else if(
Shape ==
"Annulus")
423 while(std::sqrt((x*x) + (y*
y)) >
Radius || std::sqrt((x*x) + (y*y)) <
Radius0 )
432 else if(
Shape ==
"Ellipse")
435 while(expression > 1.)
446 else if(
Shape ==
"Square")
453 else if(
Shape ==
"Rectangle")
467 G4cout <<
"Raw position " << x <<
"," << y <<
"," << z <<
G4endl;
485 G4cout <<
"Rotated and Translated position " << pos <<
G4endl;
527 if(
Shape ==
"Sphere")
532 theta = std::acos(1. - 2.*theta);
536 x =
Radius * std::sin(theta) * std::cos(phi);
537 y =
Radius * std::sin(theta) * std::sin(phi);
538 z =
Radius * std::cos(theta);
546 zdash = zdash.
unit();
554 else if(
Shape ==
"Ellipsoid")
566 theta = std::acos(1. - 2.*theta);
569 while(maxphi-minphi > 0.)
571 middlephi = (maxphi+minphi)/2.;
572 answer = (1./(
halfx*
halfx))*(middlephi/2. + std::sin(2*middlephi)/4.)
573 + (1./(halfy*
halfy))*(middlephi/2. - std::sin(2*middlephi)/4.)
575 answer = answer/constant;
576 if(answer > phi) maxphi = middlephi;
577 if(answer < phi) minphi = middlephi;
578 if(std::fabs(answer-phi) <= 0.00001)
585 x = std::sin(theta)*std::cos(phi);
586 y = std::sin(theta)*std::sin(phi);
597 tempxvar = 1./tempxvar;
598 G4double coordx = std::sqrt(tempxvar);
606 tempyvar = 1./tempyvar;
607 G4double coordy = std::sqrt(tempyvar);
613 tempzvar=(numXinZ*numXinZ)/(halfx*halfx)
614 +(numYinZ*numYinZ)/(halfy*halfy)+1./(
halfz*
halfz);
615 tempzvar = 1./tempzvar;
616 G4double coordz = std::sqrt(tempzvar);
618 lhs = std::sqrt((coordx*coordx)/(halfx*halfx) +
619 (coordy*coordy)/(halfy*halfy) +
623 G4cout <<
"Error: theta, phi not really on ellipsoid" <<
G4endl;
627 if(TestRandVar > 0.5)
632 if(TestRandVar > 0.5)
637 if(TestRandVar > 0.5)
642 RandPos.
setX(coordx);
643 RandPos.
setY(coordy);
644 RandPos.
setZ(coordz);
648 zdash = zdash.
unit();
655 else if(
Shape ==
"Cylinder")
658 G4double AreaTotal, prob1, prob2, prob3;
667 AreaLat = 2. *
pi * Radius * 2. *
halfz;
668 AreaTotal = AreaTop + AreaBot + AreaLat;
670 prob1 = AreaTop / AreaTotal;
671 prob2 = AreaBot / AreaTotal;
672 prob3 = 1.00 - prob1 - prob2;
673 if(std::fabs(prob3 - (AreaLat/AreaTotal)) >= 0.001)
683 if(testrand <= prob1)
689 while(((x*x)+(y*y)) > (Radius*Radius))
704 else if((testrand > prob1) && (testrand <= (prob1 + prob2)))
710 while(((x*x)+(y*y)) > (Radius*Radius))
725 else if(testrand > (prob1+prob2))
731 rand = rand * 2. *
pi;
733 x = Radius * std::cos(rand);
734 y = Radius * std::sin(rand);
743 zdash = zdash.
unit();
758 else if(
Shape ==
"EllipticCylinder")
760 G4double AreaTop, AreaBot, AreaLat, AreaTotal;
776 AreaTotal = AreaTop + AreaBot + AreaLat;
778 prob1 = AreaTop / AreaTotal;
779 prob2 = AreaBot / AreaTotal;
780 prob3 = 1.00 - prob1 - prob2;
781 if(std::fabs(prob3 - (AreaLat/AreaTotal)) >= 0.001)
791 if(testrand <= prob1)
796 while(expression > 1.)
802 y = (y * 2. *
halfy) - halfy;
807 else if((testrand > prob1) && (testrand <= (prob1 + prob2)))
812 while(expression > 1.)
818 y = (y * 2. *
halfy) - halfy;
823 else if(testrand > (prob1+prob2))
828 rand = rand * 2. *
pi;
830 x =
halfx * std::cos(rand);
831 y = halfy * std::sin(rand);
846 zdash = zdash.
unit();
853 else if(
Shape ==
"Para")
865 G4double AreaTotal = 2*(AreaX + AreaY + AreaZ);
867 Probs[0] = AreaX/AreaTotal;
868 Probs[1] = Probs[0] + AreaX/AreaTotal;
869 Probs[2] = Probs[1] + AreaY/AreaTotal;
870 Probs[3] = Probs[2] + AreaY/AreaTotal;
871 Probs[4] = Probs[3] + AreaZ/AreaTotal;
872 Probs[5] = Probs[4] + AreaZ/AreaTotal;
885 if(testrand < Probs[0])
896 xdash = xdash.
unit();
897 ydash = ydash.
unit();
903 else if(testrand >= Probs[0] && testrand < Probs[1])
914 xdash = xdash.
unit();
915 ydash = ydash.
unit();
921 else if(testrand >= Probs[1] && testrand < Probs[2])
931 ydash = ydash.
unit();
938 else if(testrand >= Probs[2] && testrand < Probs[3])
948 ydash = ydash.
unit();
955 else if(testrand >= Probs[3] && testrand < Probs[4])
966 else if(testrand >= Probs[4] && testrand < Probs[5])
981 G4cout <<
"testrand=" << testrand <<
" Probs[5]=" << Probs[5] <<
G4endl;
1009 G4cout <<
"Rotated and translated position " << pos <<
G4endl;
1027 if(
Shape ==
"Sphere")
1038 x = (x*2.*
Radius) - Radius;
1039 y = (y*2.*
Radius) - Radius;
1040 z = (z*2.*
Radius) - Radius;
1043 else if(
Shape ==
"Ellipsoid")
1061 else if(
Shape ==
"Cylinder")
1076 else if(
Shape ==
"EllipticCylinder")
1079 while(expression > 1.)
1092 else if(
Shape ==
"Para")
1105 G4cout <<
"Error: Volume Shape Doesnt Exist" <<
G4endl;
1117 RandPos.
setX(tempx);
1118 RandPos.
setY(tempy);
1119 RandPos.
setZ(tempz);
1126 G4cout <<
"Raw position " << x <<
"," << y <<
"," << z <<
G4endl;
1130 G4cout <<
"Rotated and translated position " << pos <<
G4endl;
1134 zdash = zdash.
unit();
1161 if(!theVolume)
return(
false);
1179 G4int LoopCount = 0;
1180 while(srcconf ==
false)
1195 msg <<
"Error: SourcePosType undefined\n";
1196 msg <<
"Generating point source\n";
1209 if(LoopCount == 100000)
1212 msg <<
"LoopCount = 100000\n";
1213 msg <<
"Either the source distribution >> confinement\n";
1214 msg <<
"or any confining volume may not overlap with\n";
1215 msg <<
"the source distribution or any confining volumes\n";
1216 msg <<
"may not exist\n"<<
G4endl;
1217 msg <<
"If you have set confine then this will be ignored\n";
1218 msg <<
"for this event.\n" <<
G4endl;