Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:12:12

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/Definitions/Common.hpp"
0013 #include "Acts/Geometry/GeometryIdentifier.hpp"
0014 #include "ActsFatras/EventData/Barcode.hpp"
0015 
0016 #include <cstdint>
0017 
0018 namespace ActsFatras {
0019 
0020 /// A simulation hit on a surface.
0021 ///
0022 /// This is the undigitized, truth hit, i.e. just a recording of the particle
0023 /// state at the surface intersection. Since Fatras is surface-based, the hit
0024 /// position is always constrained to a surface. Depending on the simulated
0025 /// interactions the momentum state before and after might differ and is
0026 /// thus stored as two separate four-vectors.
0027 class Hit {
0028  public:
0029   /// Construct default hit with (mostly) invalid information.
0030   Hit() = default;
0031   /// Construct from four-position and four-momenta.
0032   ///
0033   /// @param geometryId      Geometry identifier of the surface
0034   /// @param particleId Particle identifier of the particle that created the hit
0035   /// @param pos4       Particle space-time four-vector on the surface
0036   /// @param before4    Particle four-momentum before the interaction
0037   /// @param after4     Particle four-momentum after the interaction
0038   /// @param index_     Hit index along the particle trajectory
0039   ///
0040   /// All quantities are given in the global coordinate system. It is the
0041   /// users responsibility to ensure that the position correspond to a
0042   /// position on the given surface.
0043   Hit(Acts::GeometryIdentifier geometryId, Barcode particleId,
0044       const Acts::Vector4& pos4, const Acts::Vector4& before4,
0045       const Acts::Vector4& after4, std::int32_t index_ = -1)
0046       : m_geometryId(geometryId),
0047         m_particleId(particleId),
0048         m_index(index_),
0049         m_pos4(pos4),
0050         m_before4(before4),
0051         m_after4(after4) {}
0052   Hit(const Hit&) = default;
0053   Hit(Hit&&) = default;
0054   Hit& operator=(const Hit&) = default;
0055   Hit& operator=(Hit&&) = default;
0056 
0057   /// Geometry identifier of the hit surface.
0058   constexpr Acts::GeometryIdentifier geometryId() const { return m_geometryId; }
0059   /// Particle identifier of the particle that generated the hit.
0060   constexpr Barcode particleId() const { return m_particleId; }
0061   /// Hit index along the particle trajectory.
0062   ///
0063   /// @retval negative if the hit index is undefined.
0064   constexpr std::int32_t index() const { return m_index; }
0065 
0066   /// Space-time position four-vector.
0067   const Acts::Vector4& fourPosition() const { return m_pos4; }
0068   /// Three-position, i.e. spatial coordinates without the time.
0069   auto position() const { return m_pos4.segment<3>(Acts::ePos0); }
0070   /// Time coordinate.
0071   double time() const { return m_pos4[Acts::eTime]; }
0072 
0073   /// Particle four-momentum before the hit.
0074   const Acts::Vector4& momentum4Before() const { return m_before4; }
0075   /// Particle four-momentum after the hit.
0076   const Acts::Vector4& momentum4After() const { return m_after4; }
0077   /// Normalized particle direction vector before the hit.
0078   Acts::Vector3 directionBefore() const {
0079     return m_before4.segment<3>(Acts::eMom0).normalized();
0080   }
0081   /// Normalized particle direction vector the hit.
0082   Acts::Vector3 directionAfter() const {
0083     return m_after4.segment<3>(Acts::eMom0).normalized();
0084   }
0085   /// Average normalized particle direction vector through the surface.
0086   Acts::Vector3 direction() const {
0087     auto dir0 = m_before4.segment<3>(Acts::eMom0).normalized();
0088     auto dir1 = m_after4.segment<3>(Acts::eMom0).normalized();
0089     return ((dir0 + dir1) / 2.).segment<3>(Acts::eMom0).normalized();
0090   }
0091   /// Energy deposited by the hit.
0092   ///
0093   /// @retval positive if the particle lost energy when it passed the surface
0094   /// @retval negative if magic was involved
0095   double depositedEnergy() const {
0096     return m_before4[Acts::eEnergy] - m_after4[Acts::eEnergy];
0097   }
0098 
0099  private:
0100   /// Identifier of the surface.
0101   Acts::GeometryIdentifier m_geometryId;
0102   /// Identifier of the generating particle.
0103   Barcode m_particleId;
0104   /// Index of the hit along the particle trajectory.
0105   std::int32_t m_index = -1;
0106   /// Global space-time position four-vector.
0107   Acts::Vector4 m_pos4 = Acts::Vector4::Zero();
0108   /// Global particle energy-momentum four-vector before the hit.
0109   Acts::Vector4 m_before4 = Acts::Vector4::Zero();
0110   /// Global particle energy-momentum four-vector after the hit.
0111   Acts::Vector4 m_after4 = Acts::Vector4::Zero();
0112 };
0113 
0114 }  // namespace ActsFatras