BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
GenAccessIO.cxx
Go to the documentation of this file.
2#include "HepMC/GenEvent.h"
3#include "HepMC/GenParticle.h"
6#include <algorithm>
7#include <cmath>
8
9StatusCode GenAccessIO::getMC( MCparticleCollection& mcParticles ) const {
10 const GenIMCselector* selector = new GenAll();
11 StatusCode stat = this->getMC( mcParticles, selector );
12 return stat;
13}
14
16 const GenIMCselector* selector ) const {
17
18 const McEventCollection* mcCollptr;
19 StatusCode stat = this->getDH( mcCollptr );
20 if ( !stat ) { return StatusCode::FAILURE; }
21
22 // Iterate over all McEvent records
23 McEventCollection::const_iterator itr;
24 for ( itr = mcCollptr->begin(); itr != mcCollptr->end(); ++itr )
25 {
26 // Access the HepMC record which is wrapped within McEvent
27 const HepMC::GenEvent* genEvt = ( *itr );
28 if ( genEvt == 0 ) return StatusCode::FAILURE;
29
30 HepMC::GenEvent::particle_const_iterator it = genEvt->particles_begin();
31 HepMC::GenEvent::particle_const_iterator en = genEvt->particles_end();
32 for ( ; it != en; ++it )
33 {
34 if ( ( *selector )( *it ) ) { mcParticles.push_back( *it ); }
35 }
36 }
37
38 return StatusCode::SUCCESS;
39}
std::vector< const HepMC::GenParticle * > MCparticleCollection
Definition GenAccessIO.h:17
StatusCode getMC(MCparticleCollection &) const
StatusCode getDH(const McEventCollection *&) const
Definition GenAccessIO.h:46