15 HepMC3::GenVertexPtr v0=std::make_shared<HepMC3::GenVertex>();
24 if (v->particles_out().size()!=0)
continue;
25 for (
int i=0; i<n; i++) v->add_particle_out(std::make_shared<HepMC3::GenParticle>());
30 for (
auto v: vertices)
32 if (v->particles_out().size()!=0)
continue;
33 for (
int i=0; i<n; i++) v->add_particle_out(std::make_shared<HepMC3::GenParticle>());
34 for (
auto p: v->particles_out())
36 HepMC3::GenVertexPtr vx=std::make_shared<HepMC3::GenVertex>();
37 vx->add_particle_in(p);
48 std::cout<<
"search_example: start"<<std::endl;
49 auto start0 = std::chrono::system_clock::now();
50 for (
int i=0; i<10000; i++)
55 auto end0 = std::chrono::system_clock::now();
56 std::cout<<
"search_example: generation of events "<<std::chrono::duration_cast<std::chrono::milliseconds>(end0 - start0).count()<<
" ms"<<std::endl;
58 auto start1 = std::chrono::system_clock::now();
60 for (
int i=0; i<10000; i++)
66 auto end1 = std::chrono::system_clock::now();
67 std::cout<<
"search_example: generation of events and descendants_of_same_type() "
68 <<std::chrono::duration_cast<std::chrono::milliseconds>(end1 - start1).count()<<
" ms"
69 <<
" total number of decandants: "<<np1<<std::endl;
71 auto start2 = std::chrono::system_clock::now();
73 for (
int i=0; i<10000; i++)
76 for (
auto p: evt->
particles()) np2+=(HepMC3::Relatives::DESCENDANTS(p)).size();
79 auto end2 = std::chrono::system_clock::now();
80 std::cout<<
"search_example: generation of events and Relatives::DESCENDANTS() "
81 <<std::chrono::duration_cast<std::chrono::milliseconds>(end2 - start2).count()<<
" ms"
82 <<
" total number of decandants: "<<np2<<std::endl;
84 auto start3 = std::chrono::system_clock::now();
86 for (
int i=0; i<10000; i++)
92 auto end3 = std::chrono::system_clock::now();
93 std::cout<<
"search_example: generation of events and ancestors_of_same_type() "
94 <<std::chrono::duration_cast<std::chrono::milliseconds>(end3 - start3).count()<<
" ms"
95 <<
" total number of ancestors: "<<np3<<std::endl;
98 auto start4 = std::chrono::system_clock::now();
100 for (
int i=0; i<10000; i++)
103 for (
auto p: evt->
particles()) np4+=(HepMC3::Relatives::ANCESTORS(p)).size();
106 auto end4 = std::chrono::system_clock::now();
107 std::cout<<
"search_example: generation of events and Relatives::ANCESTORS() "
108 <<std::chrono::duration_cast<std::chrono::milliseconds>(end4 - start4).count()<<
" ms"
109 <<
" total number of ancestors: "<<np4<<std::endl;
111 auto start1o = std::chrono::system_clock::now();
113 for (
int i=0; i<10000; i++)
119 auto end1o = std::chrono::system_clock::now();
120 std::cout<<
"search_example: generation of events and descendants_of_other_type() "
121 <<std::chrono::duration_cast<std::chrono::milliseconds>(end1o - start1o).count()<<
" ms"
122 <<
" total number of decandants: "<<np1o<<std::endl;
125 auto start3o = std::chrono::system_clock::now();
127 for (
int i=0; i<10000; i++)
133 auto end3o = std::chrono::system_clock::now();
134 std::cout<<
"search_example: generation of events and ancestors_of_other_type() "
135 <<std::chrono::duration_cast<std::chrono::milliseconds>(end3o - start3o).count()<<
" ms"
136 <<
" total number of decandants: "<<np3o<<std::endl;
138 std::cout<<
"search_example: end"<<std::endl;
const std::vector< ConstGenVertexPtr > & vertices() const
Get list of vertices (const)
void add_vertex(GenVertexPtr v)
Add vertex.
Definition of class GenParticle.
std::vector< HepMC3::ConstGenVertexPtr > ancestor_vertices(HepMC3::ConstGenParticlePtr obj)
Return ancestor vertices.
Definition of class GenVertex.
Stores event-related information.
Defines helper classes to extract relatives of an input GenParticle or GenVertex. ...
std::vector< HepMC3::ConstGenVertexPtr > descendant_vertices(HepMC3::ConstGenParticlePtr obj)
Return descendant vertices.
Definition of static class Print.
std::vector< HepMC3::ConstGenParticlePtr > descendant_particles(HepMC3::ConstGenVertexPtr obj)
Return descendant particles.
int main(int argc, char **argv)
Definition of class GenEvent.
const std::vector< ConstGenParticlePtr > & particles() const
Get list of particles (const)
std::vector< HepMC3::ConstGenParticlePtr > ancestor_particles(HepMC3::ConstGenVertexPtr obj)
Return ancestor particles.