GenParticlePtr p1 = make_shared<GenParticle>(
FourVector( 0.0, 0.0, 7000.0, 7000.0 ),2212, 3 );
GenParticlePtr p2 = make_shared<GenParticle>(
FourVector( 0.750, -1.569, 32.191, 32.238), 1, 3 );
GenParticlePtr p3 = make_shared<GenParticle>(
FourVector( 0.0, 0.0, -7000.0, 7000.0 ),2212, 3 );
GenParticlePtr p4 = make_shared<GenParticle>(
FourVector(-3.047,-19.0, -54.629, 57.920), -2, 3 );
GenVertexPtr v1 = make_shared<GenVertex>();
v1->add_particle_in (p1);
v1->add_particle_out(p2);
v1->set_status(4);
GenVertexPtr v2 = make_shared<GenVertex>();
v2->add_particle_in (p3);
v2->add_particle_out(p4);
GenVertexPtr v3 = make_shared<GenVertex>();
v3->add_particle_in(p2);
v3->add_particle_in(p4);
GenParticlePtr p5 = make_shared<GenParticle>(
FourVector(-3.813, 0.113, -1.833, 4.233), 22, 1 );
GenParticlePtr p6 = make_shared<GenParticle>(
FourVector( 1.517,-20.68, -20.605,85.925), -24, 3 );
v3->add_particle_out(p5);
v3->add_particle_out(p6);
GenVertexPtr v4 = make_shared<GenVertex>();
v4->add_particle_in (p6);
GenParticlePtr p7 = make_shared<GenParticle>(
FourVector(-2.445, 28.816, 6.082,29.552), 1, 1 );
GenParticlePtr p8 = make_shared<GenParticle>(
FourVector( 3.962,-49.498,-26.687,56.373), -2, 1 );
v4->add_particle_out(p7);
v4->add_particle_out(p8);
std::cout << std::endl << "Find all stable particles: " << std::endl;
Print::line(p);
}
std::cout <<std::endl << "Find all ancestors of particle with id " << p5->id() << ": " << std::endl;
for(ConstGenParticlePtr p: Relatives::ANCESTORS(p5)){
Print::line(p);
}
std::cout <<std::endl << "Find stable descendants of particle with id " << p4->id() << ": " << std::endl;
std::cout<<"We check both for STATUS == 1 (equivalent of IS_STABLE) and no end vertex, just to be safe" << std::endl;
Filter has_end_vtx = [](ConstGenParticlePtr input)->
bool{
return (
bool)input->end_vertex();};
vector<GenParticlePtr> results3 =
applyFilter(Selector::STATUS==1 && has_end_vtx, Relatives::DESCENDANTS(p4));
for(ConstGenParticlePtr p: results3){
Print::line(p);
}
std::cout << std::endl << "Narrow down results of previous search to quarks only: " << std::endl;
for(ConstGenParticlePtr p:
applyFilter( *
abs(Selector::PDG_ID) <= 6, results3)){
Print::line(p);
}
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);
std::cout << std::endl << " Manipulating attributes:" << std::endl;
if(cs) {
Print::line(cs);
}
else std::cout << "Problem accessing attribute!" <<std::endl;
if(!cs)std::cout << "Successfully removed attribute" <<std::endl;
else std::cout << "Problem removing attribute!" <<std::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 );
std::cout << std::endl << "Find all particles with attribute 'tool' "<< std::endl;
std::cout << "(should return particles 2,4,6):" << std::endl;
Print::line(p);
}
std::cout <<std::endl << "Find all particles with attribute 'tool' equal 1 "<< std::endl;
std::cout << "(should return particles 2,4):" <<std::endl;
for(ConstGenParticlePtr p:
applyFilter(Selector::ATTRIBUTE(
"tool") && Selector::ATTRIBUTE(
"tool") == tool1, evt.
particles())){
Print::line(p);
}
std::cout << std::endl << "Find all particles with a string attribute 'other' equal 'test attribute' "<< std::endl;
std::cout << "(should return particle 2):" << std::endl;
for(ConstGenParticlePtr p:
applyFilter(Selector::ATTRIBUTE(
"other") && Selector::ATTRIBUTE(
"other") ==
"test_attribute", evt.
particles())){
Print::line(p);
}
std::cout << std::endl << "Offsetting event position by 5,5,5,5" << std::endl;
Print::listing(evt);
std::cout << std::endl << "Printing full content of the GenEvent object " << std::endl
<< "(including particles and vertices in one-line format):" << std::endl << std::endl;
Print::content(evt);
std::cout <<std::endl << "Now: removing particle with id 6 and printing again:" <<std::endl <<std::endl;
Print::listing(evt);
Print::content(evt);
std::cout <<std::endl << "Now: removing beam particles, leaving an empty event" <<std::endl <<std::endl;
Print::listing(evt);
Print::content(evt);
return 0;
}
Definition of class GenEvent.
Definition of class GenParticle.
Definition of class GenVertex.
Definition of static class Print.
Defines helper classes to extract relatives of an input GenParticle or GenVertex.
definition of /b Selector class
Stores additional information about cross-section.
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.
void add_vertex(GenVertexPtr v)
Add vertex.
void remove_attribute(const string &name, const int &id=0)
Remove attribute.
void remove_particle(GenParticlePtr v)
Remove particle from the event.
void remove_particles(std::vector< GenParticlePtr > v)
Remove a set of particles.
std::vector< ConstGenParticlePtr > beams() const
Vector of beam particles.
void shift_position_by(const FourVector &delta)
Shift position of all vertices in the event by delta.
void add_attribute(const string &name, const shared_ptr< Attribute > &att, const int &id=0)
Add event attribute to event.
shared_ptr< T > attribute(const string &name, const int &id=0) const
Get attribute of type T.
const std::vector< ConstGenParticlePtr > & particles() const
Get list of particles (const)
vector< GenParticlePtr > applyFilter(const Filter &filter, const vector< GenParticlePtr > &particles)
Apply a Filter to a list of GenParticles Returns a vector of GenParticles that satisfy the Filter.
std::function< bool(ConstGenParticlePtr)> Filter
type of Filter
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,...
int main(int argc, char **argv)