Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-05 08:10:59

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   constexpr SinglyChargedParticleHypothesis(PdgParticle absPdg, float mass)
0029       : GenericParticleHypothesis(absPdg, mass, {}) {}
0030 
0031   explicit SinglyChargedParticleHypothesis(PdgParticle absPdg)
0032       : GenericParticleHypothesis(absPdg) {}
0033 
0034   template <typename other_charge_t>
0035   explicit constexpr SinglyChargedParticleHypothesis(
0036       const GenericParticleHypothesis<other_charge_t>& other)
0037       : GenericParticleHypothesis(other) {}
0038 
0039   static SinglyChargedParticleHypothesis muon() {
0040     static const SinglyChargedParticleHypothesis cache(PdgParticle::eMuon);
0041     return cache;
0042   }
0043   static SinglyChargedParticleHypothesis pion() {
0044     static const SinglyChargedParticleHypothesis cache(PdgParticle::ePionPlus);
0045     return cache;
0046   }
0047   static SinglyChargedParticleHypothesis electron() {
0048     static const SinglyChargedParticleHypothesis cache(PdgParticle::eElectron);
0049     return cache;
0050   }
0051   static SinglyChargedParticleHypothesis kaon() {
0052     static const SinglyChargedParticleHypothesis cache(PdgParticle::eKaonPlus);
0053     return cache;
0054   }
0055   static SinglyChargedParticleHypothesis proton() {
0056     static const SinglyChargedParticleHypothesis cache(PdgParticle::eProton);
0057     return cache;
0058   }
0059 
0060   static SinglyChargedParticleHypothesis chargedGeantino() {
0061     static const SinglyChargedParticleHypothesis cache(PdgParticle::eInvalid,
0062                                                        0);
0063     return cache;
0064   }
0065 };
0066 
0067 /// Specialized particle hypothesis for neutral particles.
0068 ///
0069 /// @note This serves as a factory for common neutral particles.
0070 class NeutralParticleHypothesis : public GenericParticleHypothesis<Neutral> {
0071  public:
0072   constexpr NeutralParticleHypothesis(PdgParticle absPdg, float mass)
0073       : GenericParticleHypothesis(absPdg, mass, {}) {}
0074   explicit NeutralParticleHypothesis(PdgParticle absPdg)
0075       : GenericParticleHypothesis(absPdg) {}
0076 
0077   template <typename other_charge_t>
0078   explicit constexpr NeutralParticleHypothesis(
0079       const GenericParticleHypothesis<other_charge_t>& other)
0080       : GenericParticleHypothesis(other) {}
0081 
0082   static NeutralParticleHypothesis photon() {
0083     static const NeutralParticleHypothesis cache(PdgParticle::eGamma);
0084     return cache;
0085   }
0086   static NeutralParticleHypothesis pion0() {
0087     static const NeutralParticleHypothesis cache(PdgParticle::ePionZero);
0088     return cache;
0089   }
0090 
0091   static NeutralParticleHypothesis geantino() {
0092     static const NeutralParticleHypothesis cache(PdgParticle::eInvalid, 0);
0093     return cache;
0094   }
0095 };
0096 
0097 /// Specialized particle hypothesis for non-neutral particles.
0098 ///
0099 /// @note This serves as a factory for common non-neutral particles.
0100 class NonNeutralChargedParticleHypothesis
0101     : public GenericParticleHypothesis<NonNeutralCharge> {
0102  public:
0103   constexpr NonNeutralChargedParticleHypothesis(PdgParticle absPdg, float mass,
0104                                                 NonNeutralCharge chargeType)
0105       : GenericParticleHypothesis(absPdg, mass, chargeType) {}
0106   explicit NonNeutralChargedParticleHypothesis(PdgParticle absPdg)
0107       : GenericParticleHypothesis(absPdg) {}
0108 
0109   template <typename other_charge_t>
0110   explicit constexpr NonNeutralChargedParticleHypothesis(
0111       const GenericParticleHypothesis<other_charge_t>& other)
0112       : GenericParticleHypothesis(other) {}
0113 
0114   static NonNeutralChargedParticleHypothesis muon() {
0115     return NonNeutralChargedParticleHypothesis{
0116         SinglyChargedParticleHypothesis::muon()};
0117   }
0118   static NonNeutralChargedParticleHypothesis pion() {
0119     return NonNeutralChargedParticleHypothesis{
0120         SinglyChargedParticleHypothesis::pion()};
0121   }
0122   static NonNeutralChargedParticleHypothesis electron() {
0123     return NonNeutralChargedParticleHypothesis{
0124         SinglyChargedParticleHypothesis::electron()};
0125   }
0126   static NonNeutralChargedParticleHypothesis kaon() {
0127     return NonNeutralChargedParticleHypothesis{
0128         SinglyChargedParticleHypothesis::kaon()};
0129   }
0130   static NonNeutralChargedParticleHypothesis proton() {
0131     return NonNeutralChargedParticleHypothesis{
0132         SinglyChargedParticleHypothesis::proton()};
0133   }
0134 
0135   static NonNeutralChargedParticleHypothesis pionLike(float absQ) {
0136     return NonNeutralChargedParticleHypothesis(
0137         pion().absolutePdg(), pion().mass(), NonNeutralCharge{absQ});
0138   }
0139 
0140   static NonNeutralChargedParticleHypothesis chargedGeantino() {
0141     static const auto cache = chargedGeantino(Acts::UnitConstants::e);
0142     return cache;
0143   }
0144   static NonNeutralChargedParticleHypothesis chargedGeantino(float absQ) {
0145     return NonNeutralChargedParticleHypothesis(PdgParticle::eInvalid, 0,
0146                                                NonNeutralCharge{absQ});
0147   }
0148 };
0149 
0150 /// Specialized particle hypothesis for any kind of charged particles.
0151 ///
0152 /// @note This serves as a factory for common particles with any kind of charge.
0153 class ParticleHypothesis : public GenericParticleHypothesis<AnyCharge> {
0154  public:
0155   constexpr ParticleHypothesis(PdgParticle absPdg, float mass,
0156                                AnyCharge chargeType)
0157       : GenericParticleHypothesis(absPdg, mass, chargeType) {}
0158   explicit ParticleHypothesis(PdgParticle absPdg)
0159       : GenericParticleHypothesis(absPdg) {}
0160 
0161   template <typename other_charge_t>
0162   explicit constexpr ParticleHypothesis(
0163       const GenericParticleHypothesis<other_charge_t>& other)
0164       : GenericParticleHypothesis(other) {}
0165 
0166   static ParticleHypothesis muon() {
0167     return ParticleHypothesis{SinglyChargedParticleHypothesis::muon()};
0168   }
0169   static ParticleHypothesis pion() {
0170     return ParticleHypothesis{SinglyChargedParticleHypothesis::pion()};
0171   }
0172   static ParticleHypothesis electron() {
0173     return ParticleHypothesis{SinglyChargedParticleHypothesis::electron()};
0174   }
0175   static ParticleHypothesis kaon() {
0176     return ParticleHypothesis{SinglyChargedParticleHypothesis::kaon()};
0177   }
0178   static ParticleHypothesis proton() {
0179     return ParticleHypothesis{SinglyChargedParticleHypothesis::proton()};
0180   }
0181 
0182   static ParticleHypothesis photon() {
0183     return ParticleHypothesis{NeutralParticleHypothesis::photon()};
0184   }
0185   static ParticleHypothesis pion0() {
0186     return ParticleHypothesis{NeutralParticleHypothesis::pion0()};
0187   }
0188 
0189   static ParticleHypothesis pionLike(float absQ) {
0190     return ParticleHypothesis(pion().absolutePdg(), pion().mass(),
0191                               AnyCharge{absQ});
0192   }
0193 
0194   static ParticleHypothesis geantino() {
0195     return ParticleHypothesis{NeutralParticleHypothesis::geantino()};
0196   }
0197   static ParticleHypothesis chargedGeantino() {
0198     static const auto cache = chargedGeantino(Acts::UnitConstants::e);
0199     return cache;
0200   }
0201   static ParticleHypothesis chargedGeantino(float absQ) {
0202     return ParticleHypothesis(PdgParticle::eInvalid, 0, AnyCharge{absQ});
0203   }
0204 };
0205 
0206 }  // namespace Acts