Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-05-10 02:21:25

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/EllipticalTube.h"
0005 #include "Utilities/Testing/interface/CppUnit_testdriver.icpp"
0006 #include "cppunit/extensions/HelperMacros.h"
0007 #include <G4EllipticalTube.hh>
0008 #include <cmath>
0009 #include <limits>
0010 #include <string>
0011 
0012 using namespace std;
0013 using CLHEP::cm;
0014 using CLHEP::cm3;
0015 
0016 class testEllipticalTube : public CppUnit::TestFixture {
0017   CPPUNIT_TEST_SUITE(testEllipticalTube);
0018   CPPUNIT_TEST(matched_g4_and_dd);
0019 
0020   CPPUNIT_TEST_SUITE_END();
0021 
0022 public:
0023   void matched_g4_and_dd(void);
0024 };
0025 
0026 void testEllipticalTube::matched_g4_and_dd(void) {
0027   double xSemiAxis = 3.0 * cm;
0028   double ySemiAxis = 2.0 * cm;
0029   double zHeight = 5.0 * cm;
0030   string name("fred1");
0031 
0032   G4EllipticalTube g4(name, xSemiAxis, ySemiAxis, zHeight);
0033   DDI::EllipticalTube dd(xSemiAxis, ySemiAxis, zHeight);
0034   DDEllipticalTube dds = DDSolidFactory::ellipticalTube(name, xSemiAxis, ySemiAxis, zHeight);
0035   cout << endl;
0036   dd.stream(cout);
0037   cout << endl;
0038 
0039   double g4v = g4.GetCubicVolume() / cm3;
0040   double ddv = dd.volume() / cm3;
0041   double ddsv = dds.volume() / cm3;
0042 
0043   cout << "\tg4 volume = " << g4v << " cm3" << endl;
0044   cout << "\tdd volume = " << ddv << " cm3" << endl;
0045   cout << "\tDD Information: " << dds << " vol=" << ddsv << " cm3" << endl;
0046 
0047   CPPUNIT_ASSERT(abs(g4v - ddv) < numeric_limits<float>::epsilon());
0048   CPPUNIT_ASSERT(abs(g4v - ddsv) < numeric_limits<float>::epsilon());
0049 }
0050 
0051 CPPUNIT_TEST_SUITE_REGISTRATION(testEllipticalTube);