/usr/share/HepMC/examples/example_BuildEventFromScratch.cc is in hepmc-examples 2.06.09-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | //////////////////////////////////////////////////////////////////////////
// Matt.Dobbs@Cern.CH, Feb 2000
// Example of building an event and a particle data table from scratch
// This is meant to be of use for persons implementing HepMC inside a MC
// event generator
//////////////////////////////////////////////////////////////////////////
// To Compile: go to the HepMC directory and type:
// gmake examples/example_BuildEventFromScratch.exe
//
#include <iostream>
#include "HepMC/GenEvent.h"
// in this example we use the HepMC namespace, so that we do not have to
// precede all HepMC classes with HepMC::
// This example also shows how to use the CLHEP Lorentz vector with HepMC2
using namespace HepMC;
int main() {
//
// In this example we will place the following event into HepMC "by hand"
//
// name status pdg_id parent Px Py Pz Energy Mass
// 1 !p+! 3 2212 0,0 0.000 0.000 7000.000 7000.000 0.938
// 2 !p+! 3 2212 0,0 0.000 0.000-7000.000 7000.000 0.938
//=========================================================================
// 3 !d! 3 1 1,1 0.750 -1.569 32.191 32.238 0.000
// 4 !u~! 3 -2 2,2 -3.047 -19.000 -54.629 57.920 0.000
// 5 !W-! 3 -24 1,2 1.517 -20.68 -20.605 85.925 80.799
// 6 !gamma! 1 22 1,2 -3.813 0.113 -1.833 4.233 0.000
// 7 !d! 1 1 5,5 -2.445 28.816 6.082 29.552 0.010
// 8 !u~! 1 -2 5,5 3.962 -49.498 -26.687 56.373 0.006
// now we build the graph, which will look like
// p7 #
// p1 / #
// \v1__p3 p5---v4 #
// \_v3_/ \ #
// / \ p8 #
// v2__p4 \ #
// / p6 #
// p2 #
// #
// First create the event container, with Signal Process 20, event number 1
//
GenEvent* evt = new GenEvent( 20, 1 );
// define the units
evt->use_units(HepMC::Units::GEV, HepMC::Units::MM);
//
// create vertex 1 and vertex 2, together with their inparticles
GenVertex* v1 = new GenVertex();
evt->add_vertex( v1 );
v1->add_particle_in( new GenParticle( FourVector(0,0,7000,7000),
2212, 3 ) );
GenVertex* v2 = new GenVertex();
evt->add_vertex( v2 );
v2->add_particle_in( new GenParticle( FourVector(0,0,-7000,7000),
2212, 3 ) );
//
// create the outgoing particles of v1 and v2
GenParticle* p3 =
new GenParticle( FourVector(.750,-1.569,32.191,32.238), 1, 3 );
v1->add_particle_out( p3 );
GenParticle* p4 =
new GenParticle( FourVector(-3.047,-19.,-54.629,57.920), -2, 3 );
v2->add_particle_out( p4 );
//
// create v3
GenVertex* v3 = new GenVertex();
evt->add_vertex( v3 );
v3->add_particle_in( p3 );
v3->add_particle_in( p4 );
v3->add_particle_out(
new GenParticle( FourVector(-3.813,0.113,-1.833,4.233 ), 22, 1 )
);
GenParticle* p5 =
new GenParticle( FourVector(1.517,-20.68,-20.605,85.925), -24,3);
v3->add_particle_out( p5 );
//
// create v4
GenVertex* v4 = new GenVertex(FourVector(0.12,-0.3,0.05,0.004));
evt->add_vertex( v4 );
v4->add_particle_in( p5 );
v4->add_particle_out(
new GenParticle( FourVector(-2.445,28.816,6.082,29.552), 1,1 )
);
v4->add_particle_out(
new GenParticle( FourVector(3.962,-49.498,-26.687,56.373), -2,1 )
);
//
// tell the event which vertex is the signal process vertex
evt->set_signal_process_vertex( v3 );
// the event is complete, we now print it out to the screen
evt->print();
// now clean-up by deleteing all objects from memory
//
// deleting the event deletes all contained vertices, and all particles
// contained in those vertices
delete evt;
return 0;
}
|