18 #include "TGeoManager.h"
19 #include "TGeoMatrix.h"
23 std::unique_ptr<const Logger> logger)
24 : m_cfg(), m_logger(std::move(logger)) {
36 std::unique_ptr<const Logger> newLogger) {
37 m_logger = std::move(newLogger);
70 if (gGeoManager ==
nullptr) {
75 using LayerSurfaceVector = std::vector<std::shared_ptr<const Surface>>;
76 LayerSurfaceVector layerSurfaces;
78 std::vector<LayerConfig> layerConfigs = m_cfg.layerConfigurations[type + 1];
79 std::string layerType = m_layerTypes[type + 1];
82 std::string addonOutput = m_cfg.layerSplitToleranceR[type + 1] > 0.
83 ? std::string(
", splitting in r")
85 addonOutput += m_cfg.layerSplitToleranceZ[type + 1] > 0.
86 ? std::string(
", splitting in z")
88 addonOutput += std::string(
".");
91 ACTS_DEBUG(layerType <<
" layers : found " << layerConfigs.size()
92 <<
" configuration(s)" + addonOutput);
95 auto fillLayer = [&](
const LayerSurfaceVector lSurfaces,
98 auto nb0 = std::get<int>(lCfg.binning0);
99 auto nb1 = std::get<int>(lCfg.binning1);
101 auto nt0 = std::get<BinningType>(lCfg.binning0);
102 auto nt1 = std::get<BinningType>(lCfg.binning1);
107 << lSurfaces.size() <<
" surfaces at r = " << pl.
medium(
binR));
110 if (nb0 > 0 and nb1 > 0) {
112 m_cfg.layerCreator->cylinderLayer(gctx, lSurfaces, nb0, nb1, pl));
115 m_cfg.layerCreator->cylinderLayer(gctx, lSurfaces, nt0, nt1, pl));
120 << lSurfaces.size() <<
" surfaces at z = " << pl.
medium(
binZ));
123 if (nb0 > 0 and nb1 > 0) {
125 m_cfg.layerCreator->discLayer(gctx, lSurfaces, nb0, nb1, pl));
128 m_cfg.layerCreator->discLayer(gctx, lSurfaces, nt0, nt1, pl));
133 for (
auto layerCfg : layerConfigs) {
134 ACTS_DEBUG(
"- layer configuration found for layer " << layerCfg.volumeName
135 <<
" with sensors ");
136 for (
auto& sensor : layerCfg.sensorNames) {
139 if (not layerCfg.parseRanges.empty()) {
140 for (
const auto& pRange : layerCfg.parseRanges) {
143 << pRange.second.first <<
"/" << pRange.second.second
147 if (not layerCfg.splitConfigs.empty()) {
148 for (
const auto& sConfig : layerCfg.splitConfigs) {
151 << sConfig.second <<
".");
156 TGeoVolume* tVolume =
157 gGeoManager->FindVolumeFast(layerCfg.volumeName.c_str());
158 if (tVolume ==
nullptr) {
159 tVolume = gGeoManager->GetTopVolume();
160 ACTS_DEBUG(
"- search volume is TGeo top volume");
162 ACTS_DEBUG(
"- setting search volume to " << tVolume->GetName());
165 if (tVolume !=
nullptr) {
170 tgpOptions.
unit = m_cfg.unit;
172 tgpState.
volume = tVolume;
174 ACTS_DEBUG(
"- applying " << layerCfg.parseRanges.size()
175 <<
" search restrictions.");
176 for (
const auto& prange : layerCfg.parseRanges) {
178 <<
" within [ " << prange.second.first <<
", "
179 << prange.second.second <<
"]");
184 ACTS_DEBUG(
"- number of selsected nodes found : "
189 m_cfg.identifierProvider !=
nullptr
190 ? m_cfg.identifierProvider->identify(gctx, *snode.node)
193 auto tgElement = std::make_shared<const Acts::TGeoDetectorElement>(
194 identifier, *snode.node, *snode.transform, layerCfg.localAxes,
196 m_elementStore.push_back(tgElement);
197 layerSurfaces.push_back(tgElement->surface().getSharedPtr());
200 ACTS_DEBUG(
"- created TGeoDetectorElements : " << layerSurfaces.size());
202 if (m_cfg.protoLayerHelper !=
nullptr and
203 not layerCfg.splitConfigs.empty()) {
204 auto protoLayers = m_cfg.protoLayerHelper->protoLayers(
206 ACTS_DEBUG(
"- splitting into " << protoLayers.size() <<
" layers.");
207 for (
auto& pLayer : protoLayers) {
208 layerSurfaces.clear();
209 for (
const auto& lsurface : pLayer.surfaces()) {
210 layerSurfaces.push_back(lsurface->getSharedPtr());
212 fillLayer(layerSurfaces, layerCfg);
215 fillLayer(layerSurfaces, layerCfg);