cepgen is hosted by Hepforge, IPPP Durham
CepGen 1.2.5
Central exclusive processes event generator
Loading...
Searching...
No Matches
Pythia6Interface.cpp
Go to the documentation of this file.
1/*
2 * CepGen: a central exclusive processes event generator
3 * Copyright (C) 2013-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
21#include "CepGen/Physics/PDG.h"
22#include "CepGen/Utils/String.h"
24
25extern "C" {
26double pyalem_(double& q2);
27double pyalps_(double& q2);
28extern double pymass_(int&);
29extern void pyexec_();
30extern void pygive_(const char*, int);
31extern void pyckbd_();
32extern void pylist_(int&);
33extern void pyjoin_(int&, int&);
34extern void pyname_(int&, char*, int);
35extern int pyk_(int&, int&);
36extern double pyp_(int&, int&);
37extern int pychge_(int&);
38void pystop_() { CG_INFO("pythia6:pystop") << "End of run"; }
39}
40
41namespace cepgen {
42 namespace pythia6 {
43 double pyalem(double q2) { return pyalem_(q2); }
44
45 double pyalps(double q2) { return pyalps_(q2); }
46
47 void pyexec() { pyexec_(); }
48
49 int pychge(int pdgid) { return pychge_(pdgid); }
50
51 void pyckbd() { pyckbd_(); }
52
53 void pygive(const std::string& line) { pygive_(line.c_str(), line.length()); }
54
55 void pyjoin(std::vector<int> join) {
56 int njoin = join.size();
57 return pyjoin_(njoin, *join.data());
58 }
59
60 int pyk(int id, int qty) { return pyk_(id, qty); }
61
62 void pylist(int mlist) { pylist_(mlist); }
63
64 double pymass(int pdgid) { return pymass_(pdgid); }
65
66 std::string pyname(int pdgid) {
67 // maximal number of characters to fetch for the particle's name
68 static constexpr unsigned short NAME_CHR = 16;
69
70 char out[NAME_CHR];
71 std::string s;
72 pyname_(pdgid, out, NAME_CHR);
73 s = std::string(out, NAME_CHR);
74 s.erase(remove(s.begin(), s.end(), ' '), s.end());
75 return s;
76 }
77
78 double pyp(int id, int qty) { return pyp_(id, qty); }
79
80 int pythia6Status(int cg_status) {
81 switch (static_cast<cepgen::Particle::Status>(cg_status)) {
83 return 21;
86 return 1;
88 return 3;
92 return 11;
93 default:
94 throw CG_FATAL("pythia6:status") << "No conversion rule for CepGen status code: " << cg_status << ".";
95 }
96 }
97
98 int cepgenStatus(int py_status) {
99 switch (py_status) {
100 case 1:
101 return static_cast<int>(cepgen::Particle::Status::FinalState);
102 case 3:
103 return static_cast<int>(cepgen::Particle::Status::Propagator);
104 case 11:
105 return static_cast<int>(cepgen::Particle::Status::Fragmented);
106 case 21:
107 return static_cast<int>(cepgen::Particle::Status::PrimordialIncoming);
108 default:
109 return py_status;
110 }
111 }
112
113 void checkPDGid(int pdg_id) {
114 if (cepgen::PDG::get().has(pdg_id))
115 return;
116 const auto name = pythia6::pyname(pdg_id);
118 prop.pdgid = pdg_id;
119 prop.name = name;
120 prop.descr = name;
121 //prop.colours = pyk(p + 1, 12); // colour factor
122 prop.mass = pymass(pdg_id);
123 prop.width = -1.; //pmas( pdg_id, 2 ),
124 if (const auto ch = pychge(pdg_id); std::fabs(ch) > 0)
125 prop.charges = {ch, -ch};
126 prop.fermion = false;
127 cepgen::PDG::get().define(prop);
128 }
129 } // namespace pythia6
130} // namespace cepgen
#define CG_FATAL(mod)
Definition Exception.h:61
#define CG_INFO(mod)
Definition Message.h:216
void pygive_(const char *, int)
Set a parameter value to the Pythia module.
int pychge_(int &)
void pyckbd_()
double pyalem_(double &q2)
void pyname_(int &, char *, int)
Get a particle's human-readable name from Pythia.
double pyp_(int &, int &)
Get real-valued event information from Pythia.
void pylist_(int &)
List all the particles in the event in a human-readable format.
double pymass_(int &)
Get the particle's mass in GeV from Pythia.
void pyexec_()
Launch the Pythia6 fragmentation.
void pyjoin_(int &, int &)
Join two coloured particles in a colour singlet.
double pyalps_(double &q2)
int pyk_(int &, int &)
Get integer-valued event information from Pythia.
void pystop_()
Purely virtual method to call at the end of the run.
void define(const ParticleProperties &)
Add a new particle definition to the library.
Definition PDG.cpp:60
static PDG & get()
Retrieve a unique instance of this particles info collection.
Definition PDG.cpp:41
Status
Internal status code for a particle.
Definition Particle.h:36
@ Undecayed
Particle to be decayed externally.
@ Fragmented
Already fragmented outgoing beam.
@ PrimordialIncoming
Incoming beam particle.
@ Incoming
Incoming parton.
@ FinalState
Stable, final state particle.
@ Unfragmented
Particle to be hadronised externally.
@ Propagator
Generic propagator.
double pyalem(double q2)
int pyk(int id, int qty)
int cepgenStatus(int py_status)
void pygive(const std::string &line)
double pymass(int pdgid)
double pyp(int id, int qty)
void pyjoin(std::vector< int > join)
Connect entries with colour flow information.
void pylist(int mlist)
std::string pyname(int pdgid)
int pychge(int pdgid)
void checkPDGid(int pdg_id)
double pyalps(double q2)
int pythia6Status(int cg_status)
Common namespace for this Monte Carlo generator.
A collection of physics constants associated to a single particle.
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.
double width
Decay width, in GeV/c .