Basic example of building HepMC3 tree by hand Based on HepMC2/examples/example_BuildEventFromScratch.cc
#include "HepMC/GenEvent.h"
#include "HepMC/GenVertex.h"
#include "HepMC/GenParticle.h"
#include "HepMC/Search/FindParticles.h"
#include "HepMC/Print.h"
v1->add_particle_in (p1);
v1->add_particle_out(p2);
v1->set_status(4);
v2->add_particle_in (p3);
v2->add_particle_out(p4);
v3->add_particle_in(p2);
v3->add_particle_in(p4);
v3->add_particle_out(p5);
v3->add_particle_out(p6);
v4->add_particle_in (p6);
v4->add_particle_out(p7);
v4->add_particle_out(p8);
cout << endl << "Find all stable particles: " << endl;
}
cout << endl << "Find all ancestors of particle with id " << p5->id() << ": " << endl;
}
cout << endl << "Find stable descendants of particle with id " << p4->id() << ": " << endl;
cout<<"We check both for STATUS == 1 (equivalent of IS_STABLE) and no end vertex, just to be safe" << endl;
}
cout << endl << "Narrow down results of previous search to quarks only: " << endl;
}
shared_ptr<GenPdfInfo> pdf_info = make_shared<GenPdfInfo>();
pdf_info->set(1,2,3.4,5.6,7.8,9.0,1.2,3,4);
shared_ptr<GenHeavyIon> heavy_ion = make_shared<GenHeavyIon>();
heavy_ion->set( 1,2,3,4,5,6,7,8,9,0.1,2.3,4.5,6.7);
shared_ptr<GenCrossSection> cross_section = make_shared<GenCrossSection>();
cross_section->set_cross_section(1.2,3.4);
cout << endl << " Manipulating attributes:" << endl;
if(cs) {
}
else cout << "Problem accessing attribute!" << endl;
if(!cs) cout << "Successfully removed attribute" << endl;
else cout << "Problem removing attribute!" << endl;
shared_ptr<Attribute> tool1 = make_shared<IntAttribute>(1);
shared_ptr<Attribute> tool999 = make_shared<IntAttribute>(999);
shared_ptr<Attribute> test_attribute = make_shared<StringAttribute>("test attribute");
shared_ptr<Attribute> test_attribute2 = make_shared<StringAttribute>("test attribute2");
p2->add_attribute( "tool" , tool1 );
p2->add_attribute( "other" , test_attribute );
p4->add_attribute( "tool" , tool1 );
p6->add_attribute( "tool" , tool999 );
p6->add_attribute( "other" , test_attribute2 );
v3->add_attribute( "vtx_att" , test_attribute );
v4->add_attribute( "vtx_att" , test_attribute2 );
cout << endl << "Find all particles with attribute 'tool' "<< endl;
cout << "(should return particles 2,4,6):" << endl;
}
cout << endl << "Find all particles with attribute 'tool' equal 1 "<< endl;
cout << "(should return particles 2,4):" << endl;
}
cout << endl << "Find all particles with a string attribute 'other' equal 'test attribute' "<< endl;
cout << "(should return particle 2):" << endl;
}
cout << endl << "Offsetting event position by 5,5,5,5" << endl;
cout << endl << "Printing full content of the GenEvent object " << endl
<< "(including particles and vertices in one-line format):" << endl << endl;
cout << endl << "Now: removing particle with id 6 and printing again:" << endl << endl;
cout << endl << "Now: removing beam particles, leaving an empty event" << endl << endl;
return 0;
}