TauolaHepMCEvent.cxx

00001 #include "TauolaHepMCEvent.h"
00002 #include "Log.h"
00003 
00004 using namespace std;
00005 
00006 namespace Tauolapp
00007 {
00008 
00009 TauolaHepMCEvent::TauolaHepMCEvent(HepMC::GenEvent * event){
00010   m_event=event;
00011 
00012   // Default units
00013   m_momentum_unit = "GEV";
00014   m_length_unit   = "MM";
00015 
00016   if(m_event->momentum_unit() != HepMC::Units::GEV) m_momentum_unit = "MEV";
00017   if(m_event->length_unit()   != HepMC::Units::MM ) m_length_unit   = "CM";
00018 
00019   // If needed - change units used by HepMC to GEV and MM
00020   if( m_event->momentum_unit() != HepMC::Units::GEV ||
00021       m_event->length_unit()   != HepMC::Units::MM     )
00022   {
00023     m_event->use_units(HepMC::Units::GEV,HepMC::Units::MM);
00024   }
00025 }
00026 
00027 TauolaHepMCEvent::~TauolaHepMCEvent(){
00028 
00029   while(m_tau_list.size()!=0){
00030     TauolaParticle * temp = m_tau_list.back();
00031     m_tau_list.pop_back();
00032     delete temp;
00033   }
00034 
00035 }
00036 
00037 HepMC::GenEvent * TauolaHepMCEvent::getEvent(){
00038   return m_event;
00039 }
00040 
00041 std::vector<TauolaParticle*> TauolaHepMCEvent::findParticles(int pdg_id){
00042   
00043   if(m_tau_list.size()==0){
00044 
00045     HepMC::GenEvent::particle_const_iterator part_itr = m_event->particles_begin();
00046     //loop over all particle in the event looking for taus (or other)
00047     for( ; part_itr!=m_event->particles_end(); part_itr++){
00048       if(abs((*part_itr)->pdg_id())==pdg_id)
00049         m_tau_list.push_back(new TauolaHepMCParticle(*part_itr));
00050     }
00051   }
00052   return m_tau_list;
00053 }
00054 
00055 std::vector<TauolaParticle*> TauolaHepMCEvent::findStableParticles(int pdg_id){
00056 
00057   /**  HepMC::GenEvent::particle_const_iterator part_itr = m_event->particles_begin();
00058   //loop over all particle in the event looking for taus (or other)
00059   for( ; part_itr!=m_event->particles_end(); part_itr++){
00060     if(fabs((*part_itr)->pdg_id())==pdg_id){
00061       if((*part_itr)->end_vertex()){
00062         cout << "WARNING: Particle with pdg code " << (*part_itr)->pdg_id()
00063              << " has end vertex" <<endl;
00064       }
00065       else
00066         list.push_back(new TauolaHepMCParticle(*part_itr));
00067     }
00068     }**/
00069 
00070   std::vector<TauolaParticle*> tau_list = findParticles(pdg_id);
00071   std::vector<TauolaParticle*> stable_tau_list;
00072 
00073   for(int i=0; i<(int) tau_list.size(); i++){
00074     
00075     if(!tau_list.at(i)->hasDaughters())
00076       stable_tau_list.push_back(tau_list.at(i)); 
00077     else
00078     {
00079       std::vector<TauolaParticle*> t = tau_list.at(i)->getDaughters();
00080       //Ignore taus that we won't be decaying anyway
00081       if(t.size()==1) continue;
00082       if(t.size()==2 && (abs(t[0]->getPdgID())==15 || abs(t[1]->getPdgID())==15) ) continue;
00083       Log::Warning()<<"Particle with pdg code "<<tau_list.at(i)->getPdgID()
00084                     <<" already has daughters" <<endl;
00085     }
00086   }
00087 
00088   return stable_tau_list;
00089 
00090 }
00091 
00092 void TauolaHepMCEvent::eventEndgame(){
00093 
00094   //Set output units for the event
00095   string momentum("GEV"),length("MM");
00096 
00097   switch(Tauola::momentumUnit)
00098   {
00099     case Tauola::GEV:
00100       momentum = "GEV";
00101       break;
00102     case Tauola::MEV:
00103       momentum = "MEV";
00104       break;
00105     default:
00106       momentum = m_momentum_unit;
00107   }
00108 
00109   switch(Tauola::lengthUnit)
00110   {
00111     case Tauola::MM:
00112       length = "MM";
00113       break;
00114     case Tauola::CM:
00115       length = "CM";
00116       break;
00117     default:
00118       length = m_length_unit;
00119   }
00120 
00121   m_event->use_units(momentum,length);
00122 }
00123 
00124 } // namespace Tauolapp
Generated on Sun Oct 20 20:24:11 2013 for C++InterfacetoTauola by  doxygen 1.6.3