The Gaudi Framework  master (594c33fa)
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 ()=default
 
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  validated_pid_t {
  validated_pid_t::Electron = 0, validated_pid_t::Muon, validated_pid_t::Pion, validated_pid_t::Kaon,
  validated_pid_t::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::ostreamtoStream (const PID &pid, std::ostream &os)
 
std::ostreamoperator<< (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

enum Gaudi::Tr::PID::validated_pid_t
strongprivate
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]

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

Definition at line 45 of file TrackDefaultParticles.h.

45 : m_value( validate( id ) ) {}

◆ PID() [2/3]

constexpr 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 ( )
default

Member Function Documentation

◆ Electron()

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

Definition at line 52 of file TrackDefaultParticles.h.

52 { return PID{ validated_pid_t::Electron }; }

◆ isElectron()

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

Definition at line 97 of file TrackDefaultParticles.h.

◆ isKaon()

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

Definition at line 103 of file TrackDefaultParticles.h.

103 { return validated_pid_t::Kaon == m_value; }

◆ isMuon()

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

Definition at line 99 of file TrackDefaultParticles.h.

99 { return validated_pid_t::Muon == m_value; }

◆ isPion()

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

Definition at line 101 of file TrackDefaultParticles.h.

101 { return validated_pid_t::Pion == m_value; }

◆ isProton()

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

Definition at line 105 of file TrackDefaultParticles.h.

105 { return validated_pid_t::Proton == m_value; }

◆ 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()

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

Definition at line 95 of file TrackDefaultParticles.h.

95 { return s_mass[static_cast<int>( m_value )]; }

◆ 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:
32  return validated_pid_t::Muon;
33  case 211:
34  return validated_pid_t::Pion;
35  case 321:
36  return validated_pid_t::Kaon;
37  case 2212:
39  default:
40  throw std::runtime_error( "invalid PID" );
41  }
42  }

Friends And Related Function 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 ); }

◆ 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;
89  return StatusCode::SUCCESS;
90  }
91  return StatusCode::FAILURE;
92  }

◆ 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

constexpr 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.


The documentation for this class was generated from the following files:
Gaudi::Tr::PID::validated_pid_t::Electron
@ Electron
Gaudi::Tr::PID::validated_pid_t::Proton
@ Proton
Gaudi::Tr::PID::toStream
friend std::ostream & toStream(const PID &pid, std::ostream &os)
Definition: TrackDefaultParticles.h:80
Gaudi::Tr::PID::Pion
static constexpr PID Pion()
Definition: TrackDefaultParticles.h:56
Gaudi::Tr::PID::validated_pid_t::Pion
@ Pion
Gaudi::Tr::PID::m_value
validated_pid_t m_value
Definition: TrackDefaultParticles.h:25
Gaudi::Tr::PID::PID
PID()=default
std::runtime_error
STL class.
Gaudi::Tr::PID::toString
friend const char * toString(PID pid)
Definition: TrackDefaultParticles.h:63
Gaudi::Tr::PID::Kaon
static constexpr PID Kaon()
Definition: TrackDefaultParticles.h:58
Gaudi::Tr::PID::validated_pid_t::Muon
@ Muon
Gaudi::Tr::PID::s_mass
static constexpr std::array< double, 5 > s_mass
Definition: TrackDefaultParticles.h:23
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:100
Gaudi::Tr::PID::validate
static constexpr validated_pid_t validate(int id)
Definition: TrackDefaultParticles.h:27
Gaudi::Tr::PID::Proton
static constexpr PID Proton()
Definition: TrackDefaultParticles.h:60
Gaudi::Tr::PID::Electron
static constexpr PID Electron()
Definition: TrackDefaultParticles.h:52
Gaudi::Tr::PID::validated_pid_t::Kaon
@ Kaon
compareRootHistos.ref
ref
Definition: compareRootHistos.py:27
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:101
Gaudi::Tr::PID::Muon
static constexpr PID Muon()
Definition: TrackDefaultParticles.h:54