00001 #include "TruthHelper/GenAccessIO.h"
00002 #include <cmath>
00003 #include <algorithm>
00004 #include "TruthHelper/GenIMCselector.h"
00005 #include "TruthHelper/GenAll.h"
00006 #include "HepMC/GenEvent.h"
00007 #include "HepMC/GenParticle.h"
00008
00009 StatusCode GenAccessIO::getMC(MCparticleCollection& mcParticles) const {
00010 const GenIMCselector* selector = new GenAll();
00011 StatusCode stat = this->getMC(mcParticles, selector);
00012 return stat;
00013 }
00014
00015
00016 StatusCode GenAccessIO::getMC(MCparticleCollection& mcParticles,
00017 const GenIMCselector* selector) const {
00018
00019 const McEventCollection* mcCollptr;
00020 StatusCode stat = this->getDH(mcCollptr);
00021 if(!stat){
00022 return StatusCode::FAILURE;
00023 }
00024
00025
00026 McEventCollection::const_iterator itr;
00027 for (itr = mcCollptr->begin(); itr!=mcCollptr->end(); ++itr) {
00028
00029 const HepMC::GenEvent* genEvt = (*itr);
00030 if(genEvt == 0) return StatusCode::FAILURE;
00031
00032 HepMC::GenEvent::particle_const_iterator it= genEvt->particles_begin();
00033 HepMC::GenEvent::particle_const_iterator en= genEvt->particles_end();
00034 for(; it!=en; ++it){
00035 if((*selector)(*it)){mcParticles.push_back(*it);}
00036 }
00037 }
00038
00039 return StatusCode::SUCCESS;
00040
00041 }