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/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 using CLHEP::cm;
0014 using CLHEP::cm3;
0015 using CLHEP::deg;
0016
0017 class testTrap : public CppUnit::TestFixture {
0018 CPPUNIT_TEST_SUITE(testTrap);
0019 CPPUNIT_TEST(matched_g4_and_dd);
0020
0021 CPPUNIT_TEST_SUITE_END();
0022
0023 public:
0024 void matched_g4_and_dd(void);
0025 };
0026
0027 void testTrap::matched_g4_and_dd(void) {
0028 double dz = 60. * cm;
0029 double pTheta = 0. * deg;
0030 double pPhi = 0. * deg;
0031 double pDy1 = 30. * cm;
0032 double pDx1 = 30. * cm;
0033 double pDx2 = 30. * cm;
0034 double pAlp1 = 0. * deg;
0035 double pDy2 = 15. * cm;
0036 double pDx3 = 10. * cm;
0037 double pDx4 = 10. * cm;
0038 double pAlp2 = 0. * deg;
0039 string name("fred1");
0040
0041
0042
0043 G4Trap g4(name, dz, pTheta, pPhi, pDy1, pDx1, pDx2, pAlp1, pDy2, pDx3, pDx4, pAlp2);
0044 DDI::Trap dd(dz, pTheta, pPhi, pDy1, pDx1, pDx2, pAlp1, pDy2, pDx3, pDx4, pAlp2);
0045 DDTrap dds = DDSolidFactory::trap(name, dz, pTheta, pPhi, pDy1, pDx1, pDx2, pAlp1, pDy2, pDx3, pDx4, pAlp2);
0046 cout << endl;
0047 dd.stream(cout);
0048 cout << endl;
0049
0050 double g4v = g4.GetCubicVolume() / cm3;
0051 double ddv = dd.volume() / cm3;
0052 double ddsv = dds.volume() / cm3;
0053
0054 cout << "\tg4 volume = " << g4v << " cm3" << endl;
0055 cout << "\tdd volume = " << ddv << " cm3" << endl;
0056 cout << "\tDD Information: " << dds << " vol=" << ddsv << " cm3" << endl;
0057
0058 CPPUNIT_ASSERT(abs(g4v - ddv) < numeric_limits<float>::epsilon());
0059 CPPUNIT_ASSERT(abs(g4v - ddsv) < numeric_limits<float>::epsilon());
0060 }
0061
0062 CPPUNIT_TEST_SUITE_REGISTRATION(testTrap);