File indexing completed on 2025-01-18 10:01:12
0001
0002
0003
0004
0005
0006 #ifndef HEPMC3_GENPARTICLE_H
0007 #define HEPMC3_GENPARTICLE_H
0008
0009
0010
0011
0012
0013
0014
0015
0016 #include <string>
0017 #include "HepMC3/Data/GenParticleData.h"
0018 #include "HepMC3/FourVector.h"
0019
0020 #include "HepMC3/GenParticle_fwd.h"
0021 #include "HepMC3/GenVertex_fwd.h"
0022
0023 #ifdef HEPMC3_PROTOBUFIO
0024 namespace HepMC3_pb {
0025 class GenEventData_GenParticleData;
0026 }
0027 #endif
0028
0029 namespace HepMC3 {
0030
0031 class GenEvent;
0032 class Attribute;
0033
0034 class GenParticle : public std::enable_shared_from_this<GenParticle> {
0035
0036 friend class GenVertex;
0037 friend class GenEvent;
0038
0039
0040
0041
0042 public:
0043
0044
0045 GenParticle( const FourVector &momentum = FourVector::ZERO_VECTOR(), int pid = 0, int status = 0 );
0046
0047
0048 GenParticle( const GenParticleData &data );
0049
0050 #ifdef HEPMC3_PROTOBUFIO
0051
0052 GenParticle( HepMC3_pb::GenEventData_GenParticleData const &data );
0053 #endif
0054
0055
0056
0057
0058 public:
0059
0060 bool in_event() const { return (bool) (m_event); }
0061
0062
0063 GenEvent* parent_event() { return m_event; }
0064
0065 const GenEvent* parent_event() const { return m_event; }
0066
0067
0068 int id() const { return m_id; }
0069
0070 const GenParticleData& data() const { return m_data; }
0071
0072 ConstGenVertexPtr production_vertex() const;
0073 ConstGenVertexPtr end_vertex() const;
0074
0075 GenVertexPtr production_vertex();
0076 GenVertexPtr end_vertex();
0077
0078
0079
0080 std::vector<GenParticlePtr> parents();
0081
0082
0083
0084 std::vector<ConstGenParticlePtr> parents() const;
0085
0086
0087
0088 std::vector<GenParticlePtr> children();
0089
0090
0091
0092 std::vector<ConstGenParticlePtr> children() const;
0093
0094 int pid() const { return m_data.pid; }
0095 int abs_pid() const { return std::abs(pid()); }
0096 int status() const { return m_data.status; }
0097 const FourVector& momentum() const { return m_data.momentum; }
0098 bool is_generated_mass_set() const { return m_data.is_mass_set; }
0099
0100
0101
0102
0103
0104 double generated_mass() const;
0105
0106
0107 void set_pid(int pid);
0108 void set_status(int status);
0109 void set_momentum(const FourVector& momentum);
0110 void set_generated_mass(double m);
0111 void unset_generated_mass();
0112
0113
0114
0115
0116
0117
0118 bool add_attribute(const std::string& name, std::shared_ptr<Attribute> att);
0119
0120
0121 std::vector<std::string> attribute_names() const;
0122
0123
0124 void remove_attribute(const std::string& name);
0125
0126
0127 template<class T>
0128 std::shared_ptr<T> attribute(const std::string& name) const;
0129
0130
0131 std::string attribute_as_string(const std::string& name) const;
0132
0133
0134
0135
0136
0137
0138
0139 int pdg_id() const { return pid(); }
0140
0141
0142
0143 void set_pdg_id(const int& pidin) { set_pid(pidin); }
0144
0145
0146
0147
0148
0149 private:
0150 GenEvent *m_event;
0151 int m_id;
0152 GenParticleData m_data;
0153
0154 std::weak_ptr<GenVertex> m_production_vertex;
0155 std::weak_ptr<GenVertex> m_end_vertex;
0156 };
0157
0158 }
0159
0160
0161
0162 #include "HepMC3/GenEvent.h"
0163 namespace HepMC3 {
0164
0165 template<class T> std::shared_ptr<T> GenParticle::attribute(const std::string& name) const {
0166 return parent_event()?
0167 parent_event()->attribute<T>(name, id()): std::shared_ptr<T>();
0168 }
0169 }
0170 #endif