13 const Parents Relatives::PARENTS;
15 thread_local
const Ancestors Relatives::ANCESTORS;
16 thread_local
const Descendants Relatives::DESCENDANTS;
24 std::vector<HepMC3::GenParticlePtr> children(HepMC3::GenVertexPtr O) {
25 if (O)
return O->particles_out();
26 return std::vector<HepMC3::GenParticlePtr>();
28 std::vector<HepMC3::ConstGenParticlePtr> children(HepMC3::ConstGenVertexPtr O) {
29 if (O)
return O->particles_out();
30 return std::vector<HepMC3::ConstGenParticlePtr>();
33 std::vector<HepMC3::GenVertexPtr> children(HepMC3::GenParticlePtr O) {
34 std::vector<HepMC3::GenVertexPtr> result;
35 if (O->end_vertex()) result.push_back(O->end_vertex());
38 std::vector<HepMC3::ConstGenVertexPtr> children(HepMC3::ConstGenParticlePtr O) {
39 std::vector<HepMC3::ConstGenVertexPtr> result;
40 if (O->end_vertex()) result.push_back(O->end_vertex());
44 std::vector<HepMC3::GenParticlePtr> grandchildren(HepMC3::GenParticlePtr O) {
45 if (O)
if (O->end_vertex())
return O->end_vertex()->particles_out();
46 return std::vector<HepMC3::GenParticlePtr> ();
48 std::vector<HepMC3::ConstGenParticlePtr> grandchildren(HepMC3::ConstGenParticlePtr O) {
49 if (O)
if (O->end_vertex())
return O->end_vertex()->particles_out();
50 return std::vector<HepMC3::ConstGenParticlePtr> ();
53 std::vector<HepMC3::GenVertexPtr> grandchildren(HepMC3::GenVertexPtr O) {
54 std::vector<HepMC3::GenVertexPtr> result;
55 if (O)
for (
auto o: O->particles_out())
if (o->end_vertex()) result.push_back(o->end_vertex());
58 std::vector<HepMC3::ConstGenVertexPtr> grandchildren(HepMC3::ConstGenVertexPtr O) {
59 std::vector<HepMC3::ConstGenVertexPtr> result;
60 if (O)
for (
auto o:O->particles_out())
if (o->end_vertex()) result.push_back(o->end_vertex());
64 std::vector<HepMC3::GenParticlePtr> parents(HepMC3::GenVertexPtr O) {
65 if (O)
return O->particles_in();
66 return std::vector<GenParticlePtr>();
68 std::vector<HepMC3::ConstGenParticlePtr> parents(HepMC3::ConstGenVertexPtr O) {
69 if (O)
return O->particles_in();
70 return std::vector<HepMC3::ConstGenParticlePtr>();
73 std::vector<HepMC3::GenVertexPtr> parents(HepMC3::GenParticlePtr O) {
74 std::vector<HepMC3::GenVertexPtr> result;
75 if (O->production_vertex()) result.push_back(O->production_vertex());
78 std::vector<HepMC3::ConstGenVertexPtr> parents(HepMC3::ConstGenParticlePtr O) {
79 std::vector<HepMC3::ConstGenVertexPtr> result;
80 if (O->production_vertex()) result.push_back(O->production_vertex());
84 std::vector<HepMC3::GenParticlePtr> grandparents(HepMC3::GenParticlePtr O) {
85 if (O)
if (O->production_vertex())
return O->production_vertex()->particles_in();
86 return std::vector<HepMC3::GenParticlePtr> ();
88 std::vector<HepMC3::ConstGenParticlePtr> grandparents(HepMC3::ConstGenParticlePtr O) {
89 if (O)
if (O->production_vertex())
return O->production_vertex()->particles_in();
90 return std::vector<HepMC3::ConstGenParticlePtr> ();
93 std::vector<HepMC3::GenVertexPtr> grandparents(HepMC3::GenVertexPtr O) {
94 std::vector<HepMC3::GenVertexPtr> result;
95 if (O)
for (
auto o: O->particles_in())
if (o->production_vertex()) result.push_back(o->production_vertex());
98 std::vector<HepMC3::ConstGenVertexPtr> grandparents(HepMC3::ConstGenVertexPtr O) {
99 std::vector<HepMC3::ConstGenVertexPtr> result;
100 if (O)
for (
auto o:O->particles_in())
if (o->end_vertex()) result.push_back(o->production_vertex());
104 template <
class O> std::vector<O> descendants_of_same_type(O obj)
106 std::vector<O> result=grandchildren(obj);
111 for (; gc<result.size(); gc++)
113 auto temp0=grandchildren(result[gc]);
114 temp.insert(temp.end(),temp0.begin(),temp0.end());
116 for (
auto p2: temp)
if (std::find(result.begin(),result.end(),p2)==result.end()) result.push_back(p2);
117 if (gc>=result.size())
break;
123 template <
class O,
class R> std::vector<R> descendants_of_other_type(O obj)
125 std::vector<R> localchildren=children(obj);
126 std::vector<R> result=localchildren;
127 for (
auto c: localchildren)
129 std::vector<R> desc=descendants_of_same_type(c);
130 for (
auto d: desc)
if (std::find(result.begin(),result.end(),d)==result.end()) result.push_back(d);
135 template <
class O> std::vector<O> ancestors_of_same_type(O obj)
137 std::vector<O> result=grandparents(obj);
142 for (; gc<result.size(); gc++)
144 auto temp0=grandparents(result[gc]);
145 temp.insert(temp.end(),temp0.begin(),temp0.end());
147 for (
auto p2: temp)
if (std::find(result.begin(),result.end(),p2)==result.end()) result.push_back(p2);
148 if (gc>=result.size())
break;
153 template <
class O,
class R> std::vector<R> ancestors_of_other_type(O obj)
155 std::vector<R> localparents=parents(obj);
156 std::vector<R> result=localparents;
157 for (
auto c: localparents)
159 std::vector<R> desc=ancestors_of_same_type(c);
160 for (
auto d: desc)
if (std::find(result.begin(),result.end(),d)==result.end()) result.push_back(d);
166 return descendants_of_other_type<HepMC3::ConstGenVertexPtr,HepMC3::ConstGenParticlePtr>(obj);
169 return descendants_of_other_type<HepMC3::GenVertexPtr,HepMC3::GenParticlePtr>(obj);
173 return descendants_of_other_type<HepMC3::ConstGenParticlePtr,HepMC3::ConstGenVertexPtr>(obj);
176 return descendants_of_other_type<HepMC3::GenParticlePtr,HepMC3::GenVertexPtr>(obj);
180 return ancestors_of_other_type<HepMC3::ConstGenVertexPtr,HepMC3::ConstGenParticlePtr>(obj);
183 return ancestors_of_other_type<HepMC3::GenVertexPtr,HepMC3::GenParticlePtr>(obj);
187 return ancestors_of_other_type<HepMC3::ConstGenParticlePtr,HepMC3::ConstGenVertexPtr>(obj);
190 return ancestors_of_other_type<HepMC3::GenParticlePtr,HepMC3::GenVertexPtr>(obj);
194 std::vector<HepMC3::ConstGenParticlePtr>
descendant_particles(HepMC3::ConstGenParticlePtr obj) {
return descendants_of_same_type(obj); }
195 std::vector<HepMC3::GenParticlePtr>
descendant_particles(HepMC3::GenParticlePtr obj) {
return descendants_of_same_type(obj); }
196 std::vector<HepMC3::ConstGenVertexPtr>
descendant_vertices(HepMC3::ConstGenVertexPtr obj) {
return descendants_of_same_type(obj); }
197 std::vector<HepMC3::GenVertexPtr>
descendant_vertices(HepMC3::GenVertexPtr obj) {
return descendants_of_same_type(obj); }
198 std::vector<HepMC3::ConstGenParticlePtr>
ancestor_particles(HepMC3::ConstGenParticlePtr obj) {
return ancestors_of_same_type(obj); }
199 std::vector<HepMC3::GenParticlePtr>
ancestor_particles(HepMC3::GenParticlePtr obj) {
return ancestors_of_same_type(obj); }
200 std::vector<HepMC3::ConstGenVertexPtr>
ancestor_vertices(HepMC3::ConstGenVertexPtr obj) {
return ancestors_of_same_type(obj); }
201 std::vector<HepMC3::GenVertexPtr>
ancestor_vertices(HepMC3::GenVertexPtr obj) {
return ancestors_of_same_type(obj); }
202 std::vector<HepMC3::GenParticlePtr>
children_particles(HepMC3::GenVertexPtr O) {
return children(O); }
203 std::vector<HepMC3::ConstGenParticlePtr>
children_particles(HepMC3::ConstGenVertexPtr O) {
return children(O); }
204 std::vector<HepMC3::GenVertexPtr>
children_vertices(HepMC3::GenParticlePtr O) {
return children(O); }
205 std::vector<HepMC3::ConstGenVertexPtr>
children_vertices(HepMC3::ConstGenParticlePtr O) {
return children(O); }
210 std::vector<HepMC3::GenParticlePtr>
parent_particles(HepMC3::GenVertexPtr O) {
return parents(O); }
211 std::vector<HepMC3::ConstGenParticlePtr>
parent_particles(HepMC3::ConstGenVertexPtr O) {
return parents(O); }
212 std::vector<HepMC3::GenVertexPtr>
parent_vertices(HepMC3::GenParticlePtr O) {
return parents(O); }
213 std::vector<HepMC3::ConstGenVertexPtr>
parent_vertices(HepMC3::ConstGenParticlePtr O) {
return parents(O); }
215 std::vector<HepMC3::ConstGenParticlePtr>
grandparent_particles(HepMC3::ConstGenParticlePtr O) {
return grandparents(O); }
217 std::vector<HepMC3::ConstGenVertexPtr>
grandparent_vertices(HepMC3::ConstGenVertexPtr O) {
return grandparents(O); }
std::vector< HepMC3::GenVertexPtr > grandchildren_vertices(HepMC3::GenVertexPtr O)
Return grandchildren vertices.
std::vector< HepMC3::GenVertexPtr > grandparent_vertices(HepMC3::GenVertexPtr O)
Return grandparent vertices.
std::vector< HepMC3::GenParticlePtr > grandchildren_particles(HepMC3::GenParticlePtr O)
Return grandchildren particles.
std::vector< HepMC3::GenParticlePtr > children_particles(HepMC3::GenVertexPtr O)
Return children particles.
std::vector< HepMC3::ConstGenVertexPtr > ancestor_vertices(HepMC3::ConstGenParticlePtr obj)
Return ancestor vertices.
RelativesInterface< _parents > Parents
alias of _parents wrapped in the Relatives interface
std::vector< HepMC3::GenVertexPtr > children_vertices(HepMC3::GenParticlePtr O)
Return children vertices.
std::vector< HepMC3::GenVertexPtr > parent_vertices(HepMC3::GenParticlePtr O)
Return parent vertices.
RelativesInterface< Recursive< _parents > > Ancestors
Ancestors is an alias to Recursion applied to the _parents and wrapped in the Relatives interface...
std::vector< HepMC3::GenParticlePtr > parent_particles(HepMC3::GenVertexPtr O)
Return parent particles.
Defines helper classes to extract relatives of an input GenParticle or GenVertex. ...
RelativesInterface< _children > Children
alias of _children wrapped in the Relatives interface
std::vector< HepMC3::ConstGenVertexPtr > descendant_vertices(HepMC3::ConstGenParticlePtr obj)
Return descendant vertices.
std::vector< HepMC3::ConstGenParticlePtr > descendant_particles(HepMC3::ConstGenVertexPtr obj)
Return descendant particles.
std::vector< HepMC3::GenParticlePtr > grandparent_particles(HepMC3::GenParticlePtr O)
Return grandparent particles.
RelativesInterface< Recursive< _children > > Descendants
Descendants is an alias to Recursion applied to the _children and wrapped in the Relatives interface...
std::vector< HepMC3::ConstGenParticlePtr > ancestor_particles(HepMC3::ConstGenVertexPtr obj)
Return ancestor particles.