11 #include "HepMC/GenEvent.h" 12 #include "HepMC/GenVertex.h" 13 #include "HepMC/GenParticle.h" 14 #include "HepMC/Search/FindParticles.h" 15 #include "HepMC/Print.h" 17 using namespace HepMC;
56 v1->add_particle_in (p1);
57 v1->add_particle_out(p2);
64 v2->add_particle_in (p3);
65 v2->add_particle_out(p4);
69 v3->add_particle_in(p2);
70 v3->add_particle_in(p4);
76 v3->add_particle_out(p5);
77 v3->add_particle_out(p6);
80 v4->add_particle_in (p6);
86 v4->add_particle_out(p7);
87 v4->add_particle_out(p8);
94 cout << endl <<
"Find all stable particles: " << endl;
103 cout << endl <<
"Find all ancestors of particle with id " << p5->id() <<
": " << endl;
112 cout << endl <<
"Find stable descendants of particle with id " << p4->id() <<
": " << endl;
113 cout<<
"We check both for STATUS == 1 (equivalent of IS_STABLE) and no end vertex, just to be safe" << endl;
122 cout << endl <<
"Narrow down results of previous search to quarks only: " << endl;
133 shared_ptr<GenPdfInfo> pdf_info = make_shared<GenPdfInfo>();
134 evt.add_attribute(
"GenPdfInfo",pdf_info);
136 pdf_info->set(1,2,3.4,5.6,7.8,9.0,1.2,3,4);
138 shared_ptr<GenHeavyIon> heavy_ion = make_shared<GenHeavyIon>();
139 evt.add_attribute(
"GenHeavyIon",heavy_ion);
141 heavy_ion->set( 1,2,3,4,5,6,7,8,9,0.1,2.3,4.5,6.7);
143 shared_ptr<GenCrossSection> cross_section = make_shared<GenCrossSection>();
144 evt.add_attribute(
"GenCrossSection",cross_section);
146 cross_section->set_cross_section(1.2,3.4);
152 cout << endl <<
" Manipulating attributes:" << endl;
155 shared_ptr<GenCrossSection> cs = evt.attribute<
GenCrossSection>(
"GenCrossSection");
162 else cout <<
"Problem accessing attribute!" << endl;
165 evt.remove_attribute(
"GenCrossSection");
166 evt.remove_attribute(
"GenCrossSection");
171 if(!cs) cout <<
"Successfully removed attribute" << endl;
172 else cout <<
"Problem removing attribute!" << endl;
178 shared_ptr<Attribute> tool1 = make_shared<IntAttribute>(1);
179 shared_ptr<Attribute> tool999 = make_shared<IntAttribute>(999);
180 shared_ptr<Attribute> test_attribute = make_shared<StringAttribute>(
"test attribute");
181 shared_ptr<Attribute> test_attribute2 = make_shared<StringAttribute>(
"test attribute2");
183 p2->add_attribute(
"tool" , tool1 );
184 p2->add_attribute(
"other" , test_attribute );
186 p4->add_attribute(
"tool" , tool1 );
188 p6->add_attribute(
"tool" , tool999 );
189 p6->add_attribute(
"other" , test_attribute2 );
191 v3->add_attribute(
"vtx_att" , test_attribute );
192 v4->add_attribute(
"vtx_att" , test_attribute2 );
194 cout << endl <<
"Find all particles with attribute 'tool' "<< endl;
195 cout <<
"(should return particles 2,4,6):" << endl;
203 cout << endl <<
"Find all particles with attribute 'tool' equal 1 "<< endl;
204 cout <<
"(should return particles 2,4):" << endl;
208 FOREACH(
const GenParticlePtr &p, search_attributes2.results() ) {
212 cout << endl <<
"Find all particles with a string attribute 'other' equal 'test attribute' "<< endl;
213 cout <<
"(should return particle 2):" << endl;
217 FOREACH(
const GenParticlePtr &p, search_attributes3.results() ) {
221 cout << endl <<
"Offsetting event position by 5,5,5,5" << endl;
227 cout << endl <<
"Printing full content of the GenEvent object " << endl
228 <<
"(including particles and vertices in one-line format):" << endl << endl;
232 cout << endl <<
"Now: removing particle with id 6 and printing again:" << endl << endl;
233 evt.remove_particle(p6);
238 cout << endl <<
"Now: removing beam particles, leaving an empty event" << endl << endl;
239 evt.remove_particles( evt.beams() );
Filter for the attributes.
static void listing(const GenEvent &event, unsigned short precision=2)
Print event in listing (HepMC2) format.
Stores additional information about cross-section.
static void line(const GenEvent &event)
Print one-line info.
Smart pointer for HepMC objects.
static const Filter HAS_END_VERTEX
Filter for checking if HepMC::GenParticle::end_vertex() != NULL.
Stores event-related information.
static const Filter IS_STABLE
Filter for checking if particle is stable.
Search engine for GenEvent class.
static const FilterBase PDG_ID
Filter base for filtering GenParticle::pid()
static void content(const GenEvent &event)
Print content of all GenEvent containers.
int main(int argc, char **argv)
Definition of template class SmartPointer.
static const FilterBase STATUS
Filter base for filtering GenParticle::status()
void set_cross_section(double xs, double xs_err, long n_acc=-1, long n_att=-1)
Set all fields.