Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-07-26 08:22:02

0001 /** TRACCC library, part of the ACTS project (R&D line)
0002  *
0003  * (c) 2024 CERN for the benefit of the ACTS project
0004  *
0005  * Mozilla Public License Version 2.0
0006  */
0007 
0008 #pragma once
0009 
0010 // traccc include(s).
0011 #include "traccc/definitions/primitives.hpp"
0012 #include "traccc/definitions/qualifiers.hpp"
0013 #include "traccc/edm/track_parameters.hpp"
0014 
0015 // detray include(s).
0016 #include <detray/definitions/pdg_particle.hpp>
0017 
0018 // System include(s).
0019 #include <stdexcept>
0020 
0021 namespace traccc {
0022 
0023 template <typename scalar_t>
0024 using pdg_particle = detray::pdg_particle<scalar_t>;
0025 
0026 template <typename scalar_t>
0027 using electron = detray::electron<scalar_t>;
0028 template <typename scalar_t>
0029 using positron = detray::positron<scalar_t>;
0030 template <typename scalar_t>
0031 using muon = detray::muon<scalar_t>;
0032 template <typename scalar_t>
0033 using antimuon = detray::antimuon<scalar_t>;
0034 template <typename scalar_t>
0035 using pion_plus = detray::pion_plus<scalar_t>;
0036 template <typename scalar_t>
0037 using pion_minus = detray::pion_minus<scalar_t>;
0038 
0039 namespace detail {
0040 
0041 template <typename scalar_t>
0042 TRACCC_HOST_DEVICE inline traccc::pdg_particle<scalar_t>
0043 particle_from_pdg_number(const int pdg_num) {
0044   switch (pdg_num) {
0045     case 11:
0046       return detray::electron<scalar_t>();
0047     case -11:
0048       return detray::positron<scalar_t>();
0049     case 13:
0050       return detray::muon<scalar_t>();
0051     case -13:
0052       return detray::antimuon<scalar_t>();
0053     case 211:
0054       return detray::pion_plus<scalar_t>();
0055     case -211:
0056       return detray::pion_minus<scalar_t>();
0057   }
0058 
0059   // TODO: Replace with `detray::invalid` in the future
0060   return traccc::pdg_particle<scalar_t>(0, 0.f, 0.f);
0061 }
0062 
0063 // Apply the charge operator to return the antimatter
0064 template <typename scalar_t>
0065 TRACCC_HOST_DEVICE inline traccc::pdg_particle<scalar_t> charge_conjugation(
0066     const traccc::pdg_particle<scalar_t>& ptc) {
0067   const auto pdg_num = ptc.pdg_num();
0068 
0069   switch (pdg_num) {
0070     case 11:
0071       return detray::positron<scalar_t>();
0072     case -11:
0073       return detray::electron<scalar_t>();
0074     case 13:
0075       return detray::antimuon<scalar_t>();
0076     case -13:
0077       return detray::muon<scalar_t>();
0078     case 211:
0079       return detray::pion_minus<scalar_t>();
0080     case -211:
0081       return detray::pion_plus<scalar_t>();
0082   }
0083 
0084   // TODO: Replace with `detray::invalid` in the future
0085   return traccc::pdg_particle<scalar_t>(0, 0.f, 0.f);
0086 }
0087 
0088 // Return the consistent particle type based on the particle hypothesis and the
0089 // charge of the track parameters
0090 template <typename scalar_t>
0091 TRACCC_HOST_DEVICE inline traccc::pdg_particle<scalar_t>
0092 correct_particle_hypothesis(
0093     const traccc::pdg_particle<scalar_t>& ptc_hypothesis,
0094     const bound_track_parameters<>& params) {
0095   if (ptc_hypothesis.charge() * params.qop() > 0.f) {
0096     return ptc_hypothesis;
0097   } else {
0098     return charge_conjugation(ptc_hypothesis);
0099   }
0100 }
0101 
0102 template <typename scalar_t>
0103 TRACCC_HOST_DEVICE inline traccc::pdg_particle<scalar_t>
0104 correct_particle_hypothesis(
0105     const traccc::pdg_particle<scalar_t>& ptc_hypothesis,
0106     const free_track_parameters<>& params) {
0107   if (ptc_hypothesis.charge() * params.qop() > 0.f) {
0108     return ptc_hypothesis;
0109   } else {
0110     return charge_conjugation(ptc_hypothesis);
0111   }
0112 }
0113 
0114 }  // namespace detail
0115 
0116 }  // namespace traccc