25 #include "TGeoManager.h"
26 #include "TGeoMatrix.h"
29 class ISurfaceMaterial;
34 std::unique_ptr<const Logger>
logger)
47 std::unique_ptr<const Logger> newLogger) {
81 if (gGeoManager ==
nullptr) {
86 using LayerSurfaceVector = std::vector<std::shared_ptr<const Surface>>;
87 LayerSurfaceVector layerSurfaces;
89 std::vector<LayerConfig> layerConfigs =
m_cfg.layerConfigurations[type + 1];
96 addonOutput +=
m_cfg.layerSplitToleranceZ[type + 1] > 0.
102 ACTS_DEBUG(layerType <<
" layers : found " << layerConfigs.size()
103 <<
" configuration(s)" + addonOutput);
106 auto fillLayer = [&](
const LayerSurfaceVector& lSurfaces,
108 unsigned int pl_id = 0) ->
void {
109 int nb0 = 0, nt0 = 0;
110 bool is_autobinning = ((lCfg.binning0.size() == 1) and
111 (std::get<int>(lCfg.binning0.at(0)) <= 0));
112 if (!is_autobinning and std::get<int>(lCfg.binning0.at(pl_id)) <= 0) {
113 throw std::invalid_argument(
114 "Incorrect binning configuration found for loc0 protolayer #" +
116 ". Layer is autobinned: No mixed binning (manual and auto) for loc0 "
117 "possible between layers in a single subvolume. Quitting");
119 if (is_autobinning) {
121 nb0 = std::get<int>(lCfg.binning0.at(0));
123 nt0 = std::get<BinningType>(lCfg.binning0.at(0));
124 }
else if (pl_id < lCfg.binning0.size()) {
126 nb0 = std::get<int>(lCfg.binning0.at(pl_id));
129 int nb1 = 0, nt1 = 0;
130 is_autobinning = (lCfg.binning1.size() == 1) and
131 (std::get<int>(lCfg.binning1.at(0)) <= 0);
132 if (!is_autobinning and std::get<int>(lCfg.binning1.at(pl_id)) <= 0) {
133 throw std::invalid_argument(
134 "Incorrect binning configuration found for loc1 protolayer #" +
136 ". Layer is autobinned: No mixed binning (manual and auto) for loc1 "
137 "possible between layers in a single subvolume. Quitting");
139 if (is_autobinning) {
141 nb1 = std::get<int>(lCfg.binning1.at(0));
143 nt1 = std::get<BinningType>(lCfg.binning1.at(0));
144 }
else if (pl_id < lCfg.binning1.size()) {
146 nb1 = std::get<int>(lCfg.binning1.at(pl_id));
152 << lSurfaces.size() <<
" surfaces at r = " << pl.
medium(
binR));
156 if (nb0 >= 0 and nb1 >= 0) {
158 m_cfg.layerCreator->cylinderLayer(gctx, lSurfaces, nb0, nb1, pl));
161 m_cfg.layerCreator->cylinderLayer(gctx, lSurfaces, nt0, nt1, pl));
166 << lSurfaces.size() <<
" surfaces at z = " << pl.
medium(
binZ));
170 if (nb0 >= 0 and nb1 >= 0) {
172 m_cfg.layerCreator->discLayer(gctx, lSurfaces, nb0, nb1, pl));
175 m_cfg.layerCreator->discLayer(gctx, lSurfaces, nt0, nt1, pl));
180 for (
auto layerCfg : layerConfigs) {
181 ACTS_DEBUG(
"- layer configuration found for layer " << layerCfg.volumeName
182 <<
" with sensors ");
183 for (
auto& sensor : layerCfg.sensorNames) {
186 if (not layerCfg.parseRanges.empty()) {
187 for (
const auto& pRange : layerCfg.parseRanges) {
190 << pRange.second.first <<
"/" << pRange.second.second
194 if (not layerCfg.splitConfigs.empty()) {
195 for (
const auto& sConfig : layerCfg.splitConfigs) {
198 << sConfig.second <<
".");
203 TGeoVolume* tVolume =
204 gGeoManager->FindVolumeFast(layerCfg.volumeName.c_str());
205 if (tVolume ==
nullptr) {
206 tVolume = gGeoManager->GetTopVolume();
207 ACTS_DEBUG(
"- search volume is TGeo top volume");
209 ACTS_DEBUG(
"- setting search volume to " << tVolume->GetName());
212 if (tVolume !=
nullptr) {
219 tgpState.
volume = tVolume;
221 ACTS_DEBUG(
"- applying " << layerCfg.parseRanges.size()
222 <<
" search restrictions.");
223 for (
const auto& prange : layerCfg.parseRanges) {
225 <<
" within [ " << prange.second.first <<
", "
226 << prange.second.second <<
"]");
231 ACTS_DEBUG(
"- number of selected nodes found : "
236 m_cfg.identifierProvider !=
nullptr
237 ?
m_cfg.identifierProvider->identify(gctx, *snode.node)
242 layerCfg.localAxes,
m_cfg.unit,
nullptr);
244 std::vector<std::shared_ptr<const Acts::TGeoDetectorElement>>
246 (
m_cfg.detectorElementSplitter ==
nullptr)
247 ? std::vector<std::shared_ptr<
249 :
m_cfg.detectorElementSplitter->split(gctx, tgElement);
251 for (
const auto& tge : tgElements) {
252 m_elementStore.push_back(tge);
253 layerSurfaces.push_back(tge->surface().getSharedPtr());
257 ACTS_DEBUG(
"- created TGeoDetectorElements : " << layerSurfaces.size());
259 if (
m_cfg.protoLayerHelper !=
nullptr and
260 not layerCfg.splitConfigs.empty()) {
261 auto protoLayers =
m_cfg.protoLayerHelper->protoLayers(
263 ACTS_DEBUG(
"- splitting into " << protoLayers.size() <<
" layers.");
267 const bool is_loc0_n_config =
268 layerCfg.binning0.size() == protoLayers.size();
269 const bool is_loc0_autobinning =
270 (layerCfg.binning0.size() == 1) and
271 (std::get<int>(layerCfg.binning0.at(0)) <= 0);
272 const bool is_loc1_n_config =
273 layerCfg.binning1.size() == protoLayers.size();
274 const bool is_loc1_autobinning =
275 (layerCfg.binning1.size() == 1) and
276 (std::get<int>(layerCfg.binning1.at(0)) <= 0);
277 if ((!is_loc0_n_config and !is_loc0_autobinning) or
278 (!is_loc1_n_config and !is_loc1_autobinning)) {
279 throw std::invalid_argument(
280 "Incorrect binning configuration found: Number of configurations "
281 "does not match number of protolayers in subvolume " +
282 layerCfg.volumeName +
". Quitting.");
284 unsigned int layer_id = 0;
285 for (
auto& pLayer : protoLayers) {
286 layerSurfaces.clear();
288 for (
const auto& lsurface : pLayer.surfaces()) {
289 layerSurfaces.push_back(lsurface->getSharedPtr());
291 fillLayer(layerSurfaces, layerCfg, layer_id);
295 fillLayer(layerSurfaces, layerCfg);
302 std::shared_ptr<Acts::TGeoDetectorElement>
305 const TGeoMatrix& tGeoMatrix,
const std::string& axes,
double scalor,
306 std::shared_ptr<const Acts::ISurfaceMaterial>
material) {
307 return std::make_shared<TGeoDetectorElement>(