00001 #include "AtlfastUtils/TesIO.h"
00002 #include <cmath>
00003 #include <algorithm>
00004 #include "AtlfastUtils/FunctionObjects.h"
00005 #include "GeneratorObjects/McEventCollection.h"
00006 #include "AtlfastUtils/HepMC_helper/IMCselector.h"
00007 #include "AtlfastUtils/HepMC_helper/All.h"
00008
00009 #include "AtlfastEvent/ReconstructedParticleCollection.h"
00010 #include "HepMC/GenEvent.h"
00011 #include "HepMC/GenParticle.h"
00012
00013
00014 namespace Atlfast {
00015
00016 TesIoStat TesIO::getMC(MCparticleCollection& mcParticles) const {
00017 const HepMC_helper::IMCselector* selector = new HepMC_helper::All();
00018 TesIoStat stat = this->getMC(mcParticles, selector);
00019 return stat;
00020 }
00021
00022
00023 TesIoStat TesIO::getMC(MCparticleCollection& mcParticles,
00024 const HepMC_helper::IMCselector* selector) const {
00025
00026 const DataHandle<McEventCollection> mcCollptr;
00027 TesIoStat stat = this->getDH(mcCollptr);
00028 if(!stat){
00029 return TesIoStat(StatusCode::FAILURE,"Could not find MC ptcles in TES");
00030 }
00031
00032
00033
00034
00035 McEventCollection::const_iterator itr;
00036 for (itr = mcCollptr->begin(); itr!=mcCollptr->end(); ++itr) {
00037
00038 HepMC::GenEvent* genEvt = (*itr)->pGenEvt() ;
00039 if(genEvt == 0) return TesIoStat(StatusCode::FAILURE,
00040 "Could not find HEP Gen event");
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055 GenEvent::particle_const_iterator it= genEvt->particles_begin();
00056 GenEvent::particle_const_iterator en= genEvt->particles_end();
00057 for(; it!=en; ++it){
00058 if((*selector)(*it)){mcParticles.push_back(*it);}
00059 }
00060 }
00061
00062 return TesIoStat(StatusCode::SUCCESS);
00063
00064 }
00065 }
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078