hepmc - Diff between revs 100 and 179
Subversion Repositories:
| Rev 100 | Rev 179 | |||
|---|---|---|---|---|
| Line 40... | Line 40... | |||
| 40 | } | 40 | } | |
| 41 | }; | 41 | }; | |
| 42 | 42 | |||
| 43 | //! example class | 43 | //! example class | |
| 44 | 44 | |||
| 45 | /// \class IsFinalState | - | ||
| - | 45 | /// \class IsStateFinal | ||
| 46 | /// this predicate returns true if the input has no decay vertex | 46 | /// this predicate returns true if the input has no decay vertex | |
| 47 | class IsFinalState { | - | ||
| - | 47 | class IsStateFinal { | ||
| 48 | public: | 48 | public: | |
| 49 | /// returns true if the GenParticle does not decay | 49 | /// returns true if the GenParticle does not decay | |
| 50 | bool operator()( const HepMC::GenParticle* p ) { | 50 | bool operator()( const HepMC::GenParticle* p ) { | |
| 51 | if ( !p->end_vertex() && p->status()==1 ) return 1; | 51 | if ( !p->end_vertex() && p->status()==1 ) return 1; | |
| 52 | return 0; | 52 | return 0; | |
| Line 81... | Line 81... | |||
| 81 | std::list<HepMC::GenVertex*> allvertices2; | 81 | std::list<HepMC::GenVertex*> allvertices2; | |
| 82 | copy( evt->vertices_begin(), evt->vertices_end(), | 82 | copy( evt->vertices_begin(), evt->vertices_end(), | |
| 83 | back_inserter(allvertices2) ); | 83 | back_inserter(allvertices2) ); | |
| 84 | 84 | |||
| 85 | // fill a list of all final state particles in the event, by requiring | 85 | // fill a list of all final state particles in the event, by requiring | |
| 86 | // that each particle satisfyies the IsFinalState predicate | - | ||
| 87 | IsFinalState isfinal; | - | ||
| - | 86 | // that each particle satisfyies the IsStateFinal predicate | ||
| - | 87 | IsStateFinal isfinal; | ||
| 88 | std::list<HepMC::GenParticle*> finalstateparticles; | 88 | std::list<HepMC::GenParticle*> finalstateparticles; | |
| 89 | for ( HepMC::GenEvent::particle_iterator p = evt->particles_begin(); | 89 | for ( HepMC::GenEvent::particle_iterator p = evt->particles_begin(); | |
| 90 | p != evt->particles_end(); ++p ) { | 90 | p != evt->particles_end(); ++p ) { | |
| 91 | if ( isfinal(*p) ) finalstateparticles.push_back(*p); | 91 | if ( isfinal(*p) ) finalstateparticles.push_back(*p); | |
| 92 | } | 92 | } | |
| Line 94... | Line 94... | |||
| 94 | // an STL-like algorithm called HepMC::copy_if is provided in the | 94 | // an STL-like algorithm called HepMC::copy_if is provided in the | |
| 95 | // GenEvent.h header to do this sort of operation more easily, | 95 | // GenEvent.h header to do this sort of operation more easily, | |
| 96 | // you could get the identical results as above by using: | 96 | // you could get the identical results as above by using: | |
| 97 | std::list<HepMC::GenParticle*> finalstateparticles2; | 97 | std::list<HepMC::GenParticle*> finalstateparticles2; | |
| 98 | HepMC::copy_if( evt->particles_begin(), evt->particles_end(), | 98 | HepMC::copy_if( evt->particles_begin(), evt->particles_end(), | |
| 99 | back_inserter(finalstateparticles2), IsFinalState() ); | - | ||
| - | 99 | back_inserter(finalstateparticles2), IsStateFinal() ); | ||
| 100 | 100 | |||
| 101 | // lets print all photons in the event that satisfy the IsPhoton criteria | 101 | // lets print all photons in the event that satisfy the IsPhoton criteria | |
| 102 | IsPhoton isphoton; | 102 | IsPhoton isphoton; | |
| 103 | for ( HepMC::GenEvent::particle_iterator p = evt->particles_begin(); | 103 | for ( HepMC::GenEvent::particle_iterator p = evt->particles_begin(); | |
| 104 | p != evt->particles_end(); ++p ) { | 104 | p != evt->particles_end(); ++p ) { | |
