File indexing completed on 2023-10-25 10:04:29
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/Cons.h"
0005 #include "Utilities/Testing/interface/CppUnit_testdriver.icpp"
0006 #include "cppunit/extensions/HelperMacros.h"
0007 #include <G4Cons.hh>
0008 #include <cmath>
0009 #include <limits>
0010 #include <string>
0011
0012 using namespace std;
0013
0014 class testCons : public CppUnit::TestFixture {
0015 CPPUNIT_TEST_SUITE(testCons);
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 testCons::matched_g4_and_dd(void) {
0025 double rIn1 = 10. * cm;
0026 double rOut1 = 15. * cm;
0027 double rIn2 = 20. * cm;
0028 double rOut2 = 25. * cm;
0029 double zhalf = 20. * cm;
0030 double startPhi = 0. * deg;
0031 double deltaPhi = 90. * deg;
0032 string name("fred1");
0033
0034 G4Cons g4(name, rIn1, rOut1, rIn2, rOut2, zhalf, startPhi, deltaPhi);
0035 DDI::Cons dd(zhalf, rIn1, rOut1, rIn2, rOut2, startPhi, deltaPhi);
0036 DDCons dds = DDSolidFactory::cons(name, zhalf, rIn1, rOut1, rIn2, rOut2, startPhi, deltaPhi);
0037 cout << endl;
0038 dd.stream(cout);
0039 cout << endl;
0040
0041 double g4v = g4.GetCubicVolume() / cm3;
0042 double ddv = dd.volume() / cm3;
0043 double ddsv = dds.volume() / cm3;
0044
0045 cout << "\tg4 volume = " << g4v << " cm3" << endl;
0046 cout << "\tdd volume = " << ddv << " cm3" << endl;
0047 cout << "\tDD Information: " << dds << " vol=" << ddsv << " cm3" << endl;
0048
0049 CPPUNIT_ASSERT(abs(g4v - ddv) < numeric_limits<float>::epsilon());
0050 CPPUNIT_ASSERT(abs(g4v - ddsv) < numeric_limits<float>::epsilon());
0051 }
0052
0053 CPPUNIT_TEST_SUITE_REGISTRATION(testCons);