28 #include "DD4hep/Detector.h"
29 #include "TGeoManager.h"
30 #include "TGeoMatrix.h"
32 #include <boost/algorithm/string.hpp>
36 std::unique_ptr<const Logger> logger)
37 : m_cfg(), m_logger(std::move(logger)) {
50 const std::vector<dd4hep::DetElement>& dendcapLayers,
51 const std::string& side)
const {
53 if (dendcapLayers.empty()) {
54 ACTS_VERBOSE(
" No layers handed over for " << side <<
" volume!");
57 <<
" volume -> creating "
60 for (
auto& detElement : dendcapLayers) {
62 std::vector<std::shared_ptr<const Surface>> layerSurfaces;
69 resolveSensitive(detElement, layerSurfaces);
72 convertTransform(&(detElement.nominal().worldTransformation()));
75 detElement.placement().ptr()->GetVolume()->GetShape();
78 if (detExtension->
hasValue(
"r",
"envelope") &&
79 detExtension->
hasValue(
"z",
"envelope")) {
82 detExtension->
getValue(
"r",
"envelope")};
84 detExtension->
getValue(
"z",
"envelope")};
85 }
else if (geoShape !=
nullptr) {
86 TGeoTubeSeg* tube =
dynamic_cast<TGeoTubeSeg*
>(geoShape);
87 if (tube ==
nullptr) {
88 ACTS_ERROR(
" Disc layer has wrong shape - needs to be TGeoTubeSeg!");
105 if (layerSurfaces.empty()) {
109 double z = (zMin + zMax) * 0.5;
112 pl.
minZ = (z != 0.) ? z - m_cfg.defaultThickness : 0.;
113 pl.
maxZ = (z != 0.) ? z + m_cfg.defaultThickness : 0.;
120 <<
" senstive surfaces.");
127 throw std::logic_error(
128 std::string(
"Layer DetElement: ") + detElement.name() +
129 std::string(
" has neither a shape nor tolerances for envelopes "
130 "added to its extension. Please check your detector "
134 std::shared_ptr<Layer> endcapLayer =
nullptr;
136 if (detElement.volume().isSensitive()) {
138 auto sensitiveSurf = createSensitiveSurface(detElement,
true);
140 std::unique_ptr<Acts::SurfaceArray> sArray =
141 std::make_unique<SurfaceArray>(sensitiveSurf);
144 auto dBounds = std::make_shared<const RadialBounds>(pl.
minR, pl.
maxR);
151 endcapLayer = m_cfg.layerCreator->discLayer(
152 gctx, layerSurfaces, m_cfg.bTypeR, m_cfg.bTypePhi, pl,
transform,
158 layers.push_back(endcapLayer);
166 return endcapLayers(gctx, m_cfg.negativeLayers,
"negative");
172 if (m_cfg.centralLayers.empty()) {
173 ACTS_VERBOSE(
" No layers handed over for central volume!");
176 " Received layers for central volume -> creating "
177 "cylindrical layers");
179 for (
auto& detElement : m_cfg.centralLayers) {
181 std::vector<std::shared_ptr<const Surface>> layerSurfaces;
188 resolveSensitive(detElement, layerSurfaces);
191 convertTransform(&(detElement.nominal().worldTransformation()));
193 TGeoShape* geoShape =
194 detElement.placement().ptr()->GetVolume()->GetShape();
197 if (detExtension->
hasValue(
"r",
"envelope") &&
198 detExtension->
hasValue(
"z",
"envelope")) {
201 detExtension->
getValue(
"r",
"envelope")};
203 detExtension->
getValue(
"z",
"envelope")};
204 }
else if (geoShape !=
nullptr) {
205 TGeoTubeSeg* tube =
dynamic_cast<TGeoTubeSeg*
>(geoShape);
208 " Cylinder layer has wrong shape - needs to be TGeoTubeSeg!");
215 if (layerSurfaces.empty()) {
218 double r = (rMin + rMax) * 0.5;
221 pl.
minR = (r != 0.) ? r - m_cfg.defaultThickness : 0.;
222 pl.
maxR = (r != 0.) ? r + m_cfg.defaultThickness : 0.;
234 throw std::logic_error(
235 std::string(
"Layer DetElement: ") + detElement.name() +
236 std::string(
" has neither a shape nor tolerances for envelopes "
237 "added to it¥s extension. Please check your detector "
241 double halfZ = (pl.
minZ - pl.
maxZ) * 0.5;
243 std::shared_ptr<Layer> centralLayer =
nullptr;
245 if (detElement.volume().isSensitive()) {
247 auto sensitiveSurf = createSensitiveSurface(detElement);
249 std::unique_ptr<Acts::SurfaceArray> sArray =
250 std::make_unique<SurfaceArray>(sensitiveSurf);
253 double layerR = (pl.
minR + pl.
maxR) * 0.5;
255 std::shared_ptr<const CylinderBounds> cBounds(
263 centralLayer = m_cfg.layerCreator->cylinderLayer(
264 gctx, layerSurfaces, m_cfg.bTypePhi, m_cfg.bTypeZ, pl,
transform,
270 layers.push_back(centralLayer);
278 return endcapLayers(gctx, m_cfg.positiveLayers,
"positive");
282 const dd4hep::DetElement& detElement,
283 std::vector<std::shared_ptr<const Acts::Surface>>& surfaces)
const {
284 const dd4hep::DetElement::Children& children = detElement.children();
285 if (!children.empty()) {
286 for (
auto& child : children) {
287 dd4hep::DetElement childDetElement = child.second;
288 if (childDetElement.volume().isSensitive()) {
290 surfaces.push_back(createSensitiveSurface(childDetElement,
false));
292 resolveSensitive(childDetElement, surfaces);
297 std::shared_ptr<const Acts::Surface>
299 const dd4hep::DetElement& detElement,
bool isDisc)
const {
304 }
catch (std::runtime_error&
e) {
309 auto detAxis = detExtension->
getType(
"axes",
"definitions");
313 isDisc,
nullptr,
nullptr);
319 std::shared_ptr<const Acts::Transform3D>
322 const Double_t* rotation = tGeoTrans->GetRotationMatrix();
323 const Double_t* translation = tGeoTrans->GetTranslation();
330 translation[1] * UnitConstants::cm,
331 translation[2] * UnitConstants::cm)));