cepgen is hosted by Hepforge, IPPP Durham
CepGen 1.2.5
Central exclusive processes event generator
Loading...
Searching...
No Matches
HeavyIon.cpp
Go to the documentation of this file.
1/*
2 * CepGen: a central exclusive processes event generator
3 * Copyright (C) 2013-2022 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 <math.h>
20
23#include "CepGen/Physics/PDG.h"
24
25#define ELEM_STR(x) #x
26#define ELEM_EVAL(x) ELEM_STR(x)
27#define DEF_ELEM(x) \
28 case Element::x: \
29 return os << ELEM_EVAL(x)
30
31namespace cepgen {
32 HeavyIon::HeavyIon(unsigned short a, const Element& z) : Z(z), A(a) {}
33
35 if (pdg == PDG::neutron)
36 return neutron();
37 else if (pdg == PDG::proton)
38 return proton();
39 else if (pdg / 10'000'000 != 0)
40 return HeavyIon(pdg % 1000, static_cast<Element>((pdg / 1000) % 1000));
41 CG_WARNING("HeavyIon") << "Failed to parse heavy ion from PDG id=" << pdg << ".";
42 return HeavyIon(0, Element::invalid);
43 }
44
45 HeavyIon::operator pdgid_t() const {
46 // Pythia8 convention/10-1e10+1e6
47 if (*this == proton())
48 return PDG::proton;
49 if (*this == neutron())
50 return PDG::neutron;
51 return (pdgid_t)10'000'000 + 1000 * (unsigned short)Z + A;
52 }
53
54 bool HeavyIon::isHI(const spdgid_t& pdgid) { return pdgid / 10'000'000 != 0; }
55
57 return isHI(prop.pdgid); //FIXME can refine a bit
58 }
59
60 double HeavyIon::massP() const {
61 if (Z == Element::invalid)
62 throw CG_FATAL("HeavyIon:massP") << "Invalid heavy ion: " << (*this) << "!";
63 return (short)Z * PDG::get().mass(PDG::proton);
64 }
65
66 double HeavyIon::massN() const {
67 if (Z == Element::invalid)
68 throw CG_FATAL("HeavyIon:massN") << "Invalid heavy ion: " << (*this) << "!";
69 return (A - (short)Z) * PDG::get().mass(PDG::neutron);
70 }
71
72 double HeavyIon::radius() const {
73 switch (Z) {
74 case Element::H: {
75 if (A == 1) // simple proton
76 return 0.841e-15;
77 else // deuteron
78 return 2.128e-15;
79 }
80 case Element::Cu:
81 return 4.214e-15;
82 case Element::Xe:
83 return 5.36e-15;
84 case Element::Au:
85 return 6.38e-15;
86 case Element::Pb:
87 return 6.624e-15;
88 default: {
89 CG_WARNING("HeavyIon:radius") << "Using hard-sphere approximation R ~ 1.2 A^(1/3).";
90 return 1.2e-15 * cbrt(A);
91 }
92 }
93 }
94
95 std::ostream& operator<<(std::ostream& os, const HeavyIon& hi) {
96 if (hi == HeavyIon::proton())
97 return os << "proton";
98 if (hi == HeavyIon::neutron())
99 return os << "neutron";
100 std::ostringstream oss;
101 oss << hi.Z;
102 if (oss.str().empty() || hi.Z == Element::invalid)
103 return os << "HI{Z=" << (unsigned short)hi.Z << ", A=" << hi.A << "}";
104 return os << hi.A << oss.str();
105 }
106
107 std::ostream& operator<<(std::ostream& os, const Element& elem) {
108 switch (elem) {
111 DEF_ELEM(H);
112 DEF_ELEM(C);
113 DEF_ELEM(O);
114 DEF_ELEM(Al);
115 DEF_ELEM(Cu);
116 DEF_ELEM(Xe);
117 DEF_ELEM(Au);
118 DEF_ELEM(Pb);
119 DEF_ELEM(U);
120 }
121 return os;
122 }
123} // namespace cepgen
124
125#undef DEF_ELEM
126#undef ELEM_STR
127#undef ELEM_EVAL
#define CG_FATAL(mod)
Definition Exception.h:61
#define DEF_ELEM(x)
Definition HeavyIon.cpp:27
#define CG_WARNING(mod)
Definition Message.h:228
@ neutron
Definition PDG.h:49
@ proton
Definition PDG.h:50
double mass(spdgid_t) const
Particle mass (in GeV)
Definition PDG.cpp:90
static PDG & get()
Retrieve a unique instance of this particles info collection.
Definition PDG.cpp:41
Common namespace for this Monte Carlo generator.
Element
Enumeration of chemical elements.
Definition HeavyIon.h:28
unsigned long long pdgid_t
Alias for the integer-like particle PDG id.
long long spdgid_t
std::ostream & operator<<(std::ostream &os, const Exception::Type &type)
Definition Exception.cpp:59
Heavy ion container (Z+A)
Definition HeavyIon.h:44
double massP() const
Protons mass, in GeV/c2.
Definition HeavyIon.cpp:60
double radius() const
Heavy ion radius, in m.
Definition HeavyIon.cpp:72
Element Z
Atomic number.
Definition HeavyIon.h:85
HeavyIon(unsigned short, const Element &)
General constructor from mass and atomic number.
Definition HeavyIon.cpp:32
static HeavyIon fromPdgId(pdgid_t)
Build from a custom PDG id.
Definition HeavyIon.cpp:34
double massN() const
Neutrons mass, in GeV/c2.
Definition HeavyIon.cpp:66
static HeavyIon neutron()
Simple neutron.
Definition HeavyIon.h:73
unsigned short A
Mass number.
Definition HeavyIon.h:87
static bool isHI(const spdgid_t &)
Check if the PDG id is compatible with a HI.
Definition HeavyIon.cpp:54
static HeavyIon proton()
Simple proton.
Definition HeavyIon.h:71
A collection of physics constants associated to a single particle.
pdgid_t pdgid
PDG identifier.