File indexing completed on 2024-05-10 02:21:26
0001 #include <CLHEP/Units/SystemOfUnits.h>
0002 #include "DetectorDescription/Core/interface/DDSolid.h"
0003 #include "DetectorDescription/Core/interface/DDSolidShapes.h"
0004 #include "DetectorDescription/Core/interface/Polyhedra.h"
0005 #include "Utilities/Testing/interface/CppUnit_testdriver.icpp"
0006 #include "cppunit/extensions/HelperMacros.h"
0007 #include <G4Polyhedra.hh>
0008 #include <cmath>
0009 #include <limits>
0010 #include <string>
0011
0012 using namespace std;
0013
0014 class testPolyhedra : public CppUnit::TestFixture {
0015 CPPUNIT_TEST_SUITE(testPolyhedra);
0016 CPPUNIT_TEST(matched_g4_and_dd);
0017
0018 CPPUNIT_TEST_SUITE_END();
0019
0020 public:
0021 void matched_g4_and_dd(void);
0022 };
0023
0024 void testPolyhedra::matched_g4_and_dd(void) {
0025 int sides = 3;
0026 double phiStart = 45. * CLHEP::deg;
0027 double phiTotal = 325. * CLHEP::deg;
0028 double inner[] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
0029 vector<double> rInner(inner, inner + sizeof(inner) / sizeof(double));
0030 double outer[] = {0, 10, 10, 5, 5, 10, 10, 2, 2};
0031 vector<double> rOuter(outer, outer + sizeof(outer) / sizeof(double));
0032 double pl[] = {5, 7, 9, 11, 25, 27, 29, 31, 35};
0033 vector<double> z(pl, pl + sizeof(pl) / sizeof(double));
0034 string name("fred1");
0035
0036 G4Polyhedra g4(name, phiStart, phiTotal, sides, z.size(), &z[0], &rInner[0], &rOuter[0]);
0037 DDI::Polyhedra dd(sides, phiStart, phiTotal, z, rInner, rOuter);
0038 DDPolyhedra dds = DDSolidFactory::polyhedra(name, sides, phiStart, phiTotal, z, rInner, rOuter);
0039 cout << endl;
0040 dd.stream(cout);
0041 cout << endl;
0042
0043 double g4v = g4.GetCubicVolume() / CLHEP::cm3;
0044 double ddv = dd.volume() / CLHEP::cm3;
0045 double ddsv = dds.volume() / CLHEP::cm3;
0046
0047 cout << "\tg4 volume = " << g4v << " cm3" << endl;
0048 cout << "\tdd volume = " << ddv << " cm3" << endl;
0049 cout << "\tDD Information: " << dds << " vol=" << ddsv << " cm3" << endl;
0050
0051
0052
0053
0054 }
0055
0056 CPPUNIT_TEST_SUITE_REGISTRATION(testPolyhedra);