Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:10:48

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