Back to home page

Project CMSSW displayed by LXR

 
 

    


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/Polycone.h"
0005 #include "Utilities/Testing/interface/CppUnit_testdriver.icpp"
0006 #include "cppunit/extensions/HelperMacros.h"
0007 #include <G4Polycone.hh>
0008 #include <cmath>
0009 #include <limits>
0010 #include <string>
0011 
0012 using namespace std;
0013 
0014 class testPolycone : public CppUnit::TestFixture {
0015   CPPUNIT_TEST_SUITE(testPolycone);
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 testPolycone::matched_g4_and_dd(void) {
0025   double phiStart = 45. * deg;
0026   double phiTotal = 325. * deg;
0027   double inner[] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
0028   vector<double> rInner(inner, inner + sizeof(inner) / sizeof(double));
0029   double outer[] = {0, 10, 10, 5, 5, 10, 10, 2, 2};
0030   vector<double> rOuter(outer, outer + sizeof(outer) / sizeof(double));
0031   double pl[] = {5, 7, 9, 11, 25, 27, 29, 31, 35};
0032   vector<double> z(pl, pl + sizeof(pl) / sizeof(double));
0033   string name("fred1");
0034 
0035   G4Polycone g4(name, phiStart, phiTotal, z.size(), &z[0], &rInner[0], &rOuter[0]);
0036   DDI::Polycone dd(phiStart, phiTotal, z, rInner, rOuter);
0037   DDPolycone dds = DDSolidFactory::polycone(name, phiStart, phiTotal, z, rInner, rOuter);
0038   cout << endl;
0039   dd.stream(cout);
0040   cout << endl;
0041 
0042   double g4v = g4.GetCubicVolume() / cm3;
0043   double ddv = dd.volume() / cm3;
0044   double ddsv = dds.volume() / cm3;
0045 
0046   cout << "\tg4 volume = " << g4v << " cm3" << endl;
0047   cout << "\tdd volume = " << ddv << " cm3" << endl;
0048   cout << "\tDD Information: " << dds << " vol= " << ddsv << " cm3" << endl;
0049 
0050   CPPUNIT_ASSERT(abs(g4v - ddv) < numeric_limits<float>::epsilon());
0051   CPPUNIT_ASSERT(abs(g4v - ddsv) < numeric_limits<float>::epsilon());
0052 }
0053 
0054 CPPUNIT_TEST_SUITE_REGISTRATION(testPolycone);