10 #ifndef HEPMC3_RELATIVES_H
11 #define HEPMC3_RELATIVES_H
55 virtual std::vector<GenParticlePtr> operator()(GenParticlePtr input)
const = 0;
56 virtual std::vector<ConstGenParticlePtr> operator()(ConstGenParticlePtr input)
const = 0;
57 virtual std::vector<GenParticlePtr> operator()(GenVertexPtr input)
const = 0;
58 virtual std::vector<ConstGenParticlePtr> operator()(ConstGenVertexPtr input)
const = 0;
62 static thread_local
const Ancestors ANCESTORS;
73 template<
typename Relative_type>
82 GenParticles_type<GenParticlePtr> operator()(GenParticlePtr input)
const override {
return _internal(input);}
83 GenParticles_type<ConstGenParticlePtr> operator()(ConstGenParticlePtr input)
const override {
return _internal(input);}
84 GenParticles_type<GenVertexPtr> operator()(GenVertexPtr input)
const override {
return _internal(input);}
85 GenParticles_type<ConstGenVertexPtr> operator()(ConstGenVertexPtr input)
const override {
return _internal(input);}
89 Relative_type _internal;
93 template<
typename Relation_type>
98 template<
typename GenObject_type>
99 GenParticles_type<GenObject_type> operator()(GenObject_type input)
const {
100 for(
auto obj: m_checkedObjects) {
103 m_checkedObjects.clear();
104 return _recursive(input);
109 template<
typename GenObject_type,
typename dummy>
110 GenParticles_type<GenObject_type> _recursive(GenObject_type input)
const ;
112 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>
113 GenParticles_type<GenObject_type> _recursive(GenObject_type input)
const {
115 GenParticles_type <GenObject_type> 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<GenObject_type>(input));
123 for(
auto p: m_applyRelation(input)) {
124 results.emplace_back(p);
125 GenParticles_type <GenObject_type> tmp = _recursive(p);
126 results.insert(results.end(),
127 std::make_move_iterator(tmp.begin()),
128 std::make_move_iterator(tmp.end()));
134 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>
135 GenParticles_type<GenObject_type> _recursive(GenObject_type input)
const {
136 return _recursive(m_applyRelation.vertex(input));
144 virtual int id()
const = 0;
147 template<
typename ID_type>
151 constexpr
idInterface(ID_type genObject): m_object(genObject) {}
152 int id()
const {
return m_object->id();}
160 Relation_type m_applyRelation;
161 mutable std::vector<hasId*> m_checkedObjects;
173 template<
typename GenObject_type,
typename dummy>
174 GenParticles_type<GenObject_type> operator()(GenObject_type input)
const;
176 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>
177 GenParticles_type<GenObject_type> operator()(GenObject_type input)
const {
return input->particles_in();}
179 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>
180 GenParticles_type<GenObject_type> operator()(GenObject_type input)
const {
return (*
this)(vertex(input));}
182 template<
typename GenObject_type>
183 GenVertex_type<GenObject_type> vertex(GenObject_type input)
const {
return input->production_vertex();}
195 template<
typename GenObject_type,
typename dummy>
196 GenParticles_type<GenObject_type> operator()(GenObject_type input)
const;
198 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>
199 GenParticles_type<GenObject_type> operator()(GenObject_type input)
const {
return input->particles_out();}
201 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>
202 GenParticles_type<GenObject_type> operator()(GenObject_type input)
const {
return (*
this)(vertex(input));}
204 template<
typename GenObject_type>
205 GenVertex_type<GenObject_type> vertex(GenObject_type input)
const {
return input->end_vertex();}
Provides operator to find the child particles of a Vertex or Particle.
Definition of class GenParticle.
Provides operator to find the parent particles of a Vertex or Particle.
forward declare the Relatives interface in which _parents and _children are wrapped ...
Definition of class GenVertex.
Define a common interface that all Relatives objects will satisfy Relatives provides an operator to g...
forward declare the recursion wrapper