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 /* NO UNITS YET
12  // Default units
13  m_momentum_unit = "GEV";
14  m_length_unit = "MM";
15 
16  if(m_event->momentum_unit() != Units::GEV) m_momentum_unit = "MEV";
17  if(m_event->length_unit() != Units::MM ) m_length_unit = "CM";
18 
19  // If needed - change units used by HepMC to GEV and MM
20  if( m_event->momentum_unit() != Units::GEV ||
21  m_event->length_unit() != Units::MM )
22  {
23  m_event->use_units(Units::GEV,Units::MM);
24  }
25 */
26 }
27 
28 TauolaHepMC3Event::~TauolaHepMC3Event(){
29 
30  while(m_tau_list.size()!=0){
31  TauolaParticle * temp = m_tau_list.back();
32  m_tau_list.pop_back();
33  delete temp;
34  }
35 
36 }
37 
39  return m_event;
40 }
41 
42 std::vector<TauolaParticle*> TauolaHepMC3Event::findParticles(int pdg_id){
43 
44  if(m_tau_list.size()==0){
45 
46  //loop over all particle in the event looking for taus (or other)
47  for( unsigned int i=0; i<m_event->particles().size(); ++i) {
48  if(abs((m_event->particles()[i])->pid())==pdg_id)
49  m_tau_list.push_back(new TauolaHepMC3Particle(m_event->particles()[i]));
50  }
51  }
52  return m_tau_list;
53 }
54 
55 std::vector<TauolaParticle*> TauolaHepMC3Event::findStableParticles(int pdg_id){
56 
57  /** 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;
64  }
65  else
66  list.push_back(new TauolaHepMC3Particle(*part_itr));
67  }
68  }**/
69 
70  std::vector<TauolaParticle*> tau_list = findParticles(pdg_id);
71  std::vector<TauolaParticle*> stable_tau_list;
72 
73  for(int i=0; i<(int) tau_list.size(); i++){
74 
75  if(!tau_list.at(i)->hasDaughters())
76  stable_tau_list.push_back(tau_list.at(i));
77  else
78  {
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;
85  }
86  }
87 
88  return stable_tau_list;
89 
90 }
91 
93 /* NO UNITS YET
94  //Set output units for the event
95  string momentum("GEV"),length("MM");
96 
97  switch(Tauola::momentumUnit)
98  {
99  case Tauola::GEV:
100  momentum = "GEV";
101  break;
102  case Tauola::MEV:
103  momentum = "MEV";
104  break;
105  default:
106  momentum = m_momentum_unit;
107  }
108 
109  switch(Tauola::lengthUnit)
110  {
111  case Tauola::MM:
112  length = "MM";
113  break;
114  case Tauola::CM:
115  length = "CM";
116  break;
117  default:
118  length = m_length_unit;
119  }
120 
121  m_event->use_units(momentum,length);
122 */
123 }
124 
125 } // namespace Tauolapp
std::vector< TauolaParticle * > findParticles(int pdgID)
std::vector< TauolaParticle * > findStableParticles(int pdgID)
TauolaHepMC3Event(GenEvent *event)