Line data Source code
1 : #include "DecayList.h"
2 : #include "TauolaLog.h"
3 :
4 : using namespace std;
5 :
6 : namespace Tauolapp
7 : {
8 :
9 6 : vector<TauolaParticle*> DecayList::m_particle_list;
10 :
11 : int DecayList::getAbsoluteIndex(int index){
12 0 : 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 0 : if(index > 0) //absolute position
20 0 : absIndex = index;
21 : else //relative to fixed
22 0 : absIndex = index + neg_index_relative_to;
23 : //Some error checking
24 0 : if(absIndex < 1 || absIndex > (int)m_particle_list.size()+1){
25 0 : Log::Error()<<"Index outside range: "<< absIndex << ". Range: 1 to "
26 0 : << m_particle_list.size()+1 << endl;
27 0 : Log::Fatal(4);
28 0 : }
29 : // cout << "Final call in getAbsoluteIndex().. "<< absIndex << endl;
30 0 : 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 0 : for(int i=0; i < (int) m_particle_list.size(); i++){
36 0 : if(m_particle_list.at(i)==particle)
37 0 : return i+1;
38 : }
39 0 : Log::Warning()<<"Could not find particle in particle_list" << endl;
40 0 : return 0;
41 0 : }
42 :
43 : TauolaParticle * DecayList::getParticle(int index){
44 0 : return m_particle_list.at(index-1);
45 : }
46 :
47 : void DecayList::updateList(TauolaParticle * new_particle,
48 : int index){
49 :
50 0 : if(index > (int) m_particle_list.size())
51 : //Add new particle to end
52 0 : addToEnd(new_particle);
53 : else{
54 : // NOTE: Not executed by release examples
55 :
56 0 : TauolaParticle * old_particle = getParticle(index);
57 : //Add new particle
58 0 : m_particle_list.at(index - 1) = new_particle;
59 :
60 : //Remove old particle at same index in event record
61 : /** if(old_particle->production_vertex())
62 : old_particle->production_vertex()->remove_particle(old_particle);
63 : if(old_particle->end_vertex())
64 : old_particle->end_vertex()->remove_particle(old_particle);
65 : delete old_particle;**/
66 0 : delete old_particle;
67 :
68 : }
69 0 : }
70 :
71 : void DecayList::addToEnd(TauolaParticle * new_particle){
72 0 : m_particle_list.push_back(new_particle);
73 0 : }
74 :
75 : void DecayList::print(){
76 0 : for(int index=0; index < (int) m_particle_list.size(); index++){
77 0 : Log::Info()<< "Index: "<< index+1<<" Object: "<< m_particle_list.at(index)<<endl;
78 : }
79 0 : }
80 :
81 : void DecayList::clear(){
82 0 : m_particle_list.clear();
83 0 : }
84 :
85 : } // namespace Tauolapp
|