Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:28:02

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2021 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 http://mozilla.org/MPL/2.0/.
0008 
0009 #pragma once
0010 
0011 #include "Acts/Geometry/GeometryContext.hpp"
0012 #include "Acts/Plugins/TGeo/ITGeoDetectorElementSplitter.hpp"
0013 #include "Acts/Utilities/Logger.hpp"
0014 
0015 #include <map>
0016 #include <memory>
0017 #include <regex>
0018 #include <string>
0019 #include <tuple>
0020 #include <utility>
0021 #include <vector>
0022 
0023 class TGeoNode;
0024 
0025 namespace Acts {
0026 class TGeoDetectorElement;
0027 }
0028 
0029 namespace ActsExamples {
0030 
0031 /// @brief TGeoITkModuleSplitter
0032 ///
0033 /// Split Itk modules into submodules, depending on the sensor type
0034 class TGeoITkModuleSplitter : public Acts::ITGeoDetectorElementSplitter {
0035  public:
0036   using SplitRange = std::pair<double, double>;
0037 
0038   /// Nested configuration struct
0039   struct Config {
0040     // Map the nodes name to the splitting parameters
0041     std::map<std::string, unsigned int> barrelMap = {};
0042     std::map<std::string, std::vector<SplitRange>> discMap = {};
0043     std::map<std::string, std::string> splitPatterns;
0044   };
0045 
0046   /// Constructor
0047   ///
0048   /// @param cfg the configuration struct
0049   /// @param logger the logging object
0050   TGeoITkModuleSplitter(const Config& cfg,
0051                         std::unique_ptr<const Acts::Logger> logger =
0052                             Acts::getDefaultLogger("TGeoITkModuleSplitter",
0053                                                    Acts::Logging::INFO));
0054 
0055   ~TGeoITkModuleSplitter() override = default;
0056 
0057   /// Take a geometry context and TGeoElement and find the correct splitting
0058   /// method for the module type.
0059   ///
0060   /// @param gctx is a geometry context object
0061   /// @param detElement is a TGeoDetectorElement that is eventually split
0062   ///
0063   /// @note If no split is performed the unsplit detector element is returned
0064   ///
0065   /// @return a vector of TGeoDetectorElement objects
0066   std::vector<std::shared_ptr<const Acts::TGeoDetectorElement>> split(
0067       const Acts::GeometryContext& gctx,
0068       std::shared_ptr<const Acts::TGeoDetectorElement> detElement)
0069       const override;
0070 
0071  private:
0072   /// Categorise module split patterns as barrel or disc module splits
0073   ///
0074   /// Mark the split pattern as either barrel or disc module split
0075   /// depending on whether the split category is found in the
0076   /// barrel or disc map, and compile the regular expression.
0077   void initSplitCategories();
0078 
0079   /// Take a geometry context and TGeoElement in the Itk barrel region
0080   /// and split it into sub elements.
0081   ///
0082   /// @param gctx is a geometry context object
0083   /// @param detElement is a TGeoDetectorElement that should be split
0084   /// @param nSegments is the number of submodules
0085   ///
0086   /// @note If no split is performed the unsplit detector element is returned
0087   ///
0088   /// @return a vector of TGeoDetectorElement objects
0089   std::vector<std::shared_ptr<const Acts::TGeoDetectorElement>>
0090   splitBarrelModule(
0091       const Acts::GeometryContext& gctx,
0092       const std::shared_ptr<const Acts::TGeoDetectorElement>& detElement,
0093       unsigned int nSegments) const;
0094 
0095   /// Take a geometry context and TGeoElement in the Itk disks and split it
0096   /// into sub elements.
0097   ///
0098   /// @param gctx is a geometry context object
0099   /// @param detElement is a TGeoDetectorElement that should be split
0100   /// @param splitRanges are the ranges in r for the submodules
0101   ///
0102   /// @note If no split is performed the unsplit detector element is returned
0103   ///
0104   /// @return a vector of TGeoDetectorElement objects
0105   std::vector<std::shared_ptr<const Acts::TGeoDetectorElement>> splitDiscModule(
0106       const Acts::GeometryContext& gctx,
0107       const std::shared_ptr<const Acts::TGeoDetectorElement>& detElement,
0108       const std::vector<SplitRange>& splitRanges) const;
0109 
0110   /// Contains the splitting parameters, sorted by sensor type
0111   Config m_cfg;
0112 
0113   /// regular expressions to match sensors for barrel or disk module splits
0114   std::vector<std::tuple<std::regex, std::string, bool>> m_splitCategories;
0115 
0116   /// Private access to the logger
0117   const Acts::Logger& logger() const { return *m_logger; }
0118 
0119   /// Logging instance
0120   std::unique_ptr<const Acts::Logger> m_logger;
0121 };
0122 
0123 }  // namespace ActsExamples