StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
TauolaHEPEVTEvent.cxx
1 #include "TauolaHEPEVTEvent.h"
2 
3 #include "Log.h"
4 
5 namespace Tauolapp
6 {
7 
9 {
10  for(unsigned int i=0;i<particle_list.size();i++) delete particle_list[i];
11 }
12 
14 
16 {
17  p->setEvent(this);
18 
19  p->setBarcode(particle_list.size());
20  particle_list.push_back(p);
21 }
22 
24 {
25  if( i<0 || i>=(int)particle_list.size() ) return NULL;
26  return particle_list[i];
27 }
28 
30 {
31  return particle_list.size();
32 }
33 
34 // we have conflict in names, looks for -pdg_id also...
35 std::vector<TauolaParticle*> TauolaHEPEVTEvent::findParticles(int pdg_id){
36 
37  std::vector<TauolaParticle*> list;
38 
39  // Loop over all particles in the event looking
40  // for tau (or other) particle with specified pdg_id and -pdg_id
41  for(unsigned int i=0; i<particle_list.size(); i++)
42  {
43  if( abs(particle_list[i]->getPdgID() ) == pdg_id)
44  list.push_back(particle_list[i]);
45  }
46 
47  return list;
48 }
49 
50 // we have conflict in names, should be findStableTaus or have another argument.
51 std::vector<TauolaParticle*> TauolaHEPEVTEvent::findStableParticles(int pdg_id){
52 
53  std::vector<TauolaParticle*> tau_list = findParticles(pdg_id);
54  std::vector<TauolaParticle*> stable_tau_list;
55 
56  for(int i=0; i<(int) tau_list.size(); i++){
57 
58  if(!tau_list.at(i)->hasDaughters())
59  stable_tau_list.push_back(tau_list[i]);
60  else
61  {
62  std::vector<TauolaParticle*> t = tau_list[i]->getDaughters();
63  //Ignore taus that we won't be decaying anyway
64  if(t.size()==1) continue;
65  if(t.size()==2 && (abs(t[0]->getPdgID())==15 || abs(t[1]->getPdgID())==15) ) continue;
66  Log::Warning()<<"Particle with pdg code "<<tau_list.at(i)->getPdgID()
67  <<" already has daughters" <<endl;
68  }
69  }
70 
71  return stable_tau_list;
72 
73 }
74 
76 {
77  printf("TauolaHEPEVTEvent\n-----------------\n");
78  for(unsigned int i=0;i<particle_list.size();i++) particle_list[i]->print();
79 }
80 
82 {
83  for(unsigned int i=0;i<particle_list.size();i++) delete particle_list[i];
84  particle_list.clear();
85 }
86 
87 #ifdef USE_HEPEVT_INTERFACE
88 
89 void TauolaHEPEVTEvent::read_event_from_HEPEVT(TauolaHEPEVTEvent *evt)
90 {
91  if(evt==NULL) return;
92 
93  for(int i=0; i<hepevt_.nhep; i++)
94  {
96  (
97  hepevt_.idhep [i],
98  hepevt_.isthep[i],
99  hepevt_.phep [i][0],
100  hepevt_.phep [i][1],
101  hepevt_.phep [i][2],
102  hepevt_.phep [i][3],
103  hepevt_.phep [i][4],
104  hepevt_.jmohep[i][0]-1,
105  hepevt_.jmohep[i][1]-1,
106  hepevt_.jdahep[i][0]-1,
107  hepevt_.jdahep[i][1]-1
108  );
109  evt->addParticle(p);
110  }
111 }
112 
113 void TauolaHEPEVTEvent::write_event_to_HEPEVT(TauolaHEPEVTEvent *evt)
114 {
115  if(evt==NULL) return;
116 
117  hepevt_.nhep = evt->getParticleCount();
118 
119  for(int i=0; i<hepevt_.nhep; i++)
120  {
121  TauolaHEPEVTParticle *p = evt->getParticle(i);
122 
123  hepevt_.idhep [i] =p->getPdgID();
124  hepevt_.isthep[i] =p->getStatus();
125  hepevt_.phep [i][0]=p->getPx();
126  hepevt_.phep [i][1]=p->getPy();
127  hepevt_.phep [i][2]=p->getPz();
128  hepevt_.phep [i][3]=p->getE();
129  hepevt_.phep [i][4]=p->getMass();
130  hepevt_.jmohep[i][0]=p->getFirstMotherIndex() +1;
131  hepevt_.jmohep[i][1]=p->getSecondMotherIndex() +1;
132  hepevt_.jdahep[i][0]=p->getDaughterRangeStart()+1;
133  hepevt_.jdahep[i][1]=p->getDaughterRangeEnd() +1;
134  hepevt_.vhep [i][0]=0.0;
135  hepevt_.vhep [i][1]=0.0;
136  hepevt_.vhep [i][2]=0.0;
137  hepevt_.vhep [i][3]=0.0;
138  }
139 }
140 
141 #endif
142 
143 } // namespace Tauolapp
std::vector< TauolaParticle * > findParticles(int pdgID)
void addParticle(TauolaHEPEVTParticle *p)
TauolaHEPEVTParticle * getParticle(int i)
void setEvent(TauolaHEPEVTEvent *event)
Single particle of HEPEVT event record.
std::vector< TauolaParticle * > findStableParticles(int pdgID)