Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-10-22 07:51:39

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/PdgParticle.hpp"
0012 #include "Acts/Definitions/Units.hpp"
0013 #include "Acts/EventData/Charge.hpp"
0014 #include "Acts/EventData/GenericParticleHypothesis.hpp"
0015 
0016 namespace Acts {
0017 
0018 // TODO In principle the factory methods could provide a reference to a static
0019 // instance which would avoid copying the particle hypothesis and potentially
0020 // save some memory. But constexpr+static seems to require C++2b extension.
0021 
0022 /// Specialized particle hypothesis for singly charged particles.
0023 ///
0024 /// @note This serves as a factory for common singly charge particles.
0025 class SinglyChargedParticleHypothesis
0026     : public GenericParticleHypothesis<SinglyCharged> {
0027  public:
0028   /// Constructor with explicit mass
0029   /// @param absPdg The absolute PDG particle code
0030   /// @param mass The particle mass
0031   constexpr SinglyChargedParticleHypothesis(PdgParticle absPdg, float mass)
0032       : GenericParticleHypothesis(absPdg, mass, {}) {}
0033 
0034   /// Constructor with PDG particle code (mass from particle data table)
0035   /// @param absPdg The absolute PDG particle code
0036   explicit SinglyChargedParticleHypothesis(PdgParticle absPdg)
0037       : GenericParticleHypothesis(absPdg) {}
0038 
0039   /// Convert from another particle hypothesis with different charge type
0040   /// @param other The source particle hypothesis to convert from
0041   template <typename other_charge_t>
0042   explicit constexpr SinglyChargedParticleHypothesis(
0043       const GenericParticleHypothesis<other_charge_t>& other)
0044       : GenericParticleHypothesis(other) {}
0045 
0046   /// Create a muon particle hypothesis
0047   /// @return Singly charged muon particle hypothesis
0048   static SinglyChargedParticleHypothesis muon() {
0049     static const SinglyChargedParticleHypothesis cache(PdgParticle::eMuon);
0050     return cache;
0051   }
0052   /// Create a charged pion particle hypothesis
0053   /// @return Singly charged pion particle hypothesis
0054   static SinglyChargedParticleHypothesis pion() {
0055     static const SinglyChargedParticleHypothesis cache(PdgParticle::ePionPlus);
0056     return cache;
0057   }
0058   /// Create an electron particle hypothesis
0059   /// @return Singly charged electron particle hypothesis
0060   static SinglyChargedParticleHypothesis electron() {
0061     static const SinglyChargedParticleHypothesis cache(PdgParticle::eElectron);
0062     return cache;
0063   }
0064   /// Create a charged kaon particle hypothesis
0065   /// @return Singly charged kaon particle hypothesis
0066   static SinglyChargedParticleHypothesis kaon() {
0067     static const SinglyChargedParticleHypothesis cache(PdgParticle::eKaonPlus);
0068     return cache;
0069   }
0070   /// Create a proton particle hypothesis
0071   /// @return Singly charged proton particle hypothesis
0072   static SinglyChargedParticleHypothesis proton() {
0073     static const SinglyChargedParticleHypothesis cache(PdgParticle::eProton);
0074     return cache;
0075   }
0076 
0077   /// Create a charged geantino particle hypothesis (massless charged particle)
0078   /// @return Singly charged geantino particle hypothesis
0079   static SinglyChargedParticleHypothesis chargedGeantino() {
0080     static const SinglyChargedParticleHypothesis cache(PdgParticle::eInvalid,
0081                                                        0);
0082     return cache;
0083   }
0084 };
0085 
0086 /// Specialized particle hypothesis for neutral particles.
0087 ///
0088 /// @note This serves as a factory for common neutral particles.
0089 class NeutralParticleHypothesis : public GenericParticleHypothesis<Neutral> {
0090  public:
0091   /// Constructor with explicit mass
0092   /// @param absPdg The absolute PDG particle code
0093   /// @param mass The particle mass
0094   constexpr NeutralParticleHypothesis(PdgParticle absPdg, float mass)
0095       : GenericParticleHypothesis(absPdg, mass, {}) {}
0096   /// Constructor with PDG particle code (mass from particle data table)
0097   /// @param absPdg The absolute PDG particle code
0098   explicit NeutralParticleHypothesis(PdgParticle absPdg)
0099       : GenericParticleHypothesis(absPdg) {}
0100 
0101   /// Convert from another particle hypothesis with different charge type
0102   /// @param other The source particle hypothesis to convert from
0103   template <typename other_charge_t>
0104   explicit constexpr NeutralParticleHypothesis(
0105       const GenericParticleHypothesis<other_charge_t>& other)
0106       : GenericParticleHypothesis(other) {}
0107 
0108   /// Create a photon particle hypothesis
0109   /// @return Neutral photon particle hypothesis
0110   static NeutralParticleHypothesis photon() {
0111     static const NeutralParticleHypothesis cache(PdgParticle::eGamma);
0112     return cache;
0113   }
0114   /// Create a neutral pion particle hypothesis
0115   /// @return Neutral pion particle hypothesis
0116   static NeutralParticleHypothesis pion0() {
0117     static const NeutralParticleHypothesis cache(PdgParticle::ePionZero);
0118     return cache;
0119   }
0120 
0121   /// Create a neutral geantino particle hypothesis (massless neutral particle)
0122   /// @return Neutral geantino particle hypothesis
0123   static NeutralParticleHypothesis geantino() {
0124     static const NeutralParticleHypothesis cache(PdgParticle::eInvalid, 0);
0125     return cache;
0126   }
0127 };
0128 
0129 /// Specialized particle hypothesis for non-neutral particles.
0130 ///
0131 /// @note This serves as a factory for common non-neutral particles.
0132 class NonNeutralChargedParticleHypothesis
0133     : public GenericParticleHypothesis<NonNeutralCharge> {
0134  public:
0135   /// Constructor with explicit mass and charge
0136   /// @param absPdg The absolute PDG particle code
0137   /// @param mass The particle mass
0138   /// @param chargeType The non-neutral charge type
0139   constexpr NonNeutralChargedParticleHypothesis(PdgParticle absPdg, float mass,
0140                                                 NonNeutralCharge chargeType)
0141       : GenericParticleHypothesis(absPdg, mass, chargeType) {}
0142   /// Constructor with PDG particle code (mass from particle data table)
0143   /// @param absPdg The absolute PDG particle code
0144   explicit NonNeutralChargedParticleHypothesis(PdgParticle absPdg)
0145       : GenericParticleHypothesis(absPdg) {}
0146 
0147   /// Convert from another particle hypothesis with different charge type
0148   /// @param other The source particle hypothesis to convert from
0149   template <typename other_charge_t>
0150   explicit constexpr NonNeutralChargedParticleHypothesis(
0151       const GenericParticleHypothesis<other_charge_t>& other)
0152       : GenericParticleHypothesis(other) {}
0153 
0154   /// Create a muon particle hypothesis
0155   /// @return Non-neutral charged muon particle hypothesis
0156   static NonNeutralChargedParticleHypothesis muon() {
0157     return NonNeutralChargedParticleHypothesis{
0158         SinglyChargedParticleHypothesis::muon()};
0159   }
0160   /// Create a charged pion particle hypothesis
0161   /// @return Non-neutral charged pion particle hypothesis
0162   static NonNeutralChargedParticleHypothesis pion() {
0163     return NonNeutralChargedParticleHypothesis{
0164         SinglyChargedParticleHypothesis::pion()};
0165   }
0166   /// Create an electron particle hypothesis
0167   /// @return Non-neutral charged electron particle hypothesis
0168   static NonNeutralChargedParticleHypothesis electron() {
0169     return NonNeutralChargedParticleHypothesis{
0170         SinglyChargedParticleHypothesis::electron()};
0171   }
0172   /// Create a charged kaon particle hypothesis
0173   /// @return Non-neutral charged kaon particle hypothesis
0174   static NonNeutralChargedParticleHypothesis kaon() {
0175     return NonNeutralChargedParticleHypothesis{
0176         SinglyChargedParticleHypothesis::kaon()};
0177   }
0178   /// Create a proton particle hypothesis
0179   /// @return Non-neutral charged proton particle hypothesis
0180   static NonNeutralChargedParticleHypothesis proton() {
0181     return NonNeutralChargedParticleHypothesis{
0182         SinglyChargedParticleHypothesis::proton()};
0183   }
0184 
0185   /// Create a pion-like particle hypothesis with custom charge
0186   /// @param absQ The absolute charge value
0187   /// @return Non-neutral charged pion-like particle hypothesis
0188   static NonNeutralChargedParticleHypothesis pionLike(float absQ) {
0189     return NonNeutralChargedParticleHypothesis(
0190         pion().absolutePdg(), pion().mass(), NonNeutralCharge{absQ});
0191   }
0192 
0193   /// Create a charged geantino particle hypothesis with unit charge
0194   /// @return Non-neutral charged geantino particle hypothesis
0195   static NonNeutralChargedParticleHypothesis chargedGeantino() {
0196     static const auto cache = chargedGeantino(Acts::UnitConstants::e);
0197     return cache;
0198   }
0199   /// Create a charged geantino particle hypothesis with custom charge
0200   /// @param absQ The absolute charge value
0201   /// @return Non-neutral charged geantino particle hypothesis
0202   static NonNeutralChargedParticleHypothesis chargedGeantino(float absQ) {
0203     return NonNeutralChargedParticleHypothesis(PdgParticle::eInvalid, 0,
0204                                                NonNeutralCharge{absQ});
0205   }
0206 };
0207 
0208 /// Specialized particle hypothesis for any kind of charged particles.
0209 ///
0210 /// @note This serves as a factory for common particles with any kind of charge.
0211 class ParticleHypothesis : public GenericParticleHypothesis<AnyCharge> {
0212  public:
0213   /// Constructor with explicit mass and charge
0214   /// @param absPdg The absolute PDG particle code
0215   /// @param mass The particle mass
0216   /// @param chargeType The charge type (any charge)
0217   constexpr ParticleHypothesis(PdgParticle absPdg, float mass,
0218                                AnyCharge chargeType)
0219       : GenericParticleHypothesis(absPdg, mass, chargeType) {}
0220   /// Constructor with PDG particle code (mass from particle data table)
0221   /// @param absPdg The absolute PDG particle code
0222   explicit ParticleHypothesis(PdgParticle absPdg)
0223       : GenericParticleHypothesis(absPdg) {}
0224 
0225   /// Convert from another particle hypothesis with different charge type
0226   /// @param other The source particle hypothesis to convert from
0227   template <typename other_charge_t>
0228   explicit constexpr ParticleHypothesis(
0229       const GenericParticleHypothesis<other_charge_t>& other)
0230       : GenericParticleHypothesis(other) {}
0231 
0232   /// Create a muon particle hypothesis
0233   /// @return Muon particle hypothesis with any charge type
0234   static ParticleHypothesis muon() {
0235     return ParticleHypothesis{SinglyChargedParticleHypothesis::muon()};
0236   }
0237   /// Create a charged pion particle hypothesis
0238   /// @return Charged pion particle hypothesis with any charge type
0239   static ParticleHypothesis pion() {
0240     return ParticleHypothesis{SinglyChargedParticleHypothesis::pion()};
0241   }
0242   /// Create an electron particle hypothesis
0243   /// @return Electron particle hypothesis with any charge type
0244   static ParticleHypothesis electron() {
0245     return ParticleHypothesis{SinglyChargedParticleHypothesis::electron()};
0246   }
0247   /// Create a charged kaon particle hypothesis
0248   /// @return Charged kaon particle hypothesis with any charge type
0249   static ParticleHypothesis kaon() {
0250     return ParticleHypothesis{SinglyChargedParticleHypothesis::kaon()};
0251   }
0252   /// Create a proton particle hypothesis
0253   /// @return Proton particle hypothesis with any charge type
0254   static ParticleHypothesis proton() {
0255     return ParticleHypothesis{SinglyChargedParticleHypothesis::proton()};
0256   }
0257 
0258   /// Create a photon particle hypothesis
0259   /// @return Photon particle hypothesis with any charge type
0260   static ParticleHypothesis photon() {
0261     return ParticleHypothesis{NeutralParticleHypothesis::photon()};
0262   }
0263   /// Create a neutral pion particle hypothesis
0264   /// @return Neutral pion particle hypothesis with any charge type
0265   static ParticleHypothesis pion0() {
0266     return ParticleHypothesis{NeutralParticleHypothesis::pion0()};
0267   }
0268 
0269   /// Create a pion-like particle hypothesis with custom charge
0270   /// @param absQ The absolute charge value
0271   /// @return Pion-like particle hypothesis with any charge type
0272   static ParticleHypothesis pionLike(float absQ) {
0273     return ParticleHypothesis(pion().absolutePdg(), pion().mass(),
0274                               AnyCharge{absQ});
0275   }
0276 
0277   /// Create a neutral geantino particle hypothesis (massless neutral particle)
0278   /// @return Neutral geantino particle hypothesis with any charge type
0279   static ParticleHypothesis geantino() {
0280     return ParticleHypothesis{NeutralParticleHypothesis::geantino()};
0281   }
0282   /// Create a charged geantino particle hypothesis with unit charge
0283   /// @return Charged geantino particle hypothesis with any charge type
0284   static ParticleHypothesis chargedGeantino() {
0285     static const auto cache = chargedGeantino(Acts::UnitConstants::e);
0286     return cache;
0287   }
0288   /// Create a charged geantino particle hypothesis with custom charge
0289   /// @param absQ The absolute charge value
0290   /// @return Charged geantino particle hypothesis with any charge type
0291   static ParticleHypothesis chargedGeantino(float absQ) {
0292     return ParticleHypothesis(PdgParticle::eInvalid, 0, AnyCharge{absQ});
0293   }
0294 };
0295 
0296 }  // namespace Acts