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/ExtrudedPolygon.h"
0005 #include "Utilities/Testing/interface/CppUnit_testdriver.icpp"
0006 #include "cppunit/extensions/HelperMacros.h"
0007 #include <G4ExtrudedSolid.hh>
0008 #include <cmath>
0009 #include <limits>
0010 #include <string>
0011 
0012 using namespace std;
0013 
0014 class testExtrudedPgon : public CppUnit::TestFixture {
0015   CPPUNIT_TEST_SUITE(testExtrudedPgon);
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 testExtrudedPgon::matched_g4_and_dd(void) {
0025   vector<double> x = {-300, -300, 300, 300, 150, 150, -150, -150};
0026   vector<double> y = {-300, 300, 300, -300, -300, 150, 150, -300};
0027   vector<double> z = {-600, -150, 100, 600};
0028   vector<double> zx = {0, 0, 0, 0};
0029   vector<double> zy = {300, -300, 0, 300};
0030   vector<double> zscale = {8, 10, 6, 12};
0031   string name("fred1");
0032 
0033   vector<G4TwoVector> polygon;
0034   vector<G4ExtrudedSolid::ZSection> zsections;
0035   for (unsigned int it = 0; it < x.size(); ++it)
0036     polygon.emplace_back(x[it], y[it]);
0037   for (unsigned int it = 0; it < z.size(); ++it)
0038     zsections.emplace_back(z[it], G4TwoVector(zx[it], zy[it]), zscale[it]);
0039   G4ExtrudedSolid g4(name, polygon, zsections);
0040   DDI::ExtrudedPolygon dd(x, y, z, zx, zy, zscale);
0041   DDExtrudedPolygon dds = DDSolidFactory::extrudedpolygon(name, x, y, z, zx, zy, zscale);
0042 
0043   dd.stream(cout);
0044   cout << endl;
0045   cout << "\tg4 volume = " << g4.GetCubicVolume() / CLHEP::cm3 << " cm3" << endl;
0046   cout << "\tdd volume = " << dd.volume() / CLHEP::cm3 << " cm3" << endl;
0047   cout << "\tDD Information: " << dds << " vol= " << dds.volume() << endl;
0048 
0049   // FIXME: dd voulme is not implemented yet!
0050 }
0051 
0052 CPPUNIT_TEST_SUITE_REGISTRATION(testExtrudedPgon);