11 #include <vxd/geometry/GeoVXDServiceCreator.h>
12 #include <vxd/geometry/GeoVXDComponents.h>
13 #include <geometry/CreatorFactory.h>
14 #include <geometry/Materials.h>
15 #include <simulation/background/BkgSensitiveDetector.h>
16 #include <framework/gearbox/GearDir.h>
17 #include <framework/logging/Logger.h>
18 #include <G4Transform3D.hh>
19 #include <G4LogicalVolume.hh>
20 #include <G4PVPlacement.hh>
30 using namespace geometry;
37 VXDServiceGeometryPar GeoVXDServiceCreator::createConfiguration(
const GearDir& content)
39 VXDServiceGeometryPar vxdServiceGeometryPar(content.getBool(
"RecordBackground",
false));
41 GearDir content2(content,
"DockBoxes");
44 for (
const GearDir& boxtype : content2.getNodes(
"BoxType")) {
46 boxtype.getString(
"@name"),
47 boxtype.getString(
"material"),
48 boxtype.getInt(
"@identifier", 0),
49 boxtype.getLength(
"width"),
50 boxtype.getLength(
"length"),
51 boxtype.getLength(
"height")
53 vxdServiceGeometryPar.getBoxTypes().push_back(boxtypePar);
59 position.getString(
"@name"),
60 position.getLength(
"minZ"),
61 position.getLength(
"maxZ"),
62 position.getLength(
"minR"),
63 position.getLength(
"maxR"),
64 position.getInt(
"divisions")
68 for (
const double number : slot.getArray(
"")) {
69 slotsPar.getSlotNumbers().push_back(number);
71 positionPar.getSlots().push_back(slotsPar);
73 vxdServiceGeometryPar.getPositions().push_back(positionPar);
76 return vxdServiceGeometryPar;
79 void GeoVXDServiceCreator::createGeometry(
const VXDServiceGeometryPar& parameters, G4LogicalVolume& topVolume,
GeometryTypes)
81 m_defaultMaterial = topVolume.GetMaterial();
82 bool active = parameters.getRecordBackground();
85 std::map<std::string, VXDGeoComponent> boxes;
89 boxtype.getMaterial(),
"",
90 boxtype.getWidth() / 2.0 /
Unit::mm, 0,
91 boxtype.getLength() / 2.0 /
Unit::mm,
92 boxtype.getHeight() / 2.0 /
Unit::mm);
93 const std::string name = boxtype.getName();
96 B2DEBUG(50,
"Created " << name <<
" DockBox with a mass of " << (box.
getVolume()->GetMass(
true) / CLHEP::kg) <<
"kg");
98 int identifier = boxtype.getIdentifier();
99 B2DEBUG(50,
"Creating BkgSensitiveDetector for DockBox " << name <<
" with identifier " << identifier);
101 box.
getVolume()->SetSensitiveDetector(sensitive);
108 const double minZ = position.getMinZ() /
Unit::mm;
109 const double maxZ = position.getMaxZ() /
Unit::mm;
110 const double minR = position.getMinR() /
Unit::mm;
111 const double maxR = position.getMaxR() /
Unit::mm;
112 const int divisions = position.getDivisions();
113 const std::string name =
"VXD.DockBoxes." + position.getName();
117 const int signZ = minZ < 0 ? -1 : +1;
119 G4VSolid* shape_envelope =
new G4Tubs(name, minR, maxR, (maxZ - minZ) / 2.0, 0, 2 * M_PI);
120 G4LogicalVolume* envelope =
new G4LogicalVolume(shape_envelope, m_defaultMaterial, name);
121 new G4PVPlacement(G4TranslateZ3D((minZ + maxZ) / 2.0), envelope, name, &topVolume,
false, 1);
125 for (
const VXDSlotsPar& slot : position.getSlots()) {
126 const std::string type = slot.getType();
128 if (!box.
getVolume()) B2FATAL(
"Unknown DockBox type: " << type);
129 for (
double number : slot.getSlotNumbers()) {
130 const double angle = (2 * M_PI / divisions) * (number + 0.5);
134 const double z = -signZ * ((maxZ - minZ) / 2.0 - box.
getLength());
135 const G4Transform3D placement = G4RotateZ3D(angle) * G4Translate3D(r, 0, z);
136 new G4PVPlacement(placement, box.
getVolume(), name +
".box", envelope,
false,
static_cast<int>(number));