1 #include "TauolaHepMCEvent.h"
9 TauolaHepMCEvent::TauolaHepMCEvent(HepMC::GenEvent * event){
13 m_momentum_unit = "GEV";
16 if(m_event->momentum_unit() != HepMC::Units::GEV) m_momentum_unit = "MEV";
17 if(m_event->length_unit() != HepMC::Units::MM ) m_length_unit = "CM";
19 // If needed - change units used by HepMC to GEV and MM
20 if( m_event->momentum_unit() != HepMC::Units::GEV ||
21 m_event->length_unit() != HepMC::Units::MM )
23 m_event->use_units(HepMC::Units::GEV,HepMC::Units::MM);
27 TauolaHepMCEvent::~TauolaHepMCEvent(){
29 while(m_tau_list.size()!=0){
30 TauolaParticle * temp = m_tau_list.back();
31 m_tau_list.pop_back();
37 HepMC::GenEvent * TauolaHepMCEvent::getEvent(){
41 std::vector<TauolaParticle*> TauolaHepMCEvent::findParticles(int pdg_id){
43 if(m_tau_list.size()==0){
45 HepMC::GenEvent::particle_const_iterator part_itr = m_event->particles_begin();
46 //loop over all particle in the event looking for taus (or other)
47 for( ; part_itr!=m_event->particles_end(); part_itr++){
48 if(abs((*part_itr)->pdg_id())==pdg_id)
49 m_tau_list.push_back(new TauolaHepMCParticle(*part_itr));
55 std::vector<TauolaParticle*> TauolaHepMCEvent::findStableParticles(int pdg_id){
57 /** HepMC::GenEvent::particle_const_iterator part_itr = m_event->particles_begin();
58 //loop over all particle in the event looking for taus (or other)
59 for( ; part_itr!=m_event->particles_end(); part_itr++){
60 if(fabs((*part_itr)->pdg_id())==pdg_id){
61 if((*part_itr)->end_vertex()){
62 cout << "WARNING: Particle with pdg code " << (*part_itr)->pdg_id()
63 << " has end vertex" <<endl;
66 list.push_back(new TauolaHepMCParticle(*part_itr));
70 std::vector<TauolaParticle*> tau_list = findParticles(pdg_id);
71 std::vector<TauolaParticle*> stable_tau_list;
73 for(int i=0; i<(int) tau_list.size(); i++){
75 if(!tau_list.at(i)->hasDaughters())
76 stable_tau_list.push_back(tau_list.at(i));
79 std::vector<TauolaParticle*> t = tau_list.at(i)->getDaughters();
80 //Ignore taus that we won't be decaying anyway
81 if(t.size()==1) continue;
82 if(t.size()==2 && (abs(t[0]->getPdgID())==15 || abs(t[1]->getPdgID())==15) ) continue;
83 Log::Warning()<<"Particle with pdg code "<<tau_list.at(i)->getPdgID()
84 <<" already has daughters" <<endl;
88 return stable_tau_list;
92 void TauolaHepMCEvent::eventEndgame(){
94 //Set output units for the event
95 string momentum("GEV"),length("MM");
97 switch(Tauola::momentumUnit)
106 momentum = m_momentum_unit;
109 switch(Tauola::lengthUnit)
118 length = m_length_unit;
121 m_event->use_units(momentum,length);
124 } // namespace Tauolapp