Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-16 08:12:53

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/Definitions/Algebra.hpp"
0012 #include "Acts/Geometry/GeometryContext.hpp"
0013 #include "Acts/Geometry/GeometryIdentifier.hpp"
0014 #include "Acts/Utilities/AxisDefinitions.hpp"
0015 #include "Acts/Utilities/VectorHelpers.hpp"
0016 
0017 namespace Acts {
0018 
0019 /// Base class to provide GeometryIdentifier interface:
0020 /// - simple set and get
0021 ///
0022 /// It also provides the referencePosition method for
0023 /// Geometry geometrical object to be binned in BinnedArrays
0024 ///
0025 class GeometryObject {
0026  public:
0027   /// Defaulted constructor
0028   GeometryObject() = default;
0029 
0030   /// Defaulted copy constructor
0031   GeometryObject(const GeometryObject&) = default;
0032 
0033   /// Constructor from a value
0034   ///
0035   /// @param geometryId the geometry identifier of the object
0036   explicit GeometryObject(const GeometryIdentifier& geometryId)
0037       : m_geometryId(geometryId) {}
0038 
0039   virtual ~GeometryObject() noexcept = default;
0040 
0041   /// Assignment operator
0042   ///
0043   /// @param geometryId the source geometryId
0044   GeometryObject& operator=(const GeometryObject& geometryId) {
0045     if (&geometryId != this) {
0046       m_geometryId = geometryId.m_geometryId;
0047     }
0048     return *this;
0049   }
0050 
0051   /// @return the geometry id by reference
0052   GeometryIdentifier geometryId() const;
0053 
0054   /// Force a binning position method
0055   ///
0056   /// @param gctx The current geometry context object, e.g. alignment
0057   /// @param aDir is the value for which the reference position is requesed
0058   ///
0059   /// @return vector 3D used for the binning schema
0060   virtual Vector3 referencePosition(const GeometryContext& gctx,
0061                                     AxisDirection aDir) const = 0;
0062 
0063   /// Implement the binningValue
0064   ///
0065   /// @param gctx The current geometry context object, e.g. alignment
0066   /// @param aDir is the dobule in which you want to bin
0067   ///
0068   /// @return float to be used for the binning schema
0069   virtual double referencePositionValue(const GeometryContext& gctx,
0070                                         AxisDirection aDir) const;
0071 
0072   /// Set the value
0073   ///
0074   /// @param geometryId the geometry identifier to be assigned
0075   void assignGeometryId(const GeometryIdentifier& geometryId);
0076 
0077  protected:
0078   GeometryIdentifier m_geometryId;
0079 };
0080 
0081 inline GeometryIdentifier GeometryObject::geometryId() const {
0082   return m_geometryId;
0083 }
0084 
0085 inline void GeometryObject::assignGeometryId(
0086     const GeometryIdentifier& geometryId) {
0087   m_geometryId = geometryId;
0088 }
0089 
0090 inline double GeometryObject::referencePositionValue(
0091     const GeometryContext& gctx, AxisDirection aDir) const {
0092   return VectorHelpers::cast(referencePosition(gctx, aDir), aDir);
0093 }
0094 
0095 }  // namespace Acts