20 #define M_PI 3.14159265358979323846264338327950288
22 #include "HepMC3TestUtils.h"
23 using namespace HepMC3;
64 evt.set_event_number(1);
65 evt.add_attribute(
"signal_process_id", std::make_shared<IntAttribute>(20));
67 GenVertexPtr v1=std::make_shared<GenVertex>();
69 GenParticlePtr p1=std::make_shared<GenParticle>(
FourVector(0,0,7000,7000),2212, 3 );
70 evt.add_particle( p1 );
71 p1->add_attribute(
"flow1", std::make_shared<IntAttribute>(231));
72 p1->add_attribute(
"flow1", std::make_shared<IntAttribute>(231));
73 p1->add_attribute(
"theta", std::make_shared<DoubleAttribute>(std::rand()/
double(RAND_MAX)*
M_PI));
74 p1->add_attribute(
"phi", std::make_shared<DoubleAttribute>(std::rand()/
double(RAND_MAX)*M_PI*2));
76 GenVertexPtr v2=std::make_shared<GenVertex>();
78 GenParticlePtr p2=std::make_shared<GenParticle>(
FourVector(0,0,-7000,7000),2212, 3 );
79 evt.add_particle( p2 );
80 p2->add_attribute(
"flow1", std::make_shared<IntAttribute>(243));
81 p2->add_attribute(
"theta", std::make_shared<DoubleAttribute>(std::rand()/
double(RAND_MAX)*M_PI));
82 p2->add_attribute(
"phi", std::make_shared<DoubleAttribute>(std::rand()/
double(RAND_MAX)*M_PI*2));
83 v2->add_particle_in( p2 );
86 GenParticlePtr p3=std::make_shared<GenParticle>(
FourVector(.750,-1.569,32.191,32.238),1, 3 );
87 evt.add_particle( p3 );
88 p3->add_attribute(
"flow1", std::make_shared<IntAttribute>(231));
89 p3->add_attribute(
"theta", std::make_shared<DoubleAttribute>(std::rand()/
double(RAND_MAX)*M_PI));
90 p3->add_attribute(
"phi", std::make_shared<DoubleAttribute>(std::rand()/
double(RAND_MAX)*M_PI*2));
91 v1->add_particle_out( p3 );
92 GenParticlePtr p4=std::make_shared<GenParticle>(
FourVector(-3.047,-19.,-54.629,57.920),-2, 3 );
93 evt.add_particle( p4 );
94 p4->add_attribute(
"flow1", std::make_shared<IntAttribute>(243));
95 p4->add_attribute(
"theta", std::make_shared<DoubleAttribute>(std::rand()/
double(RAND_MAX)*M_PI));
96 p4->add_attribute(
"phi", std::make_shared<DoubleAttribute>(std::rand()/
double(RAND_MAX)*M_PI*2));
97 v2->add_particle_out( p4 );
100 GenVertexPtr v3=std::make_shared<GenVertex>();
101 evt.add_vertex( v3 );
102 v3->add_particle_in( p3 );
103 v3->add_particle_in( p4 );
104 GenParticlePtr p6=std::make_shared<GenParticle>(
FourVector(-3.813,0.113,-1.833,4.233 ),22, 1 );
105 evt.add_particle( p6 );
106 p6->add_attribute(
"flow1", std::make_shared<IntAttribute>(231));
107 p6->add_attribute(
"theta", std::make_shared<DoubleAttribute>(std::rand()/
double(RAND_MAX)*M_PI));
108 p6->add_attribute(
"phi", std::make_shared<DoubleAttribute>(std::rand()/
double(RAND_MAX)*M_PI*2));
109 v3->add_particle_out( p6 );
110 GenParticlePtr p5=std::make_shared<GenParticle>(
FourVector(1.517,-20.68,-20.605,85.925),-24, 3 );
111 evt.add_particle( p5 );
112 p5->add_attribute(
"flow1", std::make_shared<IntAttribute>(243));
113 p5->add_attribute(
"theta", std::make_shared<DoubleAttribute>(std::rand()/
double(RAND_MAX)*M_PI));
114 p5->add_attribute(
"phi", std::make_shared<DoubleAttribute>(std::rand()/
double(RAND_MAX)*M_PI*2));
115 v3->add_particle_out( p5 );
118 GenVertexPtr v4=std::make_shared<GenVertex>(
FourVector(0.12,-0.3,0.05,0.004));
119 evt.add_vertex( v4 );
120 v4->add_particle_in( p5 );
122 evt.add_particle( p7 );
123 v4->add_particle_out( p7 );
125 evt.add_particle( p8 );
126 v4->add_particle_out( p8 );
129 GenParticlePtr pl=std::make_shared<GenParticle>(
FourVector(0.0,0.0,0.0,0.0 ),21, 3 );
130 evt.add_particle( pl );
131 v3->add_particle_out( pl );
132 v2->add_particle_in( pl );
137 evt.add_attribute(
"signal_process_vertex", std::make_shared<IntAttribute>(v3->id()));
143 for ( ConstGenParticlePtr ip: evt.particles()) {
148 xout1.write_event(evt);
150 xout2.write_event(evt);
165 while( !xin1.failed() )
167 xin1.read_event(evt);
168 if( xin1.failed() ) {
169 printf(
"End of file reached. Exit.\n");
181 while( !xin2.failed() )
183 xin2.read_event(evt);
184 if( xin2.failed() ) {
185 printf(
"End of file reached. Exit.\n");
GenEvent I/O serialization for structured text files.
GenEvent I/O parsing for structured text files.
Definition of class GenParticle.
#define M_PI
Definition of PI. Needed on some platforms.
Definition of class GenVertex.
Definition of class WriterAscii.
Stores particle-related information.
static void listing(std::ostream &os, const GenEvent &event, unsigned short precision=2)
Print event in listing (HepMC2) format.
Parser for HepMC2 I/O files.
Definition of class ReaderAsciiHepMC2.
Stores event-related information.
Definition of class ReaderAscii.
static void line(std::ostream &os, const GenEvent &event, bool attributes=false)
Print one-line info.
Definition of class WriterAsciiHepMC2.
Definition of static class Print.
int main(int argc, char **argv)
Definition of class GenEvent.
Definition of class Attribute, class IntAttribute and class StringAttribute.
GenEvent I/O serialization for structured text files.
static void content(std::ostream &os, const GenEvent &event)
Print content of all GenEvent containers.