57 std::string name = params.getString(
"@name");
58 if (!prefix.empty()) {
59 name = prefix +
"." + name;
61 const std::string type = params.getString(
"@type");
62 const std::string material = params.getString(
"material",
"");
63 const double r = params.getLength(
"r", 0) /
Unit::mm * CLHEP::mm;
64 const double top = params.getLength(
"top", 0) /
Unit::mm * CLHEP::mm;
65 const double u = params.getLength(
"u", 0) /
Unit::mm * CLHEP::mm;
66 const bool active = params.getBool(
"active",
false);
69 if (!material.empty()) {
72 G4VSolid* shape{
nullptr};
75 const double length = params.getLength(
"length") /
Unit::mm * CLHEP::mm;
76 const double width = params.getLength(
"width") /
Unit::mm * CLHEP::mm;
77 height = params.getLength(
"height") /
Unit::mm * CLHEP::mm;
78 shape =
new G4Box(name, width / 2, height / 2, length / 2);
79 }
else if (type ==
"tube") {
80 const double length = params.getLength(
"length") /
Unit::mm * CLHEP::mm;
81 height = params.getLength(
"diameter") /
Unit::mm * CLHEP::mm;
82 shape =
new G4Tubs(name, 0, height / 2, length / 2, 0, 2 * M_PI);
84 G4LogicalVolume* volume =
new G4LogicalVolume(shape, mat, name);
91 for (
const GearDir& child : params.getNodes(
"shape")) {
96 const double center = r + roffset - height / 2 - top;
97 for (
double phi : params.getArray(
"phi", {M_PI / 2})) {
98 for (
double z : params.getArray(
"z", {0})) {
100 G4Transform3D transform = G4RotateZ3D(phi - M_PI / 2) * G4Translate3D(u, center, z);
101 new G4PVPlacement(transform, volume, name, parent,
false, copyNo++, check);
void createShape(const std::string &prefix, const GearDir ¶ms, G4LogicalVolume *parent, double roffset, bool check)
create a shape (box or cylinder) from XML description and place all child shapes in it by recursively...