The Gaudi Framework  master (ff829712)
Loading...
Searching...
No Matches
Gaudi::Tr::PID Class Reference

#include </builds/gaudi/Gaudi/GaudiPartProp/include/Gaudi/Tr/TrackDefaultParticles.h>

Collaboration diagram for Gaudi::Tr::PID:

Public Member Functions

constexpr PID (const int id)
 
constexpr PID (validated_pid_t pid)
 
 PID ()=delete
 
constexpr double mass () const
 
constexpr bool isElectron () const
 
constexpr bool isMuon () const
 
constexpr bool isPion () const
 
constexpr bool isKaon () const
 
constexpr bool isProton () const
 

Static Public Member Functions

static constexpr PID Electron ()
 
static constexpr PID Muon ()
 
static constexpr PID Pion ()
 
static constexpr PID Kaon ()
 
static constexpr PID Proton ()
 

Private Types

enum class  validated_pid_t {
  Electron = 0 , Muon , Pion , Kaon ,
  Proton
}
 

Static Private Member Functions

static constexpr validated_pid_t validate (int id)
 

Private Attributes

validated_pid_t m_value
 

Static Private Attributes

static constexpr std::array< double, 5 > s_mass = { 0.51099891, 105.65837, 139.57018, 493.677, 938.27203 }
 

Friends

const char * toString (PID pid)
 
std::ostream & toStream (const PID &pid, std::ostream &os)
 
std::ostream & operator<< (std::ostream &os, const PID &pid)
 
StatusCode parse (PID &pid, std::string_view in)
 

Detailed Description

Definition at line 21 of file TrackDefaultParticles.h.

Member Enumeration Documentation

◆ validated_pid_t

Enumerator
Electron 
Muon 
Pion 
Kaon 
Proton 

Definition at line 22 of file TrackDefaultParticles.h.

22{ Electron = 0, Muon, Pion, Kaon, Proton };

Constructor & Destructor Documentation

◆ PID() [1/3]

Gaudi::Tr::PID::PID ( const int id)
inlineexplicitconstexpr

Definition at line 45 of file TrackDefaultParticles.h.

45: m_value( validate( id ) ) {}
static constexpr validated_pid_t validate(int id)
validated_pid_t m_value

◆ PID() [2/3]

Gaudi::Tr::PID::PID ( validated_pid_t pid)
inlineexplicitconstexpr

Definition at line 47 of file TrackDefaultParticles.h.

47: m_value( pid ) {}

◆ PID() [3/3]

Gaudi::Tr::PID::PID ( )
delete

Member Function Documentation

◆ Electron()

static constexpr PID Gaudi::Tr::PID::Electron ( )
inlinestaticconstexpr

Definition at line 52 of file TrackDefaultParticles.h.

◆ isElectron()

bool Gaudi::Tr::PID::isElectron ( ) const
inlineconstexpr

Definition at line 97 of file TrackDefaultParticles.h.

◆ isKaon()

bool Gaudi::Tr::PID::isKaon ( ) const
inlineconstexpr

◆ isMuon()

bool Gaudi::Tr::PID::isMuon ( ) const
inlineconstexpr

◆ isPion()

bool Gaudi::Tr::PID::isPion ( ) const
inlineconstexpr

◆ isProton()

bool Gaudi::Tr::PID::isProton ( ) const
inlineconstexpr

◆ Kaon()

static constexpr PID Gaudi::Tr::PID::Kaon ( )
inlinestaticconstexpr

Definition at line 58 of file TrackDefaultParticles.h.

58{ return PID{ validated_pid_t::Kaon }; }

◆ mass()

double Gaudi::Tr::PID::mass ( ) const
inlineconstexpr

Definition at line 95 of file TrackDefaultParticles.h.

95{ return s_mass[static_cast<int>( m_value )]; }
static constexpr std::array< double, 5 > s_mass

◆ Muon()

static constexpr PID Gaudi::Tr::PID::Muon ( )
inlinestaticconstexpr

Definition at line 54 of file TrackDefaultParticles.h.

54{ return PID{ validated_pid_t::Muon }; }

◆ Pion()

static constexpr PID Gaudi::Tr::PID::Pion ( )
inlinestaticconstexpr

Definition at line 56 of file TrackDefaultParticles.h.

56{ return PID{ validated_pid_t::Pion }; }

◆ Proton()

static constexpr PID Gaudi::Tr::PID::Proton ( )
inlinestaticconstexpr

Definition at line 60 of file TrackDefaultParticles.h.

60{ return PID{ validated_pid_t::Proton }; }

◆ validate()

static constexpr validated_pid_t Gaudi::Tr::PID::validate ( int id)
inlinestaticconstexprprivate

Definition at line 27 of file TrackDefaultParticles.h.

27 {
28 switch ( id ) {
29 case 11:
31 case 13:
33 case 211:
35 case 321:
37 case 2212:
39 default:
40 throw std::runtime_error( "invalid PID" );
41 }
42 }

Friends And Related Symbol Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream & os,
const PID & pid )
friend

Definition at line 83 of file TrackDefaultParticles.h.

83{ return toStream( pid, os ); }
friend std::ostream & toStream(const PID &pid, std::ostream &os)

◆ parse

StatusCode parse ( PID & pid,
std::string_view in )
friend

Definition at line 85 of file TrackDefaultParticles.h.

85 {
86 for ( PID ref : { Electron(), Muon(), Pion(), Kaon(), Proton() } ) {
87 if ( in != toString( ref ) ) continue;
88 pid = ref;
90 }
92 }
static constexpr PID Kaon()
friend const char * toString(PID pid)
static constexpr PID Muon()
static constexpr PID Pion()
static constexpr PID Proton()
static constexpr PID Electron()
constexpr static const auto SUCCESS
Definition StatusCode.h:99
constexpr static const auto FAILURE
Definition StatusCode.h:100

◆ toStream

std::ostream & toStream ( const PID & pid,
std::ostream & os )
friend

Definition at line 80 of file TrackDefaultParticles.h.

80 {
81 return os << std::quoted( toString( pid ), '\'' );
82 }

◆ toString

const char * toString ( PID pid)
friend

Definition at line 63 of file TrackDefaultParticles.h.

63 {
64 switch ( pid.m_value ) {
66 return "Electron";
68 return "Muon";
70 return "Pion";
72 return "Kaon";
74 return "Proton";
75 default:
76 throw std::runtime_error( "Calling toString on invalid PID" );
77 }
78 }

Member Data Documentation

◆ m_value

validated_pid_t Gaudi::Tr::PID::m_value
private

Definition at line 25 of file TrackDefaultParticles.h.

◆ s_mass

std::array< double, 5 > Gaudi::Tr::PID::s_mass = { 0.51099891, 105.65837, 139.57018, 493.677, 938.27203 }
staticconstexprprivate

Definition at line 23 of file TrackDefaultParticles.h.

23{ 0.51099891, 105.65837, 139.57018, 493.677, 938.27203 };

The documentation for this class was generated from the following files: