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;
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));
143 virtual int id()
const = 0;
146 template<
typename ID_type>
150 constexpr
idInterface(ID_type genObject): m_object(genObject){}
151 int id()
const {
return m_object->id();}
159 Relation_type m_applyRelation;
160 mutable std::vector<hasId*> m_checkedObjects;
172 template<
typename GenObject_type,
typename dummy>
175 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>
178 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>
181 template<
typename GenObject_type>
182 GenVertex_type<GenObject_type> vertex(GenObject_type input)
const {
return input->production_vertex();}
194 template<
typename GenObject_type,
typename dummy>
197 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>
200 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>
203 template<
typename GenObject_type>
204 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.
typename std::conditional< std::is_const< typename T::element_type >::value, ConstGenParticles, GenParticles >::type GenParticles_type
Provides operator to find the parent particles of a Vertex or Particle.
wrap a templated class that implements Relatives Since we need to template the functionality on the i...
Definition of class GenVertex.
Define a common interface that all Relatives objects will satisfy Relatives provides an operator to g...