17 using namespace HepMC3;
49 GenParticlePtr p1 = std::make_shared<GenParticle>(
FourVector( 0.0, 0.0, 7000.0, 7000.0 ),2212, 3 );
50 GenParticlePtr p2 = std::make_shared<GenParticle>(
FourVector( 0.750, -1.569, 32.191, 32.238), 1, 3 );
51 GenParticlePtr p3 = std::make_shared<GenParticle>(
FourVector( 0.0, 0.0, -7000.0, 7000.0 ),2212, 3 );
52 GenParticlePtr p4 = std::make_shared<GenParticle>(
FourVector(-3.047,-19.0, -54.629, 57.920), -2, 3 );
54 GenVertexPtr v1 = std::make_shared<GenVertex>();
55 v1->add_particle_in (p1);
56 v1->add_particle_out(p2);
62 GenVertexPtr v2 = std::make_shared<GenVertex>();
63 v2->add_particle_in (p3);
64 v2->add_particle_out(p4);
67 GenVertexPtr v3 = std::make_shared<GenVertex>();
68 v3->add_particle_in(p2);
69 v3->add_particle_in(p4);
72 GenParticlePtr p5 = std::make_shared<GenParticle>(
FourVector(-3.813, 0.113, -1.833, 4.233), 22, 1 );
73 GenParticlePtr p6 = std::make_shared<GenParticle>(
FourVector( 1.517,-20.68, -20.605,85.925), -24, 3 );
75 v3->add_particle_out(p5);
76 v3->add_particle_out(p6);
78 GenVertexPtr v4 =std:: make_shared<GenVertex>();
79 v4->add_particle_in (p6);
82 GenParticlePtr p7 = std::make_shared<GenParticle>(
FourVector(-2.445, 28.816, 6.082,29.552), 1, 1 );
83 GenParticlePtr p8 = std::make_shared<GenParticle>(
FourVector( 3.962,-49.498,-26.687,56.373), -2, 1 );
85 v4->add_particle_out(p7);
86 v4->add_particle_out(p8);
91 std::shared_ptr<GenPdfInfo> pdf_info = std::make_shared<GenPdfInfo>();
92 evt.add_attribute(
"GenPdfInfo",pdf_info);
94 pdf_info->set(1,2,3.4,5.6,7.8,9.0,1.2,3,4);
96 std::shared_ptr<GenHeavyIon> heavy_ion = std::make_shared<GenHeavyIon>();
97 evt.add_attribute(
"GenHeavyIon",heavy_ion);
99 heavy_ion->set( 1,2,3,4,5,6,7,8,9,0.1,2.3,4.5,6.7);
101 std::shared_ptr<GenCrossSection> cross_section = std::make_shared<GenCrossSection>();
102 evt.add_attribute(
"GenCrossSection",cross_section);
104 cross_section->set_cross_section(1.2,3.4);
110 std::cout << std::endl <<
" Manipulating attributes:" << std::endl;
113 std::shared_ptr<GenCrossSection> cs = evt.attribute<
GenCrossSection>(
"GenCrossSection");
120 else std::cout <<
"Problem accessing attribute!" <<std::endl;
123 evt.remove_attribute(
"GenCrossSection");
124 evt.remove_attribute(
"GenCrossSection");
129 if(!cs)std::cout <<
"Successfully removed attribute" <<std::endl;
130 else std::cout <<
"Problem removing attribute!" <<std::endl;
136 std::shared_ptr<Attribute> tool1 = std::make_shared<IntAttribute>(1);
137 std::shared_ptr<Attribute> tool999 = std::make_shared<IntAttribute>(999);
138 std::shared_ptr<Attribute> test_attribute = std::make_shared<StringAttribute>(
"test attribute");
139 std::shared_ptr<Attribute> test_attribute2 = std::make_shared<StringAttribute>(
"test attribute2");
141 p2->add_attribute(
"tool" , tool1 );
142 p2->add_attribute(
"other" , test_attribute );
144 p4->add_attribute(
"tool" , tool1 );
146 p6->add_attribute(
"tool" , tool999 );
147 p6->add_attribute(
"other" , test_attribute2 );
149 v3->add_attribute(
"vtx_att" , test_attribute );
150 v4->add_attribute(
"vtx_att" , test_attribute2 );
160 for(ConstGenParticlePtr p: applyFilter(Selector::ATTRIBUTE("tool"), evt.particles())){
164 std::cout <<std::endl << "Find all particles with attribute 'tool' equal 1 "<< std::endl;
165 std::cout << "(should return particles 2,4):" <<std::endl;
167 for(ConstGenParticlePtr p: applyFilter(Selector::ATTRIBUTE("tool") && Selector::ATTRIBUTE("tool") == tool1, evt.particles())){
171 std::cout << std::endl << "Find all particles with a string attribute 'other' equal 'test attribute' "<< std::endl;
172 std::cout << "(should return particle 2):" << std::endl;
175 for(ConstGenParticlePtr p: applyFilter(Selector::ATTRIBUTE("other") && Selector::ATTRIBUTE("other") == "test_attribute", evt.particles())){
180 std::cout << std::endl <<
"Offsetting event position by 5,5,5,5" << std::endl;
186 std::cout << std::endl <<
"Printing full content of the GenEvent object " << std::endl
187 <<
"(including particles and vertices in one-line format):" << std::endl << std::endl;
191 std::cout <<std::endl <<
"Now: removing particle with id 6 and printing again:" <<std::endl <<std::endl;
192 evt.remove_particle(p6);
197 std::cout <<std::endl <<
"Now: removing beam particles, leaving an empty event" <<std::endl <<std::endl;
198 evt.remove_particles( evt.beams() );
definition of /b Selector class
Definition of class GenParticle.
Definition of class GenVertex.
static void listing(std::ostream &os, const GenEvent &event, unsigned short precision=2)
Print event in listing (HepMC2) format.
void set_cross_section(const double &xs, const double &xs_err, const long &n_acc=-1, const long &n_att=-1)
Set all fields.
Stores event-related information.
static void line(std::ostream &os, const GenEvent &event, bool attributes=false)
Print one-line info.
Definition of static class Print.
int main(int argc, char **argv)
Definition of class GenEvent.
Stores additional information about cross-section.
static void content(std::ostream &os, const GenEvent &event)
Print content of all GenEvent containers.