cepgen
is hosted by
Hepforge
,
IPPP Durham
CepGen
1.2.5
Central exclusive processes event generator
Loading...
Searching...
No Matches
ParticleProperties.cpp
Go to the documentation of this file.
1
/*
2
* CepGen: a central exclusive processes event generator
3
* Copyright (C) 2017-2024 Laurent Forthomme
4
*
5
* This program is free software: you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation, either version 3 of the License, or
8
* any later version.
9
*
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
14
*
15
* You should have received a copy of the GNU General Public License
16
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17
*/
18
19
#include <iostream>
20
21
#include "
CepGen/Core/Exception.h
"
22
#include "
CepGen/Physics/ParticleProperties.h
"
23
#include "
CepGen/Utils/String.h
"
24
25
namespace
cepgen
{
26
ParticleProperties::ParticleProperties
(
const
ParametersList
& params) :
SteeredObject
(params) {
27
charges
.reserve(4);
28
(*this)
29
.add(
"pdgid"
,
pdgid
)
30
.add(
"name"
,
name
)
31
.add(
"description"
,
descr
)
32
.add(
"colours"
,
colours
)
33
.add(
"mass"
,
mass
)
34
.add(
"width"
,
width
)
35
.add(
"charges"
,
charges
)
36
.add(
"fermion"
,
fermion
);
37
}
38
39
ParticleProperties::ParticleProperties
(
pdgid_t
ppdgid,
40
const
std::string& pname,
41
const
std::string& pdescr,
42
int
pcolours,
43
double
pmass,
44
double
pwidth,
45
const
std::vector<int>& pcharges,
46
bool
pfermion)
47
:
ParticleProperties
(
ParametersList
()
48
.set(
"pdgid"
, ppdgid)
49
.set(
"name"
, pname)
50
.set(
"description"
, pdescr)
51
.set(
"colours"
, pcolours)
52
.set(
"mass"
, pmass)
53
.set(
"width"
, pwidth)
54
.set(
"charges"
, pcharges)
55
.set(
"fermion"
, pfermion)) {}
56
57
short
ParticleProperties::integerCharge
()
const
{
58
if
(
charges
.empty())
59
return
0;
60
if
(
charges
.size() > 2)
61
throw
CG_ERROR
(
"ParticleProperties:integerCharge"
)
62
<<
"Multiple charges are possible for the given particle: "
<<
charges
<<
"."
;
63
return
charges
.at(0);
64
}
65
66
ParametersDescription
ParticleProperties::description
() {
67
auto
desc =
ParametersDescription
();
68
desc.add<
pdgid_t
>(
"pdgid"
, 0).setDescription(
"PDG unique identifier"
);
69
desc.add<std::string>(
"name"
,
"n/a"
).setDescription(
"particle computer-readable name"
);
70
desc.add<std::string>(
"description"
,
"n/a"
).setDescription(
"particle human-readable name"
);
71
desc.add<
int
>(
"colours"
, 0).setDescription(
"colour factor"
);
72
desc.add<
double
>(
"mass"
, 0.).setDescription(
"particle mass (in GeV/c^2)"
);
73
desc.add<
double
>(
"width"
, 0.).setDescription(
"particle width (in GeV)"
);
74
desc.add<std::vector<int> >(
"charges"
, {}).setDescription(
"possible electric charges (in units of e)"
);
75
desc.add<
bool
>(
"fermion"
,
false
).setDescription(
"is the particle following the Fermi-Dirac statistics?"
);
76
return
desc;
77
}
78
79
std::ostream&
operator<<
(std::ostream& os,
const
ParticleProperties
& prop) {
80
return
os << (prop.
name
.empty() ?
"unnamed"
: prop.
name
) <<
"{"
81
<<
"pdgid="
<< prop.
pdgid
<<
",desc="
<< prop.
descr
<<
",colours="
<< prop.
colours
82
<<
",mass="
<< prop.
mass
<<
",width="
<< prop.
width
<<
",charges={"
<<
utils::merge
(prop.
charges
,
", "
)
83
<<
"}"
<< (prop.
fermion
?
",fermion"
:
""
) <<
"}"
;
84
}
85
}
// namespace cepgen
Exception.h
CG_ERROR
#define CG_ERROR(mod)
Definition
Exception.h:60
ParticleProperties.h
String.h
cepgen::ParametersDescription
A description object for parameters collection.
Definition
ParametersDescription.h:26
cepgen::ParametersList
Definition
ParametersList.h:52
cepgen::SteeredObject
Base user-steerable object.
Definition
SteeredObject.h:41
cepgen::utils::merge
std::string merge(const std::vector< T > &vec, const std::string &delim)
Merge a collection of a printable type in a single string.
Definition
String.cpp:248
cepgen
Common namespace for this Monte Carlo generator.
Definition
CommandLineHandler.cpp:36
cepgen::pdgid_t
unsigned long long pdgid_t
Alias for the integer-like particle PDG id.
Definition
ParticleProperties.h:26
cepgen::operator<<
std::ostream & operator<<(std::ostream &os, const Exception::Type &type)
Definition
Exception.cpp:59
cepgen::ParticleProperties
A collection of physics constants associated to a single particle.
Definition
ParticleProperties.h:31
cepgen::ParticleProperties::ParticleProperties
ParticleProperties(const ParametersList &)
Definition
ParticleProperties.cpp:26
cepgen::ParticleProperties::descr
std::string descr
Human-readable name.
Definition
ParticleProperties.h:50
cepgen::ParticleProperties::mass
double mass
Mass, in GeV/c .
Definition
ParticleProperties.h:52
cepgen::ParticleProperties::pdgid
pdgid_t pdgid
PDG identifier.
Definition
ParticleProperties.h:48
cepgen::ParticleProperties::charges
std::vector< int > charges
Electric charges, in /3.
Definition
ParticleProperties.h:54
cepgen::ParticleProperties::name
std::string name
Particle name.
Definition
ParticleProperties.h:49
cepgen::ParticleProperties::integerCharge
short integerCharge() const
Integer charge, in /3.
Definition
ParticleProperties.cpp:57
cepgen::ParticleProperties::width
double width
Decay width, in GeV/c .
Definition
ParticleProperties.h:53
cepgen::ParticleProperties::description
static ParametersDescription description()
Definition
ParticleProperties.cpp:66
cepgen::ParticleProperties::colours
int colours
Colour factor.
Definition
ParticleProperties.h:51
cepgen::ParticleProperties::fermion
bool fermion
Is the particle a fermion?
Definition
ParticleProperties.h:55
CepGen
Physics
ParticleProperties.cpp
Generated on Mon Jul 29 2024 for CepGen by
1.9.7