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 v1->add_particle_in( 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 v2->add_particle_in( 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));
85 GenParticlePtr p3=std::make_shared<GenParticle>(
FourVector(.750,-1.569,32.191,32.238),1, 3 );
86 v1->add_particle_out( p3 );
87 p3->add_attribute(
"flow1", std::make_shared<IntAttribute>(231));
88 p3->add_attribute(
"theta", std::make_shared<DoubleAttribute>(std::rand()/
double(RAND_MAX)*M_PI));
89 p3->add_attribute(
"phi", std::make_shared<DoubleAttribute>(std::rand()/
double(RAND_MAX)*M_PI*2));
91 GenParticlePtr p4=std::make_shared<GenParticle>(
FourVector(-3.047,-19.,-54.629,57.920),-2, 3 );
92 v2->add_particle_out( p4 );
93 p4->add_attribute(
"flow1", std::make_shared<IntAttribute>(243));
94 p4->add_attribute(
"theta", std::make_shared<DoubleAttribute>(std::rand()/
double(RAND_MAX)*M_PI));
95 p4->add_attribute(
"phi", std::make_shared<DoubleAttribute>(std::rand()/
double(RAND_MAX)*M_PI*2));
98 GenVertexPtr v3=std::make_shared<GenVertex>();
100 v3->add_particle_in( p3 );
101 v3->add_particle_in( p4 );
102 GenParticlePtr p6=std::make_shared<GenParticle>(
FourVector(-3.813,0.113,-1.833,4.233 ),22, 1 );
103 evt.add_particle( p6 );
104 p6->add_attribute(
"flow1", std::make_shared<IntAttribute>(231));
105 p6->add_attribute(
"theta", std::make_shared<DoubleAttribute>(std::rand()/
double(RAND_MAX)*M_PI));
106 p6->add_attribute(
"phi", std::make_shared<DoubleAttribute>(std::rand()/
double(RAND_MAX)*M_PI*2));
107 v3->add_particle_out( p6 );
108 GenParticlePtr p5=std::make_shared<GenParticle>(
FourVector(1.517,-20.68,-20.605,85.925),-24, 3 );
109 v3->add_particle_out( p5 );
110 p5->add_attribute(
"flow1", std::make_shared<IntAttribute>(243));
111 p5->add_attribute(
"theta", std::make_shared<DoubleAttribute>(std::rand()/
double(RAND_MAX)*M_PI));
112 p5->add_attribute(
"phi", std::make_shared<DoubleAttribute>(std::rand()/
double(RAND_MAX)*M_PI*2));
116 GenVertexPtr v4=std::make_shared<GenVertex>(
FourVector(0.12,-0.3,0.05,0.004));
117 evt.add_vertex( v4 );
118 v4->add_particle_in( p5 );
120 v4->add_particle_out( p7 );
122 v4->add_particle_out( p8 );
125 GenParticlePtr ploop=std::make_shared<GenParticle>(
FourVector(0.0,0.0,0.0,0.0 ),21, 3 );
126 v3->add_particle_out( ploop );
127 v2->add_particle_in( ploop );
132 evt.add_attribute(
"signal_process_vertex", std::make_shared<IntAttribute>(v3->id()));
138 for ( ConstGenParticlePtr ip: evt.particles()) {
143 xout1.write_event(evt);
145 xout2.write_event(evt);
161 while( !xin1.failed() )
163 xin1.read_event(evt);
164 if( xin1.failed() ) {
165 printf(
"End of file reached. Exit.\n");
179 while( !xin2.failed() )
181 xin2.read_event(evt);
182 if( xin2.failed() ) {
183 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.
Feature< Feature_type > abs(const Feature< Feature_type > &input)
Obtain the absolute value of a Feature. This works as you'd expect. If foo is a valid Feature...
static void content(std::ostream &os, const GenEvent &event)
Print content of all GenEvent containers.