10#ifndef HEPMC3_RELATIVES_H
11#define HEPMC3_RELATIVES_H
12#if defined(WIN32)&&(!defined(HEPMC3search_NO_Relatives_EXPORTS))
13#ifdef HepMC3search_EXPORTS
14#define HEPMC3search_Relatives_EXPORT_API __declspec(dllexport)
16#define HEPMC3search_Relatives_EXPORT_API __declspec(dllimport)
19#define HEPMC3search_Relatives_EXPORT_API
28std::vector<HepMC3::ConstGenParticlePtr>
children_particles(HepMC3::ConstGenVertexPtr O);
30std::vector<HepMC3::ConstGenVertexPtr>
children_vertices(HepMC3::ConstGenParticlePtr O);
36std::vector<HepMC3::ConstGenParticlePtr>
parent_particles(HepMC3::ConstGenVertexPtr O);
37std::vector<HepMC3::GenVertexPtr>
parent_vertices(HepMC3::GenParticlePtr O);
38std::vector<HepMC3::ConstGenVertexPtr>
parent_vertices(HepMC3::ConstGenParticlePtr O);
51std::vector<HepMC3::ConstGenParticlePtr>
ancestor_particles(HepMC3::ConstGenVertexPtr obj);
53std::vector<HepMC3::ConstGenParticlePtr>
ancestor_particles(HepMC3::ConstGenParticlePtr obj);
55std::vector<HepMC3::ConstGenVertexPtr>
ancestor_vertices(HepMC3::ConstGenParticlePtr obj);
57std::vector<HepMC3::ConstGenVertexPtr>
ancestor_vertices(HepMC3::ConstGenVertexPtr obj);
67class RelativesInterface;
79 template<
typename GenObject_type,
typename dummy>
80 GenParticles_type<GenObject_type>
operator()(GenObject_type input)
const;
83 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>
84 GenParticles_type<GenObject_type>
operator()(GenObject_type input)
const {
return input->particles_in();}
87 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>
88 GenParticles_type<GenObject_type>
operator()(GenObject_type input)
const {
return (*
this)(
vertex(input));}
91 template<
typename GenObject_type>
92 GenVertex_type<GenObject_type>
vertex(GenObject_type input)
const {
return input->production_vertex();}
102 template<
typename GenObject_type,
typename dummy>
103 GenParticles_type<GenObject_type>
operator()(GenObject_type input)
const;
106 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>
107 GenParticles_type<GenObject_type>
operator()(GenObject_type input)
const {
return input->particles_out();}
110 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>
111 GenParticles_type<GenObject_type>
operator()(GenObject_type input)
const {
return (*
this)(
vertex(input));}
114 template<
typename GenObject_type>
115 GenVertex_type<GenObject_type>
vertex(GenObject_type input)
const {
return input->end_vertex();}
121 std::vector<ConstGenParticlePtr> operator()(ConstGenVertexPtr input) {
return parent_particles(input);}
122 std::vector<GenParticlePtr> operator()(GenVertexPtr input) {
return parent_particles(input);}
123 std::vector<ConstGenParticlePtr> operator()(ConstGenParticlePtr input) {
return grandparent_particles(input);}
127class SearchChildren {
129 std::vector<ConstGenParticlePtr> operator()(ConstGenVertexPtr input)
const {
return children_particles(input);}
130 std::vector<GenParticlePtr> operator()(GenVertexPtr input)
const {
return children_particles(input);}
131 std::vector<ConstGenParticlePtr> operator()(ConstGenParticlePtr input)
const {
return grandchildren_particles(input);}
135class SearchAncestors {
137 std::vector<ConstGenParticlePtr> operator()(ConstGenVertexPtr input)
const {
return ancestor_particles(input);}
138 std::vector<GenParticlePtr> operator()(GenVertexPtr input)
const {
return ancestor_particles(input);}
139 std::vector<ConstGenParticlePtr> operator()(ConstGenParticlePtr input)
const {
return ancestor_particles(input);}
140 std::vector<GenParticlePtr> operator()(GenParticlePtr input)
const {
return ancestor_particles(input);}
143class SearchDescendants {
145 std::vector<ConstGenParticlePtr> operator()(ConstGenVertexPtr input)
const {
return descendant_particles(input);}
146 std::vector<GenParticlePtr> operator()(GenVertexPtr input)
const {
return descendant_particles(input);}
147 std::vector<ConstGenParticlePtr> operator()(ConstGenParticlePtr input)
const {
return descendant_particles(input);}
148 std::vector<GenParticlePtr> operator()(GenParticlePtr input)
const {
return descendant_particles(input);}
185 virtual std::vector<GenParticlePtr>
operator()(GenParticlePtr input)
const = 0;
187 virtual std::vector<ConstGenParticlePtr>
operator()(ConstGenParticlePtr input)
const = 0;
189 virtual std::vector<GenParticlePtr>
operator()(GenVertexPtr input)
const = 0;
191 virtual std::vector<ConstGenParticlePtr>
operator()(ConstGenVertexPtr input)
const = 0;
216template<
typename Relative_type>
223 GenParticles_type<GenParticlePtr>
operator()(GenParticlePtr input)
const override {
return _internal(input);}
225 GenParticles_type<ConstGenParticlePtr>
operator()(ConstGenParticlePtr input)
const override {
return _internal(input);}
227 GenParticles_type<GenVertexPtr>
operator()(GenVertexPtr input)
const override {
return _internal(input);}
229 GenParticles_type<ConstGenVertexPtr>
operator()(ConstGenVertexPtr input)
const override {
return _internal(input);}
232 Relative_type _internal;
235template<
typename Relation_type>
239 template<
typename GenObject_type>
240 GenParticles_type<GenObject_type>
operator()(GenObject_type input)
const {
250 template<
typename GenObject_type,
typename dummy>
251 GenParticles_type<GenObject_type>
_recursive(GenObject_type input)
const;
254 GenParticles_type<GenVertexPtr>
_recursive(GenVertexPtr input)
const {
255 GenParticles_type <GenVertexPtr> results;
256 if ( !input )
return results;
258 if (v->id() == input->id())
return results;
264 results.emplace_back(p);
265 GenParticles_type <GenVertexPtr> tmp =
_recursive(p);
266 results.insert(results.end(),
267 std::make_move_iterator(tmp.begin()),
268 std::make_move_iterator(tmp.end()));
275 GenParticles_type<ConstGenVertexPtr>
_recursive(ConstGenVertexPtr input)
const {
276 GenParticles_type <ConstGenVertexPtr> results;
277 if ( !input )
return results;
279 if (v->id() == input->id())
return results;
285 results.emplace_back(p);
286 GenParticles_type <ConstGenVertexPtr> tmp =
_recursive(p);
287 results.insert(results.end(),
288 std::make_move_iterator(tmp.begin()),
289 std::make_move_iterator(tmp.end()));
296 GenParticles_type<GenParticlePtr>
_recursive(GenParticlePtr input)
const {
300 GenParticles_type<ConstGenParticlePtr>
_recursive(ConstGenParticlePtr input)
const {
311 virtual int id()
const = 0;
314 template<
typename ID_type>
Definition of class GenParticle.
Definition of class GenVertex.
virtual ~hasId()
destructor
virtual int id() const =0
id
ID_type m_object
id of object
constexpr idInterface(ID_type genObject)
idInterface
int id() const override
id
forward declare the recursion wrapper
GenParticles_type< GenObject_type > _recursive(GenObject_type input) const
recursive
std::vector< hasId * > m_checkedObjects
Checked objects.
GenParticles_type< ConstGenVertexPtr > _recursive(ConstGenVertexPtr input) const
recursive
GenParticles_type< ConstGenParticlePtr > _recursive(ConstGenParticlePtr input) const
recursive
Relation_type m_applyRelation
applyRelation
GenParticles_type< GenVertexPtr > _recursive(GenVertexPtr input) const
recursive
GenParticles_type< GenParticlePtr > _recursive(GenParticlePtr input) const
recursive
GenParticles_type< GenObject_type > operator()(GenObject_type input) const
Operator.
forward declare the Relatives interface in which _parents and _children are wrapped
GenParticles_type< ConstGenParticlePtr > operator()(ConstGenParticlePtr input) const override
Operator.
GenParticles_type< GenVertexPtr > operator()(GenVertexPtr input) const override
Operator.
GenParticles_type< ConstGenVertexPtr > operator()(ConstGenVertexPtr input) const override
Operator.
GenParticles_type< GenParticlePtr > operator()(GenParticlePtr input) const override
Operator.
Define a common interface that all Relatives objects will satisfy Relatives provides an operator to g...
static HEPMC3search_Relatives_EXPORT_API thread_local const Ancestors ANCESTORS
Ancestors.
static HEPMC3search_Relatives_EXPORT_API const Parents PARENTS
Parents.
virtual std::vector< ConstGenParticlePtr > operator()(ConstGenParticlePtr input) const =0
Operator.
virtual std::vector< ConstGenParticlePtr > operator()(ConstGenVertexPtr input) const =0
Operator.
virtual std::vector< GenParticlePtr > operator()(GenParticlePtr input) const =0
Operator.
static HEPMC3search_Relatives_EXPORT_API const Children CHILDREN
Children.
virtual std::vector< GenParticlePtr > operator()(GenVertexPtr input) const =0
Operator.
static HEPMC3search_Relatives_EXPORT_API thread_local const Descendants DESCENDANTS
Descendants.
Provides operator to find the child particles of a Vertex or Particle.
GenParticles_type< GenObject_type > operator()(GenObject_type input) const
operator
GenVertex_type< GenObject_type > vertex(GenObject_type input) const
operator
Provides operator to find the parent particles of a Vertex or Particle.
GenParticles_type< GenObject_type > operator()(GenObject_type input) const
operator
GenVertex_type< GenObject_type > vertex(GenObject_type input) const
vertex
std::vector< HepMC3::GenParticlePtr > parent_particles(HepMC3::GenVertexPtr O)
Return parent particles.
std::vector< HepMC3::ConstGenParticlePtr > ancestor_particles(HepMC3::ConstGenVertexPtr obj)
Return ancestor particles.
std::vector< HepMC3::GenParticlePtr > grandparent_particles(HepMC3::GenParticlePtr O)
Return grandparent particles.
std::vector< HepMC3::ConstGenVertexPtr > descendant_vertices(HepMC3::ConstGenParticlePtr obj)
Return descendant vertices.
std::vector< HepMC3::ConstGenVertexPtr > ancestor_vertices(HepMC3::ConstGenParticlePtr obj)
Return ancestor vertices.
RelativesInterface< Recursive< _children > > Descendants
Descendants is an alias to Recursion applied to the _children and wrapped in the Relatives interface.
RelativesInterface< Recursive< _parents > > Ancestors
Ancestors is an alias to Recursion applied to the _parents and wrapped in the Relatives interface.
std::vector< HepMC3::ConstGenParticlePtr > descendant_particles(HepMC3::ConstGenVertexPtr obj)
Return descendant particles.
std::vector< HepMC3::GenParticlePtr > children_particles(HepMC3::GenVertexPtr O)
Return children particles.
std::vector< HepMC3::GenVertexPtr > grandchildren_vertices(HepMC3::GenVertexPtr O)
Return grandchildren vertices.
std::vector< HepMC3::GenParticlePtr > grandchildren_particles(HepMC3::GenParticlePtr O)
Return grandchildren particles.
std::vector< HepMC3::GenVertexPtr > parent_vertices(HepMC3::GenParticlePtr O)
Return parent vertices.
std::vector< HepMC3::GenVertexPtr > children_vertices(HepMC3::GenParticlePtr O)
Return children vertices.
RelativesInterface< _parents > Parents
alias of _parents wrapped in the Relatives interface
RelativesInterface< _children > Children
alias of _children wrapped in the Relatives interface
std::vector< HepMC3::GenVertexPtr > grandparent_vertices(HepMC3::GenVertexPtr O)
Return grandparent vertices.