cepgen is hosted by Hepforge, IPPP Durham
CepGen N/A
Central exclusive processes event generator
Particle.h
Go to the documentation of this file.
1/*
2 * CepGen: a central exclusive processes event generator
3 * Copyright (C) 2013-2025 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#ifndef CepGen_Event_Particle_h
20#define CepGen_Event_Particle_h
21
22#include <set>
23
26#include "CepGen/Utils/Hasher.h"
27
28namespace cepgen {
29 using ParticlesIds = std::set<int>;
30
32 class Particle {
33 public:
35 enum class Status {
37 DebugResonance = -5,
38 Resonance = -4,
39 Fragmented = -3,
40 Propagator = -2,
41 Incoming = -1,
42 Undefined = 0,
43 FinalState = 1,
44 Undecayed = 2,
45 Unfragmented = 3
46 };
47 friend std::ostream& operator<<(std::ostream& os, const Status&);
49 enum class Role {
50 UnknownRole = -1,
51 IncomingBeam1 = 1,
52 IncomingBeam2 = 2,
53 OutgoingBeam1 = 3,
54 OutgoingBeam2 = 5,
55 CentralSystem = 6,
56 Intermediate = 4,
57 Parton1 = 41,
58 Parton2 = 42
59 };
60 friend std::ostream& operator<<(std::ostream& os, const Role&);
61
62 //----- static getters
63
69
70 bool operator<(const Particle&) const;
71 bool operator==(const Particle&) const;
72
73 // --- general particle properties
74
75 inline int id() const { return id_; }
77 inline Particle& setId(int id) {
78 id_ = id;
79 return *this;
80 }
81 float charge() const;
83 inline Particle& setAntiparticle(bool anti) {
84 antiparticle_ = anti;
85 return *this;
86 }
87 inline Role role() const { return role_; }
89 inline Particle& setRole(const Role& role) {
90 role_ = role;
91 return *this;
92 }
93 inline Status status() const { return static_cast<Status>(status_); }
96 status_ = static_cast<int>(status);
97 return *this;
98 }
100 inline Particle& setStatus(int status) {
101 status_ = status;
102 return *this;
103 }
104
108 Particle& setPdgId(pdgid_t pdg, short charge_factor = 0);
109 pdgid_t pdgId() const;
113 long integerPdgId() const;
114
115 inline float helicity() const { return helicity_; }
117 inline Particle& setHelicity(float heli) {
118 helicity_ = heli;
119 return *this;
120 }
121
122 inline Momentum& momentum() { return momentum_; }
124 inline const Momentum& momentum() const { return momentum_; }
127 Particle& setMomentum(const Momentum&, bool off_shell = false);
133 Particle& setMomentum(double px, double py, double pz, double energy = -1.);
136 inline Particle& setMomentum(double p[4]) { return setMomentum(p[0], p[1], p[2], p[3]); }
137 bool valid() const;
138
139 // --- particle relations
140
141 inline bool primary() const { return mothers_.empty(); }
142 Particle& addMother(Particle& mother_particle);
143 inline ParticlesIds mothers() const { return mothers_; }
144 inline ParticlesIds& mothers() { return mothers_; }
145 Particle& addChild(Particle& child_particle);
146 inline ParticlesIds children() const { return children_; }
147 inline ParticlesIds& children() { return children_; }
148
149 // --- global particle information extraction
150
151 friend std::ostream& operator<<(std::ostream&, const Particle&);
152
153 protected:
154 int id_{-1};
155 bool antiparticle_{false};
157 float helicity_{0.};
159 int status_{static_cast<int>(Status::Undefined)};
163 };
164
165 // --- particle containers
166
167 using ParticleRef = std::reference_wrapper<Particle>;
168 using Particles = std::vector<Particle>;
169 using ParticlesRefs = std::vector<ParticleRef>;
170 using ParticleRoles = std::vector<Particle::Role>;
171
173 class ParticlesMap : public std::unordered_map<Particle::Role, Particles, utils::EnumHash<Particle::Role> > {
174 public:
175 ParticlesMap() = default;
178 ~ParticlesMap() = default;
179 };
180} // namespace cepgen
181
182#endif
Container for a particle's 4-momentum, along with useful methods to ease the development of any matri...
Definition Momentum.h:30
Kinematic information for one particle.
Definition Particle.h:32
Momentum & momentum()
Retrieve the momentum object associated with this particle Retrieve the momentum object associated wi...
Definition Particle.h:122
pdgid_t pdgId() const
Retrieve the objectified PDG identifier Set the PDG identifier (along with the particle's electric ch...
Particle & addChild(Particle &child_particle)
Add a decay product.
Momentum momentum_
Momentum properties handler.
Definition Particle.h:156
friend std::ostream & operator<<(std::ostream &os, const Status &)
Human-readable particle's status Role of the particle in the process.
float helicity_
Helicity.
Definition Particle.h:157
ParticlesIds & mothers()
Identifier to the mother particles.
Definition Particle.h:144
friend std::ostream & operator<<(std::ostream &os, const Role &)
Human-readable particle's role in the event.
Particle & setMomentum(double px, double py, double pz, double energy=-1.)
Set the 3- or 4-momentum associated with the particle.
bool operator<(const Particle &) const
Comparison operator (from unique identifier)
Particle & setStatus(int status)
Set the particle decay/stability status.
Definition Particle.h:100
Role role_
Role in the process.
Definition Particle.h:158
bool valid() const
Is this particle a valid particle which can be used for kinematic computations?
float helicity() const
Particle's helicity Set the helicity of the particle.
Definition Particle.h:115
int status_
Decay/stability status.
Definition Particle.h:159
friend std::ostream & operator<<(std::ostream &, const Particle &)
Human-readable dump of particle information.
long integerPdgId() const
Retrieve the integer value of the PDG identifier.
Particle & setPdgId(pdgid_t pdg, short charge_factor=0)
Set the PDG identifier (along with the particle's electric charge)
ParticlesIds children() const
Identifiers list of all child particles.
Definition Particle.h:146
const Momentum & momentum() const
Definition Particle.h:124
Status
Internal status code for a particle.
Definition Particle.h:35
@ Undecayed
Particle to be decayed externally.
@ Fragmented
Already fragmented outgoing beam.
@ PrimordialIncoming
Incoming beam particle.
@ Incoming
Incoming parton.
@ FinalState
Stable, final state particle.
@ Resonance
Already decayed intermediate resonance.
@ Unfragmented
Particle to be hadronised externally.
@ Propagator
Generic propagator.
@ DebugResonance
Intermediate resonance (for processes developers)
@ Undefined
Undefined particle.
int id() const
Unique identifier (in a Event object context) Set the particle unique identifier in an event.
Definition Particle.h:75
Particle(Role role=Role::UnknownRole, pdgid_t id=0, Status status=Status::Undefined)
Build using the role of the particle in the process and its PDG id.
ParticlesIds children_
List of child particles.
Definition Particle.h:161
ParticlesIds mothers() const
Identifier to the mother particles.
Definition Particle.h:143
Particle & setIntegerPdgId(long pdg_id)
Particle & setAntiparticle(bool anti)
Definition Particle.h:83
Particle & setRole(const Role &role)
Definition Particle.h:89
float charge() const
Electric charge (given as a float number, for the quarks and bound states) Set whether we are coping ...
bool operator==(const Particle &) const
Equality operator.
bool primary() const
Is this particle a primary particle?
Definition Particle.h:141
bool antiparticle_
Are we dealing with the particle or antiparticle?
Definition Particle.h:155
Particle & setHelicity(float heli)
Definition Particle.h:117
int id_
Unique identifier in an event.
Definition Particle.h:154
ParticlesIds & children()
Identifiers list of all child particles.
Definition Particle.h:147
Particle & setMomentum(const Momentum &, bool off_shell=false)
Associate a momentum object with this particle.
Particle & setMomentum(double p[4])
Set the 4-momentum associated with the particle.
Definition Particle.h:136
@ OutgoingBeam2
outgoing beam state/particle
@ CentralSystem
Central particles system.
@ Parton2
beam incoming parton
@ OutgoingBeam1
outgoing beam state/particle
@ IncomingBeam2
incoming beam particle
@ Intermediate
Intermediate two-parton system.
@ Parton1
beam incoming parton
@ UnknownRole
Undefined role.
@ IncomingBeam1
incoming beam particle
ParticlesIds mothers_
List of mother particles.
Definition Particle.h:160
Status status() const
Particle status Set the particle decay/stability status.
Definition Particle.h:93
pdgid_t pdg_id_
PDG id.
Definition Particle.h:162
Particle & setId(int id)
Definition Particle.h:77
Role role() const
Role in the considered process Set the particle role in the process.
Definition Particle.h:87
Particle & setStatus(Status status)
Definition Particle.h:95
Particle & addMother(Particle &mother_particle)
Set the mother particle.
Map between a particle's role and its associated Particle object.
Definition Particle.h:173
ParticlesMap(const ParticlesMap &)
Copy constructor.
ParticlesMap & operator=(const ParticlesMap &)
Assignment operator.
Common namespace for this Monte Carlo generator.
Definition Handler.h:26
std::set< int > ParticlesIds
A set of integer-type particle identifiers.
Definition Particle.h:29
unsigned long long pdgid_t
Alias for the integer-like particle PDG id.
std::vector< Particle::Role > ParticleRoles
List of particles' roles.
Definition Particle.h:170
std::vector< ParticleRef > ParticlesRefs
List of references to Particle objects.
Definition Particle.h:169
std::vector< Particle > Particles
List of Particle objects.
Definition Particle.h:168
std::reference_wrapper< Particle > ParticleRef
Reference to a Particle object.
Definition Particle.h:167