MARLEY (Model of Argon Reaction Low Energy Yields) v2.0.0
A Monte Carlo event generator for tens-of-MeV neutrino interactions
Loading...
Searching...
No Matches
GenVertex.h
1// -*- C++ -*-
2//
3// This file is part of HepMC
4// Copyright (C) 2014-2023 The HepMC collaboration (see AUTHORS for details)
5//
8//
9#ifndef HEPMC3_GENVERTEX_H
10#define HEPMC3_GENVERTEX_H
11#include <string>
12#include "HepMC3/GenParticle_fwd.h"
13#include "HepMC3/GenVertex_fwd.h"
14#include "HepMC3/Data/GenVertexData.h"
15#include "HepMC3/FourVector.h"
16
17#ifdef HEPMC3_PROTOBUFIO
18namespace HepMC3_pb {
19class GenEventData_GenVertexData;
20}
21#endif
22
23namespace HepMC3 {
24
25class Attribute;
26class GenEvent;
27
29class GenVertex : public std::enable_shared_from_this<GenVertex> {
30
31 friend class GenEvent;
32
33public:
34
37
40
43
44#ifdef HEPMC3_PROTOBUFIO
46 GenVertex( HepMC3_pb::GenEventData_GenVertexData const &data );
47#endif
48
50
51
54
56 GenEvent* parent_event() { return m_event; }
57
59 const GenEvent* parent_event() const { return m_event; }
60
62 bool in_event() const { return parent_event() != nullptr; }
63
67 int id() const { return m_id; }
68
70 int status() const { return m_data.status; }
72 void set_status(int stat) { m_data.status = stat; }
73
75 const GenVertexData& data() const { return m_data; }
76
78 void add_particle_in ( GenParticlePtr p);
80 void add_particle_out( GenParticlePtr p);
82 void remove_particle_in ( GenParticlePtr p);
84 void remove_particle_out( GenParticlePtr p);
85
87 inline int particles_in_size() const { return m_particles_in.size(); }
89 inline int particles_out_size() const { return m_particles_out.size(); }
90
91
93 const std::vector<GenParticlePtr>& particles_in() { return m_particles_in; }
95 const std::vector<ConstGenParticlePtr>& particles_in() const;
97 const std::vector<GenParticlePtr>& particles_out() { return m_particles_out; }
99 const std::vector<ConstGenParticlePtr>& particles_out() const;
100
107 const FourVector& position() const;
109 bool has_set_position() const { return !(m_data.position.is_zero()); }
110
112 void set_position(const FourVector& new_pos);
113
119 bool add_attribute(const std::string& name, std::shared_ptr<Attribute> att);
120
122 std::vector<std::string> attribute_names() const;
123
125 void remove_attribute(const std::string& name);
126
128 template<class T>
129 std::shared_ptr<T> attribute(const std::string& name) const;
130
132 std::string attribute_as_string(const std::string& name) const;
133
134
135private:
136
139 GenEvent *m_event;
140 int m_id;
141 GenVertexData m_data;
142
143 std::vector<GenParticlePtr> m_particles_in;
144
145 std::vector<GenParticlePtr> m_particles_out;
147
148};
149
150
151} // namespace HepMC3
152
153#include "HepMC3/GenEvent.h"
154namespace HepMC3 {
156template<class T> std::shared_ptr<T> GenVertex::attribute(const std::string& name) const {
157 return parent_event()?
158 parent_event()->attribute<T>(name, id()): std::shared_ptr<T>();
159}
160}
161
162#endif
Base attribute class.
Definition Attribute.h:44
Generic 4-vector.
Definition FourVector.h:36
static const FourVector & ZERO_VECTOR()
Static null FourVector = (0,0,0,0)
Definition FourVector.h:306
Stores event-related information.
Definition GenEvent.h:47
std::shared_ptr< T > attribute(const std::string &name, const int &id=0) const
Get attribute of type T.
Definition GenEvent.h:418
std::vector< std::string > attribute_names() const
Get list of names of attributes assigned to this particle.
GenEvent * parent_event()
Get parent event.
Definition GenVertex.h:56
const GenVertexData & data() const
Get vertex data.
Definition GenVertex.h:75
int id() const
Definition GenVertex.h:67
void add_particle_in(GenParticlePtr p)
Add incoming particle.
std::string attribute_as_string(const std::string &name) const
Get attribute of any type as string.
void set_status(int stat)
Set vertex status code.
Definition GenVertex.h:72
const GenEvent * parent_event() const
Get parent event.
Definition GenVertex.h:59
int particles_in_size() const
Number of incoming particles, HepMC2 compatiility.
Definition GenVertex.h:87
int status() const
Get vertex status code.
Definition GenVertex.h:70
bool in_event() const
Check if this vertex belongs to an event.
Definition GenVertex.h:62
void remove_attribute(const std::string &name)
Remove attribute.
void remove_particle_in(GenParticlePtr p)
Remove incoming particle.
const std::vector< GenParticlePtr > & particles_out()
Get list of outgoing particles.
Definition GenVertex.h:97
void set_position(const FourVector &new_pos)
Set vertex position.
bool has_set_position() const
Check if position of this vertex is set.
Definition GenVertex.h:109
std::shared_ptr< T > attribute(const std::string &name) const
Get attribute of type T.
Definition GenVertex.h:156
bool add_attribute(const std::string &name, std::shared_ptr< Attribute > att)
Add event attribute to this vertex.
const FourVector & position() const
Get vertex position.
int particles_out_size() const
Number of outgoing particles, HepMC2 compatiility.
Definition GenVertex.h:89
const std::vector< GenParticlePtr > & particles_in()
Get list of incoming particles.
Definition GenVertex.h:93
void add_particle_out(GenParticlePtr p)
Add outgoing particle.
GenVertex(const FourVector &position=FourVector::ZERO_VECTOR())
Default constructor.
void remove_particle_out(GenParticlePtr p)
Remove outgoing particle.
Stores serializable vertex information.