Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-27 07:23:58

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 // Project include(s).
0012 #include "detray/definitions/algebra.hpp"
0013 #include "detray/definitions/detail/qualifiers.hpp"
0014 #include "detray/definitions/units.hpp"
0015 
0016 // System include(s).
0017 #include <cstdint>
0018 
0019 namespace detray {
0020 
0021 template <concepts::scalar scalar_t>
0022 struct pdg_particle {
0023   using scalar_type = scalar_t;
0024 
0025   template <typename T>
0026   DETRAY_HOST_DEVICE constexpr pdg_particle(const std::int32_t pdg_num,
0027                                             const T mass, const T charge)
0028       : m_pdg_num(pdg_num),
0029         m_mass(static_cast<scalar_t>(mass)),
0030         m_charge(static_cast<scalar_t>(charge)) {}
0031 
0032   DETRAY_HOST_DEVICE
0033   constexpr std::int32_t pdg_num() const { return m_pdg_num; }
0034 
0035   DETRAY_HOST_DEVICE
0036   constexpr scalar_type mass() const { return m_mass; }
0037 
0038   DETRAY_HOST_DEVICE
0039   constexpr scalar_type charge() const { return m_charge; }
0040 
0041   DETRAY_HOST_DEVICE
0042   constexpr bool is_valid() const { return m_pdg_num != 0; }
0043 
0044  private:
0045   std::int32_t m_pdg_num;
0046   scalar_type m_mass;
0047   scalar_type m_charge;
0048 };
0049 
0050 /// Apply the charge conjugation operator to a particle hypothesis @param ptc
0051 template <concepts::scalar scalar_t>
0052 DETRAY_HOST_DEVICE constexpr pdg_particle<scalar_t> charge_conjugation(
0053     const pdg_particle<scalar_t>& ptc) {
0054   return (ptc.charge() != 0)
0055              ? detray::pdg_particle<scalar_t>{-ptc.pdg_num(), ptc.mass(),
0056                                               -ptc.charge()}
0057              : ptc;
0058 }
0059 
0060 /// @returns an updated particle hypothesis according to the track qop
0061 template <concepts::scalar scalar_t, typename track_t>
0062 DETRAY_HOST_DEVICE constexpr pdg_particle<scalar_t> update_particle_hypothesis(
0063     const pdg_particle<scalar_t>& ptc, const track_t& params) {
0064   return (ptc.charge() * params.qop() > 0.f) ? ptc : charge_conjugation(ptc);
0065 }
0066 
0067 // Macro for declaring the particle
0068 #define DETRAY_DECLARE_PARTICLE(PARTICLE_NAME, PDG_NUM, MASS, CHARGE) \
0069   template <concepts::scalar scalar_t>                                \
0070   struct PARTICLE_NAME final : public pdg_particle<scalar_t> {        \
0071     using base_type = pdg_particle<scalar_t>;                         \
0072     DETRAY_HOST_DEVICE                                                \
0073     constexpr PARTICLE_NAME() : base_type(PDG_NUM, MASS, CHARGE) {}   \
0074   }
0075 
0076 // Declare PDG number 0 to be invalid
0077 DETRAY_DECLARE_PARTICLE(invalid, 0, 0.f, 0.f);
0078 // Declare some predefined particles
0079 DETRAY_DECLARE_PARTICLE(electron, 11, constant<float>::m_e,
0080                         -1.f * unit<float>::e);
0081 DETRAY_DECLARE_PARTICLE(positron, -11, constant<float>::m_e,
0082                         1.f * unit<float>::e);
0083 // Muon mass from: https://physics.nist.gov/cgi-bin/cuu/Value?mmuc2mev (Visited
0084 // Aug 1st, 2024)
0085 DETRAY_DECLARE_PARTICLE(muon, 13, 105.6583755f * unit<float>::MeV,
0086                         -1.f * unit<float>::e);
0087 DETRAY_DECLARE_PARTICLE(antimuon, -13, 105.6583755f * unit<float>::MeV,
0088                         1.f * unit<float>::e);
0089 // Pion mass from: PDG 2024
0090 DETRAY_DECLARE_PARTICLE(pion_zero, 111, 134.9768 * unit<float>::MeV, 0.f);
0091 DETRAY_DECLARE_PARTICLE(pion_plus, 211, 139.57039f * unit<float>::MeV,
0092                         1.f * unit<float>::e);
0093 DETRAY_DECLARE_PARTICLE(pion_minus, -211, 139.57039f * unit<float>::MeV,
0094                         -1.f * unit<float>::e);
0095 DETRAY_DECLARE_PARTICLE(photon, 22, 0.f, 0.f);
0096 
0097 }  // namespace detray