void testExtrudedPgon::matched_g4_and_dd( void ) { std::vector<double> x = { -300, -300, 300, 300, 150, 150, -150, -150 }; std::vector<double> y = { -300, 300, 300, -300, -300, 150, 150, -300 }; std::vector<double> z = { -600, -150, 100, 600 }; std::vector<double> zx = { 0, 0, 0, 0 }; std::vector<double> zy = { 300, -300, 0, 300 }; std::vector<double> zscale = { 8, 10, 6, 12 }; std::string name( "fred1" ); std::vector<G4TwoVector> polygon; std::vector<G4ExtrudedSolid::ZSection> zsections; for( unsigned int it = 0; it < x.size(); ++it ) polygon.emplace_back( x[it], y[it] ); for( unsigned int it = 0; it < z.size(); ++it ) zsections.emplace_back( z[it], G4TwoVector(zx[it], zy[it]), zscale[it] ); G4ExtrudedSolid g4( name, polygon, zsections ); DDI::ExtrudedPolygon dd( x, y, z, zx, zy, zscale ); DDExtrudedPolygon dds = DDSolidFactory::extrudedpolygon( name, x, y, z, zx, zy, zscale ); dd.stream(std::cout); std::cout << std::endl; std::cout << "\tg4 volume = " << g4.GetCubicVolume()/cm3 <<" cm3" << std::endl; std::cout << "\tdd volume = " << dd.volume()/cm3 << " cm3"<< std::endl; std::cout << "\tDD Information: " << dds << " vol= " << dds.volume() << std::endl; // FIXME: dd voulme is not implemented yet! // CPPUNIT_ASSERT( g4.GetCubicVolume()/cm3 == dd.volume()/cm3 ); }
G4VSolid const *PlacedSExtru::ConvertToGeant4() const { std::vector<G4TwoVector> G4vertices; using ZSection = G4ExtrudedSolid::ZSection; std::vector<ZSection> zsections; auto &vertices = GetUnplacedStruct()->GetPolygon().GetVertices(); for (size_t i = 0; i < vertices.size(); ++i) { G4vertices.push_back(G4TwoVector(vertices.x(i), vertices.y(i))); } zsections.push_back(ZSection(GetUnplacedStruct()->GetLowerZ(), 0., 1.)); zsections.push_back(ZSection(GetUnplacedStruct()->GetUpperZ(), 0., 1.)); G4String s("g4extru"); return new G4ExtrudedSolid(s, G4vertices, zsections); };
// // 25. Extruded Polygon: // // The extrusion of an arbitrary polygon (extruded solid) // with fixed outline in the defined Z sections can be defined as follows // (in a general way, or as special construct with two Z sections): // // G4ExtrudedSolid(const G4String& pName, // std::vector<G4TwoVector> polygon, // std::vector<ZSection> zsections) // void doExtrudedPgon(const std::string &name, const std::vector<double> x, const std::vector<double> y, const std::vector<double> z, const std::vector<double> zx, const std::vector<double> zy, const std::vector<double> zscale) { std::vector<G4TwoVector> polygon; std::vector<G4ExtrudedSolid::ZSection> zsections; for (unsigned int it = 0; it < x.size(); ++it) polygon.emplace_back(x[it], y[it]); for (unsigned int it = 0; it < z.size(); ++it) zsections.emplace_back(z[it], G4TwoVector(zx[it], zy[it]), zscale[it]); G4ExtrudedSolid g4(name, polygon, zsections); DDI::ExtrudedPolygon dd(x, y, z, zx, zy, zscale); DDExtrudedPolygon dds = DDSolidFactory::extrudedpolygon(name, x, y, z, zx, zy, zscale); dd.stream(std::cout); std::cout << std::endl; std::cout << "\tg4 volume = " << g4.GetCubicVolume() / cm3 << " cm3" << std::endl; std::cout << "\tdd volume = " << dd.volume() / cm3 << " cm3" << std::endl; std::cout << "\tDD Information: " << dds << " vol= " << dds.volume() << std::endl; }