示例#1
0
int main(int argc, char *argv[]) {
  double xSemiaxis(2. * cm);
  double ySemiAxis(2. * cm);
  double zHeight(2. * cm);
  std::string name("fred1");

  //
  // 1. Box:
  //
  std::cout << "\n\nBox tests\n" << std::endl;
  doBox(name, xSemiaxis, ySemiAxis, zHeight);
  std::cout << std::endl;

  //
  // 2. Cylindrical Section or Tube:
  //
  std::cout << "\n\nTub tests\n" << std::endl;
  double rIn = 10. * cm;
  double rOut = 15. * cm;
  double zhalf = 20. * cm;
  double startPhi = 0. * deg;
  double deltaPhi = 90. * deg;
  doTubs(name, rIn, rOut, zhalf, startPhi, deltaPhi);
  std::cout << std::endl;

  //
  // 3. Cone or Conical section:
  //
  std::cout << "\n\nCons tests\n" << std::endl;
  double rIn2 = 20. * cm;
  double rOut2 = 25. * cm;
  doCons(name, rIn, rOut, rIn2, rOut2, zhalf, startPhi, deltaPhi);
  std::cout << std::endl;

  //
  // 5. Trapezoid:
  //
  std::cout << "\n\nTrapezoid tests\n" << std::endl;
  double dx1 = 10. * cm;
  double dx2 = 30. * cm;
  double dy1 = 15. * cm;
  double dy2 = 30. * cm;
  double dz = 60. * cm;
  doTrd(name, dx1, dx2, dy1, dy2, dz);
  std::cout << std::endl;

  //
  // 6. Generic Trapezoid:
  //
  std::cout << "\n\nGeneric Trapezoid tests\n" << std::endl;
  double pTheta = 0. * deg;
  double pPhi = 0. * deg;
  double pDy1 = 30. * cm;
  double pDx1 = 30. * cm;
  double pDx2 = 30. * cm;
  double pAlp1 = 0. * deg;
  double pDy2 = 15. * cm;
  double pDx3 = 10. * cm;
  double pDx4 = 10. * cm;
  double pAlp2 = 0. * deg;
  doTrap(name, dz, pTheta, pPhi, pDy1, pDx1, pDx2, pAlp1, pDy2, pDx3, pDx4, pAlp2);
  std::cout << std::endl;

  //
  // 7. Sphere or Spherical Shell Section:
  //
  std::cout << "\n\nSphere tests\n" << std::endl;
  std::cout << "This next should be the same as a 2cm ball: " << std::endl;
  doSphere("fred1", 0.0 * cm, 2.0 * cm, 0. * deg, 360. * deg, 0., 180. * deg);
  std::cout << "Manual computation gives: " << 4. / 3. * Geom::pi() * 2.0 * cm * 2.0 * cm * 2.0 * cm / cm3 << std::endl;
  std::cout << "If you mess up phi and theta you get: " << std::endl;
  doSphere("fred1", 0.0 * cm, 2.0 * cm, 0. * deg, 180. * deg, 0., 360. * deg);
  std::cout << "\n1 cm thick shell: " << std::endl;
  doSphere("fred1", 2.0 * cm, 3.0 * cm, 0. * deg, 360. * deg, 0., 180. * deg);
  std::cout << "Manual computation gives: "
            << 4. / 3. * Geom::pi() * 3.0 * cm * 3.0 * cm * 3.0 * cm / cm3 -
                   4. / 3. * Geom::pi() * 2.0 * cm * 2.0 * cm * 2.0 * cm / cm3
            << std::endl;
  std::cout << "\nHALF of the above 1 cm thick shell: " << std::endl;
  doSphere("fred1", 2.0 * cm, 3.0 * cm, 0. * deg, 180. * deg, 0., 180. * deg);
  std::cout << "Manual computation gives: "
            << (4. / 3. * Geom::pi() * 3.0 * cm * 3.0 * cm * 3.0 * cm / cm3 -
                4. / 3. * Geom::pi() * 2.0 * cm * 2.0 * cm * 2.0 * cm / cm3) /
                   2.
            << std::endl;
  std::cout << "\n30 degree span in theta; full phi \"top\" hemisphere" << std::endl;
  doSphere("fred1", 2.0 * cm, 3.0 * cm, 0. * deg, 360. * deg, 10. * deg, 30. * deg);
  std::cout << "\n30 degree span in theta; full phi \"bottom\" hemisphere; "
               "mirror of above, so should be same."
            << std::endl;
  doSphere("fred1", 2.0 * cm, 3.0 * cm, 0. * deg, 360. * deg, 140. * deg, 30. * deg);
  std::cout << "\n30 degree span in theta; full phi around equator (should be "
               "bigger than above)"
            << std::endl;
  doSphere("fred1", 2.0 * cm, 3.0 * cm, 0. * deg, 360. * deg, 75. * deg, 30. * deg);

  //
  // 9. Torus:
  //
  std::cout << "\n\nTorus tests\n" << std::endl;
  double radius = 200. * cm;
  doTorus(name, rIn, rOut, radius, startPhi, deltaPhi);
  std::cout << std::endl;

  //
  // 10. Polycons:
  //
  std::cout << "\n\nPolycons tests\n" << std::endl;
  double phiStart = 45. * deg;
  double phiTotal = 325. * deg;
  double inner[] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
  std::vector<double> rInner(inner, inner + sizeof(inner) / sizeof(double));
  double outer[] = {0, 10, 10, 5, 5, 10, 10, 2, 2};
  std::vector<double> rOuter(outer, outer + sizeof(outer) / sizeof(double));
  double pl[] = {5, 7, 9, 11, 25, 27, 29, 31, 35};
  std::vector<double> z(pl, pl + sizeof(pl) / sizeof(double));
  doPolycone1(name, phiStart, phiTotal, z, rInner, rOuter);
  std::cout << std::endl;

  doPolycone2(name, phiStart, phiTotal, z, rOuter);
  std::cout << std::endl;

  //
  // 11. Polyhedra (PGON):
  //
  std::cout << "\n\nPolyhedra tests\n" << std::endl;
  int sides = 3;
  doPolyhedra1(name, sides, phiStart, phiTotal, z, rInner, rOuter);
  std::cout << std::endl;

  doPolyhedra2(name, sides, phiStart, phiTotal, z, rOuter);
  std::cout << std::endl;

  //
  // 12. Tube with an elliptical cross section:
  //

  std::cout << "\n\nElliptical Tube tests\n" << std::endl;
  doEllipticalTube(name, xSemiaxis, ySemiAxis, zHeight);
  std::cout << std::endl;
  ySemiAxis = 3. * cm;
  doEllipticalTube(name, xSemiaxis, ySemiAxis, zHeight);
  std::cout << std::endl;
  xSemiaxis = 3. * cm;
  ySemiAxis = 2. * cm;
  zHeight = 10. * cm;
  doEllipticalTube(name, xSemiaxis, ySemiAxis, zHeight);
  std::cout << std::endl;
  xSemiaxis = 300. * cm;
  ySemiAxis = 400. * cm;
  zHeight = 3000. * cm;
  doEllipticalTube(name, xSemiaxis, ySemiAxis, zHeight);

  //
  // 14. Cone with Elliptical Cross Section:
  //

  //
  // 15. Paraboloid, a solid with parabolic profile:
  //

  //
  // 16. Tube with Hyperbolic Profile:
  //

  //
  // 17. Tetrahedra:
  //

  //
  // 18. Extruded Polygon:
  //

  //
  // 19. Box Twisted:
  //

  //
  // 20. Trapezoid Twisted along One Axis:
  //

  //
  // 21. Twisted Trapezoid with x and y dimensions varying along z:
  //

  //
  // 22. Generic trapezoid with optionally collapsing vertices:
  //

  //
  // 23. Tube Section Twisted along Its Axis:
  //

  //
  // 24. Cylindrical Cut Section or Cut Tube:
  //
  std::cout << "\n\nCutTub tests\n" << std::endl;
  std::array<double, 3> lowNorm = {{0, -0.7, -0.71}};
  std::array<double, 3> highNorm = {{0.7, 0, 0.71}};

  doCutTubs(name, rIn, rOut, zhalf, startPhi, deltaPhi, lowNorm, highNorm);
  std::cout << std::endl;

  //
  // 25. Extruded Polygon:
  //
  // The extrusion of an arbitrary polygon (extruded solid)
  // with fixed outline in the defined Z sections can be defined as follows
  // (in a general way, or as special construct with two Z sections):
  //
  //    G4ExtrudedSolid(const G4String& pName,
  //                    std::vector<G4TwoVector> polygon,
  //                    std::vector<ZSection> zsections)
  //
  std::cout << "\n\nExtruded Polygon tests\n" << std::endl;
  std::vector<double> x = {-300, -300, 300, 300, 150, 150, -150, -150};
  std::vector<double> y = {-300, 300, 300, -300, -300, 150, 150, -300};
  std::vector<double> epz = {-600, -150, 100, 600};
  std::vector<double> zx = {0, 0, 0, 0};
  std::vector<double> zy = {300, -300, 0, 300};
  std::vector<double> zscale = {8, 10, 6, 12};

  doExtrudedPgon(name, x, y, epz, zx, zy, zscale);
  std::cout << std::endl;

  return EXIT_SUCCESS;
}
示例#2
0
int
main( int argc, char *argv[] )
{
  double xSemiaxis(2.*cm);
  double ySemiAxis(2.*cm);
  double zHeight(2.*cm);
  std::string name("fred1");

//
// 1. Box:
//
  std::cout << "\n\nBox tests\n" << std::endl;
  doBox( name, xSemiaxis, ySemiAxis, zHeight );
  std::cout << std::endl;
  
//
// 2. Cylindrical Section or Tube:
//
  std::cout << "\n\nTub tests\n" << std::endl;
  double rIn = 10.*cm;
  double rOut = 15.*cm;
  double zhalf = 20.*cm;
  double startPhi = 0.*deg;
  double deltaPhi = 90.*deg;
  doTubs( name, rIn, rOut, zhalf, startPhi, deltaPhi );
  std::cout << std::endl;

//
// 3. Cone or Conical section:
//
  std::cout << "\n\nCons tests\n" << std::endl;
  double rIn2 = 20.*cm;
  double rOut2 = 25.*cm;
  doCons( name, rIn, rOut, rIn2, rOut2, zhalf, startPhi, deltaPhi );
  std::cout << std::endl;

//
// 4. Parallelepiped:
//
  std::cout << "\n\nParallelepiped tests\n" << std::endl;
  std::cout << "This next should be the same as a xhalf=5cm, yhalf=6cm, zhalf=7cm, alpha=15deg, theta=30deg, phi=45deg" << std::endl;
  doPara("fred1", 5.*cm, 6.*cm, 7.*cm, 15*deg, 30*deg, 45*deg);

//
// 5. Trapezoid:
//
  std::cout << "\n\nTrapezoid tests\n" << std::endl;
  double dx1 = 10.*cm;
  double dx2 = 30.*cm;
  double dy1 = 15.*cm;
  double dy2 = 30.*cm;
  double dz = 60.*cm;
  doTrd( name, dx1, dx2, dy1, dy2, dz );
  std::cout << std::endl;

//
// 6. Generic Trapezoid:
//
  std::cout << "\n\nGeneric Trapezoid tests\n" << std::endl;
  double pTheta = 0.*deg;
  double pPhi = 0.*deg;
  double pDy1 = 30.*cm;
  double pDx1 = 30.*cm;
  double pDx2 = 30.*cm;
  double pAlp1 = 0.*deg;
  double pDy2 = 15.*cm;
  double pDx3 = 10.*cm;
  double pDx4 = 10.*cm;
  double pAlp2 = 0.*deg;
  doTrap( name, dz, pTheta, pPhi, pDy1, pDx1, pDx2, pAlp1, pDy2, pDx3, pDx4, pAlp2 );
  std::cout << std::endl;

//
// 7. Sphere or Spherical Shell Section:
//
  std::cout << "\n\nSphere tests\n" << std::endl;
  std::cout << "This next should be the same as a 2cm ball: " << std::endl;
  doSphere("fred1", 0.0*cm, 2.0*cm, 0.*deg, 360.*deg, 0., 180.*deg);
  std::cout << "Manual computation gives: " 
	    << 4./3. * Geom::pi() * 2.0*cm * 2.0*cm *2.0*cm / cm3
	    <<std::endl;
  std::cout << "If you mess up phi and theta you get: " << std::endl;
  doSphere("fred1", 0.0*cm, 2.0*cm, 0.*deg, 180.*deg, 0., 360.*deg);
  std::cout << "\n1 cm thick shell: " << std::endl;
  doSphere("fred1", 2.0*cm, 3.0*cm, 0.*deg, 360.*deg, 0., 180.*deg);
  std::cout << "Manual computation gives: "
	    << 4./3. * Geom::pi() * 3.0*cm * 3.0*cm *3.0*cm / cm3 - 4./3. * Geom::pi() * 2.0*cm * 2.0*cm *2.0*cm / cm3
	    <<std::endl;
  std::cout << "\nHALF of the above 1 cm thick shell: " << std::endl;
  doSphere("fred1", 2.0*cm, 3.0*cm, 0.*deg, 180.*deg, 0., 180.*deg);
  std::cout << "Manual computation gives: "
	    << (4./3. * Geom::pi() * 3.0*cm * 3.0*cm *3.0*cm / cm3 - 4./3. * Geom::pi() * 2.0*cm * 2.0*cm *2.0*cm / cm3) / 2.
	    <<std::endl;
  std::cout << "\n30 degree span in theta; full phi \"top\" hemisphere" << std::endl;
  doSphere("fred1", 2.0*cm, 3.0*cm, 0.*deg, 360.*deg, 10.*deg, 30.*deg);
  std::cout << "\n30 degree span in theta; full phi \"bottom\" hemisphere; mirror of above, so should be same." << std::endl;
  doSphere("fred1", 2.0*cm, 3.0*cm, 0.*deg, 360.*deg, 140.*deg, 30.*deg);
  std::cout << "\n30 degree span in theta; full phi around equator (should be bigger than above)" << std::endl;
  doSphere("fred1", 2.0*cm, 3.0*cm, 0.*deg, 360.*deg, 75.*deg, 30.*deg);

//
// 8. Full Solid Sphere:
//
  std::cout << "\n\nOrb\n" << std::endl;
  std::cout << "This next should be the same as a 2cm ball (also the sphere above): " << std::endl;
  doOrb("fred1", 2.0*cm);
  
//
// 9. Torus:
//
  std::cout << "\n\nTorus tests\n" << std::endl;
  double radius = 200.*cm;
  doTorus( name, rIn, rOut, radius, startPhi, deltaPhi );
  std::cout << std::endl;

// 
// 10. Polycons:
//
  std::cout << "\n\nPolycons tests\n" << std::endl;
  double phiStart = 45.*deg;
  double phiTotal = 325.*deg;
  double inner[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
  std::vector<double> rInner( inner, inner + sizeof( inner ) / sizeof( double ));
  double outer[] = { 0, 10, 10, 5, 5, 10, 10, 2, 2 };
  std::vector<double> rOuter( outer, outer + sizeof( outer ) / sizeof( double ));
  double pl[] = { 5, 7, 9, 11, 25, 27, 29, 31, 35 };
  std::vector<double> z( pl, pl + sizeof( pl ) / sizeof( double ));
  doPolycone1( name, phiStart, phiTotal, z, rInner, rOuter );
  std::cout << std::endl;

  doPolycone2( name, phiStart, phiTotal, z, rOuter);
  std::cout << std::endl;

//
// 11. Polyhedra (PGON):
//
  std::cout << "\n\nPolyhedra tests\n" << std::endl;
  int sides = 3;
  doPolyhedra1( name, sides, phiStart, phiTotal, z, rInner, rOuter );
  std::cout << std::endl;

  doPolyhedra2( name, sides, phiStart, phiTotal, z, rOuter );
  std::cout << std::endl;

//
// 12. Tube with an elliptical cross section:
//  
  
  std::cout << "\n\nElliptical Tube tests\n" << std::endl;
  doEllipticalTube(name, xSemiaxis, ySemiAxis, zHeight);
  std::cout << std::endl;
  ySemiAxis = 3.*cm;
  doEllipticalTube(name, xSemiaxis, ySemiAxis, zHeight);
  std::cout << std::endl;
  xSemiaxis = 3.* cm;
  ySemiAxis = 2.* cm;
  zHeight = 10.* cm;
  doEllipticalTube(name, xSemiaxis, ySemiAxis, zHeight);
  std::cout << std::endl;
  xSemiaxis = 300.* cm;
  ySemiAxis = 400.* cm;
  zHeight = 3000. * cm;
  doEllipticalTube(name, xSemiaxis, ySemiAxis, zHeight);

//
// 13. General Ellipsoid:
//
  std::cout << "\n\nEllipsoid tests\n" << std::endl;
  std::cout << "This next should be the same as a x = 3cm; y = 2cm; and z = 5cm " << std::endl;
  doEllipsoid("fred1", 3.0*cm, 2.0*cm, 5.*cm, 0.*cm, 0.*cm);
  std::cout << "\nThis one has a top cut off at z=1cm  and should be half of the above + some bit." << std::endl;
  doEllipsoid("fred1", 3.0*cm, 2.0*cm, 5.*cm, 0.*cm, 1.*cm);
  std::cout << "\nThis has a bottom cut off at z= -1cm  and should be the same as the above (symmetric)" << std::endl;
  doEllipsoid("fred1", 3.0*cm, 2.0*cm, 5.*cm, -1.*cm, 0.*cm);
  std::cout << "\nThis has a bottom cut off at z= -1cm  and top cut at z=1cm and should be smaller (just the fat bit around the middle)." << std::endl;
  doEllipsoid("fred1", 3.0*cm, 2.0*cm, 5.*cm, -1.*cm, 1.*cm);

//
// 14. Cone with Elliptical Cross Section:
//

//
// 15. Paraboloid, a solid with parabolic profile:
//

//
// 16. Tube with Hyperbolic Profile:
//
  
//
// 17. Tetrahedra:
//

//
// 18. Extruded Polygon:
//

//
// 19. Box Twisted:
//

//
// 20. Trapezoid Twisted along One Axis:
//

//
// 21. Twisted Trapezoid with x and y dimensions varying along z:
//

//
// 22. Generic trapezoid with optionally collapsing vertices:
//

//
// 23. Tube Section Twisted along Its Axis: 
//   
  
  return EXIT_SUCCESS;
}