Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-06-22 08:01:24

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 #pragma once
0010 
0011 #include "Acts/Geometry/Extent.hpp"
0012 #include "Acts/Utilities/AxisDefinitions.hpp"
0013 
0014 #include <memory>
0015 #include <regex>
0016 #include <string>
0017 #include <string_view>
0018 
0019 namespace dd4hep {
0020 class Detector;
0021 }
0022 
0023 namespace Acts {
0024 class GeometryContext;
0025 class Logger;
0026 class TrackingGeometry;
0027 }  // namespace Acts
0028 
0029 namespace ActsPlugins::DD4hep {
0030 
0031 namespace detail {
0032 
0033 inline const std::regex kPixelLayerFilter{
0034     "(?:PixelLayer|PixelEndcap[NP])(\\d)"};
0035 inline const std::regex kShortStripLayerFilter{
0036     "(?:ShortStripLayer|ShortStripEndcap[NP])(\\d)"};
0037 inline const std::regex kLongStripLayerFilter{
0038     "(?:LongStripLayer|LongStripEndcap[NP])(\\d)"};
0039 inline const std::regex kPixelBarrelLayerFilter{"PixelLayer\\d"};
0040 inline const std::regex kPixelNegativeEndcapLayerFilter{"PixelEndcapN\\d"};
0041 inline const std::regex kPixelPositiveEndcapLayerFilter{"PixelEndcapP\\d"};
0042 inline const std::regex kShortStripBarrelLayerFilter{"ShortStripLayer\\d"};
0043 inline const std::regex kShortStripNegativeEndcapLayerFilter{
0044     "ShortStripEndcapN\\d"};
0045 inline const std::regex kShortStripPositiveEndcapLayerFilter{
0046     "ShortStripEndcapP\\d"};
0047 inline const std::regex kLongStripBarrelLayerFilter{"LongStripLayer\\d"};
0048 inline const std::regex kLongStripNegativeEndcapLayerFilter{
0049     "LongStripEndcapN\\d"};
0050 inline const std::regex kLongStripPositiveEndcapLayerFilter{
0051     "LongStripEndcapP\\d"};
0052 
0053 inline const Acts::ExtentEnvelope kBlueprintEnvelope =
0054     Acts::ExtentEnvelope::Zero()
0055         .set(Acts::AxisDirection::AxisZ, {20., 20.})
0056         .set(Acts::AxisDirection::AxisR, {0., 20.});
0057 
0058 inline const Acts::ExtentEnvelope kLayerEnvelope =
0059     Acts::ExtentEnvelope::Zero()
0060         .set(Acts::AxisDirection::AxisZ, {2., 2.})
0061         .set(Acts::AxisDirection::AxisR, {2., 2.});
0062 
0063 inline int layerIndexFromName(std::string_view elemName,
0064                               const std::regex& layerFilter) {
0065   std::cmatch match;
0066   if (std::regex_search(elemName.begin(), elemName.end(), match, layerFilter) &&
0067       match.size() > 1) {
0068     return std::stoi(match[1].str());
0069   }
0070 
0071   if (std::regex groupedLayerNameFilter{"layer(\\d+)"};
0072       std::regex_search(elemName.begin(), elemName.end(), match,
0073                         groupedLayerNameFilter) &&
0074       match.size() > 1) {
0075     return std::stoi(match[1].str());
0076   }
0077 
0078   return 0;
0079 }
0080 
0081 }  // namespace detail
0082 
0083 /// Build the Open Data Detector tracking geometry using the BarrelEndcap
0084 /// construction path (BarrelEndcapAssembler wrapping ElementLayerAssembler).
0085 std::unique_ptr<Acts::TrackingGeometry> buildOpenDataDetectorBarrelEndcap(
0086     const dd4hep::Detector& detector, const Acts::GeometryContext& gctx,
0087     const Acts::Logger& logger);
0088 
0089 /// Build the Open Data Detector tracking geometry using the TGeo backend with
0090 /// metadata extracted from DD4hep and explicit ODD layer-name patterns.
0091 std::unique_ptr<Acts::TrackingGeometry>
0092 buildOpenDataDetectorBarrelEndcapViaTGeo(const dd4hep::Detector& detector,
0093                                          const Acts::GeometryContext& gctx,
0094                                          const Acts::Logger& logger);
0095 
0096 /// Build the Open Data Detector tracking geometry using the DirectLayer
0097 /// construction path (ElementLayerAssembler directly).
0098 std::unique_ptr<Acts::TrackingGeometry> buildOpenDataDetectorDirectLayer(
0099     const dd4hep::Detector& detector, const Acts::GeometryContext& gctx,
0100     const Acts::Logger& logger);
0101 
0102 /// Build the Open Data Detector tracking geometry using the DirectLayerGrouped
0103 /// construction path (SensorLayerAssembler with groupBy).
0104 std::unique_ptr<Acts::TrackingGeometry> buildOpenDataDetectorDirectLayerGrouped(
0105     const dd4hep::Detector& detector, const Acts::GeometryContext& gctx,
0106     const Acts::Logger& logger);
0107 
0108 }  // namespace ActsPlugins::DD4hep