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
23#include "CepGen/Utils/String.h"
24
25namespace cepgen {
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
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)
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
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
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
#define CG_ERROR(mod)
Definition Exception.h:60
A description object for parameters collection.
Base user-steerable object.
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
Common namespace for this Monte Carlo generator.
unsigned long long pdgid_t
Alias for the integer-like particle PDG id.
std::ostream & operator<<(std::ostream &os, const Exception::Type &type)
Definition Exception.cpp:59
A collection of physics constants associated to a single particle.
ParticleProperties(const ParametersList &)
std::string descr
Human-readable name.
double mass
Mass, in GeV/c .
pdgid_t pdgid
PDG identifier.
std::vector< int > charges
Electric charges, in /3.
std::string name
Particle name.
short integerCharge() const
Integer charge, in /3.
double width
Decay width, in GeV/c .
static ParametersDescription description()
bool fermion
Is the particle a fermion?