30 #include <boost/algorithm/string.hpp>
32 #include "DD4hep/Detector.h"
33 #include "TGeoManager.h"
34 #include "TGeoMatrix.h"
38 std::unique_ptr<const Logger> logger)
39 : m_cfg(), m_logger(std::move(logger)) {
52 const std::vector<dd4hep::DetElement>& dendcapLayers,
53 const std::string& side)
const {
55 if (dendcapLayers.empty()) {
56 ACTS_VERBOSE(
" No layers handed over for " << side <<
" volume!");
59 <<
" volume -> creating "
62 for (
auto& detElement : dendcapLayers) {
64 std::vector<std::shared_ptr<const Surface>> layerSurfaces;
71 resolveSensitive(detElement, layerSurfaces);
74 convertTransform(&(detElement.nominal().worldTransformation()));
77 detElement.placement().ptr()->GetVolume()->GetShape();
80 if (detExtension->
hasValue(
"r",
"envelope") &&
81 detExtension->
hasValue(
"z",
"envelope")) {
84 detExtension->
getValue(
"r",
"envelope")};
86 detExtension->
getValue(
"z",
"envelope")};
87 }
else if (geoShape !=
nullptr) {
88 TGeoTubeSeg* tube =
dynamic_cast<TGeoTubeSeg*
>(geoShape);
89 if (tube ==
nullptr) {
90 ACTS_ERROR(
" Disc layer has wrong shape - needs to be TGeoTubeSeg!");
107 if (layerSurfaces.empty()) {
111 double z = (zMin + zMax) * 0.5;
114 double eiz = (z != 0.) ? z - m_cfg.defaultThickness : 0.;
115 double eoz = (z != 0.) ? z + m_cfg.defaultThickness : 0.;
122 <<
" senstive surfaces.");
131 throw std::logic_error(
132 std::string(
"Layer DetElement: ") + detElement.name() +
133 std::string(
" has neither a shape nor tolerances for envelopes "
134 "added to its extension. Please check your detector "
138 std::shared_ptr<Layer> endcapLayer =
nullptr;
140 if (detElement.volume().isSensitive()) {
142 auto sensitiveSurf = createSensitiveSurface(detElement,
true);
144 std::unique_ptr<Acts::SurfaceArray> sArray =
145 std::make_unique<SurfaceArray>(sensitiveSurf);
148 auto dBounds = std::make_shared<const RadialBounds>(pl.
min(
Acts::binR),
156 endcapLayer = m_cfg.layerCreator->discLayer(
157 gctx, layerSurfaces, m_cfg.bTypeR, m_cfg.bTypePhi, pl,
transform,
163 layers.push_back(endcapLayer);
171 return endcapLayers(gctx, m_cfg.negativeLayers,
"negative");
177 if (m_cfg.centralLayers.empty()) {
178 ACTS_VERBOSE(
" No layers handed over for central volume!");
181 " Received layers for central volume -> creating "
182 "cylindrical layers");
184 for (
auto& detElement : m_cfg.centralLayers) {
186 std::vector<std::shared_ptr<const Surface>> layerSurfaces;
193 resolveSensitive(detElement, layerSurfaces);
196 convertTransform(&(detElement.nominal().worldTransformation()));
198 TGeoShape* geoShape =
199 detElement.placement().ptr()->GetVolume()->GetShape();
202 if (detExtension->
hasValue(
"r",
"envelope") &&
203 detExtension->
hasValue(
"z",
"envelope")) {
206 detExtension->
getValue(
"r",
"envelope")};
208 detExtension->
getValue(
"z",
"envelope")};
209 }
else if (geoShape !=
nullptr) {
210 TGeoTubeSeg* tube =
dynamic_cast<TGeoTubeSeg*
>(geoShape);
213 " Cylinder layer has wrong shape - needs to be TGeoTubeSeg!");
220 if (layerSurfaces.empty()) {
223 double r = (rMin + rMax) * 0.5;
226 double eir = (r != 0.) ? r - m_cfg.defaultThickness : 0.;
227 double eor = (r != 0.) ? r + m_cfg.defaultThickness : 0.;
241 throw std::logic_error(
242 std::string(
"Layer DetElement: ") + detElement.name() +
243 std::string(
" has neither a shape nor tolerances for envelopes "
244 "added to it¥s extension. Please check your detector "
250 std::shared_ptr<Layer> centralLayer =
nullptr;
252 if (detElement.volume().isSensitive()) {
254 auto sensitiveSurf = createSensitiveSurface(detElement);
256 std::unique_ptr<Acts::SurfaceArray> sArray =
257 std::make_unique<SurfaceArray>(sensitiveSurf);
262 std::shared_ptr<const CylinderBounds> cBounds(
270 centralLayer = m_cfg.layerCreator->cylinderLayer(
271 gctx, layerSurfaces, m_cfg.bTypePhi, m_cfg.bTypeZ, pl,
transform,
277 layers.push_back(centralLayer);
285 return endcapLayers(gctx, m_cfg.positiveLayers,
"positive");
289 const dd4hep::DetElement& detElement,
290 std::vector<std::shared_ptr<const Acts::Surface>>& surfaces)
const {
291 const dd4hep::DetElement::Children& children = detElement.children();
292 if (!children.empty()) {
293 for (
auto& child : children) {
294 dd4hep::DetElement childDetElement = child.second;
295 if (childDetElement.volume().isSensitive()) {
297 surfaces.push_back(createSensitiveSurface(childDetElement,
false));
299 resolveSensitive(childDetElement, surfaces);
304 std::shared_ptr<const Acts::Surface>
306 const dd4hep::DetElement& detElement,
bool isDisc)
const {
311 }
catch (std::runtime_error&
e) {
316 auto detAxis = detExtension->
getType(
"axes",
"definitions");
320 isDisc,
nullptr,
nullptr);
327 const TGeoMatrix* tGeoTrans)
const {
329 const Double_t* rotation = tGeoTrans->GetRotationMatrix();
330 const Double_t* translation = tGeoTrans->GetTranslation();
336 translation[1] * UnitConstants::cm,
337 translation[2] * UnitConstants::cm));