The Gaudi Framework
master (1a7a3838)
Toggle main menu visibility
Loading...
Searching...
No Matches
TrackDefaultParticles.h
Go to the documentation of this file.
1
/***********************************************************************************\
2
* (c) Copyright 1998-2024 CERN for the benefit of the LHCb and ATLAS collaborations *
3
* *
4
* This software is distributed under the terms of the Apache version 2 licence, *
5
* copied verbatim in the file "LICENSE". *
6
* *
7
* In applying this licence, CERN does not waive the privileges and immunities *
8
* granted to it by virtue of its status as an Intergovernmental Organization *
9
* or submit itself to any jurisdiction. *
10
\***********************************************************************************/
11
#pragma once
12
13
#include <
GaudiKernel/StatusCode.h
>
14
#include <array>
15
#include <iomanip>
16
#include <stdexcept>
17
#include <stdint.h>
18
19
namespace
Gaudi
{
20
namespace
Tr
{
21
class
PID
{
22
enum class
validated_pid_t
{
Electron
= 0,
Muon
,
Pion
,
Kaon
,
Proton
};
23
static
constexpr
std::array<double, 5>
s_mass
= { 0.51099891, 105.65837, 139.57018, 493.677, 938.27203 };
24
25
validated_pid_t
m_value
;
26
27
static
constexpr
validated_pid_t
validate
(
int
id
) {
28
switch
(
id
) {
29
case
11:
30
return
validated_pid_t::Electron
;
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:
38
return
validated_pid_t::Proton
;
39
default
:
40
throw
std::runtime_error(
"invalid PID"
);
41
}
42
}
43
44
public
:
45
constexpr
explicit
PID
(
const
int
id
) :
m_value
(
validate
( id ) ) {}
46
47
constexpr
explicit
PID
(
validated_pid_t
pid ) :
m_value
( pid ) {}
48
49
PID
() =
delete
;
50
// Make the creation of thes PID objects expressive in user code
51
// by calling Gaudi::Tr::PID::Electron()
52
static
constexpr
PID
Electron
() {
return
PID
{
validated_pid_t::Electron
}; }
53
54
static
constexpr
PID
Muon
() {
return
PID
{
validated_pid_t::Muon
}; }
55
56
static
constexpr
PID
Pion
() {
return
PID
{
validated_pid_t::Pion
}; }
57
58
static
constexpr
PID
Kaon
() {
return
PID
{
validated_pid_t::Kaon
}; }
59
60
static
constexpr
PID
Proton
() {
return
PID
{
validated_pid_t::Proton
}; }
61
62
// Framwork functions allowing the use of PID inside a property
63
friend
const
char
*
toString
(
PID
pid ) {
64
switch
( pid.
m_value
) {
65
case
validated_pid_t::Electron
:
66
return
"Electron"
;
67
case
validated_pid_t::Muon
:
68
return
"Muon"
;
69
case
validated_pid_t::Pion
:
70
return
"Pion"
;
71
case
validated_pid_t::Kaon
:
72
return
"Kaon"
;
73
case
validated_pid_t::Proton
:
74
return
"Proton"
;
75
default
:
76
throw
std::runtime_error(
"Calling toString on invalid PID"
);
77
}
78
}
79
80
friend
std::ostream&
toStream
(
const
PID
& pid, std::ostream& os ) {
81
return
os << std::quoted(
toString
( pid ),
'\''
);
82
}
83
friend
std::ostream&
operator<<
( std::ostream& os,
const
PID
& pid ) {
return
toStream
( pid, os ); }
84
85
friend
StatusCode
parse
(
PID
& pid, std::string_view in ) {
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
}
93
//----------------------------------------------------------
94
95
constexpr
double
mass
()
const
{
return
s_mass
[
static_cast<
int
>
(
m_value
)]; }
96
97
constexpr
bool
isElectron
()
const
{
return
validated_pid_t::Electron
==
m_value
; }
98
99
constexpr
bool
isMuon
()
const
{
return
validated_pid_t::Muon
==
m_value
; }
100
101
constexpr
bool
isPion
()
const
{
return
validated_pid_t::Pion
==
m_value
; }
102
103
constexpr
bool
isKaon
()
const
{
return
validated_pid_t::Kaon
==
m_value
; }
104
105
constexpr
bool
isProton
()
const
{
return
validated_pid_t::Proton
==
m_value
; }
106
};
107
}
// namespace Tr
108
}
// namespace Gaudi
StatusCode.h
Gaudi::Tr::PID::Kaon
static constexpr PID Kaon()
Definition
TrackDefaultParticles.h:58
Gaudi::Tr::PID::isMuon
constexpr bool isMuon() const
Definition
TrackDefaultParticles.h:99
Gaudi::Tr::PID::operator<<
friend std::ostream & operator<<(std::ostream &os, const PID &pid)
Definition
TrackDefaultParticles.h:83
Gaudi::Tr::PID::s_mass
static constexpr std::array< double, 5 > s_mass
Definition
TrackDefaultParticles.h:23
Gaudi::Tr::PID::isKaon
constexpr bool isKaon() const
Definition
TrackDefaultParticles.h:103
Gaudi::Tr::PID::mass
constexpr double mass() const
Definition
TrackDefaultParticles.h:95
Gaudi::Tr::PID::isElectron
constexpr bool isElectron() const
Definition
TrackDefaultParticles.h:97
Gaudi::Tr::PID::toString
friend const char * toString(PID pid)
Definition
TrackDefaultParticles.h:63
Gaudi::Tr::PID::validated_pid_t
validated_pid_t
Definition
TrackDefaultParticles.h:22
Gaudi::Tr::PID::validated_pid_t::Electron
@ Electron
Definition
TrackDefaultParticles.h:22
Gaudi::Tr::PID::validated_pid_t::Proton
@ Proton
Definition
TrackDefaultParticles.h:22
Gaudi::Tr::PID::validated_pid_t::Kaon
@ Kaon
Definition
TrackDefaultParticles.h:22
Gaudi::Tr::PID::validated_pid_t::Pion
@ Pion
Definition
TrackDefaultParticles.h:22
Gaudi::Tr::PID::validated_pid_t::Muon
@ Muon
Definition
TrackDefaultParticles.h:22
Gaudi::Tr::PID::parse
friend StatusCode parse(PID &pid, std::string_view in)
Definition
TrackDefaultParticles.h:85
Gaudi::Tr::PID::validate
static constexpr validated_pid_t validate(int id)
Definition
TrackDefaultParticles.h:27
Gaudi::Tr::PID::toStream
friend std::ostream & toStream(const PID &pid, std::ostream &os)
Definition
TrackDefaultParticles.h:80
Gaudi::Tr::PID::isProton
constexpr bool isProton() const
Definition
TrackDefaultParticles.h:105
Gaudi::Tr::PID::PID
constexpr PID(validated_pid_t pid)
Definition
TrackDefaultParticles.h:47
Gaudi::Tr::PID::Muon
static constexpr PID Muon()
Definition
TrackDefaultParticles.h:54
Gaudi::Tr::PID::Pion
static constexpr PID Pion()
Definition
TrackDefaultParticles.h:56
Gaudi::Tr::PID::isPion
constexpr bool isPion() const
Definition
TrackDefaultParticles.h:101
Gaudi::Tr::PID::PID
constexpr PID(const int id)
Definition
TrackDefaultParticles.h:45
Gaudi::Tr::PID::m_value
validated_pid_t m_value
Definition
TrackDefaultParticles.h:25
Gaudi::Tr::PID::PID
PID()=delete
Gaudi::Tr::PID::Proton
static constexpr PID Proton()
Definition
TrackDefaultParticles.h:60
Gaudi::Tr::PID::Electron
static constexpr PID Electron()
Definition
TrackDefaultParticles.h:52
StatusCode
This class is used for returning status codes from appropriate routines.
Definition
StatusCode.h:64
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition
StatusCode.h:99
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition
StatusCode.h:100
Gaudi::Tr
Definition
TrackDefaultParticles.h:20
Gaudi
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
Definition
__init__.py:1
GaudiPartProp
include
Gaudi
Tr
TrackDefaultParticles.h
Generated on
for The Gaudi Framework by
1.17.0