DecayList.cxx

00001 #include "DecayList.h"
00002 #include "Log.h"
00003 
00004 using namespace std;
00005 
00006 namespace Tauolapp
00007 {
00008 
00009 vector<TauolaParticle*> DecayList::m_particle_list;
00010 
00011 int DecayList::getAbsoluteIndex(int index){
00012   return getAbsoluteIndex(index, m_particle_list.size()+1);
00013 }
00014 
00015 int DecayList::getAbsoluteIndex(int index, 
00016                                 int neg_index_relative_to){
00017   int absIndex;
00018 
00019   if(index > 0) //absolute position
00020     absIndex = index;
00021   else //relative to fixed
00022     absIndex = index + neg_index_relative_to;
00023   //Some error checking
00024   if(absIndex < 1 || absIndex > (int)m_particle_list.size()+1){
00025     Log::Error()<<"Index outside range: "<< absIndex << ". Range: 1 to "
00026                 << m_particle_list.size()+1 << endl;
00027     Log::Fatal(4);
00028   }
00029   //  cout << "Final call in getAbsoluteIndex().. "<< absIndex << endl;
00030   return absIndex; //account for vectors starting at index 0
00031 }
00032 
00033 // NOTE: Not executed by release examples
00034 int DecayList::getAbsoluteIndex(TauolaParticle * particle){
00035   for(int i=0; i < (int) m_particle_list.size(); i++){
00036     if(m_particle_list.at(i)==particle)
00037       return i+1;
00038   }
00039   Log::Warning()<<"Could not find particle in particle_list" << endl;
00040   return 0;
00041 }
00042 
00043 TauolaParticle * DecayList::getParticle(int index){
00044   return m_particle_list.at(index-1);
00045 }
00046 
00047 void DecayList::updateList(TauolaParticle * new_particle,
00048                            int index){
00049   
00050   if(index > (int) m_particle_list.size())
00051     //Add new particle to end
00052     addToEnd(new_particle);
00053   else{ 
00054     // NOTE: Not executed by release examples
00055 
00056     TauolaParticle * old_particle = getParticle(index);
00057     //Add new particle
00058     m_particle_list.at(index - 1) = new_particle;
00059 
00060     //Remove old particle at same index in event record
00061     /**    if(old_particle->production_vertex())
00062       old_particle->production_vertex()->remove_particle(old_particle);
00063     if(old_particle->end_vertex())
00064       old_particle->end_vertex()->remove_particle(old_particle);
00065       delete old_particle;**/
00066     delete old_particle;
00067 
00068   }
00069 }
00070 
00071 void DecayList::addToEnd(TauolaParticle * new_particle){
00072   m_particle_list.push_back(new_particle);
00073 }
00074 
00075 void DecayList::print(){
00076   for(int index=0; index < (int) m_particle_list.size(); index++){
00077     Log::Info()<< "Index: "<< index+1<<" Object: "<< m_particle_list.at(index)<<endl;
00078   }
00079 }
00080   
00081 void DecayList::clear(){
00082   m_particle_list.clear();
00083 }
00084 
00085 } // namespace Tauolapp
Generated on Sun Oct 20 20:24:08 2013 for C++InterfacetoTauola by  doxygen 1.6.3