14 std::shared_ptr<GenRunInfo> run = std::make_shared<GenRunInfo>();
16 GenParticlePtr b1 = std::make_shared<GenParticle>(
FourVector( 0.0, 0.0, 7000.0, 7000.0 ),2212, 3 );
17 GenParticlePtr b2 = std::make_shared<GenParticle>(
FourVector( 0.750, -1.569, 32.191, 32.238), 1, 3 );
18 GenParticlePtr b3 = std::make_shared<GenParticle>(
FourVector( 0.750, -1.569, 32.191, 32.238), 1, 3 );
19 GenVertexPtr v1 = std::make_shared<GenVertex>();
20 v1->add_particle_in (b1);
21 v1->add_particle_in(b2);
22 v1->add_particle_out(b3);
24 for (
size_t z= 0; z < 12; z++) {
26 for (
auto p: particles) {
27 if (p->end_vertex())
continue;
28 GenParticlePtr p1 = std::make_shared<GenParticle>(
FourVector( 0.0, 0.0, 7000.0, 7000.0 ),2212, 3 );
29 GenParticlePtr p2 = std::make_shared<GenParticle>(
FourVector( 0.750, -1.569, 32.191, 32.238), 1, 3 );
30 GenVertexPtr v = std::make_shared<GenVertex>();
31 v->add_particle_in (p);
32 v->add_particle_out(p1);
33 v->add_particle_out(p2);
35 v->add_attribute(
"barcode",std::make_shared<HepMC3::IntAttribute>(-20));
36 p1->add_attribute(
"phi",std::make_shared<HepMC3::DoubleAttribute>(0.1));
37 p1->add_attribute(
"theta",std::make_shared<HepMC3::DoubleAttribute>(0.1));
38 p1->add_attribute(
"barcode",std::make_shared<HepMC3::IntAttribute>(10));
39 p2->add_attribute(
"phi",std::make_shared<HepMC3::DoubleAttribute>(0.1));
40 p2->add_attribute(
"theta",std::make_shared<HepMC3::DoubleAttribute>(0.1));
41 p2->add_attribute(
"barcode",std::make_shared<HepMC3::IntAttribute>(10));
53 std::shared_ptr<GenRunInfo> run = std::make_shared<GenRunInfo>();
55 GenParticlePtr b1 = std::make_shared<GenParticle>(
FourVector( 0.0, 0.0, 7000.0, 7000.0 ),2212, 3 );
56 GenParticlePtr b2 = std::make_shared<GenParticle>(
FourVector( 0.750, -1.569, 32.191, 32.238), 1, 3 );
57 GenParticlePtr b3 = std::make_shared<GenParticle>(
FourVector( 0.750, -1.569, 32.191, 32.238), 1, 3 );
58 GenVertexPtr v1 = std::make_shared<GenVertex>();
59 v1->add_particle_in (b1);
60 v1->add_particle_in(b2);
61 v1->add_particle_out(b3);
63 std::vector<std::string> names;
65 std::vector<std::shared_ptr<Attribute> > atts;
69 for (
size_t z= 0; z < 12; z++) {
71 for (
auto p: particles) {
72 if (p->end_vertex())
continue;
73 GenParticlePtr p1 = std::make_shared<GenParticle>(
FourVector( 0.0, 0.0, 7000.0, 7000.0 ),2212, 3 );
74 GenParticlePtr p2 = std::make_shared<GenParticle>(
FourVector( 0.750, -1.569, 32.191, 32.238), 1, 3 );
75 GenVertexPtr v = std::make_shared<GenVertex>();
76 v->add_particle_in (p);
77 v->add_particle_out(p1);
78 v->add_particle_out(p2);
80 names.push_back(
"barcode");
81 names.push_back(
"barcode");
82 names.push_back(
"phi");
83 names.push_back(
"theta");
84 names.push_back(
"barcode");
85 names.push_back(
"phi");
86 names.push_back(
"theta");
87 atts.push_back(std::make_shared<HepMC3::IntAttribute>(-20));
88 atts.push_back(std::make_shared<HepMC3::DoubleAttribute>(0.1));
89 atts.push_back(std::make_shared<HepMC3::DoubleAttribute>(0.1));
90 atts.push_back(std::make_shared<HepMC3::IntAttribute>(10));
91 atts.push_back(std::make_shared<HepMC3::DoubleAttribute>(0.1));
92 atts.push_back(std::make_shared<HepMC3::DoubleAttribute>(0.1));
93 atts.push_back(std::make_shared<HepMC3::IntAttribute>(10));
94 ids.push_back(v->id());
95 ids.push_back(p1->id());
96 ids.push_back(p1->id());
97 ids.push_back(p1->id());
98 ids.push_back(p2->id());
99 ids.push_back(p2->id());
100 ids.push_back(p2->id());
109 std::shared_ptr<GenRunInfo> run = std::make_shared<GenRunInfo>();
111 GenParticlePtr b1 = std::make_shared<GenParticle>(
FourVector( 0.0, 0.0, 7000.0, 7000.0 ),2212, 3 );
112 GenParticlePtr b2 = std::make_shared<GenParticle>(
FourVector( 0.750, -1.569, 32.191, 32.238), 1, 3 );
113 GenParticlePtr b3 = std::make_shared<GenParticle>(
FourVector( 0.750, -1.569, 32.191, 32.238), 1, 3 );
114 GenVertexPtr v1 = std::make_shared<GenVertex>();
115 v1->add_particle_in (b1);
116 v1->add_particle_in(b2);
117 v1->add_particle_out(b3);
119 std::vector<std::shared_ptr<Attribute> > attsb;
120 attsb.reserve(2048*2);
121 std::vector<int> idsb;
122 idsb.reserve(2048*2);
123 std::vector<std::shared_ptr<Attribute> > attsp;
125 std::vector<int> idsp;
127 std::vector<std::shared_ptr<Attribute> > attst;
129 std::vector<int> idst;
132 for (
size_t z= 0; z < 12; z++) {
134 for (
auto p: particles) {
135 if (p->end_vertex())
continue;
136 GenParticlePtr p1 = std::make_shared<GenParticle>(
FourVector( 0.0, 0.0, 7000.0, 7000.0 ),2212, 3 );
137 GenParticlePtr p2 = std::make_shared<GenParticle>(
FourVector( 0.750, -1.569, 32.191, 32.238), 1, 3 );
138 GenVertexPtr v = std::make_shared<GenVertex>();
139 v->add_particle_in (p);
140 v->add_particle_out(p1);
141 v->add_particle_out(p2);
143 attsb.push_back(std::make_shared<HepMC3::IntAttribute>(-20));
144 attst.push_back(std::make_shared<HepMC3::DoubleAttribute>(0.1));
145 attsp.push_back(std::make_shared<HepMC3::DoubleAttribute>(0.1));
146 attsb.push_back(std::make_shared<HepMC3::IntAttribute>(10));
147 attst.push_back(std::make_shared<HepMC3::DoubleAttribute>(0.1));
148 attsp.push_back(std::make_shared<HepMC3::DoubleAttribute>(0.1));
149 attsb.push_back(std::make_shared<HepMC3::IntAttribute>(10));
150 idsb.push_back(v->id());
151 idsb.push_back(p1->id());
152 idsp.push_back(p1->id());
153 idst.push_back(p1->id());
154 idsb.push_back(p2->id());
155 idsp.push_back(p2->id());
156 idst.push_back(p2->id());
167 std::shared_ptr<GenRunInfo> run = std::make_shared<GenRunInfo>();
169 GenParticlePtr b1 = std::make_shared<GenParticle>(
FourVector( 0.0, 0.0, 7000.0, 7000.0 ),2212, 3 );
170 GenParticlePtr b2 = std::make_shared<GenParticle>(
FourVector( 0.750, -1.569, 32.191, 32.238), 1, 3 );
171 GenParticlePtr b3 = std::make_shared<GenParticle>(
FourVector( 0.750, -1.569, 32.191, 32.238), 1, 3 );
172 GenVertexPtr v1 = std::make_shared<GenVertex>();
173 v1->add_particle_in (b1);
174 v1->add_particle_in(b2);
175 v1->add_particle_out(b3);
177 std::vector<std::pair<int,std::shared_ptr<Attribute> > > attsb;
178 std::vector<std::pair<int,std::shared_ptr<Attribute> > > attsp;
179 std::vector<std::pair<int,std::shared_ptr<Attribute> > > attst;
180 attsb.reserve(2048*2);
184 for (
size_t z= 0; z < 12; z++) {
186 for (
auto p: particles) {
187 if (p->end_vertex())
continue;
188 GenParticlePtr p1 = std::make_shared<GenParticle>(
FourVector( 0.0, 0.0, 7000.0, 7000.0 ),2212, 3 );
189 GenParticlePtr p2 = std::make_shared<GenParticle>(
FourVector( 0.750, -1.569, 32.191, 32.238), 1, 3 );
190 GenVertexPtr v = std::make_shared<GenVertex>();
191 v->add_particle_in (p);
192 v->add_particle_out(p1);
193 v->add_particle_out(p2);
195 attsb.push_back(std::pair<
int,std::shared_ptr<Attribute> > (v->id(), std::make_shared<HepMC3::IntAttribute>(-20)));
196 attst.push_back(std::pair<
int,std::shared_ptr<Attribute> > (p1->id(), std::make_shared<HepMC3::DoubleAttribute>(0.1)));
197 attsp.push_back(std::pair<
int,std::shared_ptr<Attribute> > (p1->id(),std::make_shared<HepMC3::DoubleAttribute>(0.1)));
198 attsb.push_back(std::pair<
int,std::shared_ptr<Attribute> > (p1->id(),std::make_shared<HepMC3::IntAttribute>(10)));
199 attst.push_back(std::pair<
int,std::shared_ptr<Attribute> > (p2->id(),std::make_shared<HepMC3::DoubleAttribute>(0.1)));
200 attsp.push_back(std::pair<
int,std::shared_ptr<Attribute> > (p2->id(),std::make_shared<HepMC3::DoubleAttribute>(0.1)));
201 attsb.push_back(std::pair<
int,std::shared_ptr<Attribute> > (p2->id(),std::make_shared<HepMC3::IntAttribute>(10)));
210typedef std::chrono::high_resolution_clock Clock;
214 auto rawstart1= Clock::now();
215 for (
int i = 0; i < N; i++) generate1();
216 auto now1 = Clock::now();
219 auto rawstart2 = Clock::now();
221 for (
int i = 0; i < N; i++) generate2();
222 auto now2 = Clock::now();
225 auto rawstart3 = Clock::now();
227 for (
int i = 0; i < N; i++) generate3();
228 auto now3 = Clock::now();
231 auto rawstart4 = Clock::now();
233 for (
int i = 0; i < N; i++) generate4();
234 auto now4 = Clock::now();
237 std::cout<< std::chrono::duration_cast<std::chrono::nanoseconds>(now1-rawstart1).count() <<
" "
238 << std::chrono::duration_cast<std::chrono::nanoseconds>(now2-rawstart2).count() <<
" "
239 << std::chrono::duration_cast<std::chrono::nanoseconds>(now3-rawstart3).count() <<
" "
240 << std::chrono::duration_cast<std::chrono::nanoseconds>(now4-rawstart4).count() <<
Definition of class GenEvent.
Definition of class GenParticle.
Definition of class GenVertex.
Stores event-related information.
void add_vertex(GenVertexPtr v)
Add vertex.
void set_run_info(std::shared_ptr< GenRunInfo > run)
Set the GenRunInfo object by smart pointer.
void add_attributes(const std::vector< std::string > &names, const std::vector< std::shared_ptr< Attribute > > &atts, const std::vector< int > &ids)
Add multiple attributes to event.
const std::vector< ConstGenParticlePtr > & particles() const
Get list of particles (const)