26std::vector<HepMC3::GenParticlePtr>
children(
const HepMC3::GenVertexPtr& O) {
27 if (O)
return O->particles_out();
31std::vector<HepMC3::ConstGenParticlePtr>
children(
const HepMC3::ConstGenVertexPtr& O) {
32 if (O)
return O->particles_out();
36std::vector<HepMC3::GenVertexPtr>
children(
const HepMC3::GenParticlePtr& O) {
37 std::vector<HepMC3::GenVertexPtr> result;
38 if (O->end_vertex()) result.emplace_back(O->end_vertex());
42std::vector<HepMC3::ConstGenVertexPtr>
children(
const HepMC3::ConstGenParticlePtr& O) {
43 std::vector<HepMC3::ConstGenVertexPtr> result;
44 if (O->end_vertex()) result.emplace_back(O->end_vertex());
48std::vector<HepMC3::GenParticlePtr>
grandchildren(
const HepMC3::GenParticlePtr& O) {
49 if (O)
if (O->end_vertex())
return O->end_vertex()->particles_out();
53std::vector<HepMC3::ConstGenParticlePtr>
grandchildren(
const HepMC3::ConstGenParticlePtr& O) {
54 if (O)
if (O->end_vertex())
return O->end_vertex()->particles_out();
58std::vector<HepMC3::GenVertexPtr>
grandchildren(
const HepMC3::GenVertexPtr& O) {
59 std::vector<HepMC3::GenVertexPtr> result;
60 if (O)
for (
const auto&o: O->particles_out())
if (o->end_vertex()) result.emplace_back(o->end_vertex());
64std::vector<HepMC3::ConstGenVertexPtr>
grandchildren(
const HepMC3::ConstGenVertexPtr& O) {
65 std::vector<HepMC3::ConstGenVertexPtr> result;
66 if (O)
for (
const auto& o:O->particles_out())
if (o->end_vertex()) result.emplace_back(o->end_vertex());
70std::vector<HepMC3::GenParticlePtr>
parents(
const HepMC3::GenVertexPtr& O) {
71 if (O)
return O->particles_in();
75std::vector<HepMC3::ConstGenParticlePtr>
parents(
const HepMC3::ConstGenVertexPtr& O) {
76 if (O)
return O->particles_in();
80std::vector<HepMC3::GenVertexPtr>
parents(
const HepMC3::GenParticlePtr& O) {
81 std::vector<HepMC3::GenVertexPtr> result;
82 if (O->production_vertex()) result.emplace_back(O->production_vertex());
86std::vector<HepMC3::ConstGenVertexPtr>
parents(
const HepMC3::ConstGenParticlePtr& O) {
87 std::vector<HepMC3::ConstGenVertexPtr> result;
88 if (O->production_vertex()) result.emplace_back(O->production_vertex());
92std::vector<HepMC3::GenParticlePtr>
grandparents(
const HepMC3::GenParticlePtr& O) {
93 if (O)
if (O->production_vertex())
return O->production_vertex()->particles_in();
97std::vector<HepMC3::ConstGenParticlePtr>
grandparents(
const HepMC3::ConstGenParticlePtr& O) {
98 if (O)
if (O->production_vertex())
return O->production_vertex()->particles_in();
102std::vector<HepMC3::GenVertexPtr>
grandparents(
const HepMC3::GenVertexPtr& O) {
103 std::vector<HepMC3::GenVertexPtr> result;
104 if (O)
for (
const auto& o: O->particles_in())
if (o->production_vertex()) result.emplace_back(o->production_vertex());
108std::vector<HepMC3::ConstGenVertexPtr>
grandparents(
const HepMC3::ConstGenVertexPtr& O) {
109 std::vector<HepMC3::ConstGenVertexPtr> result;
110 if (O)
for (
const auto& o: O->particles_in())
if (o->end_vertex()) result.emplace_back(o->production_vertex());
122 for (; gc < result.size(); gc++)
125 std::move(temp0.begin(), temp0.end(), std::back_inserter(temp));
127 for (
const auto& p2: temp)
if (std::find(result.begin(), result.end(), p2) == result.end()) result.emplace_back(p2);
128 if (gc >= result.size())
break;
135 std::vector<R> localchildren =
children(obj);
136 std::vector<R> result = localchildren;
137 for (
const auto& c: localchildren)
140 for (
const auto& d: desc)
if (std::find(result.begin(), result.end(), d) == result.end()) result.emplace_back(d);
153 for (; gc < result.size(); gc++)
156 std::move(temp0.begin(), temp0.end(), std::back_inserter(temp));
158 for (
const auto& p2: temp)
if (std::find(result.begin(), result.end(), p2) == result.end()) result.emplace_back(p2);
159 if (gc >= result.size())
break;
166 std::vector<R> localparents =
parents(obj);
167 std::vector<R> result = localparents;
168 for (
const auto& c: localparents)
171 for (
const auto& d: desc)
if (std::find(result.begin(), result.end(), d) == result.end()) result.emplace_back(d);
177 return descendants_of_other_type<HepMC3::ConstGenVertexPtr, HepMC3::ConstGenParticlePtr>(obj);
180 return descendants_of_other_type<HepMC3::GenVertexPtr, HepMC3::GenParticlePtr>(obj);
184 return descendants_of_other_type<HepMC3::ConstGenParticlePtr, HepMC3::ConstGenVertexPtr>(obj);
187 return descendants_of_other_type<HepMC3::GenParticlePtr, HepMC3::GenVertexPtr>(obj);
191 return ancestors_of_other_type<HepMC3::ConstGenVertexPtr, HepMC3::ConstGenParticlePtr>(obj);
194 return ancestors_of_other_type<HepMC3::GenVertexPtr, HepMC3::GenParticlePtr>(obj);
197std::vector<HepMC3::ConstGenVertexPtr>
ancestor_vertices(
const HepMC3::ConstGenParticlePtr& obj) {
198 return ancestors_of_other_type<HepMC3::ConstGenParticlePtr, HepMC3::ConstGenVertexPtr>(obj);
201 return ancestors_of_other_type<HepMC3::GenParticlePtr, HepMC3::GenVertexPtr>(obj);
Defines helper classes to extract relatives of an input GenParticle or GenVertex.
static HEPMC3search_Relatives_EXPORT_API thread_local const Ancestors ANCESTORS
Ancestors.
static HEPMC3search_Relatives_EXPORT_API const Parents PARENTS
Parents.
static HEPMC3search_Relatives_EXPORT_API const Children CHILDREN
Children.
static HEPMC3search_Relatives_EXPORT_API thread_local const Descendants DESCENDANTS
Descendants.
std::vector< HepMC3::GenParticlePtr > parent_particles(const HepMC3::GenVertexPtr &O)
Return parent particles.
std::vector< HepMC3::GenParticlePtr > grandparent_particles(const HepMC3::GenParticlePtr &O)
Return grandparent particles.
std::vector< HepMC3::ConstGenParticlePtr > ancestor_particles(const HepMC3::ConstGenVertexPtr &obj)
Return ancestor particles.
std::vector< R > ancestors_of_other_type(const O &obj)
Returns ancestors of the other type, i.e. vertices for particle and particles for vertex.
std::vector< HepMC3::GenParticlePtr > grandparents(const HepMC3::GenParticlePtr &O)
Returns grandparents of particle, i.e. incoming particles of production vertex.
std::vector< HepMC3::ConstGenParticlePtr > descendant_particles(const HepMC3::ConstGenVertexPtr &obj)
Return descendant particles.
std::vector< HepMC3::GenVertexPtr > grandchildren_vertices(const HepMC3::GenVertexPtr &O)
Return grandchildren vertices.
std::vector< HepMC3::GenVertexPtr > grandparent_vertices(const HepMC3::GenVertexPtr &O)
Return grandparent vertices.
std::vector< HepMC3::GenParticlePtr > children_particles(const HepMC3::GenVertexPtr &O)
Return children particles.
std::vector< HepMC3::GenVertexPtr > parent_vertices(const HepMC3::GenParticlePtr &O)
Return parent vertices.
RelativesInterface< Recursive< _children > > Descendants
Descendants is an alias to Recursion applied to the _children and wrapped in the Relatives interface.
std::vector< O > descendants_of_same_type(const O &obj)
Returns descendands of the same type, i.e. vertices for vertex and particles for particle.
RelativesInterface< Recursive< _parents > > Ancestors
Ancestors is an alias to Recursion applied to the _parents and wrapped in the Relatives interface.
std::vector< R > descendants_of_other_type(const O &obj)
Returns descendands of the other type, i.e. vertices for particle and particles for vertex.
std::vector< HepMC3::GenParticlePtr > grandchildren_particles(const HepMC3::GenParticlePtr &O)
Return grandchildren particles.
std::vector< HepMC3::GenParticlePtr > grandchildren(const HepMC3::GenParticlePtr &O)
Returns grandchildren of particle, i.e. the outgoing particles of the end vertex.
std::vector< O > ancestors_of_same_type(const O &obj)
Returns ancestors of the same type, i.e. vertices for vertex and particles for particle.
std::vector< HepMC3::GenParticlePtr > children(const HepMC3::GenVertexPtr &O)
Returns children of vertex, i.e. outgoing particles.
std::vector< HepMC3::GenVertexPtr > children_vertices(const HepMC3::GenParticlePtr &O)
Return children vertices.
std::vector< HepMC3::ConstGenVertexPtr > ancestor_vertices(const HepMC3::ConstGenParticlePtr &obj)
Return ancestor vertices.
RelativesInterface< _parents > Parents
alias of _parents wrapped in the Relatives interface
std::vector< HepMC3::ConstGenVertexPtr > descendant_vertices(const HepMC3::ConstGenParticlePtr &obj)
Return descendant vertices.
RelativesInterface< _children > Children
alias of _children wrapped in the Relatives interface
std::vector< HepMC3::GenParticlePtr > parents(const HepMC3::GenVertexPtr &O)
Returns parents of vertex, i.e. incoming particles.