Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:09:13

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