C++InterfacetoTauola
TauolaHepMC3Event.cxx
1 #include "TauolaHepMC3Event.h"
2 #include "Log.h"
3 
4 
5 
6 namespace Tauolapp
7 {
8 using namespace std;
10  m_event=event;
11  // Default units
12  m_momentum_unit = "GEV";
13  m_length_unit = "MM";
14 
15  if(m_event->momentum_unit() != Units::GEV) m_momentum_unit = "MEV";
16  if(m_event->length_unit() != Units::MM ) m_length_unit = "CM";
17 
18  // If needed - change units used by HepMC to GEV and MM
19  if( m_event->momentum_unit() != Units::GEV ||
20  m_event->length_unit() != Units::MM )
21  {
22  m_event->set_units(Units::GEV,Units::MM);
23  }
24 }
25 
26 TauolaHepMC3Event::~TauolaHepMC3Event(){
27 
28  while(m_tau_list.size()!=0){
29  TauolaParticle * temp = m_tau_list.back();
30  m_tau_list.pop_back();
31  delete temp;
32  }
33 
34 }
35 
37  return m_event;
38 }
39 
40 std::vector<TauolaParticle*> TauolaHepMC3Event::findParticles(int pdg_id){
41 
42  if(m_tau_list.size()==0){
43 
44  //loop over all particle in the event looking for taus (or other)
45  for( unsigned int i=0; i<m_event->particles().size(); ++i) {
46  if(abs((m_event->particles()[i])->pid())==pdg_id)
47  m_tau_list.push_back(new TauolaHepMC3Particle(m_event->particles()[i]));
48  }
49  }
50  return m_tau_list;
51 }
52 
53 std::vector<TauolaParticle*> TauolaHepMC3Event::findStableParticles(int pdg_id){
54 
55  /** GenEvent::particle_const_iterator part_itr = m_event->particles_begin();
56  //loop over all particle in the event looking for taus (or other)
57  for( ; part_itr!=m_event->particles_end(); part_itr++){
58  if(fabs((*part_itr)->pdg_id())==pdg_id){
59  if((*part_itr)->end_vertex()){
60  cout << "WARNING: Particle with pdg code " << (*part_itr)->pdg_id()
61  << " has end vertex" <<endl;
62  }
63  else
64  list.push_back(new TauolaHepMC3Particle(*part_itr));
65  }
66  }**/
67 
68  std::vector<TauolaParticle*> tau_list = findParticles(pdg_id);
69  std::vector<TauolaParticle*> stable_tau_list;
70 
71  for(int i=0; i<(int) tau_list.size(); i++){
72 
73  if(!tau_list.at(i)->hasDaughters())
74  stable_tau_list.push_back(tau_list.at(i));
75  else
76  {
77  std::vector<TauolaParticle*> t = tau_list.at(i)->getDaughters();
78  //Ignore taus that we won't be decaying anyway
79  if(t.size()==1) continue;
80  if(t.size()==2 && (abs(t[0]->getPdgID())==15 || abs(t[1]->getPdgID())==15) ) continue;
81  Log::Warning()<<"Particle with pdg code "<<tau_list.at(i)->getPdgID()
82  <<" already has daughters" <<endl;
83  }
84  }
85 
86  return stable_tau_list;
87 
88 }
89 
91  //Set output units for the event
92  string momentum("GEV"),length("MM");
93 
94  switch(Tauola::momentumUnit)
95  {
96  case Tauola::GEV:
97  momentum = "GEV";
98  break;
99  case Tauola::MEV:
100  momentum = "MEV";
101  break;
102  default:
103  momentum = m_momentum_unit;
104  }
105 
106  switch(Tauola::lengthUnit)
107  {
108  case Tauola::MM:
109  length = "MM";
110  break;
111  case Tauola::CM:
112  length = "CM";
113  break;
114  default:
115  length = m_length_unit;
116  }
117 
118  m_event->set_units(Units::momentum_unit(momentum),Units::length_unit(length));
119 }
120 
121 } // namespace Tauolapp
std::vector< TauolaParticle * > findParticles(int pdgID)
std::vector< TauolaParticle * > findStableParticles(int pdgID)
STL namespace.
TauolaHepMC3Event(GenEvent *event)