24 #include <G4LogicalVolume.hh>
25 #include <G4Material.hh>
26 #include <G4VPhysicalVolume.hh>
32 throw std::invalid_argument(
"No Acts::TrackingGeometry provided.");
41 auto g4LogicalVolume = g4PhysicalVolume->GetLogicalVolume();
42 auto g4SensitiveDetector = g4LogicalVolume->GetSensitiveDetector();
45 auto g4Translation = g4PhysicalVolume->GetTranslation();
46 auto g4Rotation = g4PhysicalVolume->GetRotation();
48 g4Translation[1] * convertLength,
49 g4Translation[2] * convertLength);
52 if (g4Rotation ==
nullptr) {
56 rotation << g4Rotation->xx(), g4Rotation->yx(), g4Rotation->zx(),
57 g4Rotation->xy(), g4Rotation->yy(), g4Rotation->zy(), g4Rotation->xz(),
58 g4Rotation->yz(), g4Rotation->zz();
59 transform = motherTransform * (translation * rotation);
61 Acts::Vector3 g4AbsPosition = transform * Acts::Vector3::Zero();
63 if (G4int nDaughters = g4LogicalVolume->GetNoDaughters(); nDaughters > 0) {
65 for (G4int
id = 0;
id < nDaughters; ++
id) {
66 remapSensitiveNames(g4LogicalVolume->GetDaughter(
id),
transform,
72 std::string volumeName = g4LogicalVolume->GetName();
73 std::string volumeMaterialName = g4LogicalVolume->GetMaterial()->GetName();
74 if (g4SensitiveDetector ==
nullptr or
75 std::find(
m_cfg.materialMappings.begin(),
m_cfg.materialMappings.end(),
76 volumeMaterialName) !=
m_cfg.materialMappings.end() or
77 std::find(
m_cfg.volumeMappings.begin(),
m_cfg.volumeMappings.end(),
78 volumeName) !=
m_cfg.volumeMappings.end()) {
80 auto actsLayer =
m_cfg.trackingGeometry->associatedLayer(
86 if (actsLayer !=
nullptr and actsLayer->surfaceArray() !=
nullptr) {
87 auto actsSurfaces = actsLayer->surfaceArray()->at(g4AbsPosition);
88 if (not actsSurfaces.empty()) {
90 for (
const auto& as : actsSurfaces) {
97 if (mappedSurface ==
nullptr) {
99 for (
const auto& as : actsLayer->surfaceArray()->surfaces()) {
109 if (mappedSurface !=
nullptr) {
115 << g4RelPosition.transpose());
116 ACTS_VERBOSE(
"Remap: " << g4PhysicalVolume->GetName() <<
" -> "
117 << mappedVolumeName);
118 g4PhysicalVolume->SetName(mappedVolumeName.c_str());
121 << volumeName <<
"' with material '" << volumeMaterialName
122 <<
"' at position " << g4RelPosition.transpose());
126 << g4PhysicalVolume->GetName() <<
"' at "
127 << g4RelPosition.transpose()
128 <<
" because g4SensitiveDetector (=" << g4SensitiveDetector
129 <<
") is null and volume name (=" << volumeName
130 <<
") and material name (=" << volumeMaterialName
131 <<
") were not found");