Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-14 09:20:36

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/Geometry/GeometryContext.hpp"
0013 #include "Acts/Surfaces/Surface.hpp"
0014 #include "Acts/Utilities/BinningData.hpp"
0015 #include "Acts/Utilities/BinningType.hpp"
0016 #include "Acts/Utilities/Logger.hpp"
0017 
0018 #include <functional>
0019 #include <map>
0020 #include <memory>
0021 #include <optional>
0022 #include <string>
0023 #include <tuple>
0024 #include <vector>
0025 
0026 namespace Acts {
0027 
0028 struct ProtoVolume;
0029 
0030 namespace Experimental {
0031 
0032 class DetectorVolume;
0033 class Portal;
0034 
0035 /// Current volumes (connected)
0036 using DetectorVolumes = std::vector<std::shared_ptr<DetectorVolume>>;
0037 /// Current shell (i.e. outside portals)
0038 using ProtoContainer = std::map<unsigned int, std::shared_ptr<Portal>>;
0039 /// Current block (volumes and shell)
0040 using DetectorBlock = std::tuple<DetectorVolumes, ProtoContainer>;
0041 
0042 /// The detector builder function
0043 using DetectorBlockBuilder = std::function<void(
0044     DetectorBlock&, const GeometryContext&, Acts::Logging::Level)>;
0045 }  // namespace Experimental
0046 
0047 /// A proto volume description being used to define an overall
0048 /// structure of either a TrackingVolume or Experimental::DetectorVolume
0049 struct ProtoVolume {
0050   // Internal structure information
0051   struct InternalStructure {
0052     /// Possibility to provide a layer type information
0053     Surface::SurfaceType layerType = Surface::SurfaceType::Other;
0054     /// Possibility to provide a surface binning
0055     std::vector<BinningData> surfaceBinning = {};
0056   };
0057 
0058   // Container structure information
0059   struct ContainerStructure {
0060     /// Internal structure container
0061     std::vector<ProtoVolume> constituentVolumes = {};
0062     /// The constituent binning if this a container
0063     std::vector<BinningData> constituentBinning = {};
0064     /// Layer container flag
0065     bool layerContainer = false;
0066   };
0067 
0068   /// Name of the proto volume
0069   std::string name = "";
0070   /// The extent of this volume
0071   Extent extent;
0072 
0073   /// Information about internal structure - legacy building
0074   std::optional<InternalStructure> internal = std::nullopt;
0075 
0076   /// Information about container structure - legacy building
0077   std::optional<ContainerStructure> container = std::nullopt;
0078 
0079   /// An attached Detector volume Builder - new detector schema
0080   Experimental::DetectorBlockBuilder blockBuilder;
0081 
0082   /// Define an operator==
0083   ///
0084   /// @param ptVolume the proto volume to be checked
0085   /// @return True if the proto volumes are equal, false otherwise
0086   bool operator==(const ProtoVolume& ptVolume) const;
0087 
0088   /// Harmonize the detector information, this can run in two
0089   /// modes, steered by the @param legacy boolean
0090   ///
0091   /// The legacy mode prepares everything for `Acts::TrackingVolume`,
0092   /// if off it creates a description for `Acts::Detector`.
0093   void harmonize(bool legacy = true);
0094 
0095   /// Extend the tracking volume with its own constituents,
0096   /// upwards here means that extents are promoted to the mother
0097   ///
0098   /// @param ptVolume the protoVolume
0099   void extendUp(ProtoVolume& ptVolume);
0100 
0101   /// Extend the tracking volume with its own constituents
0102   /// @param aDir the axis direction that is propagated
0103   void propagateMinDown(AxisDirection aDir);
0104 
0105   /// Extend the tracking volume with its own constituents
0106   /// @param aDir the axis direction that is propagated
0107   void propagateMaxDown(AxisDirection aDir);
0108 
0109   /// Constrain the daughter volumes with this volume
0110   ///
0111   /// @param ptVolume is the proto volume from which the constrain
0112   /// is taken
0113   void constrainDown(const ProtoVolume& ptVolume);
0114 
0115   /// Write the tracking volume to screen
0116   /// @param indent the current indentation
0117   /// @return String representation of the proto volume
0118   std::string toString(const std::string& indent = "") const;
0119 };
0120 
0121 /// A proto detector description being used to define an overall
0122 /// structure of either a TrackingGeometry or Experimental::Detector
0123 struct ProtoDetector {
0124   /// Name identifier for the detector
0125   std::string name = "";
0126   /// Root volume containing all detector components
0127   ProtoVolume worldVolume;
0128 
0129   /// Harmonize the detector information, this can run in two
0130   /// modes, steered by the @param legacy boolean
0131   ///
0132   /// The legacy mode prepares everything for `Acts::TrackingVolume`,
0133   /// if off it creates a description for `Acts::Detector`.
0134   ///
0135   void harmonize(bool legacy = true) {
0136     worldVolume.extendUp(worldVolume);
0137     worldVolume.constrainDown(worldVolume);
0138     worldVolume.harmonize(legacy);
0139   }
0140 
0141   /// Write the tracking volume to screen
0142   /// @param indent the current indentation
0143   /// @return String representation of the proto detector
0144   std::string toString(const std::string& indent = "") const;
0145 };
0146 
0147 }  // namespace Acts