Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:27:34

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2022 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/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   bool operator==(const ProtoVolume& ptVolume) const;
0086 
0087   /// Harmonize the detector information, this can run in two
0088   /// modes, steered by the @param legacy boolean
0089   ///
0090   /// The legacy mode prepares everything for `Acts::TrackingVolume`,
0091   /// if off it creates a description for `Acts::Detector`.
0092   void harmonize(bool legacy = true);
0093 
0094   /// Extend the tracking volume with its own constituents,
0095   /// upwards here means that extents are promoted to the mother
0096   ///
0097   /// @param ptVolume the protoVolume
0098   void extendUp(ProtoVolume& ptVolume);
0099 
0100   /// Extend the tracking volume with its own constituents
0101   /// @param bValue the binning value that is propagated
0102   void propagateMinDown(BinningValue bValue);
0103 
0104   /// Extend the tracking volume with its own constituents
0105   /// @param bValue the binning value that is propagated
0106   void propagateMaxDown(BinningValue bValue);
0107 
0108   /// Constrain the daughter volumes with this volume
0109   ///
0110   /// @param ptVolume is the proto volume from which the constrain
0111   /// is taken
0112   void constrainDown(const ProtoVolume& ptVolume);
0113 
0114   /// Write the tracking volume to screen
0115   /// @param indent the current indentation
0116   std::string toString(const std::string& indent = "") const;
0117 };
0118 
0119 /// A proto detector description being used to define an overall
0120 /// structure of either a TrackingGeometry or Experimental::Detector
0121 struct ProtoDetector {
0122   std::string name = "";
0123   ProtoVolume worldVolume;
0124 
0125   /// Harmonize the detector information, this can run in two
0126   /// modes, steered by the @param legacy boolean
0127   ///
0128   /// The legacy mode prepares everything for `Acts::TrackingVolume`,
0129   /// if off it creates a description for `Acts::Detector`.
0130   ///
0131   void harmonize(bool legacy = true) {
0132     worldVolume.extendUp(worldVolume);
0133     worldVolume.constrainDown(worldVolume);
0134     worldVolume.harmonize(legacy);
0135   }
0136 
0137   /// Write the tracking volume to screen
0138   /// @param indent the current indentation
0139   std::string toString(const std::string& indent = "") const;
0140 };
0141 
0142 }  // namespace Acts