Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-04 07:59:18

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/Volume.hpp"
0012 #include "Acts/Geometry/VolumeResizeStrategy.hpp"
0013 #include "Acts/Utilities/AxisDefinitions.hpp"
0014 
0015 #include <span>
0016 #include <vector>
0017 
0018 namespace Acts {
0019 
0020 /// @class VolumeStack
0021 /// @brief A stack of volumes
0022 /// @note This is a base class for the different types of volume stacks
0023 class VolumeStack : public Volume {
0024  public:
0025   /// Access the gap volume that were created during attachment or resizing.
0026   /// @return the vector of gap volumes
0027   const std::vector<std::shared_ptr<Volume>>& gaps() const;
0028 
0029   /// Check if a volume is a gap volume
0030   /// @param volume is the volume to check
0031   /// @return true if the volume is a gap volume, false otherwise
0032   bool isGapVolume(const Volume& volume) const;
0033 
0034  private:
0035   /// Helper to get the first volume in the input, and throw an exception if
0036   /// there is not one.
0037   /// @param volumes is the vector of volumes
0038   /// @return the first volume
0039   static Volume& initialVolume(std::span<Volume*> volumes);
0040 
0041  protected:
0042   /// Pair of resize strategies for volume stacking
0043   struct ResizeStrategies {
0044     /// First resize strategy
0045     VolumeResizeStrategy first;
0046     /// Second resize strategy
0047     VolumeResizeStrategy second;
0048 
0049     friend std::ostream& operator<<(std::ostream& os,
0050                                     const ResizeStrategies& rs) {
0051       if (rs.first == rs.second) {
0052         os << "<-" << rs.first << "->";
0053       } else {
0054         os << "<-" << rs.first << "|" << rs.second << "->";
0055       }
0056       return os;
0057     }
0058   };
0059 
0060   /// @param volumes is the vector of volumes
0061   /// @param direction is the direction of the stack
0062   /// @param resizeStrategies is the pair of resize strategies
0063   VolumeStack(
0064       std::vector<Volume*>& volumes, AxisDirection direction,
0065       std::pair<VolumeResizeStrategy, VolumeResizeStrategy> resizeStrategies);
0066 
0067   /// @param transform is the transform of the gap volume
0068   /// @param bounds is the bounds of the gap volume
0069   /// @return the shared pointer to the gap volume
0070   std::shared_ptr<Volume> addGapVolume(
0071       const Transform3& transform, const std::shared_ptr<VolumeBounds>& bounds);
0072 
0073   /// Direction axis along which volumes are stacked
0074   AxisDirection m_direction{};
0075 
0076   /// Resize strategies for volume attachment and modification
0077   ResizeStrategies m_resizeStrategies;
0078 
0079   /// Container of gap volumes created during volume attachment or resizing
0080   std::vector<std::shared_ptr<Volume>> m_gaps{};
0081   /// Reference to the vector of volumes in the stack
0082   std::vector<Volume*>& m_volumes;
0083 };
0084 }  // namespace Acts