StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
DecayList.cxx
1 #include "DecayList.h"
2 #include "Log.h"
3 
4 using namespace std;
5 
6 namespace Tauolapp
7 {
8 
9 vector<TauolaParticle*> DecayList::m_particle_list;
10 
11 int DecayList::getAbsoluteIndex(int index){
12  return getAbsoluteIndex(index, m_particle_list.size()+1);
13 }
14 
15 int DecayList::getAbsoluteIndex(int index,
16  int neg_index_relative_to){
17  int absIndex;
18 
19  if(index > 0) //absolute position
20  absIndex = index;
21  else //relative to fixed
22  absIndex = index + neg_index_relative_to;
23  //Some error checking
24  if(absIndex < 1 || absIndex > (int)m_particle_list.size()+1){
25  Log::Error()<<"Index outside range: "<< absIndex << ". Range: 1 to "
26  << m_particle_list.size()+1 << endl;
27  Log::Fatal(4);
28  }
29  // cout << "Final call in getAbsoluteIndex().. "<< absIndex << endl;
30  return absIndex; //account for vectors starting at index 0
31 }
32 
33 // NOTE: Not executed by release examples
34 int DecayList::getAbsoluteIndex(TauolaParticle * particle){
35  for(int i=0; i < (int) m_particle_list.size(); i++){
36  if(m_particle_list.at(i)==particle)
37  return i+1;
38  }
39  Log::Warning()<<"Could not find particle in particle_list" << endl;
40  return 0;
41 }
42 
43 TauolaParticle * DecayList::getParticle(int index){
44  return m_particle_list.at(index-1);
45 }
46 
47 void DecayList::updateList(TauolaParticle * new_particle,
48  int index){
49 
50  if(index > (int) m_particle_list.size())
51  //Add new particle to end
52  addToEnd(new_particle);
53  else{
54  // NOTE: Not executed by release examples
55 
56  TauolaParticle * old_particle = getParticle(index);
57  //Add new particle
58  m_particle_list.at(index - 1) = new_particle;
59 
60  //Remove old particle at same index in event record
66  delete old_particle;
67 
68  }
69 }
70 
71 void DecayList::addToEnd(TauolaParticle * new_particle){
72  m_particle_list.push_back(new_particle);
73 }
74 
75 void DecayList::print(){
76  for(int index=0; index < (int) m_particle_list.size(); index++){
77  Log::Info()<< "Index: "<< index+1<<" Object: "<< m_particle_list.at(index)<<endl;
78  }
79 }
80 
81 void DecayList::clear(){
82  m_particle_list.clear();
83 }
84 
85 } // namespace Tauolapp
void clear()
Clear/delete all parameters held by this container.
Definition: Parameters.h:47