Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-09 07:49:37

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   struct ResizeStrategies {
0043     VolumeResizeStrategy first;
0044     VolumeResizeStrategy second;
0045 
0046     friend std::ostream& operator<<(std::ostream& os,
0047                                     const ResizeStrategies& rs) {
0048       if (rs.first == rs.second) {
0049         os << "<-" << rs.first << "->";
0050       } else {
0051         os << "<-" << rs.first << "|" << rs.second << "->";
0052       }
0053       return os;
0054     }
0055   };
0056 
0057   /// @param volumes is the vector of volumes
0058   /// @param direction is the direction of the stack
0059   /// @param resizeStrategies is the pair of resize strategies
0060   VolumeStack(
0061       std::vector<Volume*>& volumes, AxisDirection direction,
0062       std::pair<VolumeResizeStrategy, VolumeResizeStrategy> resizeStrategies);
0063 
0064   /// @param transform is the transform of the gap volume
0065   /// @param bounds is the bounds of the gap volume
0066   /// @return the shared pointer to the gap volume
0067   std::shared_ptr<Volume> addGapVolume(
0068       const Transform3& transform, const std::shared_ptr<VolumeBounds>& bounds);
0069 
0070   AxisDirection m_direction{};
0071 
0072   ResizeStrategies m_resizeStrategies;
0073 
0074   std::vector<std::shared_ptr<Volume>> m_gaps{};
0075   std::vector<Volume*>& m_volumes;
0076 };
0077 }  // namespace Acts