Skip to content

Commit f4d3d88

Browse files
committed
make some useful methods public
1 parent 4355a0e commit f4d3d88

5 files changed

Lines changed: 58 additions & 53 deletions

File tree

Core/include/Acts/Geometry/BlueprintBuilder.hpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,9 @@ class BlueprintBuilder {
255255

256256
std::shared_ptr<Acts::Experimental::LayerBlueprintNode> makeLayer(
257257
const Element& detElement, const LayerSpec& layerSpec) const;
258+
std::shared_ptr<Acts::Experimental::LayerBlueprintNode> makeLayer(
259+
const Element& parent, std::span<const Element> sensitives,
260+
const LayerSpec& layerSpec) const;
258261

259262
LayerAssembler layers() const;
260263
BarrelEndcapAssembler barrelEndcap() const;
@@ -275,15 +278,9 @@ class BlueprintBuilder {
275278
const Acts::Logger& logger() const;
276279
const Backend& backend() const;
277280

278-
private:
279-
std::shared_ptr<Acts::Experimental::LayerBlueprintNode>
280-
makeLayerFromSensitives(const Element& parent,
281-
std::span<const Element> sensitives,
282-
const LayerSpec& layerSpec) const;
283-
284-
static std::vector<Element> resolveSensitives(const Backend& backend,
285-
const Element& detElement);
281+
std::vector<Element> resolveSensitives(const Element& detElement) const;
286282

283+
private:
287284
std::unique_ptr<const Acts::Logger> m_logger;
288285
Backend m_backend;
289286
};

Core/include/Acts/Geometry/detail/BlueprintBuilder_impl.hpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -395,8 +395,8 @@ template <detail::BlueprintBackend BackendT>
395395
std::shared_ptr<Acts::Experimental::LayerBlueprintNode>
396396
BlueprintBuilder<BackendT>::makeLayer(const Element& detElement,
397397
const LayerSpec& layerSpec) const {
398-
auto sensitives = resolveSensitives(m_backend, detElement);
399-
return makeLayerFromSensitives(detElement, sensitives, layerSpec);
398+
auto sensitives = resolveSensitives(detElement);
399+
return makeLayer(detElement, sensitives, layerSpec);
400400
}
401401

402402
template <detail::BlueprintBackend BackendT>
@@ -530,7 +530,7 @@ BlueprintBuilder<BackendT>::findEndcapElements(const Element& assembly) const {
530530

531531
template <detail::BlueprintBackend BackendT>
532532
std::shared_ptr<Acts::Experimental::LayerBlueprintNode>
533-
BlueprintBuilder<BackendT>::makeLayerFromSensitives(
533+
BlueprintBuilder<BackendT>::makeLayer(
534534
const Element& parent, std::span<const Element> sensitives,
535535
const LayerSpec& layerSpec) const {
536536
std::string fullLayerName = getPathToElementName(parent);
@@ -545,15 +545,14 @@ BlueprintBuilder<BackendT>::makeLayerFromSensitives(
545545

546546
template <detail::BlueprintBackend BackendT>
547547
std::vector<typename BlueprintBuilder<BackendT>::Element>
548-
BlueprintBuilder<BackendT>::resolveSensitives(const Backend& backend,
549-
const Element& detElement) {
548+
BlueprintBuilder<BackendT>::resolveSensitives(const Element& detElement) const {
550549
std::vector<Element> sensitives;
551550

552551
std::function<void(const Element&)> visit = [&](const Element& elem) {
553-
if (backend.isSensitive(elem)) {
552+
if (m_backend.isSensitive(elem)) {
554553
sensitives.push_back(elem);
555554
}
556-
for (const auto& child : backend.children(elem)) {
555+
for (const auto& child : m_backend.children(elem)) {
557556
visit(child);
558557
}
559558
};

Plugins/DD4hep/src/BlueprintBuilder.cpp

Lines changed: 4 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -107,40 +107,6 @@ bool DD4hepBackend::isTracker(const Element& element) const {
107107
return dd4hep::DetType{element.typeFlag()}.is(dd4hep::DetType::TRACKER);
108108
}
109109

110-
namespace {
111-
Acts::Transform3 convertTGeoTransform(const TGeoShape& shape,
112-
const TGeoMatrix& transform,
113-
TGeoAxes axes, double lengthScale) {
114-
const Double_t* translation = transform.GetTranslation();
115-
const Double_t* rotation = transform.GetRotationMatrix();
116-
117-
auto [cBounds, cTransform, cThickness] =
118-
ActsPlugins::TGeoSurfaceConverter::cylinderComponents(
119-
shape, rotation, translation, axes, lengthScale);
120-
if (cBounds != nullptr) {
121-
return cTransform;
122-
}
123-
124-
auto [dBounds, dTransform, dThickness] = TGeoSurfaceConverter::discComponents(
125-
shape, rotation, translation, axes, lengthScale);
126-
if (dBounds != nullptr) {
127-
return dTransform;
128-
}
129-
130-
auto [pBounds, pTransform, pThickness] =
131-
TGeoSurfaceConverter::planeComponents(shape, rotation, translation, axes,
132-
lengthScale);
133-
if (pBounds != nullptr) {
134-
return pTransform;
135-
}
136-
137-
throw std::runtime_error(
138-
"Could not extract transform from TGeoShape of type " +
139-
std::string(shape.ClassName()));
140-
}
141-
142-
} // namespace
143-
144110
std::shared_ptr<Acts::Experimental::LayerBlueprintNode>
145111
DD4hepBackend::makeLayer(const dd4hep::DetElement& parent,
146112
std::span<const dd4hep::DetElement> sensitives,
@@ -172,10 +138,10 @@ DD4hepBackend::makeLayer(const dd4hep::DetElement& parent,
172138
if (layerSpec.layerAxes.has_value()) {
173139
ACTS_DEBUG("Finding layer transform automatically using layer axes: "
174140
<< layerSpec.layerAxes.value());
175-
Acts::Transform3 layerTransform =
176-
convertTGeoTransform(*parent.placement().ptr()->GetVolume()->GetShape(),
177-
parent.nominal().worldTransformation(),
178-
layerSpec.layerAxes.value(), m_cfg.lengthScale);
141+
Acts::Transform3 layerTransform = TGeoSurfaceConverter::transformFromShape(
142+
*parent.placement().ptr()->GetVolume()->GetShape(),
143+
parent.nominal().worldTransformation(), layerSpec.layerAxes.value(),
144+
m_cfg.lengthScale);
179145

180146
ACTS_VERBOSE(" -> Layer transform:\n" << layerTransform.matrix());
181147
node->setTransform(layerTransform);

Plugins/Root/include/ActsPlugins/Root/TGeoSurfaceConverter.hpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,20 @@ struct TGeoSurfaceConverter {
9898
const TGeoShape& tgShape, const TGeoMatrix& tgMatrix, TGeoAxes axes,
9999
double scalor = 10.) noexcept(false);
100100

101+
/// Extract the transform from a TGeoShape by trying cylinder, disc, then
102+
/// plane conversion.
103+
///
104+
/// @param tgShape The TGeoShape
105+
/// @param tgMatrix The matrix representing the transform
106+
/// @param axes The axes definition
107+
/// @param scalor The unit scalor between TGeo and Acts
108+
/// @return The Acts transform
109+
/// @throws std::runtime_error if the shape cannot be converted
110+
static Acts::Transform3 transformFromShape(const TGeoShape& tgShape,
111+
const TGeoMatrix& tgMatrix,
112+
TGeoAxes axes,
113+
double scalor = 10.) noexcept(false);
114+
101115
/// Translate TGeo degree [0, 360) to radian
102116
/// * will correct to [-pi,pi)
103117
/// * it will return any multiple of 360.0 to 2pi

Plugins/Root/src/TGeoSurfaceConverter.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,3 +484,32 @@ ActsPlugins::TGeoSurfaceConverter::toSurface(const TGeoShape& tgShape,
484484

485485
return {nullptr, 0.};
486486
}
487+
488+
Acts::Transform3 ActsPlugins::TGeoSurfaceConverter::transformFromShape(
489+
const TGeoShape& tgShape, const TGeoMatrix& tgMatrix, TGeoAxes axes,
490+
double scalor) noexcept(false) {
491+
const Double_t* rotation = tgMatrix.GetRotationMatrix();
492+
const Double_t* translation = tgMatrix.GetTranslation();
493+
494+
auto [cBounds, cTransform, cThickness] =
495+
cylinderComponents(tgShape, rotation, translation, axes, scalor);
496+
if (cBounds != nullptr) {
497+
return cTransform;
498+
}
499+
500+
auto [dBounds, dTransform, dThickness] =
501+
discComponents(tgShape, rotation, translation, axes, scalor);
502+
if (dBounds != nullptr) {
503+
return dTransform;
504+
}
505+
506+
auto [pBounds, pTransform, pThickness] =
507+
planeComponents(tgShape, rotation, translation, axes, scalor);
508+
if (pBounds != nullptr) {
509+
return pTransform;
510+
}
511+
512+
throw std::runtime_error(
513+
"Could not extract transform from TGeoShape of type " +
514+
std::string(tgShape.ClassName()));
515+
}

0 commit comments

Comments
 (0)