File indexing completed on 2023-10-25 10:04:30
0001 #include "CLHEP/Units/GlobalSystemOfUnits.h"
0002 #include "DetectorDescription/Core/interface/DDSolid.h"
0003 #include "DetectorDescription/Core/interface/DDSolidShapes.h"
0004 #include "DetectorDescription/Core/interface/Trap.h"
0005 #include "Utilities/Testing/interface/CppUnit_testdriver.icpp"
0006 #include "cppunit/extensions/HelperMacros.h"
0007 #include <G4Trap.hh>
0008 #include <cmath>
0009 #include <limits>
0010 #include <string>
0011
0012 using namespace std;
0013
0014 class testTrap : public CppUnit::TestFixture {
0015 CPPUNIT_TEST_SUITE(testTrap);
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 testTrap::matched_g4_and_dd(void) {
0025 double dz = 60. * cm;
0026 double pTheta = 0. * deg;
0027 double pPhi = 0. * deg;
0028 double pDy1 = 30. * cm;
0029 double pDx1 = 30. * cm;
0030 double pDx2 = 30. * cm;
0031 double pAlp1 = 0. * deg;
0032 double pDy2 = 15. * cm;
0033 double pDx3 = 10. * cm;
0034 double pDx4 = 10. * cm;
0035 double pAlp2 = 0. * deg;
0036 string name("fred1");
0037
0038
0039
0040 G4Trap g4(name, dz, pTheta, pPhi, pDy1, pDx1, pDx2, pAlp1, pDy2, pDx3, pDx4, pAlp2);
0041 DDI::Trap dd(dz, pTheta, pPhi, pDy1, pDx1, pDx2, pAlp1, pDy2, pDx3, pDx4, pAlp2);
0042 DDTrap dds = DDSolidFactory::trap(name, dz, pTheta, pPhi, pDy1, pDx1, pDx2, pAlp1, pDy2, pDx3, pDx4, pAlp2);
0043 cout << endl;
0044 dd.stream(cout);
0045 cout << endl;
0046
0047 double g4v = g4.GetCubicVolume() / cm3;
0048 double ddv = dd.volume() / cm3;
0049 double ddsv = dds.volume() / cm3;
0050
0051 cout << "\tg4 volume = " << g4v << " cm3" << endl;
0052 cout << "\tdd volume = " << ddv << " cm3" << endl;
0053 cout << "\tDD Information: " << dds << " vol=" << ddsv << " cm3" << endl;
0054
0055 CPPUNIT_ASSERT(abs(g4v - ddv) < numeric_limits<float>::epsilon());
0056 CPPUNIT_ASSERT(abs(g4v - ddsv) < numeric_limits<float>::epsilon());
0057 }
0058
0059 CPPUNIT_TEST_SUITE_REGISTRATION(testTrap);