Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members  

TesIO.cxx

Go to the documentation of this file.
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 //#include "AtlfastCode/HepMC_helper/MCselectorWrapper.h"
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     //    HepMC_helper::MCselectorWrapper wrappedSelector(selector);
00033     
00034     // Iterate over all McEvent records
00035     McEventCollection::const_iterator itr;
00036     for (itr = mcCollptr->begin(); itr!=mcCollptr->end(); ++itr) {
00037       // Access the HepMC record which is wrapped within McEvent
00038       HepMC::GenEvent* genEvt = (*itr)->pGenEvt()  ;
00039       if(genEvt == 0) return TesIoStat(StatusCode::FAILURE,
00040                                        "Could not find HEP Gen event");
00041       
00042       // Copy all final state particles of the correct type into the 
00043       // collection
00044       
00045       //      HepMC::copy_if( genEvt->particles_begin(), 
00046       //              genEvt->particles_end(),
00047       //              back_inserter( mcParticles),
00048       //              wrappedSelector
00049       //              );
00050       //      HepMC::copy_if( genEvt->particles_begin(), 
00051       //              genEvt->particles_end(),
00052       //              back_inserter( mcParticles),
00053       //              *(selector->create())
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 }//namespace
00066 
00067 
00068 
00069 
00070 
00071 
00072 
00073 
00074 
00075 
00076 
00077 
00078 

Generated on Wed Jan 15 11:00:30 2003 for AtlfastUtils by doxygen1.3-rc1