Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-19 09:23:34

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2016-2020 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/Definitions/Algebra.hpp"
0012 #include "Acts/Surfaces/BoundaryCheck.hpp"
0013 #include "Acts/Surfaces/SurfaceBounds.hpp"
0014 
0015 #include <array>
0016 #include <iosfwd>
0017 #include <stdexcept>
0018 #include <vector>
0019 
0020 namespace Acts {
0021 
0022 /// @class LineBounds
0023 ///
0024 /// Bounds for a LineSurface.
0025 class LineBounds : public SurfaceBounds {
0026  public:
0027   enum BoundValues : int { eR = 0, eHalfLengthZ = 1, eSize = 2 };
0028 
0029   LineBounds() = delete;
0030 
0031   /// Constructor
0032   ///
0033   /// @param r is the radius of the cylinder, default = 0.
0034   /// @param halfZ is the half length in z, default = 0.
0035   LineBounds(double r, double halfZ) noexcept(false) : m_values({r, halfZ}) {
0036     checkConsistency();
0037   }
0038 
0039   /// Constructor - from fixed size array
0040   ///
0041   /// @param values The parameter values
0042   LineBounds(const std::array<double, eSize>& values) noexcept(false)
0043       : m_values(values) {
0044     checkConsistency();
0045   }
0046 
0047   ~LineBounds() override = default;
0048 
0049   BoundsType type() const final;
0050 
0051   /// Return the bound values as dynamically sized vector
0052   ///
0053   /// @return this returns a copy of the internal values
0054   std::vector<double> values() const final;
0055 
0056   /// Inside check for the bounds object driven by the boundary check directive
0057   /// Each Bounds has a method inside, which checks if a LocalPosition is inside
0058   /// the bounds  Inside can be called without/with tolerances.
0059   ///
0060   /// @param lposition Local position (assumed to be in right surface frame)
0061   /// @param bcheck boundary check directive
0062   ///
0063   /// @return boolean indicator for the success of this operation
0064   bool inside(const Vector2& lposition,
0065               const BoundaryCheck& bcheck) const final;
0066 
0067   /// Output Method for std::ostream
0068   ///
0069   /// @param sl is the ostream to be dumped into
0070   std::ostream& toStream(std::ostream& sl) const final;
0071 
0072   /// Access to the bound values
0073   /// @param bValue the class nested enum for the array access
0074   double get(BoundValues bValue) const { return m_values[bValue]; }
0075 
0076  private:
0077   std::array<double, eSize> m_values;
0078 
0079   /// Check the input values for consistency, will throw a logic_exception
0080   /// if consistency is not given
0081   void checkConsistency() noexcept(false);
0082 };
0083 
0084 inline std::vector<double> LineBounds::values() const {
0085   std::vector<double> valvector;
0086   valvector.insert(valvector.begin(), m_values.begin(), m_values.end());
0087   return valvector;
0088 }
0089 
0090 inline void LineBounds::checkConsistency() noexcept(false) {
0091   if (get(eR) < 0.) {
0092     throw std::invalid_argument("LineBounds: zero radius.");
0093   }
0094   if (get(eHalfLengthZ) <= 0.) {
0095     throw std::invalid_argument("LineBounds: zero/negative length.");
0096   }
0097 }
0098 
0099 }  // namespace Acts