Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-10-18 08:20:31

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   /// @return Reference to this GeometryObject after assignment
0045   GeometryObject& operator=(const GeometryObject& geometryId) {
0046     if (&geometryId != this) {
0047       m_geometryId = geometryId.m_geometryId;
0048     }
0049     return *this;
0050   }
0051 
0052   /// @return the geometry id by reference
0053   GeometryIdentifier geometryId() const;
0054 
0055   /// Force a binning position method
0056   ///
0057   /// @param gctx The current geometry context object, e.g. alignment
0058   /// @param aDir is the value for which the reference position is requesed
0059   ///
0060   /// @return vector 3D used for the binning schema
0061   virtual Vector3 referencePosition(const GeometryContext& gctx,
0062                                     AxisDirection aDir) const = 0;
0063 
0064   /// Implement the binningValue
0065   ///
0066   /// @param gctx The current geometry context object, e.g. alignment
0067   /// @param aDir is the dobule in which you want to bin
0068   ///
0069   /// @return float to be used for the binning schema
0070   virtual double referencePositionValue(const GeometryContext& gctx,
0071                                         AxisDirection aDir) const;
0072 
0073   /// Set the value
0074   ///
0075   /// @param geometryId the geometry identifier to be assigned
0076   void assignGeometryId(const GeometryIdentifier& geometryId);
0077 
0078  protected:
0079   /// Unique geometry identifier for this object
0080   GeometryIdentifier m_geometryId;
0081 };
0082 
0083 inline GeometryIdentifier GeometryObject::geometryId() const {
0084   return m_geometryId;
0085 }
0086 
0087 inline void GeometryObject::assignGeometryId(
0088     const GeometryIdentifier& geometryId) {
0089   m_geometryId = geometryId;
0090 }
0091 
0092 inline double GeometryObject::referencePositionValue(
0093     const GeometryContext& gctx, AxisDirection aDir) const {
0094   return VectorHelpers::cast(referencePosition(gctx, aDir), aDir);
0095 }
0096 
0097 }  // namespace Acts