File indexing completed on 2025-01-18 10:01:12
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef HEPMC3_GENVERTEX_H
0010 #define HEPMC3_GENVERTEX_H
0011 #include <string>
0012 #include "HepMC3/GenParticle_fwd.h"
0013 #include "HepMC3/GenVertex_fwd.h"
0014 #include "HepMC3/Data/GenVertexData.h"
0015 #include "HepMC3/FourVector.h"
0016
0017 #ifdef HEPMC3_PROTOBUFIO
0018 namespace HepMC3_pb {
0019 class GenEventData_GenVertexData;
0020 }
0021 #endif
0022
0023 namespace HepMC3 {
0024
0025 class Attribute;
0026 class GenEvent;
0027
0028
0029 class GenVertex : public std::enable_shared_from_this<GenVertex> {
0030
0031 friend class GenEvent;
0032
0033 public:
0034
0035
0036
0037
0038
0039 GenVertex( const FourVector& position = FourVector::ZERO_VECTOR() );
0040
0041
0042 GenVertex( const GenVertexData& data );
0043
0044 #ifdef HEPMC3_PROTOBUFIO
0045
0046 GenVertex( HepMC3_pb::GenEventData_GenVertexData const &data );
0047 #endif
0048
0049
0050
0051
0052
0053
0054
0055
0056 GenEvent* parent_event() { return m_event; }
0057
0058
0059 const GenEvent* parent_event() const { return m_event; }
0060
0061
0062 bool in_event() const { return parent_event() != nullptr; }
0063
0064
0065
0066
0067 int id() const { return m_id; }
0068
0069
0070 int status() const { return m_data.status; }
0071
0072 void set_status(int stat) { m_data.status = stat; }
0073
0074
0075 const GenVertexData& data() const { return m_data; }
0076
0077
0078 void add_particle_in ( GenParticlePtr p);
0079
0080 void add_particle_out( GenParticlePtr p);
0081
0082 void remove_particle_in ( GenParticlePtr p);
0083
0084 void remove_particle_out( GenParticlePtr p);
0085
0086
0087 inline int particles_in_size() const { return m_particles_in.size(); }
0088
0089 inline int particles_out_size() const { return m_particles_out.size(); }
0090
0091
0092
0093 const std::vector<GenParticlePtr>& particles_in() { return m_particles_in; }
0094
0095 const std::vector<ConstGenParticlePtr>& particles_in() const;
0096
0097 const std::vector<GenParticlePtr>& particles_out() { return m_particles_out; }
0098
0099 const std::vector<ConstGenParticlePtr>& particles_out() const;
0100
0101
0102
0103
0104
0105
0106
0107 const FourVector& position() const;
0108
0109 bool has_set_position() const { return !(m_data.position.is_zero()); }
0110
0111
0112 void set_position(const FourVector& new_pos);
0113
0114
0115
0116
0117
0118
0119 bool add_attribute(const std::string& name, std::shared_ptr<Attribute> att);
0120
0121
0122 std::vector<std::string> attribute_names() const;
0123
0124
0125 void remove_attribute(const std::string& name);
0126
0127
0128 template<class T>
0129 std::shared_ptr<T> attribute(const std::string& name) const;
0130
0131
0132 std::string attribute_as_string(const std::string& name) const;
0133
0134
0135 private:
0136
0137
0138
0139 GenEvent *m_event;
0140 int m_id;
0141 GenVertexData m_data;
0142
0143 std::vector<GenParticlePtr> m_particles_in;
0144
0145 std::vector<GenParticlePtr> m_particles_out;
0146
0147
0148 };
0149
0150
0151 }
0152
0153 #include "HepMC3/GenEvent.h"
0154 namespace HepMC3 {
0155
0156 template<class T> std::shared_ptr<T> GenVertex::attribute(const std::string& name) const {
0157 return parent_event()?
0158 parent_event()->attribute<T>(name, id()): std::shared_ptr<T>();
0159 }
0160 }
0161
0162 #endif