10 #ifndef HEPMC3_RELATIVES_H
11 #define HEPMC3_RELATIVES_H
56 virtual std::vector<GenParticlePtr> operator()(GenParticlePtr input)
const = 0;
57 virtual std::vector<ConstGenParticlePtr> operator()(ConstGenParticlePtr input)
const = 0;
58 virtual std::vector<GenParticlePtr> operator()(GenVertexPtr input)
const = 0;
59 virtual std::vector<ConstGenParticlePtr> operator()(ConstGenVertexPtr input)
const = 0;
63 static thread_local
const Ancestors ANCESTORS;
74 template<
typename Relative_type>
83 GenParticles_type<GenParticlePtr> operator()(GenParticlePtr input)
const override {
return _internal(input);}
84 GenParticles_type<ConstGenParticlePtr> operator()(ConstGenParticlePtr input)
const override {
return _internal(input);}
85 GenParticles_type<GenVertexPtr> operator()(GenVertexPtr input)
const override {
return _internal(input);}
86 GenParticles_type<ConstGenVertexPtr> operator()(ConstGenVertexPtr input)
const override {
return _internal(input);}
90 Relative_type _internal;
94 template<
typename Relation_type>
99 template<
typename GenObject_type>
100 GenParticles_type<GenObject_type> operator()(GenObject_type input)
const {
101 for(
auto obj: m_checkedObjects) {
104 m_checkedObjects.clear();
105 return _recursive(input);
110 template<
typename GenObject_type,
typename dummy>
111 GenParticles_type<GenObject_type> _recursive(GenObject_type input)
const ;
113 GenParticles_type<GenVertexPtr> _recursive(GenVertexPtr input)
const {
115 GenParticles_type <GenVertexPtr> results;
116 if ( !input )
return results;
117 for(
auto v: m_checkedObjects) {
118 if(v->id() == input->id())
return results;
121 m_checkedObjects.emplace_back(
new idInterface<GenVertexPtr>(input));
123 for(
auto p: m_applyRelation(input)) {
124 results.emplace_back(p);
125 GenParticles_type <GenVertexPtr> tmp = _recursive(p);
126 results.insert(results.end(),
127 std::make_move_iterator(tmp.begin()),
128 std::make_move_iterator(tmp.end()));
134 GenParticles_type<ConstGenVertexPtr> _recursive(ConstGenVertexPtr input)
const {
136 GenParticles_type <ConstGenVertexPtr> results;
137 if ( !input )
return results;
138 for(
auto v: m_checkedObjects) {
139 if(v->id() == input->id())
return results;
142 m_checkedObjects.emplace_back(
new idInterface<ConstGenVertexPtr>(input));
144 for(
auto p: m_applyRelation(input)) {
145 results.emplace_back(p);
146 GenParticles_type <ConstGenVertexPtr> tmp = _recursive(p);
147 results.insert(results.end(),
148 std::make_move_iterator(tmp.begin()),
149 std::make_move_iterator(tmp.end()));
155 GenParticles_type<GenParticlePtr> _recursive(GenParticlePtr input)
const {
156 return _recursive(m_applyRelation.vertex(input));
158 GenParticles_type<ConstGenParticlePtr> _recursive(ConstGenParticlePtr input)
const {
159 return _recursive(m_applyRelation.vertex(input));
168 virtual int id()
const = 0;
171 template<
typename ID_type>
175 constexpr
idInterface(ID_type genObject): m_object(genObject) {}
176 int id()
const {
return m_object->id();}
184 Relation_type m_applyRelation;
185 mutable std::vector<hasId*> m_checkedObjects;
197 template<
typename GenObject_type,
typename dummy>
198 GenParticles_type<GenObject_type> operator()(GenObject_type input)
const;
200 template<typename GenObject_type, typename std::enable_if<std::is_same<GenVertex, typename std::remove_const<typename GenObject_type::element_type>::type>::value,
int*>
::type =
nullptr>
201 GenParticles_type<GenObject_type> operator()(GenObject_type input)
const {
return input->particles_in();}
203 template<typename GenObject_type, typename std::enable_if<std::is_same<GenParticle, typename std::remove_const<typename GenObject_type::element_type>::type>::value,
int*>
::type =
nullptr>
204 GenParticles_type<GenObject_type> operator()(GenObject_type input)
const {
return (*
this)(vertex(input));}
206 template<
typename GenObject_type>
207 GenVertex_type<GenObject_type> vertex(GenObject_type input)
const {
return input->production_vertex();}
219 template<
typename GenObject_type,
typename dummy>
220 GenParticles_type<GenObject_type> operator()(GenObject_type input)
const;
222 template<typename GenObject_type, typename std::enable_if<std::is_same<GenVertex, typename std::remove_const<typename GenObject_type::element_type>::type>::value,
int*>
::type =
nullptr>
223 GenParticles_type<GenObject_type> operator()(GenObject_type input)
const {
return input->particles_out();}
225 template<typename GenObject_type, typename std::enable_if<std::is_same<GenParticle, typename std::remove_const<typename GenObject_type::element_type>::type>::value,
int*>
::type =
nullptr>
226 GenParticles_type<GenObject_type> operator()(GenObject_type input)
const {
return (*
this)(vertex(input));}
228 template<
typename GenObject_type>
229 GenVertex_type<GenObject_type> vertex(GenObject_type input)
const {
return input->end_vertex();}
239 std::vector<HepMC3::ConstGenParticlePtr>
children_particles(HepMC3::ConstGenVertexPtr O);
241 std::vector<HepMC3::ConstGenVertexPtr>
children_vertices(HepMC3::ConstGenParticlePtr O);
246 std::vector<HepMC3::GenParticlePtr>
parent_particles(HepMC3::GenVertexPtr O);
247 std::vector<HepMC3::ConstGenParticlePtr>
parent_particles(HepMC3::ConstGenVertexPtr O);
248 std::vector<HepMC3::GenVertexPtr>
parent_vertices(HepMC3::GenParticlePtr O);
249 std::vector<HepMC3::ConstGenVertexPtr>
parent_vertices(HepMC3::ConstGenParticlePtr O);
258 std::vector<HepMC3::ConstGenVertexPtr>
descendant_vertices(HepMC3::ConstGenParticlePtr obj);
262 std::vector<HepMC3::ConstGenParticlePtr>
ancestor_particles(HepMC3::ConstGenVertexPtr obj);
264 std::vector<HepMC3::ConstGenParticlePtr>
ancestor_particles(HepMC3::ConstGenParticlePtr obj);
266 std::vector<HepMC3::ConstGenVertexPtr>
ancestor_vertices(HepMC3::ConstGenParticlePtr obj);
268 std::vector<HepMC3::ConstGenVertexPtr>
ancestor_vertices(HepMC3::ConstGenVertexPtr obj);
std::vector< HepMC3::GenVertexPtr > grandchildren_vertices(HepMC3::GenVertexPtr O)
Return grandchildren vertices.
Provides operator to find the child particles of a Vertex or Particle.
std::vector< HepMC3::GenVertexPtr > grandparent_vertices(HepMC3::GenVertexPtr O)
Return grandparent vertices.
std::vector< HepMC3::GenParticlePtr > grandchildren_particles(HepMC3::GenParticlePtr O)
Return grandchildren particles.
Definition of class GenParticle.
std::vector< HepMC3::GenParticlePtr > children_particles(HepMC3::GenVertexPtr O)
Return children particles.
std::vector< HepMC3::ConstGenVertexPtr > ancestor_vertices(HepMC3::ConstGenParticlePtr obj)
Return ancestor vertices.
Provides operator to find the parent particles of a Vertex or Particle.
forward declare the Relatives interface in which _parents and _children are wrapped ...
std::vector< HepMC3::GenVertexPtr > children_vertices(HepMC3::GenParticlePtr O)
Return children vertices.
Definition of class GenVertex.
Define a common interface that all Relatives objects will satisfy Relatives provides an operator to g...
std::vector< HepMC3::GenVertexPtr > parent_vertices(HepMC3::GenParticlePtr O)
Return parent vertices.
forward declare the recursion wrapper
std::vector< HepMC3::GenParticlePtr > parent_particles(HepMC3::GenVertexPtr O)
Return parent particles.
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.
std::vector< HepMC3::ConstGenParticlePtr > ancestor_particles(HepMC3::ConstGenVertexPtr obj)
Return ancestor particles.