File indexing completed on 2021-08-04 02:03:01
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/PseudoTrap.h"
0005 #include "SimG4Core/Geometry/interface/DDG4SolidConverter.h"
0006 #include "Utilities/Testing/interface/CppUnit_testdriver.icpp"
0007 #include "cppunit/extensions/HelperMacros.h"
0008 #include <G4VSolid.hh>
0009 #include <cmath>
0010 #include <limits>
0011 #include <string>
0012
0013 using namespace std;
0014
0015 class testPseudoTrap : public CppUnit::TestFixture {
0016 CPPUNIT_TEST_SUITE(testPseudoTrap);
0017 CPPUNIT_TEST(matched_g4_and_dd);
0018
0019 CPPUNIT_TEST_SUITE_END();
0020
0021 public:
0022 void matched_g4_and_dd(void);
0023 };
0024
0025 void testPseudoTrap::matched_g4_and_dd(void) {
0026 double pDx1 = 0.293734 * m;
0027 double pDx2 = 1.86356 * m;
0028 double pDy1 = 0.3000 * m;
0029 double pDy2 = 0.3000 * m;
0030 double pDz = 2.92934 * m;
0031 double radius = -1.1350 * m;
0032 bool atMinusZ = true;
0033
0034 string name("fred1");
0035
0036 DDI::PseudoTrap dd(pDx1, pDx2, pDy1, pDy2, pDz, radius, atMinusZ);
0037 DDPseudoTrap dds = DDSolidFactory::pseudoTrap(name, pDx1, pDx2, pDy1, pDy2, pDz, radius, atMinusZ);
0038 G4VSolid *g4 = DDG4SolidConverter::pseudotrap(dds);
0039 cout << endl;
0040 dd.stream(cout);
0041 cout << endl;
0042
0043 double g4v = g4->GetCubicVolume() / cm3;
0044 double ddv = dd.volume() / cm3;
0045 double ddsv = dds.volume() / 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 if (ddv > 0.0) {
0052 CPPUNIT_ASSERT(abs(g4v - ddv) < numeric_limits<float>::epsilon());
0053 CPPUNIT_ASSERT(abs(g4v - ddsv) < numeric_limits<float>::epsilon());
0054 }
0055 }
0056
0057 CPPUNIT_TEST_SUITE_REGISTRATION(testPseudoTrap);